summaryrefslogtreecommitdiff
path: root/apps/plugins/minesweeper.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/minesweeper.c')
-rw-r--r--apps/plugins/minesweeper.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/apps/plugins/minesweeper.c b/apps/plugins/minesweeper.c
index 7b1587ce6f..75a9330f47 100644
--- a/apps/plugins/minesweeper.c
+++ b/apps/plugins/minesweeper.c
@@ -303,6 +303,12 @@ int stack_pos = 0;
303/* a usefull string for snprintf */ 303/* a usefull string for snprintf */
304char str[30]; 304char str[30];
305 305
306#ifdef HAVE_TOUCHPAD
307
308#include "lib/touchscreen.h"
309static struct ts_raster mine_raster = { 0, 0, MAX_WIDTH, MAX_HEIGHT, TileSize, TileSize };
310#endif
311
306 312
307void push( int *stack, int y, int x ) 313void push( int *stack, int y, int x )
308{ 314{
@@ -477,6 +483,9 @@ void mine_show( void )
477 button = rb->button_get(true); 483 button = rb->button_get(true);
478 while( ( button == BUTTON_NONE ) 484 while( ( button == BUTTON_NONE )
479 || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); 485 || ( button & (BUTTON_REL|BUTTON_REPEAT) ) );
486#ifdef HAVE_TOUCHPAD
487 button = BUTTON_NONE;
488#endif
480} 489}
481 490
482int count_tiles_left( void ) 491int count_tiles_left( void )
@@ -570,6 +579,13 @@ enum minesweeper_status minesweeper( void )
570 */ 579 */
571 top = (LCD_HEIGHT-height*TileSize)/2; 580 top = (LCD_HEIGHT-height*TileSize)/2;
572 left = (LCD_WIDTH-width*TileSize)/2; 581 left = (LCD_WIDTH-width*TileSize)/2;
582
583#ifdef HAVE_TOUCHPAD
584 mine_raster.tl_x = left;
585 mine_raster.tl_y = top;
586 mine_raster.width = width*TileSize;
587 mine_raster.height = height*TileSize;
588#endif
573 589
574 rb->srand( *rb->current_tick ); 590 rb->srand( *rb->current_tick );
575 minesweeper_init(); 591 minesweeper_init();
@@ -614,7 +630,29 @@ enum minesweeper_status minesweeper( void )
614 /* update the screen */ 630 /* update the screen */
615 rb->lcd_update(); 631 rb->lcd_update();
616 632
617 switch( button = rb->button_get( true ) ) 633 button = rb->button_get(true);
634#ifdef HAVE_TOUCHPAD
635 if(button & BUTTON_TOUCHPAD)
636 {
637 struct ts_raster_result res;
638 if(touchscreen_map_raster(&mine_raster, rb->button_get_data() >> 16, rb->button_get_data() & 0xffff, &res) == 1)
639 {
640 button &= ~BUTTON_TOUCHPAD;
641 lastbutton &= ~BUTTON_TOUCHPAD;
642
643 if(button & BUTTON_REPEAT && lastbutton != MINESWP_TOGGLE && lastbutton ^ BUTTON_REPEAT)
644 button = MINESWP_TOGGLE;
645 else if(button == BUTTON_REL && lastbutton ^ BUTTON_REPEAT)
646 button = MINESWP_DISCOVER;
647 else
648 button |= BUTTON_TOUCHPAD;
649
650 x = res.x;
651 y = res.y;
652 }
653 }
654#endif
655 switch(button)
618 { 656 {
619 /* quit minesweeper (you really shouldn't use this button ...) */ 657 /* quit minesweeper (you really shouldn't use this button ...) */
620#ifdef MINESWP_RC_QUIT 658#ifdef MINESWP_RC_QUIT