summaryrefslogtreecommitdiff
path: root/apps/plugins/sliding_puzzle.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2004-10-18 21:45:00 +0000
committerJens Arnold <amiconn@rockbox.org>2004-10-18 21:45:00 +0000
commite35a658ded457698aca2401b699e743a3011cfce (patch)
treecb89b7785ef2c72f7a293fe165a4d3b76e38227f /apps/plugins/sliding_puzzle.c
parentd24766675db5faddb67810ca67b37491d49c2313 (diff)
downloadrockbox-e35a658ded457698aca2401b699e743a3011cfce.tar.gz
rockbox-e35a658ded457698aca2401b699e743a3011cfce.zip
Plugin rework 2: (all) Compile-time keyboard configuration, for Ondio adaption. (all) Now using the default event handler, standard placement is now in switch() default case. (minesweeper,pong,snake,snake2) added USB handling. (mandelbrot,mosaique) Fixed return value. (minesweeper) fast moving with button repeat. (oscillograph) Fixed cleanup in USB case.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5304 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/sliding_puzzle.c')
-rw-r--r--apps/plugins/sliding_puzzle.c48
1 files changed, 41 insertions, 7 deletions
diff --git a/apps/plugins/sliding_puzzle.c b/apps/plugins/sliding_puzzle.c
index 423ab7fcf1..789e8789e8 100644
--- a/apps/plugins/sliding_puzzle.c
+++ b/apps/plugins/sliding_puzzle.c
@@ -19,6 +19,20 @@
19#include "plugin.h" 19#include "plugin.h"
20#ifdef HAVE_LCD_BITMAP 20#ifdef HAVE_LCD_BITMAP
21 21
22/* variable button definitions */
23#if CONFIG_KEYPAD == RECORDER_PAD
24#define PUZZLE_QUIT BUTTON_OFF
25#define PUZZLE_SHUFFLE BUTTON_F1
26#define PUZZLE_PICTURE BUTTON_F2
27
28#elif CONFIG_KEYPAD == ONDIO_PAD
29#define PUZZLE_QUIT BUTTON_OFF
30#define PUZZLE_SHUFFLE_PICTURE_PRE BUTTON_MENU
31#define PUZZLE_SHUFFLE (BUTTON_MENU | BUTTON_REPEAT)
32#define PUZZLE_PICTURE (BUTTON_MENU | BUTTON_REL)
33
34#endif
35
22static struct plugin_api* rb; 36static struct plugin_api* rb;
23static int spots[20]; 37static int spots[20];
24static int hole = 19, moves; 38static int hole = 19, moves;
@@ -232,20 +246,31 @@ static void puzzle_init(void)
232/* the main game loop */ 246/* the main game loop */
233static int puzzle_loop(void) 247static int puzzle_loop(void)
234{ 248{
249 int button;
250 int lastbutton = BUTTON_NONE;
235 int i; 251 int i;
236 puzzle_init(); 252 puzzle_init();
237 while(true) { 253 while(true) {
238 switch (rb->button_get(true)) { 254 button = rb->button_get(true);
239 case BUTTON_OFF: 255 switch (button) {
256 case PUZZLE_QUIT:
240 /* get out of here */ 257 /* get out of here */
241 return PLUGIN_OK; 258 return PLUGIN_OK;
242 259
243 case BUTTON_F1: 260 case PUZZLE_SHUFFLE:
261#ifdef PUZZLE_SHUFFLE_PICTURE_PRE
262 if (lastbutton != PUZZLE_SHUFFLE_PICTURE_PRE)
263 break;
264#endif
244 /* mix up the pieces */ 265 /* mix up the pieces */
245 puzzle_init(); 266 puzzle_init();
246 break; 267 break;
247 268
248 case BUTTON_F2: 269 case PUZZLE_PICTURE:
270#ifdef PUZZLE_SHUFFLE_PICTURE_PRE
271 if (lastbutton != PUZZLE_SHUFFLE_PICTURE_PRE)
272 break;
273#endif
249 /* change picture */ 274 /* change picture */
250 pic = (pic==true?false:true); 275 pic = (pic==true?false:true);
251 for (i=0; i<20; i++) 276 for (i=0; i<20; i++)
@@ -273,10 +298,13 @@ static int puzzle_loop(void)
273 move_spot(0, 1); 298 move_spot(0, 1);
274 break; 299 break;
275 300
276 case SYS_USB_CONNECTED: 301 default:
277 rb->usb_screen(); 302 if (rb->default_event_handler(button) == SYS_USB_CONNECTED)
278 return PLUGIN_USB_CONNECTED; 303 return PLUGIN_USB_CONNECTED;
304 break;
279 } 305 }
306 if (button != BUTTON_NONE)
307 lastbutton = button;
280 } 308 }
281} 309}
282 310
@@ -300,9 +328,15 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
300 /* print instructions */ 328 /* print instructions */
301 rb->lcd_clear_display(); 329 rb->lcd_clear_display();
302 rb->lcd_setfont(FONT_SYSFIXED); 330 rb->lcd_setfont(FONT_SYSFIXED);
331#if CONFIG_KEYPAD == RECORDER_PAD
303 rb->lcd_putsxy(3, 18, "[OFF] to stop"); 332 rb->lcd_putsxy(3, 18, "[OFF] to stop");
304 rb->lcd_putsxy(3, 28, "[F1] shuffle"); 333 rb->lcd_putsxy(3, 28, "[F1] shuffle");
305 rb->lcd_putsxy(3, 38, "[F2] change pic"); 334 rb->lcd_putsxy(3, 38, "[F2] change pic");
335#elif CONFIG_KEYPAD == ONDIO_PAD
336 rb->lcd_putsxy(0, 18, "[OFF] to stop");
337 rb->lcd_putsxy(0, 28, "[MENU..] shuffle");
338 rb->lcd_putsxy(0, 38, "[MENU] change pic");
339#endif
306 rb->lcd_update(); 340 rb->lcd_update();
307 rb->sleep(HZ*2); 341 rb->sleep(HZ*2);
308 342