From 0eb5dc649f34ca136d0160bf5d43961a2c3cea05 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Mon, 20 Apr 2009 01:41:56 +0000 Subject: beginings of a working touchscreen interface for the WPS. 2 new tags: %T|x|y|width|height|action| <- setup a region (relative to the current viewport) where if pressed the "action" will be done (currently play/stop/prev/next/menu/browse work, suggestions for others to add and better names welcome) %Tl <- used as a conditional to say if the touchscreen was touched in the last , use this to enable/disable button viewports or something... same syntax as other timeout tags cabbiev2 for the mr500 has been modified to demonstrate the new tags. press the pause/play button to pause playback. press the rockbox logo to get back to the menu. pretty icons needed to make this more usable :) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20753 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/gwps.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'apps/gui/gwps.c') diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c index 0c8a3aa2b1..26b531e332 100644 --- a/apps/gui/gwps.c +++ b/apps/gui/gwps.c @@ -293,7 +293,38 @@ void gwps_draw_statusbars(void) { viewportmanager_set_statusbar(wpsbars); } - +#ifdef HAVE_TOUCHSCREEN +static int wps_get_touchaction(struct wps_data *data) +{ + short x,y; + short vx, vy; + int type = action_get_touchscreen_press(&x, &y); + int i; + struct touchregion *r; + if (type != BUTTON_REL) + return ACTION_TOUCHSCREEN; + for (i=0; itouchregion_count; i++) + { + r = &data->touchregion[i]; + /* make sure this region's viewport is visible */ + if (r->wvp->hidden_flags&VP_DRAW_HIDDEN) + continue; + /* reposition the touch inside the viewport */ + vx = x - r->wvp->vp.x; + vy = y - r->wvp->vp.y; + /* check if its inside this viewport */ + if (vx >= 0 && vx < r->wvp->vp.x + r->wvp->vp.width && + vy >= 0 && vy < r->wvp->vp.y + r->wvp->vp.height) + { + /* 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; + } + } + return ACTION_TOUCHSCREEN; +} +#endif /* The WPS can be left in two ways: * a) call a function, which draws over the wps. In this case, the wps * will be still active (i.e. the below function didn't return) @@ -393,6 +424,10 @@ long gui_wps_show(void) playlist or if using the sleep timer. */ if (!(audio_status() & AUDIO_STATUS_PLAY)) exit = true; +#ifdef HAVE_TOUCHSCREEN + if (button == ACTION_TOUCHSCREEN) + button = wps_get_touchaction(gui_wps[SCREEN_MAIN].data); +#endif /* The iPods/X5/M5 use a single button for the A-B mode markers, defined as ACTION_WPSAB_SINGLE in their config files. */ #ifdef ACTION_WPSAB_SINGLE -- cgit v1.2.3