diff options
Diffstat (limited to 'apps/plugins/chessbox/chessbox.c')
-rw-r--r-- | apps/plugins/chessbox/chessbox.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/apps/plugins/chessbox/chessbox.c b/apps/plugins/chessbox/chessbox.c index 0d145ec00a..092de1825a 100644 --- a/apps/plugins/chessbox/chessbox.c +++ b/apps/plugins/chessbox/chessbox.c | |||
@@ -89,12 +89,14 @@ PLUGIN_HEADER | |||
89 | #define CB_QUIT BUTTON_OFF | 89 | #define CB_QUIT BUTTON_OFF |
90 | 90 | ||
91 | #elif CONFIG_KEYPAD == ONDIO_PAD | 91 | #elif CONFIG_KEYPAD == ONDIO_PAD |
92 | #define CB_SELECT_PRE BUTTON_MENU | ||
92 | #define CB_SELECT (BUTTON_MENU|BUTTON_REL) | 93 | #define CB_SELECT (BUTTON_MENU|BUTTON_REL) |
93 | #define CB_UP BUTTON_UP | 94 | #define CB_UP BUTTON_UP |
94 | #define CB_DOWN BUTTON_DOWN | 95 | #define CB_DOWN BUTTON_DOWN |
95 | #define CB_LEFT BUTTON_LEFT | 96 | #define CB_LEFT BUTTON_LEFT |
96 | #define CB_RIGHT BUTTON_RIGHT | 97 | #define CB_RIGHT BUTTON_RIGHT |
97 | #define CB_PLAY BUTTON_MENU | 98 | #define CB_PLAY_PRE BUTTON_MENU |
99 | #define CB_PLAY (BUTTON_MENU|BUTTON_REPEAT) | ||
98 | #define CB_LEVEL (BUTTON_MENU|BUTTON_OFF) | 100 | #define CB_LEVEL (BUTTON_MENU|BUTTON_OFF) |
99 | #define CB_QUIT BUTTON_OFF | 101 | #define CB_QUIT BUTTON_OFF |
100 | 102 | ||
@@ -133,6 +135,12 @@ PLUGIN_HEADER | |||
133 | /*#define COMMAND_RESTART 4*/ | 135 | /*#define COMMAND_RESTART 4*/ |
134 | #define COMMAND_QUIT 5 | 136 | #define COMMAND_QUIT 5 |
135 | 137 | ||
138 | /* GCC wants this to be present for some targets */ | ||
139 | void* memcpy(void* dst, const void* src, size_t size) | ||
140 | { | ||
141 | return rb->memcpy(dst, src, size); | ||
142 | } | ||
143 | |||
136 | /* ---- Get the board column and row (e2 f.e.) for a physical x y ---- */ | 144 | /* ---- Get the board column and row (e2 f.e.) for a physical x y ---- */ |
137 | void xy2cr ( short x, short y, short *c, short *r ) { | 145 | void xy2cr ( short x, short y, short *c, short *r ) { |
138 | if (computer == black ) { | 146 | if (computer == black ) { |
@@ -286,7 +294,7 @@ void cb_levelup ( void ) { | |||
286 | struct cb_command cb_getcommand (void) { | 294 | struct cb_command cb_getcommand (void) { |
287 | static short x = 4 , y = 4 ; | 295 | static short x = 4 , y = 4 ; |
288 | short c , r , l; | 296 | short c , r , l; |
289 | int button = BUTTON_NONE; | 297 | int button, lastbutton = BUTTON_NONE; |
290 | int marked = false , from_marked = false ; | 298 | int marked = false , from_marked = false ; |
291 | short marked_x = 0 , marked_y = 0 ; | 299 | short marked_x = 0 , marked_y = 0 ; |
292 | struct cb_command result = { 0, {0,0,0,0,0}, 0 }; | 300 | struct cb_command result = { 0, {0,0,0,0,0}, 0 }; |
@@ -306,6 +314,10 @@ struct cb_command cb_getcommand (void) { | |||
306 | result.type = COMMAND_LEVEL; | 314 | result.type = COMMAND_LEVEL; |
307 | return result; | 315 | return result; |
308 | case CB_PLAY: | 316 | case CB_PLAY: |
317 | #ifdef CB_PLAY_PRE | ||
318 | if (lastbutton != CB_PLAY_PRE) | ||
319 | break; | ||
320 | #endif | ||
309 | result.type = COMMAND_PLAY; | 321 | result.type = COMMAND_PLAY; |
310 | return result; | 322 | return result; |
311 | case CB_UP: | 323 | case CB_UP: |
@@ -369,6 +381,10 @@ struct cb_command cb_getcommand (void) { | |||
369 | } | 381 | } |
370 | break; | 382 | break; |
371 | case CB_SELECT: | 383 | case CB_SELECT: |
384 | #ifdef CB_SELECT_PRE | ||
385 | if (lastbutton != CB_SELECT_PRE) | ||
386 | break; | ||
387 | #endif | ||
372 | if ( !marked ) { | 388 | if ( !marked ) { |
373 | xy2cr ( x , y , &c , &r ); | 389 | xy2cr ( x , y , &c , &r ); |
374 | l = locn[r][c]; | 390 | l = locn[r][c]; |
@@ -396,6 +412,8 @@ struct cb_command cb_getcommand (void) { | |||
396 | } | 412 | } |
397 | break; | 413 | break; |
398 | } | 414 | } |
415 | if (button != BUTTON_NONE) | ||
416 | lastbutton = button; | ||
399 | } | 417 | } |
400 | 418 | ||
401 | } | 419 | } |