touchscreen: Add flick detector to touchscreen test
rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]>
| Newsgroups | gmane.comp.systems.archos.rockbox.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit a89e1f999d4e267d28d51e5133c56142b7a9b4e7 Author: Aidan MacDonald <[email protected]> Date: Mon Dec 1 20:46:58 2025 +0000 touchscreen: Add flick detector to touchscreen test Change-Id: I9b41881e3e9a271f0532cc9c500e0511c606e895 diff --git a/apps/plugin.c b/apps/plugin.c index d06e9936e3..51b4478421 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -876,6 +876,10 @@ static const struct plugin_api rockbox_api = { /* new stuff at the end, sort into place next time the API gets incompatible */ font_measurestring, +#ifdef HAVE_TOUCHSCREEN + gesture_flick_get_in_vp, + gesture_flick_get, +#endif }; static int plugin_buffer_handle; diff --git a/apps/plugin.h b/apps/plugin.h index 7ccc4b1239..cc10371a35 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -1041,6 +1041,11 @@ struct plugin_api { the API gets incompatible */ int (*font_measurestring)(const unsigned char *str, size_t maxbytes, size_t maxwidth, int *w, int *h, int fontnum); +#ifdef HAVE_TOUCHSCREEN + int (*gesture_flick_get_in_vp)(const struct gesture_event *gevt, + const struct viewport *vp); + int (*gesture_flick_get)(const struct gesture_event *gevt); +#endif }; /* plugin header */ diff --git a/apps/plugins/test_touchscreen.c b/apps/plugins/test_touchscreen.c index af130c4016..3c9e559a45 100644 --- a/apps/plugins/test_touchscreen.c +++ b/apps/plugins/test_touchscreen.c @@ -287,6 +287,55 @@ static void tstest_velocity(void) } } +static void tstest_flick(void) +{ + struct gesture_event gevent; + + rb->splashf(HZ, "Flick test"); + rb->touchscreen_set_mode(TOUCHSCREEN_POINT); + + rb->lcd_clear_display(); + rb->lcd_update(); + + while (true) + { + int action = rb->get_custom_action(CONTEXT_PLUGIN, TIMEOUT_BLOCK, + get_context_map); + if (action == ACTION_TOUCHSCREEN) + { + rb->lcd_clear_display(); + rb->action_gesture_get_event(&gevent); + + switch (rb->gesture_flick_get(&gevent)) { + case GESTURE_FLICK_TOP: + rb->splashf(HZ, "top flick"); + break; + case GESTURE_FLICK_BOTTOM: + rb->splashf(HZ, "bottom flick"); + break; + case GESTURE_FLICK_LEFT: + rb->splashf(HZ, "left flick"); + break; + case GESTURE_FLICK_RIGHT: + rb->splashf(HZ, "right flick"); + break; + } + + rb->lcd_clear_display(); + rb->lcd_update(); + } + else if (action == ACTION_STD_CANCEL) + { + break; + } + else if (rb->default_event_handler(action) == SYS_USB_CONNECTED) + { + usb_exit = true; + break; + } + } +} + /* plugin entry point */ enum plugin_status plugin_start(const void* parameter) { @@ -299,6 +348,7 @@ enum plugin_status plugin_start(const void* parameter) "Pointing mode test", "Gesture test", "Velocity test", + "Flick test", "Quit"); while (true) @@ -322,6 +372,10 @@ enum plugin_status plugin_start(const void* parameter) tstest_velocity(); break; + case 4: + tstest_flick(); + break; + default: return PLUGIN_OK; } -- rockbox-cvs mailing list [email protected] https://lists.haxx.se/mailman/listinfo/rockbox-cvs