diff options
author | Thomas Martitz <kugel@rockbox.org> | 2012-01-27 00:15:15 +0100 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2012-01-27 09:15:05 +0100 |
commit | 93a4b32d03e99d4b542872867ef08bf27e39c091 (patch) | |
tree | 8d7f9ff838810fd8bf21b4cc46a4e6dbb790994a | |
parent | 049f3c782a74258640e4f5c165496c282b4203dd (diff) | |
download | rockbox-93a4b32d03e99d4b542872867ef08bf27e39c091.tar.gz rockbox-93a4b32d03e99d4b542872867ef08bf27e39c091.zip |
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
-rw-r--r-- | apps/plugins/SOURCES.app_build | 1 | ||||
-rw-r--r-- | apps/plugins/test_codec.c | 60 | ||||
-rw-r--r-- | apps/plugins/test_fps.c | 51 |
3 files changed, 107 insertions, 5 deletions
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 | |||
17 | 17 | ||
18 | 18 | ||
19 | #ifdef HAVE_TEST_PLUGINS /* enable in advanced build options */ | 19 | #ifdef HAVE_TEST_PLUGINS /* enable in advanced build options */ |
20 | test_fps.c | ||
20 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 21 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
21 | test_boost.c | 22 | test_boost.c |
22 | #endif | 23 | #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 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include "plugin.h" | 21 | #include "plugin.h" |
22 | #include "lib/pluginlib_touchscreen.h" | ||
23 | #include "lib/pluginlib_exit.h" | ||
22 | 24 | ||
23 | /* All swcodec targets have BUTTON_SELECT apart from the H10 and M3 */ | 25 | /* All swcodec targets have BUTTON_SELECT apart from the H10 and M3 */ |
24 | 26 | ||
@@ -42,7 +44,7 @@ | |||
42 | #elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD | 44 | #elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD |
43 | #define TESTCODEC_EXITBUTTON BUTTON_BACK | 45 | #define TESTCODEC_EXITBUTTON BUTTON_BACK |
44 | #elif defined(HAVE_TOUCHSCREEN) | 46 | #elif defined(HAVE_TOUCHSCREEN) |
45 | #define TESTCODEC_EXITBUTTON BUTTON_TOPLEFT | 47 | #define TESTCODEC_EXITBUTTON (BUTTON_BOTTOMMIDDLE|BUTTON_REL) |
46 | #else | 48 | #else |
47 | #define TESTCODEC_EXITBUTTON BUTTON_SELECT | 49 | #define TESTCODEC_EXITBUTTON BUTTON_SELECT |
48 | #endif | 50 | #endif |
@@ -807,6 +809,54 @@ exit: | |||
807 | return res; | 809 | return res; |
808 | } | 810 | } |
809 | 811 | ||
812 | #ifdef HAVE_TOUCHSCREEN | ||
813 | void cleanup(void) | ||
814 | { | ||
815 | rb->screens[0]->set_viewport(NULL); | ||
816 | } | ||
817 | #endif | ||
818 | |||
819 | |||
820 | static struct touchbutton button[] = { | ||
821 | { | ||
822 | .action = ACTION_STD_OK, | ||
823 | .title = "OK", | ||
824 | /* viewport runtime initialized, rest false/NULL */ | ||
825 | } | ||
826 | }; | ||
827 | |||
828 | void plugin_quit(void) | ||
829 | { | ||
830 | int btn; | ||
831 | #ifdef HAVE_TOUCHSCREEN | ||
832 | struct viewport *vp = &button[0].vp; | ||
833 | struct screen *lcd = rb->screens[SCREEN_MAIN]; | ||
834 | rb->viewport_set_defaults(vp, SCREEN_MAIN); | ||
835 | const int border = 10; | ||
836 | const int height = 50; | ||
837 | |||
838 | lcd->set_viewport(vp); | ||
839 | /* button matches the bottom center in the grid */ | ||
840 | vp->x = lcd->lcdwidth/3; | ||
841 | vp->width = lcd->lcdwidth/3; | ||
842 | vp->height = height; | ||
843 | vp->y = lcd->lcdheight - height - border; | ||
844 | |||
845 | touchbutton_draw(button, ARRAYLEN(button)); | ||
846 | lcd->update_viewport(); | ||
847 | if (rb->touchscreen_get_mode() == TOUCHSCREEN_POINT) | ||
848 | { | ||
849 | while (codec_action != CODEC_ACTION_HALT && | ||
850 | touchbutton_get(button, ARRAYLEN(button)) != ACTION_STD_OK); | ||
851 | } | ||
852 | else | ||
853 | #endif | ||
854 | do { | ||
855 | btn = rb->button_get(true); | ||
856 | exit_on_usb(btn); | ||
857 | } while (codec_action != CODEC_ACTION_HALT && btn != TESTCODEC_EXITBUTTON); | ||
858 | } | ||
859 | |||
810 | /* plugin entry point */ | 860 | /* plugin entry point */ |
811 | enum plugin_status plugin_start(const void* parameter) | 861 | enum plugin_status plugin_start(const void* parameter) |
812 | { | 862 | { |
@@ -839,6 +889,10 @@ enum plugin_status plugin_start(const void* parameter) | |||
839 | rb->lcd_clear_display(); | 889 | rb->lcd_clear_display(); |
840 | rb->lcd_update(); | 890 | rb->lcd_update(); |
841 | 891 | ||
892 | #ifdef HAVE_TOUCHSCREEN | ||
893 | rb->touchscreen_set_mode(rb->global_settings->touch_mode); | ||
894 | #endif | ||
895 | |||
842 | enum | 896 | enum |
843 | { | 897 | { |
844 | SPEED_TEST = 0, | 898 | SPEED_TEST = 0, |
@@ -980,10 +1034,8 @@ menu: | |||
980 | close_wav(); | 1034 | close_wav(); |
981 | log_text("Wrote /test.wav",true); | 1035 | log_text("Wrote /test.wav",true); |
982 | } | 1036 | } |
983 | |||
984 | while (codec_action != CODEC_ACTION_HALT && | ||
985 | rb->button_get(true) != TESTCODEC_EXITBUTTON); | ||
986 | } | 1037 | } |
1038 | plugin_quit(); | ||
987 | 1039 | ||
988 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 1040 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
989 | if(boost) | 1041 | 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 @@ | |||
21 | #include "plugin.h" | 21 | #include "plugin.h" |
22 | #include "lib/helper.h" | 22 | #include "lib/helper.h" |
23 | #include "lib/grey.h" | 23 | #include "lib/grey.h" |
24 | #include "lib/pluginlib_touchscreen.h" | ||
25 | #include "lib/pluginlib_exit.h" | ||
24 | 26 | ||
25 | #if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \ | 27 | #if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \ |
26 | (CONFIG_KEYPAD == IPOD_1G2G_PAD) | 28 | (CONFIG_KEYPAD == IPOD_1G2G_PAD) |
@@ -39,6 +41,8 @@ | |||
39 | #define FPS_QUIT (BUTTON_M|BUTTON_REPEAT) | 41 | #define FPS_QUIT (BUTTON_M|BUTTON_REPEAT) |
40 | #elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD | 42 | #elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD |
41 | #define FPS_QUIT BUTTON_BACK | 43 | #define FPS_QUIT BUTTON_BACK |
44 | #elif defined(HAVE_TOUCHSCREEN) | ||
45 | #define FPS_QUIT (BUTTON_BOTTOMMIDDLE|BUTTON_REL) | ||
42 | #elif defined(BUTTON_OFF) | 46 | #elif defined(BUTTON_OFF) |
43 | #define FPS_QUIT BUTTON_OFF | 47 | #define FPS_QUIT BUTTON_OFF |
44 | #else | 48 | #else |
@@ -356,6 +360,47 @@ static void time_greyscale(void) | |||
356 | } | 360 | } |
357 | #endif | 361 | #endif |
358 | 362 | ||
363 | static struct touchbutton button[] = { | ||
364 | { | ||
365 | .action = ACTION_STD_OK, | ||
366 | .title = "OK", | ||
367 | /* viewport runtime initialized, rest false/NULL */ | ||
368 | } | ||
369 | }; | ||
370 | |||
371 | void plugin_quit(void) | ||
372 | { | ||
373 | #ifdef HAVE_TOUCHSCREEN | ||
374 | struct viewport *vp = &button[0].vp; | ||
375 | struct screen *lcd = rb->screens[SCREEN_MAIN]; | ||
376 | rb->viewport_set_defaults(vp, SCREEN_MAIN); | ||
377 | const int border = 10; | ||
378 | const int height = 50; | ||
379 | |||
380 | lcd->set_viewport(vp); | ||
381 | /* button matches the bottom center in the grid */ | ||
382 | vp->x = lcd->lcdwidth/3; | ||
383 | vp->width = lcd->lcdwidth/3; | ||
384 | vp->height = height; | ||
385 | vp->y = lcd->lcdheight - height - border; | ||
386 | |||
387 | touchbutton_draw(button, ARRAYLEN(button)); | ||
388 | lcd->update_viewport(); | ||
389 | if (rb->touchscreen_get_mode() == TOUCHSCREEN_POINT) | ||
390 | { | ||
391 | while(touchbutton_get(button, ARRAYLEN(button)) != ACTION_STD_OK); | ||
392 | } | ||
393 | else | ||
394 | #endif | ||
395 | while (1) | ||
396 | { | ||
397 | int btn = rb->button_get(true); | ||
398 | exit_on_usb(btn); | ||
399 | if (btn == FPS_QUIT) | ||
400 | break; | ||
401 | } | ||
402 | } | ||
403 | |||
359 | /* plugin entry point */ | 404 | /* plugin entry point */ |
360 | enum plugin_status plugin_start(const void* parameter) | 405 | enum plugin_status plugin_start(const void* parameter) |
361 | { | 406 | { |
@@ -367,6 +412,10 @@ enum plugin_status plugin_start(const void* parameter) | |||
367 | /* standard stuff */ | 412 | /* standard stuff */ |
368 | (void)parameter; | 413 | (void)parameter; |
369 | 414 | ||
415 | #ifdef HAVE_TOUCHSCREEN | ||
416 | rb->touchscreen_set_mode(rb->global_settings->touch_mode); | ||
417 | #endif | ||
418 | |||
370 | log_init(); | 419 | log_init(); |
371 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) | 420 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
372 | cpu_freq = *rb->cpu_frequency; /* remember CPU frequency */ | 421 | cpu_freq = *rb->cpu_frequency; /* remember CPU frequency */ |
@@ -396,7 +445,7 @@ enum plugin_status plugin_start(const void* parameter) | |||
396 | backlight_use_settings(); | 445 | backlight_use_settings(); |
397 | 446 | ||
398 | /* wait until user closes plugin */ | 447 | /* wait until user closes plugin */ |
399 | while (rb->button_get(true) != FPS_QUIT); | 448 | plugin_quit(); |
400 | 449 | ||
401 | return PLUGIN_OK; | 450 | return PLUGIN_OK; |
402 | } | 451 | } |