diff options
| author | Teruaki Kawashima <teru@rockbox.org> | 2009-12-18 14:17:28 +0000 |
|---|---|---|
| committer | Teruaki Kawashima <teru@rockbox.org> | 2009-12-18 14:17:28 +0000 |
| commit | dc010201a5020b8b468a1a24a8fafb45a8986530 (patch) | |
| tree | d07b364d2ee16ed4d0c4c9ad9818096c7e57f536 /apps/plugins | |
| parent | 3e2aba0c3eded353ba119e5df23968d70b1263c5 (diff) | |
| download | rockbox-dc010201a5020b8b468a1a24a8fafb45a8986530.zip rockbox-dc010201a5020b8b468a1a24a8fafb45a8986530.tar.gz rockbox-dc010201a5020b8b468a1a24a8fafb45a8986530.tar.bz2 rockbox-dc010201a5020b8b468a1a24a8fafb45a8986530.tar.xz | |
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
Diffstat (limited to 'apps/plugins')
| -rw-r--r-- | apps/plugins/SOURCES | 2 | ||||
| -rw-r--r-- | apps/plugins/blackjack.c | 2 | ||||
| -rw-r--r-- | apps/plugins/mosaique.c | 12 | ||||
| -rw-r--r-- | apps/plugins/robotfindskitten.c | 2 | ||||
| -rw-r--r-- | apps/plugins/rocklife.c | 23 | ||||
| -rw-r--r-- | apps/plugins/starfield.c | 5 | ||||
| -rw-r--r-- | apps/plugins/text_editor.c | 4 | ||||
| -rw-r--r-- | apps/plugins/viewer.c | 24 |
8 files changed, 38 insertions, 36 deletions
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index 76a0b57..a3ce60f 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES @@ -64,7 +64,7 @@ rockblox1d.c brickmania.c calendar.c maze.c -mazezam.c +mazezam.c text_editor.c wavview.c robotfindskitten.c diff --git a/apps/plugins/blackjack.c b/apps/plugins/blackjack.c index 3854799..315f21f 100644 --- a/apps/plugins/blackjack.c +++ b/apps/plugins/blackjack.c @@ -136,7 +136,7 @@ enum { #define BJACK_LEFT BUTTON_LEFT #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD -#define BJACK_SELECT_NAME "PLAY" +#define BJACK_SELECT_NAME "SELECT" #define BJACK_STAY_NAME "REC" #define BJACK_RESUME_NAME "DOWN" #define BJACK_QUIT_NAME "POWER" diff --git a/apps/plugins/mosaique.c b/apps/plugins/mosaique.c index 51005fd..0f3e9ff 100644 --- a/apps/plugins/mosaique.c +++ b/apps/plugins/mosaique.c @@ -208,20 +208,20 @@ enum plugin_status plugin_start(const void* parameter) x = 2*GFX_WIDTH-x; sx=-sx; } - + if (x<0) { x = -x; sx = -sx; } - + y+=sy; if (y>GFX_HEIGHT) { y = 2*GFX_HEIGHT-y; sy=-sy; } - + if (y<0) { y = -y; @@ -235,7 +235,7 @@ enum plugin_status plugin_start(const void* parameter) MYLCD(update)(); rb->sleep(HZ/timer); - + button = rb->button_get(false); switch (button) { @@ -254,7 +254,7 @@ enum plugin_status plugin_start(const void* parameter) if (timer>20) timer=5; break; - + case MOSAIQUE_RESTART: sx = rb->rand() % (GFX_HEIGHT/2) + 1; @@ -278,5 +278,3 @@ enum plugin_status plugin_start(const void* parameter) } } } - - diff --git a/apps/plugins/robotfindskitten.c b/apps/plugins/robotfindskitten.c index a2bff3b..5cd0e46 100644 --- a/apps/plugins/robotfindskitten.c +++ b/apps/plugins/robotfindskitten.c @@ -676,7 +676,7 @@ static void play_game() { int old_x = robot.x; int old_y = robot.y; - int input = 0; /* Not sure what a reasonable initial value is */ + int input = BUTTON_NONE; #ifdef __PLUGINLIB_ACTIONS_H__ const struct button_mapping *plugin_contexts[] = {generic_directions, generic_actions}; #endif diff --git a/apps/plugins/rocklife.c b/apps/plugins/rocklife.c index 5258121..35c848d 100644 --- a/apps/plugins/rocklife.c +++ b/apps/plugins/rocklife.c @@ -131,7 +131,7 @@ static bool load_cellfile(const char *file, char *pgrid){ fd = rb->open(file, O_RDONLY); if (fd<0) return false; - + init_grid(pgrid); char c; @@ -143,7 +143,7 @@ static bool load_cellfile(const char *file, char *pgrid){ ymid = (GRID_H>>1) - 2; comment = false; - while (true) { + while (true) { nc = rb->read(fd, &c, 1); if (nc <= 0) break; @@ -343,7 +343,7 @@ static inline bool check_cell(unsigned char *n) /* now we build the number of non-zero neighbours :-P */ alive_cells = 8 - empty_cells; - + if (n[4]) { /* If the cell is alive, it stays alive iff it has 2 or 3 alive neighbours */ result = (alive_cells==2 || alive_cells==3); @@ -468,6 +468,7 @@ enum plugin_status plugin_start(const void* parameter) int button = 0; int quit = 0; int stop = 0; + int usb = 0; int pattern = 0; char *pgrid; char *pnext_grid; @@ -488,8 +489,7 @@ enum plugin_status plugin_start(const void* parameter) pgrid = (char *)grid_a; pnext_grid = (char *)grid_b; - init_grid(pgrid); - + init_grid(pgrid); if( parameter == NULL ) { @@ -544,6 +544,11 @@ enum plugin_status plugin_start(const void* parameter) stop = 1; break; default: + if (rb->default_event_handler(button) == SYS_USB_CONNECTED) { + stop = 1; + quit = 1; + usb = 1; + } break; } rb->yield(); @@ -562,12 +567,12 @@ enum plugin_status plugin_start(const void* parameter) break; case ROCKLIFE_QUIT: /* quit plugin */ - quit=true; - return PLUGIN_OK; + quit = 1; break; default: if (rb->default_event_handler(button) == SYS_USB_CONNECTED) { - return PLUGIN_USB_CONNECTED; + quit = 1; + usb = 1; } break; } @@ -575,5 +580,5 @@ enum plugin_status plugin_start(const void* parameter) } backlight_use_settings(); /* backlight control in lib/helper.c */ - return PLUGIN_OK; + return usb? PLUGIN_USB_CONNECTED: PLUGIN_OK; } diff --git a/apps/plugins/starfield.c b/apps/plugins/starfield.c index 4a680ee..0da3305 100644 --- a/apps/plugins/starfield.c +++ b/apps/plugins/starfield.c @@ -482,8 +482,6 @@ int plugin_main(void) #endif case(STARFIELD_QUIT): case(SYS_USB_CONNECTED): - /* Turn on backlight timeout (revert to settings) */ - backlight_use_settings(); /* backlight control in lib/helper.c*/ return PLUGIN_OK; break; } @@ -502,6 +500,9 @@ enum plugin_status plugin_start(const void* parameter) ret = plugin_main(); + /* Turn on backlight timeout (revert to settings) */ + backlight_use_settings(); /* backlight control in lib/helper.c*/ + return ret; } diff --git a/apps/plugins/text_editor.c b/apps/plugins/text_editor.c index a8c8c2d..4d5812b 100644 --- a/apps/plugins/text_editor.c +++ b/apps/plugins/text_editor.c @@ -86,7 +86,7 @@ char* _do_action(int action, char* str, int line) break; case ACTION_REMOVE: if (line > line_count) - return 0; + return NULL; len = rb->strlen(&buffer[c])+1; rb->memmove(&buffer[c],&buffer[c+len],char_count-c-len); char_count -= len; @@ -225,7 +225,7 @@ enum { }; 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, "Cut/Delete", "Copy", "Insert Above", "Insert Below", diff --git a/apps/plugins/viewer.c b/apps/plugins/viewer.c index a212885..88b43c3 100644 --- a/apps/plugins/viewer.c +++ b/apps/plugins/viewer.c @@ -1,12 +1,11 @@ /*************************************************************************** - * * __________ __ ___. * Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ - * + * $Id$ * * Copyright (C) 2002 Gilles Roux, 2003 Garrett Derner * @@ -432,7 +431,6 @@ struct preferences { } scroll_mode; int autoscroll_speed; - }; struct preferences prefs; @@ -1226,7 +1224,7 @@ static void viewer_load_settings(void) /* same name as global, but not the same int settings_fd, i; struct bookmark_file_data *data; struct bookmarked_file_info this_bookmark; - + /* read settings file */ settings_fd=rb->open(SETTINGS_FILE, O_RDONLY); if ((settings_fd >= 0) && (rb->filesize(settings_fd) == sizeof(struct preferences))) @@ -1271,7 +1269,7 @@ static void viewer_load_settings(void) /* same name as global, but not the same file_pos = screen_pos - screen_top; screen_top_ptr = buffer + screen_top; break; - } + } } this_bookmark.file_position = file_pos; @@ -1284,16 +1282,16 @@ static void viewer_load_settings(void) /* same name as global, but not the same if (i >= data->bookmarked_files_count) { if (i < MAX_BOOKMARKED_FILES) - data->bookmarked_files_count++; - else + data->bookmarked_files_count++; + else i = MAX_BOOKMARKED_FILES-1; - } + } /* write bookmark file with spare slot in first position to be filled in by viewer_save_settings */ settings_fd = rb->open(BOOKMARKS_FILE, O_WRONLY|O_CREAT); if (settings_fd >=0 ) - { + { /* write count */ rb->write (settings_fd, &data->bookmarked_files_count, sizeof(signed int)); @@ -1336,7 +1334,7 @@ static void viewer_save_settings(void)/* same name as global, but not the same f rb->close(settings_fd); } } - + /* save the bookmark if the position has changed */ if (file_pos + screen_top_ptr - buffer != start_position) { @@ -1559,11 +1557,11 @@ enum plugin_status plugin_start(const void* file) } viewer_load_settings(); /* load the preferences and bookmark */ - + #if LCD_DEPTH > 1 rb->lcd_set_backdrop(NULL); #endif - + viewer_draw(col); while (!done) { @@ -1577,7 +1575,7 @@ enum plugin_status plugin_start(const void* file) old_tick = *rb->current_tick; } } - + button = rb->button_get_w_tmo(HZ/10); switch (button) { case VIEWER_MENU: |