forked from len0rd/rockbox
Handle SYS_POWEROFF event in recorder and chessbox plugins
Credit to Igor Poretsky Change-Id: I151d3511b9cee269190d87df7fa7dd355aaafc9b
This commit is contained in:
parent
7a718fc27d
commit
75fe78c802
2 changed files with 21 additions and 3 deletions
|
@ -92,6 +92,9 @@ const char *level_string[] = { "Level 1: 60 moves / 5 min" ,
|
||||||
/* "While thinking" command */
|
/* "While thinking" command */
|
||||||
int wt_command = COMMAND_NOP;
|
int wt_command = COMMAND_NOP;
|
||||||
|
|
||||||
|
/* System event id */
|
||||||
|
static long cb_sysevent = 0;
|
||||||
|
|
||||||
/* ---- Get the board column and row (e2 f.e.) for a physical x y ---- */
|
/* ---- Get the board column and row (e2 f.e.) for a physical x y ---- */
|
||||||
static void xy2cr ( short x, short y, short *c, short *r ) {
|
static void xy2cr ( short x, short y, short *c, short *r ) {
|
||||||
if (computer == black ) {
|
if (computer == black ) {
|
||||||
|
@ -189,12 +192,14 @@ static void cb_wt_callback ( void ) {
|
||||||
wt_command = COMMAND_NOP;
|
wt_command = COMMAND_NOP;
|
||||||
button = rb->button_get(false);
|
button = rb->button_get(false);
|
||||||
switch (button) {
|
switch (button) {
|
||||||
|
case SYS_POWEROFF:
|
||||||
|
cb_sysevent = button;
|
||||||
#ifdef CB_RC_QUIT
|
#ifdef CB_RC_QUIT
|
||||||
case CB_RC_QUIT:
|
case CB_RC_QUIT:
|
||||||
|
#endif
|
||||||
wt_command = COMMAND_QUIT;
|
wt_command = COMMAND_QUIT;
|
||||||
timeout = true;
|
timeout = true;
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
case CB_MENU:
|
case CB_MENU:
|
||||||
wt_command = COMMAND_MENU;
|
wt_command = COMMAND_MENU;
|
||||||
timeout = true;
|
timeout = true;
|
||||||
|
@ -531,11 +536,13 @@ static struct cb_command cb_get_viewer_command (void) {
|
||||||
while ( true ) {
|
while ( true ) {
|
||||||
button = rb->button_get(true);
|
button = rb->button_get(true);
|
||||||
switch (button) {
|
switch (button) {
|
||||||
|
case SYS_POWEROFF:
|
||||||
|
cb_sysevent = button;
|
||||||
#ifdef CB_RC_QUIT
|
#ifdef CB_RC_QUIT
|
||||||
case CB_RC_QUIT:
|
case CB_RC_QUIT:
|
||||||
|
#endif
|
||||||
result.type = COMMAND_QUIT;
|
result.type = COMMAND_QUIT;
|
||||||
return result;
|
return result;
|
||||||
#endif
|
|
||||||
#ifdef CB_RESTART
|
#ifdef CB_RESTART
|
||||||
case CB_RESTART:
|
case CB_RESTART:
|
||||||
result.type = COMMAND_RESTART;
|
result.type = COMMAND_RESTART;
|
||||||
|
@ -764,11 +771,13 @@ static struct cb_command cb_getcommand (void) {
|
||||||
while ( true ) {
|
while ( true ) {
|
||||||
button = rb->button_get(true);
|
button = rb->button_get(true);
|
||||||
switch (button) {
|
switch (button) {
|
||||||
|
case SYS_POWEROFF:
|
||||||
|
cb_sysevent = button;
|
||||||
#ifdef CB_RC_QUIT
|
#ifdef CB_RC_QUIT
|
||||||
case CB_RC_QUIT:
|
case CB_RC_QUIT:
|
||||||
|
#endif
|
||||||
result.type = COMMAND_QUIT;
|
result.type = COMMAND_QUIT;
|
||||||
return result;
|
return result;
|
||||||
#endif
|
|
||||||
#ifdef CB_RESTART
|
#ifdef CB_RESTART
|
||||||
case CB_RESTART:
|
case CB_RESTART:
|
||||||
result.type = COMMAND_RESTART;
|
result.type = COMMAND_RESTART;
|
||||||
|
@ -1058,6 +1067,7 @@ enum plugin_status plugin_start(const void* parameter) {
|
||||||
#if LCD_DEPTH > 1
|
#if LCD_DEPTH > 1
|
||||||
rb->lcd_set_backdrop(NULL);
|
rb->lcd_set_backdrop(NULL);
|
||||||
#endif
|
#endif
|
||||||
|
cb_sysevent = 0;
|
||||||
|
|
||||||
/* end of plugin init */
|
/* end of plugin init */
|
||||||
|
|
||||||
|
@ -1070,5 +1080,8 @@ enum plugin_status plugin_start(const void* parameter) {
|
||||||
cb_play_game();
|
cb_play_game();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cb_sysevent)
|
||||||
|
rb->default_event_handler(cb_sysevent);
|
||||||
|
|
||||||
return PLUGIN_OK;
|
return PLUGIN_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1615,6 +1615,11 @@ bool recording_screen(bool no_source)
|
||||||
break;
|
break;
|
||||||
#endif /* CONFIG_KEYPAD == RECORDER_PAD */
|
#endif /* CONFIG_KEYPAD == RECORDER_PAD */
|
||||||
|
|
||||||
|
case SYS_POWEROFF:
|
||||||
|
default_event_handler(SYS_POWEROFF);
|
||||||
|
done = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case SYS_USB_CONNECTED:
|
case SYS_USB_CONNECTED:
|
||||||
/* Only accept USB connection when not recording */
|
/* Only accept USB connection when not recording */
|
||||||
if(!(audio_stat & AUDIO_STATUS_RECORD))
|
if(!(audio_stat & AUDIO_STATUS_RECORD))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue