diff --git a/apps/plugin.c b/apps/plugin.c
index 2528075..8f2f166 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -326,6 +326,7 @@ static const struct plugin_api rockbox_api = {
#endif
#ifdef HAVE_TOUCHSCREEN
touchscreen_set_mode,
+ touchscreen_get_mode,
#endif

#ifdef HAVE_BUTTON_LIGHT
@@ -657,6 +658,7 @@ static const struct plugin_api rockbox_api = {
get_action,
#ifdef HAVE_TOUCHSCREEN
action_get_touchscreen_press,
+ action_get_touchscreen_press_in_vp,
#endif
action_userabort,

diff --git a/apps/plugin.h b/apps/plugin.h
index d83f6f4..406b488 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -413,6 +413,7 @@ struct plugin_api {
#endif
#ifdef HAVE_TOUCHSCREEN
void (*touchscreen_set_mode)(enum touchscreen_mode);
+ enum touchscreen_mode (*touchscreen_get_mode)(void);
#endif
#ifdef HAVE_BUTTON_LIGHT
void (*buttonlight_set_timeout)(int value);
@@ -789,6 +790,7 @@ struct plugin_api {
int (*get_action)(int context, int timeout);
#ifdef HAVE_TOUCHSCREEN
int (*action_get_touchscreen_press)(short *x, short *y);
+ int (*action_get_touchscreen_press_in_vp)(short *x, short *y, struct viewport *vp);
#endif
bool (*action_userabort)(int timeout);

diff --git a/apps/plugins/CATEGORIES b/apps/plugins/CATEGORIES
index 0ac5bdb..427f319 100644
--- a/apps/plugins/CATEGORIES
+++ b/apps/plugins/CATEGORIES
@@ -109,8 +109,8 @@ test_mem,apps
test_codec,viewers
test_disk,apps
test_fps,apps
-test_grey,apps
test_gfx,apps
+test_grey,apps
test_resize,apps
test_sampr,apps
test_scanrate,apps
diff --git a/apps/plugins/SOURCES.app_build b/apps/plugins/SOURCES.app_build
index e374062..e42e464 100644
--- a/apps/plugins/SOURCES.app_build
+++ b/apps/plugins/SOURCES.app_build
@@ -12,6 +12,7 @@ theme_remove.c
vbrfix.c

#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/SUBDIRS b/apps/plugins/SUBDIRS
index d2feb72..f374b45 100644
--- a/apps/plugins/SUBDIRS
+++ b/apps/plugins/SUBDIRS
@@ -1,3 +1,11 @@
+#ifdef HAVE_TAGCACHE
+pictureflow
+#endif
+
+#if CONFIG_CODEC == SWCODEC && PLUGIN_BUFFER_SIZE > 0x20000
+fft
+#endif
+#ifndef APPLICATION
/* For all targets */
shortcuts
text_viewer
@@ -21,14 +29,6 @@ clock
rockboy
#endif

-#ifdef HAVE_TAGCACHE
-pictureflow
-#endif
-
-#if CONFIG_CODEC == SWCODEC && PLUGIN_BUFFER_SIZE > 0x20000
-fft
-#endif
-
chessbox
fractals
imageviewer
@@ -88,3 +88,5 @@ mpegplayer
#if PLUGIN_BUFFER_SIZE >= 0x80000
lua
#endif
+
+#endif /* APPLICATION */
diff --git a/apps/plugins/chopper.c b/apps/plugins/chopper.c
index d819da4..b2c3653 100644
--- a/apps/plugins/chopper.c
+++ b/apps/plugins/chopper.c
@@ -180,7 +180,7 @@ CONFIG_KEYPAD == MROBE500_PAD
#define ACTION BUTTON_SELECT
#define ACTIONTEXT "SELECT"

-#else
+#elif !defined(HAVE_TOUCHSCREEN)
#error No keymap defined!
#endif

diff --git a/apps/plugins/fft/fft.c b/apps/plugins/fft/fft.c
index b2ef8d8..1c4e1b4 100644
--- a/apps/plugins/fft/fft.c
+++ b/apps/plugins/fft/fft.c
@@ -266,7 +266,7 @@ GREY_INFO_STRUCT
# define FFT_FREQ_SCALE BUTTON_DOWN
# define FFT_QUIT BUTTON_BACK

-#else
+#elif !defined(HAVE_TOUCHSCREEN)
#error No keymap defined!
#endif

diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c
index 4c0739f..f02b3b7 100644
--- a/apps/plugins/test_codec.c
+++ b/apps/plugins/test_codec.c
@@ -42,7 +42,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
#else
#define TESTCODEC_EXITBUTTON BUTTON_SELECT
#endif
@@ -807,6 +807,52 @@ exit:
return res;
}

+#ifdef HAVE_TOUCHSCREEN
+void cleanup(void)
+{
+ rb->screens[0]->set_viewport(NULL);
+}
+#endif
+
+void plugin_quit(void)
+{
+#ifdef HAVE_TOUCHSCREEN
+ struct viewport vp;
+ struct screen *lcd = rb->screens[SCREEN_MAIN];
+ rb->viewport_set_defaults(&vp, SCREEN_MAIN);
+ int font_height = rb->font_get(vp.font)->height;
+ int yoff;
+
+ vp.x = 10;
+ vp.width = lcd->lcdwidth - 20;
+ vp.y = lcd->lcdheight - 60;
+ vp.height = 50;
+ vp.flags = VP_FLAG_ALIGN_CENTER;
+
+ yoff = vp.height/2 - font_height/2;
+ lcd->set_viewport(&vp);
+ atexit(cleanup);
+ lcd->clear_viewport();
+ lcd->set_foreground(LCD_WHITE);
+ lcd->putsxy(0, yoff, "OK");
+ lcd->drawrect(vp.x, vp.y, vp.width, vp.height);
+ lcd->update_viewport();
+ short x,y;
+ if (rb->touchscreen_get_mode() == TOUCHSCREEN_POINT)
+ {
+ while(1)
+ {
+ rb->get_action(CONTEXT_STD, TIMEOUT_BLOCK);
+ if (rb->action_get_touchscreen_press_in_vp(&x, &y, &vp) & BUTTON_REL)
+ break;
+ }
+ }
+ else
+#endif
+ while (codec_action != CODEC_ACTION_HALT &&
+ rb->button_get(true) != TESTCODEC_EXITBUTTON);
+}
+
/* plugin entry point */
enum plugin_status plugin_start(const void* parameter)
{
@@ -980,9 +1026,7 @@ 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
diff --git a/apps/plugins/test_fps.c b/apps/plugins/test_fps.c
index 4514aa6..ac19954 100644
--- a/apps/plugins/test_fps.c
+++ b/apps/plugins/test_fps.c
@@ -39,6 +39,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 +358,51 @@ static void time_greyscale(void)
}
#endif

+#ifdef HAVE_TOUCHSCREEN
+void cleanup(void)
+{
+ rb->screens[0]->set_viewport(NULL);
+}
+#endif
+
+void plugin_quit(void)
+{
+#ifdef HAVE_TOUCHSCREEN
+ struct viewport vp;
+ struct screen *lcd = rb->screens[SCREEN_MAIN];
+ rb->viewport_set_defaults(&vp, SCREEN_MAIN);
+ int font_height = rb->font_get(vp.font)->height;
+ int yoff;
+
+ vp.x = 10;
+ vp.width = lcd->lcdwidth - 20;
+ vp.y = lcd->lcdheight - 60;
+ vp.height = 50;
+ vp.flags = VP_FLAG_ALIGN_CENTER;
+
+ yoff = vp.height/2 - font_height/2;
+ lcd->set_viewport(&vp);
+ atexit(cleanup);
+ lcd->clear_viewport();
+ lcd->set_foreground(LCD_WHITE);
+ lcd->drawrect(vp.x, vp.y, vp.width, vp.height);
+ lcd->putsxy(0, yoff, "OK");
+ lcd->update_viewport();
+ short x,y;
+ if (rb->touchscreen_get_mode() == TOUCHSCREEN_POINT)
+ {
+ while(1)
+ {
+ rb->get_action(CONTEXT_STD, TIMEOUT_BLOCK);
+ if (rb->action_get_touchscreen_press_in_vp(&x, &y, &vp) & BUTTON_REL)
+ break;
+ }
+ }
+ else
+#endif
+ while (rb->button_get(true) != FPS_QUIT);
+}
+
/* plugin entry point */
enum plugin_status plugin_start(const void* parameter)
{
@@ -376,6 +423,7 @@ enum plugin_status plugin_start(const void* parameter)
time_main_update();
rb->sleep(HZ);
#if defined(HAVE_LCD_COLOR) && (MEMORYSIZE > 2)
+ rb->sleep(HZ/2); /* sleep a bit to see numbers */
time_main_yuv();
#endif
#if LCD_DEPTH < 4
@@ -396,7 +444,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;
}
diff --git a/apps/plugins/test_touchscreen.c b/apps/plugins/test_touchscreen.c
index 0c9cdc7..eb03b6d 100644
--- a/apps/plugins/test_touchscreen.c
+++ b/apps/plugins/test_touchscreen.c
@@ -31,6 +31,12 @@
#elif (CONFIG_KEYPAD == ONDAVX747_PAD)
#define TOUCHSCREEN_QUIT BUTTON_POWER
#define TOUCHSCREEN_TOGGLE BUTTON_MENU
+#elif (CONFIG_KEYPAD == ANDROID_PAD)
+#define TOUCHSCREEN_QUIT BUTTON_BACK
+#define TOUCHSCREEN_TOGGLE BUTTON_MENU
+#elif (CONFIG_KEYPAD == SDL_PAD)
+#define TOUCHSCREEN_QUIT BUTTON_MIDLEFT
+#define TOUCHSCREEN_TOGGLE BUTTON_CENTER
#endif

/* plugin entry point */
@@ -104,7 +110,6 @@ enum plugin_status plugin_start(const void* parameter)
mode = (mode == TOUCHSCREEN_POINT) ? TOUCHSCREEN_BUTTON : TOUCHSCREEN_POINT;
rb->touchscreen_set_mode(mode);
}
-
if (button & BUTTON_REL) draw_rect = false;

rb->lcd_clear_display();