summaryrefslogtreecommitdiffstats
path: root/apps/action.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-10-11 20:11:48 +0000
committerThomas Martitz <kugel@rockbox.org>2009-10-11 20:11:48 +0000
commit891c446302d341d2e8f6f2da54343589bf46d0e4 (patch)
treebb5cf557c25f5a508430937f5c42d80c622dec6e /apps/action.c
parent6cea8c1e1aa9a7888ceec0cf35181632b5b0eb29 (diff)
downloadrockbox-891c446302d341d2e8f6f2da54343589bf46d0e4.tar.gz
rockbox-891c446302d341d2e8f6f2da54343589bf46d0e4.tar.bz2
rockbox-891c446302d341d2e8f6f2da54343589bf46d0e4.zip
Add a action helper for touchscreen targets to only receive the touchpress coordinates if they're in the passed viewport. Also, fixes the coordinates to be relaitve to the viewport.
Use it in the color picker screen. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23116 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/action.c')
-rw-r--r--apps/action.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/apps/action.c b/apps/action.c
index fc10c927e5..2eef7d9d7b 100644
--- a/apps/action.c
+++ b/apps/action.c
@@ -37,6 +37,7 @@
#if defined(HAVE_LCD_BITMAP) && !defined(BOOTLOADER)
#include "language.h"
#endif
+#include "viewport.h"
static int last_button = BUTTON_NONE|BUTTON_REL; /* allow the ipod wheel to
work on startup */
@@ -386,6 +387,24 @@ int action_get_touchscreen_press(short *x, short *y)
return BUTTON_REPEAT|BUTTON_REL;
return BUTTON_TOUCHSCREEN;
}
+
+int action_get_touchscreen_press_in_vp(short *x1, short *y1, struct viewport *vp)
+{
+ short x, y;
+ int ret;
+
+ ret = action_get_touchscreen_press(&x, &y);
+
+ if (ret != BUTTON_NONE && viewport_point_within_vp(vp, x, y))
+ {
+ *x1 = x - vp->x;
+ *y1 = y - vp->y;
+ return ret;
+ }
+ if (ret & BUTTON_TOUCHSCREEN)
+ return ACTION_UNKNOWN;
+ return BUTTON_NONE;
+}
#endif
/* Don't let get_action*() return any ACTION_* values untill the current buttons