Index: uisimulator/sdl/button_defines.h =================================================================== --- uisimulator/sdl/button_defines.h (revision 0) +++ uisimulator/sdl/button_defines.h (revision 0) @@ -0,0 +1,202 @@ +/* + * Generated with the following command: + * for b in $(grep -o "BUTTON[_A-Z]*" button.c |sort |uniq); do + * printf "#ifdef %s\n { \"%s\", %s },\n#endif\n" $b $b $b >> button_defines.h + * done + * + * Plus some manual editing + */ +struct buttonpairs { + char *define; + int value; +}; + +static struct buttonpairs buttons[] = { + + /* USB connection events */ +#ifdef SYS_USB_CONNECTED + { "SYS_USB_CONNECTED", SYS_USB_CONNECTED }, +#endif +#ifdef SYS_USB_DISCONNECTED + { "SYS_USB_DISCONNECTED", SYS_USB_DISCONNECTED }, +#endif + + /* Button events */ +#ifdef BUTTON_A + { "BUTTON_A", BUTTON_A }, +#endif +#ifdef BUTTON_BACK + { "BUTTON_BACK", BUTTON_BACK }, +#endif +#ifdef BUTTON_BOTTOMLEFT + { "BUTTON_BOTTOMLEFT", BUTTON_BOTTOMLEFT }, +#endif +#ifdef BUTTON_BOTTOMMIDDLE + { "BUTTON_BOTTOMMIDDLE", BUTTON_BOTTOMMIDDLE }, +#endif +#ifdef BUTTON_BOTTOMRIGHT + { "BUTTON_BOTTOMRIGHT", BUTTON_BOTTOMRIGHT }, +#endif +#ifdef BUTTON_CENTER + { "BUTTON_CENTER", BUTTON_CENTER }, +#endif +#ifdef BUTTON_CUSTOM + { "BUTTON_CUSTOM", BUTTON_CUSTOM }, +#endif +#ifdef BUTTON_DISPLAY + { "BUTTON_DISPLAY", BUTTON_DISPLAY }, +#endif +#ifdef BUTTON_DOWN + { "BUTTON_DOWN", BUTTON_DOWN }, +#endif +#ifdef BUTTON_EQ + { "BUTTON_EQ", BUTTON_EQ }, +#endif +#ifdef BUTTON_F + { "BUTTON_F", BUTTON_F }, +#endif +#ifdef BUTTON_FF + { "BUTTON_FF", BUTTON_FF }, +#endif +#ifdef BUTTON_FFWD + { "BUTTON_FFWD", BUTTON_FFWD }, +#endif +#ifdef BUTTON_HOLD + { "BUTTON_HOLD", BUTTON_HOLD }, +#endif +#ifdef BUTTON_HOME + { "BUTTON_HOME", BUTTON_HOME }, +#endif +#ifdef BUTTON_LEFT + { "BUTTON_LEFT", BUTTON_LEFT }, +#endif +#ifdef BUTTON_MENU + { "BUTTON_MENU", BUTTON_MENU }, +#endif +#ifdef BUTTON_MIDLEFT + { "BUTTON_MIDLEFT", BUTTON_MIDLEFT }, +#endif +#ifdef BUTTON_MIDRIGHT + { "BUTTON_MIDRIGHT", BUTTON_MIDRIGHT }, +#endif +#ifdef BUTTON_MINUS + { "BUTTON_MINUS", BUTTON_MINUS }, +#endif +#ifdef BUTTON_MODE + { "BUTTON_MODE", BUTTON_MODE }, +#endif +#ifdef BUTTON_NEXT + { "BUTTON_NEXT", BUTTON_NEXT }, +#endif +#ifdef BUTTON_NONE + { "BUTTON_NONE", BUTTON_NONE }, +#endif +#ifdef BUTTON_OFF + { "BUTTON_OFF", BUTTON_OFF }, +#endif +#ifdef BUTTON_ON + { "BUTTON_ON", BUTTON_ON }, +#endif +#ifdef BUTTON_PLAY + { "BUTTON_PLAY", BUTTON_PLAY }, +#endif +#ifdef BUTTON_PLAYLIST + { "BUTTON_PLAYLIST", BUTTON_PLAYLIST }, +#endif +#ifdef BUTTON_PLUS + { "BUTTON_PLUS", BUTTON_PLUS }, +#endif +#ifdef BUTTON_POWER + { "BUTTON_POWER", BUTTON_POWER }, +#endif +#ifdef BUTTON_PREV + { "BUTTON_PREV", BUTTON_PREV }, +#endif +#ifdef BUTTON_RC_DOWN + { "BUTTON_RC_DOWN", BUTTON_RC_DOWN }, +#endif +#ifdef BUTTON_RC_FF + { "BUTTON_RC_FF", BUTTON_RC_FF }, +#endif +#ifdef BUTTON_RC_HEART + { "BUTTON_RC_HEART", BUTTON_RC_HEART }, +#endif +#ifdef BUTTON_RC_MODE + { "BUTTON_RC_MODE", BUTTON_RC_MODE }, +#endif +#ifdef BUTTON_RC_PLAY + { "BUTTON_RC_PLAY", BUTTON_RC_PLAY }, +#endif +#ifdef BUTTON_RC_REW + { "BUTTON_RC_REW", BUTTON_RC_REW }, +#endif +#ifdef BUTTON_RC_VOL_DOWN + { "BUTTON_RC_VOL_DOWN", BUTTON_RC_VOL_DOWN }, +#endif +#ifdef BUTTON_RC_VOL_UP + { "BUTTON_RC_VOL_UP", BUTTON_RC_VOL_UP }, +#endif +#ifdef BUTTON_REC + { "BUTTON_REC", BUTTON_REC }, +#endif +#ifdef BUTTON_REMOTE + { "BUTTON_REMOTE", BUTTON_REMOTE }, +#endif +#ifdef BUTTON_REPEAT + { "BUTTON_REPEAT", BUTTON_REPEAT }, +#endif +#ifdef BUTTON_REW + { "BUTTON_REW", BUTTON_REW }, +#endif +#ifdef BUTTON_RIGHT + { "BUTTON_RIGHT", BUTTON_RIGHT }, +#endif +#ifdef BUTTON_SCROLL_BACK + { "BUTTON_SCROLL_BACK", BUTTON_SCROLL_BACK }, +#endif +#ifdef BUTTON_SCROLL_DOWN + { "BUTTON_SCROLL_DOWN", BUTTON_SCROLL_DOWN }, +#endif +#ifdef BUTTON_SCROLL_FWD + { "BUTTON_SCROLL_FWD", BUTTON_SCROLL_FWD }, +#endif +#ifdef BUTTON_SCROLL_UP + { "BUTTON_SCROLL_UP", BUTTON_SCROLL_UP }, +#endif +#ifdef BUTTON_SELECT + { "BUTTON_SELECT", BUTTON_SELECT }, +#endif +#ifdef BUTTON_STOP + { "BUTTON_STOP", BUTTON_STOP }, +#endif +#ifdef BUTTON_TOPLEFT + { "BUTTON_TOPLEFT", BUTTON_TOPLEFT }, +#endif +#ifdef BUTTON_TOPMIDDLE + { "BUTTON_TOPMIDDLE", BUTTON_TOPMIDDLE }, +#endif +#ifdef BUTTON_TOPRIGHT + { "BUTTON_TOPRIGHT", BUTTON_TOPRIGHT }, +#endif +#ifdef BUTTON_TOUCHSCREEN + { "BUTTON_TOUCHSCREEN", BUTTON_TOUCHSCREEN }, +#endif +#ifdef BUTTON_UP + { "BUTTON_UP", BUTTON_UP }, +#endif +#ifdef BUTTON_VIEW + { "BUTTON_VIEW", BUTTON_VIEW }, +#endif +#ifdef BUTTON_VOLDOWN + { "BUTTON_VOLDOWN", BUTTON_VOLDOWN }, +#endif +#ifdef BUTTON_VOL_DOWN + { "BUTTON_VOL_DOWN", BUTTON_VOL_DOWN }, +#endif +#ifdef BUTTON_VOLUP + { "BUTTON_VOLUP", BUTTON_VOLUP }, +#endif +#ifdef BUTTON_VOL_UP + { "BUTTON_VOL_UP", BUTTON_VOL_UP }, +#endif +}; Index: uisimulator/sdl/uisdl.c =================================================================== --- uisimulator/sdl/uisdl.c (revision 22563) +++ uisimulator/sdl/uisdl.c (working copy) @@ -41,6 +41,11 @@ #include "SDL_mutex.h" #include "SDL_thread.h" +#include "button_defines.h" +#include "backlight.h" +#define PIPEBUFFER 255 +FILE *cmdpipe = NULL; + /* extern functions */ extern void new_key(int key); @@ -102,6 +107,44 @@ } } +void cmdpipe_loop(void) +{ + char line[PIPEBUFFER + 1]; + int i, button_num; + + button_num = sizeof(buttons)/sizeof(struct buttonpairs); + + printf("Available commands:\n"); + printf(" SCREENSHOT\n"); + for (i = 0; i < button_num; i++) + { + printf(" %s\n", buttons[i].define); + } + + while (fgets(line, PIPEBUFFER, cmdpipe)) { + line[strlen(line) - 1] = 0; + for (i = 0; i < button_num; i++) + { + if (strcmp(line, "SCREENSHOT") == 0) { + sim_trigger_screendump(); + } + else if (strcmp(line, buttons[i].define) == 0) { + /* + * This is not "real" button handling. We simply post key + * events directly into the queue as we get them and force + * the backlight on. + */ + sim_enter_irq_handler(); + backlight_on(); + queue_post(&button_queue, buttons[i].value, 0); + queue_post(&button_queue, buttons[i].value|BUTTON_REL, 0); + sim_exit_irq_handler(); + } + } + } + fclose(cmdpipe); +} + bool gui_startup(void) { SDL_Surface *picture_surface; @@ -225,17 +268,34 @@ printf("Root directory: %s\n", sim_root_dir); } } + else if (!strcmp("--cmdpipe", argv[x])) + { + x++; + if (x < argc) + { + printf("Command pipe: %s\n", argv[x]); + printf("Opening pipe..\n"); + cmdpipe = fopen(argv[x], "r"); + printf("Pipe opened\n"); + if (cmdpipe == NULL) + { + printf("Couldn't open file: %s\n", argv[x]); + exit(1); + } + } + } else { printf("rockboxui\n"); printf("Arguments:\n"); - printf(" --debugaudio \t Write raw PCM data to audiodebug.raw\n"); - printf(" --debugwps \t Print advanced WPS debug info\n"); + printf(" --debugaudio \t\t Write raw PCM data to audiodebug.raw\n"); + printf(" --debugwps \t\t Print advanced WPS debug info\n"); printf(" --nobackground \t Disable the background image\n"); - printf(" --old_lcd \t [Player] simulate old playermodel (ROM version<4.51)\n"); - printf(" --zoom [VAL]\t Window zoom (will disable backgrounds)\n"); - printf(" --alarm \t Simulate a wake-up on alarm\n"); - printf(" --root [DIR]\t Set root directory\n"); + printf(" --old_lcd \t\t [Player] simulate old playermodel (ROM version<4.51)\n"); + printf(" --zoom [VAL]\t\t Window zoom (will disable backgrounds)\n"); + printf(" --alarm \t\t Simulate a wake-up on alarm\n"); + printf(" --cmdpipe [FILE] \t Read commands from a named pipe (not keyboard)\n"); + printf(" --root [DIR]\t\t Set root directory\n"); exit(0); } } @@ -261,7 +321,10 @@ return -1; } - gui_message_loop(); + if (cmdpipe != NULL) + cmdpipe_loop(); + else + gui_message_loop(); return gui_shutdown(); }