From 93a4b32d03e99d4b542872867ef08bf27e39c091 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Fri, 27 Jan 2012 00:15:15 +0100 Subject: test_codec/test_fps: Use pluginlib_touchscreen API to make them fit for touchscreen including point mode. Enable test_fps on RaaA also. Change-Id: Ifeb60d5ad30bde1f8a645cd9e9d5d5ae34f4425d --- apps/plugins/SOURCES.app_build | 1 + apps/plugins/test_codec.c | 60 +++++++++++++++++++++++++++++++++++++++--- apps/plugins/test_fps.c | 51 ++++++++++++++++++++++++++++++++++- 3 files changed, 107 insertions(+), 5 deletions(-) (limited to 'apps') diff --git a/apps/plugins/SOURCES.app_build b/apps/plugins/SOURCES.app_build index d33f9951cf..a416c3b171 100644 --- a/apps/plugins/SOURCES.app_build +++ b/apps/plugins/SOURCES.app_build @@ -17,6 +17,7 @@ boomshine.lua #ifdef HAVE_TEST_PLUGINS /* enable in advanced build options */ +test_fps.c #ifdef HAVE_ADJUSTABLE_CPU_FREQ test_boost.c #endif diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c index 4c0739f660..50d3fc93ef 100644 --- a/apps/plugins/test_codec.c +++ b/apps/plugins/test_codec.c @@ -19,6 +19,8 @@ * ****************************************************************************/ #include "plugin.h" +#include "lib/pluginlib_touchscreen.h" +#include "lib/pluginlib_exit.h" /* All swcodec targets have BUTTON_SELECT apart from the H10 and M3 */ @@ -42,7 +44,7 @@ #elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD #define TESTCODEC_EXITBUTTON BUTTON_BACK #elif defined(HAVE_TOUCHSCREEN) -#define TESTCODEC_EXITBUTTON BUTTON_TOPLEFT +#define TESTCODEC_EXITBUTTON (BUTTON_BOTTOMMIDDLE|BUTTON_REL) #else #define TESTCODEC_EXITBUTTON BUTTON_SELECT #endif @@ -807,6 +809,54 @@ exit: return res; } +#ifdef HAVE_TOUCHSCREEN +void cleanup(void) +{ + rb->screens[0]->set_viewport(NULL); +} +#endif + + +static struct touchbutton button[] = { + { + .action = ACTION_STD_OK, + .title = "OK", + /* viewport runtime initialized, rest false/NULL */ + } +}; + +void plugin_quit(void) +{ + int btn; +#ifdef HAVE_TOUCHSCREEN + struct viewport *vp = &button[0].vp; + struct screen *lcd = rb->screens[SCREEN_MAIN]; + rb->viewport_set_defaults(vp, SCREEN_MAIN); + const int border = 10; + const int height = 50; + + lcd->set_viewport(vp); + /* button matches the bottom center in the grid */ + vp->x = lcd->lcdwidth/3; + vp->width = lcd->lcdwidth/3; + vp->height = height; + vp->y = lcd->lcdheight - height - border; + + touchbutton_draw(button, ARRAYLEN(button)); + lcd->update_viewport(); + if (rb->touchscreen_get_mode() == TOUCHSCREEN_POINT) + { + while (codec_action != CODEC_ACTION_HALT && + touchbutton_get(button, ARRAYLEN(button)) != ACTION_STD_OK); + } + else +#endif + do { + btn = rb->button_get(true); + exit_on_usb(btn); + } while (codec_action != CODEC_ACTION_HALT && btn != TESTCODEC_EXITBUTTON); +} + /* plugin entry point */ enum plugin_status plugin_start(const void* parameter) { @@ -839,6 +889,10 @@ enum plugin_status plugin_start(const void* parameter) rb->lcd_clear_display(); rb->lcd_update(); +#ifdef HAVE_TOUCHSCREEN + rb->touchscreen_set_mode(rb->global_settings->touch_mode); +#endif + enum { SPEED_TEST = 0, @@ -980,10 +1034,8 @@ menu: close_wav(); log_text("Wrote /test.wav",true); } - - while (codec_action != CODEC_ACTION_HALT && - rb->button_get(true) != TESTCODEC_EXITBUTTON); } + plugin_quit(); #ifdef HAVE_ADJUSTABLE_CPU_FREQ if(boost) diff --git a/apps/plugins/test_fps.c b/apps/plugins/test_fps.c index 4514aa61bb..caabde4d1b 100644 --- a/apps/plugins/test_fps.c +++ b/apps/plugins/test_fps.c @@ -21,6 +21,8 @@ #include "plugin.h" #include "lib/helper.h" #include "lib/grey.h" +#include "lib/pluginlib_touchscreen.h" +#include "lib/pluginlib_exit.h" #if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \ (CONFIG_KEYPAD == IPOD_1G2G_PAD) @@ -39,6 +41,8 @@ #define FPS_QUIT (BUTTON_M|BUTTON_REPEAT) #elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD #define FPS_QUIT BUTTON_BACK +#elif defined(HAVE_TOUCHSCREEN) +#define FPS_QUIT (BUTTON_BOTTOMMIDDLE|BUTTON_REL) #elif defined(BUTTON_OFF) #define FPS_QUIT BUTTON_OFF #else @@ -356,6 +360,47 @@ static void time_greyscale(void) } #endif +static struct touchbutton button[] = { + { + .action = ACTION_STD_OK, + .title = "OK", + /* viewport runtime initialized, rest false/NULL */ + } +}; + +void plugin_quit(void) +{ +#ifdef HAVE_TOUCHSCREEN + struct viewport *vp = &button[0].vp; + struct screen *lcd = rb->screens[SCREEN_MAIN]; + rb->viewport_set_defaults(vp, SCREEN_MAIN); + const int border = 10; + const int height = 50; + + lcd->set_viewport(vp); + /* button matches the bottom center in the grid */ + vp->x = lcd->lcdwidth/3; + vp->width = lcd->lcdwidth/3; + vp->height = height; + vp->y = lcd->lcdheight - height - border; + + touchbutton_draw(button, ARRAYLEN(button)); + lcd->update_viewport(); + if (rb->touchscreen_get_mode() == TOUCHSCREEN_POINT) + { + while(touchbutton_get(button, ARRAYLEN(button)) != ACTION_STD_OK); + } + else +#endif + while (1) + { + int btn = rb->button_get(true); + exit_on_usb(btn); + if (btn == FPS_QUIT) + break; + } +} + /* plugin entry point */ enum plugin_status plugin_start(const void* parameter) { @@ -367,6 +412,10 @@ enum plugin_status plugin_start(const void* parameter) /* standard stuff */ (void)parameter; +#ifdef HAVE_TOUCHSCREEN + rb->touchscreen_set_mode(rb->global_settings->touch_mode); +#endif + log_init(); #if (CONFIG_PLATFORM & PLATFORM_NATIVE) cpu_freq = *rb->cpu_frequency; /* remember CPU frequency */ @@ -396,7 +445,7 @@ enum plugin_status plugin_start(const void* parameter) backlight_use_settings(); /* wait until user closes plugin */ - while (rb->button_get(true) != FPS_QUIT); + plugin_quit(); return PLUGIN_OK; } -- cgit v1.2.3