summaryrefslogtreecommitdiff
path: root/apps/plugins/pong.c
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2008-06-09 20:59:55 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2008-06-09 20:59:55 +0000
commit50763d512cfac64f39e412879d0cf1820635109a (patch)
treedaefae1e50c8439b572191206495262f0f43fec8 /apps/plugins/pong.c
parentfb573630b8798eb743f27fab9ecc854055adb12a (diff)
downloadrockbox-50763d512cfac64f39e412879d0cf1820635109a.tar.gz
rockbox-50763d512cfac64f39e412879d0cf1820635109a.zip
Make some more games touchscreen compatible.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17707 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/pong.c')
-rw-r--r--apps/plugins/pong.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/apps/plugins/pong.c b/apps/plugins/pong.c
index c7382a58b2..d5bb626f60 100644
--- a/apps/plugins/pong.c
+++ b/apps/plugins/pong.c
@@ -199,10 +199,9 @@ void singlepad(int x, int y, int set)
199 } 199 }
200} 200}
201 201
202static int xpos[2]={0, LCD_WIDTH-PAD_WIDTH};
202void pad(struct pong *p, int pad) 203void pad(struct pong *p, int pad)
203{ 204{
204 static int xpos[2]={0, LCD_WIDTH-PAD_WIDTH};
205
206 /* clear existing pad */ 205 /* clear existing pad */
207 singlepad(xpos[pad], p->e_pad[pad], 0); 206 singlepad(xpos[pad], p->e_pad[pad], 0);
208 207
@@ -396,12 +395,31 @@ int keys(struct pong *p)
396 static bool pause = false; 395 static bool pause = false;
397#endif 396#endif
398 397
399 int time = 4; /* number of ticks this function will loop reading keys */ 398 /* number of ticks this function will loop reading keys */
399#ifndef HAVE_TOUCHPAD
400 int time = 4;
401#else
402 int time = 1;
403#endif
400 int start = *rb->current_tick; 404 int start = *rb->current_tick;
401 int end = start + time; 405 int end = start + time;
402 406
403 while(end > *rb->current_tick) { 407 while(end > *rb->current_tick) {
404 key = rb->button_get_w_tmo(end - *rb->current_tick); 408 key = rb->button_get_w_tmo(end - *rb->current_tick);
409
410#ifdef HAVE_TOUCHPAD
411 short touch_x, touch_y;
412 if(key & BUTTON_TOUCHPAD)
413 {
414 touch_x = rb->button_get_data() >> 16;
415 touch_y = rb->button_get_data() & 0xFFFF;
416 if(touch_x >= xpos[0] && touch_x <= xpos[0]+(PAD_WIDTH*4))
417 padmove(&p->w_pad[0], touch_y-(p->e_pad[0]*2+PAD_HEIGHT)/2);
418
419 if(touch_x >= xpos[1]-(PAD_WIDTH*4) && touch_x <= xpos[1])
420 padmove(&p->w_pad[1], touch_y-(p->e_pad[1]*2+PAD_HEIGHT)/2);
421 }
422#endif
405 423
406#ifdef HAS_BUTTON_HOLD 424#ifdef HAS_BUTTON_HOLD
407 if (rb->button_hold()) 425 if (rb->button_hold())