summaryrefslogtreecommitdiffstats
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;
/* a usefull string for snprintf */
char str[30];
+#ifdef HAVE_TOUCHPAD
+
+#include "lib/touchscreen.h"
+static struct ts_raster mine_raster = { 0, 0, MAX_WIDTH, MAX_HEIGHT, TileSize, TileSize };
+#endif
+
void push( int *stack, int y, int x )
{
@@ -477,6 +483,9 @@ void mine_show( void )
button = rb->button_get(true);
while( ( button == BUTTON_NONE )
|| ( button & (BUTTON_REL|BUTTON_REPEAT) ) );
+#ifdef HAVE_TOUCHPAD
+ button = BUTTON_NONE;
+#endif
}
int count_tiles_left( void )
@@ -570,6 +579,13 @@ enum minesweeper_status minesweeper( void )
*/
top = (LCD_HEIGHT-height*TileSize)/2;
left = (LCD_WIDTH-width*TileSize)/2;
+
+#ifdef HAVE_TOUCHPAD
+ mine_raster.tl_x = left;
+ mine_raster.tl_y = top;
+ mine_raster.width = width*TileSize;
+ mine_raster.height = height*TileSize;
+#endif
rb->srand( *rb->current_tick );
minesweeper_init();
@@ -614,7 +630,29 @@ enum minesweeper_status minesweeper( void )
/* update the screen */
rb->lcd_update();
- switch( button = rb->button_get( true ) )
+ button = rb->button_get(true);
+#ifdef HAVE_TOUCHPAD
+ if(button & BUTTON_TOUCHPAD)
+ {
+ struct ts_raster_result res;
+ if(touchscreen_map_raster(&mine_raster, rb->button_get_data() >> 16, rb->button_get_data() & 0xffff, &res) == 1)
+ {
+ button &= ~BUTTON_TOUCHPAD;
+ lastbutton &= ~BUTTON_TOUCHPAD;
+
+ if(button & BUTTON_REPEAT && lastbutton != MINESWP_TOGGLE && lastbutton ^ BUTTON_REPEAT)
+ button = MINESWP_TOGGLE;
+ else if(button == BUTTON_REL && lastbutton ^ BUTTON_REPEAT)
+ button = MINESWP_DISCOVER;
+ else
+ button |= BUTTON_TOUCHPAD;
+
+ x = res.x;
+ y = res.y;
+ }
+ }
+#endif
+ switch(button)
{
/* quit minesweeper (you really shouldn't use this button ...) */
#ifdef MINESWP_RC_QUIT