From 443b1349830912add7211e07557029b9c185d948 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Sun, 27 Mar 2011 07:23:38 +0000 Subject: [PATCH] Fix touchregions muting volume, and change & to mean 'needs long press but only fire once'. Use * for 'long press and allow repeats' git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29653 a1c6a512-1295-4272-9138-f99709370657 --- apps/action.h | 2 ++ apps/gui/skin_engine/skin_parser.c | 16 ++++++---- apps/gui/skin_engine/skin_touchsupport.c | 38 ++++++++++++++---------- apps/gui/skin_engine/wps_internals.h | 11 ++++--- apps/gui/wps.c | 4 +-- manual/appendix/wps_tags.tex | 4 ++- 6 files changed, 44 insertions(+), 31 deletions(-) diff --git a/apps/action.h b/apps/action.h index a9e4de1665..e380b1289a 100644 --- a/apps/action.h +++ b/apps/action.h @@ -248,6 +248,8 @@ enum { ACTION_TOUCH_SHUFFLE, ACTION_TOUCH_REPMODE, ACTION_TOUCH_MUTE, + ACTION_TOUCH_SCROLLBAR, + ACTION_TOUCH_VOLUME, #endif /* USB HID codes */ diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 236c6feea1..468f6808c4 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -1030,6 +1030,7 @@ static int parse_touchregion(struct skin_element *element, region->reverse_bar = false; region->value = 0; region->last_press = 0xffff; + region->press_length = PRESS; action = element->params[p++].data.text; strcpy(temp, action); @@ -1042,20 +1043,23 @@ static int parse_touchregion(struct skin_element *element, } if(!strcmp(pb_string, action)) - region->type = WPS_TOUCHREGION_SCROLLBAR; + region->action = ACTION_TOUCH_SCROLLBAR; else if(!strcmp(vol_string, action)) - region->type = WPS_TOUCHREGION_VOLUME; + region->action = ACTION_TOUCH_VOLUME; else { - region->type = WPS_TOUCHREGION_ACTION; - if (*action == '&') { action++; - region->repeat = true; + region->press_length = LONG_PRESS; + } + else if(*action == '*') + { + action++; + region->press_length = REPEAT; } else - region->repeat = false; + region->press_length = PRESS; imax = ARRAYLEN(touchactions); for (i = 0; i < imax; i++) diff --git a/apps/gui/skin_engine/skin_touchsupport.c b/apps/gui/skin_engine/skin_touchsupport.c index e1a7d0688e..beb6780c3c 100644 --- a/apps/gui/skin_engine/skin_touchsupport.c +++ b/apps/gui/skin_engine/skin_touchsupport.c @@ -62,6 +62,7 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset, bool released = (type == BUTTON_REL); bool pressed = (type == BUTTON_TOUCHSCREEN); struct skin_token_list *regions = data->touchregions; + bool needs_repeat; while (regions) { @@ -72,6 +73,7 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset, regions = regions->next; continue; } + needs_repeat = r->press_length != PRESS; /* check if it's inside this viewport */ if (viewport_point_within_vp(&(r->wvp->vp), x, y)) { /* reposition the touch inside the viewport since touchregions @@ -87,10 +89,25 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset, vy -= r->y; - switch(r->type) + switch(r->action) { - case WPS_TOUCHREGION_ACTION: - if (r->armed && ((repeated && r->repeat) || (released && !r->repeat))) + case ACTION_TOUCH_SCROLLBAR: + case ACTION_TOUCH_VOLUME: + if (edge_offset) + { + if(r->width > r->height) + *edge_offset = vx*100/r->width; + else + *edge_offset = vy*100/r->height; + if (r->reverse_bar) + *edge_offset = 100 - *edge_offset; + } + temp = r; + returncode = r->action; + break; + default: + if (r->armed && ((repeated && needs_repeat) || + (released && !needs_repeat))) { last_action = r->action; returncode = r->action; @@ -102,19 +119,6 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset, r->last_press = current_tick; } break; - default: - if (edge_offset) - { - if(r->width > r->height) - *edge_offset = vx*100/r->width; - else - *edge_offset = vy*100/r->height; - if (r->reverse_bar) - *edge_offset = 100 - *edge_offset; - } - returncode = r->type; - temp = r; - break; } } } @@ -126,6 +130,8 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset, skin_disarm_touchregions(data); if (retregion && temp) *retregion = temp; + if (temp && temp->press_length == LONG_PRESS) + temp->armed = false; if (returncode != ACTION_NONE) { diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index 47453ed34b..0f5cb6df0c 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h @@ -188,13 +188,12 @@ struct touchregion { short int y; /* y-pos */ short int width; /* width */ short int height; /* height */ - enum { - WPS_TOUCHREGION_ACTION, - WPS_TOUCHREGION_SCROLLBAR, - WPS_TOUCHREGION_VOLUME - } type; /* type of touch region */ bool reverse_bar; /* if true 0% is the left or top */ - bool repeat; /* requires the area be held for the action */ + enum { + PRESS, /* quick press only */ + LONG_PRESS, /* Long press without repeat */ + REPEAT, /* long press allowing repeats */ + } press_length; int action; /* action this button will return */ bool armed; /* A region is armed on press. Only armed regions are triggered on repeat or release. */ diff --git a/apps/gui/wps.c b/apps/gui/wps.c index fc91b9abb2..c33268e6bd 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c @@ -217,7 +217,7 @@ static int skintouch_to_wps(struct wps_data *data) case ACTION_STD_HOTKEY: return ACTION_WPS_HOTKEY; #endif - case WPS_TOUCHREGION_SCROLLBAR: + case ACTION_TOUCH_SCROLLBAR: skin_get_global_state()->id3->elapsed = skin_get_global_state()->id3->length*offset/100; if (!skin_get_global_state()->paused) #if (CONFIG_CODEC == SWCODEC) @@ -231,7 +231,7 @@ static int skintouch_to_wps(struct wps_data *data) audio_resume(); #endif return ACTION_TOUCHSCREEN; - case WPS_TOUCHREGION_VOLUME: + case ACTION_TOUCH_VOLUME: { const int min_vol = sound_min(SOUND_VOLUME); const int max_vol = sound_max(SOUND_VOLUME); diff --git a/manual/appendix/wps_tags.tex b/manual/appendix/wps_tags.tex index 46bf4a3967..cddfbe1d85 100644 --- a/manual/appendix/wps_tags.tex +++ b/manual/appendix/wps_tags.tex @@ -602,7 +602,9 @@ display cycling round the defined sublines. See & Invoke the action specified when the user presses in the defined touchscreen area.\\ \end{tagmap} - If the action starts with \& then the area must be held. Possible actions are: + If the action starts with \& then the area must be held. + If the action starts with \* then the area must be held and allows repeat presses. + Possible actions are: \begin{description} \item[play] -- Play/pause playback.