From cad30d334ce4a50fe26c562467b81e184bb3fa40 Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Mon, 2 Jun 2008 16:08:01 +0000 Subject: [PATCH] 1) Make touchscreen interface more intuitive 2) Comment the code git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17676 a1c6a512-1295-4272-9138-f99709370657 --- apps/action.c | 13 +++++----- apps/gui/bitmap/list.c | 58 ++++++++++++++++++++++++++++++------------ 2 files changed, 49 insertions(+), 22 deletions(-) diff --git a/apps/action.c b/apps/action.c index 0614443bac..2c089ee699 100644 --- a/apps/action.c +++ b/apps/action.c @@ -281,11 +281,12 @@ int get_action_statuscode(int *button) } #ifdef HAVE_TOUCHPAD -/* return BUTTON_NONE on error - BUTTON_REPEAT if repeated press - BUTTON_REL if its a short press - BUTTON_TOUCHPAD otherwise -*/ +/* return BUTTON_NONE on error + * BUTTON_REPEAT if repeated press + * BUTTON_REPEAT|BUTTON_REL if release after repeated press + * BUTTON_REL if its a short press = release after press + * BUTTON_TOUCHPAD if press + */ int action_get_touchpad_press(short *x, short *y) { static int last_data = 0; @@ -308,7 +309,7 @@ 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 */ + /* This is to return a BUTTON_REL after a BUTTON_REPEAT. */ if (last_button & BUTTON_REL) return BUTTON_REPEAT|BUTTON_REL; return BUTTON_TOUCHPAD; diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c index dacf65adbd..ee9cab2da7 100644 --- a/apps/gui/bitmap/list.c +++ b/apps/gui/bitmap/list.c @@ -278,13 +278,15 @@ void list_draw(struct screen *display, struct viewport *parent, #if defined(HAVE_TOUCHPAD) +/* 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 assumption but + * fine until customizable lists comes in... + */ static unsigned 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... */ + unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewport *parent) { - short x,y; + short x, y; unsigned button = action_get_touchpad_press(&x, &y); int line; struct screen *display = &screens[SCREEN_MAIN]; @@ -292,7 +294,7 @@ unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewpor return ACTION_NONE; if (x list_text[SCREEN_MAIN].y) { int i, line_height, actual_y; @@ -343,11 +355,13 @@ unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewpor break; } } + + /* Something went wrong during line detection... */ 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 (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN] && button ^ BUTTON_REL) { if (gui_list->start_item[SCREEN_MAIN]+line > gui_list->nb_items) return ACTION_NONE; @@ -356,27 +370,39 @@ unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewpor } if (button == (BUTTON_REPEAT|BUTTON_REL)) - return ACTION_STD_CONTEXT; - else if(button == BUTTON_REL) { - if((signed)prev_line == line) + if(prev_line == (unsigned)line) { + /* Pen was hold on the same line as the previously selected one + * => simulate long button press + */ prev_line = -1; - return ACTION_STD_OK; + return ACTION_STD_CONTEXT; } else { + /* Pen was moved across several lines and then released on this one + * => simulate short button press + */ prev_line = line; - return ACTION_NONE; + return ACTION_STD_OK; } } + else if(button == BUTTON_REL) + { + /* Pen was released on either the same line as the previously selected one + * or an other one + * => simulate short press + */ + return ACTION_STD_OK; + } else return ACTION_NONE; } - /* title goes up one level */ + /* Title goes up one level (only on BUTTON_REL&~BUTTON_REPEAT) */ 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 */ + /* Title or statusbar is cancel (only on BUTTON_REL&~BUTTON_REPEAT) */ else if (global_settings.statusbar && button == BUTTON_REL) return ACTION_STD_CANCEL; }