diff --git a/bootloader/x1000/gui.c b/bootloader/x1000/gui.c index 513a3cb9cb..1208d3c161 100644 --- a/bootloader/x1000/gui.c +++ b/bootloader/x1000/gui.c @@ -122,10 +122,17 @@ void splashf(long delay, const char* msg, ...) int get_button(int timeout) { int btn = button_get_w_tmo(timeout); - if(btn == SYS_USB_CONNECTED) - is_usb_connected = true; - else if(btn == SYS_USB_DISCONNECTED) - is_usb_connected = false; + switch(btn) { + case SYS_USB_CONNECTED: + case SYS_USB_DISCONNECTED: + is_usb_connected = (btn == SYS_USB_CONNECTED); + break; +#ifdef HAVE_SCREENDUMP + case BL_SCREENSHOT: + screenshot(); + break; +#endif + } return btn; } diff --git a/bootloader/x1000/recovery.c b/bootloader/x1000/recovery.c index d70c3b9305..c53fa376b9 100644 --- a/bootloader/x1000/recovery.c +++ b/bootloader/x1000/recovery.c @@ -65,6 +65,9 @@ static const struct menuitem recovery_items[] = { static const struct menuitem debug_menu_items[] = { {MENUITEM_HEADING, "Debug tools", NULL}, +#ifdef HAVE_SCREENDUMP + {MENUITEM_ACTION, "Enable screenshots", &screenshot_enable}, +#endif #ifdef OF_PLAYER_ADDR {MENUITEM_ACTION, "Dump OF player", &dump_of_player}, #endif diff --git a/bootloader/x1000/utils.c b/bootloader/x1000/utils.c index 629a2c6280..4d3fb69e57 100644 --- a/bootloader/x1000/utils.c +++ b/bootloader/x1000/utils.c @@ -29,6 +29,7 @@ #include "rb-loader.h" #include "loader_strerror.h" #include "linuxboot.h" +#include "screendump.h" #include "nand-x1000.h" /* Set to true if a SYS_USB_CONNECTED event is seen @@ -37,6 +38,8 @@ * TODO: this is an ugly kludge */ bool is_usb_connected = false; +static bool screenshot_enabled = false; + /* this is both incorrect and incredibly racy... */ int check_disk(bool wait) { @@ -75,6 +78,25 @@ void usb_mode(void) splashf(3*HZ, "USB disconnected"); } +void screenshot(void) +{ +#ifdef HAVE_SCREENDUMP + if(!screenshot_enabled || check_disk(false) != DISK_PRESENT) + return; + + screen_dump(); +#endif +} + +void screenshot_enable(void) +{ +#ifdef HAVE_SCREENDUMP + splashf(3*HZ, "Screenshots enabled\nPress %s for screenshot", + BL_SCREENSHOT_NAME); + screenshot_enabled = true; +#endif +} + int load_rockbox(const char* filename, size_t* sizep) { if(check_disk(true) != DISK_PRESENT) diff --git a/bootloader/x1000/x1000bootloader.h b/bootloader/x1000/x1000bootloader.h index f6231bbd54..0886e6f6b5 100644 --- a/bootloader/x1000/x1000bootloader.h +++ b/bootloader/x1000/x1000bootloader.h @@ -36,10 +36,12 @@ struct uimage_header; # define BL_DOWN BUTTON_VOL_DOWN # define BL_SELECT BUTTON_PLAY # define BL_QUIT BUTTON_POWER +# define BL_SCREENSHOT_NAME BUTTON_MENU # define BL_UP_NAME "VOL+" # define BL_DOWN_NAME "VOL-" # define BL_SELECT_NAME "PLAY" # define BL_QUIT_NAME "POWER" +# define BL_SCREENSHOT_NAME "MENU" # define BOOTBACKUP_FILE "/fiiom3k-boot.bin" # define OF_PLAYER_NAME "FiiO player" # define OF_PLAYER_ADDR 0x20000 @@ -63,10 +65,12 @@ struct uimage_header; # define BL_DOWN BUTTON_NEXT # define BL_SELECT BUTTON_PLAY # define BL_QUIT BUTTON_POWER +# define BL_SCREENSHOT BUTTON_TOPLEFT # define BL_UP_NAME "PREV" # define BL_DOWN_NAME "NEXT" # define BL_SELECT_NAME "PLAY" # define BL_QUIT_NAME "POWER" +# define BL_SCREENSHOT_NAME "TOPLEFT" # define BOOTBACKUP_FILE "/shanlingq1-boot.bin" # define OF_PLAYER_NAME "Shanling player" # define OF_PLAYER_ADDR 0x140000 @@ -84,10 +88,12 @@ struct uimage_header; # define BL_DOWN BUTTON_SCROLL_FWD # define BL_SELECT BUTTON_PLAY # define BL_QUIT BUTTON_POWER +# define BL_SCREENSHOT BUTTON_MENU # define BL_UP_NAME "Up" # define BL_DOWN_NAME "Scroll Down" # define BL_SELECT_NAME "PLAY" # define BL_QUIT_NAME "POWER" +# define BL_SCREENSHOT_NAME "MENU" # define BOOTBACKUP_FILE "/erosqnative-boot.bin" #else # error "Missing keymap!" @@ -160,6 +166,8 @@ enum { int check_disk(bool wait); void usb_mode(void); +void screenshot(void); +void screenshot_enable(void); int load_rockbox(const char* filename, size_t* sizep); int load_uimage_file(const char* filename, diff --git a/firmware/export/config/erosqnative.h b/firmware/export/config/erosqnative.h index a76e8f6426..3b83d52c0e 100644 --- a/firmware/export/config/erosqnative.h +++ b/firmware/export/config/erosqnative.h @@ -136,3 +136,4 @@ #define HAVE_TAGCACHE #define HAVE_QUICKSCREEN #define HAVE_HOTKEY +#define HAVE_BOOTLOADER_SCREENDUMP diff --git a/firmware/export/config/fiiom3k.h b/firmware/export/config/fiiom3k.h index baf4cf4660..27aefc374f 100644 --- a/firmware/export/config/fiiom3k.h +++ b/firmware/export/config/fiiom3k.h @@ -144,3 +144,4 @@ #define HAVE_HOTKEY #define HAVE_LOCKED_ACTIONS #define AB_REPEAT_ENABLE +#define HAVE_BOOTLOADER_SCREENDUMP diff --git a/firmware/export/config/shanlingq1.h b/firmware/export/config/shanlingq1.h index 1355c1824e..222427716f 100644 --- a/firmware/export/config/shanlingq1.h +++ b/firmware/export/config/shanlingq1.h @@ -128,3 +128,4 @@ #define HAVE_QUICKSCREEN #define HAVE_HOTKEY #define AB_REPEAT_ENABLE +#define HAVE_BOOTLOADER_SCREENDUMP