From 2172c9147361829e4a65f1c918450b617c4d04d5 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Sun, 17 May 2009 06:25:18 +0000 Subject: 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 --- apps/gui/gwps-common.c | 6 ++++++ apps/gui/gwps.c | 19 +++++++++++++++---- apps/gui/gwps.h | 5 +++++ apps/gui/wps_parser.c | 14 ++++++++++++-- wps/cabbiev2.320x240x16.mrobe500.wps | 3 ++- 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index 9a69c74bf3..9cfff4cba8 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c @@ -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; } diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c index ae9dc453f5..c89a6fcbb4 100644 --- a/apps/gui/gwps.c +++ b/apps/gui/gwps.c @@ -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; itouchregion_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 diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h index f3562214a0..ac1cbad60b 100644 --- a/apps/gui/gwps.h +++ b/apps/gui/gwps.h @@ -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); diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index 7211e6c86a..bd599509ae 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c @@ -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))) { diff --git a/wps/cabbiev2.320x240x16.mrobe500.wps b/wps/cabbiev2.320x240x16.mrobe500.wps index ad66fbb02b..a18babd0f4 100644 --- a/wps/cabbiev2.320x240x16.mrobe500.wps +++ b/wps/cabbiev2.320x240x16.mrobe500.wps @@ -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 -- cgit v1.2.3