1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
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();