summaryrefslogtreecommitdiff
path: root/apps/plugins/sudoku
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2006-04-02 00:09:33 +0000
committerDave Chapman <dave@dchapman.com>2006-04-02 00:09:33 +0000
commita698c3e43e84253e6df132ce506b0a2894ea5599 (patch)
treec81f2c2987734bebd35452a5b8219ba87b212e4f /apps/plugins/sudoku
parent3a3304fa31c081cfd41e125b814eab58f83422c0 (diff)
Change (and hopefully simplify) the iPod button mappings and correct some comments. iPod mappings are now: Clickwheel for cursor movement, next/prev to increment/decrement number under cursor, MENU to bring up the menu, and PLAY to add a number to the scratchpad.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9415 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/sudoku')
-rw-r--r--apps/plugins/sudoku/sudoku.c67
-rw-r--r--apps/plugins/sudoku/sudoku.h28
2 files changed, 79 insertions, 16 deletions
diff --git a/apps/plugins/sudoku/sudoku.c b/apps/plugins/sudoku/sudoku.c
index 9ca5376a58..bd171f1192 100644
--- a/apps/plugins/sudoku/sudoku.c
+++ b/apps/plugins/sudoku/sudoku.c
@@ -66,6 +66,10 @@ Example ".ss" file, and one with a saved state:
PLUGIN_HEADER
+/* here is a global api struct pointer. while not strictly necessary,
+ it's nice not to have to pass the api pointer in all function calls
+ in the plugin */
+
struct plugin_api* rb;
/* The bitmaps */
@@ -887,7 +891,7 @@ bool sudoku_menu(struct sudoku_state_t* state)
result=rb->menu_show(m);
switch (result) {
- case 0: /* Save state */
+ case 0: /* Audio playback */
playback_control(rb);
break;
@@ -991,10 +995,12 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
button = rb->button_get(true);
switch(button){
+#ifdef SUDOKU_BUTTON_QUIT
/* Exit game */
case SUDOKU_BUTTON_QUIT:
exit=1;
break;
+#endif
/* Increment digit */
#ifdef SUDOKU_BUTTON_ALTTOGGLE
@@ -1037,26 +1043,74 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
update_cell(&state,state.y,state.x);
break;
+#ifdef SUDOKU_BUTTON_TOGGLEBACK
+ case SUDOKU_BUTTON_TOGGLEBACK | BUTTON_REPEAT:
+ /* Slow down the repeat speed to 1/3 second */
+ if ((*rb->current_tick-ticks) < (HZ/3)) {
+ break;
+ }
+
+ case SUDOKU_BUTTON_TOGGLEBACK:
+ /* Decrement digit */
+ ticks=*rb->current_tick;
+ if (state.editmode) {
+ if (state.startboard[state.y][state.x]=='0') {
+ state.startboard[state.y][state.x]='9';
+ state.currentboard[state.y][state.x]='9';
+ } else {
+ state.startboard[state.y][state.x]--;
+ state.currentboard[state.y][state.x]--;
+ }
+ } else {
+ if (state.startboard[state.y][state.x]=='0') {
+ if (state.currentboard[state.y][state.x]=='0') {
+ state.currentboard[state.y][state.x]='9';
+ } else {
+ state.currentboard[state.y][state.x]--;
+ }
+ }
+ }
+ update_cell(&state,state.y,state.x);
+ break;
+#endif
+
/* move cursor left */
- case BUTTON_LEFT:
- case (BUTTON_LEFT | BUTTON_REPEAT):
+ case SUDOKU_BUTTON_LEFT:
+ case (SUDOKU_BUTTON_LEFT | BUTTON_REPEAT):
if (state.x==0) {
+#ifndef SUDOKU_BUTTON_UP
+ if (state.y==0) {
+ move_cursor(&state,8,8);
+ } else {
+ move_cursor(&state,8,state.y-1);
+ }
+#else
move_cursor(&state,8,state.y);
+#endif
} else {
move_cursor(&state,state.x-1,state.y);
}
break;
/* move cursor right */
- case BUTTON_RIGHT:
- case (BUTTON_RIGHT | BUTTON_REPEAT):
+ case SUDOKU_BUTTON_RIGHT:
+ case (SUDOKU_BUTTON_RIGHT | BUTTON_REPEAT):
if (state.x==8) {
+#ifndef SUDOKU_BUTTON_DOWN
+ if (state.y==8) {
+ move_cursor(&state,0,0);
+ } else {
+ move_cursor(&state,0,state.y+1);
+ }
+#else
move_cursor(&state,0,state.y);
+#endif
} else {
move_cursor(&state,state.x+1,state.y);
}
break;
+#ifdef SUDOKU_BUTTON_UP
/* move cursor up */
case SUDOKU_BUTTON_UP:
case (SUDOKU_BUTTON_UP | BUTTON_REPEAT):
@@ -1066,7 +1120,9 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
move_cursor(&state,state.x,state.y-1);
}
break;
+#endif
+#ifdef SUDOKU_BUTTON_DOWN
/* move cursor down */
case SUDOKU_BUTTON_DOWN:
case (SUDOKU_BUTTON_DOWN | BUTTON_REPEAT):
@@ -1076,6 +1132,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
move_cursor(&state,state.x,state.y+1);
}
break;
+#endif
case SUDOKU_BUTTON_MENU:
#ifdef SUDOKU_BUTTON_MENU_PRE
diff --git a/apps/plugins/sudoku/sudoku.h b/apps/plugins/sudoku/sudoku.h
index cdad581767..0985ff5710 100644
--- a/apps/plugins/sudoku/sudoku.h
+++ b/apps/plugins/sudoku/sudoku.h
@@ -22,11 +22,6 @@
#include "plugin.h"
-/* here is a global api struct pointer. while not strictly necessary,
- it's nice not to have to pass the api pointer in all function calls
- in the plugin */
-
-#define STATE_FILE PLUGIN_DIR "/sudoku.state"
#define GAME_FILE PLUGIN_DIR "/sudoku.ss"
/* variable button definitions */
@@ -34,6 +29,8 @@
#define SUDOKU_BUTTON_QUIT BUTTON_OFF
#define SUDOKU_BUTTON_UP BUTTON_UP
#define SUDOKU_BUTTON_DOWN BUTTON_DOWN
+#define SUDOKU_BUTTON_LEFT BUTTON_LEFT
+#define SUDOKU_BUTTON_RIGHT BUTTON_RIGHT
#define SUDOKU_BUTTON_TOGGLE BUTTON_PLAY
#define SUDOKU_BUTTON_MENU BUTTON_F1
#define SUDOKU_BUTTON_POSSIBLE BUTTON_F2
@@ -42,6 +39,8 @@
#define SUDOKU_BUTTON_QUIT BUTTON_OFF
#define SUDOKU_BUTTON_UP BUTTON_UP
#define SUDOKU_BUTTON_DOWN BUTTON_DOWN
+#define SUDOKU_BUTTON_LEFT BUTTON_LEFT
+#define SUDOKU_BUTTON_RIGHT BUTTON_RIGHT
#define SUDOKU_BUTTON_ALTTOGGLE (BUTTON_MENU | BUTTON_DOWN)
#define SUDOKU_BUTTON_TOGGLE_PRE BUTTON_MENU
#define SUDOKU_BUTTON_TOGGLE (BUTTON_MENU | BUTTON_REL)
@@ -54,6 +53,8 @@
#define SUDOKU_BUTTON_QUIT BUTTON_OFF
#define SUDOKU_BUTTON_UP BUTTON_UP
#define SUDOKU_BUTTON_DOWN BUTTON_DOWN
+#define SUDOKU_BUTTON_LEFT BUTTON_LEFT
+#define SUDOKU_BUTTON_RIGHT BUTTON_RIGHT
#define SUDOKU_BUTTON_ALTTOGGLE BUTTON_ON
#define SUDOKU_BUTTON_TOGGLE BUTTON_SELECT
#define SUDOKU_BUTTON_MENU BUTTON_MODE
@@ -61,17 +62,20 @@
#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
(CONFIG_KEYPAD == IPOD_3G_PAD)
-#define SUDOKU_BUTTON_QUIT (BUTTON_SELECT | BUTTON_MENU)
-#define SUDOKU_BUTTON_UP BUTTON_SCROLL_BACK
-#define SUDOKU_BUTTON_DOWN BUTTON_SCROLL_FWD
-#define SUDOKU_BUTTON_TOGGLE BUTTON_SELECT
-#define SUDOKU_BUTTON_MENU BUTTON_MENU
-#define SUDOKU_BUTTON_POSSIBLE (BUTTON_SELECT | BUTTON_LEFT)
+#define SUDOKU_BUTTON_MENU BUTTON_MENU
+#define SUDOKU_BUTTON_LEFT BUTTON_SCROLL_BACK
+#define SUDOKU_BUTTON_RIGHT BUTTON_SCROLL_FWD
+#define SUDOKU_BUTTON_ALTTOGGLE BUTTON_SELECT
+#define SUDOKU_BUTTON_TOGGLE BUTTON_RIGHT
+#define SUDOKU_BUTTON_TOGGLEBACK BUTTON_LEFT
+#define SUDOKU_BUTTON_POSSIBLE BUTTON_PLAY
#elif (CONFIG_KEYPAD == IAUDIO_X5_PAD)
#define SUDOKU_BUTTON_QUIT BUTTON_POWER
#define SUDOKU_BUTTON_UP BUTTON_UP
#define SUDOKU_BUTTON_DOWN BUTTON_DOWN
+#define SUDOKU_BUTTON_LEFT BUTTON_LEFT
+#define SUDOKU_BUTTON_RIGHT BUTTON_RIGHT
#define SUDOKU_BUTTON_TOGGLE BUTTON_SELECT
#define SUDOKU_BUTTON_MENU BUTTON_PLAY
#define SUDOKU_BUTTON_POSSIBLE BUTTON_REC
@@ -80,6 +84,8 @@
#define SUDOKU_BUTTON_QUIT BUTTON_A
#define SUDOKU_BUTTON_UP BUTTON_UP
#define SUDOKU_BUTTON_DOWN BUTTON_DOWN
+#define SUDOKU_BUTTON_LEFT BUTTON_LEFT
+#define SUDOKU_BUTTON_RIGHT BUTTON_RIGHT
#define SUDOKU_BUTTON_TOGGLE BUTTON_SELECT
#define SUDOKU_BUTTON_MENU BUTTON_MENU
#define SUDOKU_BUTTON_POSSIBLE BUTTON_POWER