diff --git a/console/griffin/griffin.c b/console/griffin/griffin.c index 3218af0e9d..e1c83d4f2b 100644 --- a/console/griffin/griffin.c +++ b/console/griffin/griffin.c @@ -304,6 +304,7 @@ MENU #endif #ifdef HAVE_RGUI +#include "../../screenshot.c" #include "../rgui/rgui.c" #include "../rgui/list.c" #endif diff --git a/console/rgui/rgui.c b/console/rgui/rgui.c index 83fa3fd3ae..13ceb3f49e 100644 --- a/console/rgui/rgui.c +++ b/console/rgui/rgui.c @@ -16,6 +16,7 @@ #include "rgui.h" #include "list.h" #include "../rarch_console_video.h" +#include "../../screenshot.h" #include #include #include @@ -32,8 +33,6 @@ #define TERM_WIDTH (((RGUI_WIDTH - TERM_START_X - 15) / (FONT_WIDTH_STRIDE))) #define TERM_HEIGHT (((RGUI_HEIGHT - TERM_START_Y - 15) / (FONT_HEIGHT_STRIDE)) - 1) -extern char app_dir[PATH_MAX]; - struct rgui_handle { uint32_t *frame_buf; @@ -421,6 +420,23 @@ static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t rarch_settings_change(S_RETURN_TO_GAME); } break; + case RGUI_SETTINGS_SCREENSHOT: + if (action == RGUI_ACTION_OK) + { + const uint16_t *data = (const uint16_t*)g_extern.frame_cache.data; + unsigned width = g_extern.frame_cache.width; + unsigned height = g_extern.frame_cache.height; + int pitch = g_extern.frame_cache.pitch; + + // Negative pitch is needed as screenshot takes bottom-up, + // but we use top-down. + bool r = screenshot_dump(default_paths.savestate_dir, + data + (height - 1) * (pitch >> 1), + width, height, -pitch, false); + + msg_queue_push(g_extern.msg_queue, r ? "Screenshot saved" : "Screenshot failed to save", 1, S_DELAY_90); + } + break; case RGUI_SETTINGS_VIDEO_FILTER: if (action == RGUI_ACTION_START) rarch_settings_default(S_DEF_HW_TEXTURE_FILTER); @@ -577,6 +593,7 @@ static void rgui_settings_populate_entries(rgui_handle_t *rgui) RGUI_MENU_ITEM("Savestate Slot", RGUI_SETTINGS_SAVESTATE_SLOT); RGUI_MENU_ITEM("Save State", RGUI_SETTINGS_SAVESTATE_SAVE); RGUI_MENU_ITEM("Load State", RGUI_SETTINGS_SAVESTATE_LOAD); + RGUI_MENU_ITEM("Take Screenshot", RGUI_SETTINGS_SCREENSHOT); } RGUI_MENU_ITEM("Hardware filtering", RGUI_SETTINGS_VIDEO_FILTER); #ifdef HW_RVL @@ -624,7 +641,7 @@ static const char *rgui_settings_iterate(rgui_handle_t *rgui, rgui_action_t acti const char *label = 0; rgui_list_at(rgui->folder_buf, rgui->directory_ptr, &label, &type, NULL); if (type == RGUI_SETTINGS_CORE) - label = app_dir; + label = default_paths.port_dir; const char *dir = 0; rgui_file_type_t menu_type = 0; size_t directory_ptr = 0; diff --git a/console/rgui/rgui.h b/console/rgui/rgui.h index 476d310b12..8d834588d7 100644 --- a/console/rgui/rgui.h +++ b/console/rgui/rgui.h @@ -36,6 +36,7 @@ typedef enum RGUI_SETTINGS_SAVESTATE_SLOT, RGUI_SETTINGS_SAVESTATE_SAVE, RGUI_SETTINGS_SAVESTATE_LOAD, + RGUI_SETTINGS_SCREENSHOT, RGUI_SETTINGS_VIDEO_FILTER, #ifdef HW_RVL RGUI_SETTINGS_VIDEO_SOFT_FILTER, diff --git a/gx/frontend/main.c b/gx/frontend/main.c index d67d0de123..fc9a674770 100644 --- a/gx/frontend/main.c +++ b/gx/frontend/main.c @@ -49,8 +49,6 @@ FILE * log_fp; uint32_t menu_framebuf[320 * 240]; rgui_handle_t *rgui; -char app_dir[PATH_MAX]; - #if defined(HAVE_LOGGER) || defined(HAVE_FILE_LOGGER) static devoptab_t dotab_stdout = { "stdout", // device name @@ -89,9 +87,7 @@ int gx_logger_net(struct _reent *r, int fd, const char *ptr, size_t len) logger_send("%s", temp); return len; } -#endif - -#ifdef HAVE_FILE_LOGGER +#elif defined(HAVE_FILE_LOGGER) int gx_logger_file(struct _reent *r, int fd, const char *ptr, size_t len) { fwrite(ptr, 1, len, log_fp); @@ -340,7 +336,6 @@ int main(void) #endif fatInitDefault(); - getcwd(app_dir, sizeof(app_dir)); get_environment_settings(); @@ -350,8 +345,7 @@ int main(void) devoptab_list[STD_OUT] = &dotab_stdout; devoptab_list[STD_ERR] = &dotab_stdout; dotab_stdout.write_r = gx_logger_net; -#endif -#ifdef HAVE_FILE_LOGGER +#elif defined(HAVE_FILE_LOGGER) g_extern.verbose = true; log_fp = fopen("/retroarch-log.txt", "w"); devoptab_list[STD_OUT] = &dotab_stdout; diff --git a/gx/gx_input.c b/gx/gx_input.c index d4d8b20a10..750ee2b902 100644 --- a/gx/gx_input.c +++ b/gx/gx_input.c @@ -33,7 +33,7 @@ #include "../libretro.h" #include -#define JOYSTICK_THRESHOLD 64 +#define JOYSTICK_THRESHOLD 48 #define MAX_PADS 4