get repeat/hold actions working on the touchscreen WPS. prepending an action with & means that this will only get triggered if you hold down the area. cabbie WPS updated so the fwd/rwd icons will do that when held or skip fwd/back if just pressed.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20974 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2009-05-17 06:25:18 +00:00
parent 03ea249297
commit 2172c91473
5 changed files with 40 additions and 7 deletions

View file

@ -268,7 +268,13 @@ bool ffwd_rew(int button)
break;
}
if (!exit)
{
button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,TIMEOUT_BLOCK);
#ifdef HAVE_TOUCHSCREEN
if (button == ACTION_TOUCHSCREEN)
button = wps_get_touchaction(gui_wps[SCREEN_MAIN].data);
#endif
}
}
return usb;
}

View file

@ -295,15 +295,16 @@ void gwps_draw_statusbars(void)
viewportmanager_set_statusbar(wpsbars);
}
#ifdef HAVE_TOUCHSCREEN
static int wps_get_touchaction(struct wps_data *data)
int wps_get_touchaction(struct wps_data *data)
{
short x,y;
short vx, vy;
int type = action_get_touchscreen_press(&x, &y);
int i;
static int last_action = ACTION_NONE;
struct touchregion *r;
if (type != BUTTON_REL)
return ACTION_TOUCHSCREEN;
bool repeated = (type == BUTTON_REPEAT);
bool released = (type == BUTTON_REL);
for (i=0; i<data->touchregion_count; i++)
{
r = &data->touchregion[i];
@ -320,9 +321,19 @@ static int wps_get_touchaction(struct wps_data *data)
/* now see if the point is inside this region */
if (vx >= r->x && vx < r->x+r->width &&
vy >= r->y && vy < r->y+r->height)
return r->action;
{
if ((repeated && r->repeat) ||
(released && !r->repeat))
{
last_action = r->action;
return r->action;
}
}
}
}
if ((last_action == ACTION_WPS_SEEKBACK || last_action == ACTION_WPS_SEEKFWD))
return ACTION_WPS_STOPSEEK;
last_action = ACTION_TOUCHSCREEN;
return ACTION_TOUCHSCREEN;
}
#endif

View file

@ -375,6 +375,7 @@ struct touchregion {
short int y; /* y-pos */
short int width; /* width */
short int height; /* height */
bool repeat; /* requires the area be held for the action */
int action; /* action this button will return */
};
#define MAX_TOUCHREGIONS 12
@ -533,6 +534,10 @@ extern struct gui_wps gui_wps[NB_SCREENS];
void gui_sync_wps_init(void);
#ifdef HAVE_TOUCHSCREEN
int wps_get_touchaction(struct wps_data *data);
#endif
#ifdef HAVE_ALBUMART
/* gives back if WPS contains an albumart tag */
bool gui_sync_wps_uses_albumart(void);

View file

@ -1163,6 +1163,7 @@ struct touchaction {char* s; int action;};
static struct touchaction touchactions[] = {
{"play", ACTION_WPS_PLAY }, {"stop", ACTION_WPS_STOP },
{"prev", ACTION_WPS_SKIPPREV }, {"next", ACTION_WPS_SKIPNEXT },
{"ffwd", ACTION_WPS_SEEKFWD }, {"rwd", ACTION_WPS_SEEKBACK },
{"menu", ACTION_WPS_MENU }, {"browse", ACTION_WPS_BROWSE },
{"shuffle", ACTION_TOUCH_SHUFFLE }, {"repmode", ACTION_TOUCH_REPMODE },
{"quickscreen", ACTION_WPS_QUICKSCREEN },{"contextmenu", ACTION_WPS_CONTEXT },
@ -1178,13 +1179,14 @@ static int parse_touchregion(const char *wps_bufptr,
int x,y,w,h;
/* format: %T|x|y|width|height|action|
* if action starts with & the area must be held to happen
* action is one of:
* play - play/pause playback
* stop - stop playback, exit the wps
* prev - prev track
* next - next track
* ffwd
* rwd
* ffwd - seek forward
* rwd - seek backwards
* menu - go back to the main menu
* browse - go back to the file/db browser
* shuffle - toggle shuffle mode
@ -1213,6 +1215,14 @@ static int parse_touchregion(const char *wps_bufptr,
region->height = h;
region->wvp = &wps_data->viewports[wps_data->num_viewports];
i = 0;
if (*action == '&')
{
action++;
region->repeat = true;
}
else
region->repeat = false;
while ((region->action == ACTION_NONE) &&
(i < sizeof(touchactions)/sizeof(*touchactions)))
{

View file

@ -65,8 +65,9 @@
#%T|50|5|24|24|pitch|
%T|80|5|24|24|contextmenu|
%T|110|5|24|24|quickscreen|
%T|150|5|24|24|&rwd|
%T|175|5|24|24|&ffwd|
%T|150|5|24|24|prev|
%T|175|5|24|24|next|
%Vl|u|0|74|-|30|1|-|-|
#purposly left blank