diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/maze.c | 46 | ||||
-rw-r--r-- | apps/plugins/mazezam.c | 64 |
2 files changed, 78 insertions, 32 deletions
diff --git a/apps/plugins/maze.c b/apps/plugins/maze.c index 881d804400..307f14d86a 100644 --- a/apps/plugins/maze.c +++ b/apps/plugins/maze.c | |||
@@ -38,7 +38,6 @@ PLUGIN_HEADER | |||
38 | /* key assignments */ | 38 | /* key assignments */ |
39 | 39 | ||
40 | #if (CONFIG_KEYPAD == IPOD_4G_PAD) || \ | 40 | #if (CONFIG_KEYPAD == IPOD_4G_PAD) || \ |
41 | (CONFIG_KEYPAD == IPOD_3G_PAD) || \ | ||
42 | (CONFIG_KEYPAD == IPOD_1G2G_PAD) | 41 | (CONFIG_KEYPAD == IPOD_1G2G_PAD) |
43 | # define MAZE_NEW (BUTTON_SELECT | BUTTON_REPEAT) | 42 | # define MAZE_NEW (BUTTON_SELECT | BUTTON_REPEAT) |
44 | # define MAZE_NEW_PRE BUTTON_SELECT | 43 | # define MAZE_NEW_PRE BUTTON_SELECT |
@@ -48,10 +47,34 @@ PLUGIN_HEADER | |||
48 | # define MAZE_LEFT BUTTON_LEFT | 47 | # define MAZE_LEFT BUTTON_LEFT |
49 | # define MAZE_UP BUTTON_MENU | 48 | # define MAZE_UP BUTTON_MENU |
50 | # define MAZE_DOWN BUTTON_PLAY | 49 | # define MAZE_DOWN BUTTON_PLAY |
51 | # define MAZE_RRIGHT (BUTTON_RIGHT | BUTTON_REPEAT) | 50 | |
52 | # define MAZE_RLEFT (BUTTON_LEFT | BUTTON_REPEAT) | 51 | #elif (CONFIG_KEYPAD == IPOD_3G_PAD) |
53 | # define MAZE_RUP (BUTTON_MENU | BUTTON_REPEAT) | 52 | # define MAZE_NEW (BUTTON_SELECT | BUTTON_REPEAT) |
54 | # define MAZE_RDOWN (BUTTON_PLAY | BUTTON_REPEAT) | 53 | # define MAZE_NEW_PRE BUTTON_SELECT |
54 | # define MAZE_QUIT BUTTON_MENU | ||
55 | # define MAZE_SOLVE (BUTTON_SELECT | BUTTON_PLAY) | ||
56 | # define MAZE_RIGHT BUTTON_RIGHT | ||
57 | # define MAZE_LEFT BUTTON_LEFT | ||
58 | # define MAZE_UP BUTTON_SCROLL_BACK | ||
59 | # define MAZE_DOWN BUTTON_SCROLL_FWD | ||
60 | |||
61 | #elif (CONFIG_KEYPAD == SANSA_FUZE_PAD) | ||
62 | # define MAZE_NEW (BUTTON_SELECT | BUTTON_REPEAT) | ||
63 | # define MAZE_QUIT (BUTTON_HOME | BUTTON_REPEAT) | ||
64 | # define MAZE_SOLVE BUTTON_SELECT | ||
65 | # define MAZE_RIGHT BUTTON_RIGHT | ||
66 | # define MAZE_LEFT BUTTON_LEFT | ||
67 | # define MAZE_UP BUTTON_UP | ||
68 | # define MAZE_DOWN BUTTON_DOWN | ||
69 | |||
70 | #elif (CONFIG_KEYPAD == SANSA_E200_PAD) | ||
71 | # define MAZE_NEW (BUTTON_SELECT | BUTTON_REPEAT) | ||
72 | # define MAZE_QUIT BUTTON_POWER | ||
73 | # define MAZE_SOLVE BUTTON_SELECT | ||
74 | # define MAZE_RIGHT BUTTON_RIGHT | ||
75 | # define MAZE_LEFT BUTTON_LEFT | ||
76 | # define MAZE_UP BUTTON_UP | ||
77 | # define MAZE_DOWN BUTTON_DOWN | ||
55 | 78 | ||
56 | #else | 79 | #else |
57 | # include "lib/pluginlib_actions.h" | 80 | # include "lib/pluginlib_actions.h" |
@@ -62,10 +85,6 @@ PLUGIN_HEADER | |||
62 | # define MAZE_LEFT PLA_LEFT | 85 | # define MAZE_LEFT PLA_LEFT |
63 | # define MAZE_UP PLA_UP | 86 | # define MAZE_UP PLA_UP |
64 | # define MAZE_DOWN PLA_DOWN | 87 | # define MAZE_DOWN PLA_DOWN |
65 | # define MAZE_RRIGHT PLA_RIGHT_REPEAT | ||
66 | # define MAZE_RLEFT PLA_LEFT_REPEAT | ||
67 | # define MAZE_RUP PLA_UP_REPEAT | ||
68 | # define MAZE_RDOWN PLA_DOWN_REPEAT | ||
69 | static const struct button_mapping *plugin_contexts[] | 88 | static const struct button_mapping *plugin_contexts[] |
70 | = {generic_directions, generic_actions}; | 89 | = {generic_directions, generic_actions}; |
71 | 90 | ||
@@ -548,25 +567,25 @@ enum plugin_status plugin_start(const void* parameter) | |||
548 | maze_draw(&maze, rb->screens[i]); | 567 | maze_draw(&maze, rb->screens[i]); |
549 | break; | 568 | break; |
550 | case MAZE_UP: | 569 | case MAZE_UP: |
551 | case MAZE_RUP: | 570 | case (MAZE_UP|BUTTON_REPEAT): |
552 | maze_move_player_up(&maze); | 571 | maze_move_player_up(&maze); |
553 | FOR_NB_SCREENS(i) | 572 | FOR_NB_SCREENS(i) |
554 | maze_draw(&maze, rb->screens[i]); | 573 | maze_draw(&maze, rb->screens[i]); |
555 | break; | 574 | break; |
556 | case MAZE_RIGHT: | 575 | case MAZE_RIGHT: |
557 | case MAZE_RRIGHT: | 576 | case (MAZE_RIGHT|BUTTON_REPEAT): |
558 | maze_move_player_right(&maze); | 577 | maze_move_player_right(&maze); |
559 | FOR_NB_SCREENS(i) | 578 | FOR_NB_SCREENS(i) |
560 | maze_draw(&maze, rb->screens[i]); | 579 | maze_draw(&maze, rb->screens[i]); |
561 | break; | 580 | break; |
562 | case MAZE_DOWN: | 581 | case MAZE_DOWN: |
563 | case MAZE_RDOWN: | 582 | case (MAZE_DOWN|BUTTON_REPEAT): |
564 | maze_move_player_down(&maze); | 583 | maze_move_player_down(&maze); |
565 | FOR_NB_SCREENS(i) | 584 | FOR_NB_SCREENS(i) |
566 | maze_draw(&maze, rb->screens[i]); | 585 | maze_draw(&maze, rb->screens[i]); |
567 | break; | 586 | break; |
568 | case MAZE_LEFT: | 587 | case MAZE_LEFT: |
569 | case MAZE_RLEFT: | 588 | case (MAZE_LEFT|BUTTON_REPEAT): |
570 | maze_move_player_left(&maze); | 589 | maze_move_player_left(&maze); |
571 | FOR_NB_SCREENS(i) | 590 | FOR_NB_SCREENS(i) |
572 | maze_draw(&maze, rb->screens[i]); | 591 | maze_draw(&maze, rb->screens[i]); |
@@ -584,7 +603,6 @@ enum plugin_status plugin_start(const void* parameter) | |||
584 | } | 603 | } |
585 | if( button != BUTTON_NONE ) | 604 | if( button != BUTTON_NONE ) |
586 | lastbutton = button; | 605 | lastbutton = button; |
587 | |||
588 | } | 606 | } |
589 | /* Turn on backlight timeout (revert to settings) */ | 607 | /* Turn on backlight timeout (revert to settings) */ |
590 | backlight_use_settings(); /* backlight control in lib/helper.c */ | 608 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
diff --git a/apps/plugins/mazezam.c b/apps/plugins/mazezam.c index ac7e651fbc..92f9def274 100644 --- a/apps/plugins/mazezam.c +++ b/apps/plugins/mazezam.c | |||
@@ -22,27 +22,51 @@ | |||
22 | #include "plugin.h" | 22 | #include "plugin.h" |
23 | #include "lib/configfile.h" | 23 | #include "lib/configfile.h" |
24 | #include "lib/helper.h" | 24 | #include "lib/helper.h" |
25 | #include "lib/pluginlib_actions.h" | ||
26 | #include "lib/playback_control.h" | 25 | #include "lib/playback_control.h" |
27 | 26 | ||
28 | /* Include standard plugin macro */ | 27 | /* Include standard plugin macro */ |
29 | PLUGIN_HEADER | 28 | PLUGIN_HEADER |
30 | 29 | ||
31 | /* The plugin actions of interest. */ | 30 | #if (CONFIG_KEYPAD == IPOD_4G_PAD) || \ |
31 | (CONFIG_KEYPAD == IPOD_1G2G_PAD) | ||
32 | # define MAZEZAM_MENU (BUTTON_SELECT | BUTTON_MENU) | ||
33 | # define MAZEZAM_RIGHT BUTTON_RIGHT | ||
34 | # define MAZEZAM_LEFT BUTTON_LEFT | ||
35 | # define MAZEZAM_UP BUTTON_MENU | ||
36 | # define MAZEZAM_DOWN BUTTON_PLAY | ||
37 | |||
38 | #elif (CONFIG_KEYPAD == IPOD_3G_PAD) | ||
39 | # define MAZE_QUIT BUTTON_MENU | ||
40 | # define MAZE_RIGHT BUTTON_RIGHT | ||
41 | # define MAZE_LEFT BUTTON_LEFT | ||
42 | # define MAZE_UP BUTTON_SCROLL_BACK | ||
43 | # define MAZE_DOWN BUTTON_SCROLL_FWD | ||
44 | |||
45 | #elif (CONFIG_KEYPAD == SANSA_FUZE_PAD) | ||
46 | # define MAZEZAM_MENU (BUTTON_HOME | BUTTON_REPEAT) | ||
47 | # define MAZEZAM_RIGHT BUTTON_RIGHT | ||
48 | # define MAZEZAM_LEFT BUTTON_LEFT | ||
49 | # define MAZEZAM_UP BUTTON_UP | ||
50 | # define MAZEZAM_DOWN BUTTON_DOWN | ||
51 | |||
52 | #elif (CONFIG_KEYPAD == SANSA_E200_PAD) | ||
53 | # define MAZEZAM_MENU BUTTON_POWER | ||
54 | # define MAZEZAM_SOLVE BUTTON_SELECT | ||
55 | # define MAZEZAM_RIGHT BUTTON_RIGHT | ||
56 | # define MAZEZAM_LEFT BUTTON_LEFT | ||
57 | # define MAZEZAM_UP BUTTON_UP | ||
58 | # define MAZEZAM_DOWN BUTTON_DOWN | ||
59 | |||
60 | #else | ||
61 | # include "lib/pluginlib_actions.h" | ||
62 | # define MAZEZAM_MENU PLA_QUIT | ||
63 | # define MAZEZAM_RIGHT PLA_RIGHT | ||
64 | # define MAZEZAM_LEFT PLA_LEFT | ||
65 | # define MAZEZAM_UP PLA_UP | ||
66 | # define MAZEZAM_DOWN PLA_DOWN | ||
32 | const struct button_mapping *plugin_contexts[] | 67 | const struct button_mapping *plugin_contexts[] |
33 | = {generic_directions, generic_actions}; | 68 | = {generic_directions, generic_actions}; |
34 | 69 | #endif | |
35 | /* Use the standard plugin buttons rather than a hard-to-maintain list of | ||
36 | * MazezaM specific buttons. */ | ||
37 | #define MAZEZAM_UP PLA_UP | ||
38 | #define MAZEZAM_UP_REPEAT PLA_UP_REPEAT | ||
39 | #define MAZEZAM_DOWN PLA_DOWN | ||
40 | #define MAZEZAM_DOWN_REPEAT PLA_DOWN_REPEAT | ||
41 | #define MAZEZAM_LEFT PLA_LEFT | ||
42 | #define MAZEZAM_LEFT_REPEAT PLA_LEFT_REPEAT | ||
43 | #define MAZEZAM_RIGHT PLA_RIGHT | ||
44 | #define MAZEZAM_RIGHT_REPEAT PLA_RIGHT_REPEAT | ||
45 | #define MAZEZAM_MENU PLA_QUIT | ||
46 | 70 | ||
47 | /* All the text is here */ | 71 | /* All the text is here */ |
48 | #define MAZEZAM_TEXT_GAME_OVER "Game Over" | 72 | #define MAZEZAM_TEXT_GAME_OVER "Game Over" |
@@ -541,12 +565,16 @@ static void level_loop(struct level_info* li, short* shift, short *x, short *y) | |||
541 | while (state >= STATE_IN_LEVEL) { | 565 | while (state >= STATE_IN_LEVEL) { |
542 | draw_level(li, shift, *x, *y); | 566 | draw_level(li, shift, *x, *y); |
543 | rb->lcd_update(); | 567 | rb->lcd_update(); |
568 | #ifdef __PLUGINLIB_ACTIONS_H__ | ||
544 | button = pluginlib_getaction(TIMEOUT_BLOCK, plugin_contexts, 2); | 569 | button = pluginlib_getaction(TIMEOUT_BLOCK, plugin_contexts, 2); |
570 | #else | ||
571 | button = rb->button_get(true); | ||
572 | #endif | ||
545 | blocked = false; | 573 | blocked = false; |
546 | 574 | ||
547 | switch (button) { | 575 | switch (button) { |
548 | case MAZEZAM_UP: | 576 | case MAZEZAM_UP: |
549 | case MAZEZAM_UP_REPEAT: | 577 | case (MAZEZAM_UP|BUTTON_REPEAT): |
550 | if ((*y > 0) && (*x >= 0) && (*x < li->width)) { | 578 | if ((*y > 0) && (*x >= 0) && (*x < li->width)) { |
551 | for (i = 0; i < li->cd.l_num[*y-1]; i++) | 579 | for (i = 0; i < li->cd.l_num[*y-1]; i++) |
552 | blocked = blocked || | 580 | blocked = blocked || |
@@ -560,7 +588,7 @@ static void level_loop(struct level_info* li, short* shift, short *x, short *y) | |||
560 | 588 | ||
561 | 589 | ||
562 | case MAZEZAM_DOWN: | 590 | case MAZEZAM_DOWN: |
563 | case MAZEZAM_DOWN_REPEAT: | 591 | case (MAZEZAM_DOWN|BUTTON_REPEAT): |
564 | if ((*y < li->height-1) && (*x >= 0) && (*x < li->width)) { | 592 | if ((*y < li->height-1) && (*x >= 0) && (*x < li->width)) { |
565 | for (i = 0; i < li->cd.l_num[*y+1]; i++) | 593 | for (i = 0; i < li->cd.l_num[*y+1]; i++) |
566 | blocked = blocked || | 594 | blocked = blocked || |
@@ -572,7 +600,7 @@ static void level_loop(struct level_info* li, short* shift, short *x, short *y) | |||
572 | break; | 600 | break; |
573 | 601 | ||
574 | case MAZEZAM_LEFT: | 602 | case MAZEZAM_LEFT: |
575 | case MAZEZAM_LEFT_REPEAT: | 603 | case (MAZEZAM_LEFT|BUTTON_REPEAT): |
576 | if (*x > 0) { | 604 | if (*x > 0) { |
577 | for (i = 0; i < li->cd.l_num[*y]; i++) | 605 | for (i = 0; i < li->cd.l_num[*y]; i++) |
578 | blocked = blocked || | 606 | blocked = blocked || |
@@ -587,7 +615,7 @@ static void level_loop(struct level_info* li, short* shift, short *x, short *y) | |||
587 | break; | 615 | break; |
588 | 616 | ||
589 | case MAZEZAM_RIGHT: | 617 | case MAZEZAM_RIGHT: |
590 | case MAZEZAM_RIGHT_REPEAT: | 618 | case (MAZEZAM_RIGHT|BUTTON_REPEAT): |
591 | if (*x < li->width-1) { | 619 | if (*x < li->width-1) { |
592 | for (i = 0; i < li->cd.l_num[*y]; i++) | 620 | for (i = 0; i < li->cd.l_num[*y]; i++) |
593 | blocked = blocked || | 621 | blocked = blocked || |