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/rocklife.c | |
parent | 3e2aba0c3eded353ba119e5df23968d70b1263c5 (diff) | |
download | rockbox-dc010201a5020b8b468a1a24a8fafb45a8986530.tar.gz rockbox-dc010201a5020b8b468a1a24a8fafb45a8986530.zip |
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/rocklife.c')
-rw-r--r-- | apps/plugins/rocklife.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/apps/plugins/rocklife.c b/apps/plugins/rocklife.c index 5258121ea3..35c848de1d 100644 --- a/apps/plugins/rocklife.c +++ b/apps/plugins/rocklife.c | |||
@@ -131,7 +131,7 @@ static bool load_cellfile(const char *file, char *pgrid){ | |||
131 | fd = rb->open(file, O_RDONLY); | 131 | fd = rb->open(file, O_RDONLY); |
132 | if (fd<0) | 132 | if (fd<0) |
133 | return false; | 133 | return false; |
134 | 134 | ||
135 | init_grid(pgrid); | 135 | init_grid(pgrid); |
136 | 136 | ||
137 | char c; | 137 | char c; |
@@ -143,7 +143,7 @@ static bool load_cellfile(const char *file, char *pgrid){ | |||
143 | ymid = (GRID_H>>1) - 2; | 143 | ymid = (GRID_H>>1) - 2; |
144 | comment = false; | 144 | comment = false; |
145 | 145 | ||
146 | while (true) { | 146 | while (true) { |
147 | nc = rb->read(fd, &c, 1); | 147 | nc = rb->read(fd, &c, 1); |
148 | if (nc <= 0) | 148 | if (nc <= 0) |
149 | break; | 149 | break; |
@@ -343,7 +343,7 @@ static inline bool check_cell(unsigned char *n) | |||
343 | 343 | ||
344 | /* now we build the number of non-zero neighbours :-P */ | 344 | /* now we build the number of non-zero neighbours :-P */ |
345 | alive_cells = 8 - empty_cells; | 345 | alive_cells = 8 - empty_cells; |
346 | 346 | ||
347 | if (n[4]) { | 347 | if (n[4]) { |
348 | /* If the cell is alive, it stays alive iff it has 2 or 3 alive neighbours */ | 348 | /* If the cell is alive, it stays alive iff it has 2 or 3 alive neighbours */ |
349 | result = (alive_cells==2 || alive_cells==3); | 349 | result = (alive_cells==2 || alive_cells==3); |
@@ -468,6 +468,7 @@ enum plugin_status plugin_start(const void* parameter) | |||
468 | int button = 0; | 468 | int button = 0; |
469 | int quit = 0; | 469 | int quit = 0; |
470 | int stop = 0; | 470 | int stop = 0; |
471 | int usb = 0; | ||
471 | int pattern = 0; | 472 | int pattern = 0; |
472 | char *pgrid; | 473 | char *pgrid; |
473 | char *pnext_grid; | 474 | char *pnext_grid; |
@@ -488,8 +489,7 @@ enum plugin_status plugin_start(const void* parameter) | |||
488 | pgrid = (char *)grid_a; | 489 | pgrid = (char *)grid_a; |
489 | pnext_grid = (char *)grid_b; | 490 | pnext_grid = (char *)grid_b; |
490 | 491 | ||
491 | init_grid(pgrid); | 492 | init_grid(pgrid); |
492 | |||
493 | 493 | ||
494 | if( parameter == NULL ) | 494 | if( parameter == NULL ) |
495 | { | 495 | { |
@@ -544,6 +544,11 @@ enum plugin_status plugin_start(const void* parameter) | |||
544 | stop = 1; | 544 | stop = 1; |
545 | break; | 545 | break; |
546 | default: | 546 | default: |
547 | if (rb->default_event_handler(button) == SYS_USB_CONNECTED) { | ||
548 | stop = 1; | ||
549 | quit = 1; | ||
550 | usb = 1; | ||
551 | } | ||
547 | break; | 552 | break; |
548 | } | 553 | } |
549 | rb->yield(); | 554 | rb->yield(); |
@@ -562,12 +567,12 @@ enum plugin_status plugin_start(const void* parameter) | |||
562 | break; | 567 | break; |
563 | case ROCKLIFE_QUIT: | 568 | case ROCKLIFE_QUIT: |
564 | /* quit plugin */ | 569 | /* quit plugin */ |
565 | quit=true; | 570 | quit = 1; |
566 | return PLUGIN_OK; | ||
567 | break; | 571 | break; |
568 | default: | 572 | default: |
569 | if (rb->default_event_handler(button) == SYS_USB_CONNECTED) { | 573 | if (rb->default_event_handler(button) == SYS_USB_CONNECTED) { |
570 | return PLUGIN_USB_CONNECTED; | 574 | quit = 1; |
575 | usb = 1; | ||
571 | } | 576 | } |
572 | break; | 577 | break; |
573 | } | 578 | } |
@@ -575,5 +580,5 @@ enum plugin_status plugin_start(const void* parameter) | |||
575 | } | 580 | } |
576 | 581 | ||
577 | backlight_use_settings(); /* backlight control in lib/helper.c */ | 582 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
578 | return PLUGIN_OK; | 583 | return usb? PLUGIN_USB_CONNECTED: PLUGIN_OK; |
579 | } | 584 | } |