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
This commit is contained in:
Maurus Cuelenaere 2008-06-02 16:08:01 +00:00
parent bc97952134
commit cad30d334c
2 changed files with 49 additions and 22 deletions

View file

@ -281,11 +281,12 @@ int get_action_statuscode(int *button)
} }
#ifdef HAVE_TOUCHPAD #ifdef HAVE_TOUCHPAD
/* return BUTTON_NONE on error /* return BUTTON_NONE on error
BUTTON_REPEAT if repeated press * BUTTON_REPEAT if repeated press
BUTTON_REL if its a short press * BUTTON_REPEAT|BUTTON_REL if release after repeated press
BUTTON_TOUCHPAD otherwise * BUTTON_REL if its a short press = release after press
*/ * BUTTON_TOUCHPAD if press
*/
int action_get_touchpad_press(short *x, short *y) int action_get_touchpad_press(short *x, short *y)
{ {
static int last_data = 0; static int last_data = 0;
@ -308,7 +309,7 @@ int action_get_touchpad_press(short *x, short *y)
return BUTTON_REPEAT; return BUTTON_REPEAT;
if (short_press) if (short_press)
return BUTTON_REL; 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) if (last_button & BUTTON_REL)
return BUTTON_REPEAT|BUTTON_REL; return BUTTON_REPEAT|BUTTON_REL;
return BUTTON_TOUCHPAD; return BUTTON_TOUCHPAD;

View file

@ -278,13 +278,15 @@ void list_draw(struct screen *display, struct viewport *parent,
#if defined(HAVE_TOUCHPAD) #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; 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) 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); unsigned button = action_get_touchpad_press(&x, &y);
int line; int line;
struct screen *display = &screens[SCREEN_MAIN]; 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; return ACTION_NONE;
if (x<list_text[SCREEN_MAIN].x) if (x<list_text[SCREEN_MAIN].x)
{ {
/* top left corner is hopefully GO_TO_ROOT */ /* Top left corner is hopefully GO_TO_ROOT */
if (y<list_text[SCREEN_MAIN].y) if (y<list_text[SCREEN_MAIN].y)
{ {
if (button == BUTTON_REL) if (button == BUTTON_REL)
@ -302,7 +304,7 @@ unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewpor
else else
return ACTION_NONE; return ACTION_NONE;
} }
/* scroll bar */ /* Scroll bar */
else else
{ {
int new_selection, nb_lines; int new_selection, nb_lines;
@ -327,8 +329,18 @@ unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewpor
} }
else else
{ {
/* pressing an item will select it. /* |--------------------------------------------------------|
pressing the selected item will "enter" it */ * | Description of the touchscreen list interface: |
* |--------------------------------------------------------|
* | Pressing an item will select it and "enter" it. |
* | |
* | Pressing and holding your pen down will scroll through |
* | the list of items, releasing your pen will "enter" it. |
* | |
* | Pressing and holding your pen down on a single item |
* | will bring up the context menu of it. |
* |--------------------------------------------------------|
*/
if (y > list_text[SCREEN_MAIN].y) if (y > list_text[SCREEN_MAIN].y)
{ {
int i, line_height, actual_y; int i, line_height, actual_y;
@ -343,11 +355,13 @@ unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewpor
break; break;
} }
} }
/* Something went wrong during line detection... */
if(line == -1) if(line == -1)
return ACTION_NONE; return ACTION_NONE;
/* BUTTON_TOUCHPAD represents a button press*/ /* 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) if (gui_list->start_item[SCREEN_MAIN]+line > gui_list->nb_items)
return ACTION_NONE; 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)) 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; prev_line = -1;
return ACTION_STD_OK; return ACTION_STD_CONTEXT;
} }
else else
{ {
/* Pen was moved across several lines and then released on this one
* => simulate short button press
*/
prev_line = line; 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 else
return ACTION_NONE; 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) else if (y > title_text[SCREEN_MAIN].y && draw_title(display, parent, gui_list) && button == BUTTON_REL)
return ACTION_STD_CANCEL; 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) else if (global_settings.statusbar && button == BUTTON_REL)
return ACTION_STD_CANCEL; return ACTION_STD_CANCEL;
} }