Fix touchregions muting volume, and change &<action> to mean 'needs long press but only fire once'. Use *<action> for 'long press and allow repeats'

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29653 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2011-03-27 07:23:38 +00:00
parent 86c4ec7277
commit 443b134983
6 changed files with 44 additions and 31 deletions

View File

@ -248,6 +248,8 @@ enum {
ACTION_TOUCH_SHUFFLE,
ACTION_TOUCH_REPMODE,
ACTION_TOUCH_MUTE,
ACTION_TOUCH_SCROLLBAR,
ACTION_TOUCH_VOLUME,
#endif
/* USB HID codes */

View File

@ -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++)

View File

@ -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)
{

View File

@ -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. */

View File

@ -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);

View File

@ -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.