1
0
Fork 0
forked from len0rd/rockbox

make sure plugin reset backlight setting before exit. do code polish.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24076 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Teruaki Kawashima 2009-12-18 14:17:28 +00:00
parent 3e2aba0c3e
commit dc010201a5
9 changed files with 73 additions and 71 deletions

View file

@ -634,12 +634,12 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame
return SYS_PHONE_UNPLUGGED; return SYS_PHONE_UNPLUGGED;
#endif #endif
#ifdef IPOD_ACCESSORY_PROTOCOL #ifdef IPOD_ACCESSORY_PROTOCOL
case SYS_IAP_PERIODIC: case SYS_IAP_PERIODIC:
iap_periodic(); iap_periodic();
return SYS_IAP_PERIODIC; return SYS_IAP_PERIODIC;
case SYS_IAP_HANDLEPKT: case SYS_IAP_HANDLEPKT:
iap_handlepkt(); iap_handlepkt();
return SYS_IAP_HANDLEPKT; return SYS_IAP_HANDLEPKT;
#endif #endif
} }
return 0; return 0;
@ -857,14 +857,14 @@ void format_time(char* buf, int buf_size, long t)
{ {
if ( t < 3600000 ) if ( t < 3600000 )
{ {
snprintf(buf, buf_size, "%d:%02d", snprintf(buf, buf_size, "%d:%02d",
(int) (t / 60000), (int) (t % 60000 / 1000)); (int) (t / 60000), (int) (t % 60000 / 1000));
} }
else else
{ {
snprintf(buf, buf_size, "%d:%02d:%02d", snprintf(buf, buf_size, "%d:%02d:%02d",
(int) (t / 3600000), (int) (t % 3600000 / 60000), (int) (t / 3600000), (int) (t % 3600000 / 60000),
(int) (t % 60000 / 1000)); (int) (t % 60000 / 1000));
} }
} }
@ -895,7 +895,7 @@ int open_utf8(const char* pathname, int flags)
read(fd, bom, BOM_SIZE); read(fd, bom, BOM_SIZE);
/* check for BOM */ /* check for BOM */
if(memcmp(bom, BOM, BOM_SIZE)) if(memcmp(bom, BOM, BOM_SIZE))
lseek(fd, 0, SEEK_SET); lseek(fd, 0, SEEK_SET);
} }
return fd; return fd;
} }
@ -908,8 +908,8 @@ int open_utf8(const char* pathname, int flags)
static int hex2dec(int c) static int hex2dec(int c)
{ {
return (((c) >= '0' && ((c) <= '9')) ? (c) - '0' : return (((c) >= '0' && ((c) <= '9')) ? (c) - '0' :
(toupper(c)) - 'A' + 10); (toupper(c)) - 'A' + 10);
} }
int hex_to_rgb(const char* hex, int* color) int hex_to_rgb(const char* hex, int* color)
@ -986,7 +986,7 @@ const char* parse_list(const char *fmt, uint32_t *set_vals,
*s = p; *s = p;
while (*p && *p != sep) while (*p && *p != sep)
p++; p++;
set = (s[0][0]!='-') && (s[0][1]!=sep) ; set = (s[0][0]!='-') && (s[0][1]!=sep) ;
break; break;
@ -1007,9 +1007,9 @@ const char* parse_list(const char *fmt, uint32_t *set_vals,
} }
else else
{ {
*d = *p++ - '0'; *d = *p++ - '0';
while (isdigit(*p)) while (isdigit(*p))
*d = (*d * 10) + (*p++ - '0'); *d = (*d * 10) + (*p++ - '0');
set = true; set = true;
if (is_negative) if (is_negative)
*d *= -1; *d *= -1;

View file

@ -136,7 +136,7 @@ enum {
#define BJACK_LEFT BUTTON_LEFT #define BJACK_LEFT BUTTON_LEFT
#elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
#define BJACK_SELECT_NAME "PLAY" #define BJACK_SELECT_NAME "SELECT"
#define BJACK_STAY_NAME "REC" #define BJACK_STAY_NAME "REC"
#define BJACK_RESUME_NAME "DOWN" #define BJACK_RESUME_NAME "DOWN"
#define BJACK_QUIT_NAME "POWER" #define BJACK_QUIT_NAME "POWER"

View file

@ -278,5 +278,3 @@ enum plugin_status plugin_start(const void* parameter)
} }
} }
} }

View file

@ -676,7 +676,7 @@ static void play_game()
{ {
int old_x = robot.x; int old_x = robot.x;
int old_y = robot.y; int old_y = robot.y;
int input = 0; /* Not sure what a reasonable initial value is */ int input = BUTTON_NONE;
#ifdef __PLUGINLIB_ACTIONS_H__ #ifdef __PLUGINLIB_ACTIONS_H__
const struct button_mapping *plugin_contexts[] = {generic_directions, generic_actions}; const struct button_mapping *plugin_contexts[] = {generic_directions, generic_actions};
#endif #endif

View file

@ -468,6 +468,7 @@ enum plugin_status plugin_start(const void* parameter)
int button = 0; int button = 0;
int quit = 0; int quit = 0;
int stop = 0; int stop = 0;
int usb = 0;
int pattern = 0; int pattern = 0;
char *pgrid; char *pgrid;
char *pnext_grid; char *pnext_grid;
@ -490,7 +491,6 @@ enum plugin_status plugin_start(const void* parameter)
init_grid(pgrid); init_grid(pgrid);
if( parameter == NULL ) if( parameter == NULL )
{ {
setup_grid(pgrid, pattern++); setup_grid(pgrid, pattern++);
@ -544,6 +544,11 @@ enum plugin_status plugin_start(const void* parameter)
stop = 1; stop = 1;
break; break;
default: default:
if (rb->default_event_handler(button) == SYS_USB_CONNECTED) {
stop = 1;
quit = 1;
usb = 1;
}
break; break;
} }
rb->yield(); rb->yield();
@ -562,12 +567,12 @@ enum plugin_status plugin_start(const void* parameter)
break; break;
case ROCKLIFE_QUIT: case ROCKLIFE_QUIT:
/* quit plugin */ /* quit plugin */
quit=true; quit = 1;
return PLUGIN_OK;
break; break;
default: default:
if (rb->default_event_handler(button) == SYS_USB_CONNECTED) { if (rb->default_event_handler(button) == SYS_USB_CONNECTED) {
return PLUGIN_USB_CONNECTED; quit = 1;
usb = 1;
} }
break; break;
} }
@ -575,5 +580,5 @@ enum plugin_status plugin_start(const void* parameter)
} }
backlight_use_settings(); /* backlight control in lib/helper.c */ backlight_use_settings(); /* backlight control in lib/helper.c */
return PLUGIN_OK; return usb? PLUGIN_USB_CONNECTED: PLUGIN_OK;
} }

View file

@ -482,8 +482,6 @@ int plugin_main(void)
#endif #endif
case(STARFIELD_QUIT): case(STARFIELD_QUIT):
case(SYS_USB_CONNECTED): case(SYS_USB_CONNECTED):
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c*/
return PLUGIN_OK; return PLUGIN_OK;
break; break;
} }
@ -502,6 +500,9 @@ enum plugin_status plugin_start(const void* parameter)
ret = plugin_main(); ret = plugin_main();
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c*/
return ret; return ret;
} }

View file

@ -86,7 +86,7 @@ char* _do_action(int action, char* str, int line)
break; break;
case ACTION_REMOVE: case ACTION_REMOVE:
if (line > line_count) if (line > line_count)
return 0; return NULL;
len = rb->strlen(&buffer[c])+1; len = rb->strlen(&buffer[c])+1;
rb->memmove(&buffer[c],&buffer[c+len],char_count-c-len); rb->memmove(&buffer[c],&buffer[c+len],char_count-c-len);
char_count -= len; char_count -= len;
@ -225,7 +225,7 @@ enum {
}; };
int do_item_menu(int cur_sel, char* copy_buffer) int do_item_menu(int cur_sel, char* copy_buffer)
{ {
int ret = 0; int ret = MENU_RET_NO_UPDATE;
MENUITEM_STRINGLIST(menu, "Line Options", NULL, MENUITEM_STRINGLIST(menu, "Line Options", NULL,
"Cut/Delete", "Copy", "Cut/Delete", "Copy",
"Insert Above", "Insert Below", "Insert Above", "Insert Below",

View file

@ -1,12 +1,11 @@
/*************************************************************************** /***************************************************************************
*
* __________ __ ___. * __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* * $Id$
* *
* Copyright (C) 2002 Gilles Roux, 2003 Garrett Derner * Copyright (C) 2002 Gilles Roux, 2003 Garrett Derner
* *
@ -432,7 +431,6 @@ struct preferences {
} scroll_mode; } scroll_mode;
int autoscroll_speed; int autoscroll_speed;
}; };
struct preferences prefs; struct preferences prefs;