summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2008-05-30 22:55:24 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2008-05-30 22:55:24 +0000
commit944219bb7764206b59a5ea6e44ec52db39793161 (patch)
tree2de70412d29edff70d7cf68c2c9722195f581536
parent48b47801e737202b575aeadb39b8bb99942f85a2 (diff)
downloadrockbox-944219bb7764206b59a5ea6e44ec52db39793161.tar.gz
rockbox-944219bb7764206b59a5ea6e44ec52db39793161.tar.bz2
rockbox-944219bb7764206b59a5ea6e44ec52db39793161.zip
(Simulator) Touchscreen improvements.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17662 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/action.c3
-rw-r--r--apps/gui/bitmap/list.c49
-rw-r--r--uisimulator/sdl/button.c16
3 files changed, 54 insertions, 14 deletions
diff --git a/apps/action.c b/apps/action.c
index 89d6a7ae7a..5d0f994862 100644
--- a/apps/action.c
+++ b/apps/action.c
@@ -308,6 +308,9 @@ int action_get_touchpad_press(short *x, short *y)
return BUTTON_REPEAT;
if (short_press)
return BUTTON_REL;
+ /* this is to give a BUTTON_REL after a BUTTON_REPEAT */
+ if (last_button & BUTTON_REL)
+ return BUTTON_REL;
return BUTTON_TOUCHPAD;
}
#endif
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c
index ed257155bd..fa41daeb01 100644
--- a/apps/gui/bitmap/list.c
+++ b/apps/gui/bitmap/list.c
@@ -278,6 +278,7 @@ void list_draw(struct screen *display, struct viewport *parent,
#if defined(HAVE_TOUCHPAD)
+static int prev_line=0;
/* this needs to be fixed if we ever get more than 1 touchscreen on a target */
/* this also assumes the whole screen is used, which is a bad asusmption but
fine untill customizable lists comes in... */
@@ -309,15 +310,15 @@ unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewpor
nb_lines = viewport_get_nb_lines(&list_text[SCREEN_MAIN]);
if (nb_lines < gui_list->nb_items)
{
- height = nb_lines * display->char_height;
+ height = nb_lines * font_get(parent->font)->height;
size = height*nb_lines / gui_list->nb_items;
new_selection = ((y-list_text[SCREEN_MAIN].y)*(gui_list->nb_items-nb_lines))/(height-size);
- gui_synclist_select_item(gui_list, new_selection);
nb_lines /= 2;
+
if (new_selection - gui_list->start_item[SCREEN_MAIN] > nb_lines)
- {
new_selection = gui_list->start_item[SCREEN_MAIN]+nb_lines;
- }
+
+ gui_synclist_select_item(gui_list, new_selection);
gui_list->start_item[SCREEN_MAIN] = new_selection;
return ACTION_REDRAW;
}
@@ -329,32 +330,52 @@ unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewpor
pressing the selected item will "enter" it */
if (y > list_text[SCREEN_MAIN].y)
{
- line = (y-list_text[SCREEN_MAIN].y) / display->char_height;
- if (button != BUTTON_REL && button != BUTTON_REPEAT)
+ int i, line_height, actual_y;
+ actual_y = y - list_text[SCREEN_MAIN].y;
+ line_height = font_get(parent->font)->height;
+ line = -1;
+ for(i=0; i<gui_list->nb_items; i++)
{
- if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN])
- gui_synclist_select_item(gui_list, gui_list->start_item[SCREEN_MAIN]+line);
- return ACTION_REDRAW;
+ if(actual_y > line_height*i && actual_y < line_height*(i+1))
+ line = i;
}
- if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN])
+ if(line == -1)
+ return ACTION_NONE;
+
+ /* BUTTON_TOUCHPAD represents a button press*/
+ if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN] && button == BUTTON_TOUCHPAD)
{
if (gui_list->start_item[SCREEN_MAIN]+line > gui_list->nb_items)
return ACTION_NONE;
gui_synclist_select_item(gui_list, gui_list->start_item[SCREEN_MAIN]+line);
+ return ACTION_REDRAW;
}
-
+
if (button == BUTTON_REPEAT)
return ACTION_STD_CONTEXT;
+ else if(button == BUTTON_REL)
+ {
+ if(prev_line == line)
+ {
+ prev_line = 0;
+ return ACTION_STD_OK;
+ }
+ else
+ {
+ prev_line = line;
+ return ACTION_NONE;
+ }
+ }
else
- return ACTION_STD_OK;
+ return ACTION_NONE;
}
/* title goes up one level */
- else if (y > title_text[SCREEN_MAIN].y && draw_title(display, parent, gui_list))
+ else if (y > title_text[SCREEN_MAIN].y && draw_title(display, parent, gui_list) && button == BUTTON_REL)
{
return ACTION_STD_CANCEL;
}
/* title or statusbar is cancel */
- else if (global_settings.statusbar)
+ else if (global_settings.statusbar && button == BUTTON_REL)
{
return ACTION_STD_CANCEL;
}
diff --git a/uisimulator/sdl/button.c b/uisimulator/sdl/button.c
index 76a1f2f10c..ba19f30061 100644
--- a/uisimulator/sdl/button.c
+++ b/uisimulator/sdl/button.c
@@ -166,6 +166,13 @@ void button_event(int key, bool pressed)
case SDLK_KP3:
new_btn = BUTTON_BOTTOMRIGHT;
break;
+ case SDLK_F10:
+ if(pressed)
+ {
+ touchpad_mode = (touchpad_mode == TOUCHPAD_POINT ? TOUCHPAD_BUTTON : TOUCHPAD_POINT);
+ printf("Touchpad mode: %s\n", touchpad_mode == TOUCHPAD_POINT ? "TOUCHPAD_POINT" : "TOUCHPAD_BUTTON");
+ }
+ break;
#endif
case SDLK_u:
@@ -1080,6 +1087,15 @@ void mouse_tick_task(void)
last_check = current_tick;
if (SDL_GetMouseState(&x, &y) & SDL_BUTTON(SDL_BUTTON_LEFT))
{
+ if(background)
+ {
+ x -= UI_LCD_POSX;
+ y -= UI_LCD_POSY;
+
+ if(x<0 || y<0 || x>UI_LCD_WIDTH || y>UI_LCD_HEIGHT)
+ return;
+ }
+
mouse_coords = (x<<16)|y;
button_event(BUTTON_TOUCHPAD, true);
if (debug_wps)