From 3af20f428a34f8e2703233db28d211bad0466695 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Sun, 10 Oct 2010 00:37:50 +0200 Subject: [PATCH] enable some test plugins --- apps/plugin.c | 3 +++ apps/plugin.h | 4 +++ apps/plugins/SOURCES | 3 ++- apps/plugins/SUBDIRS | 3 +++ apps/plugins/test_codec.c | 56 +++++++++++++++++++++++++++++++++++++++-- apps/plugins/test_fps.c | 50 +++++++++++++++++++++++++++++++++++- apps/plugins/test_gfx.c | 6 ++--- apps/plugins/test_touchscreen.c | 4 ++- tools/configure | 2 +- 9 files changed, 122 insertions(+), 9 deletions(-) diff --git a/apps/plugin.c b/apps/plugin.c index 28c585479..f3d6db692 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -290,6 +290,7 @@ static const struct plugin_api rockbox_api = { #endif #ifdef HAVE_TOUCHSCREEN touchscreen_set_mode, + touchscreen_get_mode, #endif #ifdef HAVE_BUTTON_LIGHT @@ -587,6 +588,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, @@ -728,6 +730,7 @@ static const struct plugin_api rockbox_api = { lc_open_from_mem, lc_get_header, lc_close, + get_user_file_path, }; int plugin_load(const char* plugin, const void* parameter) diff --git a/apps/plugin.h b/apps/plugin.h index cbfc48bd0..31c4440ed 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -406,6 +406,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); @@ -735,6 +736,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); @@ -901,6 +903,8 @@ struct plugin_api { void* (*lc_open_from_mem)(void* addr, size_t blob_size); void* (*lc_get_header)(void *handle); void (*lc_close)(void *handle); + const char* (*get_user_file_path)(const char *path, unsigned flags, + char* buf, const size_t bufsize); }; /* plugin header */ diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index 21b9cecee..549279597 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES @@ -1,3 +1,4 @@ +#ifndef APPLICATION /* plugins common to all models */ chessclock.c credits.c @@ -213,7 +214,7 @@ superdom.c #endif /* LCD_DEPTH > 1 */ - +#endif /* APPLICATION */ #ifdef HAVE_TEST_PLUGINS /* enable in advanced build options */ #ifdef HAVE_ADJUSTABLE_CPU_FREQ diff --git a/apps/plugins/SUBDIRS b/apps/plugins/SUBDIRS index 33efc5f12..6a0911c08 100644 --- a/apps/plugins/SUBDIRS +++ b/apps/plugins/SUBDIRS @@ -1,3 +1,4 @@ +#ifndef APPLICATION /* For all targets */ shortcuts text_viewer @@ -87,3 +88,5 @@ mpegplayer #if PLUGIN_BUFFER_SIZE >= 0x80000 lua #endif + +#endif /* APPLICATION */ diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c index 0c2e694eb..6eb5eb3dc 100644 --- a/apps/plugins/test_codec.c +++ b/apps/plugins/test_codec.c @@ -35,7 +35,7 @@ #elif CONFIG_KEYPAD == PBELL_VIBE500_PAD #define TESTCODEC_EXITBUTTON BUTTON_REC #elif defined(HAVE_TOUCHSCREEN) -#define TESTCODEC_EXITBUTTON BUTTON_TOPLEFT +#define TESTCODEC_EXITBUTTON BUTTON_BOTTOMMIDDLE #else #define TESTCODEC_EXITBUTTON BUTTON_SELECT #endif @@ -64,8 +64,15 @@ static bool log_init(bool use_logfile) if (use_logfile) { log_close(); +#if (CONFIG_PLATFORM & PLATFORM_HOSTED) && !defined(SIMULATOR) + rb->get_user_file_path(ROCKBOX_DIR, NEED_WRITE|IS_FILE|FORCE_BUFFER_COPY, + logfilename, sizeof(logfilename)); + rb->create_numbered_filename(logfilename, logfilename, "test_codec_log_", ".txt", + 2 IF_CNFN_NUM_(, NULL)); +#else rb->create_numbered_filename(logfilename, "/", "test_codec_log_", ".txt", 2 IF_CNFN_NUM_(, NULL)); +#endif log_fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC, 0666); return log_fd >= 0; } @@ -782,6 +789,51 @@ 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 (rb->button_get(true) != TESTCODEC_EXITBUTTON); +} + /* plugin entry point */ enum plugin_status plugin_start(const void* parameter) { @@ -924,7 +976,7 @@ show_menu: close_wav(); log_text("Wrote /test.wav",true); } - while (rb->button_get(true) != TESTCODEC_EXITBUTTON); + plugin_quit(); } rb->button_clear_queue(); goto show_menu; diff --git a/apps/plugins/test_fps.c b/apps/plugins/test_fps.c index 4f197e0d5..99919923f 100644 --- a/apps/plugins/test_fps.c +++ b/apps/plugins/test_fps.c @@ -33,6 +33,8 @@ #define FPS_QUIT (BUTTON_HOME|BUTTON_REPEAT) #elif CONFIG_KEYPAD == MPIO_HD200_PAD #define FPS_QUIT (BUTTON_REC|BUTTON_PLAY) +#elif defined(HAVE_TOUCHSCREEN) +#define FPS_QUIT (BUTTON_BOTTOMMIDDLE|BUTTON_REL) #elif defined(BUTTON_OFF) #define FPS_QUIT BUTTON_OFF #else @@ -350,6 +352,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) { @@ -369,6 +416,7 @@ enum plugin_status plugin_start(const void* parameter) time_main_update(); #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 @@ -389,7 +437,7 @@ enum plugin_status plugin_start(const void* parameter) backlight_use_settings(); /* backlight control in lib/helper.c */ /* wait until user closes plugin */ - while (rb->button_get(true) != FPS_QUIT); + plugin_quit(); return PLUGIN_OK; } diff --git a/apps/plugins/test_gfx.c b/apps/plugins/test_gfx.c index aa898549b..2960f17dd 100644 --- a/apps/plugins/test_gfx.c +++ b/apps/plugins/test_gfx.c @@ -402,7 +402,7 @@ static void time_text(void) /* tests mono_bitmap performance */ /* plugin entry point */ enum plugin_status plugin_start(const void* parameter) { -#ifndef SIMULATOR +#if CONFIG_PLATFORM & PLATFORM_NATIVE int cpu_freq; #endif @@ -447,7 +447,7 @@ enum plugin_status plugin_start(const void* parameter) 6*4*DURATION/HZ); init_rand_table(); -#ifndef SIMULATOR +#if CONFIG_PLATFORM & PLATFORM_NATIVE cpu_freq = *rb->cpu_frequency; /* remember CPU frequency */ #endif @@ -458,7 +458,7 @@ enum plugin_status plugin_start(const void* parameter) time_fillrect(); time_text(); -#ifndef SIMULATOR +#if CONFIG_PLATFORM & PLATFORM_NATIVE if (*rb->cpu_frequency != cpu_freq) rb->fdprintf(log_fd, "\nCPU: %s\n", "clock changed!"); else diff --git a/apps/plugins/test_touchscreen.c b/apps/plugins/test_touchscreen.c index 0c9cdc730..25aa21771 100644 --- a/apps/plugins/test_touchscreen.c +++ b/apps/plugins/test_touchscreen.c @@ -31,6 +31,9 @@ #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 #endif /* plugin entry point */ @@ -104,7 +107,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(); diff --git a/tools/configure b/tools/configure index e716439ca..d820cdb21 100755 --- a/tools/configure +++ b/tools/configure @@ -2731,7 +2731,7 @@ fi bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" bmp2rb_native="$rootdir/tools/bmp2rb -f 4" appextra="recorder:gui:radio" - plugins="" + plugins="yes" swcodec="yes" # architecture, manufacturer and model for the target-tree build t_cpu="hosted" -- 2.11.4.GIT