mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 10:37:38 -04:00
1) Implement generic touchscreen detection library for the plugins
2) Adapt minesweeper, pegbox & calculator to it 3) Simplify gui/bitmap/list.c git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17695 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
f9bf137b67
commit
e1753de41a
7 changed files with 382 additions and 12 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue