From 05df632bd828d7cac1b4c2ca134e94fbdfabc1ab Mon Sep 17 00:00:00 2001 From: Nicolas Guillaumin Date: Thu, 8 Sep 2016 15:18:37 -0700 Subject: [PATCH 001/334] WIP: Fixes #2026 Screensaver suspend on Linux via Dbus One some systems (tested with Gnome 3 on Arch Linux) the current method of using `xdg-screensaver` to suspend the screensaver does not work. Instead, using DBus to issue an `Inhibit` request is recommended. The request returns a cookie that needs to be re-used to un-inhibit the screensaver later. Additionally if the DBus connection is closed the current inhibition is discarded. Thus, the DBus connection needs to stay connected for the duration of the screenshot inhibition. The code is heavily inspired from the [SDL 2.x code](http://hg.libsdl.org/SDL/file/default/src/core/linux/SDL_dbus.c#l172). I didn't call the SDL 2 code though since this it to fix the issue with the GL driver, and I assume one would want to have screensaver inhibited even when SDL 2 is not available (but GL is). I've set "WIP" because: * I haven't done C in a long time so my code is probably not great * There's a dependency on DBus which I don't know is acceptable or not * I've put my code where I could to check it works, but `x11_common` may not be the best place * The code need and "init" and "deinit" kind of method as it needs to initialise the DBus connection, and on deinit close it properly. I've used `x11_connect` and `x11_window_destroy` but they don't sound like the best choices. * I'm a bit unclear as to what happens when "suspend screensaver" is ticked on/off in the menu. This doesn't seem to call `x11_suspend_screensaver` everytime, so I'm not sure if there's a hook somewhere (as disabling screensaver suspend in the menu should cause a DBus unhinibit request to be sent). * Should I just call the SDL 2.x code (meaning that the GL driver would depend on SDL 2.x at runtime)? So, first of all are you ok with the approach, and if yes I'd gladly get feedback about the code, how to architecture it and the best place to put it. Thanks! --- Makefile.common | 5 ++ gfx/common/x11_common.c | 117 ++++++++++++++++++++++++++++++++++++++++ gfx/common/x11_common.h | 4 ++ qb/config.libs.sh | 1 + 4 files changed, 127 insertions(+) diff --git a/Makefile.common b/Makefile.common index d091566bfe..9034725f8d 100644 --- a/Makefile.common +++ b/Makefile.common @@ -612,6 +612,11 @@ ifeq ($(HAVE_XKBCOMMON), 1) LIBS += $(XKBCOMMON_LIBS) endif +ifeq ($(HAVE_DBUS), 1) + LIBS += $(DBUS_LIBS) + CFLAGS += $(DBUS_CFLAGS) +endif + ifeq ($(HAVE_UDEV), 1) DEFINES += $(UDEV_CFLAGS) LIBS += $(UDEV_LIBS) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 7f1058b785..32ba700aef 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -34,6 +34,12 @@ #include "../../verbosity.h" #include "../../runloop.h" +#ifdef HAVE_DBUS +#include +static DBusConnection* dbus_connection; +static unsigned int dbus_screensaver_cookie = 0; +#endif + Colormap g_x11_cmap; Window g_x11_win; Display *g_x11_dpy; @@ -146,6 +152,75 @@ void x11_set_window_attr(Display *dpy, Window win) } void x11_suspend_screensaver(Window wnd, bool enable) +{ + x11_suspend_screensaver_xdg_screensaver(wnd, enable); +#ifdef HAVE_DBUS + x11_suspend_screensaver_dbus(enable); +#endif +} + +#ifdef HAVE_DBUS +void x11_suspend_screensaver_dbus(bool enable) +{ + const char *app = "RetroArch"; + const char *reason = "Playing a game"; + DBusMessage *msg, *reply; + + if (!enable) + return; + + if (dbus_screensaver_cookie > 0) + return; // Already suspended + + if (dbus_connection == NULL) + return; // DBus connection was not obtained + + + msg = dbus_message_new_method_call("org.freedesktop.ScreenSaver", + "/org/freedesktop/ScreenSaver", + "org.freedesktop.ScreenSaver", + "Inhibit"); + + if (msg != NULL) + { + dbus_message_append_args(msg, + DBUS_TYPE_STRING, &app, + DBUS_TYPE_STRING, &reason, + DBUS_TYPE_INVALID); + } + + if (msg != NULL) + { + reply = dbus_connection_send_with_reply_and_block(dbus_connection, msg, 300, NULL); + if (reply != NULL) { + if (!dbus_message_get_args(reply, NULL, + DBUS_TYPE_UINT32, &dbus_screensaver_cookie, + DBUS_TYPE_INVALID)) + { + dbus_screensaver_cookie = 0; + } + + dbus_message_unref(reply); + } + + dbus_message_unref(msg); + } + + if (dbus_screensaver_cookie == 0) + { + RARCH_ERR("[DBus]: Failed to suspend screensaver via DBus.\n"); + } + else + { + RARCH_LOG("[DBus]: Suspended screensaver.\n"); + } + + return; + +} +#endif + +void x11_suspend_screensaver_xdg_screensaver(Window wnd, bool enable) { int ret; char cmd[64] = {0}; @@ -533,6 +608,22 @@ bool x11_connect(void) return false; } +#ifdef HAVE_DBUS + DBusError err; + int ret; + dbus_error_init(&err); + + dbus_connection = dbus_bus_get_private(DBUS_BUS_SESSION, &err); + if (dbus_error_is_set(&err)) { + RARCH_ERR("[DBus]: Failed to get DBus connection. Screensaver will not be suspended.\n"); + dbus_error_free(&err); + } + if (dbus_connection != NULL) { + dbus_connection_set_exit_on_disconnect(dbus_connection, true); + } +#endif + + return true; } @@ -573,6 +664,32 @@ void x11_window_destroy(bool fullscreen) if (!fullscreen) XDestroyWindow(g_x11_dpy, g_x11_win); g_x11_win = None; + +#ifdef HAVE_DBUS + if (dbus_connection != NULL) + { + + DBusMessage *msg = dbus_message_new_method_call("org.freedesktop.ScreenSaver", + "/org/freedesktop/ScreenSaver", + "org.freedesktop.ScreenSaver", + "UnInhibit"); + dbus_message_append_args (msg, + DBUS_TYPE_UINT32, &dbus_screensaver_cookie, + DBUS_TYPE_INVALID); + if (msg != NULL) { + if (dbus_connection_send(dbus_connection, msg, NULL)) { + dbus_connection_flush(dbus_connection); + } + dbus_message_unref(msg); + } + + dbus_screensaver_cookie = 0; + + dbus_connection_close(dbus_connection); + dbus_connection_unref(dbus_connection); + dbus_shutdown(); + } +#endif } void x11_colormap_destroy(void) diff --git a/gfx/common/x11_common.h b/gfx/common/x11_common.h index 0bfea3202f..7c5d359443 100644 --- a/gfx/common/x11_common.h +++ b/gfx/common/x11_common.h @@ -44,6 +44,10 @@ void x11_save_last_used_monitor(Window win); void x11_show_mouse(Display *dpy, Window win, bool state); void x11_windowed_fullscreen(Display *dpy, Window win); void x11_suspend_screensaver(Window win, bool enable); +void x11_suspend_screensaver_xdg_screensaver(Window win, bool enable); +#ifdef HAVE_DBUS +void x11_suspend_screensaver_dbus(bool enable); +#endif bool x11_enter_fullscreen(Display *dpy, unsigned width, unsigned height, XF86VidModeModeInfo *desktop_mode); diff --git a/qb/config.libs.sh b/qb/config.libs.sh index d6a4f1a6e2..8a7b2fec22 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -382,6 +382,7 @@ check_pkgconf XCB xcb check_pkgconf WAYLAND wayland-egl check_pkgconf XKBCOMMON xkbcommon 0.3.2 +check_pkgconf DBUS dbus-1 check_pkgconf XEXT xext check_pkgconf XF86VM xxf86vm check_pkgconf XINERAMA xinerama From c69c488fdf0fdc13b3cdbd7927db60fa7663e6d8 Mon Sep 17 00:00:00 2001 From: nguillaumin Date: Fri, 9 Sep 2016 18:08:54 -0700 Subject: [PATCH 002/334] Address code review comments --- gfx/common/x11_common.c | 233 ++++++++++++++++++++++------------------ gfx/common/x11_common.h | 4 - 2 files changed, 128 insertions(+), 109 deletions(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 32ba700aef..86fe77ec13 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -62,6 +62,122 @@ unsigned g_x11_screen; #define MOVERESIZE_X_SHIFT 8 #define MOVERESIZE_Y_SHIFT 9 +#ifdef HAVE_DBUS +static void dbus_get_connection() +{ + DBusError err; + int ret; + + dbus_error_init(&err); + + dbus_connection = dbus_bus_get_private(DBUS_BUS_SESSION, &err); + if (dbus_error_is_set(&err)) + { + RARCH_ERR("[DBus]: Failed to get DBus connection. Screensaver will not be suspended via DBus.\n"); + dbus_error_free(&err); + } + + if (dbus_connection != NULL) { + dbus_connection_set_exit_on_disconnect(dbus_connection, true); + } +} + +static void dbus_close_connection() +{ + if (dbus_connection != NULL) + { + dbus_connection_close(dbus_connection); + dbus_connection_unref(dbus_connection); + } +} + +static void dbus_screensaver_inhibit() +{ + const char *app = "RetroArch"; + const char *reason = "Playing a game"; + DBusMessage *msg, *reply; + + if (dbus_connection == NULL) + return; // DBus connection was not obtained + + if (dbus_screensaver_cookie > 0) + return; // Already inhibited + + msg = dbus_message_new_method_call("org.freedesktop.ScreenSaver", + "/org/freedesktop/ScreenSaver", + "org.freedesktop.ScreenSaver", + "Inhibit"); + + if (msg != NULL) + { + dbus_message_append_args(msg, + DBUS_TYPE_STRING, &app, + DBUS_TYPE_STRING, &reason, + DBUS_TYPE_INVALID); + } + + if (msg != NULL) + { + reply = dbus_connection_send_with_reply_and_block(dbus_connection, msg, 300, NULL); + if (reply != NULL) { + if (!dbus_message_get_args(reply, NULL, + DBUS_TYPE_UINT32, &dbus_screensaver_cookie, + DBUS_TYPE_INVALID)) + { + dbus_screensaver_cookie = 0; + } + + dbus_message_unref(reply); + } + + dbus_message_unref(msg); + } + + if (dbus_screensaver_cookie == 0) + { + RARCH_ERR("[DBus]: Failed to suspend screensaver via DBus.\n"); + } + else + { + RARCH_LOG("[DBus]: Suspended screensaver via DBus.\n"); + } +} + +static void dbus_screensaver_uninhibit() +{ + if (dbus_connection != NULL && dbus_screensaver_cookie > 0) + { + DBusMessage *msg = dbus_message_new_method_call("org.freedesktop.ScreenSaver", + "/org/freedesktop/ScreenSaver", + "org.freedesktop.ScreenSaver", + "UnInhibit"); + dbus_message_append_args (msg, + DBUS_TYPE_UINT32, &dbus_screensaver_cookie, + DBUS_TYPE_INVALID); + if (msg != NULL) { + if (dbus_connection_send(dbus_connection, msg, NULL)) { + dbus_connection_flush(dbus_connection); + } + dbus_message_unref(msg); + } + + dbus_screensaver_cookie = 0; + } +} + +void x11_suspend_screensaver_dbus(bool enable) +{ + if (!enable && !dbus_screensaver_cookie == 0) + return; // Disable requested and was not already suspended + + if (!enable && dbus_screensaver_cookie > 0) + dbus_screensaver_uninhibit(); // Disable requesed and was suspended -> unsuspend + + if (enable) + dbus_screensaver_inhibit(); +} +#endif + static void x11_hide_mouse(Display *dpy, Window win) { static char bm_no_data[] = {0, 0, 0, 0, 0, 0, 0, 0}; @@ -151,76 +267,7 @@ void x11_set_window_attr(Display *dpy, Window win) x11_set_window_class(dpy, win); } -void x11_suspend_screensaver(Window wnd, bool enable) -{ - x11_suspend_screensaver_xdg_screensaver(wnd, enable); -#ifdef HAVE_DBUS - x11_suspend_screensaver_dbus(enable); -#endif -} - -#ifdef HAVE_DBUS -void x11_suspend_screensaver_dbus(bool enable) -{ - const char *app = "RetroArch"; - const char *reason = "Playing a game"; - DBusMessage *msg, *reply; - - if (!enable) - return; - - if (dbus_screensaver_cookie > 0) - return; // Already suspended - - if (dbus_connection == NULL) - return; // DBus connection was not obtained - - - msg = dbus_message_new_method_call("org.freedesktop.ScreenSaver", - "/org/freedesktop/ScreenSaver", - "org.freedesktop.ScreenSaver", - "Inhibit"); - - if (msg != NULL) - { - dbus_message_append_args(msg, - DBUS_TYPE_STRING, &app, - DBUS_TYPE_STRING, &reason, - DBUS_TYPE_INVALID); - } - - if (msg != NULL) - { - reply = dbus_connection_send_with_reply_and_block(dbus_connection, msg, 300, NULL); - if (reply != NULL) { - if (!dbus_message_get_args(reply, NULL, - DBUS_TYPE_UINT32, &dbus_screensaver_cookie, - DBUS_TYPE_INVALID)) - { - dbus_screensaver_cookie = 0; - } - - dbus_message_unref(reply); - } - - dbus_message_unref(msg); - } - - if (dbus_screensaver_cookie == 0) - { - RARCH_ERR("[DBus]: Failed to suspend screensaver via DBus.\n"); - } - else - { - RARCH_LOG("[DBus]: Suspended screensaver.\n"); - } - - return; - -} -#endif - -void x11_suspend_screensaver_xdg_screensaver(Window wnd, bool enable) +static void x11_suspend_screensaver_xdg_screensaver(Window wnd, bool enable) { int ret; char cmd[64] = {0}; @@ -249,6 +296,14 @@ void x11_suspend_screensaver_xdg_screensaver(Window wnd, bool enable) } } +void x11_suspend_screensaver(Window wnd, bool enable) +{ + x11_suspend_screensaver_xdg_screensaver(wnd, enable); +#ifdef HAVE_DBUS + x11_suspend_screensaver_dbus(enable); +#endif +} + static bool get_video_mode(Display *dpy, unsigned width, unsigned height, XF86VidModeModeInfo *mode, XF86VidModeModeInfo *desktop_mode) { @@ -609,18 +664,7 @@ bool x11_connect(void) } #ifdef HAVE_DBUS - DBusError err; - int ret; - dbus_error_init(&err); - - dbus_connection = dbus_bus_get_private(DBUS_BUS_SESSION, &err); - if (dbus_error_is_set(&err)) { - RARCH_ERR("[DBus]: Failed to get DBus connection. Screensaver will not be suspended.\n"); - dbus_error_free(&err); - } - if (dbus_connection != NULL) { - dbus_connection_set_exit_on_disconnect(dbus_connection, true); - } + dbus_get_connection(); #endif @@ -666,29 +710,8 @@ void x11_window_destroy(bool fullscreen) g_x11_win = None; #ifdef HAVE_DBUS - if (dbus_connection != NULL) - { - - DBusMessage *msg = dbus_message_new_method_call("org.freedesktop.ScreenSaver", - "/org/freedesktop/ScreenSaver", - "org.freedesktop.ScreenSaver", - "UnInhibit"); - dbus_message_append_args (msg, - DBUS_TYPE_UINT32, &dbus_screensaver_cookie, - DBUS_TYPE_INVALID); - if (msg != NULL) { - if (dbus_connection_send(dbus_connection, msg, NULL)) { - dbus_connection_flush(dbus_connection); - } - dbus_message_unref(msg); - } - - dbus_screensaver_cookie = 0; - - dbus_connection_close(dbus_connection); - dbus_connection_unref(dbus_connection); - dbus_shutdown(); - } + dbus_screensaver_uninhibit(); + dbus_close_connection(); #endif } diff --git a/gfx/common/x11_common.h b/gfx/common/x11_common.h index 7c5d359443..0bfea3202f 100644 --- a/gfx/common/x11_common.h +++ b/gfx/common/x11_common.h @@ -44,10 +44,6 @@ void x11_save_last_used_monitor(Window win); void x11_show_mouse(Display *dpy, Window win, bool state); void x11_windowed_fullscreen(Display *dpy, Window win); void x11_suspend_screensaver(Window win, bool enable); -void x11_suspend_screensaver_xdg_screensaver(Window win, bool enable); -#ifdef HAVE_DBUS -void x11_suspend_screensaver_dbus(bool enable); -#endif bool x11_enter_fullscreen(Display *dpy, unsigned width, unsigned height, XF86VidModeModeInfo *desktop_mode); From 2ad380e677904bbd3d933edf51a00806453daea9 Mon Sep 17 00:00:00 2001 From: Jean-Sebastien Guay Date: Sun, 11 Sep 2016 17:31:16 -0400 Subject: [PATCH 003/334] Add fetching git submodules (in the case of retroarch, currently only glslang) --- fetch-submodules.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fetch-submodules.sh b/fetch-submodules.sh index 3cb3f53eed..91825d3025 100755 --- a/fetch-submodules.sh +++ b/fetch-submodules.sh @@ -75,3 +75,5 @@ fetch_git "https://github.com/libretro/common-overlays.git" "media/overlays" fetch_git "https://github.com/libretro/retroarch-assets.git" "media/assets" fetch_git "https://github.com/libretro/retroarch-joypad-autoconfig.git" "media/autoconfig" fetch_git "https://github.com/libretro/libretro-database.git" "media/libretrodb" + +git submodule update --init From 0774831b21aac058741f40652b1e662287810a9b Mon Sep 17 00:00:00 2001 From: Jean-Sebastien Guay Date: Sun, 11 Sep 2016 19:43:16 -0400 Subject: [PATCH 004/334] Add --recursive in case submodules have third-party dependencies --- fetch-submodules.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fetch-submodules.sh b/fetch-submodules.sh index 91825d3025..7515dbbf32 100755 --- a/fetch-submodules.sh +++ b/fetch-submodules.sh @@ -76,4 +76,4 @@ fetch_git "https://github.com/libretro/retroarch-assets.git" "media/assets" fetch_git "https://github.com/libretro/retroarch-joypad-autoconfig.git" "media/autoconfig" fetch_git "https://github.com/libretro/libretro-database.git" "media/libretrodb" -git submodule update --init +git submodule update --init --recursive From 49d52102560f83d8625d1358be81e2b8293e0459 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Sep 2016 08:37:40 +0200 Subject: [PATCH 005/334] Should make Start Core work on statically linked RA now --- retroarch.c | 5 ++++- tasks/task_content.c | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/retroarch.c b/retroarch.c index 41c5a92a9c..e482ab0b22 100644 --- a/retroarch.c +++ b/retroarch.c @@ -722,7 +722,8 @@ static void retroarch_parse_input(int argc, char *argv[]) * bogus arguments. */ - retroarch_set_current_core_type(CORE_TYPE_DUMMY, false); + if (!current_core_explicitly_set) + retroarch_set_current_core_type(CORE_TYPE_DUMMY, false); *global->subsystem = '\0'; @@ -1071,12 +1072,14 @@ static void retroarch_parse_input(int argc, char *argv[]) RARCH_ERR("--menu was used, but content file was passed as well.\n"); retroarch_fail(1, "retroarch_parse_input()"); } +#ifdef HAVE_DYNAMIC else { /* Allow stray -L arguments to go through to workaround cases where it's used as "config file". * This seems to still be the case for Android, which should be properly fixed. */ retroarch_set_current_core_type(CORE_TYPE_DUMMY, false); } +#endif } if (string_is_empty(global->subsystem) && optind < argc) diff --git a/tasks/task_content.c b/tasks/task_content.c index 455d5d587e..1a5a8f5ee3 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -1962,6 +1962,7 @@ bool task_push_content_load_default( runloop_ctl(RUNLOOP_CTL_DATA_DEINIT, NULL); runloop_ctl(RUNLOOP_CTL_TASK_INIT, NULL); break; + case CONTENT_MODE_LOAD_NOTHING_WITH_CURRENT_CORE_FROM_MENU: case CONTENT_MODE_LOAD_NOTHING_WITH_NEW_CORE_FROM_MENU: retroarch_set_current_core_type(type, true); break; From ae158453e1eb5fe531126a8a11de5c75900f507b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Sep 2016 15:17:28 +0200 Subject: [PATCH 006/334] (Emscripten) Add title for menu toggle --- pkg/emscripten/proto.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/emscripten/proto.html b/pkg/emscripten/proto.html index c759e8174f..656ec7ffc3 100644 --- a/pkg/emscripten/proto.html +++ b/pkg/emscripten/proto.html @@ -94,7 +94,7 @@ - From f735e96dfb2c7fec7852d99405c7b69379e3df81 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Sep 2016 16:31:40 +0200 Subject: [PATCH 007/334] Cleanup --- driver.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/driver.h b/driver.h index b32704c14f..9a260e9825 100644 --- a/driver.h +++ b/driver.h @@ -24,10 +24,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - RETRO_BEGIN_DECLS #define DRIVERS_CMD_ALL \ From cdc5eb4fac36f9787621db26e080d00e67f996ca Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Sep 2016 16:36:27 +0200 Subject: [PATCH 008/334] Cleanups --- runloop.h | 4 ++++ verbosity.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/runloop.h b/runloop.h index 138e7b2623..6bee74e3a0 100644 --- a/runloop.h +++ b/runloop.h @@ -20,6 +20,10 @@ #include #include +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "input/input_defines.h" RETRO_BEGIN_DECLS diff --git a/verbosity.h b/verbosity.h index 5009d56879..916e2d8253 100644 --- a/verbosity.h +++ b/verbosity.h @@ -21,6 +21,10 @@ #include #include +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + RETRO_BEGIN_DECLS bool verbosity_is_enabled(void); From e42034ebd8aace3f02bb0b621b6417bd8af7274b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Sep 2016 16:39:50 +0200 Subject: [PATCH 009/334] Cleanups --- frontend/drivers/platform_ctr.c | 5 +++++ frontend/drivers/platform_gx.c | 4 ++++ frontend/drivers/platform_null.c | 5 ++--- frontend/drivers/platform_psp.c | 4 ++++ frontend/drivers/platform_xdk.cpp | 5 +++++ frontend/frontend_driver.h | 4 ---- 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index fee219113f..a172d449bf 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -22,6 +22,11 @@ #include <3ds.h> #include + +#ifdef HAVE_CONFIG_H +#include "../../config.h" +#endif + #ifndef IS_SALAMANDER #include #endif diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index 4c37656e47..392cf9e479 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -24,6 +24,10 @@ #include #include +#ifdef HAVE_CONFIG_H +#include "../../config.h" +#endif + #if defined(HW_RVL) && !defined(IS_SALAMANDER) #include #include "../../memory/wii/mem2_manager.h" diff --git a/frontend/drivers/platform_null.c b/frontend/drivers/platform_null.c index 056f657116..4dc3800c23 100644 --- a/frontend/drivers/platform_null.c +++ b/frontend/drivers/platform_null.c @@ -14,10 +14,9 @@ * If not, see . */ -#include "../frontend_driver.h" - #include -#include + +#include "../frontend_driver.h" frontend_ctx_driver_t frontend_ctx_null = { NULL, /* environment_get */ diff --git a/frontend/drivers/platform_psp.c b/frontend/drivers/platform_psp.c index 16aabd32a8..72725d9f06 100644 --- a/frontend/drivers/platform_psp.c +++ b/frontend/drivers/platform_psp.c @@ -18,6 +18,10 @@ #include #include +#ifdef HAVE_CONFIG_H +#include "../../config.h" +#endif + #ifdef VITA #include #include diff --git a/frontend/drivers/platform_xdk.cpp b/frontend/drivers/platform_xdk.cpp index 82dec30de1..b5a92a6161 100644 --- a/frontend/drivers/platform_xdk.cpp +++ b/frontend/drivers/platform_xdk.cpp @@ -22,6 +22,11 @@ #include #include + +#ifdef HAVE_CONFIG_H +#include "../../config.h" +#endif + #ifndef IS_SALAMANDER #include #endif diff --git a/frontend/frontend_driver.h b/frontend/frontend_driver.h index 66f4bc348a..b20751aee0 100644 --- a/frontend/frontend_driver.h +++ b/frontend/frontend_driver.h @@ -23,10 +23,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include "../config.h" -#endif - RETRO_BEGIN_DECLS enum frontend_powerstate From 93d98069b2116f977eee81aa2c43652d96574d9a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Sep 2016 16:45:26 +0200 Subject: [PATCH 010/334] Cleanups --- gfx/video_driver.h | 4 ++++ input/drivers_keyboard/keyboard_event_android.c | 2 ++ input/drivers_keyboard/keyboard_event_udev.c | 6 ++++++ input/drivers_keyboard/keyboard_event_x11.c | 12 ++++++++---- input/input_driver.h | 4 ---- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/gfx/video_driver.h b/gfx/video_driver.h index db8078e92b..cf2751c7b2 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -30,6 +30,10 @@ #include "../input/input_driver.h" +#ifdef HAVE_OVERLAY +#include "../input/input_overlay.h" +#endif + RETRO_BEGIN_DECLS enum texture_filter_type diff --git a/input/drivers_keyboard/keyboard_event_android.c b/input/drivers_keyboard/keyboard_event_android.c index 8b10ef86b1..47b1208f2c 100644 --- a/input/drivers_keyboard/keyboard_event_android.c +++ b/input/drivers_keyboard/keyboard_event_android.c @@ -13,6 +13,8 @@ * If not, see . */ +#include + #include "keyboard_event_android.h" #define AKEYCODE_ASSIST 219 diff --git a/input/drivers_keyboard/keyboard_event_udev.c b/input/drivers_keyboard/keyboard_event_udev.c index 5ad3b6135e..a2d1274388 100644 --- a/input/drivers_keyboard/keyboard_event_udev.c +++ b/input/drivers_keyboard/keyboard_event_udev.c @@ -13,6 +13,12 @@ * If not, see . */ +#include + +#ifdef HAVE_CONFIG_H +#include "../../config.h" +#endif + #include "../input_keymaps.h" #include "../input_keyboard.h" #include "../../driver.h" diff --git a/input/drivers_keyboard/keyboard_event_x11.c b/input/drivers_keyboard/keyboard_event_x11.c index 1abe5a1de4..d632b6d4e8 100644 --- a/input/drivers_keyboard/keyboard_event_x11.c +++ b/input/drivers_keyboard/keyboard_event_x11.c @@ -18,15 +18,19 @@ #include #include -#ifdef HAVE_XINERAMA -#include -#endif - #include #include #include #include +#ifdef HAVE_CONFIG_H +#include "../../config.h" +#endif + +#ifdef HAVE_XINERAMA +#include +#endif + #include "../input_keyboard.h" #include "../input_keymaps.h" diff --git a/input/input_driver.h b/input/input_driver.h index c9722fc35a..8f30b0bd7b 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -27,10 +27,6 @@ #include "input_joypad_driver.h" #include "input_defines.h" -#ifdef HAVE_OVERLAY -#include "input_overlay.h" -#endif - RETRO_BEGIN_DECLS typedef struct retro_input From 6f23a8ac0d8deed7ed570a42d17b1818489cd309 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Sep 2016 17:21:00 +0200 Subject: [PATCH 011/334] Move httpserver to network/ --- griffin/griffin.c | 2 +- .../httpserver}/handle_form.inl | 0 {httpserver => network/httpserver}/httpserver.c | 16 ++++++++-------- {httpserver => network/httpserver}/httpserver.h | 0 runloop.c | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) rename {httpserver => network/httpserver}/handle_form.inl (100%) rename {httpserver => network/httpserver}/httpserver.c (98%) rename {httpserver => network/httpserver}/httpserver.h (100%) diff --git a/griffin/griffin.c b/griffin/griffin.c index e38f6657b0..871467abfd 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -1046,7 +1046,7 @@ HTTP SERVER ============================================================ */ #if defined(HAVE_HTTPSERVER) && defined(HAVE_ZLIB) #include "../deps/civetweb/civetweb.c" -#include "httpserver/httpserver.c" +#include "network/httpserver/httpserver.c" #endif #ifdef __cplusplus diff --git a/httpserver/handle_form.inl b/network/httpserver/handle_form.inl similarity index 100% rename from httpserver/handle_form.inl rename to network/httpserver/handle_form.inl diff --git a/httpserver/httpserver.c b/network/httpserver/httpserver.c similarity index 98% rename from httpserver/httpserver.c rename to network/httpserver/httpserver.c index 5e0c44e55a..e90909d52d 100644 --- a/httpserver/httpserver.c +++ b/network/httpserver/httpserver.c @@ -9,19 +9,19 @@ #include #include -#include "../core.h" -#include "../runloop.h" -#include "../core.h" -#include "../gfx/video_driver.h" -#include "../managers/core_option_manager.h" -#include "../cheevos.h" -#include "../content.h" +#include "../../core.h" +#include "../../runloop.h" +#include "../../core.h" +#include "../../gfx/video_driver.h" +#include "../../managers/core_option_manager.h" +#include "../../cheevos.h" +#include "../../content.h" #define BASIC_INFO "info" #define MEMORY_MAP "memoryMap" static struct mg_callbacks s_httpserver_callbacks; -static struct mg_context* s_httpserver_ctx; +static struct mg_context *s_httpserver_ctx = NULL; /* Based on https://github.com/zeromq/rfc/blob/master/src/spec_32.c */ static void httpserver_z85_encode_inplace(Bytef* data, size_t size) diff --git a/httpserver/httpserver.h b/network/httpserver/httpserver.h similarity index 100% rename from httpserver/httpserver.h rename to network/httpserver/httpserver.h diff --git a/runloop.c b/runloop.c index 71b5e84798..fb8a86897a 100644 --- a/runloop.c +++ b/runloop.c @@ -52,7 +52,7 @@ #endif #if defined(HAVE_HTTPSERVER) && defined(HAVE_ZLIB) -#include "httpserver/httpserver.h" +#include "network/httpserver/httpserver.h" #endif #include "autosave.h" From b4d75fbafd58f470d7956cb55a70c8451a1d7343 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Sep 2016 17:29:01 +0200 Subject: [PATCH 012/334] Cleanups --- gfx/video_context_driver.h | 4 ---- gfx/video_filter.h | 1 + gfx/video_frame.c | 25 +++++++++++++++++++------ gfx/video_frame.h | 17 ++++++++++------- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index b05bd4332d..111e1bbb0f 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -22,10 +22,6 @@ #include "video_driver.h" -#ifdef HAVE_CONFIG_H -#include "../config.h" -#endif - RETRO_BEGIN_DECLS #ifndef MAX_EGLIMAGE_TEXTURES diff --git a/gfx/video_filter.h b/gfx/video_filter.h index d8af27ad47..5921657b78 100644 --- a/gfx/video_filter.h +++ b/gfx/video_filter.h @@ -22,6 +22,7 @@ #include #define RARCH_SOFTFILTER_THREADS_AUTO 0 + typedef struct rarch_softfilter rarch_softfilter_t; rarch_softfilter_t *rarch_softfilter_new(const char *filter_path, diff --git a/gfx/video_frame.c b/gfx/video_frame.c index 4ccd8ba441..c1fca69aab 100644 --- a/gfx/video_frame.c +++ b/gfx/video_frame.c @@ -13,6 +13,8 @@ * If not, see . */ +#include + #include #include "../performance_counters.h" @@ -21,12 +23,14 @@ #include "video_frame.h" void video_frame_convert_rgb16_to_rgb32( - struct scaler_ctx *scaler, + void *data, void *output, const void *input, int width, int height, int in_pitch) { + struct scaler_ctx *scaler = (struct scaler_ctx*)data; + if (width != scaler->in_width || height != scaler->in_height) { scaler->in_width = width; @@ -46,7 +50,7 @@ void video_frame_convert_rgb16_to_rgb32( } void video_frame_scale( - struct scaler_ctx *scaler, + void *data, void *output, const void *input, enum scaler_pix_fmt format, @@ -57,6 +61,8 @@ void video_frame_scale( unsigned height, unsigned pitch) { + struct scaler_ctx *scaler = (struct scaler_ctx*)data; + if ( width != (unsigned)scaler->in_width || height != (unsigned)scaler->in_height @@ -80,7 +86,7 @@ void video_frame_scale( } void video_frame_record_scale( - struct scaler_ctx *scaler, + void *data, void *output, const void *input, unsigned scaler_width, @@ -91,6 +97,8 @@ void video_frame_record_scale( unsigned pitch, bool bilinear) { + struct scaler_ctx *scaler = (struct scaler_ctx*)data; + if ( width != (unsigned)scaler->in_width || height != (unsigned)scaler->in_height @@ -114,10 +122,12 @@ void video_frame_record_scale( } void video_frame_convert_argb8888_to_abgr8888( - struct scaler_ctx *scaler, + void *data, void *output, const void *input, int width, int height, int in_pitch) { + struct scaler_ctx *scaler = (struct scaler_ctx*)data; + if (width != scaler->in_width || height != scaler->in_height) { scaler->in_width = width; @@ -136,11 +146,13 @@ void video_frame_convert_argb8888_to_abgr8888( } void video_frame_convert_to_bgr24( - struct scaler_ctx *scaler, + void *data, void *output, const void *input, int width, int height, int in_pitch, bool bgr24) { + struct scaler_ctx *scaler = (struct scaler_ctx*)data; + scaler->in_width = width; scaler->in_height = height; scaler->out_width = width; @@ -179,11 +191,12 @@ void video_frame_convert_rgba_to_bgr( } bool video_pixel_frame_scale( - struct scaler_ctx *scaler, + void *scaler_data, void *output, const void *data, unsigned width, unsigned height, size_t pitch) { + struct scaler_ctx *scaler = (struct scaler_ctx*)scaler_data; static struct retro_perf_counter video_frame_conv = {0}; performance_counter_init(&video_frame_conv, "video_frame_conv"); diff --git a/gfx/video_frame.h b/gfx/video_frame.h index 452ef76a26..da1ecfea7f 100644 --- a/gfx/video_frame.h +++ b/gfx/video_frame.h @@ -17,18 +17,19 @@ #define _VIDEO_FRAME_H #include +#include -#include +RETRO_BEGIN_DECLS void video_frame_convert_rgb16_to_rgb32( - struct scaler_ctx *scaler, + void *data, void *output, const void *input, int width, int height, int in_pitch); void video_frame_scale( - struct scaler_ctx *scaler, + void *data, void *output, const void *input, enum scaler_pix_fmt format, @@ -40,7 +41,7 @@ void video_frame_scale( unsigned pitch); void video_frame_record_scale( - struct scaler_ctx *scaler, + void *data, void *output, const void *input, unsigned scaler_width, @@ -52,12 +53,12 @@ void video_frame_record_scale( bool bilinear); void video_frame_convert_argb8888_to_abgr8888( - struct scaler_ctx *scaler, + void *data, void *output, const void *input, int width, int height, int in_pitch); void video_frame_convert_to_bgr24( - struct scaler_ctx *scaler, + void *data, void *output, const void *input, int width, int height, int in_pitch, bool bgr24); @@ -68,10 +69,12 @@ void video_frame_convert_rgba_to_bgr( unsigned width); bool video_pixel_frame_scale( - struct scaler_ctx *scaler, + void *scaler_data, void *output, const void *data, unsigned width, unsigned height, size_t pitch); +RETRO_END_DECLS + #endif From 79222de018cac59cfbb1445d0aec946e29e4dbd4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Sep 2016 17:32:35 +0200 Subject: [PATCH 013/334] Move define to scaler_filter.c --- libretro-common/gfx/scaler/scaler_filter.c | 2 ++ libretro-common/include/gfx/scaler/scaler.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libretro-common/gfx/scaler/scaler_filter.c b/libretro-common/gfx/scaler/scaler_filter.c index 50c290c8c3..a4996977b5 100644 --- a/libretro-common/gfx/scaler/scaler_filter.c +++ b/libretro-common/gfx/scaler/scaler_filter.c @@ -30,6 +30,8 @@ #include #include +#define FILTER_UNITY (1 << 14) + static bool allocate_filters(struct scaler_ctx *ctx) { ctx->horiz.filter = (int16_t*)scaler_alloc(sizeof(int16_t), ctx->horiz.filter_stride * ctx->out_width); diff --git a/libretro-common/include/gfx/scaler/scaler.h b/libretro-common/include/gfx/scaler/scaler.h index 8a68f92af9..64a52e4479 100644 --- a/libretro-common/include/gfx/scaler/scaler.h +++ b/libretro-common/include/gfx/scaler/scaler.h @@ -32,8 +32,6 @@ RETRO_BEGIN_DECLS -#define FILTER_UNITY (1 << 14) - enum scaler_pix_fmt { SCALER_FMT_ARGB8888 = 0, From 51823f716944128c66626d34a575a1aa3bd4fed8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Sep 2016 18:16:42 +0200 Subject: [PATCH 014/334] Cleanups --- command.c | 5 +---- dynamic.c | 6 +++++- dynamic.h | 20 -------------------- 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/command.c b/command.c index 3af331896b..ffbc37ef82 100644 --- a/command.c +++ b/command.c @@ -1886,14 +1886,11 @@ bool command_event(enum event_command cmd, void *data) #if defined(HAVE_DYNAMIC) if (string_is_empty(config_get_active_core_path())) return false; - +#endif libretro_get_system_info( config_get_active_core_path(), system, ptr); -#else - libretro_get_system_info_static(system, ptr); -#endif info_find.path = config_get_active_core_path(); if (!core_info_load(&info_find)) diff --git a/dynamic.c b/dynamic.c index 9d17974e95..5238eecdf1 100644 --- a/dynamic.c +++ b/dynamic.c @@ -168,7 +168,7 @@ static bool environ_cb_get_system_info(unsigned cmd, void *data) } #ifndef HAVE_DYNAMIC -bool libretro_get_system_info_static(struct retro_system_info *info, +static bool libretro_get_system_info_static(struct retro_system_info *info, bool *load_no_content) { struct retro_system_info dummy_info = {0}; @@ -296,6 +296,7 @@ static dylib_t libretro_get_system_info_lib(const char *path, bool libretro_get_system_info(const char *path, struct retro_system_info *info, bool *load_no_content) { +#ifdef HAVE_DYNAMIC struct retro_system_info dummy_info = {0}; dylib_t lib = libretro_get_system_info_lib(path, &dummy_info, load_no_content); @@ -309,6 +310,9 @@ bool libretro_get_system_info(const char *path, info->valid_extensions = strdup(dummy_info.valid_extensions); dylib_close(lib); return true; +#else + return libretro_get_system_info_static(info, load_no_content); +#endif } static void load_dynamic_core(void) diff --git a/dynamic.h b/dynamic.h index 9ea5a6cce0..af0281b957 100644 --- a/dynamic.h +++ b/dynamic.h @@ -23,10 +23,6 @@ #include "core_type.h" -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - RETRO_BEGIN_DECLS /** @@ -49,7 +45,6 @@ RETRO_BEGIN_DECLS void libretro_get_environment_info(void (*)(retro_environment_t), bool *load_no_content); -#ifdef HAVE_DYNAMIC /** * libretro_get_system_info: * @path : Path to libretro library. @@ -64,21 +59,6 @@ void libretro_get_environment_info(void (*)(retro_environment_t), **/ bool libretro_get_system_info(const char *path, struct retro_system_info *info, bool *load_no_content); -#else -/** - * libretro_get_system_info_static: - * @info : System info information. - * @load_no_content : If true, core should be able to auto-start - * without any content loaded. - * - * Gets system info from the current statically linked libretro library. - * The struct returned must be freed as strings are allocated dynamically. - * - * Returns: true (1) if successful, otherwise false (0). - **/ -bool libretro_get_system_info_static(struct retro_system_info *info, - bool *load_no_content); -#endif /** * libretro_free_system_info: From b0e372432f2cc958efc6f9a1129adbde4a5fd25d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Sep 2016 18:18:20 +0200 Subject: [PATCH 015/334] Cleanups --- network/httpserver/httpserver.c | 15 +++++++++++++++ network/httpserver/httpserver.h | 30 ++++++++++++++++++++++-------- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/network/httpserver/httpserver.c b/network/httpserver/httpserver.c index e90909d52d..05efe15552 100644 --- a/network/httpserver/httpserver.c +++ b/network/httpserver/httpserver.c @@ -1,3 +1,18 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2015-2016 - Andre Leiradella + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + #define __STDC_FORMAT_MACROS #include #include diff --git a/network/httpserver/httpserver.h b/network/httpserver/httpserver.h index 62ef7116f4..301d0d67eb 100644 --- a/network/httpserver/httpserver.h +++ b/network/httpserver/httpserver.h @@ -1,15 +1,29 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2015-2016 - Andre Leiradella + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + #ifndef __RARCH_HTTPSERVR_H #define __RARCH_HTTPSERVR_H -#ifdef __cplusplus -extern "C" { -#endif +#include - int httpserver_init(unsigned port); - void httpserver_destroy(void); +RETRO_BEGIN_DECLS -#ifdef __cplusplus -} -#endif +int httpserver_init(unsigned port); + +void httpserver_destroy(void); + +RETRO_END_DECLS #endif /* __RARCH_HTTPSERVR_H */ From d4be224ea63ef66fd70e81c41a8b12ba65ac81b6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Sep 2016 18:34:57 +0200 Subject: [PATCH 016/334] Header include cleanups --- gfx/video_driver.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gfx/video_driver.h b/gfx/video_driver.h index cf2751c7b2..916c2208f4 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -24,16 +24,20 @@ #include #include +#ifdef HAVE_CONFIG_H +#include "../config.h" +#endif + +#ifdef HAVE_OVERLAY +#include "../input/input_overlay.h" +#endif + #include "font_driver.h" #include "video_filter.h" #include "video_shader_parse.h" #include "../input/input_driver.h" -#ifdef HAVE_OVERLAY -#include "../input/input_overlay.h" -#endif - RETRO_BEGIN_DECLS enum texture_filter_type From d2dbe63b2bc13d3400d11cb5a4f3e0633b7768a5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Sep 2016 18:37:32 +0200 Subject: [PATCH 017/334] Cleanup --- gfx/video_driver.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 9842f5019d..8c64ab73fc 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -108,22 +108,23 @@ typedef struct video_pixel_scaler * could potentially make use of this. */ static uintptr_t video_driver_display; static uintptr_t video_driver_window; -static enum rarch_display_type video_driver_display_type; -static char video_driver_title_buf[64]; - -static uint64_t video_driver_frame_count; - -static void *video_driver_data = NULL; -static video_driver_t *current_video = NULL; - -/* Interface for "poking". */ -static const video_poke_interface_t *video_driver_poke = NULL; static video_driver_state_t video_driver_state; +static enum rarch_display_type video_driver_display_type = RARCH_DISPLAY_NONE; +static char video_driver_title_buf[64] = {0}; + +static uint64_t video_driver_frame_count = 0; + +static void *video_driver_data = NULL; +static video_driver_t *current_video = NULL; + +/* Interface for "poking". */ +static const video_poke_interface_t *video_driver_poke = NULL; + /* Used for 16-bit -> 16-bit conversions that take place before * being passed to video driver. */ -static video_pixel_scaler_t *video_driver_scaler_ptr = NULL; +static video_pixel_scaler_t *video_driver_scaler_ptr = NULL; char rotation_lut[4][32] = { From 3247de9afa3e1647893e7c0f2fff3807799d043d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Sep 2016 18:39:46 +0200 Subject: [PATCH 018/334] Cleanup --- input/input_autodetect.c | 10 +++------- input/input_driver.c | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/input/input_autodetect.c b/input/input_autodetect.c index c3e912b1df..40b121cd73 100644 --- a/input/input_autodetect.c +++ b/input/input_autodetect.c @@ -103,23 +103,18 @@ static int input_try_autoconfigure_joypad_from_conf(config_file_t *conf, && params->pid != 0 && input_vid != 0 && input_pid != 0) - { score += 3; - } /* Check for name match */ if (string_is_equal(ident, params->name)) - { score += 2; - } else { if (!string_is_empty(ident) && !strncmp(params->name, ident, strlen(ident))) - { score += 1; - } } + return score; } @@ -225,7 +220,8 @@ static bool input_autoconfigure_joypad_from_conf_dir( for (i = 0; i < list->size; i++) { conf = config_file_new(list->elems[i].data); - ret = input_try_autoconfigure_joypad_from_conf(conf, params); + ret = input_try_autoconfigure_joypad_from_conf(conf, params); + if(ret >= current_best) { index = i; diff --git a/input/input_driver.c b/input/input_driver.c index 8f27a5d6c3..0b31266798 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -99,7 +99,7 @@ struct turbo_buttons static turbo_buttons_t input_driver_turbo_btns; #ifdef HAVE_COMMAND -static command_t *input_driver_command = NULL; +static command_t *input_driver_command = NULL; #endif #ifdef HAVE_NETWORKGAMEPAD static input_remote_t *input_driver_remote = NULL; From 912d26ec26ec6a0e2b7073cece0f6c199e49e803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Jos=C3=A9=20Garc=C3=ADa=20Garc=C3=ADa?= Date: Mon, 12 Sep 2016 19:17:21 +0200 Subject: [PATCH 019/334] Wrong ifdef --- tasks/task_content.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/task_content.c b/tasks/task_content.c index 1a5a8f5ee3..b994179a8f 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -871,7 +871,7 @@ static void content_load_init_wrap( *argc = 0; argv[(*argc)++] = strdup("retroarch"); -#ifndef HAVE_DYNAMIC +#ifdef HAVE_DYNAMIC if (!args->no_content) { #endif @@ -888,7 +888,7 @@ static void content_load_init_wrap( argv[(*argc)++] = strdup("--menu"); } #endif -#ifndef HAVE_DYNAMIC +#ifdef HAVE_DYNAMIC } #endif From f14797b67c8ef19118e15f7893c83a2df7db2e9f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Sep 2016 19:56:50 +0200 Subject: [PATCH 020/334] Fix statically linked targets --- dynamic.c | 67 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/dynamic.c b/dynamic.c index 5238eecdf1..cff8011596 100644 --- a/dynamic.c +++ b/dynamic.c @@ -202,6 +202,40 @@ static bool libretro_get_system_info_static(struct retro_system_info *info, } #endif +/** + * libretro_get_system_info: + * @path : Path to libretro library. + * @info : Pointer to system info information. + * @load_no_content : If true, core should be able to auto-start + * without any content loaded. + * + * Gets system info from an arbitrary lib. + * The struct returned must be freed as strings are allocated dynamically. + * + * Returns: true (1) if successful, otherwise false (0). + **/ +bool libretro_get_system_info(const char *path, + struct retro_system_info *info, bool *load_no_content) +{ +#ifdef HAVE_DYNAMIC + struct retro_system_info dummy_info = {0}; + dylib_t lib = libretro_get_system_info_lib(path, + &dummy_info, load_no_content); + if (!lib) + return false; + + memcpy(info, &dummy_info, sizeof(*info)); + info->library_name = strdup(dummy_info.library_name); + info->library_version = strdup(dummy_info.library_version); + if (dummy_info.valid_extensions) + info->valid_extensions = strdup(dummy_info.valid_extensions); + dylib_close(lib); + return true; +#else + return libretro_get_system_info_static(info, load_no_content); +#endif +} + #ifdef HAVE_DYNAMIC /** * libretro_get_environment_info: @@ -281,39 +315,6 @@ static dylib_t libretro_get_system_info_lib(const char *path, return lib; } -/** - * libretro_get_system_info: - * @path : Path to libretro library. - * @info : Pointer to system info information. - * @load_no_content : If true, core should be able to auto-start - * without any content loaded. - * - * Gets system info from an arbitrary lib. - * The struct returned must be freed as strings are allocated dynamically. - * - * Returns: true (1) if successful, otherwise false (0). - **/ -bool libretro_get_system_info(const char *path, - struct retro_system_info *info, bool *load_no_content) -{ -#ifdef HAVE_DYNAMIC - struct retro_system_info dummy_info = {0}; - dylib_t lib = libretro_get_system_info_lib(path, - &dummy_info, load_no_content); - if (!lib) - return false; - - memcpy(info, &dummy_info, sizeof(*info)); - info->library_name = strdup(dummy_info.library_name); - info->library_version = strdup(dummy_info.library_version); - if (dummy_info.valid_extensions) - info->valid_extensions = strdup(dummy_info.valid_extensions); - dylib_close(lib); - return true; -#else - return libretro_get_system_info_static(info, load_no_content); -#endif -} static void load_dynamic_core(void) { From 86c44e76faee211228b9814c4620e87044a87412 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Sep 2016 19:58:05 +0200 Subject: [PATCH 021/334] Buildfix --- dynamic.c | 85 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/dynamic.c b/dynamic.c index cff8011596..e711504ac1 100644 --- a/dynamic.c +++ b/dynamic.c @@ -167,7 +167,49 @@ static bool environ_cb_get_system_info(unsigned cmd, void *data) return true; } -#ifndef HAVE_DYNAMIC +#ifdef HAVE_DYNAMIC +static dylib_t libretro_get_system_info_lib(const char *path, + struct retro_system_info *info, bool *load_no_content) +{ + dylib_t lib = dylib_load(path); + void (*proc)(struct retro_system_info*); + + if (!lib) + { + RARCH_ERR("%s: \"%s\"\n", + msg_hash_to_str(MSG_FAILED_TO_OPEN_LIBRETRO_CORE), + path); + RARCH_ERR("Error(s): %s\n", dylib_error()); + return NULL; + } + + proc = (void (*)(struct retro_system_info*)) + dylib_proc(lib, "retro_get_system_info"); + + if (!proc) + { + dylib_close(lib); + return NULL; + } + + proc(info); + + if (load_no_content) + { + void (*set_environ)(retro_environment_t); + *load_no_content = false; + set_environ = (void (*)(retro_environment_t)) + dylib_proc(lib, "retro_set_environment"); + + if (!set_environ) + return lib; + + libretro_get_environment_info(set_environ, load_no_content); + } + + return lib; +} +#else static bool libretro_get_system_info_static(struct retro_system_info *info, bool *load_no_content) { @@ -273,47 +315,6 @@ void libretro_get_environment_info(void (*func)(retro_environment_t), ignore_environment_cb = false; } -static dylib_t libretro_get_system_info_lib(const char *path, - struct retro_system_info *info, bool *load_no_content) -{ - dylib_t lib = dylib_load(path); - void (*proc)(struct retro_system_info*); - - if (!lib) - { - RARCH_ERR("%s: \"%s\"\n", - msg_hash_to_str(MSG_FAILED_TO_OPEN_LIBRETRO_CORE), - path); - RARCH_ERR("Error(s): %s\n", dylib_error()); - return NULL; - } - - proc = (void (*)(struct retro_system_info*)) - dylib_proc(lib, "retro_get_system_info"); - - if (!proc) - { - dylib_close(lib); - return NULL; - } - - proc(info); - - if (load_no_content) - { - void (*set_environ)(retro_environment_t); - *load_no_content = false; - set_environ = (void (*)(retro_environment_t)) - dylib_proc(lib, "retro_set_environment"); - - if (!set_environ) - return lib; - - libretro_get_environment_info(set_environ, load_no_content); - } - - return lib; -} static void load_dynamic_core(void) From 337a0aac5ad53c45b1a20a9b6242ec7da0372fb0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Sep 2016 20:40:07 +0200 Subject: [PATCH 022/334] Cleanup --- dynamic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dynamic.c b/dynamic.c index e711504ac1..f7c22ded28 100644 --- a/dynamic.c +++ b/dynamic.c @@ -272,10 +272,11 @@ bool libretro_get_system_info(const char *path, if (dummy_info.valid_extensions) info->valid_extensions = strdup(dummy_info.valid_extensions); dylib_close(lib); - return true; #else - return libretro_get_system_info_static(info, load_no_content); + if (!libretro_get_system_info_static(info, load_no_content)) + return false; #endif + return true; } #ifdef HAVE_DYNAMIC From 8fddf7f1ff60b6317405bad29f91eb40cfb58acc Mon Sep 17 00:00:00 2001 From: radius Date: Tue, 13 Sep 2016 00:37:23 -0500 Subject: [PATCH 023/334] prevent settings from propagating to main config when creating new overrides --- command.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/command.c b/command.c index ffbc37ef82..4e74e58e11 100644 --- a/command.c +++ b/command.c @@ -1639,6 +1639,10 @@ void command_event_save_current_config(int override_type) { snprintf(msg, sizeof(msg), "Overrides saved successfully"); RARCH_LOG("[overrides] %s\n", msg); + + /* set overrides to active so the original config can be + restored after closing content */ + runloop_ctl(RUNLOOP_CTL_SET_OVERRIDES_ACTIVE, NULL); } else { From 9ccae28f6ed06ae2e85f230fa6683be19559adaf Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 13 Sep 2016 11:41:45 +0200 Subject: [PATCH 024/334] Cleanups --- audio/audio_driver.c | 10 ++++++---- audio/audio_resampler_driver.h | 14 -------------- audio/test/main.c | 7 +++++-- audio/test/snr.c | 7 +++++-- record/drivers/record_ffmpeg.c | 14 ++++++++------ 5 files changed, 24 insertions(+), 28 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 684e098f18..3601e1dbdf 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -796,8 +796,10 @@ bool audio_driver_find_driver(void) void audio_driver_deinit_resampler(void) { - rarch_resampler_freep(&audio_driver_resampler, - &audio_driver_resampler_data); + if (audio_driver_resampler && audio_driver_resampler_data) + audio_driver_resampler->free(audio_driver_resampler_data); + audio_driver_resampler = NULL; + audio_driver_resampler_data = NULL; } bool audio_driver_free_devices_list(void) @@ -852,8 +854,8 @@ void audio_driver_process_resampler(void *data) struct resampler_data *resampler = (struct resampler_data*)data; performance_counter_init(&resampler_proc, "resampler_proc"); performance_counter_start(&resampler_proc); - rarch_resampler_process(audio_driver_resampler, - audio_driver_resampler_data, resampler); + + audio_driver_resampler->process(audio_driver_resampler_data, resampler); performance_counter_stop(&resampler_proc); } diff --git a/audio/audio_resampler_driver.h b/audio/audio_resampler_driver.h index 0366d5f872..7f3f995930 100644 --- a/audio/audio_resampler_driver.h +++ b/audio/audio_resampler_driver.h @@ -181,20 +181,6 @@ const char *audio_resampler_driver_find_ident(int index); bool rarch_resampler_realloc(void **re, const rarch_resampler_t **backend, const char *ident, double bw_ratio); -/* Convenience macros. - * freep makes sure to set handles to NULL to avoid double-free - * in rarch_resampler_realloc. */ -#define rarch_resampler_freep(backend, handle) do { \ - if (*(backend) && *(handle)) \ - (*backend)->free(*handle); \ - *backend = NULL; \ - *handle = NULL; \ -} while(0) - -#define rarch_resampler_process(backend, handle, data) do { \ - (backend)->process(handle, data); \ -} while(0) - RETRO_END_DECLS #endif diff --git a/audio/test/main.c b/audio/test/main.c index 047095c62f..a322632c53 100644 --- a/audio/test/main.c +++ b/audio/test/main.c @@ -87,7 +87,7 @@ int main(int argc, char *argv[]) data.input_frames = sizeof(input_f) / (2 * sizeof(float)); data.ratio = ratio * rate_mod; - rarch_resampler_process(resampler, re, &data); + resampler->process(re, &data); output_samples = data.output_frames * 2; @@ -97,6 +97,9 @@ int main(int argc, char *argv[]) break; } - rarch_resampler_freep(&resampler, &re); + if (resampler && re) + resampler->free(re); + resampler = NULL; + re = NULL; } diff --git a/audio/test/snr.c b/audio/test/snr.c index a61e6feb14..e3e284a40b 100644 --- a/audio/test/snr.c +++ b/audio/test/snr.c @@ -327,7 +327,7 @@ int main(int argc, char *argv[]) data.input_frames = in_rate * 2; data.ratio = ratio; - rarch_resampler_process(resampler, re, &data); + resampler->process(re, &data); /* We generate 2 seconds worth of audio, however, * only the last second is considered so phase has stabilized. */ @@ -346,7 +346,10 @@ int main(int argc, char *argv[]) res.alias_freq[2] / (float)in_rate, res.alias_power[2]); } - rarch_resampler_freep(&resampler, &re); + if (resampler && re) + resampler->free(re); + resampler = NULL; + re = NULL; free(input); free(output); diff --git a/record/drivers/record_ffmpeg.c b/record/drivers/record_ffmpeg.c index 71ba0550a3..4faff59799 100644 --- a/record/drivers/record_ffmpeg.c +++ b/record/drivers/record_ffmpeg.c @@ -762,8 +762,10 @@ static void ffmpeg_free(void *data) if (handle->config.audio_opts) av_dict_free(&handle->config.audio_opts); - rarch_resampler_freep(&handle->audio.resampler, - &handle->audio.resampler_data); + if (handle->audio.resampler && handle->audio.resampler_data) + handle->audio.resampler->free(handle->audio.resampler_data); + handle->audio.resampler = NULL; + handle->audio.resampler_data = NULL; av_free(handle->audio.float_conv); av_free(handle->audio.resample_out); @@ -1188,10 +1190,10 @@ static void ffmpeg_audio_resample(ffmpeg_t *handle, info.input_frames = aud->frames; info.ratio = handle->audio.ratio; - rarch_resampler_process(handle->audio.resampler, - handle->audio.resampler_data, &info); - aud->data = handle->audio.resample_out; - aud->frames = info.output_frames; + handle->audio.resampler->process(handle->audio.resampler_data, &info); + + aud->data = handle->audio.resample_out; + aud->frames = info.output_frames; if (!handle->audio.use_float) { From 6b47bc0bdc8a77582c67e7f4c711f9d8dcfef232 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 13 Sep 2016 11:46:42 +0200 Subject: [PATCH 025/334] Cleanup --- audio/audio_resampler_driver.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/audio/audio_resampler_driver.c b/audio/audio_resampler_driver.c index 0d83acf0c2..fdc32ab1e8 100644 --- a/audio/audio_resampler_driver.c +++ b/audio/audio_resampler_driver.c @@ -19,10 +19,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include "../config.h" -#endif - #include "audio_resampler_driver.h" #include "../config_file_userdata.h" #include "../performance_counters.h" From d636f1b4b5a423478ee93c666d951be31efbf8d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Tue, 13 Sep 2016 17:18:00 +0200 Subject: [PATCH 026/334] (Menu) Hide Interface Settings in Lakka --- menu/menu_setting.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 6560e3fb41..016c8aacb4 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -2427,7 +2427,7 @@ static bool setting_append_list( parent_group); menu_settings_list_current_add_enum_idx(list, list_info, MENU_ENUM_LABEL_MENU_SETTINGS); -#if !defined(RARCH_CONSOLE) +#if !defined(RARCH_CONSOLE) && !defined(HAVE_LAKKA) CONFIG_ACTION( list, list_info, msg_hash_to_str(MENU_ENUM_LABEL_USER_INTERFACE_SETTINGS), From 82dd2bc64c767b9173072c4fe83e7f15cee2c0ca Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 13 Sep 2016 22:37:27 +0200 Subject: [PATCH 027/334] Should add default 'no settings' entry if no settings can be pushed for updater settings list --- menu/menu_displaylist.c | 47 ++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 95f2549667..e21adb4846 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2422,12 +2422,16 @@ loop: menu_settings_list_increment(&setting); } - if (count == 0 && add_empty_entry) - menu_entries_append_enum(info->list, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_SETTINGS_FOUND), - msg_hash_to_str(MENU_ENUM_LABEL_NO_SETTINGS_FOUND), - MENU_ENUM_LABEL_NO_SETTINGS_FOUND, - 0, 0, 0); + if (count == 0) + { + if (add_empty_entry) + menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_SETTINGS_FOUND), + msg_hash_to_str(MENU_ENUM_LABEL_NO_SETTINGS_FOUND), + MENU_ENUM_LABEL_NO_SETTINGS_FOUND, + 0, 0, 0); + return -1; + } return 0; } @@ -4624,15 +4628,28 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) info->need_push = true; break; case DISPLAYLIST_UPDATER_SETTINGS_LIST: - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_CORE_UPDATER_BUILDBOT_URL, - PARSE_ONLY_STRING, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_BUILDBOT_ASSETS_URL, - PARSE_ONLY_STRING, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_CORE_UPDATER_AUTO_EXTRACT_ARCHIVE, - PARSE_ONLY_BOOL, false); + { + unsigned count = 0; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_CORE_UPDATER_BUILDBOT_URL, + PARSE_ONLY_STRING, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_BUILDBOT_ASSETS_URL, + PARSE_ONLY_STRING, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_CORE_UPDATER_AUTO_EXTRACT_ARCHIVE, + PARSE_ONLY_BOOL, false) != -1) + count++; + + if (count == 0) + menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_SETTINGS_FOUND), + msg_hash_to_str(MENU_ENUM_LABEL_NO_SETTINGS_FOUND), + MENU_ENUM_LABEL_NO_SETTINGS_FOUND, + 0, 0, 0); + } info->need_refresh = true; info->need_push = true; From 10c29cd31728df935e0dd17830aa3b80e84c19b3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 13 Sep 2016 22:43:20 +0200 Subject: [PATCH 028/334] Add default 'no settings' entry if no settings could be added for network settings --- menu/menu_displaylist.c | 102 ++++++++++++++++++++++++---------------- 1 file changed, 62 insertions(+), 40 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index e21adb4846..7a876f2f1d 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -4655,53 +4655,75 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) info->need_push = true; break; case DISPLAYLIST_NETWORK_SETTINGS_LIST: - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETPLAY_ENABLE, - PARSE_ONLY_BOOL, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETPLAY_CLIENT_SWAP_INPUT, - PARSE_ONLY_BOOL, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETPLAY_IP_ADDRESS, - PARSE_ONLY_STRING, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETPLAY_MODE, - PARSE_ONLY_BOOL, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETPLAY_SPECTATOR_MODE_ENABLE, - PARSE_ONLY_BOOL, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETPLAY_DELAY_FRAMES, - PARSE_ONLY_UINT, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETPLAY_TCP_UDP_PORT, - PARSE_ONLY_UINT, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETWORK_CMD_ENABLE, - PARSE_ONLY_BOOL, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETWORK_CMD_PORT, - PARSE_ONLY_UINT, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETWORK_REMOTE_ENABLE, - PARSE_ONLY_BOOL, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETWORK_REMOTE_PORT, - PARSE_ONLY_UINT, false); - { unsigned user; + unsigned count = 0; + + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETPLAY_ENABLE, + PARSE_ONLY_BOOL, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETPLAY_CLIENT_SWAP_INPUT, + PARSE_ONLY_BOOL, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETPLAY_IP_ADDRESS, + PARSE_ONLY_STRING, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETPLAY_MODE, + PARSE_ONLY_BOOL, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETPLAY_SPECTATOR_MODE_ENABLE, + PARSE_ONLY_BOOL, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETPLAY_DELAY_FRAMES, + PARSE_ONLY_UINT, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETPLAY_TCP_UDP_PORT, + PARSE_ONLY_UINT, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETWORK_CMD_ENABLE, + PARSE_ONLY_BOOL, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETWORK_CMD_PORT, + PARSE_ONLY_UINT, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETWORK_REMOTE_ENABLE, + PARSE_ONLY_BOOL, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETWORK_REMOTE_PORT, + PARSE_ONLY_UINT, false) != -1) + count++; + for(user = 0; user < settings->input.max_users; user++) { - menu_displaylist_parse_settings_enum(menu, info, + if (menu_displaylist_parse_settings_enum(menu, info, (enum msg_hash_enums)(MENU_ENUM_LABEL_NETWORK_REMOTE_USER_1_ENABLE + user), - PARSE_ONLY_BOOL, false); + PARSE_ONLY_BOOL, false) != -1) + count++; } - } - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_STDIN_CMD_ENABLE, - PARSE_ONLY_BOOL, false); + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_STDIN_CMD_ENABLE, + PARSE_ONLY_BOOL, false) != -1) + count++; + + if (count == 0) + menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_SETTINGS_FOUND), + msg_hash_to_str(MENU_ENUM_LABEL_NO_SETTINGS_FOUND), + MENU_ENUM_LABEL_NO_SETTINGS_FOUND, + 0, 0, 0); + } info->need_refresh = true; info->need_push = true; From 7731b14b5cd101b0bb18a5e9909972f3f1255fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Tue, 13 Sep 2016 22:58:52 +0200 Subject: [PATCH 029/334] (XMB) Undo icon --- menu/drivers/xmb.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index da491d6b89..a5efe33358 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -92,6 +92,7 @@ enum XMB_TEXTURE_RESUME, XMB_TEXTURE_SAVESTATE, XMB_TEXTURE_LOADSTATE, + XMB_TEXTURE_UNDO, XMB_TEXTURE_CORE_INFO, XMB_TEXTURE_CORE_OPTIONS, XMB_TEXTURE_INPUT_REMAPPING_OPTIONS, @@ -1623,6 +1624,9 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, return xmb->textures.list[XMB_TEXTURE_SAVESTATE]; case MENU_ENUM_LABEL_LOAD_STATE: return xmb->textures.list[XMB_TEXTURE_LOADSTATE]; + case MENU_ENUM_LABEL_UNDO_LOAD_STATE: + case MENU_ENUM_LABEL_UNDO_SAVE_STATE: + return xmb->textures.list[XMB_TEXTURE_UNDO]; case MENU_ENUM_LABEL_TAKE_SCREENSHOT: return xmb->textures.list[XMB_TEXTURE_SCREENSHOT]; case MENU_ENUM_LABEL_DELETE_ENTRY: @@ -2813,6 +2817,8 @@ static const char *xmb_texture_path(unsigned id) return "savestate.png"; case XMB_TEXTURE_LOADSTATE: return "loadstate.png"; + case XMB_TEXTURE_UNDO: + return "undo.png"; case XMB_TEXTURE_CORE_INFO: return "core-infos.png"; case XMB_TEXTURE_CORE_OPTIONS: From 7763cf1301ad1209162c274a60b9ccbc1b96221f Mon Sep 17 00:00:00 2001 From: Ezio-PS Date: Tue, 13 Sep 2016 23:20:48 +0200 Subject: [PATCH 030/334] Update Italian translation --- intl/msg_hash_it.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/intl/msg_hash_it.c b/intl/msg_hash_it.c index 0aa2c91bbf..b80b1a08af 100644 --- a/intl/msg_hash_it.c +++ b/intl/msg_hash_it.c @@ -1110,12 +1110,18 @@ const char *msg_hash_to_str_it(enum msg_hash_enums msg) { switch (msg) { - case MENU_ENUM_LABEL_VALUE_INPUT_ICADE_ENABLE: + case MENU_ENUM_LABEL_VALUE_PARENT_DIRECTORY: + return "Directory precedente"; + case MENU_ENUM_LABEL_VALUE_INPUT_ICADE_ENABLE: return "Abilita mappatura gamepad tastiera"; case MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE: return "Tipologia di mappatura gamepad tastiera"; case MENU_ENUM_LABEL_VALUE_INPUT_SMALL_KEYBOARD_ENABLE: return "Abilita tastiera ridotta"; + case MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG_OVERRIDE_CORE: + return "Salva override del core"; + case MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG_OVERRIDE_GAME: + return "Salva override di gioco"; case MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG: return "Salva configurazione attuale"; case MENU_ENUM_LABEL_VALUE_STATE_SLOT: @@ -1187,7 +1193,7 @@ const char *msg_hash_to_str_it(enum msg_hash_enums msg) case MENU_ENUM_LABEL_VALUE_UPDATE_CORE_INFO_FILES: return "Aggiorna i files info dei core"; case MENU_ENUM_LABEL_VALUE_DOWNLOAD_CORE_CONTENT: - return "Contenuto scaricato"; + return "Scarica contenuto"; case MENU_ENUM_LABEL_VALUE_SCAN_THIS_DIRECTORY: return ""; case MENU_ENUM_LABEL_VALUE_SCAN_FILE: @@ -1445,8 +1451,8 @@ const char *msg_hash_to_str_it(enum msg_hash_enums msg) return "Fotogrammi stimati del monitor"; case MENU_ENUM_LABEL_VALUE_DUMMY_ON_CORE_SHUTDOWN: return "Valore fittizio sull'arresto del core"; - case MENU_ENUM_LABEL_VALUE_CORE_SET_SUPPORTS_NO_CONTENT_ENABLE: /* TODO/FIXME */ - return "Non avviare automaticamente un core"; + case MENU_ENUM_LABEL_VALUE_CORE_SET_SUPPORTS_NO_CONTENT_ENABLE: + return "Avvia automaticamente un core"; case MENU_ENUM_LABEL_VALUE_FRAME_THROTTLE_ENABLE: return "Limita la velocità massima di caricamento"; case MENU_ENUM_LABEL_VALUE_FASTFORWARD_RATIO: @@ -1587,8 +1593,8 @@ const char *msg_hash_to_str_it(enum msg_hash_enums msg) return "Collezione"; case MENU_ENUM_LABEL_VALUE_DETECT_CORE_LIST: return "Seleziona il file ed intercetta il core"; - case MENU_ENUM_LABEL_VALUE_DOWNLOADED_FILE_DETECT_CORE_LIST: /* TODO/FIXME - rewrite */ - return "Seleziona file scaricati ed intercetta il core"; + case MENU_ENUM_LABEL_VALUE_DOWNLOADED_FILE_DETECT_CORE_LIST: + return "Scarica directories"; case MENU_ENUM_LABEL_VALUE_LOAD_CONTENT_HISTORY: return "Carica Recenti"; case MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE: @@ -1633,6 +1639,8 @@ const char *msg_hash_to_str_it(enum msg_hash_enums msg) return "Contatore dei core"; case MENU_ENUM_LABEL_VALUE_TAKE_SCREENSHOT: return "Cattura Screenshot"; + case MENU_ENUM_LABEL_VALUE_DELETE_ENTRY: + return "Rimuovi dalla Playlist"; case MENU_ENUM_LABEL_VALUE_RESUME: return "Riprendi"; case MENU_ENUM_LABEL_VALUE_DISK_INDEX: @@ -1682,7 +1690,7 @@ const char *msg_hash_to_str_it(enum msg_hash_enums msg) case MENU_ENUM_LABEL_VALUE_NAVIGATION_WRAPAROUND: return "Navigazione avvolgente"; case MENU_ENUM_LABEL_VALUE_NAVIGATION_BROWSER_FILTER_SUPPORTED_EXTENSIONS_ENABLE: - return "Filtra con estensioni supportate"; /* TODO/FIXME - rewrite */ + return "Filtra estensioni sconosciute"; case MENU_ENUM_LABEL_VALUE_CORE_UPDATER_AUTO_EXTRACT_ARCHIVE: return "Estrai automaticamente gli archivi scaricati"; case MENU_ENUM_LABEL_VALUE_SYSTEM_INFORMATION: From d6f82b4a161e696bded5751dffa6927a95d9f9b0 Mon Sep 17 00:00:00 2001 From: radius Date: Tue, 13 Sep 2016 19:37:00 -0500 Subject: [PATCH 031/334] (emscripten) disable buttons for real, use inmemory file system for content to be able to upload more than 10MB --- pkg/emscripten/proto.html | 10 +++--- pkg/emscripten/proto.js | 74 +++++++++++++++++++++++++-------------- 2 files changed, 52 insertions(+), 32 deletions(-) diff --git a/pkg/emscripten/proto.html b/pkg/emscripten/proto.html index 656ec7ffc3..6d6b683932 100644 --- a/pkg/emscripten/proto.html +++ b/pkg/emscripten/proto.html @@ -84,17 +84,17 @@ Yabause - - - - - diff --git a/pkg/emscripten/proto.js b/pkg/emscripten/proto.js index 7600129776..55e79fa62c 100644 --- a/pkg/emscripten/proto.js +++ b/pkg/emscripten/proto.js @@ -61,17 +61,20 @@ function dropboxInit() { return showError(error); } - dropboxSync(client, success); + dropboxSync(client, dropboxSyncComplete); }); } -function success() + +function dropboxSyncComplete() { document.getElementById('btnRun').disabled = false; $('#icnDrop').removeClass('fa-spinner').removeClass('fa-spin'); $('#icnDrop').addClass('fa-check'); console.log("WEBPLAYER: Sync successful"); + setupFileSystem("dropbox"); setupFolderStructure(); + preLoadingComplete(); } var afs; @@ -91,6 +94,16 @@ function dropboxSync(dropboxClient, cb) }); } +function preLoadingComplete() +{ + /* Make the Preview image clickable to start RetroArch. */ + $('.webplayer-preview').addClass('loaded').click(function () { + startRetroArch(); + return false; + }); +} + + function setupFileSystem(backend) { /* create a mountable filesystem that will server as a root @@ -114,6 +127,12 @@ function setupFileSystem(backend) /* mount the filesystems onto mfs */ mfs.mount('/home/web_user/retroarch/userdata', lsfs); + + /* create a memory filesystem for content only */ + var imfs = new BrowserFS.FileSystem.InMemory(); + + /* mount the filesystems onto mfs */ + mfs.mount('/home/web_user/retroarch/userdata/content/', imfs); } else { @@ -165,9 +184,15 @@ function startRetroArch() document.getElementById('btnRun').disabled = true; $('#btnFullscreen').removeClass('disabled'); + $('#btnMenu').removeClass('disabled'); $('#btnAdd').removeClass('disabled'); $('#btnRom').removeClass('disabled'); + document.getElementById("btnAdd").disabled = false; + document.getElementById("btnRom").disabled = false; + document.getElementById("btnMenu").disabled = false; + document.getElementById("btnFullscreen").disabled = false; + Module['callMain'](Module['arguments']); document.getElementById('canvas').focus(); } @@ -187,9 +212,9 @@ function selectFiles(files) filereader.onload = function(){uploadData(this.result, this.file_name)}; filereader.onloadend = function(evt) { + console.log("WEBPLAYER: File: " + this.file_name + " Upload Complete"); if (evt.target.readyState == FileReader.DONE) { - console.log("WEBPLAYER: File: " + this.file_name + " Upload Complete"); $('#btnAdd').removeClass('disabled'); $('#icnAdd').removeClass('fa-spinner spinning'); $('#icnAdd').addClass('fa-plus'); @@ -309,32 +334,27 @@ $(function() { // Load the Core's related JavaScript. $.getScript(core + '_libretro.js', function () { - /** - * Make the Preview image clickable to start RetroArch. - */ - $('.webplayer-preview').addClass('loaded').click(function () { - startRetroArch(); - return false; - }); + // Activate the Start RetroArch button. + $('#btnRun').removeClass('disabled'); + $('#icnRun').removeClass('fa-spinner').removeClass('fa-spin'); + $('#icnRun').addClass('fa-play'); - // Activate the Start RetroArch button. - $('#btnRun').removeClass('disabled'); - $('#icnRun').removeClass('fa-spinner').removeClass('fa-spin'); - $('#icnRun').addClass('fa-play'); + document.getElementById("btnRun").disabled = false; - if (localStorage.getItem("backend") == "dropbox") - { - $('#lblDrop').addClass('active'); - $('#lblLocal').removeClass('active'); - dropboxInit(); - } - else { - $('#lblDrop').removeClass('active'); - $('#lblLocal').addClass('active'); - setupFileSystem("browser"); - setupFolderStructure(); - } - //$('#dropdownMenu1').text(localStorage.getItem("core")); + if (localStorage.getItem("backend") == "dropbox") + { + $('#lblDrop').addClass('active'); + $('#lblLocal').removeClass('active'); + dropboxInit(); + } + else + { + $('#lblDrop').removeClass('active'); + $('#lblLocal').addClass('active'); + preLoadingComplete(); + setupFileSystem("browser"); + setupFolderStructure(); + } }); }); From 0b46a6902d6202fde42b568adf376fb7611b8db9 Mon Sep 17 00:00:00 2001 From: radius Date: Tue, 13 Sep 2016 19:40:45 -0500 Subject: [PATCH 032/334] (emscripten) add downloads to userdata --- pkg/emscripten/proto.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/emscripten/proto.js b/pkg/emscripten/proto.js index 55e79fa62c..e6308a676a 100644 --- a/pkg/emscripten/proto.js +++ b/pkg/emscripten/proto.js @@ -141,7 +141,7 @@ function setupFileSystem(backend) } mfs.mount('/home/web_user/retroarch/bundle', xfs1); - mfs.mount('/home/web_user/retroarch/downloads', xfs2); + mfs.mount('/home/web_user/retroarch/userdata/downloads', xfs2); BrowserFS.initialize(mfs); var BFS = new BrowserFS.EmscriptenFS(); FS.mount(BFS, {root: '/home'}, '/home'); From 9022bf75ada186c51f2510f1ed9cb6b558904935 Mon Sep 17 00:00:00 2001 From: radius Date: Tue, 13 Sep 2016 19:48:17 -0500 Subject: [PATCH 033/334] (emscripten) make core assets a subdir of content --- frontend/drivers/platform_emscripten.c | 2 +- pkg/emscripten/proto.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/drivers/platform_emscripten.c b/frontend/drivers/platform_emscripten.c index 5941702c6a..6488ab1767 100644 --- a/frontend/drivers/platform_emscripten.c +++ b/frontend/drivers/platform_emscripten.c @@ -126,7 +126,7 @@ static void frontend_emscripten_get_env(int *argc, char *argv[], fill_pathname_join(g_defaults.dir.menu_content, user_path, "content", sizeof(g_defaults.dir.menu_content)); fill_pathname_join(g_defaults.dir.core_assets, user_path, - "downloads", sizeof(g_defaults.dir.core_assets)); + "content/downloads", sizeof(g_defaults.dir.core_assets)); fill_pathname_join(g_defaults.dir.playlist, user_path, "playlists", sizeof(g_defaults.dir.playlist)); fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.menu_config, diff --git a/pkg/emscripten/proto.js b/pkg/emscripten/proto.js index e6308a676a..f22e7e87b3 100644 --- a/pkg/emscripten/proto.js +++ b/pkg/emscripten/proto.js @@ -141,7 +141,7 @@ function setupFileSystem(backend) } mfs.mount('/home/web_user/retroarch/bundle', xfs1); - mfs.mount('/home/web_user/retroarch/userdata/downloads', xfs2); + mfs.mount('/home/web_user/retroarch/userdata/content/downloads', xfs2); BrowserFS.initialize(mfs); var BFS = new BrowserFS.EmscriptenFS(); FS.mount(BFS, {root: '/home'}, '/home'); From 69b7dc0d08f58fe9cc4511afede1ca78a6a750d8 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Sun, 11 Sep 2016 22:01:47 -0400 Subject: [PATCH 034/334] Multitudinous fixes and updates to Netplay. Had to be one commit since they're mostly related: (1) Renamed frame_count to self_frame_count to be consistent with all other names. (2) Previously, it was possible to overwrite data in the ring buffer that hadn't yet been used. Now that's not possible, but that just changes one breakage for another: It's now possible to miss the NEW data. The final resolution for this will probably be requesting stalls. This is accomplished simply by storing frame numbers in the ring buffer and checking them against the 'other' head. (3) In TCP packets, separated cmd_size from cmd. It was beyond pointless for these to be combined, and restricted cmd_size to 16 bits, which will probably fail when/if state loading is supported. (4) Readahead is now allowed. In the past, if the peer got ahead of us, we would simply ignore their data. Thus, if they got too far ahead of us, we'd stop reading their data altogether. Fabulous. Now, we're happy to read future input. (5) If the peer gets too far ahead of us (currently an unconfigurable 10 frames), fast forward to catch up. This should prevent desync due to clock drift or stutter. (6) Used frame_count in a few places where ptr was used. Doing a comparison of pointers on a ring buffer is a far more dangerous way to assure we're done with a task than simply using the count, since the ring buffer is... well, a ring. (7) Renamed tmp_{ptr,frame_count} to replay_{ptr,frame_count} for clarity. (8) Slightly changed the protocol version hash, just to assure that other clients wouldn't think they were compatible with this one. (9) There was an off-by-one error which, under some circumstances, could allow the replay engine to run a complete round through the ring buffer, replaying stale data. Fixed. --- network/netplay/netplay.c | 47 +++++++++++++++------- network/netplay/netplay_common.c | 15 +++++++ network/netplay/netplay_net.c | 66 +++++++++++++++++++++++++------ network/netplay/netplay_private.h | 17 ++++++-- 4 files changed, 114 insertions(+), 31 deletions(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index a2a574ac52..d80728b8ac 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -65,7 +65,7 @@ static void warn_hangup(void) bool check_netplay_synched(netplay_t* netplay) { retro_assert(netplay); - return netplay->frame_count < (netplay->flip_frame + 2 * UDP_FRAME_PACKETS); + return netplay->self_frame_count < (netplay->flip_frame + 2 * UDP_FRAME_PACKETS); } static bool netplay_info_cb(netplay_t* netplay, unsigned frames) { @@ -142,7 +142,9 @@ static bool get_self_input_state(netplay_t *netplay) uint32_t state[UDP_WORDS_PER_FRAME - 1] = {0}; struct delta_frame *ptr = &netplay->buffer[netplay->self_ptr]; - if (!input_driver_is_libretro_input_blocked() && netplay->frame_count > 0) + if (!netplay_delta_frame_ready(netplay, ptr, netplay->self_frame_count)) return false; + + if (!input_driver_is_libretro_input_blocked() && netplay->self_frame_count > 0) { unsigned i; settings_t *settings = config_get_ptr(); @@ -185,7 +187,7 @@ static bool get_self_input_state(netplay_t *netplay) */ memmove(netplay->packet_buffer, netplay->packet_buffer + UDP_WORDS_PER_FRAME, sizeof (netplay->packet_buffer) - UDP_WORDS_PER_FRAME * sizeof(uint32_t)); - netplay->packet_buffer[(UDP_FRAME_PACKETS - 1) * UDP_WORDS_PER_FRAME] = htonl(netplay->frame_count); + netplay->packet_buffer[(UDP_FRAME_PACKETS - 1) * UDP_WORDS_PER_FRAME] = htonl(netplay->self_frame_count); netplay->packet_buffer[(UDP_FRAME_PACKETS - 1) * UDP_WORDS_PER_FRAME + 1] = htonl(state[0]); netplay->packet_buffer[(UDP_FRAME_PACKETS - 1) * UDP_WORDS_PER_FRAME + 2] = htonl(state[1]); netplay->packet_buffer[(UDP_FRAME_PACKETS - 1) * UDP_WORDS_PER_FRAME + 3] = htonl(state[2]); @@ -227,15 +229,17 @@ static bool netplay_get_cmd(netplay_t *netplay) { uint32_t cmd; uint32_t flip_frame; - size_t cmd_size; + uint32_t cmd_size; if (!socket_receive_all_blocking(netplay->fd, &cmd, sizeof(cmd))) return false; cmd = ntohl(cmd); - cmd_size = cmd & 0xffff; - cmd = cmd >> 16; + if (!socket_receive_all_blocking(netplay->fd, &cmd_size, sizeof(cmd))) + return false; + + cmd_size = ntohl(cmd_size); switch (cmd) { @@ -371,7 +375,7 @@ static void parse_packet(netplay_t *netplay, uint32_t *buffer, unsigned size) for (i = 0; i < size * UDP_WORDS_PER_FRAME; i++) buffer[i] = ntohl(buffer[i]); - for (i = 0; i < size && netplay->read_frame_count <= netplay->frame_count; i++) + for (i = 0; i < size; i++) { uint32_t frame = buffer[UDP_WORDS_PER_FRAME * i + 0]; const uint32_t *state = &buffer[UDP_WORDS_PER_FRAME * i + 1]; @@ -379,6 +383,14 @@ static void parse_packet(netplay_t *netplay, uint32_t *buffer, unsigned size) if (frame != netplay->read_frame_count) continue; + if (!netplay_delta_frame_ready(netplay, &netplay->buffer[netplay->read_ptr], netplay->read_frame_count)) + { + netplay->must_fast_forward = true; + continue; + } + + /* FIXME: acknowledge when we completely drop data on the floor */ + netplay->buffer[netplay->read_ptr].is_simulated = false; memcpy(netplay->buffer[netplay->read_ptr].real_input_state, state, sizeof(netplay->buffer[netplay->read_ptr].real_input_state)); @@ -427,7 +439,7 @@ static bool netplay_poll(netplay_t *netplay) /* We skip reading the first frame so the host has a chance to grab * our host info so we don't block forever :') */ - if (netplay->frame_count == 0) + if (netplay->self_frame_count == 0) { netplay->buffer[0].used_real = true; netplay->buffer[0].is_simulated = false; @@ -464,7 +476,7 @@ static bool netplay_poll(netplay_t *netplay) } parse_packet(netplay, buffer, UDP_FRAME_PACKETS); - } while ((netplay->read_frame_count <= netplay->frame_count) && + } while ((netplay->read_frame_count <= netplay->self_frame_count) && poll_input(netplay, (netplay->other_ptr == netplay->self_ptr) && (first_read == netplay->read_frame_count)) == 1); } @@ -478,7 +490,7 @@ static bool netplay_poll(netplay_t *netplay) } } - if (netplay->read_ptr != netplay->self_ptr) + if (netplay->read_frame_count <= netplay->self_frame_count) simulate_input(netplay); else netplay->buffer[PREV_PTR(netplay->self_ptr)].used_real = true; @@ -533,13 +545,13 @@ static bool netplay_is_alive(netplay_t *netplay) static bool netplay_flip_port(netplay_t *netplay, bool port) { - size_t frame = netplay->frame_count; + size_t frame = netplay->self_frame_count; if (netplay->flip_frame == 0) return port; if (netplay->is_replay) - frame = netplay->tmp_frame_count; + frame = netplay->replay_frame_count; return port ^ netplay->flip ^ (frame < netplay->flip_frame); } @@ -549,7 +561,7 @@ static int16_t netplay_input_state(netplay_t *netplay, unsigned idx, unsigned id) { size_t ptr = netplay->is_replay ? - netplay->tmp_ptr : PREV_PTR(netplay->self_ptr); + netplay->replay_ptr : PREV_PTR(netplay->self_ptr); const uint32_t *curr_input_state = netplay->buffer[ptr].self_state; @@ -871,12 +883,17 @@ error: static bool netplay_send_raw_cmd(netplay_t *netplay, uint32_t cmd, const void *data, size_t size) { - cmd = (cmd << 16) | (size & 0xffff); + uint32_t cmd_size; + cmd = htonl(cmd); + cmd_size = htonl(size); if (!socket_send_all_blocking(netplay->fd, &cmd, sizeof(cmd), false)) return false; + if (!socket_send_all_blocking(netplay->fd, &cmd_size, sizeof(cmd_size), false)) + return false; + if (!socket_send_all_blocking(netplay->fd, data, size, false)) return false; @@ -953,7 +970,7 @@ error: **/ static void netplay_flip_users(netplay_t *netplay) { - uint32_t flip_frame = netplay->frame_count + 2 * UDP_FRAME_PACKETS; + uint32_t flip_frame = netplay->self_frame_count + 2 * UDP_FRAME_PACKETS; uint32_t flip_frame_net = htonl(flip_frame); bool command = netplay_command( netplay, NETPLAY_CMD_FLIP_PLAYERS, diff --git a/network/netplay/netplay_common.c b/network/netplay/netplay_common.c index dba2eef948..ffdbddaa80 100644 --- a/network/netplay/netplay_common.c +++ b/network/netplay/netplay_common.c @@ -199,6 +199,8 @@ uint32_t netplay_impl_magic(void) for (i = 0; i < len; i++) res ^= ver[i] << ((i & 0xf) + 16); + res ^= NETPLAY_PROTOCOL_VERSION << 24; + return res; } @@ -342,3 +344,16 @@ bool netplay_is_spectate(netplay_t* netplay) return false; return netplay->spectate.enabled; } + +bool netplay_delta_frame_ready(netplay_t *netplay, struct delta_frame *delta, uint32_t frame) +{ + if (delta->frame == frame) return true; + if (netplay->other_frame_count <= delta->frame) + { + /* We haven't even replayed this frame yet, so we can't overwrite it! */ + return false; + } + memset(delta, 0, sizeof(struct delta_frame)); + delta->frame = frame; + return true; +} diff --git a/network/netplay/netplay_net.c b/network/netplay/netplay_net.c index 91dfc88615..c6ee585ce8 100644 --- a/network/netplay/netplay_net.c +++ b/network/netplay/netplay_net.c @@ -30,10 +30,13 @@ static void netplay_net_pre_frame(netplay_t *netplay) { retro_ctx_serialize_info_t serial_info; - serial_info.data = netplay->buffer[netplay->self_ptr].state; - serial_info.size = netplay->state_size; + if (netplay_delta_frame_ready(netplay, &netplay->buffer[netplay->self_ptr], netplay->self_frame_count)) + { + serial_info.data = netplay->buffer[netplay->self_ptr].state; + serial_info.size = netplay->state_size; - core_serialize(&serial_info); + core_serialize(&serial_info); + } netplay->can_poll = true; @@ -49,7 +52,7 @@ static void netplay_net_pre_frame(netplay_t *netplay) **/ static void netplay_net_post_frame(netplay_t *netplay) { - netplay->frame_count++; + netplay->self_frame_count++; /* Nothing to do... */ if (netplay->other_frame_count == netplay->read_frame_count) @@ -69,24 +72,24 @@ static void netplay_net_post_frame(netplay_t *netplay) netplay->other_frame_count++; } + /* Now replay the real input if we've gotten ahead of it */ if (netplay->other_frame_count < netplay->read_frame_count) { retro_ctx_serialize_info_t serial_info; - bool first = true; /* Replay frames. */ netplay->is_replay = true; - netplay->tmp_ptr = netplay->other_ptr; - netplay->tmp_frame_count = netplay->other_frame_count; + netplay->replay_ptr = netplay->other_ptr; + netplay->replay_frame_count = netplay->other_frame_count; serial_info.data_const = netplay->buffer[netplay->other_ptr].state; serial_info.size = netplay->state_size; core_unserialize(&serial_info); - while (first || (netplay->tmp_ptr != netplay->self_ptr)) + while (netplay->replay_frame_count < netplay->self_frame_count) { - serial_info.data = netplay->buffer[netplay->tmp_ptr].state; + serial_info.data = netplay->buffer[netplay->replay_ptr].state; serial_info.size = netplay->state_size; serial_info.data_const = NULL; @@ -99,15 +102,54 @@ static void netplay_net_post_frame(netplay_t *netplay) #if defined(HAVE_THREADS) autosave_unlock(); #endif - netplay->tmp_ptr = NEXT_PTR(netplay->tmp_ptr); - netplay->tmp_frame_count++; - first = false; + netplay->replay_ptr = NEXT_PTR(netplay->replay_ptr); + netplay->replay_frame_count++; } netplay->other_ptr = netplay->read_ptr; netplay->other_frame_count = netplay->read_frame_count; netplay->is_replay = false; } + + /* And if the other side has gotten too far ahead of /us/, skip to catch up + * FIXME: Make this configurable */ + if (netplay->read_frame_count > netplay->self_frame_count + 10 || + netplay->must_fast_forward) + { + /* "replay" into the future */ + netplay->is_replay = true; + netplay->replay_ptr = netplay->self_ptr; + netplay->replay_frame_count = netplay->self_frame_count; + + /* just assume input doesn't change for the intervening frames */ + while (netplay->replay_frame_count < netplay->read_frame_count) + { + size_t cur = netplay->replay_ptr; + size_t prev = PREV_PTR(cur); + + memcpy(netplay->buffer[cur].self_state, netplay->buffer[prev].self_state, + sizeof(netplay->buffer[prev].self_state)); + +#if defined(HAVE_THREADS) + autosave_lock(); +#endif + core_run(); +#if defined(HAVE_THREADS) + autosave_unlock(); +#endif + + netplay->replay_ptr = NEXT_PTR(cur); + netplay->replay_frame_count++; + } + + /* at this point, other = read = self */ + netplay->self_ptr = netplay->replay_ptr; + netplay->self_frame_count = netplay->replay_frame_count; + netplay->other_ptr = netplay->read_ptr; + netplay->other_frame_count = netplay->read_frame_count; + netplay->is_replay = false; + } + } static bool netplay_net_init_buffers(netplay_t *netplay) { diff --git a/network/netplay/netplay_private.h b/network/netplay/netplay_private.h index f0e30aac17..13a7dbc904 100644 --- a/network/netplay/netplay_private.h +++ b/network/netplay/netplay_private.h @@ -35,17 +35,22 @@ #define MAX_SPECTATORS 16 #define RARCH_DEFAULT_PORT 55435 +#define NETPLAY_PROTOCOL_VERSION 1 + #define PREV_PTR(x) ((x) == 0 ? netplay->buffer_size - 1 : (x) - 1) #define NEXT_PTR(x) ((x + 1) % netplay->buffer_size) struct delta_frame { + uint32_t frame; + void *state; uint32_t real_input_state[UDP_WORDS_PER_FRAME - 1]; uint32_t simulated_input_state[UDP_WORDS_PER_FRAME - 1]; uint32_t self_state[UDP_WORDS_PER_FRAME - 1]; + bool have_local; bool is_simulated; bool used_real; }; @@ -81,8 +86,8 @@ struct netplay /* Pointer to where we are reading. * Generally, other_ptr <= read_ptr <= self_ptr. */ size_t read_ptr; - /* A temporary pointer used on replay. */ - size_t tmp_ptr; + /* A pointer used temporarily for replay. */ + size_t replay_ptr; size_t state_size; @@ -90,14 +95,16 @@ struct netplay bool is_replay; /* We don't want to poll several times on a frame. */ bool can_poll; + /* If we end up having to drop remote frame data because it's ahead of us, fast-forward is URGENT */ + bool must_fast_forward; /* To compat UDP packet loss we also send * old data along with the packets. */ uint32_t packet_buffer[UDP_FRAME_PACKETS * UDP_WORDS_PER_FRAME]; - uint32_t frame_count; + uint32_t self_frame_count; uint32_t read_frame_count; uint32_t other_frame_count; - uint32_t tmp_frame_count; + uint32_t replay_frame_count; struct addrinfo *addr; struct sockaddr_storage their_addr; bool has_client_addr; @@ -158,4 +165,6 @@ bool netplay_is_server(netplay_t* netplay); bool netplay_is_spectate(netplay_t* netplay); +bool netplay_delta_frame_ready(netplay_t *netplay, struct delta_frame *delta, uint32_t frame); + #endif From 9a80a1bd7e0183ecb8c0092b24fe0e0a2faece67 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Sun, 11 Sep 2016 22:17:07 -0400 Subject: [PATCH 035/334] Adding a bit of Netplay documentation. --- network/netplay/README | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 network/netplay/README diff --git a/network/netplay/README b/network/netplay/README new file mode 100644 index 0000000000..3779c0ce68 --- /dev/null +++ b/network/netplay/README @@ -0,0 +1,52 @@ +How Netplay works (as documented by somebody who didn't write it): + +Note that this documentation is all for (the poorly-named) “net” mode, which is +the normal mode, and not “spectator” mode, which has its own whole host of +problems. + +Netplay in RetroArch works by expecting input to come delayed from the network, +then rewinding and re-playing with the delayed input to get a consistent state. +So long as both sides agree on which frame is which, it should be impossible +for them to become de-synced, since each input event always happens at the +correct frame. + +Within the state buffers, there are three locations: self, other and read. Self +is where the emulator believes itself to be, which inevitably will be ahead of +what it's read from the peer. Other is where it was most recently in perfect +sync: i.e., other has been read and actioned. Read is where it's read up to, +which can be slightly ahead of other since it can't always immediately act upon +new data. In general, other ≤ read ≤ self. If read > self, logically it should +try to catch up, but that logic currently doesn't seem to exist (?) + +In terms of the implementation, Netplay is in effect an input buffer and some +pre- and post-frame behaviors. + +Pre-frame, it serializes the core's state, polls for input from the other side, +and if input has not been received for the other side up to the current frame +(which it shouldn't be), “simulates” the other side's input up to the current +frame. The simulation is simply assuming that the input state hasn't changed. +Each frame's local serialized state and simulated or real input goes into the +frame buffers. Frame buffers that are simulated are marked as such. + +Post-frame, it checks whether it's read more than it's actioned, i.e. if read > +other. If so, it rewinds to other and runs the core in replay mode with the +real data up to read, then sets other = read. + +When in Netplay mode, the callback for receiving input is replaced by +input_state_net. It is the role of input_state_net to combine the true local +input (whether live or replay) with the remote input (whether true or +simulated). + +In the previous implementation, there was seemingly nothing to prevent the self +frame from advancing past the other frame in the ring buffer, causing local +input from one time to be mixed with remote input from another. The new +implementation uses a not-at-all-better strategy of simply refusing local input +if it steps past remote input. + +Some thoughts about "frame counts": The frame counters act like indexes into a +0-indexed array; i.e., they refer to the first unactioned frame. With +self_frame_count it's slightly more complicated, since there are two relevant +actions: Reading the data and emulating with the data. The frame count is only +incremented after the latter, but the nature of the emulation assures that the +current frame's input will always be read before it's actioned (or at least, we +should certainly hope so!) From 5edfbeafb0f6bca2a613b52ca0d3329cd64b1684 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Mon, 12 Sep 2016 07:42:35 -0400 Subject: [PATCH 036/334] Switched Netplay over to TCP. A lot of the stalling logic had to change for this, and in particular, it now sometimes stalls in a way that makes it very difficult to actually input anything (whoops :) ). Simply setting the sync frames higher avoids that. With supported cores, this is incredibly risilient, but when it fails, it mostly fails to freezing, which is less than ideal. TODO: Stall frames should be configurable. All the UDP code is still there but commented out, should be gutted. The original fast-forward code is now commented out, but really both fast-forward and stalling should be options; the only complication is that it needs to send simulated self-input for fast-forward. --- network/netplay/netplay.c | 159 +++++++++++++++++++++--------- network/netplay/netplay.h | 17 ++-- network/netplay/netplay_common.c | 3 + network/netplay/netplay_net.c | 28 ++++-- network/netplay/netplay_private.h | 18 ++-- 5 files changed, 157 insertions(+), 68 deletions(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index d80728b8ac..3425c8c712 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -65,7 +65,9 @@ static void warn_hangup(void) bool check_netplay_synched(netplay_t* netplay) { retro_assert(netplay); - return netplay->self_frame_count < (netplay->flip_frame + 2 * UDP_FRAME_PACKETS); + /*return netplay->self_frame_count < (netplay->flip_frame + 2 * UDP_FRAME_PACKETS);*/ + /* FIXME */ + return true; } static bool netplay_info_cb(netplay_t* netplay, unsigned frames) { @@ -96,6 +98,7 @@ static bool netplay_can_poll(netplay_t *netplay) return netplay->can_poll; } +#if 0 static bool send_chunk(netplay_t *netplay) { const struct sockaddr *addr = NULL; @@ -128,6 +131,7 @@ static bool send_chunk(netplay_t *netplay) } return true; } +#endif /** * get_self_input_state: @@ -139,10 +143,11 @@ static bool send_chunk(netplay_t *netplay) **/ static bool get_self_input_state(netplay_t *netplay) { - uint32_t state[UDP_WORDS_PER_FRAME - 1] = {0}; + uint32_t state[WORDS_PER_FRAME - 1] = {0}; struct delta_frame *ptr = &netplay->buffer[netplay->self_ptr]; - if (!netplay_delta_frame_ready(netplay, ptr, netplay->self_frame_count)) return false; + if (!netplay_delta_frame_ready(netplay, ptr, netplay->self_frame_count)) + return false; if (!input_driver_is_libretro_input_blocked() && netplay->self_frame_count > 0) { @@ -181,18 +186,19 @@ static bool get_self_input_state(netplay_t *netplay) * } * * payload { - * ; To compat packet losses, send input in a sliding window - * frame redundancy_frames[UDP_FRAME_PACKETS]; + * cmd (CMD_INPUT) + * cmd_size (4 words) + * frame * } */ - memmove(netplay->packet_buffer, netplay->packet_buffer + UDP_WORDS_PER_FRAME, - sizeof (netplay->packet_buffer) - UDP_WORDS_PER_FRAME * sizeof(uint32_t)); - netplay->packet_buffer[(UDP_FRAME_PACKETS - 1) * UDP_WORDS_PER_FRAME] = htonl(netplay->self_frame_count); - netplay->packet_buffer[(UDP_FRAME_PACKETS - 1) * UDP_WORDS_PER_FRAME + 1] = htonl(state[0]); - netplay->packet_buffer[(UDP_FRAME_PACKETS - 1) * UDP_WORDS_PER_FRAME + 2] = htonl(state[1]); - netplay->packet_buffer[(UDP_FRAME_PACKETS - 1) * UDP_WORDS_PER_FRAME + 3] = htonl(state[2]); + netplay->packet_buffer[0] = htonl(NETPLAY_CMD_INPUT); + netplay->packet_buffer[1] = htonl(WORDS_PER_FRAME * sizeof(uint32_t)); + netplay->packet_buffer[2] = htonl(netplay->self_frame_count); + netplay->packet_buffer[3] = htonl(state[0]); + netplay->packet_buffer[4] = htonl(state[1]); + netplay->packet_buffer[5] = htonl(state[2]); - if (!send_chunk(netplay)) + if (!socket_send_all_blocking(netplay->fd, netplay->packet_buffer, sizeof(netplay->packet_buffer), false)) { warn_hangup(); netplay->has_connection = false; @@ -204,16 +210,32 @@ static bool get_self_input_state(netplay_t *netplay) return true; } +static bool netplay_send_raw_cmd(netplay_t *netplay, uint32_t cmd, + const void *data, size_t size) +{ + uint32_t cmdbuf[2]; + + cmdbuf[0] = htonl(cmd); + cmdbuf[1] = htonl(size); + + if (!socket_send_all_blocking(netplay->fd, cmdbuf, sizeof(cmdbuf), false)) + return false; + + if (size > 0) + if (!socket_send_all_blocking(netplay->fd, data, size, false)) + return false; + + return true; +} + static bool netplay_cmd_ack(netplay_t *netplay) { - uint32_t cmd = htonl(NETPLAY_CMD_ACK); - return socket_send_all_blocking(netplay->fd, &cmd, sizeof(cmd), false); + return netplay_send_raw_cmd(netplay, NETPLAY_CMD_ACK, NULL, 0); } static bool netplay_cmd_nak(netplay_t *netplay) { - uint32_t cmd = htonl(NETPLAY_CMD_NAK); - return socket_send_all_blocking(netplay->fd, &cmd, sizeof(cmd), false); + return netplay_send_raw_cmd(netplay, NETPLAY_CMD_NAK, NULL, 0); } static bool netplay_get_response(netplay_t *netplay) @@ -231,6 +253,10 @@ static bool netplay_get_cmd(netplay_t *netplay) uint32_t flip_frame; uint32_t cmd_size; + /* If we're not ready for input, wait until we are. Could fill the TCP buffer, stalling the other side. */ + if (!netplay_delta_frame_ready(netplay, &netplay->buffer[netplay->read_ptr], netplay->read_frame_count)) + return false; + if (!socket_receive_all_blocking(netplay->fd, &cmd, sizeof(cmd))) return false; @@ -243,6 +269,53 @@ static bool netplay_get_cmd(netplay_t *netplay) switch (cmd) { + case NETPLAY_CMD_ACK: + case NETPLAY_CMD_NAK: + /* Why are we even bothering? */ + return true; + + case NETPLAY_CMD_INPUT: + { + uint32_t buffer[WORDS_PER_FRAME]; + unsigned i; + + if (cmd_size != WORDS_PER_FRAME * sizeof(uint32_t)) + { + RARCH_ERR("NETPLAY_CMD_INPUT received an unexpected payload size.\n"); + return netplay_cmd_nak(netplay); + } + + if (!socket_receive_all_blocking(netplay->fd, buffer, sizeof(buffer))) + { + RARCH_ERR("Failed to receive NETPLAY_CMD_INPUT input.\n"); + return netplay_cmd_nak(netplay); + } + + for (i = 0; i < WORDS_PER_FRAME; i++) + buffer[i] = ntohl(buffer[i]); + + if (buffer[0] != netplay->read_frame_count) + { + /* FIXME: JUST drop it? */ + return netplay_cmd_nak(netplay); + } + + if (!netplay_delta_frame_ready(netplay, &netplay->buffer[netplay->read_ptr], netplay->read_frame_count)) + { + /* FIXME: If we're here, we're desyncing. */ + netplay->must_fast_forward = true; + return netplay_cmd_nak(netplay); + } + + /* The data's good! */ + netplay->buffer[netplay->read_ptr].is_simulated = false; + memcpy(netplay->buffer[netplay->read_ptr].real_input_state, buffer + 1, sizeof(buffer) - sizeof(uint32_t)); + netplay->read_ptr = NEXT_PTR(netplay->read_ptr); + netplay->read_frame_count++; + netplay->timeout_cnt = 0; + return netplay_cmd_ack(netplay); + } + case NETPLAY_CMD_FLIP_PLAYERS: if (cmd_size != sizeof(uint32_t)) { @@ -305,6 +378,7 @@ static bool netplay_get_cmd(netplay_t *netplay) static int poll_input(netplay_t *netplay, bool block) { + bool had_input = false; int max_fd = (netplay->fd > netplay->udp_fd ? netplay->fd : netplay->udp_fd) + 1; struct timeval tv = {0}; @@ -318,6 +392,7 @@ static int poll_input(netplay_t *netplay, bool block) * Technically possible for select() to modify tmp_tv, so * we go paranoia mode. */ struct timeval tmp_tv = tv; + had_input = false; netplay->timeout_cnt++; @@ -330,31 +405,40 @@ static int poll_input(netplay_t *netplay, bool block) /* Somewhat hacky, * but we aren't using the TCP connection for anything useful atm. */ - if (FD_ISSET(netplay->fd, &fds) && !netplay_get_cmd(netplay)) - return -1; + if (FD_ISSET(netplay->fd, &fds)) + { + had_input = true; + if (!netplay_get_cmd(netplay)) + return -1; + } +#if 0 if (FD_ISSET(netplay->udp_fd, &fds)) return 1; +#endif if (!block) continue; +#if 0 if (!send_chunk(netplay)) { warn_hangup(); netplay->has_connection = false; return -1; } +#endif RARCH_LOG("Network is stalling, resending packet... Count %u of %d ...\n", netplay->timeout_cnt, MAX_RETRIES); - } while ((netplay->timeout_cnt < MAX_RETRIES) && block); + } while (had_input || (block && netplay->read_frame_count < netplay->self_frame_count)); - if (block) - return -1; + /*if (block) + return -1;*/ return 0; } +#if 0 static bool receive_data(netplay_t *netplay, uint32_t *buffer, size_t size) { socklen_t addrlen = sizeof(netplay->their_addr); @@ -400,6 +484,7 @@ static void parse_packet(netplay_t *netplay, uint32_t *buffer, unsigned size) netplay->timeout_cnt = 0; } } +#endif /* TODO: Somewhat better prediction. :P */ static void simulate_input(netplay_t *netplay) @@ -454,7 +539,7 @@ static bool netplay_poll(netplay_t *netplay) /* We might have reached the end of the buffer, where we * simply have to block. */ - res = poll_input(netplay, netplay->other_ptr == netplay->self_ptr); + res = poll_input(netplay, netplay->read_frame_count < netplay->self_frame_count - 10); /* FIXME: configure stalling intervals */ if (res == -1) { netplay->has_connection = false; @@ -462,6 +547,7 @@ static bool netplay_poll(netplay_t *netplay) return false; } +#if 0 if (res == 1) { uint32_t first_read = netplay->read_frame_count; @@ -489,8 +575,9 @@ static bool netplay_poll(netplay_t *netplay) return false; } } +#endif - if (netplay->read_frame_count <= netplay->self_frame_count) + if (netplay->read_frame_count < netplay->self_frame_count) simulate_input(netplay); else netplay->buffer[PREV_PTR(netplay->self_ptr)].used_real = true; @@ -839,8 +926,8 @@ netplay_t *netplay_new(const char *server, uint16_t port, { netplay_t *netplay = NULL; - if (frames > UDP_FRAME_PACKETS) - frames = UDP_FRAME_PACKETS; + /*if (frames > UDP_FRAME_PACKETS) + frames = UDP_FRAME_PACKETS;*/ netplay = (netplay_t*)calloc(1, sizeof(*netplay)); if (!netplay) @@ -880,26 +967,6 @@ error: return NULL; } -static bool netplay_send_raw_cmd(netplay_t *netplay, uint32_t cmd, - const void *data, size_t size) -{ - uint32_t cmd_size; - - cmd = htonl(cmd); - cmd_size = htonl(size); - - if (!socket_send_all_blocking(netplay->fd, &cmd, sizeof(cmd), false)) - return false; - - if (!socket_send_all_blocking(netplay->fd, &cmd_size, sizeof(cmd_size), false)) - return false; - - if (!socket_send_all_blocking(netplay->fd, data, size, false)) - return false; - - return true; -} - /** * netplay_command: * @netplay : pointer to netplay object @@ -970,7 +1037,7 @@ error: **/ static void netplay_flip_users(netplay_t *netplay) { - uint32_t flip_frame = netplay->self_frame_count + 2 * UDP_FRAME_PACKETS; + uint32_t flip_frame = netplay->self_frame_count + 32; /* FIXME: This value is now arbitrary */ uint32_t flip_frame_net = htonl(flip_frame); bool command = netplay_command( netplay, NETPLAY_CMD_FLIP_PLAYERS, diff --git a/network/netplay/netplay.h b/network/netplay/netplay.h index b0888a2ba0..3aac5bf1c0 100644 --- a/network/netplay/netplay.h +++ b/network/netplay/netplay.h @@ -40,7 +40,7 @@ enum rarch_netplay_ctl_state enum netplay_cmd { - /* Miscellaneous commands */ + /* Basic commands */ /* Acknowlegement response */ NETPLAY_CMD_ACK = 0x0000, @@ -48,23 +48,28 @@ enum netplay_cmd /* Failed acknowlegement response */ NETPLAY_CMD_NAK = 0x0001, + /* Input data */ + NETPLAY_CMD_INPUT = 0x0002, + + /* Misc. commands */ + /* Swap inputs between player 1 and player 2 */ - NETPLAY_CMD_FLIP_PLAYERS = 0x0002, + NETPLAY_CMD_FLIP_PLAYERS = 0x0003, /* Toggle spectate/join mode */ - NETPLAY_CMD_SPECTATE = 0x0003, + NETPLAY_CMD_SPECTATE = 0x0004, /* Gracefully disconnects from host */ - NETPLAY_CMD_DISCONNECT = 0x0004, + NETPLAY_CMD_DISCONNECT = 0x0005, /* Sends multiple config requests over, * See enum netplay_cmd_cfg */ - NETPLAY_CMD_CFG = 0x0005, + NETPLAY_CMD_CFG = 0x0006, /* CMD_CFG streamlines sending multiple configurations. This acknowledges each one individually */ - NETPLAY_CMD_CFG_ACK = 0x0006, + NETPLAY_CMD_CFG_ACK = 0x0007, /* Loading and synchronization */ diff --git a/network/netplay/netplay_common.c b/network/netplay/netplay_common.c index ffdbddaa80..cbcceedf24 100644 --- a/network/netplay/netplay_common.c +++ b/network/netplay/netplay_common.c @@ -347,13 +347,16 @@ bool netplay_is_spectate(netplay_t* netplay) bool netplay_delta_frame_ready(netplay_t *netplay, struct delta_frame *delta, uint32_t frame) { + void *remember_state; if (delta->frame == frame) return true; if (netplay->other_frame_count <= delta->frame) { /* We haven't even replayed this frame yet, so we can't overwrite it! */ return false; } + remember_state = delta->state; memset(delta, 0, sizeof(struct delta_frame)); delta->frame = frame; + delta->state = remember_state; return true; } diff --git a/network/netplay/netplay_net.c b/network/netplay/netplay_net.c index c6ee585ce8..35bfae9866 100644 --- a/network/netplay/netplay_net.c +++ b/network/netplay/netplay_net.c @@ -32,6 +32,7 @@ static void netplay_net_pre_frame(netplay_t *netplay) if (netplay_delta_frame_ready(netplay, &netplay->buffer[netplay->self_ptr], netplay->self_frame_count)) { + serial_info.data_const = NULL; serial_info.data = netplay->buffer[netplay->self_ptr].state; serial_info.size = netplay->state_size; @@ -79,13 +80,17 @@ static void netplay_net_post_frame(netplay_t *netplay) /* Replay frames. */ netplay->is_replay = true; - netplay->replay_ptr = netplay->other_ptr; - netplay->replay_frame_count = netplay->other_frame_count; + netplay->replay_ptr = PREV_PTR(netplay->other_ptr); + netplay->replay_frame_count = netplay->other_frame_count - 1; - serial_info.data_const = netplay->buffer[netplay->other_ptr].state; - serial_info.size = netplay->state_size; - - core_unserialize(&serial_info); + if (netplay->replay_frame_count < netplay->self_frame_count) + { + serial_info.data = NULL; + serial_info.data_const = netplay->buffer[netplay->replay_ptr].state; + serial_info.size = netplay->state_size; + + core_unserialize(&serial_info); + } while (netplay->replay_frame_count < netplay->self_frame_count) { @@ -106,11 +111,21 @@ static void netplay_net_post_frame(netplay_t *netplay) netplay->replay_frame_count++; } + /* For the remainder of the frames up to the read count, we can use the real data */ + while (netplay->replay_frame_count < netplay->read_frame_count) + { + netplay->buffer[netplay->replay_ptr].is_simulated = false; + netplay->buffer[netplay->replay_ptr].used_real = true; + netplay->replay_ptr = NEXT_PTR(netplay->replay_ptr); + netplay->replay_frame_count++; + } + netplay->other_ptr = netplay->read_ptr; netplay->other_frame_count = netplay->read_frame_count; netplay->is_replay = false; } +#if 0 /* And if the other side has gotten too far ahead of /us/, skip to catch up * FIXME: Make this configurable */ if (netplay->read_frame_count > netplay->self_frame_count + 10 || @@ -149,6 +164,7 @@ static void netplay_net_post_frame(netplay_t *netplay) netplay->other_frame_count = netplay->read_frame_count; netplay->is_replay = false; } +#endif } static bool netplay_net_init_buffers(netplay_t *netplay) diff --git a/network/netplay/netplay_private.h b/network/netplay/netplay_private.h index 13a7dbc904..2479376c0e 100644 --- a/network/netplay/netplay_private.h +++ b/network/netplay/netplay_private.h @@ -30,10 +30,9 @@ #define HAVE_IPV6 #endif -#define UDP_FRAME_PACKETS 16 -#define UDP_WORDS_PER_FRAME 4 /* Allows us to send 128 bits worth of state per frame. */ -#define MAX_SPECTATORS 16 -#define RARCH_DEFAULT_PORT 55435 +#define WORDS_PER_FRAME 4 /* Allows us to send 128 bits worth of state per frame. */ +#define MAX_SPECTATORS 16 +#define RARCH_DEFAULT_PORT 55435 #define NETPLAY_PROTOCOL_VERSION 1 @@ -46,9 +45,9 @@ struct delta_frame void *state; - uint32_t real_input_state[UDP_WORDS_PER_FRAME - 1]; - uint32_t simulated_input_state[UDP_WORDS_PER_FRAME - 1]; - uint32_t self_state[UDP_WORDS_PER_FRAME - 1]; + uint32_t real_input_state[WORDS_PER_FRAME - 1]; + uint32_t simulated_input_state[WORDS_PER_FRAME - 1]; + uint32_t self_state[WORDS_PER_FRAME - 1]; bool have_local; bool is_simulated; @@ -98,9 +97,8 @@ struct netplay /* If we end up having to drop remote frame data because it's ahead of us, fast-forward is URGENT */ bool must_fast_forward; - /* To compat UDP packet loss we also send - * old data along with the packets. */ - uint32_t packet_buffer[UDP_FRAME_PACKETS * UDP_WORDS_PER_FRAME]; + /* A buffer for outgoing input packets. */ + uint32_t packet_buffer[2 + WORDS_PER_FRAME]; uint32_t self_frame_count; uint32_t read_frame_count; uint32_t other_frame_count; From 4f16a19f5e7c380c896718fbdcfb92b3c2fdb004 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Mon, 12 Sep 2016 09:13:26 -0400 Subject: [PATCH 037/334] Rather than stalling by blocking and becoming unresponsive, stall by replaying the same frame. TODO: Maybe mute the audio? --- network/netplay/netplay.c | 39 ++++++++++++++++++++----------- network/netplay/netplay_net.c | 14 +++++++++++ network/netplay/netplay_private.h | 14 +++++++++++ 3 files changed, 54 insertions(+), 13 deletions(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index 3425c8c712..bbf680b467 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -149,6 +149,13 @@ static bool get_self_input_state(netplay_t *netplay) if (!netplay_delta_frame_ready(netplay, ptr, netplay->self_frame_count)) return false; + if (ptr->have_local) + { + /* We've already read this frame! */ + netplay->self_ptr = NEXT_PTR(netplay->self_ptr); + return true; + } + if (!input_driver_is_libretro_input_blocked() && netplay->self_frame_count > 0) { unsigned i; @@ -206,6 +213,7 @@ static bool get_self_input_state(netplay_t *netplay) } memcpy(ptr->self_state, state, sizeof(state)); + ptr->have_local = true; netplay->self_ptr = NEXT_PTR(netplay->self_ptr); return true; } @@ -296,14 +304,8 @@ static bool netplay_get_cmd(netplay_t *netplay) if (buffer[0] != netplay->read_frame_count) { - /* FIXME: JUST drop it? */ - return netplay_cmd_nak(netplay); - } - - if (!netplay_delta_frame_ready(netplay, &netplay->buffer[netplay->read_ptr], netplay->read_frame_count)) - { - /* FIXME: If we're here, we're desyncing. */ - netplay->must_fast_forward = true; + /* FIXME: Except on the first (null) frame, this should be + * impossible, so maybe just disconnect? */ return netplay_cmd_nak(netplay); } @@ -313,7 +315,7 @@ static bool netplay_get_cmd(netplay_t *netplay) netplay->read_ptr = NEXT_PTR(netplay->read_ptr); netplay->read_frame_count++; netplay->timeout_cnt = 0; - return netplay_cmd_ack(netplay); + return true; } case NETPLAY_CMD_FLIP_PLAYERS: @@ -431,7 +433,7 @@ static int poll_input(netplay_t *netplay, bool block) RARCH_LOG("Network is stalling, resending packet... Count %u of %d ...\n", netplay->timeout_cnt, MAX_RETRIES); - } while (had_input || (block && netplay->read_frame_count < netplay->self_frame_count)); + } while (had_input); /*if (block) return -1;*/ @@ -537,9 +539,8 @@ static bool netplay_poll(netplay_t *netplay) return true; } - /* We might have reached the end of the buffer, where we - * simply have to block. */ - res = poll_input(netplay, netplay->read_frame_count < netplay->self_frame_count - 10); /* FIXME: configure stalling intervals */ + /* Read Netplay input */ + res = poll_input(netplay, 0); /* FIXME: configure stalling intervals */ if (res == -1) { netplay->has_connection = false; @@ -582,6 +583,18 @@ static bool netplay_poll(netplay_t *netplay) else netplay->buffer[PREV_PTR(netplay->self_ptr)].used_real = true; + /* Consider stalling */ + switch (netplay->stall) { + case RARCH_NETPLAY_STALL_RUNNING_FAST: + if (netplay->read_frame_count >= netplay->self_frame_count) + netplay->stall = RARCH_NETPLAY_STALL_NONE; + break; + + default: /* not stalling */ + if (netplay->read_frame_count < netplay->self_frame_count - 10) + netplay->stall = RARCH_NETPLAY_STALL_RUNNING_FAST; + } + return true; } diff --git a/network/netplay/netplay_net.c b/network/netplay/netplay_net.c index 35bfae9866..b234aa98a3 100644 --- a/network/netplay/netplay_net.c +++ b/network/netplay/netplay_net.c @@ -166,6 +166,20 @@ static void netplay_net_post_frame(netplay_t *netplay) } #endif + /* If we're supposed to stall, rewind */ + if (netplay->stall) + { + retro_ctx_serialize_info_t serial_info; + + netplay->self_ptr = PREV_PTR(netplay->self_ptr); + netplay->self_frame_count--; + + serial_info.data = NULL; + serial_info.data_const = netplay->buffer[netplay->self_ptr].state; + serial_info.size = netplay->state_size; + + core_unserialize(&serial_info); + } } static bool netplay_net_init_buffers(netplay_t *netplay) { diff --git a/network/netplay/netplay_private.h b/network/netplay/netplay_private.h index 2479376c0e..381c934aaf 100644 --- a/network/netplay/netplay_private.h +++ b/network/netplay/netplay_private.h @@ -49,8 +49,13 @@ struct delta_frame uint32_t simulated_input_state[WORDS_PER_FRAME - 1]; uint32_t self_state[WORDS_PER_FRAME - 1]; + /* Have we read local input? */ bool have_local; + + /* Badly named: This is !have_real(_remote) */ bool is_simulated; + + /* Is the current state as of self_frame_count using the real data? */ bool used_real; }; @@ -60,6 +65,12 @@ struct netplay_callbacks { bool (*info_cb) (netplay_t *netplay, unsigned frames); }; +enum rarch_netplay_stall_reasons +{ + RARCH_NETPLAY_STALL_NONE = 0, + RARCH_NETPLAY_STALL_RUNNING_FAST +}; + struct netplay { char nick[32]; @@ -131,6 +142,9 @@ struct netplay bool pause; uint32_t pause_frame; + /* And stalling */ + int stall; + struct netplay_callbacks* net_cbs; }; From 07e869ccae82fcf7b4fb0b2ffff4bd0755a8cc9b Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Mon, 12 Sep 2016 09:18:27 -0400 Subject: [PATCH 038/334] is_simulated was confusing and poorly named. Using have_remote in its place, which is simply true if we've received remote data. Could also just use read_frame_crount instead, but this keeps the info frame-local. --- network/netplay/netplay.c | 12 ++++++------ network/netplay/netplay_net.c | 3 --- network/netplay/netplay_private.h | 6 +++--- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index bbf680b467..e797b02451 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -310,7 +310,7 @@ static bool netplay_get_cmd(netplay_t *netplay) } /* The data's good! */ - netplay->buffer[netplay->read_ptr].is_simulated = false; + netplay->buffer[netplay->read_ptr].have_remote = true; memcpy(netplay->buffer[netplay->read_ptr].real_input_state, buffer + 1, sizeof(buffer) - sizeof(uint32_t)); netplay->read_ptr = NEXT_PTR(netplay->read_ptr); netplay->read_frame_count++; @@ -498,7 +498,7 @@ static void simulate_input(netplay_t *netplay) netplay->buffer[prev].real_input_state, sizeof(netplay->buffer[prev].real_input_state)); - netplay->buffer[ptr].is_simulated = true; + netplay->buffer[ptr].have_remote = false; netplay->buffer[ptr].used_real = false; } @@ -529,7 +529,7 @@ static bool netplay_poll(netplay_t *netplay) if (netplay->self_frame_count == 0) { netplay->buffer[0].used_real = true; - netplay->buffer[0].is_simulated = false; + netplay->buffer[0].have_remote = true; memset(netplay->buffer[0].real_input_state, 0, sizeof(netplay->buffer[0].real_input_state)); @@ -667,10 +667,10 @@ static int16_t netplay_input_state(netplay_t *netplay, if (netplay->port == (netplay_flip_port(netplay, port) ? 1 : 0)) { - if (netplay->buffer[ptr].is_simulated) - curr_input_state = netplay->buffer[ptr].simulated_input_state; - else + if (netplay->buffer[ptr].have_remote) curr_input_state = netplay->buffer[ptr].real_input_state; + else + curr_input_state = netplay->buffer[ptr].simulated_input_state; } switch (device) diff --git a/network/netplay/netplay_net.c b/network/netplay/netplay_net.c index b234aa98a3..f02b79ce20 100644 --- a/network/netplay/netplay_net.c +++ b/network/netplay/netplay_net.c @@ -114,7 +114,6 @@ static void netplay_net_post_frame(netplay_t *netplay) /* For the remainder of the frames up to the read count, we can use the real data */ while (netplay->replay_frame_count < netplay->read_frame_count) { - netplay->buffer[netplay->replay_ptr].is_simulated = false; netplay->buffer[netplay->replay_ptr].used_real = true; netplay->replay_ptr = NEXT_PTR(netplay->replay_ptr); netplay->replay_frame_count++; @@ -205,8 +204,6 @@ static bool netplay_net_init_buffers(netplay_t *netplay) if (!netplay->buffer[i].state) return false; - - netplay->buffer[i].is_simulated = true; } return true; diff --git a/network/netplay/netplay_private.h b/network/netplay/netplay_private.h index 381c934aaf..66543e4265 100644 --- a/network/netplay/netplay_private.h +++ b/network/netplay/netplay_private.h @@ -52,10 +52,10 @@ struct delta_frame /* Have we read local input? */ bool have_local; - /* Badly named: This is !have_real(_remote) */ - bool is_simulated; + /* Have we read the real remote input? */ + bool have_remote; - /* Is the current state as of self_frame_count using the real data? */ + /* Is the current state as of self_frame_count using the real remote data? */ bool used_real; }; From c7d0bf90f6512c2750b2fa918bf00fff2d09029a Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Mon, 12 Sep 2016 17:50:38 -0400 Subject: [PATCH 039/334] Bugfixes to bring Netplay Nouveau from "kinda working" to "stably working": (1) Fixups to the stall logic to make sure it always receives frames while stalling :) (2) Disused the used_real field. It was misconfigured and would frequently claim to be using real data when real data hadn't been used... this means more replays for now, but used_real will be readded. (TODO) (3) Stall duration is now related to sync frames, and thus configurable. (4) Delta frames were having the good ol' initialization problem, as frame==0 was indistinguishable from unused. Quickfixed by adding a "used" field, but maybe there's a better way. (5) If serialization fails, switch immediately to blocking mode (stall_frames = 0). Blocking mode barely works, but if serialization fails, no mode will work! (6) I'm not sure which bug my replaying-from-previous-frame was trying to fix, but the correct behavior is to replay from the last frame we had vital information, not the frame prior. Notionally this should just be an efficiency thing, but unsigned arithmetic at 0 made this a "just ignore all input from now on" thing. --- network/netplay/netplay.c | 49 +++++++++++++++++++------------ network/netplay/netplay_common.c | 12 +++++--- network/netplay/netplay_net.c | 21 +++++++++---- network/netplay/netplay_private.h | 2 ++ 4 files changed, 56 insertions(+), 28 deletions(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index e797b02451..f7066ddf4a 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -143,7 +143,7 @@ static bool send_chunk(netplay_t *netplay) **/ static bool get_self_input_state(netplay_t *netplay) { - uint32_t state[WORDS_PER_FRAME - 1] = {0}; + uint32_t state[WORDS_PER_FRAME - 1] = {0, 0, 0}; struct delta_frame *ptr = &netplay->buffer[netplay->self_ptr]; if (!netplay_delta_frame_ready(netplay, ptr, netplay->self_frame_count)) @@ -261,9 +261,9 @@ static bool netplay_get_cmd(netplay_t *netplay) uint32_t flip_frame; uint32_t cmd_size; - /* If we're not ready for input, wait until we are. Could fill the TCP buffer, stalling the other side. */ - if (!netplay_delta_frame_ready(netplay, &netplay->buffer[netplay->read_ptr], netplay->read_frame_count)) - return false; + /* FIXME: This depends on delta_frame_ready */ + + netplay->timeout_cnt = 0; if (!socket_receive_all_blocking(netplay->fd, &cmd, sizeof(cmd))) return false; @@ -314,7 +314,6 @@ static bool netplay_get_cmd(netplay_t *netplay) memcpy(netplay->buffer[netplay->read_ptr].real_input_state, buffer + 1, sizeof(buffer) - sizeof(uint32_t)); netplay->read_ptr = NEXT_PTR(netplay->read_ptr); netplay->read_frame_count++; - netplay->timeout_cnt = 0; return true; } @@ -409,9 +408,13 @@ static int poll_input(netplay_t *netplay, bool block) * but we aren't using the TCP connection for anything useful atm. */ if (FD_ISSET(netplay->fd, &fds)) { - had_input = true; - if (!netplay_get_cmd(netplay)) - return -1; + /* If we're not ready for input, wait until we are. Could fill the TCP buffer, stalling the other side. */ + if (netplay_delta_frame_ready(netplay, &netplay->buffer[netplay->read_ptr], netplay->read_frame_count)) + { + had_input = true; + if (!netplay_get_cmd(netplay)) + return -1; + } } #if 0 @@ -431,9 +434,9 @@ static int poll_input(netplay_t *netplay, bool block) } #endif - RARCH_LOG("Network is stalling, resending packet... Count %u of %d ...\n", - netplay->timeout_cnt, MAX_RETRIES); - } while (had_input); + RARCH_LOG("Network is stalling at frame %u, count %u of %d ...\n", + netplay->self_frame_count, netplay->timeout_cnt, MAX_RETRIES); + } while (had_input || (block && (netplay->read_frame_count <= netplay->self_frame_count))); /*if (block) return -1;*/ @@ -521,9 +524,13 @@ static bool netplay_poll(netplay_t *netplay) netplay->can_poll = false; +#if 0 if (!get_self_input_state(netplay)) return false; +#endif + get_self_input_state(netplay); +#if 0 /* We skip reading the first frame so the host has a chance to grab * our host info so we don't block forever :') */ if (netplay->self_frame_count == 0) @@ -538,9 +545,11 @@ static bool netplay_poll(netplay_t *netplay) netplay->read_frame_count++; return true; } +#endif - /* Read Netplay input */ - res = poll_input(netplay, 0); /* FIXME: configure stalling intervals */ + /* Read Netplay input, block if we're configured to stall for input every + * frame */ + res = poll_input(netplay, netplay->stall_frames == 0); if (res == -1) { netplay->has_connection = false; @@ -580,8 +589,8 @@ static bool netplay_poll(netplay_t *netplay) if (netplay->read_frame_count < netplay->self_frame_count) simulate_input(netplay); - else - netplay->buffer[PREV_PTR(netplay->self_ptr)].used_real = true; + /*else + netplay->buffer[PREV_PTR(netplay->self_ptr)].used_real = true;*/ /* Consider stalling */ switch (netplay->stall) { @@ -591,7 +600,7 @@ static bool netplay_poll(netplay_t *netplay) break; default: /* not stalling */ - if (netplay->read_frame_count < netplay->self_frame_count - 10) + if (netplay->read_frame_count + netplay->stall_frames <= netplay->self_frame_count) netplay->stall = RARCH_NETPLAY_STALL_RUNNING_FAST; } @@ -774,6 +783,9 @@ static int init_tcp_connection(const struct addrinfo *res, { bool ret = true; int fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); + int flag = 1; + + setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(int)); if (fd < 0) { @@ -937,11 +949,9 @@ netplay_t *netplay_new(const char *server, uint16_t port, bool spectate, const char *nick) { + uint32_t buffer_frames; netplay_t *netplay = NULL; - /*if (frames > UDP_FRAME_PACKETS) - frames = UDP_FRAME_PACKETS;*/ - netplay = (netplay_t*)calloc(1, sizeof(*netplay)); if (!netplay) return NULL; @@ -953,6 +963,7 @@ netplay_t *netplay_new(const char *server, uint16_t port, netplay->spectate.enabled = spectate; netplay->is_server = server == NULL; strlcpy(netplay->nick, nick, sizeof(netplay->nick)); + netplay->stall_frames = frames; if(spectate) netplay->net_cbs = netplay_get_cbs_spectate(); diff --git a/network/netplay/netplay_common.c b/network/netplay/netplay_common.c index cbcceedf24..2468c0102c 100644 --- a/network/netplay/netplay_common.c +++ b/network/netplay/netplay_common.c @@ -348,14 +348,18 @@ bool netplay_is_spectate(netplay_t* netplay) bool netplay_delta_frame_ready(netplay_t *netplay, struct delta_frame *delta, uint32_t frame) { void *remember_state; - if (delta->frame == frame) return true; - if (netplay->other_frame_count <= delta->frame) + if (delta->used) { - /* We haven't even replayed this frame yet, so we can't overwrite it! */ - return false; + if (delta->frame == frame) return true; + if (netplay->other_frame_count <= delta->frame) + { + /* We haven't even replayed this frame yet, so we can't overwrite it! */ + return false; + } } remember_state = delta->state; memset(delta, 0, sizeof(struct delta_frame)); + delta->used = true; delta->frame = frame; delta->state = remember_state; return true; diff --git a/network/netplay/netplay_net.c b/network/netplay/netplay_net.c index f02b79ce20..33ef8d521f 100644 --- a/network/netplay/netplay_net.c +++ b/network/netplay/netplay_net.c @@ -36,7 +36,12 @@ static void netplay_net_pre_frame(netplay_t *netplay) serial_info.data = netplay->buffer[netplay->self_ptr].state; serial_info.size = netplay->state_size; - core_serialize(&serial_info); + if (!core_serialize(&serial_info)) + { + /* If the core can't serialize properly, we must stall for the + * remote input on EVERY frame, because we can't recover */ + netplay->stall_frames = 0; + } } netplay->can_poll = true; @@ -55,9 +60,11 @@ static void netplay_net_post_frame(netplay_t *netplay) { netplay->self_frame_count++; +#if 0 /* Nothing to do... */ if (netplay->other_frame_count == netplay->read_frame_count) return; +#endif /* Skip ahead if we predicted correctly. * Skip until our simulation failed. */ @@ -80,8 +87,8 @@ static void netplay_net_post_frame(netplay_t *netplay) /* Replay frames. */ netplay->is_replay = true; - netplay->replay_ptr = PREV_PTR(netplay->other_ptr); - netplay->replay_frame_count = netplay->other_frame_count - 1; + netplay->replay_ptr = netplay->other_ptr; + netplay->replay_frame_count = netplay->other_frame_count; if (netplay->replay_frame_count < netplay->self_frame_count) { @@ -114,7 +121,7 @@ static void netplay_net_post_frame(netplay_t *netplay) /* For the remainder of the frames up to the read count, we can use the real data */ while (netplay->replay_frame_count < netplay->read_frame_count) { - netplay->buffer[netplay->replay_ptr].used_real = true; + /*netplay->buffer[netplay->replay_ptr].used_real = true;*/ netplay->replay_ptr = NEXT_PTR(netplay->replay_ptr); netplay->replay_frame_count++; } @@ -222,7 +229,11 @@ static bool netplay_net_info_cb(netplay_t* netplay, unsigned frames) return false; } - netplay->buffer_size = frames + 1; + /* * 2 + 1 because: + * Self sits in the middle, + * Other is allowed to drift as much as 'frames' frames behind + * Read is allowed to drift as much as 'frames' frames ahead */ + netplay->buffer_size = frames * 2 + 1; if (!netplay_net_init_buffers(netplay)) return false; diff --git a/network/netplay/netplay_private.h b/network/netplay/netplay_private.h index 66543e4265..9e6bd71749 100644 --- a/network/netplay/netplay_private.h +++ b/network/netplay/netplay_private.h @@ -41,6 +41,7 @@ struct delta_frame { + bool used; /* a bit derpy, but this is how we know if the delta's been used at all */ uint32_t frame; void *state; @@ -143,6 +144,7 @@ struct netplay uint32_t pause_frame; /* And stalling */ + uint32_t stall_frames; int stall; struct netplay_callbacks* net_cbs; From 147d739197ec96fb3c6d4b7e540915415c6c3c15 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Mon, 12 Sep 2016 21:18:00 -0400 Subject: [PATCH 040/334] Fixed stall_frames=0 mode to only block if frames are actually needed. Rather than counting on the complexicon of used_real calculations, set used_real when... real is used. (Problem: If the core doesn't read input at all, used_real won't be set; todo: test with handhelds.) Minor resilience fixes. --- network/netplay/netplay.c | 9 +++++---- network/netplay/netplay_net.c | 7 +++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index f7066ddf4a..fa2b4ec095 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -549,7 +549,7 @@ static bool netplay_poll(netplay_t *netplay) /* Read Netplay input, block if we're configured to stall for input every * frame */ - res = poll_input(netplay, netplay->stall_frames == 0); + res = poll_input(netplay, (netplay->stall_frames == 0) && (netplay->read_frame_count <= netplay->self_frame_count)); if (res == -1) { netplay->has_connection = false; @@ -587,10 +587,8 @@ static bool netplay_poll(netplay_t *netplay) } #endif - if (netplay->read_frame_count < netplay->self_frame_count) + if (netplay->read_frame_count <= netplay->self_frame_count) simulate_input(netplay); - /*else - netplay->buffer[PREV_PTR(netplay->self_ptr)].used_real = true;*/ /* Consider stalling */ switch (netplay->stall) { @@ -677,7 +675,10 @@ static int16_t netplay_input_state(netplay_t *netplay, if (netplay->port == (netplay_flip_port(netplay, port) ? 1 : 0)) { if (netplay->buffer[ptr].have_remote) + { + netplay->buffer[ptr].used_real = true; curr_input_state = netplay->buffer[ptr].real_input_state; + } else curr_input_state = netplay->buffer[ptr].simulated_input_state; } diff --git a/network/netplay/netplay_net.c b/network/netplay/netplay_net.c index 33ef8d521f..a5dc367eff 100644 --- a/network/netplay/netplay_net.c +++ b/network/netplay/netplay_net.c @@ -15,9 +15,12 @@ */ #include +#include #include "netplay_private.h" +#include "retro_assert.h" + #include "../../autosave.h" /** @@ -95,7 +98,7 @@ static void netplay_net_post_frame(netplay_t *netplay) serial_info.data = NULL; serial_info.data_const = netplay->buffer[netplay->replay_ptr].state; serial_info.size = netplay->state_size; - + core_unserialize(&serial_info); } @@ -121,7 +124,7 @@ static void netplay_net_post_frame(netplay_t *netplay) /* For the remainder of the frames up to the read count, we can use the real data */ while (netplay->replay_frame_count < netplay->read_frame_count) { - /*netplay->buffer[netplay->replay_ptr].used_real = true;*/ + retro_assert(netplay->buffer[netplay->replay_ptr].have_remote); netplay->replay_ptr = NEXT_PTR(netplay->replay_ptr); netplay->replay_frame_count++; } From c5fe0ec6be5723413cb5e26710f275c5654b17cc Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Tue, 13 Sep 2016 16:57:32 -0400 Subject: [PATCH 041/334] Updating the Netplay README to be true of the current implementation. --- network/netplay/README | 89 ++++++++++++++++++++++++++++-------------- 1 file changed, 59 insertions(+), 30 deletions(-) diff --git a/network/netplay/README b/network/netplay/README index 3779c0ce68..f0eca64749 100644 --- a/network/netplay/README +++ b/network/netplay/README @@ -1,4 +1,15 @@ -How Netplay works (as documented by somebody who didn't write it): +This is RetroArch's Netplay code. RetroArch Netplay allows a second player to +be connected via the Internet, rather than local at the same computer. Netplay +in RetroArch is guaranteed* to work with perfect synchronization given a few +minor constraints: + +(1) The core is deterministic, +(2) The only input devices the core interacts with are the joypad and analog sticks, and +(3) Both the core and the loaded content are identical on host and client. + +Furthermore, if the core supports serialization (save states), Netplay allows +for latency and clock drift, providing both host and client with a smooth +experience. Note that this documentation is all for (the poorly-named) “net” mode, which is the normal mode, and not “spectator” mode, which has its own whole host of @@ -10,43 +21,61 @@ So long as both sides agree on which frame is which, it should be impossible for them to become de-synced, since each input event always happens at the correct frame. -Within the state buffers, there are three locations: self, other and read. Self -is where the emulator believes itself to be, which inevitably will be ahead of -what it's read from the peer. Other is where it was most recently in perfect -sync: i.e., other has been read and actioned. Read is where it's read up to, -which can be slightly ahead of other since it can't always immediately act upon -new data. In general, other ≤ read ≤ self. If read > self, logically it should -try to catch up, but that logic currently doesn't seem to exist (?) +In terms of the implementation, Netplay is in effect a state buffer +(implemented as a ring of buffers) and some pre- and post-frame behaviors. -In terms of the implementation, Netplay is in effect an input buffer and some -pre- and post-frame behaviors. +Within the state buffers, there are three locations: self, other and read. Each +refers to a frame, and a state buffer corresponding to that frame. The state +buffer contains the savestate for the frame, and the input from both the local +and remote players. -Pre-frame, it serializes the core's state, polls for input from the other side, -and if input has not been received for the other side up to the current frame -(which it shouldn't be), “simulates” the other side's input up to the current -frame. The simulation is simply assuming that the input state hasn't changed. -Each frame's local serialized state and simulated or real input goes into the -frame buffers. Frame buffers that are simulated are marked as such. +Self is where the emulator believes itself to be, which may be ahead or behind +of what it's read from the peer. Generally speaking, self progresses at 1 frame +per frame, except when the network stalls, described later. + +Other is where it was most recently in perfect sync: i.e., other-1 is the last +frame from which both local and remote input have been actioned. As such, other +is always less than or equal to both self and read. Since the state buffer is a +ring, other is the first frame that it's unsafe to overwrite. + +Read is where it's read up to, which can be slightly ahead of other since it +can't always immediately act upon new data. + +In general, other ≤ read and other ≤ self. In all likelyhood, read ≤ self, but +it is both possible and supported for the remote host to get ahead of the local +host. + +Pre-frame, Netplay serializes the core's state, polls for local input, and +polls for input from the other side. If the input from the other side is too +far behind, it stalls to allow the other side to catch up. To assure that this +stalling does not block the UI thread, it is implemented by rewinding the +thread every frame until data is ready. + +If input has not been received for the other side up to the current frame (the +usual case), the remote input is simulated in a simplistic manner. Each +frame's local serialized state and simulated or real input goes into the frame +buffers. + +During the frame of execution, when the core requests input, it receives the +input from the thread buffer, both local and real or simulated remote. Post-frame, it checks whether it's read more than it's actioned, i.e. if read > -other. If so, it rewinds to other and runs the core in replay mode with the -real data up to read, then sets other = read. +other. If so, it rewinds to other (by loading the serialized state there) and +runs the core in replay mode with the real data up to read, then sets other = +read. When in Netplay mode, the callback for receiving input is replaced by input_state_net. It is the role of input_state_net to combine the true local input (whether live or replay) with the remote input (whether true or simulated). -In the previous implementation, there was seemingly nothing to prevent the self -frame from advancing past the other frame in the ring buffer, causing local -input from one time to be mixed with remote input from another. The new -implementation uses a not-at-all-better strategy of simply refusing local input -if it steps past remote input. - Some thoughts about "frame counts": The frame counters act like indexes into a -0-indexed array; i.e., they refer to the first unactioned frame. With -self_frame_count it's slightly more complicated, since there are two relevant -actions: Reading the data and emulating with the data. The frame count is only -incremented after the latter, but the nature of the emulation assures that the -current frame's input will always be read before it's actioned (or at least, we -should certainly hope so!) +0-indexed array; i.e., they refer to the first unactioned frame. So, when +read_frame_count is 23, we've read 23 frames, but the last frame we read is +frame 22. With self_frame_count it's slightly more complicated, since there are +two relevant actions: Reading the data and emulating with the data. The frame +count is only incremented after the latter, so there is a period of time during +which we've actually read self_frame_count+1 frames of local input. + + +* Guarantee not actually a guarantee. From f9f4e15d33c2f99f9700d553a6a7d24ff41abe1c Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Tue, 13 Sep 2016 17:01:31 -0400 Subject: [PATCH 042/334] Removing commented-out code (mostly old UDP stuff) --- network/netplay/netplay.c | 192 +----------------------------- network/netplay/netplay_net.c | 47 -------- network/netplay/netplay_private.h | 2 - 3 files changed, 1 insertion(+), 240 deletions(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index fa2b4ec095..646b06a724 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -98,41 +98,6 @@ static bool netplay_can_poll(netplay_t *netplay) return netplay->can_poll; } -#if 0 -static bool send_chunk(netplay_t *netplay) -{ - const struct sockaddr *addr = NULL; - - if (netplay->addr) - addr = netplay->addr->ai_addr; - else if (netplay->has_client_addr) - addr = (const struct sockaddr*)&netplay->their_addr; - - if (addr) - { - ssize_t bytes_sent; - -#ifdef HAVE_IPV6 - bytes_sent = (sendto(netplay->udp_fd, (const char*)netplay->packet_buffer, - sizeof(netplay->packet_buffer), 0, addr, - sizeof(struct sockaddr_in6))); -#else - bytes_sent = (sendto(netplay->udp_fd, (const char*)netplay->packet_buffer, - sizeof(netplay->packet_buffer), 0, addr, - sizeof(struct sockaddr_in))); -#endif - - if (bytes_sent != sizeof(netplay->packet_buffer)) - { - warn_hangup(); - netplay->has_connection = false; - return false; - } - } - return true; -} -#endif - /** * get_self_input_state: * @netplay : pointer to netplay object @@ -380,8 +345,7 @@ static bool netplay_get_cmd(netplay_t *netplay) static int poll_input(netplay_t *netplay, bool block) { bool had_input = false; - int max_fd = (netplay->fd > netplay->udp_fd ? - netplay->fd : netplay->udp_fd) + 1; + int max_fd = netplay->fd + 1; struct timeval tv = {0}; tv.tv_sec = 0; tv.tv_usec = block ? (RETRY_MS * 1000) : 0; @@ -398,7 +362,6 @@ static int poll_input(netplay_t *netplay, bool block) netplay->timeout_cnt++; FD_ZERO(&fds); - FD_SET(netplay->udp_fd, &fds); FD_SET(netplay->fd, &fds); if (socket_select(max_fd, &fds, NULL, NULL, &tmp_tv) < 0) @@ -417,80 +380,16 @@ static int poll_input(netplay_t *netplay, bool block) } } -#if 0 - if (FD_ISSET(netplay->udp_fd, &fds)) - return 1; -#endif - if (!block) continue; -#if 0 - if (!send_chunk(netplay)) - { - warn_hangup(); - netplay->has_connection = false; - return -1; - } -#endif - RARCH_LOG("Network is stalling at frame %u, count %u of %d ...\n", netplay->self_frame_count, netplay->timeout_cnt, MAX_RETRIES); } while (had_input || (block && (netplay->read_frame_count <= netplay->self_frame_count))); - /*if (block) - return -1;*/ return 0; } -#if 0 -static bool receive_data(netplay_t *netplay, uint32_t *buffer, size_t size) -{ - socklen_t addrlen = sizeof(netplay->their_addr); - - if (recvfrom(netplay->udp_fd, (char*)buffer, size, 0, - (struct sockaddr*)&netplay->their_addr, &addrlen) != (ssize_t)size) - return false; - - netplay->has_client_addr = true; - - return true; -} - -static void parse_packet(netplay_t *netplay, uint32_t *buffer, unsigned size) -{ - unsigned i; - - for (i = 0; i < size * UDP_WORDS_PER_FRAME; i++) - buffer[i] = ntohl(buffer[i]); - - for (i = 0; i < size; i++) - { - uint32_t frame = buffer[UDP_WORDS_PER_FRAME * i + 0]; - const uint32_t *state = &buffer[UDP_WORDS_PER_FRAME * i + 1]; - - if (frame != netplay->read_frame_count) - continue; - - if (!netplay_delta_frame_ready(netplay, &netplay->buffer[netplay->read_ptr], netplay->read_frame_count)) - { - netplay->must_fast_forward = true; - continue; - } - - /* FIXME: acknowledge when we completely drop data on the floor */ - - netplay->buffer[netplay->read_ptr].is_simulated = false; - memcpy(netplay->buffer[netplay->read_ptr].real_input_state, state, - sizeof(netplay->buffer[netplay->read_ptr].real_input_state)); - - netplay->read_ptr = NEXT_PTR(netplay->read_ptr); - netplay->read_frame_count++; - netplay->timeout_cnt = 0; - } -} -#endif - /* TODO: Somewhat better prediction. :P */ static void simulate_input(netplay_t *netplay) { @@ -524,29 +423,8 @@ static bool netplay_poll(netplay_t *netplay) netplay->can_poll = false; -#if 0 - if (!get_self_input_state(netplay)) - return false; -#endif get_self_input_state(netplay); -#if 0 - /* We skip reading the first frame so the host has a chance to grab - * our host info so we don't block forever :') */ - if (netplay->self_frame_count == 0) - { - netplay->buffer[0].used_real = true; - netplay->buffer[0].have_remote = true; - - memset(netplay->buffer[0].real_input_state, - 0, sizeof(netplay->buffer[0].real_input_state)); - - netplay->read_ptr = NEXT_PTR(netplay->read_ptr); - netplay->read_frame_count++; - return true; - } -#endif - /* Read Netplay input, block if we're configured to stall for input every * frame */ res = poll_input(netplay, (netplay->stall_frames == 0) && (netplay->read_frame_count <= netplay->self_frame_count)); @@ -557,36 +435,6 @@ static bool netplay_poll(netplay_t *netplay) return false; } -#if 0 - if (res == 1) - { - uint32_t first_read = netplay->read_frame_count; - do - { - uint32_t buffer[UDP_FRAME_PACKETS * UDP_WORDS_PER_FRAME]; - if (!receive_data(netplay, buffer, sizeof(buffer))) - { - warn_hangup(); - netplay->has_connection = false; - return false; - } - parse_packet(netplay, buffer, UDP_FRAME_PACKETS); - - } while ((netplay->read_frame_count <= netplay->self_frame_count) && - poll_input(netplay, (netplay->other_ptr == netplay->self_ptr) && - (first_read == netplay->read_frame_count)) == 1); - } - else - { - /* Cannot allow this. Should not happen though. */ - if (netplay->self_ptr == netplay->other_ptr) - { - warn_hangup(); - return false; - } - } -#endif - if (netplay->read_frame_count <= netplay->self_frame_count) simulate_input(netplay); @@ -887,37 +735,6 @@ static bool init_tcp_socket(netplay_t *netplay, const char *server, return ret; } -static bool init_udp_socket(netplay_t *netplay, const char *server, - uint16_t port) -{ - int fd = socket_init((void**)&netplay->addr, port, server, SOCKET_TYPE_DATAGRAM); - - if (fd < 0) - goto error; - - netplay->udp_fd = fd; - - if (!server) - { - /* Not sure if we have to do this for UDP, but hey :) */ - if (!socket_bind(netplay->udp_fd, (void*)netplay->addr)) - { - RARCH_ERR("Failed to bind socket.\n"); - socket_close(netplay->udp_fd); - netplay->udp_fd = -1; - } - - freeaddrinfo_retro(netplay->addr); - netplay->addr = NULL; - } - - return true; - -error: - RARCH_ERR("Failed to initialize socket.\n"); - return false; -} - static bool init_socket(netplay_t *netplay, const char *server, uint16_t port) { if (!network_init()) @@ -925,8 +742,6 @@ static bool init_socket(netplay_t *netplay, const char *server, uint16_t port) if (!init_tcp_socket(netplay, server, port, netplay->spectate.enabled)) return false; - if (!netplay->spectate.enabled && !init_udp_socket(netplay, server, port)) - return false; return true; } @@ -958,7 +773,6 @@ netplay_t *netplay_new(const char *server, uint16_t port, return NULL; netplay->fd = -1; - netplay->udp_fd = -1; netplay->cbs = *cb; netplay->port = server ? 0 : 1; netplay->spectate.enabled = spectate; @@ -985,8 +799,6 @@ netplay_t *netplay_new(const char *server, uint16_t port, error: if (netplay->fd >= 0) socket_close(netplay->fd); - if (netplay->udp_fd >= 0) - socket_close(netplay->udp_fd); free(netplay); return NULL; @@ -1099,8 +911,6 @@ void netplay_free(netplay_t *netplay) } else { - socket_close(netplay->udp_fd); - for (i = 0; i < netplay->buffer_size; i++) free(netplay->buffer[i].state); diff --git a/network/netplay/netplay_net.c b/network/netplay/netplay_net.c index a5dc367eff..3ce115e99c 100644 --- a/network/netplay/netplay_net.c +++ b/network/netplay/netplay_net.c @@ -63,12 +63,6 @@ static void netplay_net_post_frame(netplay_t *netplay) { netplay->self_frame_count++; -#if 0 - /* Nothing to do... */ - if (netplay->other_frame_count == netplay->read_frame_count) - return; -#endif - /* Skip ahead if we predicted correctly. * Skip until our simulation failed. */ while (netplay->other_frame_count < netplay->read_frame_count) @@ -134,47 +128,6 @@ static void netplay_net_post_frame(netplay_t *netplay) netplay->is_replay = false; } -#if 0 - /* And if the other side has gotten too far ahead of /us/, skip to catch up - * FIXME: Make this configurable */ - if (netplay->read_frame_count > netplay->self_frame_count + 10 || - netplay->must_fast_forward) - { - /* "replay" into the future */ - netplay->is_replay = true; - netplay->replay_ptr = netplay->self_ptr; - netplay->replay_frame_count = netplay->self_frame_count; - - /* just assume input doesn't change for the intervening frames */ - while (netplay->replay_frame_count < netplay->read_frame_count) - { - size_t cur = netplay->replay_ptr; - size_t prev = PREV_PTR(cur); - - memcpy(netplay->buffer[cur].self_state, netplay->buffer[prev].self_state, - sizeof(netplay->buffer[prev].self_state)); - -#if defined(HAVE_THREADS) - autosave_lock(); -#endif - core_run(); -#if defined(HAVE_THREADS) - autosave_unlock(); -#endif - - netplay->replay_ptr = NEXT_PTR(cur); - netplay->replay_frame_count++; - } - - /* at this point, other = read = self */ - netplay->self_ptr = netplay->replay_ptr; - netplay->self_frame_count = netplay->replay_frame_count; - netplay->other_ptr = netplay->read_ptr; - netplay->other_frame_count = netplay->read_frame_count; - netplay->is_replay = false; - } -#endif - /* If we're supposed to stall, rewind */ if (netplay->stall) { diff --git a/network/netplay/netplay_private.h b/network/netplay/netplay_private.h index 9e6bd71749..7785195cb9 100644 --- a/network/netplay/netplay_private.h +++ b/network/netplay/netplay_private.h @@ -81,8 +81,6 @@ struct netplay struct retro_callbacks cbs; /* TCP connection for state sending, etc. Also used for commands */ int fd; - /* UDP connection for game state updates. */ - int udp_fd; /* Which port is governed by netplay (other user)? */ unsigned port; bool has_connection; From ae8e69564452bdf48900887d3ef8aa8d4085e1d9 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Tue, 13 Sep 2016 17:05:28 -0400 Subject: [PATCH 043/334] Fixing indentation to align with the rest of RetroArch. --- network/netplay/netplay.c | 96 ++++++++++++++++---------------- network/netplay/netplay_common.c | 40 ++++++------- network/netplay/netplay_net.c | 26 ++++----- 3 files changed, 81 insertions(+), 81 deletions(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index 646b06a724..2ee8be9bd4 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -196,7 +196,7 @@ static bool netplay_send_raw_cmd(netplay_t *netplay, uint32_t cmd, if (size > 0) if (!socket_send_all_blocking(netplay->fd, data, size, false)) - return false; + return false; return true; } @@ -236,7 +236,7 @@ static bool netplay_get_cmd(netplay_t *netplay) cmd = ntohl(cmd); if (!socket_receive_all_blocking(netplay->fd, &cmd_size, sizeof(cmd))) - return false; + return false; cmd_size = ntohl(cmd_size); @@ -248,40 +248,40 @@ static bool netplay_get_cmd(netplay_t *netplay) return true; case NETPLAY_CMD_INPUT: - { - uint32_t buffer[WORDS_PER_FRAME]; - unsigned i; - - if (cmd_size != WORDS_PER_FRAME * sizeof(uint32_t)) { - RARCH_ERR("NETPLAY_CMD_INPUT received an unexpected payload size.\n"); - return netplay_cmd_nak(netplay); + uint32_t buffer[WORDS_PER_FRAME]; + unsigned i; + + if (cmd_size != WORDS_PER_FRAME * sizeof(uint32_t)) + { + RARCH_ERR("NETPLAY_CMD_INPUT received an unexpected payload size.\n"); + return netplay_cmd_nak(netplay); + } + + if (!socket_receive_all_blocking(netplay->fd, buffer, sizeof(buffer))) + { + RARCH_ERR("Failed to receive NETPLAY_CMD_INPUT input.\n"); + return netplay_cmd_nak(netplay); + } + + for (i = 0; i < WORDS_PER_FRAME; i++) + buffer[i] = ntohl(buffer[i]); + + if (buffer[0] != netplay->read_frame_count) + { + /* FIXME: Except on the first (null) frame, this should be + * impossible, so maybe just disconnect? */ + return netplay_cmd_nak(netplay); + } + + /* The data's good! */ + netplay->buffer[netplay->read_ptr].have_remote = true; + memcpy(netplay->buffer[netplay->read_ptr].real_input_state, buffer + 1, sizeof(buffer) - sizeof(uint32_t)); + netplay->read_ptr = NEXT_PTR(netplay->read_ptr); + netplay->read_frame_count++; + return true; } - if (!socket_receive_all_blocking(netplay->fd, buffer, sizeof(buffer))) - { - RARCH_ERR("Failed to receive NETPLAY_CMD_INPUT input.\n"); - return netplay_cmd_nak(netplay); - } - - for (i = 0; i < WORDS_PER_FRAME; i++) - buffer[i] = ntohl(buffer[i]); - - if (buffer[0] != netplay->read_frame_count) - { - /* FIXME: Except on the first (null) frame, this should be - * impossible, so maybe just disconnect? */ - return netplay_cmd_nak(netplay); - } - - /* The data's good! */ - netplay->buffer[netplay->read_ptr].have_remote = true; - memcpy(netplay->buffer[netplay->read_ptr].real_input_state, buffer + 1, sizeof(buffer) - sizeof(uint32_t)); - netplay->read_ptr = NEXT_PTR(netplay->read_ptr); - netplay->read_frame_count++; - return true; - } - case NETPLAY_CMD_FLIP_PLAYERS: if (cmd_size != sizeof(uint32_t)) { @@ -371,13 +371,13 @@ static int poll_input(netplay_t *netplay, bool block) * but we aren't using the TCP connection for anything useful atm. */ if (FD_ISSET(netplay->fd, &fds)) { - /* If we're not ready for input, wait until we are. Could fill the TCP buffer, stalling the other side. */ - if (netplay_delta_frame_ready(netplay, &netplay->buffer[netplay->read_ptr], netplay->read_frame_count)) - { - had_input = true; - if (!netplay_get_cmd(netplay)) - return -1; - } + /* If we're not ready for input, wait until we are. Could fill the TCP buffer, stalling the other side. */ + if (netplay_delta_frame_ready(netplay, &netplay->buffer[netplay->read_ptr], netplay->read_frame_count)) + { + had_input = true; + if (!netplay_get_cmd(netplay)) + return -1; + } } if (!block) @@ -440,14 +440,14 @@ static bool netplay_poll(netplay_t *netplay) /* Consider stalling */ switch (netplay->stall) { - case RARCH_NETPLAY_STALL_RUNNING_FAST: - if (netplay->read_frame_count >= netplay->self_frame_count) - netplay->stall = RARCH_NETPLAY_STALL_NONE; - break; + case RARCH_NETPLAY_STALL_RUNNING_FAST: + if (netplay->read_frame_count >= netplay->self_frame_count) + netplay->stall = RARCH_NETPLAY_STALL_NONE; + break; - default: /* not stalling */ - if (netplay->read_frame_count + netplay->stall_frames <= netplay->self_frame_count) - netplay->stall = RARCH_NETPLAY_STALL_RUNNING_FAST; + default: /* not stalling */ + if (netplay->read_frame_count + netplay->stall_frames <= netplay->self_frame_count) + netplay->stall = RARCH_NETPLAY_STALL_RUNNING_FAST; } return true; @@ -881,7 +881,7 @@ static void netplay_flip_users(netplay_t *netplay) &flip_frame_net, sizeof flip_frame_net, CMD_OPT_HOST_ONLY | CMD_OPT_REQUIRE_SYNC, "flip users", "Successfully flipped users.\n"); - + if(command) { netplay->flip ^= true; diff --git a/network/netplay/netplay_common.c b/network/netplay/netplay_common.c index 2468c0102c..b1053c08e7 100644 --- a/network/netplay/netplay_common.c +++ b/network/netplay/netplay_common.c @@ -79,7 +79,7 @@ uint32_t *netplay_bsv_header_generate(size_t *size, uint32_t magic) uint32_t *header, bsv_header[4] = {0}; core_serialize_size(&info); - + serialize_size = info.size; header_size = sizeof(bsv_header) + serialize_size; *size = header_size; @@ -177,9 +177,9 @@ uint32_t netplay_impl_magic(void) core_api_version(&api_info); api = api_info.version; - + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); - + if (info) lib = info->info.library_name; @@ -217,7 +217,7 @@ bool netplay_send_info(netplay_t *netplay) core_get_memory(&mem_info); content_get_crc(&content_crc_ptr); - + header[0] = htonl(*content_crc_ptr); header[1] = htonl(netplay_impl_magic()); header[2] = htonl(mem_info.size); @@ -347,20 +347,20 @@ bool netplay_is_spectate(netplay_t* netplay) bool netplay_delta_frame_ready(netplay_t *netplay, struct delta_frame *delta, uint32_t frame) { - void *remember_state; - if (delta->used) - { - if (delta->frame == frame) return true; - if (netplay->other_frame_count <= delta->frame) - { - /* We haven't even replayed this frame yet, so we can't overwrite it! */ - return false; - } - } - remember_state = delta->state; - memset(delta, 0, sizeof(struct delta_frame)); - delta->used = true; - delta->frame = frame; - delta->state = remember_state; - return true; + void *remember_state; + if (delta->used) + { + if (delta->frame == frame) return true; + if (netplay->other_frame_count <= delta->frame) + { + /* We haven't even replayed this frame yet, so we can't overwrite it! */ + return false; + } + } + remember_state = delta->state; + memset(delta, 0, sizeof(struct delta_frame)); + delta->used = true; + delta->frame = frame; + delta->state = remember_state; + return true; } diff --git a/network/netplay/netplay_net.c b/network/netplay/netplay_net.c index 3ce115e99c..3ef0d57913 100644 --- a/network/netplay/netplay_net.c +++ b/network/netplay/netplay_net.c @@ -35,16 +35,16 @@ static void netplay_net_pre_frame(netplay_t *netplay) if (netplay_delta_frame_ready(netplay, &netplay->buffer[netplay->self_ptr], netplay->self_frame_count)) { - serial_info.data_const = NULL; - serial_info.data = netplay->buffer[netplay->self_ptr].state; - serial_info.size = netplay->state_size; + serial_info.data_const = NULL; + serial_info.data = netplay->buffer[netplay->self_ptr].state; + serial_info.size = netplay->state_size; - if (!core_serialize(&serial_info)) - { - /* If the core can't serialize properly, we must stall for the - * remote input on EVERY frame, because we can't recover */ - netplay->stall_frames = 0; - } + if (!core_serialize(&serial_info)) + { + /* If the core can't serialize properly, we must stall for the + * remote input on EVERY frame, because we can't recover */ + netplay->stall_frames = 0; + } } netplay->can_poll = true; @@ -118,9 +118,9 @@ static void netplay_net_post_frame(netplay_t *netplay) /* For the remainder of the frames up to the read count, we can use the real data */ while (netplay->replay_frame_count < netplay->read_frame_count) { - retro_assert(netplay->buffer[netplay->replay_ptr].have_remote); - netplay->replay_ptr = NEXT_PTR(netplay->replay_ptr); - netplay->replay_frame_count++; + retro_assert(netplay->buffer[netplay->replay_ptr].have_remote); + netplay->replay_ptr = NEXT_PTR(netplay->replay_ptr); + netplay->replay_frame_count++; } netplay->other_ptr = netplay->read_ptr; @@ -153,7 +153,7 @@ static bool netplay_net_init_buffers(netplay_t *netplay) netplay->buffer = (struct delta_frame*)calloc(netplay->buffer_size, sizeof(*netplay->buffer)); - + if (!netplay->buffer) return false; From 0ccc39769d98840d58f7ca630af8e26c7ecc3078 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Tue, 13 Sep 2016 17:06:23 -0400 Subject: [PATCH 044/334] Adding my copyright lines to files I've touched. --- network/netplay/netplay.c | 1 + network/netplay/netplay_common.c | 1 + network/netplay/netplay_net.c | 1 + 3 files changed, 3 insertions(+) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index 2ee8be9bd4..5849136258 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -1,6 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2016 - Daniel De Matteis + * Copyright (C) 2016 - Gregor Richards * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- diff --git a/network/netplay/netplay_common.c b/network/netplay/netplay_common.c index b1053c08e7..a1b26e1154 100644 --- a/network/netplay/netplay_common.c +++ b/network/netplay/netplay_common.c @@ -1,6 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2016 - Daniel De Matteis + * Copyright (C) 2016 - Gregor Richards * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- diff --git a/network/netplay/netplay_net.c b/network/netplay/netplay_net.c index 3ef0d57913..ea15cac265 100644 --- a/network/netplay/netplay_net.c +++ b/network/netplay/netplay_net.c @@ -1,6 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2016 - Daniel De Matteis + * Copyright (C) 2016 - Gregor Richards * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- From 8aa48cd3f955e8e4360720aab6736a0b79a4eeae Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Tue, 13 Sep 2016 17:08:59 -0400 Subject: [PATCH 045/334] Reinstituted "standard" timeout-based disconnection, which only works for stall_frames==0 due to the fixes to not stall the UI. --- network/netplay/netplay.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index 5849136258..0cf6653012 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -386,6 +386,9 @@ static int poll_input(netplay_t *netplay, bool block) RARCH_LOG("Network is stalling at frame %u, count %u of %d ...\n", netplay->self_frame_count, netplay->timeout_cnt, MAX_RETRIES); + + if (netplay->timeout_cnt >= MAX_RETRIES) + return -1; } while (had_input || (block && (netplay->read_frame_count <= netplay->self_frame_count))); return 0; From 6829b80c6bb1ff530658d40d187ac533421a11de Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Tue, 13 Sep 2016 17:33:26 -0400 Subject: [PATCH 046/334] Reimplemented disconnection based on stalls. If we stall for 10 seconds, disconnect. --- network/netplay/netplay.c | 19 +++++++++++++++++++ network/netplay/netplay_net.c | 4 ++++ network/netplay/netplay_private.h | 2 ++ 3 files changed, 25 insertions(+) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index 0cf6653012..ef72732002 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include "netplay_private.h" @@ -408,6 +409,8 @@ static void simulate_input(netplay_t *netplay) netplay->buffer[ptr].used_real = false; } +#define MAX_STALL_TIME_USEC 10000000 + /** * netplay_poll: * @netplay : pointer to netplay object @@ -451,7 +454,23 @@ static bool netplay_poll(netplay_t *netplay) default: /* not stalling */ if (netplay->read_frame_count + netplay->stall_frames <= netplay->self_frame_count) + { netplay->stall = RARCH_NETPLAY_STALL_RUNNING_FAST; + netplay->stall_time = cpu_features_get_time_usec(); + } + } + + /* If we're stalling, consider disconnection */ + if (netplay->stall) + { + retro_time_t now = cpu_features_get_time_usec(); + if (now - netplay->stall_time >= MAX_STALL_TIME_USEC) + { + /* Stalled out! */ + netplay->has_connection = false; + warn_hangup(); + return false; + } } return true; diff --git a/network/netplay/netplay_net.c b/network/netplay/netplay_net.c index ea15cac265..6458f1e412 100644 --- a/network/netplay/netplay_net.c +++ b/network/netplay/netplay_net.c @@ -64,6 +64,10 @@ static void netplay_net_post_frame(netplay_t *netplay) { netplay->self_frame_count++; + /* Only relevant if we're connected */ + if (!netplay->has_connection) + return; + /* Skip ahead if we predicted correctly. * Skip until our simulation failed. */ while (netplay->other_frame_count < netplay->read_frame_count) diff --git a/network/netplay/netplay_private.h b/network/netplay/netplay_private.h index 7785195cb9..e8bf820e40 100644 --- a/network/netplay/netplay_private.h +++ b/network/netplay/netplay_private.h @@ -20,6 +20,7 @@ #include "netplay.h" #include +#include #include #include "../../core.h" @@ -144,6 +145,7 @@ struct netplay /* And stalling */ uint32_t stall_frames; int stall; + retro_time_t stall_time; struct netplay_callbacks* net_cbs; }; From b140b16b5df72652150d75554d20fca3ac2ae335 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Tue, 13 Sep 2016 18:03:36 -0400 Subject: [PATCH 047/334] Removed Netplay positive acknowledgement messages: They didn't document their corresponding sent message, and so couldn't be used for acknowledgement anyway. Negative acknowledgement is sufficient. --- network/netplay/netplay.c | 53 ++++++--------------------------------- 1 file changed, 7 insertions(+), 46 deletions(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index ef72732002..b3b818266a 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -58,20 +58,6 @@ static void warn_hangup(void) runloop_msg_queue_push("Netplay has disconnected. Will continue without connection.", 0, 480, false); } -/** - * check_netplay_synched: - * @netplay: pointer to the netplay object. - * Checks to see if the host and client have synchronized states. Returns true - * on success and false on failure. - */ -bool check_netplay_synched(netplay_t* netplay) -{ - retro_assert(netplay); - /*return netplay->self_frame_count < (netplay->flip_frame + 2 * UDP_FRAME_PACKETS);*/ - /* FIXME */ - return true; -} - static bool netplay_info_cb(netplay_t* netplay, unsigned frames) { return netplay->net_cbs->info_cb(netplay, frames); } @@ -203,25 +189,11 @@ static bool netplay_send_raw_cmd(netplay_t *netplay, uint32_t cmd, return true; } -static bool netplay_cmd_ack(netplay_t *netplay) -{ - return netplay_send_raw_cmd(netplay, NETPLAY_CMD_ACK, NULL, 0); -} - static bool netplay_cmd_nak(netplay_t *netplay) { return netplay_send_raw_cmd(netplay, NETPLAY_CMD_NAK, NULL, 0); } -static bool netplay_get_response(netplay_t *netplay) -{ - uint32_t response; - if (!socket_receive_all_blocking(netplay->fd, &response, sizeof(response))) - return false; - - return ntohl(response) == NETPLAY_CMD_ACK; -} - static bool netplay_get_cmd(netplay_t *netplay) { uint32_t cmd; @@ -312,7 +284,7 @@ static bool netplay_get_cmd(netplay_t *netplay) RARCH_LOG("Netplay users are flipped.\n"); runloop_msg_queue_push("Netplay users are flipped.", 1, 180, false); - return netplay_cmd_ack(netplay); + return true; case NETPLAY_CMD_SPECTATE: RARCH_ERR("NETPLAY_CMD_SPECTATE unimplemented.\n"); @@ -320,7 +292,7 @@ static bool netplay_get_cmd(netplay_t *netplay) case NETPLAY_CMD_DISCONNECT: warn_hangup(); - return netplay_cmd_ack(netplay); + return true; case NETPLAY_CMD_LOAD_SAVESTATE: RARCH_ERR("NETPLAY_CMD_LOAD_SAVESTATE unimplemented.\n"); @@ -328,11 +300,11 @@ static bool netplay_get_cmd(netplay_t *netplay) case NETPLAY_CMD_PAUSE: command_event(CMD_EVENT_PAUSE, NULL); - return netplay_cmd_ack(netplay); + return true; case NETPLAY_CMD_RESUME: command_event(CMD_EVENT_UNPAUSE, NULL); - return netplay_cmd_ack(netplay); + return true; default: break; } @@ -849,7 +821,6 @@ bool netplay_command(netplay_t* netplay, enum netplay_cmd cmd, const char* msg = NULL; bool allowed_spectate = !!(flags & CMD_OPT_ALLOWED_IN_SPECTATE_MODE); bool host_only = !!(flags & CMD_OPT_HOST_ONLY); - bool require_sync = !!(flags & CMD_OPT_REQUIRE_SYNC); retro_assert(netplay); @@ -865,21 +836,11 @@ bool netplay_command(netplay_t* netplay, enum netplay_cmd cmd, goto error; } - if(require_sync && check_netplay_synched(netplay)) - { - msg = "Cannot %s while host and client are not in sync."; + if (!netplay_send_raw_cmd(netplay, cmd, data, sz)) goto error; - } - if(netplay_send_raw_cmd(netplay, cmd, data, sz)) { - if(netplay_get_response(netplay)) - runloop_msg_queue_push(success_msg, 1, 180, false); - else - { - msg = "Failed to send command \"%s\""; - goto error; - } - } + runloop_msg_queue_push(success_msg, 1, 180, false); + return true; error: From a0cfdb8a9cc31762f0dff3b4076e13fe968d39b3 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Tue, 13 Sep 2016 20:34:10 -0400 Subject: [PATCH 048/334] naks now cause disconnection. --- network/netplay/netplay.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index b3b818266a..79e0f8f212 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -217,10 +217,13 @@ static bool netplay_get_cmd(netplay_t *netplay) switch (cmd) { case NETPLAY_CMD_ACK: - case NETPLAY_CMD_NAK: /* Why are we even bothering? */ return true; + case NETPLAY_CMD_NAK: + /* Disconnect now! */ + return false; + case NETPLAY_CMD_INPUT: { uint32_t buffer[WORDS_PER_FRAME]; @@ -243,8 +246,7 @@ static bool netplay_get_cmd(netplay_t *netplay) if (buffer[0] != netplay->read_frame_count) { - /* FIXME: Except on the first (null) frame, this should be - * impossible, so maybe just disconnect? */ + /* Out of order = out of luck */ return netplay_cmd_nak(netplay); } From 1267e5e867cbfcb557637a944effefbeacdaa1a9 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Tue, 13 Sep 2016 20:34:40 -0400 Subject: [PATCH 049/334] A few clarifications regarding the buffer's have_remote and used_real data. simulation shouldn't touch 'em. --- network/netplay/netplay.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index 79e0f8f212..16fcd9fb23 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -378,9 +378,6 @@ static void simulate_input(netplay_t *netplay) memcpy(netplay->buffer[ptr].simulated_input_state, netplay->buffer[prev].real_input_state, sizeof(netplay->buffer[prev].real_input_state)); - - netplay->buffer[ptr].have_remote = false; - netplay->buffer[ptr].used_real = false; } #define MAX_STALL_TIME_USEC 10000000 @@ -416,7 +413,8 @@ static bool netplay_poll(netplay_t *netplay) return false; } - if (netplay->read_frame_count <= netplay->self_frame_count) + /* Simulate the input if we don't have real input */ + if (!netplay->buffer[PREV_PTR(netplay->self_ptr)].have_remote) simulate_input(netplay); /* Consider stalling */ From 99b5ed92ed335c5211ed17381499d6589c321559 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Tue, 13 Sep 2016 20:35:10 -0400 Subject: [PATCH 050/334] other should always be <= both real AND self. Before this fix, it was possible (albeit unlikely) for the remote to get so far ahead of us that they actually overwrote our own current data :) --- network/netplay/netplay_net.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/network/netplay/netplay_net.c b/network/netplay/netplay_net.c index 6458f1e412..10f00e2054 100644 --- a/network/netplay/netplay_net.c +++ b/network/netplay/netplay_net.c @@ -70,7 +70,8 @@ static void netplay_net_post_frame(netplay_t *netplay) /* Skip ahead if we predicted correctly. * Skip until our simulation failed. */ - while (netplay->other_frame_count < netplay->read_frame_count) + while (netplay->other_frame_count < netplay->read_frame_count && + netplay->other_frame_count < netplay->self_frame_count) { const struct delta_frame *ptr = &netplay->buffer[netplay->other_ptr]; @@ -83,7 +84,8 @@ static void netplay_net_post_frame(netplay_t *netplay) } /* Now replay the real input if we've gotten ahead of it */ - if (netplay->other_frame_count < netplay->read_frame_count) + if (netplay->other_frame_count < netplay->read_frame_count && + netplay->other_frame_count < netplay->self_frame_count) { retro_ctx_serialize_info_t serial_info; @@ -120,16 +122,14 @@ static void netplay_net_post_frame(netplay_t *netplay) netplay->replay_frame_count++; } - /* For the remainder of the frames up to the read count, we can use the real data */ - while (netplay->replay_frame_count < netplay->read_frame_count) + if (netplay->read_frame_count < netplay->self_frame_count) { - retro_assert(netplay->buffer[netplay->replay_ptr].have_remote); - netplay->replay_ptr = NEXT_PTR(netplay->replay_ptr); - netplay->replay_frame_count++; + netplay->other_ptr = netplay->read_ptr; + netplay->other_frame_count = netplay->read_frame_count; + } else { + netplay->other_ptr = netplay->self_ptr; + netplay->other_frame_count = netplay->self_frame_count; } - - netplay->other_ptr = netplay->read_ptr; - netplay->other_frame_count = netplay->read_frame_count; netplay->is_replay = false; } From d4e074dbedeb2b9275c592a1b01913f7e59d534f Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Tue, 13 Sep 2016 20:37:53 -0400 Subject: [PATCH 051/334] Moved the advance of self_ptr to the same place as the advance of self_frame_count, which is much clearer. --- network/netplay/netplay.c | 8 +++----- network/netplay/netplay_net.c | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index 16fcd9fb23..7de915619f 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -105,7 +105,6 @@ static bool get_self_input_state(netplay_t *netplay) if (ptr->have_local) { /* We've already read this frame! */ - netplay->self_ptr = NEXT_PTR(netplay->self_ptr); return true; } @@ -167,7 +166,6 @@ static bool get_self_input_state(netplay_t *netplay) memcpy(ptr->self_state, state, sizeof(state)); ptr->have_local = true; - netplay->self_ptr = NEXT_PTR(netplay->self_ptr); return true; } @@ -372,7 +370,7 @@ static int poll_input(netplay_t *netplay, bool block) /* TODO: Somewhat better prediction. :P */ static void simulate_input(netplay_t *netplay) { - size_t ptr = PREV_PTR(netplay->self_ptr); + size_t ptr = netplay->self_ptr; size_t prev = PREV_PTR(netplay->read_ptr); memcpy(netplay->buffer[ptr].simulated_input_state, @@ -414,7 +412,7 @@ static bool netplay_poll(netplay_t *netplay) } /* Simulate the input if we don't have real input */ - if (!netplay->buffer[PREV_PTR(netplay->self_ptr)].have_remote) + if (!netplay->buffer[netplay->self_ptr].have_remote) simulate_input(netplay); /* Consider stalling */ @@ -511,7 +509,7 @@ static int16_t netplay_input_state(netplay_t *netplay, unsigned idx, unsigned id) { size_t ptr = netplay->is_replay ? - netplay->replay_ptr : PREV_PTR(netplay->self_ptr); + netplay->replay_ptr : netplay->self_ptr; const uint32_t *curr_input_state = netplay->buffer[ptr].self_state; diff --git a/network/netplay/netplay_net.c b/network/netplay/netplay_net.c index 10f00e2054..a6d872734b 100644 --- a/network/netplay/netplay_net.c +++ b/network/netplay/netplay_net.c @@ -62,6 +62,7 @@ static void netplay_net_pre_frame(netplay_t *netplay) **/ static void netplay_net_post_frame(netplay_t *netplay) { + netplay->self_ptr = NEXT_PTR(netplay->self_ptr); netplay->self_frame_count++; /* Only relevant if we're connected */ From ea0bb6f812866571e3fc568da006951c95c9ff95 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Tue, 13 Sep 2016 21:39:10 -0400 Subject: [PATCH 052/334] Just in case some systems don't have TCP_NODElAY, put that in an ifdef. --- network/netplay/netplay.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index 7de915619f..48a50c4f3d 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -625,9 +625,13 @@ static int init_tcp_connection(const struct addrinfo *res, { bool ret = true; int fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); - int flag = 1; - setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(int)); +#if defined(IPPROTO_TCP) && defined(TCP_NODELAY) + { + int flag = 1; + setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(int)); + } +#endif if (fd < 0) { From 12bf3e4824e190e099ee53b13b828ce19b435d20 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Tue, 13 Sep 2016 21:45:06 -0400 Subject: [PATCH 053/334] Rather than repeating the same sample for every frame while stalled, just pause the sound while stalled. Both options are annoying, but this option is less annoying. --- network/netplay/netplay.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index 48a50c4f3d..f56da9fd34 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -464,14 +464,14 @@ void video_frame_net(const void *data, unsigned width, void audio_sample_net(int16_t left, int16_t right) { netplay_t *netplay = (netplay_t*)netplay_data; - if (!netplay_should_skip(netplay)) + if (!netplay_should_skip(netplay) && !netplay->stall) netplay->cbs.sample_cb(left, right); } size_t audio_sample_batch_net(const int16_t *data, size_t frames) { netplay_t *netplay = (netplay_t*)netplay_data; - if (!netplay_should_skip(netplay)) + if (!netplay_should_skip(netplay) && !netplay->stall) return netplay->cbs.sample_batch_cb(data, frames); return frames; } From 0ae05ef394b3f0c2d59aabf4584c7966ef6c2a1d Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Tue, 13 Sep 2016 22:31:16 -0400 Subject: [PATCH 054/334] Add a toggle console --- pkg/emscripten/proto.html | 7 ++++++- pkg/emscripten/proto.js | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/emscripten/proto.html b/pkg/emscripten/proto.html index 6d6b683932..826df7d335 100644 --- a/pkg/emscripten/proto.html +++ b/pkg/emscripten/proto.html @@ -114,7 +114,7 @@
-
+
+
+ +
diff --git a/pkg/emscripten/proto.js b/pkg/emscripten/proto.js index f22e7e87b3..2731fe61b8 100644 --- a/pkg/emscripten/proto.js +++ b/pkg/emscripten/proto.js @@ -280,6 +280,13 @@ function switchStorage(backend) { // When the browser has loaded everything. $(function() { + + // Hide the logging window and allow the user to show it. + $('#output').hide(); + $('#btnlogs').click(function () { + $('#output').slideToggle(); + }); + /** * Attempt to disable some default browser keys. */ From f855e80933d235c4cc34c617ddb7dd0ccf8f939d Mon Sep 17 00:00:00 2001 From: radius Date: Tue, 13 Sep 2016 23:41:53 -0500 Subject: [PATCH 055/334] (emscripten) use standard frontend assets dir --- pkg/emscripten/proto.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/emscripten/proto.js b/pkg/emscripten/proto.js index 2731fe61b8..58fe7357b8 100644 --- a/pkg/emscripten/proto.js +++ b/pkg/emscripten/proto.js @@ -112,7 +112,7 @@ function setupFileSystem(backend) /* create an XmlHttpRequest filesystem for the bundled data */ var xfs1 = new BrowserFS.FileSystem.XmlHttpRequest - (".index-xhr", "/web/assets/"); + (".index-xhr", "/assets/frontend/bundle/"); /* create an XmlHttpRequest filesystem for core assets */ var xfs2 = new BrowserFS.FileSystem.XmlHttpRequest (".index-xhr", "/assets/cores/"); From cf86aa1f1abc3f8c8be3f8e46a0b6b08f838a529 Mon Sep 17 00:00:00 2001 From: Ezio-PS Date: Wed, 14 Sep 2016 09:18:47 +0200 Subject: [PATCH 056/334] Add other translated strings --- intl/msg_hash_it.c | 50 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/intl/msg_hash_it.c b/intl/msg_hash_it.c index b80b1a08af..92421f64d0 100644 --- a/intl/msg_hash_it.c +++ b/intl/msg_hash_it.c @@ -1359,6 +1359,8 @@ const char *msg_hash_to_str_it(enum msg_hash_enums msg) return "Directory degli asset"; case MENU_ENUM_LABEL_VALUE_DYNAMIC_WALLPAPERS_DIRECTORY: return "Directory degli sfondi dinamici"; + case MENU_ENUM_LABEL_VALUE_THUMBNAILS_DIRECTORY: + return "Directory delle miniature"; case MENU_ENUM_LABEL_VALUE_RGUI_BROWSER_DIRECTORY: return "Directory di selezione file"; case MENU_ENUM_LABEL_VALUE_RGUI_CONFIG_DIRECTORY: @@ -1425,6 +1427,30 @@ const char *msg_hash_to_str_it(enum msg_hash_enums msg) return "Abilita DPI Override"; case MENU_ENUM_LABEL_VALUE_DPI_OVERRIDE_VALUE: return "DPI Override"; + case MENU_ENUM_LABEL_VALUE_XMB_SCALE_FACTOR: + return "Fattore di scala del menù"; + case MENU_ENUM_LABEL_VALUE_XMB_ALPHA_FACTOR: + return "Fattore alpha del menù"; + case MENU_ENUM_LABEL_VALUE_XMB_FONT: + return "Carattere del menù"; + case MENU_ENUM_LABEL_VALUE_XMB_THEME: + return "Icona a tema del menù"; + case MENU_ENUM_LABEL_VALUE_XMB_MENU_COLOR_THEME: + return "Colore tema del menù"; + case MENU_ENUM_LABEL_VALUE_MATERIALUI_MENU_COLOR_THEME: + return "Colore tema del menù"; + case MENU_ENUM_LABEL_VALUE_XMB_SHADOWS_ENABLE: + return "Abilità ombre per l'icona"; + case MENU_ENUM_LABEL_VALUE_XMB_SHOW_SETTINGS: + return "Mostra scheda settaggi"; + case MENU_ENUM_LABEL_VALUE_XMB_SHOW_IMAGES: + return "Mostra scheda immagini"; + case MENU_ENUM_LABEL_VALUE_XMB_SHOW_MUSIC: + return "Mostra scheda musica"; + case MENU_ENUM_LABEL_VALUE_XMB_SHOW_VIDEO: + return "Mostra scheda video"; + case MENU_ENUM_LABEL_VALUE_XMB_SHOW_HISTORY: + return "Mostra scheda storia"; case MENU_ENUM_LABEL_VALUE_SUSPEND_SCREENSAVER_ENABLE: return "Spegni salvaschermo"; case MENU_ENUM_LABEL_VALUE_VIDEO_DISABLE_COMPOSITION: @@ -1460,7 +1486,11 @@ const char *msg_hash_to_str_it(enum msg_hash_enums msg) case MENU_ENUM_LABEL_VALUE_AUTO_REMAPS_ENABLE: return "Carica file di rimappatura automaticamente"; case MENU_ENUM_LABEL_VALUE_SLOWMOTION_RATIO: - return "Slow-Motion Ratio"; + return "Rapporto di slow-motion"; + case MENU_ENUM_LABEL_VALUE_MENU_LINEAR_FILTER: + return "Filtro lineare del menù"; + case MENU_ENUM_LABEL_VALUE_MENU_ENUM_THROTTLE_FRAMERATE: + return "Frequenza fotogrammi del menù"; case MENU_ENUM_LABEL_VALUE_CORE_SPECIFIC_CONFIG: return "Configurazione per core"; case MENU_ENUM_LABEL_VALUE_GAME_SPECIFIC_OPTIONS: @@ -1471,6 +1501,10 @@ const char *msg_hash_to_str_it(enum msg_hash_enums msg) return "Carica file di override automaticamente"; case MENU_ENUM_LABEL_VALUE_CONFIG_SAVE_ON_EXIT: return "Salva configurazione all'uscita"; + case MENU_ENUM_LABEL_VALUE_CONFIRM_ON_EXIT: + return "Chiedi conferma all'uscita"; + case MENU_ENUM_LABEL_VALUE_SHOW_HIDDEN_FILES: + return "Mostra files e cartelle nascoste"; case MENU_ENUM_LABEL_VALUE_VIDEO_SMOOTH: return "Filtro bilineare hardware"; case MENU_ENUM_LABEL_VALUE_VIDEO_GAMMA: @@ -1481,6 +1515,8 @@ const char *msg_hash_to_str_it(enum msg_hash_enums msg) return "Sincronizza GPU"; case MENU_ENUM_LABEL_VALUE_VIDEO_SWAP_INTERVAL: return "Intervallo di swap vsync"; + case MENU_ENUM_LABEL_VALUE_VIDEO_MAX_SWAPCHAIN_IMAGES: + return "Massimo swapchain di immagini"; case MENU_ENUM_LABEL_VALUE_VIDEO_VSYNC: return "VSync"; case MENU_ENUM_LABEL_VALUE_VIDEO_THREADED: @@ -1717,6 +1753,12 @@ const char *msg_hash_to_str_it(enum msg_hash_enums msg) return "Salva stato"; case MENU_ENUM_LABEL_VALUE_LOAD_STATE: return "Carica stato"; + case MENU_ENUM_LABEL_VALUE_UNDO_LOAD_STATE: + return "Annulla carica stato"; + case MENU_ENUM_LABEL_VALUE_UNDO_SAVE_STATE: + return "Annulla salva stato"; + case MSG_UNDID_LOAD_STATE: + return "Annullato carica stato."; case MENU_ENUM_LABEL_VALUE_RESUME_CONTENT: return "Riprendi"; case MENU_ENUM_LABEL_VALUE_INPUT_DRIVER: @@ -1755,7 +1797,9 @@ const char *msg_hash_to_str_it(enum msg_hash_enums msg) return "Sfondo dinamico"; case MENU_ENUM_LABEL_VALUE_CORE_INPUT_REMAPPING_OPTIONS: return "Opzioni di rimappatura degli input del core"; - case MENU_ENUM_LABEL_VALUE_SHADER_OPTIONS: /* UPDATE/FIXME */ + case MENU_ENUM_LABEL_VALUE_THUMBNAILS: + return "Miniature"; + case MENU_ENUM_LABEL_VALUE_SHADER_OPTIONS: return "Shaders"; case MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS: return "Antemprima Parametri Shader"; @@ -2071,6 +2115,8 @@ const char *msg_hash_to_str_it(enum msg_hash_enums msg) return "Avvia Core"; case MENU_ENUM_LABEL_VALUE_INPUT_POLL_TYPE_BEHAVIOR: return "Tipo di ritardo"; + case MENU_ENUM_LABEL_VALUE_MENU_WALLPAPER_OPACITY: + return "Opacità dello sfondo"; default: break; } From 1b9a067bcc8053201445e9f4375b959525e4cd8d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 14 Sep 2016 14:10:39 +0200 Subject: [PATCH 057/334] Move code to apple_compat.h --- frontend/drivers/platform_darwin.m | 27 +--------------- gfx/drivers_context/cocoa_gl_ctx.m | 1 + libretro-common/include/compat/apple_compat.h | 31 +++++++++++++++++++ 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index d573974e8b..1a9a38b1f9 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -45,6 +45,7 @@ #endif #include +#include #include #include #include @@ -105,32 +106,6 @@ typedef enum CFAllDomainsMask = 0x0ffff /* All domains: all of the above and future items */ } CFDomainMask; -#ifndef __has_feature -/* Compatibility with non-Clang compilers. */ -#define __has_feature(x) 0 -#endif - -#ifndef CF_RETURNS_RETAINED -#if __has_feature(attribute_cf_returns_retained) -#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) -#else -#define CF_RETURNS_RETAINED -#endif -#endif - -#ifndef NS_INLINE -#define NS_INLINE inline -#endif - -NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetainCompat(id X) -{ -#if __has_feature(objc_arc) - return (__bridge_retained CFTypeRef)X; -#else - return X; -#endif -} - static NSSearchPathDirectory NSConvertFlagsCF(unsigned flags) { switch (flags) diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index 712cd5ff0a..d211fdff86 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -36,6 +36,7 @@ #endif #include +#include #import "../../ui/drivers/cocoa/cocoa_common.h" #include "../video_context_driver.h" diff --git a/libretro-common/include/compat/apple_compat.h b/libretro-common/include/compat/apple_compat.h index 431243e746..1d20bbcbda 100644 --- a/libretro-common/include/compat/apple_compat.h +++ b/libretro-common/include/compat/apple_compat.h @@ -20,6 +20,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#ifndef __APPLE_COMPAT_H +#define __APPLE_COMPAT_H + #ifdef __APPLE__ #include #endif @@ -32,6 +35,32 @@ typedef unsigned NSUInteger; typedef float CGFloat; #endif +#ifndef __has_feature +/* Compatibility with non-Clang compilers. */ +#define __has_feature(x) 0 +#endif + +#ifndef CF_RETURNS_RETAINED +#if __has_feature(attribute_cf_returns_retained) +#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) +#else +#define CF_RETURNS_RETAINED +#endif +#endif + +#ifndef NS_INLINE +#define NS_INLINE inline +#endif + +static NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetainCompat(id X) +{ +#if __has_feature(objc_arc) + return (__bridge_retained CFTypeRef)X; +#else + return X; +#endif +} + #endif #ifdef IOS @@ -47,3 +76,5 @@ typedef float CGFloat; #include #endif #endif + +#endif From 37ddbc10da89b60d88d0337d31177fd2380f786e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 14 Sep 2016 14:11:19 +0200 Subject: [PATCH 058/334] Buildfix --- libretro-common/include/compat/apple_compat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/include/compat/apple_compat.h b/libretro-common/include/compat/apple_compat.h index 1d20bbcbda..298d0bf7e8 100644 --- a/libretro-common/include/compat/apple_compat.h +++ b/libretro-common/include/compat/apple_compat.h @@ -52,7 +52,7 @@ typedef float CGFloat; #define NS_INLINE inline #endif -static NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetainCompat(id X) +NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetainCompat(id X) { #if __has_feature(objc_arc) return (__bridge_retained CFTypeRef)X; From 18c52dac39f2563ac70b8407b03c3c14049d6223 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Wed, 14 Sep 2016 15:42:40 +0200 Subject: [PATCH 059/334] (iOS) Buildfix --- libretro-common/include/compat/apple_compat.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libretro-common/include/compat/apple_compat.h b/libretro-common/include/compat/apple_compat.h index 298d0bf7e8..423dc30952 100644 --- a/libretro-common/include/compat/apple_compat.h +++ b/libretro-common/include/compat/apple_compat.h @@ -72,7 +72,11 @@ NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetainCompat(id X) #import #import #import +#endif +#else + +#ifdef __OBJC__ #include #endif #endif From ca673b4fc8b0632ab205e74886545e698f678df3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 14 Sep 2016 15:56:14 +0200 Subject: [PATCH 060/334] C89_BUILD fixes etc. --- gfx/common/x11_common.c | 90 ++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 41 deletions(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 86fe77ec13..5758bc37ef 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -36,7 +36,7 @@ #ifdef HAVE_DBUS #include -static DBusConnection* dbus_connection; +static DBusConnection* dbus_connection = NULL; static unsigned int dbus_screensaver_cookie = 0; #endif @@ -63,7 +63,7 @@ unsigned g_x11_screen; #define MOVERESIZE_Y_SHIFT 9 #ifdef HAVE_DBUS -static void dbus_get_connection() +static void dbus_get_connection(void) { DBusError err; int ret; @@ -71,18 +71,18 @@ static void dbus_get_connection() dbus_error_init(&err); dbus_connection = dbus_bus_get_private(DBUS_BUS_SESSION, &err); + if (dbus_error_is_set(&err)) { RARCH_ERR("[DBus]: Failed to get DBus connection. Screensaver will not be suspended via DBus.\n"); dbus_error_free(&err); } - if (dbus_connection != NULL) { + if (dbus_connection != NULL) dbus_connection_set_exit_on_disconnect(dbus_connection, true); - } } -static void dbus_close_connection() +static void dbus_close_connection(void) { if (dbus_connection != NULL) { @@ -91,17 +91,17 @@ static void dbus_close_connection() } } -static void dbus_screensaver_inhibit() +static void dbus_screensaver_inhibit(void) { const char *app = "RetroArch"; const char *reason = "Playing a game"; DBusMessage *msg, *reply; if (dbus_connection == NULL) - return; // DBus connection was not obtained + return; /* DBus connection was not obtained */ if (dbus_screensaver_cookie > 0) - return; // Already inhibited + return; /* Already inhibited */ msg = dbus_message_new_method_call("org.freedesktop.ScreenSaver", "/org/freedesktop/ScreenSaver", @@ -118,14 +118,15 @@ static void dbus_screensaver_inhibit() if (msg != NULL) { - reply = dbus_connection_send_with_reply_and_block(dbus_connection, msg, 300, NULL); - if (reply != NULL) { + reply = dbus_connection_send_with_reply_and_block(dbus_connection, + msg, 300, NULL); + + if (reply != NULL) + { if (!dbus_message_get_args(reply, NULL, DBUS_TYPE_UINT32, &dbus_screensaver_cookie, DBUS_TYPE_INVALID)) - { dbus_screensaver_cookie = 0; - } dbus_message_unref(reply); } @@ -143,38 +144,46 @@ static void dbus_screensaver_inhibit() } } -static void dbus_screensaver_uninhibit() +static void dbus_screensaver_uninhibit(void) { - if (dbus_connection != NULL && dbus_screensaver_cookie > 0) - { - DBusMessage *msg = dbus_message_new_method_call("org.freedesktop.ScreenSaver", - "/org/freedesktop/ScreenSaver", - "org.freedesktop.ScreenSaver", - "UnInhibit"); - dbus_message_append_args (msg, - DBUS_TYPE_UINT32, &dbus_screensaver_cookie, - DBUS_TYPE_INVALID); - if (msg != NULL) { - if (dbus_connection_send(dbus_connection, msg, NULL)) { - dbus_connection_flush(dbus_connection); - } - dbus_message_unref(msg); - } + DBusMessage *msg = NULL; - dbus_screensaver_cookie = 0; - } + if (!dbus_connection) + return; + + if (dbus_screensaver_cookie <= 0) + return; + + msg = dbus_message_new_method_call("org.freedesktop.ScreenSaver", + "/org/freedesktop/ScreenSaver", + "org.freedesktop.ScreenSaver", + "UnInhibit"); + dbus_message_append_args (msg, + DBUS_TYPE_UINT32, &dbus_screensaver_cookie, + DBUS_TYPE_INVALID); + + if (msg != NULL) + { + if (dbus_connection_send(dbus_connection, msg, NULL)) + dbus_connection_flush(dbus_connection); + dbus_message_unref(msg); + } + + dbus_screensaver_cookie = 0; } void x11_suspend_screensaver_dbus(bool enable) { - if (!enable && !dbus_screensaver_cookie == 0) - return; // Disable requested and was not already suspended + /* Disable requested and was not already suspended */ + if (!enable && !dbus_screensaver_cookie == 0) + return; - if (!enable && dbus_screensaver_cookie > 0) - dbus_screensaver_uninhibit(); // Disable requesed and was suspended -> unsuspend + /* Disable requesed and was suspended -> unsuspend */ + if (!enable && dbus_screensaver_cookie > 0) + dbus_screensaver_uninhibit(); - if (enable) - dbus_screensaver_inhibit(); + if (enable) + dbus_screensaver_inhibit(); } #endif @@ -504,13 +513,12 @@ void x11_destroy_input_context(XIM *xim, XIC *xic) bool x11_get_metrics(void *data, enum display_metric_types type, float *value) { - int pixels_x, pixels_y, physical_width, physical_height; unsigned screen_no = 0; Display *dpy = (Display*)XOpenDisplay(NULL); - pixels_x = DisplayWidth(dpy, screen_no); - pixels_y = DisplayHeight(dpy, screen_no); - physical_width = DisplayWidthMM(dpy, screen_no); - physical_height = DisplayHeightMM(dpy, screen_no); + int pixels_x = DisplayWidth(dpy, screen_no); + int pixels_y = DisplayHeight(dpy, screen_no); + int physical_width = DisplayWidthMM(dpy, screen_no); + int physical_height = DisplayHeightMM(dpy, screen_no); (void)pixels_y; From f87dbe7946521ed6819a015b3bd15e3b3582bd48 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 14 Sep 2016 15:58:03 +0200 Subject: [PATCH 061/334] Style nits/cleanups --- gfx/common/x11_common.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 5758bc37ef..0598f842ba 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -84,11 +84,11 @@ static void dbus_get_connection(void) static void dbus_close_connection(void) { - if (dbus_connection != NULL) - { - dbus_connection_close(dbus_connection); - dbus_connection_unref(dbus_connection); - } + if (!dbus_connection) + return; + + dbus_connection_close(dbus_connection); + dbus_connection_unref(dbus_connection); } static void dbus_screensaver_inhibit(void) @@ -109,12 +109,10 @@ static void dbus_screensaver_inhibit(void) "Inhibit"); if (msg != NULL) - { dbus_message_append_args(msg, DBUS_TYPE_STRING, &app, DBUS_TYPE_STRING, &reason, DBUS_TYPE_INVALID); - } if (msg != NULL) { @@ -225,13 +223,13 @@ void x11_windowed_fullscreen(Display *dpy, Window win) XA_INIT(_NET_WM_STATE); XA_INIT(_NET_WM_STATE_FULLSCREEN); - xev.xclient.type = ClientMessage; - xev.xclient.send_event = True; + xev.xclient.type = ClientMessage; + xev.xclient.send_event = True; xev.xclient.message_type = XA_NET_WM_STATE; - xev.xclient.window = win; - xev.xclient.format = 32; - xev.xclient.data.l[0] = _NET_WM_STATE_ADD; - xev.xclient.data.l[1] = XA_NET_WM_STATE_FULLSCREEN; + xev.xclient.window = win; + xev.xclient.format = 32; + xev.xclient.data.l[0] = _NET_WM_STATE_ADD; + xev.xclient.data.l[1] = XA_NET_WM_STATE_FULLSCREEN; XSendEvent(dpy, DefaultRootWindow(dpy), False, SubstructureRedirectMask | SubstructureNotifyMask, @@ -672,7 +670,7 @@ bool x11_connect(void) } #ifdef HAVE_DBUS - dbus_get_connection(); + dbus_get_connection(); #endif From 1b46f3c344dd8d288cd3957e8d6525c2cb67d41a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 14 Sep 2016 15:58:53 +0200 Subject: [PATCH 062/334] Nits --- gfx/common/x11_common.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 0598f842ba..da37cbb681 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -93,9 +93,10 @@ static void dbus_close_connection(void) static void dbus_screensaver_inhibit(void) { - const char *app = "RetroArch"; + const char *app = "RetroArch"; const char *reason = "Playing a game"; - DBusMessage *msg, *reply; + DBusMessage *msg = NULL; + DBusMessage *reply = NULL; if (dbus_connection == NULL) return; /* DBus connection was not obtained */ @@ -277,7 +278,7 @@ void x11_set_window_attr(Display *dpy, Window win) static void x11_suspend_screensaver_xdg_screensaver(Window wnd, bool enable) { int ret; - char cmd[64] = {0}; + char cmd[64] = {0}; static bool screensaver_na = false; if (!enable) From b1a2e096e5ae3c88776ad73fe5fb345abe1f0672 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Wed, 14 Sep 2016 10:03:26 -0400 Subject: [PATCH 063/334] Use consistent quotes in Netplay README. --- network/netplay/README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/network/netplay/README b/network/netplay/README index f0eca64749..5977cf63ab 100644 --- a/network/netplay/README +++ b/network/netplay/README @@ -11,8 +11,8 @@ Furthermore, if the core supports serialization (save states), Netplay allows for latency and clock drift, providing both host and client with a smooth experience. -Note that this documentation is all for (the poorly-named) “net” mode, which is -the normal mode, and not “spectator” mode, which has its own whole host of +Note that this documentation is all for (the poorly-named) "net" mode, which is +the normal mode, and not "spectator" mode, which has its own whole host of problems. Netplay in RetroArch works by expecting input to come delayed from the network, From 9bc78d25a0ce248f44363a12699e80e814290a4c Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Wed, 14 Sep 2016 10:06:57 -0400 Subject: [PATCH 064/334] Minor stylistic fixes for clarity and consistency with the rest of RetroArch. --- network/netplay/netplay.c | 4 +++- network/netplay/netplay_net.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index f56da9fd34..6fc49d4c72 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -378,7 +378,7 @@ static void simulate_input(netplay_t *netplay) sizeof(netplay->buffer[prev].real_input_state)); } -#define MAX_STALL_TIME_USEC 10000000 +#define MAX_STALL_TIME_USEC (10*1000*1000) /** * netplay_poll: @@ -521,7 +521,9 @@ static int16_t netplay_input_state(netplay_t *netplay, curr_input_state = netplay->buffer[ptr].real_input_state; } else + { curr_input_state = netplay->buffer[ptr].simulated_input_state; + } } switch (device) diff --git a/network/netplay/netplay_net.c b/network/netplay/netplay_net.c index a6d872734b..ee9a13c5df 100644 --- a/network/netplay/netplay_net.c +++ b/network/netplay/netplay_net.c @@ -127,7 +127,9 @@ static void netplay_net_post_frame(netplay_t *netplay) { netplay->other_ptr = netplay->read_ptr; netplay->other_frame_count = netplay->read_frame_count; - } else { + } + else + { netplay->other_ptr = netplay->self_ptr; netplay->other_frame_count = netplay->self_frame_count; } From b380977421344b40c54610d9dfc61900f9978f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Su=C3=A1rez?= Date: Wed, 14 Sep 2016 10:42:15 -0500 Subject: [PATCH 065/334] Update proto.js --- pkg/emscripten/proto.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/emscripten/proto.js b/pkg/emscripten/proto.js index 58fe7357b8..bcaf5bc12d 100644 --- a/pkg/emscripten/proto.js +++ b/pkg/emscripten/proto.js @@ -128,11 +128,11 @@ function setupFileSystem(backend) /* mount the filesystems onto mfs */ mfs.mount('/home/web_user/retroarch/userdata', lsfs); - /* create a memory filesystem for content only */ - var imfs = new BrowserFS.FileSystem.InMemory(); + /* create a memory filesystem for content only + var imfs = new BrowserFS.FileSystem.InMemory();*/ - /* mount the filesystems onto mfs */ - mfs.mount('/home/web_user/retroarch/userdata/content/', imfs); + /* mount the filesystems onto mfs + mfs.mount('/home/web_user/retroarch/userdata/content/', imfs);*/ } else { @@ -400,4 +400,4 @@ kp = function(k, event) { document.dispatchEvent(oEvent); document.getElementById('canvas').focus(); -} \ No newline at end of file +} From 35f34970338aaec90d776429a5cbf68210895664 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Wed, 14 Sep 2016 18:35:56 +0200 Subject: [PATCH 066/334] Revert "(Emscripten) Show/Hide the console" --- pkg/emscripten/proto.html | 7 +------ pkg/emscripten/proto.js | 7 ------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/pkg/emscripten/proto.html b/pkg/emscripten/proto.html index 826df7d335..6d6b683932 100644 --- a/pkg/emscripten/proto.html +++ b/pkg/emscripten/proto.html @@ -114,7 +114,7 @@
-
+
-
- -
diff --git a/pkg/emscripten/proto.js b/pkg/emscripten/proto.js index bcaf5bc12d..72091f9d23 100644 --- a/pkg/emscripten/proto.js +++ b/pkg/emscripten/proto.js @@ -280,13 +280,6 @@ function switchStorage(backend) { // When the browser has loaded everything. $(function() { - - // Hide the logging window and allow the user to show it. - $('#output').hide(); - $('#btnlogs').click(function () { - $('#output').slideToggle(); - }); - /** * Attempt to disable some default browser keys. */ From a5644d61dbcb0edd6b7d8b9f3d7597fddd5fc9da Mon Sep 17 00:00:00 2001 From: orbea Date: Wed, 14 Sep 2016 09:43:30 -0700 Subject: [PATCH 067/334] Disable dbus by default --- qb/config.params.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/qb/config.params.sh b/qb/config.params.sh index 32d6ef0090..35bee06001 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -11,6 +11,7 @@ HAVE_SDL2=auto # SDL2 support (disables SDL 1.x) C89_SDL2=no HAVE_LIBUSB=auto # Libusb HID support C89_LIBUSB=no +HAVE_DBUS=no # dbus support HAVE_UDEV=auto # Udev/Evdev gamepad support HAVE_LIBRETRO= # Libretro library used HAVE_ASSETS_DIR= # Assets install directory From 7d5b9f172aee68840c0a56e2d4679bce2002ca06 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 14 Sep 2016 22:46:29 +0200 Subject: [PATCH 068/334] Cleanups --- gfx/video_driver.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 8c64ab73fc..5f3767e06b 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -1712,8 +1712,7 @@ bool video_driver_is_alive(void) { if (current_video) return current_video->alive(video_driver_data); - else - return true; + return true; } bool video_driver_is_focused(void) @@ -2153,9 +2152,7 @@ void video_driver_frame(const void *data, unsigned width, video_driver_data, data, width, height, video_driver_frame_count, pitch, video_driver_msg)) - { video_driver_unset_active(); - } video_driver_frame_count++; } From 9ee5931c5e54c2bd84a4ab43346b5a7f6b54658e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 14 Sep 2016 23:37:20 +0200 Subject: [PATCH 069/334] Nits --- input/drivers_hid/iohidmanager_hid.c | 38 +++++++++++++--------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/input/drivers_hid/iohidmanager_hid.c b/input/drivers_hid/iohidmanager_hid.c index ef7ab25035..9fa5341181 100644 --- a/input/drivers_hid/iohidmanager_hid.c +++ b/input/drivers_hid/iohidmanager_hid.c @@ -187,15 +187,17 @@ static void iohidmanager_hid_device_input_callback(void *data, IOReturn result, default: { int i; - // +0/-0 => Left Stick Horizontal => 48 - // +1/-1 => Left Stick Vertical => 49 - // +2/-2 => Right Stick Horizontal => 51 - // +3/-3 => Right Stick Vertical => 52 - // +4/-4 => Left Trigger (if exists) => 50 - // +5/-5 => Right Trigger (if exists) => 53 static const uint32_t axis_use_ids[6] = { 48, 49, 51, 52, 50, 53 }; + /* +0/-0 => Left Stick Horizontal => 48 + * +1/-1 => Left Stick Vertical => 49 + * +2/-2 => Right Stick Horizontal => 51 + * +3/-3 => Right Stick Vertical => 52 + * +4/-4 => Left Trigger (if exists) => 50 + * +5/-5 => Right Trigger (if exists) => 53 + */ + for (i = 0; i < 6; i ++) { CFIndex min = IOHIDElementGetPhysicalMin(element); @@ -262,13 +264,10 @@ static int32_t iohidmanager_hid_device_get_int_property( int32_t value; CFNumberRef ref = (CFNumberRef)IOHIDDeviceGetProperty(device, key); - if (ref) + if (ref && (CFGetTypeID(ref) == CFNumberGetTypeID())) { - if (CFGetTypeID(ref) == CFNumberGetTypeID()) - { - CFNumberGetValue((CFNumberRef)ref, kCFNumberIntType, &value); - return value; - } + CFNumberGetValue((CFNumberRef)ref, kCFNumberIntType, &value); + return value; } return 0; @@ -410,15 +409,13 @@ static int iohidmanager_hid_manager_init(iohidmanager_hid_t *hid) hid->ptr = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); - if (hid->ptr) - { - IOHIDManagerSetDeviceMatching(hid->ptr, NULL); - IOHIDManagerScheduleWithRunLoop(hid->ptr, CFRunLoopGetCurrent(), - kCFRunLoopDefaultMode); - return 0; - } + if (!hid->ptr) + return -1; - return -1; + IOHIDManagerSetDeviceMatching(hid->ptr, NULL); + IOHIDManagerScheduleWithRunLoop(hid->ptr, CFRunLoopGetCurrent(), + kCFRunLoopDefaultMode); + return 0; } @@ -469,6 +466,7 @@ static void *iohidmanager_hid_init(void) if (!hid_apple) goto error; hid_apple->slots = pad_connection_init(MAX_USERS); + if (!hid_apple->slots) goto error; if (iohidmanager_hid_manager_init(hid_apple) == -1) From 4c2d754b06ab7b92b959ccec86a27fadd0b5c3ed Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 14 Sep 2016 23:44:49 +0200 Subject: [PATCH 070/334] (Zarch) Nits --- menu/drivers/zarch.c | 58 +++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 059e7fb714..80b2c18488 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -173,36 +173,34 @@ static float zarch_zui_strwidth(void *fb_buf, const char *text, float scale) return font_driver_get_message_width(fb_buf, text, strlen(text), scale); } - static int16_t zarch_zui_input_state(zui_t *zui, enum zarch_zui_input_state state) { - switch (state) - { - case MENU_ZARCH_MOUSE_X: - return menu_input_mouse_state(MENU_MOUSE_X_AXIS); - case MENU_ZARCH_MOUSE_Y: - return menu_input_mouse_state(MENU_MOUSE_Y_AXIS); - case MENU_POINTER_ZARCH_X: - return menu_input_pointer_state(MENU_POINTER_X_AXIS); - case MENU_POINTER_ZARCH_Y: - return menu_input_pointer_state(MENU_POINTER_Y_AXIS); - case MENU_ZARCH_PRESSED: - if ( menu_input_mouse_state(MENU_MOUSE_LEFT_BUTTON) - || menu_input_pointer_state(MENU_POINTER_PRESSED)) - return 1; - if (zui->action == MENU_ACTION_OK) - return 1; - break; - } - - return 0; + switch (state) + { + case MENU_ZARCH_MOUSE_X: + return menu_input_mouse_state(MENU_MOUSE_X_AXIS); + case MENU_ZARCH_MOUSE_Y: + return menu_input_mouse_state(MENU_MOUSE_Y_AXIS); + case MENU_POINTER_ZARCH_X: + return menu_input_pointer_state(MENU_POINTER_X_AXIS); + case MENU_POINTER_ZARCH_Y: + return menu_input_pointer_state(MENU_POINTER_Y_AXIS); + case MENU_ZARCH_PRESSED: + if ( menu_input_mouse_state(MENU_MOUSE_LEFT_BUTTON) + || menu_input_pointer_state(MENU_POINTER_PRESSED)) + return 1; + if (zui->action == MENU_ACTION_OK) + return 1; + break; + } + + return 0; } static bool zarch_zui_check_button_down(zui_t *zui, unsigned id, int x1, int y1, int x2, int y2) { menu_input_ctx_hitbox_t hitbox; - bool result = false; hitbox.x1 = x1; hitbox.x2 = x2; @@ -215,11 +213,11 @@ static bool zarch_zui_check_button_down(zui_t *zui, if ( zui->item.hot == id && zarch_zui_input_state(zui, MENU_ZARCH_PRESSED)) { - result = true; zui->item.active = id; + return true; } - return result; + return false; } static bool zarch_zui_check_button_up(zui_t *zui, @@ -328,9 +326,7 @@ static bool zarch_zui_list_item(zui_t *zui, struct zui_tabbed *tab, int x1, int frame_count = video_driver_get_frame_count_ptr(); if (tab->active_id != tab->prev_id) - { tab->prev_id = tab->active_id; - } if (selected) { @@ -398,9 +394,7 @@ static bool zarch_zui_tab(zui_t *zui, struct zui_tabbed *tab, if (zui->item.active == id || tab->active_id == ~0U || !tab->inited) tab->active_id = id; else if (id > tab->active_id) - { tab->next_id = id; - } if (!tab->inited) tab->inited = true; @@ -850,9 +844,7 @@ static void zarch_frame(void *data) menu_display_ctx_coord_draw_t coord_draw; settings_t *settings = config_get_ptr(); zui_t *zui = (zui_t*)data; - video_coord_array_t *ca = NULL; - - ca = menu_display_get_coords_array(); + video_coord_array_t *ca = menu_display_get_coords_array(); if (!zui) return; @@ -1127,8 +1119,8 @@ static int zarch_iterate(void *data, void *userdata, enum menu_action action) static bool zarch_menu_init_list(void *data) { menu_displaylist_info_t info = {0}; - file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); - file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); + file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); + file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); strlcpy(info.label, msg_hash_to_str(MENU_ENUM_LABEL_HISTORY_TAB), sizeof(info.label)); From 1a40ace1ac41b64189433b830dbc4b301293f8d0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 14 Sep 2016 23:47:18 +0200 Subject: [PATCH 071/334] Cleanup --- menu/drivers/zarch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 80b2c18488..61559c37c7 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -166,7 +166,7 @@ struct zui_tabbed }; -static enum zarch_layout_type zarch_layout; +static enum zarch_layout_type zarch_layout = LAY_HOME; static float zarch_zui_strwidth(void *fb_buf, const char *text, float scale) { From 892c0a6f5214b3c033af7742ea18cc0eb9e4a510 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 00:10:37 +0200 Subject: [PATCH 072/334] Create menu/widgets/menu_list --- Makefile.common | 1 + griffin/griffin.c | 1 + menu/cbs/menu_cbs_left.c | 2 + menu/cbs/menu_cbs_right.c | 2 + menu/drivers/xmb.c | 2 + menu/menu_displaylist.c | 1 + menu/menu_driver.c | 1 + menu/menu_driver.h | 14 ---- menu/menu_entries.c | 119 ++++----------------------------- menu/menu_entries.h | 3 - menu/widgets/menu_list.c | 134 ++++++++++++++++++++++++++++++++++++++ menu/widgets/menu_list.h | 62 ++++++++++++++++++ 12 files changed, 219 insertions(+), 123 deletions(-) create mode 100644 menu/widgets/menu_list.c create mode 100644 menu/widgets/menu_list.h diff --git a/Makefile.common b/Makefile.common index 262f92cc68..b18a87f367 100644 --- a/Makefile.common +++ b/Makefile.common @@ -511,6 +511,7 @@ ifeq ($(HAVE_MENU_COMMON), 1) menu/menu_setting.o \ menu/menu_shader.o \ menu/widgets/menu_popup.o \ + menu/widgets/menu_list.o \ menu/menu_cbs.o \ menu/cbs/menu_cbs_ok.o \ menu/cbs/menu_cbs_cancel.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index 871467abfd..ecff6a10c5 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -894,6 +894,7 @@ MENU #include "../menu/menu_cbs.c" #include "../menu/menu_content.c" #include "../menu/widgets/menu_popup.c" +#include "../menu/widgets/menu_list.c" #include "../menu/cbs/menu_cbs_ok.c" #include "../menu/cbs/menu_cbs_cancel.c" #include "../menu/cbs/menu_cbs_select.c" diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 4312602f51..299149ff05 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -30,6 +30,8 @@ #include "../menu_shader.h" #include "../menu_navigation.h" +#include "../widgets/menu_list.h" + #include "../../configuration.h" #include "../../core.h" #include "../../core_info.h" diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 47b252569a..1bf35e2d85 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -30,6 +30,8 @@ #include "../menu_shader.h" #include "../menu_navigation.h" +#include "../widgets/menu_list.h" + #include "../../configuration.h" #include "../../core.h" #include "../../core_info.h" diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index a5efe33358..13172bee3a 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -42,6 +42,8 @@ #include "../menu_display.h" #include "../menu_navigation.h" +#include "../widgets/menu_list.h" + #include "../menu_cbs.h" #include "../../frontend/frontend_driver.h" diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 7a876f2f1d..9f53dad062 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -45,6 +45,7 @@ #include "menu_driver.h" #include "menu_navigation.h" #include "widgets/menu_popup.h" +#include "widgets/menu_list.h" #include "menu_cbs.h" #include "../configuration.h" diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 75ed0853bd..23bb3507c7 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -30,6 +30,7 @@ #include "menu_display.h" #include "menu_navigation.h" #include "widgets/menu_popup.h" +#include "widgets/menu_list.h" #include "menu_shader.h" #include "../config.def.h" diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 33f277156c..21a0ea83a5 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -284,20 +284,6 @@ typedef struct menu_ctx_load_image enum menu_image_type type; } menu_ctx_load_image_t; -typedef struct menu_ctx_list -{ - file_list_t *list; - size_t list_size; - const char *path; - const char *label; - size_t idx; - enum menu_list_type type; - unsigned action; - size_t selection; - size_t size; - void *entry; -} menu_ctx_list_t; - typedef struct menu_ctx_displaylist { menu_displaylist_info_t *info; diff --git a/menu/menu_entries.c b/menu/menu_entries.c index a44d7c1a69..7db963b2d5 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -24,107 +24,13 @@ #include "menu_cbs.h" #include "menu_navigation.h" +#include "widgets/menu_list.h" + #include "../core.h" #include "../configuration.h" #include "../runloop.h" #include "../version.h" -struct menu_list -{ - file_list_t **menu_stack; - size_t menu_stack_size; - file_list_t **selection_buf; - size_t selection_buf_size; -}; - -static void menu_list_free_list(file_list_t *list) -{ - unsigned i; - - for (i = 0; i < list->size; i++) - { - menu_ctx_list_t list_info; - - list_info.list = list; - list_info.idx = i; - list_info.list_size = list->size; - - menu_driver_ctl(RARCH_MENU_CTL_LIST_FREE, &list_info); - } - - file_list_free(list); -} - -static void menu_list_free(menu_list_t *menu_list) -{ - unsigned i; - if (!menu_list) - return; - - for (i = 0; i < menu_list->menu_stack_size; i++) - { - if (!menu_list->menu_stack[i]) - continue; - - menu_list_free_list(menu_list->menu_stack[i]); - menu_list->menu_stack[i] = NULL; - } - for (i = 0; i < menu_list->selection_buf_size; i++) - { - if (!menu_list->selection_buf[i]) - continue; - - menu_list_free_list(menu_list->selection_buf[i]); - menu_list->selection_buf[i] = NULL; - } - - free(menu_list->menu_stack); - free(menu_list->selection_buf); - - free(menu_list); -} - -static menu_list_t *menu_list_new(void) -{ - unsigned i; - menu_list_t *list = (menu_list_t*)calloc(1, sizeof(*list)); - - if (!list) - return NULL; - - list->menu_stack = (file_list_t**)calloc(1, sizeof(*list->menu_stack)); - - if (!list->menu_stack) - goto error; - - list->selection_buf = (file_list_t**)calloc(1, sizeof(*list->selection_buf)); - - if (!list->selection_buf) - goto error; - - list->menu_stack_size = 1; - list->selection_buf_size = 1; - - for (i = 0; i < list->menu_stack_size; i++) - list->menu_stack[i] = (file_list_t*)calloc(1, sizeof(*list->menu_stack[i])); - - for (i = 0; i < list->selection_buf_size; i++) - list->selection_buf[i] = (file_list_t*)calloc(1, sizeof(*list->selection_buf[i])); - - return list; - -error: - menu_list_free(list); - return NULL; -} - -static size_t menu_list_get_stack_size(menu_list_t *list, size_t idx) -{ - if (!list) - return 0; - return file_list_get_size(list->menu_stack[idx]); -} - void menu_entries_get_at_offset(const file_list_t *list, size_t idx, const char **path, const char **label, unsigned *file_type, size_t *entry_idx, const char **alt) @@ -168,12 +74,10 @@ static bool menu_list_pop_stack(menu_list_t *list, { menu_ctx_list_t list_info; bool refresh = false; - file_list_t *menu_list = NULL; + file_list_t *menu_list = menu_list_get(list, idx); if (!list) return false; - menu_list = list->menu_stack[idx]; - if (menu_list_get_stack_size(list, idx) <= 1) return false; @@ -210,11 +114,12 @@ static void menu_list_flush_stack(menu_list_t *list, const char *label = NULL; unsigned type = 0; size_t entry_idx = 0; + file_list_t *menu_list = menu_list_get(list, idx); if (!list) return; menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); - menu_entries_get_last(list->menu_stack[idx], + menu_entries_get_last(menu_list, &path, &label, &type, &entry_idx); while (menu_entries_flush_stack_type( @@ -231,7 +136,9 @@ static void menu_list_flush_stack(menu_list_t *list, menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &new_selection_ptr); - menu_entries_get_last(list->menu_stack[idx], + menu_list = menu_list_get(list, idx); + + menu_entries_get_last(menu_list, &path, &label, &type, &entry_idx); } } @@ -479,7 +386,7 @@ file_list_t *menu_entries_get_menu_stack_ptr(size_t idx) menu_entries_ctl(MENU_ENTRIES_CTL_LIST_GET, &menu_list); if (!menu_list) return NULL; - return menu_list->menu_stack[idx]; + return menu_list_get(menu_list, idx); } file_list_t *menu_entries_get_selection_buf_ptr(size_t idx) @@ -488,7 +395,7 @@ file_list_t *menu_entries_get_selection_buf_ptr(size_t idx) menu_entries_ctl(MENU_ENTRIES_CTL_LIST_GET, &menu_list); if (!menu_list) return NULL; - return menu_list->selection_buf[idx]; + return menu_list_get_selection(menu_list, idx); } static bool menu_entries_init(void) @@ -622,7 +529,7 @@ menu_file_list_cbs_t *menu_entries_get_last_stack_actiondata(void) if (!menu_list) return NULL; return (menu_file_list_cbs_t*)file_list_get_last_actiondata( - menu_list->menu_stack[0]); + menu_list_get(menu_list, 0)); } void menu_entries_get_last_stack(const char **path, const char **label, @@ -634,7 +541,7 @@ void menu_entries_get_last_stack(const char **path, const char **label, if (!menu_list) return; - menu_entries_get_last(menu_list->menu_stack[0], + menu_entries_get_last(menu_list_get(menu_list, 0), path, label, file_type, entry_idx); cbs = menu_entries_get_last_stack_actiondata(); if (cbs) @@ -672,7 +579,7 @@ size_t menu_entries_get_size(void) menu_entries_ctl(MENU_ENTRIES_CTL_LIST_GET, &menu_list); if (!menu_list) return 0; - return file_list_get_size(menu_list->selection_buf[0]); + return file_list_get_size(menu_list_get_selection(menu_list, 0)); } rarch_setting_t *menu_entries_get_setting(uint32_t i) diff --git a/menu/menu_entries.h b/menu/menu_entries.h index d1a4a1cb5b..f2ae7f0ab3 100644 --- a/menu/menu_entries.h +++ b/menu/menu_entries.h @@ -130,9 +130,6 @@ typedef struct menu_file_list_cbs } menu_file_list_cbs_t; - -typedef struct menu_list menu_list_t; - size_t menu_entries_get_end(void); void menu_entries_get(size_t i, menu_entry_t *entry); diff --git a/menu/widgets/menu_list.c b/menu/widgets/menu_list.c new file mode 100644 index 0000000000..c2a6d0b34d --- /dev/null +++ b/menu/widgets/menu_list.c @@ -0,0 +1,134 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2011-2016 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include + +#include +#include +#include + +#include "menu_list.h" + +#include "../menu_driver.h" + +struct menu_list +{ + file_list_t **menu_stack; + size_t menu_stack_size; + file_list_t **selection_buf; + size_t selection_buf_size; +}; + +void menu_list_free_list(file_list_t *list) +{ + unsigned i; + + for (i = 0; i < list->size; i++) + { + menu_ctx_list_t list_info; + + list_info.list = list; + list_info.idx = i; + list_info.list_size = list->size; + + menu_driver_ctl(RARCH_MENU_CTL_LIST_FREE, &list_info); + } + + file_list_free(list); +} + +void menu_list_free(menu_list_t *menu_list) +{ + unsigned i; + if (!menu_list) + return; + + for (i = 0; i < menu_list->menu_stack_size; i++) + { + if (!menu_list->menu_stack[i]) + continue; + + menu_list_free_list(menu_list->menu_stack[i]); + menu_list->menu_stack[i] = NULL; + } + for (i = 0; i < menu_list->selection_buf_size; i++) + { + if (!menu_list->selection_buf[i]) + continue; + + menu_list_free_list(menu_list->selection_buf[i]); + menu_list->selection_buf[i] = NULL; + } + + free(menu_list->menu_stack); + free(menu_list->selection_buf); + + free(menu_list); +} + +menu_list_t *menu_list_new(void) +{ + unsigned i; + menu_list_t *list = (menu_list_t*)calloc(1, sizeof(*list)); + + if (!list) + return NULL; + + list->menu_stack = (file_list_t**)calloc(1, sizeof(*list->menu_stack)); + + if (!list->menu_stack) + goto error; + + list->selection_buf = (file_list_t**)calloc(1, sizeof(*list->selection_buf)); + + if (!list->selection_buf) + goto error; + + list->menu_stack_size = 1; + list->selection_buf_size = 1; + + for (i = 0; i < list->menu_stack_size; i++) + list->menu_stack[i] = (file_list_t*)calloc(1, sizeof(*list->menu_stack[i])); + + for (i = 0; i < list->selection_buf_size; i++) + list->selection_buf[i] = (file_list_t*)calloc(1, sizeof(*list->selection_buf[i])); + + return list; + +error: + menu_list_free(list); + return NULL; +} + +file_list_t *menu_list_get(menu_list_t *list, unsigned idx) +{ + if (!list) + return NULL; + return list->menu_stack[idx]; +} + +file_list_t *menu_list_get_selection(menu_list_t *list, unsigned idx) +{ + if (!list) + return NULL; + return list->selection_buf[idx]; +} + +size_t menu_list_get_stack_size(menu_list_t *list, size_t idx) +{ + if (!list) + return 0; + return file_list_get_size(list->menu_stack[idx]); +} diff --git a/menu/widgets/menu_list.h b/menu/widgets/menu_list.h new file mode 100644 index 0000000000..e47ea87ce6 --- /dev/null +++ b/menu/widgets/menu_list.h @@ -0,0 +1,62 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2016 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#ifndef _MENU_WIDGETS_LIST_H +#define _MENU_WIDGETS_LIST_H + +#include +#include + +#include + +#include +#include + +#include "../menu_entries.h" + +RETRO_BEGIN_DECLS + +typedef struct menu_ctx_list +{ + file_list_t *list; + size_t list_size; + const char *path; + const char *label; + size_t idx; + enum menu_list_type type; + unsigned action; + size_t selection; + size_t size; + void *entry; +} menu_ctx_list_t; + +typedef struct menu_list menu_list_t; + +void menu_list_free_list(file_list_t *list); + +void menu_list_free(menu_list_t *menu_list); + +menu_list_t *menu_list_new(void); + +file_list_t *menu_list_get(menu_list_t *list, unsigned idx); + +file_list_t *menu_list_get_selection(menu_list_t *list, unsigned idx); + +size_t menu_list_get_stack_size(menu_list_t *list, size_t idx); + +RETRO_END_DECLS + +#endif From a8f407ac33cc00c45ab707b34a08e1d92d828197 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 00:11:49 +0200 Subject: [PATCH 073/334] Header include cleanups --- menu/menu_entry.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/menu/menu_entry.c b/menu/menu_entry.c index 10909da6be..c9ad9f4949 100644 --- a/menu/menu_entry.c +++ b/menu/menu_entry.c @@ -19,11 +19,8 @@ #include #include "menu_driver.h" -#include "menu_display.h" #include "menu_navigation.h" -#include "../setting_list.h" - /* This file provides an abstraction of the currently displayed * menu. * From 02e01e0b0a5c6ca04cc781b1fd8ecb227c4c9c3f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 00:20:43 +0200 Subject: [PATCH 074/334] Create menu/widgets/menu_entry --- Makefile.common | 2 +- griffin/griffin.c | 2 +- menu/cbs/menu_cbs_scan.c | 1 - menu/cbs/menu_cbs_select.c | 2 +- menu/drivers/xmb.c | 2 +- menu/drivers/xui.cpp | 2 +- menu/drivers/zarch.c | 2 +- menu/menu_displaylist.h | 1 + menu/menu_driver.h | 2 ++ menu/menu_entries.c | 5 +++-- menu/menu_entries.h | 3 +-- menu/menu_input.c | 2 +- menu/{ => widgets}/menu_entry.c | 4 ++-- menu/{ => widgets}/menu_entry.h | 4 +++- 14 files changed, 19 insertions(+), 15 deletions(-) rename menu/{ => widgets}/menu_entry.c (99%) rename menu/{ => widgets}/menu_entry.h (98%) diff --git a/Makefile.common b/Makefile.common index b18a87f367..17091118c3 100644 --- a/Makefile.common +++ b/Makefile.common @@ -505,12 +505,12 @@ ifeq ($(HAVE_MENU_COMMON), 1) OBJ += menu/menu_driver.o \ menu/menu_content.o \ menu/menu_input.o \ - menu/menu_entry.o \ menu/menu_entries.o \ menu/menu_navigation.o \ menu/menu_setting.o \ menu/menu_shader.o \ menu/widgets/menu_popup.o \ + menu/widgets/menu_entry.o \ menu/widgets/menu_list.o \ menu/menu_cbs.o \ menu/cbs/menu_cbs_ok.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index ecff6a10c5..74839e79c3 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -888,11 +888,11 @@ MENU #ifdef HAVE_MENU #include "../menu/menu_driver.c" #include "../menu/menu_input.c" -#include "../menu/menu_entry.c" #include "../menu/menu_entries.c" #include "../menu/menu_setting.c" #include "../menu/menu_cbs.c" #include "../menu/menu_content.c" +#include "../menu/widgets/menu_entry.c" #include "../menu/widgets/menu_popup.c" #include "../menu/widgets/menu_list.c" #include "../menu/cbs/menu_cbs_ok.c" diff --git a/menu/cbs/menu_cbs_scan.c b/menu/cbs/menu_cbs_scan.c index 844b4292ad..d47da9047f 100644 --- a/menu/cbs/menu_cbs_scan.c +++ b/menu/cbs/menu_cbs_scan.c @@ -22,7 +22,6 @@ #include "../menu_driver.h" #include "../menu_cbs.h" -#include "../menu_entry.h" #include "../menu_setting.h" #include "../../configuration.h" diff --git a/menu/cbs/menu_cbs_select.c b/menu/cbs/menu_cbs_select.c index bb85faa76f..39c06eff57 100644 --- a/menu/cbs/menu_cbs_select.c +++ b/menu/cbs/menu_cbs_select.c @@ -20,7 +20,7 @@ #endif #include "../menu_driver.h" -#include "../menu_entry.h" +#include "../widgets/menu_entry.h" #include "../menu_cbs.h" #include "../menu_setting.h" diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 13172bee3a..67eabc1d88 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -36,7 +36,7 @@ #include "menu_generic.h" #include "../menu_driver.h" -#include "../menu_entry.h" +#include "../widgets/menu_entry.h" #include "../menu_animation.h" #include "../menu_display.h" #include "../menu_display.h" diff --git a/menu/drivers/xui.cpp b/menu/drivers/xui.cpp index 50c3c7ee62..eab675ffe3 100644 --- a/menu/drivers/xui.cpp +++ b/menu/drivers/xui.cpp @@ -32,7 +32,7 @@ #include "../menu_driver.h" #include "../menu_animation.h" -#include "../menu_entry.h" +#include "../widgets/menu_entry.h" #include "../menu_entries.h" #include "../menu_input.h" #include "../menu_navigation.h" diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 61559c37c7..ebbe6ba753 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -41,7 +41,7 @@ #include "../menu_driver.h" #include "../menu_animation.h" -#include "../menu_entry.h" +#include "../widgets/menu_entry.h" #include "../menu_display.h" #include "../menu_navigation.h" #include "../../retroarch.h" diff --git a/menu/menu_displaylist.h b/menu/menu_displaylist.h index 452481a657..3359d8dfc5 100644 --- a/menu/menu_displaylist.h +++ b/menu/menu_displaylist.h @@ -19,6 +19,7 @@ #include #include +#include #include #include diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 21a0ea83a5..3b85383e12 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -26,6 +26,8 @@ #include #include +#include "widgets/menu_entry.h" +#include "menu_input.h" #include "menu_entries.h" #include "../gfx/video_shader_driver.h" diff --git a/menu/menu_entries.c b/menu/menu_entries.c index 7db963b2d5..3dbdbf38bf 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -292,14 +292,15 @@ size_t menu_entries_get_end(void) } /* Get an entry from the top of the menu stack */ -void menu_entries_get(size_t i, menu_entry_t *entry) +void menu_entries_get(size_t i, void *entry_data) { const char *label = NULL; const char *path = NULL; const char *entry_label = NULL; menu_file_list_cbs_t *cbs = NULL; enum msg_hash_enums enum_idx = MSG_UNKNOWN; - file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); + menu_entry_t *entry = (menu_entry_t*)entry_data; + file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); menu_entries_get_last_stack(NULL, &label, NULL, &enum_idx, NULL); diff --git a/menu/menu_entries.h b/menu/menu_entries.h index f2ae7f0ab3..bfb5daa565 100644 --- a/menu/menu_entries.h +++ b/menu/menu_entries.h @@ -23,7 +23,6 @@ #include #include "menu_setting.h" -#include "menu_entry.h" #include "menu_displaylist.h" RETRO_BEGIN_DECLS @@ -132,7 +131,7 @@ typedef struct menu_file_list_cbs size_t menu_entries_get_end(void); -void menu_entries_get(size_t i, menu_entry_t *entry); +void menu_entries_get(size_t i, void *data_entry); int menu_entries_get_title(char *title, size_t title_len); diff --git a/menu/menu_input.c b/menu/menu_input.c index 15b1d53cd1..5a9e302469 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -39,7 +39,7 @@ #include "menu_input.h" #include "menu_animation.h" #include "menu_display.h" -#include "menu_entry.h" +#include "widgets/menu_entry.h" #include "menu_setting.h" #include "menu_shader.h" #include "menu_navigation.h" diff --git a/menu/menu_entry.c b/menu/widgets/menu_entry.c similarity index 99% rename from menu/menu_entry.c rename to menu/widgets/menu_entry.c index c9ad9f4949..39b5dc91fa 100644 --- a/menu/menu_entry.c +++ b/menu/widgets/menu_entry.c @@ -18,8 +18,8 @@ #include #include -#include "menu_driver.h" -#include "menu_navigation.h" +#include "../menu_driver.h" +#include "../menu_navigation.h" /* This file provides an abstraction of the currently displayed * menu. diff --git a/menu/menu_entry.h b/menu/widgets/menu_entry.h similarity index 98% rename from menu/menu_entry.h rename to menu/widgets/menu_entry.h index 7722b4eba0..8234d28134 100644 --- a/menu/menu_entry.h +++ b/menu/widgets/menu_entry.h @@ -22,7 +22,9 @@ #include #include -#include "menu_input.h" +#include "../../msg_hash.h" + +#include "../menu_input.h" RETRO_BEGIN_DECLS From ddccaeed8c1577cbddd300a99473f94a2e05d855 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Wed, 14 Sep 2016 18:33:52 -0400 Subject: [PATCH 075/334] (Emscripten) Print logs to the browser console --- pkg/emscripten/proto.html | 10 ---------- pkg/emscripten/proto.js | 22 +++------------------- 2 files changed, 3 insertions(+), 29 deletions(-) diff --git a/pkg/emscripten/proto.html b/pkg/emscripten/proto.html index 6d6b683932..abb5936ace 100644 --- a/pkg/emscripten/proto.html +++ b/pkg/emscripten/proto.html @@ -129,16 +129,6 @@
-
-
-
-
- -
-
- -
-

For now, we recommend you use Google Chrome for the best possible performance.

diff --git a/pkg/emscripten/proto.js b/pkg/emscripten/proto.js index 72091f9d23..63b941d1f5 100644 --- a/pkg/emscripten/proto.js +++ b/pkg/emscripten/proto.js @@ -239,25 +239,9 @@ var Module = arguments: ["-v", "--menu"], preRun: [], postRun: [], - print: (function() - { - var element = document.getElementById('output'); - element.value = ''; // clear browser cache - return function(text) - { - text = Array.prototype.slice.call(arguments).join(' '); - element.value += text + "\n"; - element.scrollTop = 99999; // focus on bottom - }; - })(), - - printErr: function(text) - { - var text = Array.prototype.slice.call(arguments).join(' '); - var element = document.getElementById('output'); - element.value += text + "\n"; - element.scrollTop = 99999; // focus on bottom - }, + // Print both stdout and stderr to the browser console. + print: console.log, + printErr: console.log, canvas: document.getElementById('canvas'), totalDependencies: 0, monitorRunDependencies: function(left) From f5ade35cc635083f55d1f9a278de0691dbbc57e2 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 14 Sep 2016 20:46:41 -0400 Subject: [PATCH 076/334] refresh rate should be 59.94 --- config.def.h | 2 +- retroarch.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config.def.h b/config.def.h index 74d841be25..3ff28986a5 100644 --- a/config.def.h +++ b/config.def.h @@ -653,7 +653,7 @@ static const float refresh_rate = (32730.0 * 8192.0) / 4481134.0 ; #elif defined(RARCH_CONSOLE) static const float refresh_rate = 60/1.001; #else -static const float refresh_rate = 59.95; +static const float refresh_rate = 59.94; #endif /* Allow games to set rotation. If false, rotation requests are diff --git a/retroarch.cfg b/retroarch.cfg index 8b57dc2b9c..0465931cbf 100644 --- a/retroarch.cfg +++ b/retroarch.cfg @@ -256,7 +256,7 @@ # Video refresh rate of your monitor. # Used to calculate a suitable audio input rate. -# video_refresh_rate = 59.95 +# video_refresh_rate = 59.94 # Allows libretro cores to set rotation modes. # Setting this to false will honor, but ignore this request. From fe4dbcb3f52786525bd77e885126ddbf139a6d40 Mon Sep 17 00:00:00 2001 From: nguillaumin Date: Wed, 14 Sep 2016 19:06:48 -0700 Subject: [PATCH 077/334] Fixes #2026: Make DBus dependency 'auto' to enable it by default Rationale copied from #2026: This DBus issue solves a real problem for users, and while I understand some people may not want the DBus dependency (but in that case, why have the lib on your system at all?) and agree it should be disablable, I think it should be enabled by default. One could argue other people doesn't want `xdg-screensaver` for various reasons, but that doesn't mean it should be disabled by default. I don't think we can really say one method is better over the other, there are arguments for and against both, so I believe doing both by default is a reasonable compromise. --- qb/config.params.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qb/config.params.sh b/qb/config.params.sh index 35bee06001..b510dec607 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -11,7 +11,7 @@ HAVE_SDL2=auto # SDL2 support (disables SDL 1.x) C89_SDL2=no HAVE_LIBUSB=auto # Libusb HID support C89_LIBUSB=no -HAVE_DBUS=no # dbus support +HAVE_DBUS=auto # dbus support HAVE_UDEV=auto # Udev/Evdev gamepad support HAVE_LIBRETRO= # Libretro library used HAVE_ASSETS_DIR= # Assets install directory From a3b4db2d638ba3e4d95eab347ca5bbb39af66469 Mon Sep 17 00:00:00 2001 From: radius Date: Wed, 14 Sep 2016 22:23:31 -0500 Subject: [PATCH 078/334] Revert "(Emscripten) Print logs to the browser console" Doesn't work on firefox or edge This reverts commit ddccaeed8c1577cbddd300a99473f94a2e05d855. --- pkg/emscripten/proto.html | 10 ++++++++++ pkg/emscripten/proto.js | 22 +++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/pkg/emscripten/proto.html b/pkg/emscripten/proto.html index abb5936ace..6d6b683932 100644 --- a/pkg/emscripten/proto.html +++ b/pkg/emscripten/proto.html @@ -129,6 +129,16 @@
+
+
+
+
+ +
+
+ +
+

For now, we recommend you use Google Chrome for the best possible performance.

diff --git a/pkg/emscripten/proto.js b/pkg/emscripten/proto.js index 63b941d1f5..72091f9d23 100644 --- a/pkg/emscripten/proto.js +++ b/pkg/emscripten/proto.js @@ -239,9 +239,25 @@ var Module = arguments: ["-v", "--menu"], preRun: [], postRun: [], - // Print both stdout and stderr to the browser console. - print: console.log, - printErr: console.log, + print: (function() + { + var element = document.getElementById('output'); + element.value = ''; // clear browser cache + return function(text) + { + text = Array.prototype.slice.call(arguments).join(' '); + element.value += text + "\n"; + element.scrollTop = 99999; // focus on bottom + }; + })(), + + printErr: function(text) + { + var text = Array.prototype.slice.call(arguments).join(' '); + var element = document.getElementById('output'); + element.value += text + "\n"; + element.scrollTop = 99999; // focus on bottom + }, canvas: document.getElementById('canvas'), totalDependencies: 0, monitorRunDependencies: function(left) From 8564a5b2663c62df57880eaaecd769aef55b533c Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Thu, 15 Sep 2016 00:43:40 -0400 Subject: [PATCH 079/334] Revert "Revert "(Emscripten) Print logs to the browser console"" This reverts commit a3b4db2d638ba3e4d95eab347ca5bbb39af66469. --- pkg/emscripten/proto.html | 10 ---------- pkg/emscripten/proto.js | 22 +++------------------- 2 files changed, 3 insertions(+), 29 deletions(-) diff --git a/pkg/emscripten/proto.html b/pkg/emscripten/proto.html index 6d6b683932..abb5936ace 100644 --- a/pkg/emscripten/proto.html +++ b/pkg/emscripten/proto.html @@ -129,16 +129,6 @@
-
-
-
-
- -
-
- -
-

For now, we recommend you use Google Chrome for the best possible performance.

diff --git a/pkg/emscripten/proto.js b/pkg/emscripten/proto.js index 72091f9d23..63b941d1f5 100644 --- a/pkg/emscripten/proto.js +++ b/pkg/emscripten/proto.js @@ -239,25 +239,9 @@ var Module = arguments: ["-v", "--menu"], preRun: [], postRun: [], - print: (function() - { - var element = document.getElementById('output'); - element.value = ''; // clear browser cache - return function(text) - { - text = Array.prototype.slice.call(arguments).join(' '); - element.value += text + "\n"; - element.scrollTop = 99999; // focus on bottom - }; - })(), - - printErr: function(text) - { - var text = Array.prototype.slice.call(arguments).join(' '); - var element = document.getElementById('output'); - element.value += text + "\n"; - element.scrollTop = 99999; // focus on bottom - }, + // Print both stdout and stderr to the browser console. + print: console.log, + printErr: console.log, canvas: document.getElementById('canvas'), totalDependencies: 0, monitorRunDependencies: function(left) From 993de8b4c470cfe94350182770d18ee1f25f9628 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Thu, 15 Sep 2016 00:45:25 -0400 Subject: [PATCH 080/334] (Emscripten) Use .bind() on the console object --- pkg/emscripten/proto.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/emscripten/proto.js b/pkg/emscripten/proto.js index 63b941d1f5..92d02f463c 100644 --- a/pkg/emscripten/proto.js +++ b/pkg/emscripten/proto.js @@ -239,9 +239,9 @@ var Module = arguments: ["-v", "--menu"], preRun: [], postRun: [], - // Print both stdout and stderr to the browser console. - print: console.log, - printErr: console.log, + // Log both stdout and stderr with the browser's console object. + print: console.log.bind(console), + printErr: console.log.bind(console), canvas: document.getElementById('canvas'), totalDependencies: 0, monitorRunDependencies: function(left) From f4791a9f637590be855f946c25b99ad0d127da1e Mon Sep 17 00:00:00 2001 From: Alcaro Date: Thu, 15 Sep 2016 10:32:27 +0200 Subject: [PATCH 081/334] (#2026 #3547 #3588) Configurable is good. Off by default is not good, if it's on your system already then using it does no harm. --- qb/config.params.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qb/config.params.sh b/qb/config.params.sh index 35bee06001..b510dec607 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -11,7 +11,7 @@ HAVE_SDL2=auto # SDL2 support (disables SDL 1.x) C89_SDL2=no HAVE_LIBUSB=auto # Libusb HID support C89_LIBUSB=no -HAVE_DBUS=no # dbus support +HAVE_DBUS=auto # dbus support HAVE_UDEV=auto # Udev/Evdev gamepad support HAVE_LIBRETRO= # Libretro library used HAVE_ASSETS_DIR= # Assets install directory From 9fbd4a5265670a347c64a4a37bc44a24f3163448 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Thu, 15 Sep 2016 13:34:31 +0200 Subject: [PATCH 082/334] Revert "(Emscripten) Bind to the console when logging" --- pkg/emscripten/proto.html | 10 ++++++++++ pkg/emscripten/proto.js | 22 +++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/pkg/emscripten/proto.html b/pkg/emscripten/proto.html index abb5936ace..6d6b683932 100644 --- a/pkg/emscripten/proto.html +++ b/pkg/emscripten/proto.html @@ -129,6 +129,16 @@
+
+
+
+
+ +
+
+ +
+

For now, we recommend you use Google Chrome for the best possible performance.

diff --git a/pkg/emscripten/proto.js b/pkg/emscripten/proto.js index 92d02f463c..72091f9d23 100644 --- a/pkg/emscripten/proto.js +++ b/pkg/emscripten/proto.js @@ -239,9 +239,25 @@ var Module = arguments: ["-v", "--menu"], preRun: [], postRun: [], - // Log both stdout and stderr with the browser's console object. - print: console.log.bind(console), - printErr: console.log.bind(console), + print: (function() + { + var element = document.getElementById('output'); + element.value = ''; // clear browser cache + return function(text) + { + text = Array.prototype.slice.call(arguments).join(' '); + element.value += text + "\n"; + element.scrollTop = 99999; // focus on bottom + }; + })(), + + printErr: function(text) + { + var text = Array.prototype.slice.call(arguments).join(' '); + var element = document.getElementById('output'); + element.value += text + "\n"; + element.scrollTop = 99999; // focus on bottom + }, canvas: document.getElementById('canvas'), totalDependencies: 0, monitorRunDependencies: function(left) From 430325aee9639dfa97da7442e277a50e05b40f49 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Thu, 15 Sep 2016 13:36:21 +0200 Subject: [PATCH 083/334] Revert "(Emscripten) Print logs to the browser console" From 93eff04e5473e10e0aecbddaae7857f1818a3aee Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 15:51:53 +0200 Subject: [PATCH 084/334] Move code to widgets/menu_list.c --- menu/menu_entries.c | 80 --------------------------------------- menu/widgets/menu_list.c | 81 ++++++++++++++++++++++++++++++++++++++++ menu/widgets/menu_list.h | 6 +++ 3 files changed, 87 insertions(+), 80 deletions(-) diff --git a/menu/menu_entries.c b/menu/menu_entries.c index 3dbdbf38bf..30d05b6cba 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -63,86 +63,6 @@ menu_file_list_cbs_t *menu_entries_get_actiondata_at_offset( file_list_get_actiondata_at_offset(list, idx); } -static int menu_entries_flush_stack_type(const char *needle, const char *label, - unsigned type, unsigned final_type) -{ - return needle ? strcmp(needle, label) : (type != final_type); -} - -static bool menu_list_pop_stack(menu_list_t *list, - size_t idx, size_t *directory_ptr, bool animate) -{ - menu_ctx_list_t list_info; - bool refresh = false; - file_list_t *menu_list = menu_list_get(list, idx); - if (!list) - return false; - - if (menu_list_get_stack_size(list, idx) <= 1) - return false; - - list_info.type = MENU_LIST_PLAIN; - list_info.action = 0; - - if (animate) - menu_driver_ctl(RARCH_MENU_CTL_LIST_CACHE, &list_info); - - if (menu_list->size != 0) - { - menu_ctx_list_t list_info; - - list_info.list = menu_list; - list_info.idx = menu_list->size - 1; - list_info.list_size = menu_list->size - 1; - - menu_driver_ctl(RARCH_MENU_CTL_LIST_FREE, &list_info); - } - - file_list_pop(menu_list, directory_ptr); - menu_driver_ctl(RARCH_MENU_CTL_LIST_SET_SELECTION, menu_list); - if (animate) - menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); - - return true; -} - -static void menu_list_flush_stack(menu_list_t *list, - size_t idx, const char *needle, unsigned final_type) -{ - bool refresh = false; - const char *path = NULL; - const char *label = NULL; - unsigned type = 0; - size_t entry_idx = 0; - file_list_t *menu_list = menu_list_get(list, idx); - if (!list) - return; - - menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); - menu_entries_get_last(menu_list, - &path, &label, &type, &entry_idx); - - while (menu_entries_flush_stack_type( - needle, label, type, final_type) != 0) - { - size_t new_selection_ptr; - - menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, - &new_selection_ptr); - - if (!menu_list_pop_stack(list, idx, &new_selection_ptr, 1)) - break; - - menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, - &new_selection_ptr); - - menu_list = menu_list_get(list, idx); - - menu_entries_get_last(menu_list, - &path, &label, &type, &entry_idx); - } -} - static bool menu_entries_clear(file_list_t *list) { unsigned i; diff --git a/menu/widgets/menu_list.c b/menu/widgets/menu_list.c index c2a6d0b34d..470036993a 100644 --- a/menu/widgets/menu_list.c +++ b/menu/widgets/menu_list.c @@ -22,6 +22,7 @@ #include "menu_list.h" #include "../menu_driver.h" +#include "../menu_navigation.h" struct menu_list { @@ -132,3 +133,83 @@ size_t menu_list_get_stack_size(menu_list_t *list, size_t idx) return 0; return file_list_get_size(list->menu_stack[idx]); } + +static int menu_list_flush_stack_type(const char *needle, const char *label, + unsigned type, unsigned final_type) +{ + return needle ? strcmp(needle, label) : (type != final_type); +} + +void menu_list_flush_stack(menu_list_t *list, + size_t idx, const char *needle, unsigned final_type) +{ + bool refresh = false; + const char *path = NULL; + const char *label = NULL; + unsigned type = 0; + size_t entry_idx = 0; + file_list_t *menu_list = menu_list_get(list, idx); + if (!list) + return; + + menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); + menu_entries_get_last(menu_list, + &path, &label, &type, &entry_idx); + + while (menu_list_flush_stack_type( + needle, label, type, final_type) != 0) + { + size_t new_selection_ptr; + + menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, + &new_selection_ptr); + + if (!menu_list_pop_stack(list, idx, &new_selection_ptr, 1)) + break; + + menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, + &new_selection_ptr); + + menu_list = menu_list_get(list, idx); + + menu_entries_get_last(menu_list, + &path, &label, &type, &entry_idx); + } +} + +bool menu_list_pop_stack(menu_list_t *list, + size_t idx, size_t *directory_ptr, bool animate) +{ + menu_ctx_list_t list_info; + bool refresh = false; + file_list_t *menu_list = menu_list_get(list, idx); + if (!list) + return false; + + if (menu_list_get_stack_size(list, idx) <= 1) + return false; + + list_info.type = MENU_LIST_PLAIN; + list_info.action = 0; + + if (animate) + menu_driver_ctl(RARCH_MENU_CTL_LIST_CACHE, &list_info); + + if (menu_list->size != 0) + { + menu_ctx_list_t list_info; + + list_info.list = menu_list; + list_info.idx = menu_list->size - 1; + list_info.list_size = menu_list->size - 1; + + menu_driver_ctl(RARCH_MENU_CTL_LIST_FREE, &list_info); + } + + file_list_pop(menu_list, directory_ptr); + menu_driver_ctl(RARCH_MENU_CTL_LIST_SET_SELECTION, menu_list); + if (animate) + menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); + + return true; +} diff --git a/menu/widgets/menu_list.h b/menu/widgets/menu_list.h index e47ea87ce6..a92d53b477 100644 --- a/menu/widgets/menu_list.h +++ b/menu/widgets/menu_list.h @@ -57,6 +57,12 @@ file_list_t *menu_list_get_selection(menu_list_t *list, unsigned idx); size_t menu_list_get_stack_size(menu_list_t *list, size_t idx); +void menu_list_flush_stack(menu_list_t *list, + size_t idx, const char *needle, unsigned final_type); + +bool menu_list_pop_stack(menu_list_t *list, + size_t idx, size_t *directory_ptr, bool animate); + RETRO_END_DECLS #endif From 233925bea659c0bf3610e872379e534d832aac6d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 15:57:25 +0200 Subject: [PATCH 085/334] Rename widgets/menu_popup to widgets/menu_dialog --- Makefile.common | 2 +- command.c | 2 +- griffin/griffin.c | 2 +- menu/cbs/menu_cbs_ok.c | 2 +- menu/drivers/menu_generic.c | 2 +- menu/menu_displaylist.c | 2 +- menu/menu_driver.c | 2 +- menu/widgets/{menu_popup.c => menu_dialog.c} | 12 ++++++------ menu/widgets/{menu_popup.h => menu_dialog.h} | 0 runloop.c | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) rename menu/widgets/{menu_popup.c => menu_dialog.c} (96%) rename menu/widgets/{menu_popup.h => menu_dialog.h} (100%) diff --git a/Makefile.common b/Makefile.common index 17091118c3..66e83b860c 100644 --- a/Makefile.common +++ b/Makefile.common @@ -509,7 +509,7 @@ ifeq ($(HAVE_MENU_COMMON), 1) menu/menu_navigation.o \ menu/menu_setting.o \ menu/menu_shader.o \ - menu/widgets/menu_popup.o \ + menu/widgets/menu_dialog.o \ menu/widgets/menu_entry.o \ menu/widgets/menu_list.o \ menu/menu_cbs.o \ diff --git a/command.c b/command.c index 4e74e58e11..6dd97de573 100644 --- a/command.c +++ b/command.c @@ -48,7 +48,7 @@ #include "menu/menu_content.h" #include "menu/menu_display.h" #include "menu/menu_shader.h" -#include "menu/widgets/menu_popup.h" +#include "menu/widgets/menu_dialog.h" #endif #ifdef HAVE_NETPLAY diff --git a/griffin/griffin.c b/griffin/griffin.c index 74839e79c3..297ad69350 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -893,7 +893,7 @@ MENU #include "../menu/menu_cbs.c" #include "../menu/menu_content.c" #include "../menu/widgets/menu_entry.c" -#include "../menu/widgets/menu_popup.c" +#include "../menu/widgets/menu_dialog.c" #include "../menu/widgets/menu_list.c" #include "../menu/cbs/menu_cbs_ok.c" #include "../menu/cbs/menu_cbs_cancel.c" diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index a6acfe2f46..313936ed9c 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -31,7 +31,7 @@ #include "../menu_setting.h" #include "../menu_shader.h" #include "../menu_navigation.h" -#include "../widgets/menu_popup.h" +#include "../widgets/menu_dialog.h" #include "../menu_content.h" #include "../../core.h" diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index 1dbd5a1fdc..ac5b2cfce3 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -25,7 +25,7 @@ #include "../menu_displaylist.h" #include "../menu_navigation.h" #include "../menu_entries.h" -#include "../widgets/menu_popup.h" +#include "../widgets/menu_dialog.h" #include "../../configuration.h" #include "../../performance_counters.h" diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 9f53dad062..5b8aa638f2 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -44,7 +44,7 @@ #include "menu_content.h" #include "menu_driver.h" #include "menu_navigation.h" -#include "widgets/menu_popup.h" +#include "widgets/menu_dialog.h" #include "widgets/menu_list.h" #include "menu_cbs.h" diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 23bb3507c7..a7b9d66f0f 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -29,7 +29,7 @@ #include "menu_cbs.h" #include "menu_display.h" #include "menu_navigation.h" -#include "widgets/menu_popup.h" +#include "widgets/menu_dialog.h" #include "widgets/menu_list.h" #include "menu_shader.h" diff --git a/menu/widgets/menu_popup.c b/menu/widgets/menu_dialog.c similarity index 96% rename from menu/widgets/menu_popup.c rename to menu/widgets/menu_dialog.c index 9c0f376fc3..3f8db6f4a9 100644 --- a/menu/widgets/menu_popup.c +++ b/menu/widgets/menu_dialog.c @@ -24,7 +24,7 @@ #include "../../cheevos.h" #endif -#include "menu_popup.h" +#include "menu_dialog.h" #include "../menu_display.h" #include "../menu_driver.h" @@ -35,11 +35,11 @@ #include "../../input/input_autodetect.h" #include "../../input/input_config.h" -static bool menu_popup_pending_push = false; -static bool menu_popup_active = false; -static unsigned menu_popup_current_id = 0; -static enum menu_popup_type menu_popup_current_type = MENU_POPUP_NONE; -static enum msg_hash_enums menu_popup_current_msg = MSG_UNKNOWN; +static bool menu_popup_pending_push = false; +static bool menu_popup_active = false; +static unsigned menu_popup_current_id = 0; +static enum menu_popup_type menu_popup_current_type = MENU_POPUP_NONE; +static enum msg_hash_enums menu_popup_current_msg = MSG_UNKNOWN; int menu_popup_iterate(char *s, size_t len, const char *label) { diff --git a/menu/widgets/menu_popup.h b/menu/widgets/menu_dialog.h similarity index 100% rename from menu/widgets/menu_popup.h rename to menu/widgets/menu_dialog.h diff --git a/runloop.c b/runloop.c index fb8a86897a..c5ef55c1ca 100644 --- a/runloop.c +++ b/runloop.c @@ -44,7 +44,7 @@ #ifdef HAVE_MENU #include "menu/menu_display.h" #include "menu/menu_driver.h" -#include "menu/widgets/menu_popup.h" +#include "menu/widgets/menu_dialog.h" #endif #ifdef HAVE_NETPLAY From f648ea86026b16e41f6d25645290f44fc7cb264d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 16:07:20 +0200 Subject: [PATCH 086/334] Cleanups --- command.c | 6 +-- menu/cbs/menu_cbs_ok.c | 20 +++---- menu/drivers/materialui.c | 5 +- menu/drivers/menu_generic.c | 19 +++---- menu/drivers/xmb.c | 10 ++-- menu/menu_displaylist.c | 2 +- menu/menu_driver.c | 8 +-- menu/widgets/menu_dialog.c | 102 ++++++++++++++++++------------------ menu/widgets/menu_dialog.h | 62 +++++++++++----------- runloop.c | 4 +- 10 files changed, 118 insertions(+), 120 deletions(-) diff --git a/command.c b/command.c index 6dd97de573..e265254cdf 100644 --- a/command.c +++ b/command.c @@ -1805,7 +1805,7 @@ void handle_quit_event() settings_t *settings = config_get_ptr(); #ifdef HAVE_MENU if (settings && settings->confirm_on_exit && - menu_popup_is_active()) + menu_dialog_is_active()) return; #endif @@ -2027,9 +2027,9 @@ bool command_event(enum event_command cmd, void *data) case CMD_EVENT_QUIT: #ifdef HAVE_MENU if (settings && settings->confirm_on_exit && - !menu_popup_is_active() && !runloop_is_quit_confirm()) + !menu_dialog_is_active() && !runloop_is_quit_confirm()) { - menu_popup_show_message(MENU_POPUP_QUIT_CONFIRM, MENU_ENUM_LABEL_CONFIRM_ON_EXIT); + menu_dialog_show_message(MENU_DIALOG_QUIT_CONFIRM, MENU_ENUM_LABEL_CONFIRM_ON_EXIT); break; } #endif diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 313936ed9c..eb1b97af78 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -245,7 +245,7 @@ int generic_action_ok_displaylist_push(const char *path, break; case ACTION_OK_DL_HELP: info_label = label; - menu_popup_push_pending(true, (enum menu_popup_type)type); + menu_dialog_push_pending(true, (enum menu_dialog_type)type); dl_type = DISPLAYLIST_HELP; break; case ACTION_OK_DL_RPL_ENTRY: @@ -1446,7 +1446,7 @@ static int action_ok_shader_pass_load(const char *path, static int generic_action_ok_help(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx, - enum msg_hash_enums id, enum menu_popup_type id2) + enum msg_hash_enums id, enum menu_dialog_type id2) { const char *lbl = msg_hash_to_str(id); @@ -1461,7 +1461,7 @@ static int action_ok_cheevos(const char *path, return generic_action_ok_help(path, label, new_id, idx, entry_idx, MENU_ENUM_LABEL_CHEEVOS_DESCRIPTION, - MENU_POPUP_HELP_CHEEVOS_DESCRIPTION); + MENU_DIALOG_HELP_CHEEVOS_DESCRIPTION); } static int action_ok_cheat(const char *path, @@ -3150,35 +3150,35 @@ static int action_ok_help_audio_video_troubleshooting(const char *path, { return generic_action_ok_help(path, label, type, idx, entry_idx, MENU_ENUM_LABEL_HELP_AUDIO_VIDEO_TROUBLESHOOTING, - MENU_POPUP_HELP_AUDIO_VIDEO_TROUBLESHOOTING); + MENU_DIALOG_HELP_AUDIO_VIDEO_TROUBLESHOOTING); } static int action_ok_help(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { return generic_action_ok_help(path, label, type, idx, entry_idx, - MENU_ENUM_LABEL_HELP, MENU_POPUP_WELCOME); + MENU_ENUM_LABEL_HELP, MENU_DIALOG_WELCOME); } static int action_ok_help_controls(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { return generic_action_ok_help(path, label, type, idx, entry_idx, - MENU_ENUM_LABEL_HELP_CONTROLS, MENU_POPUP_HELP_CONTROLS); + MENU_ENUM_LABEL_HELP_CONTROLS, MENU_DIALOG_HELP_CONTROLS); } static int action_ok_help_what_is_a_core(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { return generic_action_ok_help(path, label, type, idx, entry_idx, - MENU_ENUM_LABEL_HELP_WHAT_IS_A_CORE, MENU_POPUP_HELP_WHAT_IS_A_CORE); + MENU_ENUM_LABEL_HELP_WHAT_IS_A_CORE, MENU_DIALOG_HELP_WHAT_IS_A_CORE); } static int action_ok_help_scanning_content(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { return generic_action_ok_help(path, label, type, idx, entry_idx, - MENU_ENUM_LABEL_HELP_SCANNING_CONTENT, MENU_POPUP_HELP_SCANNING_CONTENT); + MENU_ENUM_LABEL_HELP_SCANNING_CONTENT, MENU_DIALOG_HELP_SCANNING_CONTENT); } static int action_ok_help_change_virtual_gamepad(const char *path, @@ -3186,14 +3186,14 @@ static int action_ok_help_change_virtual_gamepad(const char *path, { return generic_action_ok_help(path, label, type, idx, entry_idx, MENU_ENUM_LABEL_HELP_CHANGE_VIRTUAL_GAMEPAD, - MENU_POPUP_HELP_CHANGE_VIRTUAL_GAMEPAD); + MENU_DIALOG_HELP_CHANGE_VIRTUAL_GAMEPAD); } static int action_ok_help_load_content(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { return generic_action_ok_help(path, label, type, idx, entry_idx, - MENU_ENUM_LABEL_HELP_LOADING_CONTENT, MENU_POPUP_HELP_LOADING_CONTENT); + MENU_ENUM_LABEL_HELP_LOADING_CONTENT, MENU_DIALOG_HELP_LOADING_CONTENT); } static int action_ok_video_resolution(const char *path, diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 795b50d56a..89659dbf73 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -34,6 +34,10 @@ #include "../../config.h" #endif +#ifndef HAVE_DYNAMIC +#include "../../frontend/frontend_driver.h" +#endif + #include "menu_generic.h" #include "../menu_driver.h" @@ -44,7 +48,6 @@ #include "../../core_info.h" #include "../../core.h" #include "../../configuration.h" -#include "../../frontend/frontend_driver.h" #include "../../retroarch.h" #include "../../runloop.h" #include "../../verbosity.h" diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index ac5b2cfce3..33f09b176b 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -22,14 +22,9 @@ #include "../menu_driver.h" #include "../menu_display.h" -#include "../menu_displaylist.h" #include "../menu_navigation.h" -#include "../menu_entries.h" #include "../widgets/menu_dialog.h" -#include "../../configuration.h" -#include "../../performance_counters.h" - #include "../../verbosity.h" #include "../../runloop.h" #include "../../content.h" @@ -103,16 +98,16 @@ int generic_menu_iterate(void *data, void *userdata, enum menu_action action) switch (iterate_type) { case ITERATE_TYPE_HELP: - ret = menu_popup_iterate( + ret = menu_dialog_iterate( menu->menu_state.msg, sizeof(menu->menu_state.msg), label); BIT64_SET(menu->state, MENU_STATE_RENDER_MESSAGEBOX); BIT64_SET(menu->state, MENU_STATE_POST_ITERATE); if (ret == 1 || action == MENU_ACTION_OK) { BIT64_SET(menu->state, MENU_STATE_POP_STACK); - menu_popup_set_active(false); + menu_dialog_set_active(false); - if (menu_popup_get_current_type() == MENU_POPUP_QUIT_CONFIRM) + if (menu_dialog_get_current_type() == MENU_DIALOG_QUIT_CONFIRM) { runloop_set_quit_confirm(true); command_event(CMD_EVENT_QUIT_CONFIRM, NULL); @@ -122,9 +117,9 @@ int generic_menu_iterate(void *data, void *userdata, enum menu_action action) if (action == MENU_ACTION_CANCEL) { BIT64_SET(menu->state, MENU_STATE_POP_STACK); - menu_popup_set_active(false); + menu_dialog_set_active(false); - if (menu_popup_get_current_type() == MENU_POPUP_QUIT_CONFIRM) + if (menu_dialog_get_current_type() == MENU_DIALOG_QUIT_CONFIRM) { runloop_set_quit_confirm(false); @@ -234,7 +229,7 @@ int generic_menu_iterate(void *data, void *userdata, enum menu_action action) BIT64_SET(menu->state, MENU_STATE_POST_ITERATE); if (action == MENU_ACTION_OK || action == MENU_ACTION_CANCEL) BIT64_SET(menu->state, MENU_STATE_POP_STACK); - menu_popup_set_active(false); + menu_dialog_set_active(false); break; case ITERATE_TYPE_DEFAULT: /* FIXME: Crappy hack, needed for mouse controls @@ -253,7 +248,7 @@ int generic_menu_iterate(void *data, void *userdata, enum menu_action action) BIT64_SET(menu->state, MENU_STATE_POST_ITERATE); /* Have to defer it so we let settings refresh. */ - menu_popup_push(); + menu_dialog_push(); break; } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 67eabc1d88..c09b79f6c9 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -33,25 +33,25 @@ #include "../../config.h" #endif +#ifndef HAVE_DYNAMIC +#include "../../frontend/frontend_driver.h" +#endif + #include "menu_generic.h" #include "../menu_driver.h" -#include "../widgets/menu_entry.h" #include "../menu_animation.h" #include "../menu_display.h" -#include "../menu_display.h" #include "../menu_navigation.h" +#include "../widgets/menu_entry.h" #include "../widgets/menu_list.h" #include "../menu_cbs.h" -#include "../../frontend/frontend_driver.h" -#include "../../core.h" #include "../../verbosity.h" #include "../../configuration.h" #include "../../retroarch.h" -#include "../../file_path_special.h" #include "../../tasks/tasks_internal.h" diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 5b8aa638f2..3c880a3830 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -4187,7 +4187,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) case DISPLAYLIST_HELP: menu_entries_append_enum(info->list, info->path, info->label, MSG_UNKNOWN, info->type, info->directory_ptr, 0); - menu_popup_unset_pending_push(); + menu_dialog_unset_pending_push(); break; case DISPLAYLIST_SETTING_ENUM: { diff --git a/menu/menu_driver.c b/menu/menu_driver.c index a7b9d66f0f..9335d444ac 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -180,7 +180,7 @@ static bool menu_init(menu_handle_t *menu_data) if (settings->menu_show_start_screen) { - menu_popup_push_pending(true, MENU_POPUP_WELCOME); + menu_dialog_push_pending(true, MENU_DIALOG_WELCOME); settings->menu_show_start_screen = false; command_event(CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, NULL); } @@ -189,14 +189,14 @@ static bool menu_init(menu_handle_t *menu_data) && !string_is_empty(settings->path.bundle_assets_src) && !string_is_empty(settings->path.bundle_assets_dst) #ifdef IOS - && menu_popup_is_push_pending() + && menu_dialog_is_push_pending() #else && (settings->bundle_assets_extract_version_current != settings->bundle_assets_extract_last_version) #endif ) { - menu_popup_push_pending(true, MENU_POPUP_HELP_EXTRACT); + menu_dialog_push_pending(true, MENU_DIALOG_HELP_EXTRACT); #ifdef HAVE_ZLIB task_push_decompress(settings->path.bundle_assets_src, settings->path.bundle_assets_dst, @@ -580,7 +580,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) core_info_deinit_list(); core_info_free_current_core(); - menu_popup_reset(); + menu_dialog_reset(); free(menu_driver_data); } diff --git a/menu/widgets/menu_dialog.c b/menu/widgets/menu_dialog.c index 3f8db6f4a9..afe64af74a 100644 --- a/menu/widgets/menu_dialog.c +++ b/menu/widgets/menu_dialog.c @@ -35,13 +35,13 @@ #include "../../input/input_autodetect.h" #include "../../input/input_config.h" -static bool menu_popup_pending_push = false; -static bool menu_popup_active = false; -static unsigned menu_popup_current_id = 0; -static enum menu_popup_type menu_popup_current_type = MENU_POPUP_NONE; -static enum msg_hash_enums menu_popup_current_msg = MSG_UNKNOWN; +static bool menu_dialog_pending_push = false; +static bool menu_dialog_active = false; +static unsigned menu_dialog_current_id = 0; +static enum menu_dialog_type menu_dialog_current_type = MENU_DIALOG_NONE; +static enum msg_hash_enums menu_dialog_current_msg = MSG_UNKNOWN; -int menu_popup_iterate(char *s, size_t len, const char *label) +int menu_dialog_iterate(char *s, size_t len, const char *label) { #ifdef HAVE_CHEEVOS cheevos_ctx_desc_t desc_info; @@ -49,9 +49,9 @@ int menu_popup_iterate(char *s, size_t len, const char *label) bool do_exit = false; settings_t *settings = config_get_ptr(); - switch (menu_popup_current_type) + switch (menu_dialog_current_type) { - case MENU_POPUP_WELCOME: + case MENU_DIALOG_WELCOME: { static int64_t timeout_end; int64_t timeout; @@ -82,7 +82,7 @@ int menu_popup_iterate(char *s, size_t len, const char *label) } } break; - case MENU_POPUP_HELP_CONTROLS: + case MENU_DIALOG_HELP_CONTROLS: { unsigned i; char s2[PATH_MAX_LENGTH] = {0}; @@ -180,37 +180,37 @@ int menu_popup_iterate(char *s, size_t len, const char *label) break; #ifdef HAVE_CHEEVOS - case MENU_POPUP_HELP_CHEEVOS_DESCRIPTION: - desc_info.idx = menu_popup_current_id; + case MENU_DIALOG_HELP_CHEEVOS_DESCRIPTION: + desc_info.idx = menu_dialog_current_id; desc_info.s = s; desc_info.len = len; cheevos_get_description(&desc_info); break; #endif - case MENU_POPUP_HELP_WHAT_IS_A_CORE: + case MENU_DIALOG_HELP_WHAT_IS_A_CORE: menu_hash_get_help_enum(MENU_ENUM_LABEL_VALUE_WHAT_IS_A_CORE_DESC, s, len); break; - case MENU_POPUP_HELP_LOADING_CONTENT: + case MENU_DIALOG_HELP_LOADING_CONTENT: menu_hash_get_help_enum(MENU_ENUM_LABEL_LOAD_CONTENT_LIST, s, len); break; - case MENU_POPUP_HELP_CHANGE_VIRTUAL_GAMEPAD: + case MENU_DIALOG_HELP_CHANGE_VIRTUAL_GAMEPAD: menu_hash_get_help_enum( MENU_ENUM_LABEL_VALUE_HELP_CHANGE_VIRTUAL_GAMEPAD_DESC, s, len); break; - case MENU_POPUP_HELP_AUDIO_VIDEO_TROUBLESHOOTING: + case MENU_DIALOG_HELP_AUDIO_VIDEO_TROUBLESHOOTING: menu_hash_get_help_enum( MENU_ENUM_LABEL_VALUE_HELP_AUDIO_VIDEO_TROUBLESHOOTING_DESC, s, len); break; - case MENU_POPUP_HELP_SCANNING_CONTENT: + case MENU_DIALOG_HELP_SCANNING_CONTENT: menu_hash_get_help_enum(MENU_ENUM_LABEL_VALUE_HELP_SCANNING_CONTENT_DESC, s, len); break; - case MENU_POPUP_HELP_EXTRACT: + case MENU_DIALOG_HELP_EXTRACT: menu_hash_get_help_enum(MENU_ENUM_LABEL_VALUE_EXTRACTING_PLEASE_WAIT, s, len); @@ -220,50 +220,50 @@ int menu_popup_iterate(char *s, size_t len, const char *label) do_exit = true; } break; - case MENU_POPUP_QUIT_CONFIRM: - case MENU_POPUP_INFORMATION: - case MENU_POPUP_QUESTION: - case MENU_POPUP_WARNING: - case MENU_POPUP_ERROR: - menu_hash_get_help_enum(menu_popup_current_msg, + case MENU_DIALOG_QUIT_CONFIRM: + case MENU_DIALOG_INFORMATION: + case MENU_DIALOG_QUESTION: + case MENU_DIALOG_WARNING: + case MENU_DIALOG_ERROR: + menu_hash_get_help_enum(menu_dialog_current_msg, s, len); break; - case MENU_POPUP_NONE: + case MENU_DIALOG_NONE: default: break; } if (do_exit) { - menu_popup_current_type = MENU_POPUP_NONE; + menu_dialog_current_type = MENU_DIALOG_NONE; return 1; } return 0; } -bool menu_popup_is_push_pending(void) +bool menu_dialog_is_push_pending(void) { - return menu_popup_pending_push; + return menu_dialog_pending_push; } -void menu_popup_unset_pending_push(void) +void menu_dialog_unset_pending_push(void) { - menu_popup_pending_push = false; + menu_dialog_pending_push = false; } -void menu_popup_push_pending(bool push, enum menu_popup_type type) +void menu_dialog_push_pending(bool push, enum menu_dialog_type type) { - menu_popup_pending_push = push; - menu_popup_current_type = type; - menu_popup_active = true; + menu_dialog_pending_push = push; + menu_dialog_current_type = type; + menu_dialog_active = true; } -void menu_popup_push(void) +void menu_dialog_push(void) { menu_displaylist_info_t info = {0}; - if (!menu_popup_is_push_pending()) + if (!menu_dialog_is_push_pending()) return; info.list = menu_entries_get_menu_stack_ptr(0); @@ -275,39 +275,39 @@ void menu_popup_push(void) menu_displaylist_ctl(DISPLAYLIST_HELP, &info); } -void menu_popup_reset(void) +void menu_dialog_reset(void) { - menu_popup_pending_push = false; - menu_popup_current_id = 0; - menu_popup_current_type = MENU_POPUP_NONE; - menu_popup_current_msg = MSG_UNKNOWN; + menu_dialog_pending_push = false; + menu_dialog_current_id = 0; + menu_dialog_current_type = MENU_DIALOG_NONE; + menu_dialog_current_msg = MSG_UNKNOWN; menu_display_toggle_set_reason(MENU_TOGGLE_REASON_NONE); } -void menu_popup_show_message( - enum menu_popup_type type, enum msg_hash_enums msg) +void menu_dialog_show_message( + enum menu_dialog_type type, enum msg_hash_enums msg) { - menu_popup_current_msg = msg; + menu_dialog_current_msg = msg; if (!menu_driver_ctl(RARCH_MENU_CTL_IS_TOGGLE, NULL)) menu_display_toggle_set_reason(MENU_TOGGLE_REASON_MESSAGE); - menu_popup_push_pending(true, type); - menu_popup_push(); + menu_dialog_push_pending(true, type); + menu_dialog_push(); } -bool menu_popup_is_active(void) +bool menu_dialog_is_active(void) { - return menu_popup_active; + return menu_dialog_active; } -void menu_popup_set_active(bool on) +void menu_dialog_set_active(bool on) { - menu_popup_active = on; + menu_dialog_active = on; } -enum menu_popup_type menu_popup_get_current_type(void) +enum menu_dialog_type menu_dialog_get_current_type(void) { - return menu_popup_current_type; + return menu_dialog_current_type; } diff --git a/menu/widgets/menu_dialog.h b/menu/widgets/menu_dialog.h index 06f254783e..90c9eb80ba 100644 --- a/menu/widgets/menu_dialog.h +++ b/menu/widgets/menu_dialog.h @@ -14,8 +14,8 @@ * If not, see . */ -#ifndef _MENU_POPUP_H -#define _MENU_POPUP_H +#ifndef _MENU_DIALOG_H +#define _MENU_DIALOG_H #include #include @@ -26,50 +26,50 @@ #include "../../msg_hash.h" -enum menu_popup_type +enum menu_dialog_type { - MENU_POPUP_NONE = 0, - MENU_POPUP_WELCOME, - MENU_POPUP_HELP_EXTRACT, - MENU_POPUP_HELP_CONTROLS, - MENU_POPUP_HELP_CHEEVOS_DESCRIPTION, - MENU_POPUP_HELP_LOADING_CONTENT, - MENU_POPUP_HELP_WHAT_IS_A_CORE, - MENU_POPUP_HELP_CHANGE_VIRTUAL_GAMEPAD, - MENU_POPUP_HELP_AUDIO_VIDEO_TROUBLESHOOTING, - MENU_POPUP_HELP_SCANNING_CONTENT, - MENU_POPUP_QUIT_CONFIRM, - MENU_POPUP_INFORMATION, - MENU_POPUP_QUESTION, - MENU_POPUP_WARNING, - MENU_POPUP_ERROR, - MENU_POPUP_LAST + MENU_DIALOG_NONE = 0, + MENU_DIALOG_WELCOME, + MENU_DIALOG_HELP_EXTRACT, + MENU_DIALOG_HELP_CONTROLS, + MENU_DIALOG_HELP_CHEEVOS_DESCRIPTION, + MENU_DIALOG_HELP_LOADING_CONTENT, + MENU_DIALOG_HELP_WHAT_IS_A_CORE, + MENU_DIALOG_HELP_CHANGE_VIRTUAL_GAMEPAD, + MENU_DIALOG_HELP_AUDIO_VIDEO_TROUBLESHOOTING, + MENU_DIALOG_HELP_SCANNING_CONTENT, + MENU_DIALOG_QUIT_CONFIRM, + MENU_DIALOG_INFORMATION, + MENU_DIALOG_QUESTION, + MENU_DIALOG_WARNING, + MENU_DIALOG_ERROR, + MENU_DIALOG_LAST }; RETRO_BEGIN_DECLS -void menu_popup_push_pending( - bool push, enum menu_popup_type type); +void menu_dialog_push_pending( + bool push, enum menu_dialog_type type); -int menu_popup_iterate( +int menu_dialog_iterate( char *s, size_t len, const char *label); -void menu_popup_unset_pending_push(void); +void menu_dialog_unset_pending_push(void); -bool menu_popup_is_push_pending(void); +bool menu_dialog_is_push_pending(void); -void menu_popup_push(void); +void menu_dialog_push(void); -void menu_popup_reset(void); +void menu_dialog_reset(void); -void menu_popup_show_message( - enum menu_popup_type type, enum msg_hash_enums msg); +void menu_dialog_show_message( + enum menu_dialog_type type, enum msg_hash_enums msg); -bool menu_popup_is_active(void); +bool menu_dialog_is_active(void); -void menu_popup_set_active(bool on); +void menu_dialog_set_active(bool on); -enum menu_popup_type menu_popup_get_current_type(void); +enum menu_dialog_type menu_dialog_get_current_type(void); RETRO_END_DECLS diff --git a/runloop.c b/runloop.c index c5ef55c1ca..a6a019f508 100644 --- a/runloop.c +++ b/runloop.c @@ -1362,7 +1362,7 @@ static INLINE int runloop_iterate_time_to_exit(bool quit_key_pressed) if (settings && settings->confirm_on_exit && !runloop_quit_confirm) { - if (menu_popup_is_active()) + if (menu_dialog_is_active()) return 1; if (content_is_inited()) @@ -1372,7 +1372,7 @@ static INLINE int runloop_iterate_time_to_exit(bool quit_key_pressed) rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); } - menu_popup_show_message(MENU_POPUP_QUIT_CONFIRM, MENU_ENUM_LABEL_CONFIRM_ON_EXIT); + menu_dialog_show_message(MENU_DIALOG_QUIT_CONFIRM, MENU_ENUM_LABEL_CONFIRM_ON_EXIT); return 1; } #endif From 6c4c0cf5e70c71b97d99776aeaeea2e6f1c0dcbd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 16:13:17 +0200 Subject: [PATCH 087/334] Use menu_entry_get_value --- menu/drivers/materialui.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 89659dbf73..805eaba000 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -661,8 +661,8 @@ static void mui_render_menu_list(mui_handle_t *mui, int y; size_t selection; char rich_label[PATH_MAX_LENGTH] = {0}; + char entry_value[PATH_MAX_LENGTH] = {0}; bool entry_selected = false; - menu_entry_t entry = {{0}}; if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) continue; @@ -673,7 +673,7 @@ static void mui_render_menu_list(mui_handle_t *mui, || ((y + (int)mui->line_height) < 0)) continue; - menu_entry_get(&entry, 0, i, NULL, true); + menu_entry_get_value(i, entry_value, sizeof(entry_value)); menu_entry_get_rich_label(i, rich_label, sizeof(rich_label)); entry_selected = selection == i; @@ -687,7 +687,7 @@ static void mui_render_menu_list(mui_handle_t *mui, entry_selected ? font_hover_color : font_normal_color, entry_selected, rich_label, - entry.value, + entry_value, menu_list_color ); } From 78c4bc4a5b22e715cfc8c9b2b0337d317dc5b940 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 16:25:10 +0200 Subject: [PATCH 088/334] (xmb.c) Try to make sure 1st and 2nd arguments for fill_pathname_join are not one and the same --- menu/drivers/xmb.c | 6 ++++-- menu/drivers/zarch.c | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index c09b79f6c9..1de66a7cbd 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -753,6 +753,7 @@ static void xmb_update_thumbnail_path(void *data, unsigned i) settings->directory.thumbnails, xmb->title_name, sizeof(xmb->thumbnail_file_path)); + fill_pathname_join(xmb->thumbnail_file_path, xmb->thumbnail_file_path, xmb_thumbnails_ident(), sizeof(xmb->thumbnail_file_path)); @@ -760,8 +761,9 @@ static void xmb_update_thumbnail_path(void *data, unsigned i) if (tmp) { - fill_pathname_join(xmb->thumbnail_file_path, xmb->thumbnail_file_path, - tmp, sizeof(xmb->thumbnail_file_path)); + char tmp_new[PATH_MAX_LENGTH]; + fill_pathname_join(tmp_new, xmb->thumbnail_file_path, tmp, sizeof(tmp_new)); + strlcpy(xmb->thumbnail_file_path, tmp_new, sizeof(xmb->thumbnail_file_path)); free(tmp); } diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index ebbe6ba753..1de5ca572c 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -512,15 +512,17 @@ static int zarch_zui_render_lay_root_recent(zui_t *zui, struct zui_tabbed *tabbe for (i = zui->recent_dlist_first; i < size; ++i) { - char rich_label[PATH_MAX_LENGTH] = {0}; - menu_entry_t entry = {{0}}; + char rich_label[PATH_MAX_LENGTH] = {0}; + char entry_value[PATH_MAX_LENGTH] = {0}; + menu_entry_t entry = {{0}}; menu_entry_get(&entry, 0, i, NULL, true); menu_entry_get_rich_label(i, rich_label, sizeof(rich_label)); + menu_entry_get_value(i, entry_value,sizeof(entry_value)); if (zarch_zui_list_item(zui, tabbed, 0, tabbed->tabline_size + j * ZUI_ITEM_SIZE_PX, - rich_label, i, entry.value, gamepad_index == (signed)i)) + rich_label, i, entry_value, gamepad_index == (signed)i)) { if (menu_entry_action(&entry, i, MENU_ACTION_OK)) return 1; From 3a663ba0132c7ff9edb481237b1a47285b26792f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 16:30:22 +0200 Subject: [PATCH 089/334] (XMB) Use menu_entry_get_value --- menu/drivers/xmb.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 1de66a7cbd..cfede46cd6 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1766,18 +1766,19 @@ static void xmb_draw_items(xmb_handle_t *xmb, for (; i < end; i++) { - menu_entry_t entry = {{0}}; float icon_x, icon_y; menu_animation_ctx_ticker_t ticker; - char ticker_str[PATH_MAX_LENGTH] = {0}; - char name[PATH_MAX_LENGTH] = {0}; - char value[PATH_MAX_LENGTH] = {0}; - const float half_size = xmb->icon.size / 2.0f; - uintptr_t texture_switch = 0; - xmb_node_t * node = (xmb_node_t*) + menu_entry_t entry = {{0}}; + char ticker_str[PATH_MAX_LENGTH] = {0}; + char name[PATH_MAX_LENGTH] = {0}; + char value[PATH_MAX_LENGTH] = {0}; + char entry_value[PATH_MAX_LENGTH] = {0}; + const float half_size = xmb->icon.size / 2.0f; + uintptr_t texture_switch = 0; + xmb_node_t * node = (xmb_node_t*) menu_entries_get_userdata_at_offset(list, i); - bool do_draw_text = false; - unsigned ticker_limit = 35; + bool do_draw_text = false; + unsigned ticker_limit = 35; if (!node) continue; @@ -1803,17 +1804,18 @@ static void xmb_draw_items(xmb_handle_t *xmb, fill_short_pathname_representation(entry.path, entry.path, sizeof(entry.path)); + menu_entry_get_value(i, entry_value, sizeof(entry_value)); - if (string_is_equal(entry.value, "disabled") || - string_is_equal(entry.value, "off")) + if (string_is_equal(entry_value, "disabled") || + string_is_equal(entry_value, "off")) { if (xmb->textures.list[XMB_TEXTURE_SWITCH_OFF]) texture_switch = xmb->textures.list[XMB_TEXTURE_SWITCH_OFF]; else do_draw_text = true; } - else if (string_is_equal(entry.value, "enabled") || - string_is_equal(entry.value, "on")) + else if (string_is_equal(entry_value, "enabled") || + string_is_equal(entry_value, "on")) { if (xmb->textures.list[XMB_TEXTURE_SWITCH_ON]) texture_switch = xmb->textures.list[XMB_TEXTURE_SWITCH_ON]; @@ -1822,7 +1824,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, } else { - switch (msg_hash_to_file_type(msg_hash_calculate(entry.value))) + switch (msg_hash_to_file_type(msg_hash_calculate(entry_value))) { case FILE_TYPE_COMPRESSED: case FILE_TYPE_MORE: @@ -1853,7 +1855,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, } } - if (string_is_empty(entry.value)) + if (string_is_empty(entry_value)) { if (!string_is_equal(xmb_thumbnails_ident(), "OFF") && xmb->thumbnail) ticker_limit = 40; @@ -1881,7 +1883,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, ticker.s = value; ticker.len = 35; ticker.idx = *frame_count / 20; - ticker.str = entry.value; + ticker.str = entry_value; ticker.selected = (i == current); menu_animation_ctl(MENU_ANIMATION_CTL_TICKER, &ticker); From 84f81acba57f3cb51f4e16fa9edab764d31a2a99 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 16:36:36 +0200 Subject: [PATCH 090/334] Header include cleanups --- menu/menu_entries.h | 9 ++------- menu/widgets/menu_list.h | 9 +++++++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/menu/menu_entries.h b/menu/menu_entries.h index bfb5daa565..7a0832c619 100644 --- a/menu/menu_entries.h +++ b/menu/menu_entries.h @@ -22,18 +22,13 @@ #include #include +#include "widgets/menu_list.h" + #include "menu_setting.h" #include "menu_displaylist.h" RETRO_BEGIN_DECLS -enum menu_list_type -{ - MENU_LIST_PLAIN = 0, - MENU_LIST_HORIZONTAL, - MENU_LIST_TABS -}; - enum menu_entries_ctl_state { MENU_ENTRIES_CTL_NONE = 0, diff --git a/menu/widgets/menu_list.h b/menu/widgets/menu_list.h index a92d53b477..ebea133238 100644 --- a/menu/widgets/menu_list.h +++ b/menu/widgets/menu_list.h @@ -25,10 +25,15 @@ #include #include -#include "../menu_entries.h" - RETRO_BEGIN_DECLS +enum menu_list_type +{ + MENU_LIST_PLAIN = 0, + MENU_LIST_HORIZONTAL, + MENU_LIST_TABS +}; + typedef struct menu_ctx_list { file_list_t *list; From ed3f002f1ba073454237a281799cb047e0c9df67 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 17:07:52 +0200 Subject: [PATCH 091/334] Rename menu_input_key_line_end to menu_input_dialog_end --- menu/cbs/menu_cbs_ok.c | 4 ++-- menu/menu_input.c | 10 +++++----- menu/menu_input.h | 2 +- setting_list.c | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index eb1b97af78..e48090be2e 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1512,7 +1512,7 @@ static void menu_input_st_string_cb_save_preset(void *userdata, 1, 100, true); } - menu_input_key_end_line(); + menu_input_dialog_end(); } static int action_ok_shader_preset_save_as(const char *path, @@ -1633,7 +1633,7 @@ static void menu_input_st_string_cb_cheat_file_save_as( cheat_manager_save(str); } - menu_input_key_end_line(); + menu_input_dialog_end(); } static int action_ok_cheat_file_save_as(const char *path, diff --git a/menu/menu_input.c b/menu/menu_input.c index 5a9e302469..713a3ec8d5 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -138,7 +138,7 @@ static menu_input_t *menu_input_get_ptr(void) return &menu_input_state; } -void menu_input_key_end_line(void) +void menu_input_dialog_end(void) { bool keyboard_display = false; @@ -165,7 +165,7 @@ static void menu_input_search_cb(void *userdata, const char *str) menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll); } - menu_input_key_end_line(); + menu_input_dialog_end(); } void menu_input_st_uint_cb(void *userdata, const char *str) @@ -181,7 +181,7 @@ void menu_input_st_uint_cb(void *userdata, const char *str) setting_set_with_string_representation(setting, str); } - menu_input_key_end_line(); + menu_input_dialog_end(); } void menu_input_st_hex_cb(void *userdata, const char *str) @@ -205,7 +205,7 @@ void menu_input_st_hex_cb(void *userdata, const char *str) } } - menu_input_key_end_line(); + menu_input_dialog_end(); } void menu_input_st_cheat_cb(void *userdata, const char *str) @@ -224,7 +224,7 @@ void menu_input_st_cheat_cb(void *userdata, const char *str) cheat_manager_set_code(cheat_index, str); } - menu_input_key_end_line(); + menu_input_dialog_end(); } static bool menu_input_key_bind_custom_bind_keyboard_cb( diff --git a/menu/menu_input.h b/menu/menu_input.h index 14dc68e448..1ac111b70a 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -139,7 +139,7 @@ int16_t menu_input_mouse_state(enum menu_input_mouse_state state); bool menu_input_mouse_check_vector_inside_hitbox(menu_input_ctx_hitbox_t *hitbox); -void menu_input_key_end_line(void); +void menu_input_dialog_end(void); bool menu_input_ctl(enum menu_input_ctl_state state, void *data); diff --git a/setting_list.c b/setting_list.c index 2fbe517ade..4c6e7fae48 100644 --- a/setting_list.c +++ b/setting_list.c @@ -1787,7 +1787,7 @@ static void menu_input_st_string_cb(void *userdata, const char *str) } } - menu_input_key_end_line(); + menu_input_dialog_end(); } static int setting_generic_action_ok_linefeed(void *data, bool wraparound) From b9320514cb9357948403b8defbdde5bd33d9fc20 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 17:11:01 +0200 Subject: [PATCH 092/334] Create menu_input_dialog_start --- menu/cbs/menu_cbs_ok.c | 6 ++--- menu/menu_input.c | 51 ++++++++++++++++++++++-------------------- menu/menu_input.h | 8 ++++--- setting_list.c | 2 +- 4 files changed, 36 insertions(+), 31 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index e48090be2e..5170e17775 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1475,7 +1475,7 @@ static int action_ok_cheat(const char *path, line.idx = idx; line.cb = menu_input_st_cheat_cb; - if (!menu_input_ctl(MENU_INPUT_CTL_START_LINE, &line)) + if (!menu_input_dialog_start(&line)) return -1; return 0; } @@ -1526,7 +1526,7 @@ static int action_ok_shader_preset_save_as(const char *path, line.idx = idx; line.cb = menu_input_st_string_cb_save_preset; - if (!menu_input_ctl(MENU_INPUT_CTL_START_LINE, &line)) + if (!menu_input_dialog_start(&line)) return -1; return 0; } @@ -1647,7 +1647,7 @@ static int action_ok_cheat_file_save_as(const char *path, line.idx = idx; line.cb = menu_input_st_string_cb_cheat_file_save_as; - if (!menu_input_ctl(MENU_INPUT_CTL_START_LINE, &line)) + if (!menu_input_dialog_start(&line)) return -1; return 0; } diff --git a/menu/menu_input.c b/menu/menu_input.c index 713a3ec8d5..aef1ac19a7 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -628,10 +628,11 @@ bool menu_input_mouse_check_vector_inside_hitbox(menu_input_ctx_hitbox_t *hitbox return inside_hitbox; } +static const char **menu_input_keyboard_buffer; + bool menu_input_ctl(enum menu_input_ctl_state state, void *data) { static char menu_input_keyboard_label_setting[256]; - static const char **menu_input_keyboard_buffer; static const char *menu_input_keyboard_label = NULL; static bool pointer_dragging = false; menu_input_t *menu_input = menu_input_get_ptr(); @@ -761,29 +762,6 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data) return false; return menu_input_key_bind_iterate(bind->s, bind->len); } - case MENU_INPUT_CTL_START_LINE: - { - bool keyboard_display = true; - menu_handle_t *menu = NULL; - menu_input_ctx_line_t *line = (menu_input_ctx_line_t*)data; - if (!menu_input || !line) - return false; - if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) - return false; - - menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_DISPLAY, - &keyboard_display); - menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_LABEL, - &line->label); - menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_LABEL_SETTING, - &line->label_setting); - - menu_input->keyboard.type = line->type; - menu_input->keyboard.idx = line->idx; - menu_input_keyboard_buffer = - input_keyboard_start_line(menu, line->cb); - } - break; default: case MENU_INPUT_CTL_NONE: break; @@ -792,6 +770,31 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data) return true; } +bool menu_input_dialog_start(menu_input_ctx_line_t *line) +{ + bool keyboard_display = true; + menu_handle_t *menu = NULL; + menu_input_t *menu_input = menu_input_get_ptr(); + if (!menu_input || !line) + return false; + if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) + return false; + + menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_DISPLAY, + &keyboard_display); + menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_LABEL, + &line->label); + menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_LABEL_SETTING, + &line->label_setting); + + menu_input->keyboard.type = line->type; + menu_input->keyboard.idx = line->idx; + menu_input_keyboard_buffer = + input_keyboard_start_line(menu, line->cb); + + return true; +} + static int menu_input_pointer(unsigned *action) { const struct retro_keybind *binds[MAX_USERS] = {NULL}; diff --git a/menu/menu_input.h b/menu/menu_input.h index 1ac111b70a..fd26ad67ba 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -91,8 +91,7 @@ enum menu_input_ctl_state MENU_INPUT_CTL_BIND_SINGLE, MENU_INPUT_CTL_BIND_ALL, MENU_INPUT_CTL_BIND_ITERATE, - MENU_INPUT_CTL_BIND_SET_MIN_MAX, - MENU_INPUT_CTL_START_LINE + MENU_INPUT_CTL_BIND_SET_MIN_MAX }; typedef struct menu_input_ctx_hitbox @@ -118,6 +117,10 @@ typedef struct menu_input_ctx_line input_keyboard_line_complete_t cb; } menu_input_ctx_line_t; +bool menu_input_dialog_start(menu_input_ctx_line_t *line); + +void menu_input_dialog_end(void); + typedef struct menu_input_ctx_bind_limits { unsigned min; @@ -139,7 +142,6 @@ int16_t menu_input_mouse_state(enum menu_input_mouse_state state); bool menu_input_mouse_check_vector_inside_hitbox(menu_input_ctx_hitbox_t *hitbox); -void menu_input_dialog_end(void); bool menu_input_ctl(enum menu_input_ctl_state state, void *data); diff --git a/setting_list.c b/setting_list.c index 4c6e7fae48..e833f2f6b2 100644 --- a/setting_list.c +++ b/setting_list.c @@ -1824,7 +1824,7 @@ static int setting_generic_action_ok_linefeed(void *data, bool wraparound) line.idx = 0; line.cb = cb; - if (!menu_input_ctl(MENU_INPUT_CTL_START_LINE, &line)) + if (!menu_input_dialog_start(&line)) return -1; return 0; From d9e631de698f64612bb0b4c2f5599f48394889db Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 17:18:24 +0200 Subject: [PATCH 093/334] Create menu_input_dialog_start_search --- menu/menu_input.c | 34 +++++++++++++++++++--------------- menu/menu_input.h | 3 ++- menu/widgets/menu_entry.c | 2 +- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/menu/menu_input.c b/menu/menu_input.c index aef1ac19a7..0c9d09412a 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -629,11 +629,11 @@ bool menu_input_mouse_check_vector_inside_hitbox(menu_input_ctx_hitbox_t *hitbox } static const char **menu_input_keyboard_buffer; +static char menu_input_keyboard_label_setting[256]; +static const char *menu_input_keyboard_label = NULL; bool menu_input_ctl(enum menu_input_ctl_state state, void *data) { - static char menu_input_keyboard_label_setting[256]; - static const char *menu_input_keyboard_label = NULL; static bool pointer_dragging = false; menu_input_t *menu_input = menu_input_get_ptr(); @@ -657,19 +657,6 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data) memset(menu_input, 0, sizeof(menu_input_t)); pointer_dragging = false; break; - case MENU_INPUT_CTL_SEARCH_START: - { - menu_handle_t *menu = NULL; - if (!menu_driver_ctl( - RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) - return false; - - menu_input->keyboard.display = true; - menu_input_keyboard_label = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SEARCH); - menu_input_keyboard_buffer = - input_keyboard_start_line(menu, menu_input_search_cb); - } - break; case MENU_INPUT_CTL_MOUSE_PTR: { unsigned *ptr = (unsigned*)data; @@ -770,6 +757,23 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data) return true; } +bool menu_input_dialog_start_search(void) +{ + bool keyboard_display = true; + menu_handle_t *menu = NULL; + if (!menu_driver_ctl( + RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) + return false; + + menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_DISPLAY, + &keyboard_display); + menu_input_keyboard_label = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SEARCH); + menu_input_keyboard_buffer = + input_keyboard_start_line(menu, menu_input_search_cb); + + return true; +} + bool menu_input_dialog_start(menu_input_ctx_line_t *line) { bool keyboard_display = true; diff --git a/menu/menu_input.h b/menu/menu_input.h index fd26ad67ba..d7b16a9e45 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -85,7 +85,6 @@ enum menu_input_ctl_state MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, MENU_INPUT_CTL_SET_KEYBOARD_LABEL_SETTING, MENU_INPUT_CTL_UNSET_KEYBOARD_LABEL_SETTING, - MENU_INPUT_CTL_SEARCH_START, MENU_INPUT_CTL_DEINIT, MENU_INPUT_CTL_BIND_NONE, MENU_INPUT_CTL_BIND_SINGLE, @@ -117,6 +116,8 @@ typedef struct menu_input_ctx_line input_keyboard_line_complete_t cb; } menu_input_ctx_line_t; +bool menu_input_dialog_start_search(void); + bool menu_input_dialog_start(menu_input_ctx_line_t *line); void menu_input_dialog_end(void); diff --git a/menu/widgets/menu_entry.c b/menu/widgets/menu_entry.c index 39b5dc91fa..6085e178e1 100644 --- a/menu/widgets/menu_entry.c +++ b/menu/widgets/menu_entry.c @@ -402,7 +402,7 @@ int menu_entry_action(menu_entry_t *entry, unsigned i, enum menu_action action) entry->label, entry->type, i); break; case MENU_ACTION_SEARCH: - menu_input_ctl(MENU_INPUT_CTL_SEARCH_START, NULL); + menu_input_dialog_start_search(); break; case MENU_ACTION_SCAN: From 8530671e8fbdca0a9b39b2798791a2db6f7c0d6d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 17:21:18 +0200 Subject: [PATCH 094/334] Cleanups --- menu/menu_input.c | 18 +++++++----------- menu/menu_input.h | 2 -- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/menu/menu_input.c b/menu/menu_input.c index 0c9d09412a..2d3794cda2 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -138,13 +138,18 @@ static menu_input_t *menu_input_get_ptr(void) return &menu_input_state; } +static const char **menu_input_keyboard_buffer; +static char menu_input_keyboard_label_setting[256] = {0}; +static const char *menu_input_keyboard_label = NULL; + void menu_input_dialog_end(void) { bool keyboard_display = false; menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_DISPLAY, &keyboard_display); - menu_input_ctl(MENU_INPUT_CTL_UNSET_KEYBOARD_LABEL, NULL); - menu_input_ctl(MENU_INPUT_CTL_UNSET_KEYBOARD_LABEL_SETTING, NULL); + + menu_input_keyboard_label = NULL; + menu_input_keyboard_label_setting[0] = '\0'; /* Avoid triggering states on pressing return. */ input_driver_set_flushing_input(); @@ -628,9 +633,6 @@ bool menu_input_mouse_check_vector_inside_hitbox(menu_input_ctx_hitbox_t *hitbox return inside_hitbox; } -static const char **menu_input_keyboard_buffer; -static char menu_input_keyboard_label_setting[256]; -static const char *menu_input_keyboard_label = NULL; bool menu_input_ctl(enum menu_input_ctl_state state, void *data) { @@ -719,9 +721,6 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data) menu_input_keyboard_label = *ptr; } break; - case MENU_INPUT_CTL_UNSET_KEYBOARD_LABEL: - menu_input_keyboard_label = NULL; - break; case MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING: { const char **ptr = (const char**)data; @@ -735,9 +734,6 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data) *ptr, sizeof(menu_input_keyboard_label_setting)); } break; - case MENU_INPUT_CTL_UNSET_KEYBOARD_LABEL_SETTING: - menu_input_keyboard_label_setting[0] = '\0'; - break; case MENU_INPUT_CTL_BIND_NONE: case MENU_INPUT_CTL_BIND_SINGLE: case MENU_INPUT_CTL_BIND_ALL: diff --git a/menu/menu_input.h b/menu/menu_input.h index d7b16a9e45..d5d9d7df01 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -81,10 +81,8 @@ enum menu_input_ctl_state MENU_INPUT_CTL_KEYBOARD_BUFF_PTR, MENU_INPUT_CTL_KEYBOARD_LABEL, MENU_INPUT_CTL_SET_KEYBOARD_LABEL, - MENU_INPUT_CTL_UNSET_KEYBOARD_LABEL, MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, MENU_INPUT_CTL_SET_KEYBOARD_LABEL_SETTING, - MENU_INPUT_CTL_UNSET_KEYBOARD_LABEL_SETTING, MENU_INPUT_CTL_DEINIT, MENU_INPUT_CTL_BIND_NONE, MENU_INPUT_CTL_BIND_SINGLE, From 84160c092c217c797cde1a7adacd27a213237a2c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 17:26:30 +0200 Subject: [PATCH 095/334] Cleanups to input_dialog code --- menu/menu_input.c | 52 ++++++++++++++++------------------------------- menu/menu_input.h | 3 --- 2 files changed, 18 insertions(+), 37 deletions(-) diff --git a/menu/menu_input.c b/menu/menu_input.c index 2d3794cda2..86cc225972 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -140,15 +140,17 @@ static menu_input_t *menu_input_get_ptr(void) static const char **menu_input_keyboard_buffer; static char menu_input_keyboard_label_setting[256] = {0}; -static const char *menu_input_keyboard_label = NULL; +static char menu_input_keyboard_label[256] = {0}; void menu_input_dialog_end(void) { - bool keyboard_display = false; + menu_input_t *menu_input = menu_input_get_ptr(); - menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_DISPLAY, &keyboard_display); + if (!menu_input) + return; - menu_input_keyboard_label = NULL; + menu_input->keyboard.display = false; + menu_input_keyboard_label[0] = '\0'; menu_input_keyboard_label_setting[0] = '\0'; /* Avoid triggering states on pressing return. */ @@ -697,12 +699,6 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data) *ptr = menu_input->keyboard.display; } break; - case MENU_INPUT_CTL_SET_KEYBOARD_DISPLAY: - { - bool *ptr = (bool*)data; - menu_input->keyboard.display = *ptr; - } - break; case MENU_INPUT_CTL_KEYBOARD_BUFF_PTR: { const char **ptr = (const char**)data; @@ -715,25 +711,12 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data) *ptr = menu_input_keyboard_label; } break; - case MENU_INPUT_CTL_SET_KEYBOARD_LABEL: - { - char **ptr = (char**)data; - menu_input_keyboard_label = *ptr; - } - break; case MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING: { const char **ptr = (const char**)data; *ptr = menu_input_keyboard_label_setting; } break; - case MENU_INPUT_CTL_SET_KEYBOARD_LABEL_SETTING: - { - char **ptr = (char**)data; - strlcpy(menu_input_keyboard_label_setting, - *ptr, sizeof(menu_input_keyboard_label_setting)); - } - break; case MENU_INPUT_CTL_BIND_NONE: case MENU_INPUT_CTL_BIND_SINGLE: case MENU_INPUT_CTL_BIND_ALL: @@ -755,15 +738,18 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data) bool menu_input_dialog_start_search(void) { - bool keyboard_display = true; menu_handle_t *menu = NULL; + menu_input_t *menu_input = menu_input_get_ptr(); + + if (!menu_input) + return false; if (!menu_driver_ctl( RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return false; - menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_DISPLAY, - &keyboard_display); - menu_input_keyboard_label = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SEARCH); + menu_input->keyboard.display = true; + strlcpy(menu_input_keyboard_label, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SEARCH), + sizeof(menu_input_keyboard_label)); menu_input_keyboard_buffer = input_keyboard_start_line(menu, menu_input_search_cb); @@ -772,7 +758,6 @@ bool menu_input_dialog_start_search(void) bool menu_input_dialog_start(menu_input_ctx_line_t *line) { - bool keyboard_display = true; menu_handle_t *menu = NULL; menu_input_t *menu_input = menu_input_get_ptr(); if (!menu_input || !line) @@ -780,12 +765,11 @@ bool menu_input_dialog_start(menu_input_ctx_line_t *line) if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return false; - menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_DISPLAY, - &keyboard_display); - menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_LABEL, - &line->label); - menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_LABEL_SETTING, - &line->label_setting); + menu_input->keyboard.display = true; + strlcpy(menu_input_keyboard_label, line->label, + sizeof(menu_input_keyboard_label)); + strlcpy(menu_input_keyboard_label_setting, + line->label_setting, sizeof(menu_input_keyboard_label_setting)); menu_input->keyboard.type = line->type; menu_input->keyboard.idx = line->idx; diff --git a/menu/menu_input.h b/menu/menu_input.h index d5d9d7df01..35ef0d3b79 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -77,12 +77,9 @@ enum menu_input_ctl_state MENU_INPUT_CTL_SET_POINTER_DRAGGED, MENU_INPUT_CTL_UNSET_POINTER_DRAGGED, MENU_INPUT_CTL_KEYBOARD_DISPLAY, - MENU_INPUT_CTL_SET_KEYBOARD_DISPLAY, MENU_INPUT_CTL_KEYBOARD_BUFF_PTR, MENU_INPUT_CTL_KEYBOARD_LABEL, - MENU_INPUT_CTL_SET_KEYBOARD_LABEL, MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, - MENU_INPUT_CTL_SET_KEYBOARD_LABEL_SETTING, MENU_INPUT_CTL_DEINIT, MENU_INPUT_CTL_BIND_NONE, MENU_INPUT_CTL_BIND_SINGLE, From bd565f79ecb8218131378b4021ec09bd843b7b68 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 18:45:57 +0200 Subject: [PATCH 096/334] Add menu_input_dialog_display_kb/menu_input_dialog_hide_kb --- menu/menu_input.c | 18 ++++++++++++++++++ menu/menu_input.h | 5 ++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/menu/menu_input.c b/menu/menu_input.c index 86cc225972..bd8ade3cf9 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -736,6 +736,24 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data) return true; } +void menu_input_dialog_display_kb(void) +{ + menu_input_t *menu_input = menu_input_get_ptr(); + + if (!menu_input) + return; + menu_input->keyboard.display = true; +} + +void menu_input_dialog_hide_kb(void) +{ + menu_input_t *menu_input = menu_input_get_ptr(); + + if (!menu_input) + return; + menu_input->keyboard.display = false; +} + bool menu_input_dialog_start_search(void) { menu_handle_t *menu = NULL; diff --git a/menu/menu_input.h b/menu/menu_input.h index 35ef0d3b79..09b60538b0 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -113,6 +113,10 @@ typedef struct menu_input_ctx_line bool menu_input_dialog_start_search(void); +void menu_input_dialog_hide_kb(void); + +void menu_input_dialog_display_kb(void); + bool menu_input_dialog_start(menu_input_ctx_line_t *line); void menu_input_dialog_end(void); @@ -138,7 +142,6 @@ int16_t menu_input_mouse_state(enum menu_input_mouse_state state); bool menu_input_mouse_check_vector_inside_hitbox(menu_input_ctx_hitbox_t *hitbox); - bool menu_input_ctl(enum menu_input_ctl_state state, void *data); RETRO_END_DECLS From c64cc373af5135cd8ca97855478de35fa44d4202 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 18:46:59 +0200 Subject: [PATCH 097/334] Add menu_input_dialog_get_display_kb --- menu/menu_input.c | 9 +++++++++ menu/menu_input.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/menu/menu_input.c b/menu/menu_input.c index bd8ade3cf9..8b57d66911 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -736,6 +736,15 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data) return true; } +bool menu_input_dialog_get_display_kb(void) +{ + menu_input_t *menu_input = menu_input_get_ptr(); + + if (!menu_input) + return false; + return menu_input->keyboard.display; +} + void menu_input_dialog_display_kb(void) { menu_input_t *menu_input = menu_input_get_ptr(); diff --git a/menu/menu_input.h b/menu/menu_input.h index 09b60538b0..487dd601e9 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -117,6 +117,8 @@ void menu_input_dialog_hide_kb(void); void menu_input_dialog_display_kb(void); +bool menu_input_dialog_get_display_kb(void); + bool menu_input_dialog_start(menu_input_ctx_line_t *line); void menu_input_dialog_end(void); From bb5543c2a1b3bd40e446dc17de11d48921f70d63 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 18:50:33 +0200 Subject: [PATCH 098/334] Cleanups --- menu/drivers/materialui.c | 5 +---- menu/drivers/rgui.c | 6 ++---- menu/drivers/xmb.c | 5 +---- menu/menu_input.c | 6 ------ menu/menu_input.h | 1 - 5 files changed, 4 insertions(+), 19 deletions(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 805eaba000..e310e10da1 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -845,7 +845,6 @@ static void mui_frame(void *data) unsigned header_height = 0; size_t selection = 0; size_t title_margin = 0; - bool display_kb = false; mui_handle_t *mui = (mui_handle_t*)data; uint64_t *frame_count = video_driver_get_frame_count_ptr(); settings_t *settings = config_get_ptr(); @@ -1204,9 +1203,7 @@ static void mui_frame(void *data) mui_draw_scrollbar(mui, width, height, &grey_bg[0]); - menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_DISPLAY, &display_kb); - - if (display_kb) + if (menu_input_dialog_get_display_kb()) { const char *str = NULL, *label = NULL; menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_BUFF_PTR, &str); diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 4209a3bfa8..53cbd5e319 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -383,11 +383,11 @@ static void rgui_render(void *data) { menu_animation_ctx_ticker_t ticker; unsigned x, y; - bool display_kb, msg_force; uint16_t hover_color, normal_color; size_t i, end, fb_pitch, old_start; unsigned fb_width, fb_height; int bottom; + bool msg_force = false; uint64_t *frame_count = NULL; char title[256] = {0}; char title_buf[256] = {0}; @@ -609,9 +609,7 @@ static void rgui_render(void *data) entry_selected ? hover_color : normal_color); } - menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_DISPLAY, &display_kb); - - if (display_kb) + if (menu_input_dialog_get_display_kb()) { const char *str = NULL; const char *label = NULL; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index cfede46cd6..30590114aa 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2152,7 +2152,6 @@ static void xmb_frame(void *data) char msg[PATH_MAX_LENGTH] = {0}; char title_msg[256] = {0}; char title_truncated[256] = {0}; - bool display_kb = false; bool render_background = false; file_list_t *selection_buf = NULL; file_list_t *menu_stack = NULL; @@ -2365,9 +2364,7 @@ static void xmb_frame(void *data) menu_display_font_flush_block(); - menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_DISPLAY, &display_kb); - - if (display_kb) + if (menu_input_dialog_get_display_kb()) { const char *str = NULL; const char *label = NULL; diff --git a/menu/menu_input.c b/menu/menu_input.c index 8b57d66911..42913762ca 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -693,12 +693,6 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data) case MENU_INPUT_CTL_UNSET_POINTER_DRAGGED: pointer_dragging = false; break; - case MENU_INPUT_CTL_KEYBOARD_DISPLAY: - { - bool *ptr = (bool*)data; - *ptr = menu_input->keyboard.display; - } - break; case MENU_INPUT_CTL_KEYBOARD_BUFF_PTR: { const char **ptr = (const char**)data; diff --git a/menu/menu_input.h b/menu/menu_input.h index 487dd601e9..dbba03c2e0 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -76,7 +76,6 @@ enum menu_input_ctl_state MENU_INPUT_CTL_IS_POINTER_DRAGGED, MENU_INPUT_CTL_SET_POINTER_DRAGGED, MENU_INPUT_CTL_UNSET_POINTER_DRAGGED, - MENU_INPUT_CTL_KEYBOARD_DISPLAY, MENU_INPUT_CTL_KEYBOARD_BUFF_PTR, MENU_INPUT_CTL_KEYBOARD_LABEL, MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, From 982a818b4882f483789234f9b24a2c23b735f10d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 18:56:51 +0200 Subject: [PATCH 099/334] Create menu_input_dialog_get_buffer --- menu/drivers/materialui.c | 5 +++-- menu/drivers/rgui.c | 4 ++-- menu/drivers/xmb.c | 4 ++-- menu/drivers/xui.cpp | 7 ++++--- menu/menu_input.c | 10 ++++------ menu/menu_input.h | 3 ++- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index e310e10da1..c14fe56774 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -1205,8 +1205,9 @@ static void mui_frame(void *data) if (menu_input_dialog_get_display_kb()) { - const char *str = NULL, *label = NULL; - menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_BUFF_PTR, &str); + const char *label = NULL; + const char *str = menu_input_dialog_get_buffer(); + menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL, &label); if (!str) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 53cbd5e319..5067944de2 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -611,9 +611,9 @@ static void rgui_render(void *data) if (menu_input_dialog_get_display_kb()) { - const char *str = NULL; const char *label = NULL; - menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_BUFF_PTR, &str); + const char *str = menu_input_dialog_get_buffer(); + menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL, &label); if (!str) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 30590114aa..c55818fc87 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2366,9 +2366,9 @@ static void xmb_frame(void *data) if (menu_input_dialog_get_display_kb()) { - const char *str = NULL; const char *label = NULL; - menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_BUFF_PTR, &str); + const char *str = menu_input_dialog_get_buffer(); + menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL, &label); if (!str) diff --git a/menu/drivers/xui.cpp b/menu/drivers/xui.cpp index eab675ffe3..d9ad4f6fb4 100644 --- a/menu/drivers/xui.cpp +++ b/menu/drivers/xui.cpp @@ -592,9 +592,10 @@ static void xui_render(void *data) if (display_kb) { - char msg[1024] = {0}; - const char *str = NULL, *label = NULL; - menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_BUFF_PTR, &str); + char msg[1024] = {0}; + const char *label = NULL; + const char *str = menu_input_dialog_get_buffer(); + menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL, &label); if (!str) diff --git a/menu/menu_input.c b/menu/menu_input.c index 42913762ca..50230d3d85 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -635,6 +635,10 @@ bool menu_input_mouse_check_vector_inside_hitbox(menu_input_ctx_hitbox_t *hitbox return inside_hitbox; } +const char *menu_input_dialog_get_buffer(void) +{ + return *menu_input_keyboard_buffer; +} bool menu_input_ctl(enum menu_input_ctl_state state, void *data) { @@ -693,12 +697,6 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data) case MENU_INPUT_CTL_UNSET_POINTER_DRAGGED: pointer_dragging = false; break; - case MENU_INPUT_CTL_KEYBOARD_BUFF_PTR: - { - const char **ptr = (const char**)data; - *ptr = *menu_input_keyboard_buffer; - } - break; case MENU_INPUT_CTL_KEYBOARD_LABEL: { const char **ptr = (const char**)data; diff --git a/menu/menu_input.h b/menu/menu_input.h index dbba03c2e0..6726891cde 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -76,7 +76,6 @@ enum menu_input_ctl_state MENU_INPUT_CTL_IS_POINTER_DRAGGED, MENU_INPUT_CTL_SET_POINTER_DRAGGED, MENU_INPUT_CTL_UNSET_POINTER_DRAGGED, - MENU_INPUT_CTL_KEYBOARD_BUFF_PTR, MENU_INPUT_CTL_KEYBOARD_LABEL, MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, MENU_INPUT_CTL_DEINIT, @@ -110,6 +109,8 @@ typedef struct menu_input_ctx_line input_keyboard_line_complete_t cb; } menu_input_ctx_line_t; +const char *menu_input_dialog_get_buffer(void); + bool menu_input_dialog_start_search(void); void menu_input_dialog_hide_kb(void); From e8e16aca9e613145ecfb747849ef0fb96d47616f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 19:01:33 +0200 Subject: [PATCH 100/334] Create menu_input_dialog_get_label_buffer functions --- menu/drivers/rgui.c | 2 -- menu/menu_input.c | 11 +++++++++++ menu/menu_input.h | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 5067944de2..306acc9838 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -616,8 +616,6 @@ static void rgui_render(void *data) menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL, &label); - if (!str) - str = ""; snprintf(msg, sizeof(msg), "%s\n%s", label, str); rgui_render_messagebox(msg); } diff --git a/menu/menu_input.c b/menu/menu_input.c index 50230d3d85..48d967ddff 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -138,10 +138,21 @@ static menu_input_t *menu_input_get_ptr(void) return &menu_input_state; } + static const char **menu_input_keyboard_buffer; static char menu_input_keyboard_label_setting[256] = {0}; static char menu_input_keyboard_label[256] = {0}; +const char *menu_input_dialog_get_label_buffer(void) +{ + return menu_input_keyboard_label; +} + +const char *menu_input_dialog_get_label_setting_buffer(void) +{ + return menu_input_keyboard_label_setting; +} + void menu_input_dialog_end(void) { menu_input_t *menu_input = menu_input_get_ptr(); diff --git a/menu/menu_input.h b/menu/menu_input.h index 6726891cde..2c31b03379 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -109,6 +109,10 @@ typedef struct menu_input_ctx_line input_keyboard_line_complete_t cb; } menu_input_ctx_line_t; +const char *menu_input_dialog_get_label_setting_buffer(void); + +const char *menu_input_dialog_get_label_buffer(void); + const char *menu_input_dialog_get_buffer(void); bool menu_input_dialog_start_search(void); From 5cf53713145b5be96238c55997b93071ec586d15 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 19:07:30 +0200 Subject: [PATCH 101/334] Refactor menu_input_dialog --- menu/cbs/menu_cbs_ok.c | 14 +++++--------- menu/drivers/materialui.c | 6 +----- menu/drivers/rgui.c | 4 +--- menu/drivers/xmb.c | 6 +----- menu/drivers/xui.cpp | 14 +++++--------- menu/menu_input.c | 29 ++++++----------------------- menu/menu_input.h | 2 -- setting_list.c | 6 ++---- 8 files changed, 21 insertions(+), 60 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 5170e17775..850294d3b0 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1485,11 +1485,9 @@ static void menu_input_st_string_cb_save_preset(void *userdata, { if (str && *str) { - rarch_setting_t *setting = NULL; - const char *label = NULL; - bool ret = false; - - menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, &label); + rarch_setting_t *setting = NULL; + bool ret = false; + const char *label = menu_input_dialog_get_label_buffer(); if (!string_is_empty(label)) setting = menu_setting_find(label); @@ -1616,10 +1614,8 @@ static void menu_input_st_string_cb_cheat_file_save_as( { if (str && *str) { - rarch_setting_t *setting = NULL; - const char *label = NULL; - - menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, &label); + rarch_setting_t *setting = NULL; + const char *label = menu_input_dialog_get_label_buffer(); if (!string_is_empty(label)) setting = menu_setting_find(label); diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index c14fe56774..430a7bdfa8 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -1205,13 +1205,9 @@ static void mui_frame(void *data) if (menu_input_dialog_get_display_kb()) { - const char *label = NULL; const char *str = menu_input_dialog_get_buffer(); + const char *label = menu_input_dialog_get_label_buffer(); - menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL, &label); - - if (!str) - str = ""; mui_render_quad(mui, 0, 0, width, height, width, height, &black_bg[0]); snprintf(msg, sizeof(msg), "%s\n%s", label, str); mui_render_messagebox(mui, msg, &body_bg_color[0], font_hover_color); diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 306acc9838..6f1f584330 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -611,10 +611,8 @@ static void rgui_render(void *data) if (menu_input_dialog_get_display_kb()) { - const char *label = NULL; const char *str = menu_input_dialog_get_buffer(); - - menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL, &label); + const char *label = menu_input_dialog_get_label_buffer(); snprintf(msg, sizeof(msg), "%s\n%s", label, str); rgui_render_messagebox(msg); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index c55818fc87..5afdf65b72 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2366,13 +2366,9 @@ static void xmb_frame(void *data) if (menu_input_dialog_get_display_kb()) { - const char *label = NULL; const char *str = menu_input_dialog_get_buffer(); + const char *label = menu_input_dialog_get_label_buffer(); - menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL, &label); - - if (!str) - str = ""; snprintf(msg, sizeof(msg), "%s\n%s", label, str); render_background = true; } diff --git a/menu/drivers/xui.cpp b/menu/drivers/xui.cpp index d9ad4f6fb4..d7eb9c09bd 100644 --- a/menu/drivers/xui.cpp +++ b/menu/drivers/xui.cpp @@ -526,10 +526,10 @@ static void xui_set_list_text(int index, const wchar_t* leftText, static void xui_render(void *data) { uint64_t *frame_count; - bool display_kb, msg_force; unsigned fb_width; size_t end, i, selection; char title[PATH_MAX_LENGTH] = {0}; + bool msg_force = false; const char *dir = NULL; const char *label = NULL; unsigned menu_type = 0; @@ -584,22 +584,18 @@ static void xui_render(void *data) mbstowcs(msg_right, entry_value, sizeof(msg_right) / sizeof(wchar_t)); xui_set_list_text(i, msg_left, msg_right); } + if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) return; + XuiListSetCurSelVisible(m_menulist, selection); - menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_DISPLAY, &display_kb); - - if (display_kb) + if (menu_input_dialog_get_display_kb()) { char msg[1024] = {0}; - const char *label = NULL; const char *str = menu_input_dialog_get_buffer(); + const char *label = menu_input_dialog_get_label_buffer(); - menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL, &label); - - if (!str) - str = ""; snprintf(msg, sizeof(msg), "%s\n%s", label, str); xui_render_messagebox(msg); } diff --git a/menu/menu_input.c b/menu/menu_input.c index 48d967ddff..46376b0417 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -190,12 +190,9 @@ void menu_input_st_uint_cb(void *userdata, const char *str) { if (str && *str) { - rarch_setting_t *setting = NULL; - const char *label = NULL; + const char *label = menu_input_dialog_get_label_buffer(); + rarch_setting_t *setting = menu_setting_find(label); - menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, &label); - - setting = menu_setting_find(label); setting_set_with_string_representation(setting, str); } @@ -206,12 +203,8 @@ void menu_input_st_hex_cb(void *userdata, const char *str) { if (str && *str) { - rarch_setting_t *setting = NULL; - const char *label = NULL; - - menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, &label); - - setting = menu_setting_find(label); + const char *label = menu_input_dialog_get_label_buffer(); + rarch_setting_t *setting = menu_setting_find(label); if (setting) { @@ -648,6 +641,8 @@ bool menu_input_mouse_check_vector_inside_hitbox(menu_input_ctx_hitbox_t *hitbox const char *menu_input_dialog_get_buffer(void) { + if (!(*menu_input_keyboard_buffer)) + return ""; return *menu_input_keyboard_buffer; } @@ -708,18 +703,6 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data) case MENU_INPUT_CTL_UNSET_POINTER_DRAGGED: pointer_dragging = false; break; - case MENU_INPUT_CTL_KEYBOARD_LABEL: - { - const char **ptr = (const char**)data; - *ptr = menu_input_keyboard_label; - } - break; - case MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING: - { - const char **ptr = (const char**)data; - *ptr = menu_input_keyboard_label_setting; - } - break; case MENU_INPUT_CTL_BIND_NONE: case MENU_INPUT_CTL_BIND_SINGLE: case MENU_INPUT_CTL_BIND_ALL: diff --git a/menu/menu_input.h b/menu/menu_input.h index 2c31b03379..23798c8ecf 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -76,8 +76,6 @@ enum menu_input_ctl_state MENU_INPUT_CTL_IS_POINTER_DRAGGED, MENU_INPUT_CTL_SET_POINTER_DRAGGED, MENU_INPUT_CTL_UNSET_POINTER_DRAGGED, - MENU_INPUT_CTL_KEYBOARD_LABEL, - MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, MENU_INPUT_CTL_DEINIT, MENU_INPUT_CTL_BIND_NONE, MENU_INPUT_CTL_BIND_SINGLE, diff --git a/setting_list.c b/setting_list.c index e833f2f6b2..d29a28eada 100644 --- a/setting_list.c +++ b/setting_list.c @@ -1772,10 +1772,8 @@ static void menu_input_st_string_cb(void *userdata, const char *str) { if (str && *str) { - rarch_setting_t *setting = NULL; - const char *label = NULL; - - menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, &label); + rarch_setting_t *setting = NULL; + const char *label = menu_input_dialog_get_label_buffer(); if (!string_is_empty(label)) setting = menu_setting_find(label); From 760d4811e00a95ff6f0c7df82bc7cbb99023be32 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 19:16:16 +0200 Subject: [PATCH 102/334] Cleanups --- menu/menu_input.c | 144 +++++++++++++++++++--------------------------- menu/menu_input.h | 2 + 2 files changed, 62 insertions(+), 84 deletions(-) diff --git a/menu/menu_input.c b/menu/menu_input.c index 46376b0417..fda6118571 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -115,12 +115,6 @@ typedef struct menu_input unsigned ptr; } pointer; - struct - { - bool display; - unsigned type; - unsigned idx; - } keyboard; /* Used for key repeat */ struct @@ -138,36 +132,6 @@ static menu_input_t *menu_input_get_ptr(void) return &menu_input_state; } - -static const char **menu_input_keyboard_buffer; -static char menu_input_keyboard_label_setting[256] = {0}; -static char menu_input_keyboard_label[256] = {0}; - -const char *menu_input_dialog_get_label_buffer(void) -{ - return menu_input_keyboard_label; -} - -const char *menu_input_dialog_get_label_setting_buffer(void) -{ - return menu_input_keyboard_label_setting; -} - -void menu_input_dialog_end(void) -{ - menu_input_t *menu_input = menu_input_get_ptr(); - - if (!menu_input) - return; - - menu_input->keyboard.display = false; - menu_input_keyboard_label[0] = '\0'; - menu_input_keyboard_label_setting[0] = '\0'; - - /* Avoid triggering states on pressing return. */ - input_driver_set_flushing_input(); -} - static void menu_input_search_cb(void *userdata, const char *str) { size_t idx = 0; @@ -221,17 +185,12 @@ void menu_input_st_hex_cb(void *userdata, const char *str) void menu_input_st_cheat_cb(void *userdata, const char *str) { - menu_input_t *menu_input = menu_input_get_ptr(); - (void)userdata; - if (!menu_input) - return; - if (str && *str) { - unsigned cheat_index = - menu_input->keyboard.type - MENU_SETTINGS_CHEAT_BEGIN; + unsigned cheat_index = menu_input_dialog_get_kb_type() + - MENU_SETTINGS_CHEAT_BEGIN; cheat_manager_set_code(cheat_index, str); } @@ -639,13 +598,6 @@ bool menu_input_mouse_check_vector_inside_hitbox(menu_input_ctx_hitbox_t *hitbox return inside_hitbox; } -const char *menu_input_dialog_get_buffer(void) -{ - if (!(*menu_input_keyboard_buffer)) - return ""; - return *menu_input_keyboard_buffer; -} - bool menu_input_ctl(enum menu_input_ctl_state state, void *data) { static bool pointer_dragging = false; @@ -722,48 +674,74 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data) return true; } +static const char **menu_input_dialog_keyboard_buffer; +static bool menu_input_dialog_keyboard_display = false; +static unsigned menu_input_dialog_keyboard_type = 0; +static unsigned menu_input_dialog_keyboard_idx = 0; +static char menu_input_dialog_keyboard_label_setting[256] = {0}; +static char menu_input_dialog_keyboard_label[256] = {0}; + +const char *menu_input_dialog_get_label_buffer(void) +{ + return menu_input_dialog_keyboard_label; +} + +const char *menu_input_dialog_get_label_setting_buffer(void) +{ + return menu_input_dialog_keyboard_label_setting; +} + +void menu_input_dialog_end(void) +{ + menu_input_dialog_keyboard_type = 0; + menu_input_dialog_keyboard_idx = 0; + menu_input_dialog_keyboard_display = false; + menu_input_dialog_keyboard_label[0] = '\0'; + menu_input_dialog_keyboard_label_setting[0] = '\0'; + + /* Avoid triggering states on pressing return. */ + input_driver_set_flushing_input(); +} + +const char *menu_input_dialog_get_buffer(void) +{ + if (!(*menu_input_dialog_keyboard_buffer)) + return ""; + return *menu_input_dialog_keyboard_buffer; +} + +unsigned menu_input_dialog_get_kb_type(void) +{ + return menu_input_dialog_keyboard_type; +} + bool menu_input_dialog_get_display_kb(void) { - menu_input_t *menu_input = menu_input_get_ptr(); - - if (!menu_input) - return false; - return menu_input->keyboard.display; + return menu_input_dialog_keyboard_display; } void menu_input_dialog_display_kb(void) { - menu_input_t *menu_input = menu_input_get_ptr(); - - if (!menu_input) - return; - menu_input->keyboard.display = true; + menu_input_dialog_keyboard_display = true; } void menu_input_dialog_hide_kb(void) { - menu_input_t *menu_input = menu_input_get_ptr(); - - if (!menu_input) - return; - menu_input->keyboard.display = false; + menu_input_dialog_keyboard_display = false; } bool menu_input_dialog_start_search(void) { menu_handle_t *menu = NULL; - menu_input_t *menu_input = menu_input_get_ptr(); - if (!menu_input) - return false; if (!menu_driver_ctl( RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return false; - menu_input->keyboard.display = true; - strlcpy(menu_input_keyboard_label, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SEARCH), - sizeof(menu_input_keyboard_label)); - menu_input_keyboard_buffer = + menu_input_dialog_display_kb(); + strlcpy(menu_input_dialog_keyboard_label, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SEARCH), + sizeof(menu_input_dialog_keyboard_label)); + menu_input_dialog_keyboard_buffer = input_keyboard_start_line(menu, menu_input_search_cb); return true; @@ -772,21 +750,20 @@ bool menu_input_dialog_start_search(void) bool menu_input_dialog_start(menu_input_ctx_line_t *line) { menu_handle_t *menu = NULL; - menu_input_t *menu_input = menu_input_get_ptr(); - if (!menu_input || !line) + if (!line) return false; if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return false; - menu_input->keyboard.display = true; - strlcpy(menu_input_keyboard_label, line->label, - sizeof(menu_input_keyboard_label)); - strlcpy(menu_input_keyboard_label_setting, - line->label_setting, sizeof(menu_input_keyboard_label_setting)); + menu_input_dialog_display_kb(); + strlcpy(menu_input_dialog_keyboard_label, line->label, + sizeof(menu_input_dialog_keyboard_label)); + strlcpy(menu_input_dialog_keyboard_label_setting, + line->label_setting, sizeof(menu_input_dialog_keyboard_label_setting)); - menu_input->keyboard.type = line->type; - menu_input->keyboard.idx = line->idx; - menu_input_keyboard_buffer = + menu_input_dialog_keyboard_type = line->type; + menu_input_dialog_keyboard_idx = line->idx; + menu_input_dialog_keyboard_buffer = input_keyboard_start_line(menu, line->cb); return true; @@ -1230,7 +1207,6 @@ static unsigned menu_input_frame_build(retro_input_t trigger_input) return menu_input_frame_pointer(&ret); } - unsigned menu_input_frame_retropad(retro_input_t input, retro_input_t trigger_input) { @@ -1301,7 +1277,7 @@ unsigned menu_input_frame_retropad(retro_input_t input, if (menu_animation_ctl(MENU_ANIMATION_CTL_IDEAL_DELTA_TIME_GET, &delta)) menu_input->delay.count += delta.ideal; - if (menu_input->keyboard.display) + if (menu_input_dialog_get_display_kb()) { static unsigned ti_char = 64; static bool ti_next = false; diff --git a/menu/menu_input.h b/menu/menu_input.h index 23798c8ecf..46dba8b5cb 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -113,6 +113,8 @@ const char *menu_input_dialog_get_label_buffer(void); const char *menu_input_dialog_get_buffer(void); +unsigned menu_input_dialog_get_kb_type(void); + bool menu_input_dialog_start_search(void); void menu_input_dialog_hide_kb(void); From 8fd5c5817af30e0fa1b02e3e6f7b13f7e88b24a3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 19:23:32 +0200 Subject: [PATCH 103/334] Create menu_input_dialog --- Makefile.common | 1 + griffin/griffin.c | 1 + menu/cbs/menu_cbs_ok.c | 1 + menu/menu_input.c | 114 +------------------------- menu/menu_input.h | 29 ------- menu/widgets/menu_input_dialog.c | 136 +++++++++++++++++++++++++++++++ menu/widgets/menu_input_dialog.h | 62 ++++++++++++++ setting_list.c | 1 + 8 files changed, 203 insertions(+), 142 deletions(-) create mode 100644 menu/widgets/menu_input_dialog.c create mode 100644 menu/widgets/menu_input_dialog.h diff --git a/Makefile.common b/Makefile.common index 66e83b860c..439b56aaad 100644 --- a/Makefile.common +++ b/Makefile.common @@ -510,6 +510,7 @@ ifeq ($(HAVE_MENU_COMMON), 1) menu/menu_setting.o \ menu/menu_shader.o \ menu/widgets/menu_dialog.o \ + menu/widgets/menu_input_dialog.o \ menu/widgets/menu_entry.o \ menu/widgets/menu_list.o \ menu/menu_cbs.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index 297ad69350..37f0c26a88 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -894,6 +894,7 @@ MENU #include "../menu/menu_content.c" #include "../menu/widgets/menu_entry.c" #include "../menu/widgets/menu_dialog.c" +#include "../menu/widgets/menu_input_dialog.c" #include "../menu/widgets/menu_list.c" #include "../menu/cbs/menu_cbs_ok.c" #include "../menu/cbs/menu_cbs_cancel.c" diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 850294d3b0..49926c8776 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -32,6 +32,7 @@ #include "../menu_shader.h" #include "../menu_navigation.h" #include "../widgets/menu_dialog.h" +#include "../widgets/menu_input_dialog.h" #include "../menu_content.h" #include "../../core.h" diff --git a/menu/menu_input.c b/menu/menu_input.c index fda6118571..41d4bac4a4 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -40,6 +40,7 @@ #include "menu_animation.h" #include "menu_display.h" #include "widgets/menu_entry.h" +#include "widgets/menu_input_dialog.h" #include "menu_setting.h" #include "menu_shader.h" #include "menu_navigation.h" @@ -132,24 +133,6 @@ static menu_input_t *menu_input_get_ptr(void) return &menu_input_state; } -static void menu_input_search_cb(void *userdata, const char *str) -{ - size_t idx = 0; - file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); - - if (!selection_buf) - return; - - if (str && *str && file_list_search(selection_buf, str, &idx)) - { - bool scroll = true; - menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx); - menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll); - } - - menu_input_dialog_end(); -} - void menu_input_st_uint_cb(void *userdata, const char *str) { if (str && *str) @@ -674,101 +657,6 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data) return true; } -static const char **menu_input_dialog_keyboard_buffer; -static bool menu_input_dialog_keyboard_display = false; -static unsigned menu_input_dialog_keyboard_type = 0; -static unsigned menu_input_dialog_keyboard_idx = 0; -static char menu_input_dialog_keyboard_label_setting[256] = {0}; -static char menu_input_dialog_keyboard_label[256] = {0}; - -const char *menu_input_dialog_get_label_buffer(void) -{ - return menu_input_dialog_keyboard_label; -} - -const char *menu_input_dialog_get_label_setting_buffer(void) -{ - return menu_input_dialog_keyboard_label_setting; -} - -void menu_input_dialog_end(void) -{ - menu_input_dialog_keyboard_type = 0; - menu_input_dialog_keyboard_idx = 0; - menu_input_dialog_keyboard_display = false; - menu_input_dialog_keyboard_label[0] = '\0'; - menu_input_dialog_keyboard_label_setting[0] = '\0'; - - /* Avoid triggering states on pressing return. */ - input_driver_set_flushing_input(); -} - -const char *menu_input_dialog_get_buffer(void) -{ - if (!(*menu_input_dialog_keyboard_buffer)) - return ""; - return *menu_input_dialog_keyboard_buffer; -} - -unsigned menu_input_dialog_get_kb_type(void) -{ - return menu_input_dialog_keyboard_type; -} - -bool menu_input_dialog_get_display_kb(void) -{ - return menu_input_dialog_keyboard_display; -} - -void menu_input_dialog_display_kb(void) -{ - menu_input_dialog_keyboard_display = true; -} - -void menu_input_dialog_hide_kb(void) -{ - menu_input_dialog_keyboard_display = false; -} - -bool menu_input_dialog_start_search(void) -{ - menu_handle_t *menu = NULL; - - if (!menu_driver_ctl( - RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) - return false; - - menu_input_dialog_display_kb(); - strlcpy(menu_input_dialog_keyboard_label, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SEARCH), - sizeof(menu_input_dialog_keyboard_label)); - menu_input_dialog_keyboard_buffer = - input_keyboard_start_line(menu, menu_input_search_cb); - - return true; -} - -bool menu_input_dialog_start(menu_input_ctx_line_t *line) -{ - menu_handle_t *menu = NULL; - if (!line) - return false; - if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) - return false; - - menu_input_dialog_display_kb(); - strlcpy(menu_input_dialog_keyboard_label, line->label, - sizeof(menu_input_dialog_keyboard_label)); - strlcpy(menu_input_dialog_keyboard_label_setting, - line->label_setting, sizeof(menu_input_dialog_keyboard_label_setting)); - - menu_input_dialog_keyboard_type = line->type; - menu_input_dialog_keyboard_idx = line->idx; - menu_input_dialog_keyboard_buffer = - input_keyboard_start_line(menu, line->cb); - - return true; -} - static int menu_input_pointer(unsigned *action) { const struct retro_keybind *binds[MAX_USERS] = {NULL}; diff --git a/menu/menu_input.h b/menu/menu_input.h index 46dba8b5cb..a448cd2e64 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -98,35 +98,6 @@ typedef struct menu_input_ctx_bind size_t len; } menu_input_ctx_bind_t; -typedef struct menu_input_ctx_line -{ - const char *label; - const char *label_setting; - unsigned type; - unsigned idx; - input_keyboard_line_complete_t cb; -} menu_input_ctx_line_t; - -const char *menu_input_dialog_get_label_setting_buffer(void); - -const char *menu_input_dialog_get_label_buffer(void); - -const char *menu_input_dialog_get_buffer(void); - -unsigned menu_input_dialog_get_kb_type(void); - -bool menu_input_dialog_start_search(void); - -void menu_input_dialog_hide_kb(void); - -void menu_input_dialog_display_kb(void); - -bool menu_input_dialog_get_display_kb(void); - -bool menu_input_dialog_start(menu_input_ctx_line_t *line); - -void menu_input_dialog_end(void); - typedef struct menu_input_ctx_bind_limits { unsigned min; diff --git a/menu/widgets/menu_input_dialog.c b/menu/widgets/menu_input_dialog.c new file mode 100644 index 0000000000..f0356d58f7 --- /dev/null +++ b/menu/widgets/menu_input_dialog.c @@ -0,0 +1,136 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2016 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include + +#include "menu_input_dialog.h" + +#include "../menu_driver.h" +#include "../menu_navigation.h" +#include "../../input/input_driver.h" + +static const char **menu_input_dialog_keyboard_buffer = {NULL}; +static bool menu_input_dialog_keyboard_display = false; +static unsigned menu_input_dialog_keyboard_type = 0; +static unsigned menu_input_dialog_keyboard_idx = 0; +static char menu_input_dialog_keyboard_label_setting[256] = {0}; +static char menu_input_dialog_keyboard_label[256] = {0}; + +static void menu_input_search_cb(void *userdata, const char *str) +{ + size_t idx = 0; + file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); + + if (!selection_buf) + return; + + if (str && *str && file_list_search(selection_buf, str, &idx)) + { + bool scroll = true; + menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx); + menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll); + } + + menu_input_dialog_end(); +} + +const char *menu_input_dialog_get_label_buffer(void) +{ + return menu_input_dialog_keyboard_label; +} + +const char *menu_input_dialog_get_label_setting_buffer(void) +{ + return menu_input_dialog_keyboard_label_setting; +} + +void menu_input_dialog_end(void) +{ + menu_input_dialog_keyboard_type = 0; + menu_input_dialog_keyboard_idx = 0; + menu_input_dialog_keyboard_display = false; + menu_input_dialog_keyboard_label[0] = '\0'; + menu_input_dialog_keyboard_label_setting[0] = '\0'; + + /* Avoid triggering states on pressing return. */ + input_driver_set_flushing_input(); +} + +const char *menu_input_dialog_get_buffer(void) +{ + if (!(*menu_input_dialog_keyboard_buffer)) + return ""; + return *menu_input_dialog_keyboard_buffer; +} + +unsigned menu_input_dialog_get_kb_type(void) +{ + return menu_input_dialog_keyboard_type; +} + +bool menu_input_dialog_get_display_kb(void) +{ + return menu_input_dialog_keyboard_display; +} + +void menu_input_dialog_display_kb(void) +{ + menu_input_dialog_keyboard_display = true; +} + +void menu_input_dialog_hide_kb(void) +{ + menu_input_dialog_keyboard_display = false; +} + +bool menu_input_dialog_start_search(void) +{ + menu_handle_t *menu = NULL; + + if (!menu_driver_ctl( + RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) + return false; + + menu_input_dialog_display_kb(); + strlcpy(menu_input_dialog_keyboard_label, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SEARCH), + sizeof(menu_input_dialog_keyboard_label)); + menu_input_dialog_keyboard_buffer = + input_keyboard_start_line(menu, menu_input_search_cb); + + return true; +} + +bool menu_input_dialog_start(menu_input_ctx_line_t *line) +{ + menu_handle_t *menu = NULL; + if (!line) + return false; + if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) + return false; + + menu_input_dialog_display_kb(); + strlcpy(menu_input_dialog_keyboard_label, line->label, + sizeof(menu_input_dialog_keyboard_label)); + strlcpy(menu_input_dialog_keyboard_label_setting, + line->label_setting, sizeof(menu_input_dialog_keyboard_label_setting)); + + menu_input_dialog_keyboard_type = line->type; + menu_input_dialog_keyboard_idx = line->idx; + menu_input_dialog_keyboard_buffer = + input_keyboard_start_line(menu, line->cb); + + return true; +} diff --git a/menu/widgets/menu_input_dialog.h b/menu/widgets/menu_input_dialog.h new file mode 100644 index 0000000000..bfdc1bdc04 --- /dev/null +++ b/menu/widgets/menu_input_dialog.h @@ -0,0 +1,62 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2016 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#ifndef _MENU_INPUT_DIALOG_H +#define _MENU_INPUT_DIALOG_H + +#include +#include + +#include + +#include + +#include "../../input/input_keyboard.h" + +RETRO_BEGIN_DECLS + +typedef struct menu_input_ctx_line +{ + const char *label; + const char *label_setting; + unsigned type; + unsigned idx; + input_keyboard_line_complete_t cb; +} menu_input_ctx_line_t; + +const char *menu_input_dialog_get_label_setting_buffer(void); + +const char *menu_input_dialog_get_label_buffer(void); + +const char *menu_input_dialog_get_buffer(void); + +unsigned menu_input_dialog_get_kb_type(void); + +bool menu_input_dialog_start_search(void); + +void menu_input_dialog_hide_kb(void); + +void menu_input_dialog_display_kb(void); + +bool menu_input_dialog_get_display_kb(void); + +bool menu_input_dialog_start(menu_input_ctx_line_t *line); + +void menu_input_dialog_end(void); + +RETRO_END_DECLS + +#endif diff --git a/setting_list.c b/setting_list.c index d29a28eada..68fb25d451 100644 --- a/setting_list.c +++ b/setting_list.c @@ -25,6 +25,7 @@ #ifdef HAVE_MENU #include "menu/menu_driver.h" +#include "menu/widgets/menu_input_dialog.h" #endif #include "configuration.h" From 82673b4db480652841a52a27a0cdb5a1bec414f4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 19:26:04 +0200 Subject: [PATCH 104/334] Warning cleanups --- menu/drivers/materialui.c | 2 ++ menu/drivers/rgui.c | 2 ++ menu/drivers/xmb.c | 1 + 3 files changed, 5 insertions(+) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 430a7bdfa8..0467a5fbaf 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -45,6 +45,8 @@ #include "../menu_navigation.h" #include "../menu_display.h" +#include "../widgets/menu_input_dialog.h" + #include "../../core_info.h" #include "../../core.h" #include "../../configuration.h" diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 6f1f584330..8802a43cb2 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -42,6 +42,8 @@ #include "../menu_display.h" #include "../menu_navigation.h" +#include "../widgets/menu_input_dialog.h" + #include "../../configuration.h" #include "../../runloop.h" #include "../../gfx/drivers_font_renderer/bitmap.h" diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 5afdf65b72..d7007865e1 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -46,6 +46,7 @@ #include "../widgets/menu_entry.h" #include "../widgets/menu_list.h" +#include "../widgets/menu_input_dialog.h" #include "../menu_cbs.h" From 68f695b196dac6f96fbce7e142531b0552b3b34c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 19:46:23 +0200 Subject: [PATCH 105/334] Buildfix --- menu/widgets/menu_entry.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/menu/widgets/menu_entry.c b/menu/widgets/menu_entry.c index 6085e178e1..0a8d9e6e6b 100644 --- a/menu/widgets/menu_entry.c +++ b/menu/widgets/menu_entry.c @@ -18,6 +18,8 @@ #include #include +#include "menu_input_dialog.h" + #include "../menu_driver.h" #include "../menu_navigation.h" From a21674881ca8adc1e6e9dcf9173fda2169e55ce6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 20:35:39 +0200 Subject: [PATCH 106/334] Add menu_input_bind_dialog --- Makefile.common | 1 + griffin/griffin.c | 1 + menu/drivers/menu_generic.c | 1 + menu/menu_input.c | 442 +------------------------ menu/menu_input.h | 11 - menu/menu_setting.c | 2 + menu/widgets/menu_input_bind_dialog.c | 454 ++++++++++++++++++++++++++ menu/widgets/menu_input_bind_dialog.h | 52 +++ 8 files changed, 515 insertions(+), 449 deletions(-) create mode 100644 menu/widgets/menu_input_bind_dialog.c create mode 100644 menu/widgets/menu_input_bind_dialog.h diff --git a/Makefile.common b/Makefile.common index 439b56aaad..9b692fe951 100644 --- a/Makefile.common +++ b/Makefile.common @@ -511,6 +511,7 @@ ifeq ($(HAVE_MENU_COMMON), 1) menu/menu_shader.o \ menu/widgets/menu_dialog.o \ menu/widgets/menu_input_dialog.o \ + menu/widgets/menu_input_bind_dialog.o \ menu/widgets/menu_entry.o \ menu/widgets/menu_list.o \ menu/menu_cbs.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index 37f0c26a88..9fca97f2c0 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -895,6 +895,7 @@ MENU #include "../menu/widgets/menu_entry.c" #include "../menu/widgets/menu_dialog.c" #include "../menu/widgets/menu_input_dialog.c" +#include "../menu/widgets/menu_input_bind_dialog.c" #include "../menu/widgets/menu_list.c" #include "../menu/cbs/menu_cbs_ok.c" #include "../menu/cbs/menu_cbs_cancel.c" diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index 33f09b176b..1ae66039a6 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -24,6 +24,7 @@ #include "../menu_display.h" #include "../menu_navigation.h" #include "../widgets/menu_dialog.h" +#include "../widgets/menu_input_bind_dialog.h" #include "../../verbosity.h" #include "../../runloop.h" diff --git a/menu/menu_input.c b/menu/menu_input.c index 41d4bac4a4..2e349065f3 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -18,29 +18,26 @@ #include "../../config.h" #endif -#define MENU_MAX_BUTTONS 219 -#define MENU_MAX_AXES 32 -#define MENU_MAX_HATS 4 - #include #include #include #include #include -#include #include #ifdef HAVE_CONFIG_H #include "../config.h" #endif +#include "widgets/menu_entry.h" +#include "widgets/menu_input_dialog.h" +#include "widgets/menu_input_bind_dialog.h" + #include "menu_driver.h" #include "menu_input.h" #include "menu_animation.h" #include "menu_display.h" -#include "widgets/menu_entry.h" -#include "widgets/menu_input_dialog.h" #include "menu_setting.h" #include "menu_shader.h" #include "menu_navigation.h" @@ -66,39 +63,8 @@ enum menu_mouse_action MENU_MOUSE_ACTION_HORIZ_WHEEL_DOWN }; -struct menu_bind_state_port -{ - bool buttons[MENU_MAX_BUTTONS]; - int16_t axes[MENU_MAX_AXES]; - uint16_t hats[MENU_MAX_HATS]; -}; - -struct menu_bind_axis_state -{ - /* Default axis state. */ - int16_t rested_axes[MENU_MAX_AXES]; - /* Locked axis state. If we configured an axis, - * avoid having the same axis state trigger something again right away. */ - int16_t locked_axes[MENU_MAX_AXES]; -}; - -struct menu_bind_state -{ - struct retro_keybind *target; - /* For keyboard binding. */ - int64_t timeout_end; - unsigned begin; - unsigned last; - unsigned user; - struct menu_bind_state_port state[MAX_USERS]; - struct menu_bind_axis_state axis_state[MAX_USERS]; - bool skip; -}; - typedef struct menu_input { - struct menu_bind_state binds; - struct { unsigned ptr; @@ -125,8 +91,6 @@ typedef struct menu_input } delay; } menu_input_t; -static unsigned bind_port; - static menu_input_t *menu_input_get_ptr(void) { static menu_input_t menu_input_state; @@ -180,393 +144,6 @@ void menu_input_st_cheat_cb(void *userdata, const char *str) menu_input_dialog_end(); } -static bool menu_input_key_bind_custom_bind_keyboard_cb( - void *data, unsigned code) -{ - menu_input_t *menu_input = menu_input_get_ptr(); - settings_t *settings = config_get_ptr(); - - if (!menu_input) - return false; - - menu_input->binds.target->key = (enum retro_key)code; - menu_input->binds.begin++; - menu_input->binds.target++; - menu_input->binds.timeout_end = cpu_features_get_time_usec() + - settings->input.bind_timeout * 1000000; - - return (menu_input->binds.begin <= menu_input->binds.last); -} - -static int menu_input_key_bind_set_mode_common( - enum menu_input_ctl_state state, - rarch_setting_t *setting) -{ - size_t selection; - unsigned index_offset, bind_type; - menu_displaylist_info_t info = {0}; - struct retro_keybind *keybind = NULL; - file_list_t *menu_stack = NULL; - settings_t *settings = config_get_ptr(); - menu_input_t *menu_input = menu_input_get_ptr(); - - if (!setting) - return -1; - - index_offset = setting_get_index_offset(setting); - menu_stack = menu_entries_get_menu_stack_ptr(0); - - menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection); - - switch (state) - { - case MENU_INPUT_CTL_BIND_NONE: - return -1; - case MENU_INPUT_CTL_BIND_SINGLE: - keybind = (struct retro_keybind*)setting_get_ptr(setting); - - if (!keybind) - return -1; - - bind_type = setting_get_bind_type(setting); - - menu_input->binds.begin = bind_type; - menu_input->binds.last = bind_type; - menu_input->binds.target = keybind; - menu_input->binds.user = index_offset; - - info.list = menu_stack; - info.type = MENU_SETTINGS_CUSTOM_BIND_KEYBOARD; - info.directory_ptr = selection; - info.enum_idx = MENU_ENUM_LABEL_CUSTOM_BIND; - strlcpy(info.label, - msg_hash_to_str(MENU_ENUM_LABEL_CUSTOM_BIND), sizeof(info.label)); - - if (menu_displaylist_ctl(DISPLAYLIST_INFO, &info)) - menu_displaylist_ctl(DISPLAYLIST_PROCESS, &info); - break; - case MENU_INPUT_CTL_BIND_ALL: - menu_input->binds.target = &settings->input.binds - [index_offset][0]; - menu_input->binds.begin = MENU_SETTINGS_BIND_BEGIN; - menu_input->binds.last = MENU_SETTINGS_BIND_LAST; - - info.list = menu_stack; - info.type = MENU_SETTINGS_CUSTOM_BIND_KEYBOARD; - info.directory_ptr = selection; - info.enum_idx = MENU_ENUM_LABEL_CUSTOM_BIND_ALL; - strlcpy(info.label, - msg_hash_to_str(MENU_ENUM_LABEL_CUSTOM_BIND_ALL), - sizeof(info.label)); - - if (menu_displaylist_ctl(DISPLAYLIST_INFO, &info)) - menu_displaylist_ctl(DISPLAYLIST_PROCESS, &info); - break; - default: - case MENU_INPUT_CTL_NONE: - break; - } - - return 0; -} - -static void menu_input_key_bind_poll_bind_get_rested_axes( - struct menu_bind_state *state, unsigned port) -{ - unsigned a; - const input_device_driver_t *joypad = - input_driver_get_joypad_driver(); - const input_device_driver_t *sec_joypad = - input_driver_get_sec_joypad_driver(); - - if (!state || !joypad) - return; - - /* poll only the relevant port */ - for (a = 0; a < MENU_MAX_AXES; a++) - state->axis_state[port].rested_axes[a] = - input_joypad_axis_raw(joypad, port, a); - - if (sec_joypad) - { - /* poll only the relevant port */ - for (a = 0; a < MENU_MAX_AXES; a++) - state->axis_state[port].rested_axes[a] = - input_joypad_axis_raw(sec_joypad, port, a); - } -} - -static void menu_input_key_bind_poll_bind_state_internal( - const input_device_driver_t *joypad, - struct menu_bind_state *state, - unsigned port, - bool timed_out) -{ - unsigned b, a, h; - if (!joypad) - return; - - if (joypad->poll) - joypad->poll(); - - /* poll only the relevant port */ - /* for (i = 0; i < settings->input.max_users; i++) */ - for (b = 0; b < MENU_MAX_BUTTONS; b++) - state->state[port].buttons[b] = - input_joypad_button_raw(joypad, port, b); - - for (a = 0; a < MENU_MAX_AXES; a++) - state->state[port].axes[a] = - input_joypad_axis_raw(joypad, port, a); - - for (h = 0; h < MENU_MAX_HATS; h++) - { - if (input_joypad_hat_raw(joypad, port, HAT_UP_MASK, h)) - state->state[port].hats[h] |= HAT_UP_MASK; - if (input_joypad_hat_raw(joypad, port, HAT_DOWN_MASK, h)) - state->state[port].hats[h] |= HAT_DOWN_MASK; - if (input_joypad_hat_raw(joypad, port, HAT_LEFT_MASK, h)) - state->state[port].hats[h] |= HAT_LEFT_MASK; - if (input_joypad_hat_raw(joypad, port, HAT_RIGHT_MASK, h)) - state->state[port].hats[h] |= HAT_RIGHT_MASK; - } -} - -static void menu_input_key_bind_poll_bind_state( - struct menu_bind_state *state, - unsigned port, - bool timed_out) -{ - const input_device_driver_t *joypad = - input_driver_get_joypad_driver(); - const input_device_driver_t *sec_joypad = - input_driver_get_sec_joypad_driver(); - - if (!state) - return; - - memset(state->state, 0, sizeof(state->state)); - state->skip = timed_out || input_driver_state(NULL, 0, - RETRO_DEVICE_KEYBOARD, 0, RETROK_RETURN); - - menu_input_key_bind_poll_bind_state_internal( - joypad, state, port, timed_out); - - if (sec_joypad) - menu_input_key_bind_poll_bind_state_internal( - sec_joypad, state, port, timed_out); -} - -static bool menu_input_key_bind_set_mode( - enum menu_input_ctl_state state, void *data) -{ - unsigned index_offset; - input_keyboard_ctx_wait_t keys; - menu_handle_t *menu = NULL; - menu_input_t *menu_input = menu_input_get_ptr(); - rarch_setting_t *setting = (rarch_setting_t*)data; - settings_t *settings = config_get_ptr(); - - if (!setting) - return false; - if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) - return false; - if (menu_input_key_bind_set_mode_common(state, setting) == -1) - return false; - - index_offset = setting_get_index_offset(setting); - bind_port = settings->input.joypad_map[index_offset]; - - menu_input_key_bind_poll_bind_get_rested_axes( - &menu_input->binds, bind_port); - menu_input_key_bind_poll_bind_state( - &menu_input->binds, bind_port, false); - - menu_input->binds.timeout_end = cpu_features_get_time_usec() + - settings->input.bind_timeout * 1000000; - - keys.userdata = menu; - keys.cb = menu_input_key_bind_custom_bind_keyboard_cb; - - input_keyboard_ctl(RARCH_INPUT_KEYBOARD_CTL_START_WAIT_KEYS, &keys); - return true; -} - -static bool menu_input_key_bind_poll_find_trigger_pad( - struct menu_bind_state *state, - struct menu_bind_state *new_state, - unsigned p) -{ - unsigned a, b, h; - const struct menu_bind_state_port *n = (const struct menu_bind_state_port*) - &new_state->state[p]; - const struct menu_bind_state_port *o = (const struct menu_bind_state_port*) - &state->state[p]; - - for (b = 0; b < MENU_MAX_BUTTONS; b++) - { - bool iterate = n->buttons[b] && !o->buttons[b]; - - if (!iterate) - continue; - - state->target->joykey = b; - state->target->joyaxis = AXIS_NONE; - return true; - } - - /* Axes are a bit tricky ... */ - for (a = 0; a < MENU_MAX_AXES; a++) - { - int locked_distance = abs(n->axes[a] - - new_state->axis_state[p].locked_axes[a]); - int rested_distance = abs(n->axes[a] - - new_state->axis_state[p].rested_axes[a]); - - if (abs(n->axes[a]) >= 20000 && - locked_distance >= 20000 && - rested_distance >= 20000) - { - /* Take care of case where axis rests on +/- 0x7fff - * (e.g. 360 controller on Linux) */ - state->target->joyaxis = n->axes[a] > 0 - ? AXIS_POS(a) : AXIS_NEG(a); - state->target->joykey = NO_BTN; - - /* Lock the current axis */ - new_state->axis_state[p].locked_axes[a] = - n->axes[a] > 0 ? - 0x7fff : -0x7fff; - return true; - } - - if (locked_distance >= 20000) /* Unlock the axis. */ - new_state->axis_state[p].locked_axes[a] = 0; - } - - for (h = 0; h < MENU_MAX_HATS; h++) - { - uint16_t trigged = n->hats[h] & (~o->hats[h]); - uint16_t sane_trigger = 0; - - if (trigged & HAT_UP_MASK) - sane_trigger = HAT_UP_MASK; - else if (trigged & HAT_DOWN_MASK) - sane_trigger = HAT_DOWN_MASK; - else if (trigged & HAT_LEFT_MASK) - sane_trigger = HAT_LEFT_MASK; - else if (trigged & HAT_RIGHT_MASK) - sane_trigger = HAT_RIGHT_MASK; - - if (sane_trigger) - { - state->target->joykey = HAT_MAP(h, sane_trigger); - state->target->joyaxis = AXIS_NONE; - return true; - } - } - - return false; -} - -static bool menu_input_key_bind_poll_find_trigger( - struct menu_bind_state *state, - struct menu_bind_state *new_state) -{ - unsigned i; - settings_t *settings = config_get_ptr(); - - if (!state || !new_state) - return false; - - for (i = 0; i < settings->input.max_users; i++) - { - if (!menu_input_key_bind_poll_find_trigger_pad( - state, new_state, i)) - continue; - - /* Update the joypad mapping automatically. - * More friendly that way. */ -#if 0 - settings->input.joypad_map[state->user] = i; -#endif - return true; - } - return false; -} - - -static bool menu_input_key_bind_iterate(char *s, size_t len) -{ - struct menu_bind_state binds; - bool timed_out = false; - menu_input_t *menu_input = menu_input_get_ptr(); - settings_t *settings = config_get_ptr(); - int64_t current = cpu_features_get_time_usec(); - int timeout = - (menu_input->binds.timeout_end - current) / 1000000; - - if (timeout <= 0) - { - input_driver_keyboard_mapping_set_block(false); - - menu_input->binds.begin++; - menu_input->binds.target++; - menu_input->binds.timeout_end = cpu_features_get_time_usec() + - settings->input.bind_timeout * 1000000; - timed_out = true; - } - - snprintf(s, len, - "[%s]\npress keyboard or joypad\n(timeout %d %s)", - input_config_bind_map_get_desc( - menu_input->binds.begin - MENU_SETTINGS_BIND_BEGIN), - timeout, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SECONDS)); - - /* binds.begin is updated in keyboard_press callback. */ - if (menu_input->binds.begin > menu_input->binds.last) - { - /* Avoid new binds triggering things right away. */ - input_driver_set_flushing_input(); - - /* We won't be getting any key events, so just cancel early. */ - if (timed_out) - input_keyboard_ctl(RARCH_INPUT_KEYBOARD_CTL_CANCEL_WAIT_KEYS, NULL); - - return true; - } - - binds = menu_input->binds; - - input_driver_keyboard_mapping_set_block(true); - menu_input_key_bind_poll_bind_state(&binds, bind_port, timed_out); - - if ((binds.skip && !menu_input->binds.skip) || - menu_input_key_bind_poll_find_trigger(&menu_input->binds, &binds)) - { - input_driver_keyboard_mapping_set_block(false); - - /* Avoid new binds triggering things right away. */ - input_driver_set_flushing_input(); - - binds.begin++; - - if (binds.begin > binds.last) - { - input_keyboard_ctl(RARCH_INPUT_KEYBOARD_CTL_CANCEL_WAIT_KEYS, NULL); - return true; - } - - binds.target++; - binds.timeout_end = cpu_features_get_time_usec() + - settings->input.bind_timeout * 1000000; - } - menu_input->binds = binds; - - return false; -} - bool menu_input_mouse_check_vector_inside_hitbox(menu_input_ctx_hitbox_t *hitbox) { int16_t mouse_x = menu_input_mouse_state(MENU_MOUSE_X_AXIS); @@ -591,17 +168,6 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data) switch (state) { - case MENU_INPUT_CTL_BIND_SET_MIN_MAX: - { - menu_input_ctx_bind_limits_t *lim = - (menu_input_ctx_bind_limits_t*)data; - if (!lim || !menu_input) - return false; - - menu_input->binds.begin = lim->min; - menu_input->binds.last = lim->max; - } - break; case MENU_INPUT_CTL_DEINIT: memset(menu_input, 0, sizeof(menu_input_t)); pointer_dragging = false; diff --git a/menu/menu_input.h b/menu/menu_input.h index a448cd2e64..5d3ea16b11 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -92,17 +92,6 @@ typedef struct menu_input_ctx_hitbox int32_t y2; } menu_input_ctx_hitbox_t; -typedef struct menu_input_ctx_bind -{ - char *s; - size_t len; -} menu_input_ctx_bind_t; - -typedef struct menu_input_ctx_bind_limits -{ - unsigned min; - unsigned max; -} menu_input_ctx_bind_limits_t; /* Keyboard input callbacks */ void menu_input_st_uint_cb (void *userdata, const char *str); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 016c8aacb4..034462435a 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -42,6 +42,8 @@ #include "../frontend/frontend_driver.h" +#include "widgets/menu_input_bind_dialog.h" + #include "menu_setting.h" #include "menu_driver.h" #include "menu_animation.h" diff --git a/menu/widgets/menu_input_bind_dialog.c b/menu/widgets/menu_input_bind_dialog.c new file mode 100644 index 0000000000..9630807bba --- /dev/null +++ b/menu/widgets/menu_input_bind_dialog.c @@ -0,0 +1,454 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2016 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include + +#include + +#include "menu_input_bind_dialog.h" + +#include "../menu_driver.h" +#include "../menu_navigation.h" + +#include "../../input/input_config.h" + +#include "../../configuration.h" + +#define MENU_MAX_BUTTONS 219 +#define MENU_MAX_AXES 32 +#define MENU_MAX_HATS 4 + +struct menu_bind_state_port +{ + bool buttons[MENU_MAX_BUTTONS]; + int16_t axes[MENU_MAX_AXES]; + uint16_t hats[MENU_MAX_HATS]; +}; + +struct menu_bind_axis_state +{ + /* Default axis state. */ + int16_t rested_axes[MENU_MAX_AXES]; + /* Locked axis state. If we configured an axis, + * avoid having the same axis state trigger something again right away. */ + int16_t locked_axes[MENU_MAX_AXES]; +}; + +struct menu_bind_state +{ + struct retro_keybind *target; + /* For keyboard binding. */ + int64_t timeout_end; + unsigned begin; + unsigned last; + unsigned user; + struct menu_bind_state_port state[MAX_USERS]; + struct menu_bind_axis_state axis_state[MAX_USERS]; + bool skip; +}; + +static unsigned menu_bind_port = 0; +static struct menu_bind_state menu_input_binds; + +static bool menu_input_key_bind_custom_bind_keyboard_cb( + void *data, unsigned code) +{ + settings_t *settings = config_get_ptr(); + + menu_input_binds.target->key = (enum retro_key)code; + menu_input_binds.begin++; + menu_input_binds.target++; + menu_input_binds.timeout_end = cpu_features_get_time_usec() + + settings->input.bind_timeout * 1000000; + + return (menu_input_binds.begin <= menu_input_binds.last); +} + +static int menu_input_key_bind_set_mode_common( + enum menu_input_ctl_state state, + rarch_setting_t *setting) +{ + size_t selection; + unsigned index_offset, bind_type; + menu_displaylist_info_t info = {0}; + struct retro_keybind *keybind = NULL; + file_list_t *menu_stack = NULL; + settings_t *settings = config_get_ptr(); + + if (!setting) + return -1; + + index_offset = setting_get_index_offset(setting); + menu_stack = menu_entries_get_menu_stack_ptr(0); + + menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection); + + switch (state) + { + case MENU_INPUT_CTL_BIND_NONE: + return -1; + case MENU_INPUT_CTL_BIND_SINGLE: + keybind = (struct retro_keybind*)setting_get_ptr(setting); + + if (!keybind) + return -1; + + bind_type = setting_get_bind_type(setting); + + menu_input_binds.begin = bind_type; + menu_input_binds.last = bind_type; + menu_input_binds.target = keybind; + menu_input_binds.user = index_offset; + + info.list = menu_stack; + info.type = MENU_SETTINGS_CUSTOM_BIND_KEYBOARD; + info.directory_ptr = selection; + info.enum_idx = MENU_ENUM_LABEL_CUSTOM_BIND; + strlcpy(info.label, + msg_hash_to_str(MENU_ENUM_LABEL_CUSTOM_BIND), sizeof(info.label)); + + if (menu_displaylist_ctl(DISPLAYLIST_INFO, &info)) + menu_displaylist_ctl(DISPLAYLIST_PROCESS, &info); + break; + case MENU_INPUT_CTL_BIND_ALL: + menu_input_binds.target = &settings->input.binds + [index_offset][0]; + menu_input_binds.begin = MENU_SETTINGS_BIND_BEGIN; + menu_input_binds.last = MENU_SETTINGS_BIND_LAST; + + info.list = menu_stack; + info.type = MENU_SETTINGS_CUSTOM_BIND_KEYBOARD; + info.directory_ptr = selection; + info.enum_idx = MENU_ENUM_LABEL_CUSTOM_BIND_ALL; + strlcpy(info.label, + msg_hash_to_str(MENU_ENUM_LABEL_CUSTOM_BIND_ALL), + sizeof(info.label)); + + if (menu_displaylist_ctl(DISPLAYLIST_INFO, &info)) + menu_displaylist_ctl(DISPLAYLIST_PROCESS, &info); + break; + default: + case MENU_INPUT_CTL_NONE: + break; + } + + return 0; +} + +static void menu_input_key_bind_poll_bind_get_rested_axes( + struct menu_bind_state *state, unsigned port) +{ + unsigned a; + const input_device_driver_t *joypad = + input_driver_get_joypad_driver(); + const input_device_driver_t *sec_joypad = + input_driver_get_sec_joypad_driver(); + + if (!state || !joypad) + return; + + /* poll only the relevant port */ + for (a = 0; a < MENU_MAX_AXES; a++) + state->axis_state[port].rested_axes[a] = + input_joypad_axis_raw(joypad, port, a); + + if (sec_joypad) + { + /* poll only the relevant port */ + for (a = 0; a < MENU_MAX_AXES; a++) + state->axis_state[port].rested_axes[a] = + input_joypad_axis_raw(sec_joypad, port, a); + } +} + +static void menu_input_key_bind_poll_bind_state_internal( + const input_device_driver_t *joypad, + struct menu_bind_state *state, + unsigned port, + bool timed_out) +{ + unsigned b, a, h; + if (!joypad) + return; + + if (joypad->poll) + joypad->poll(); + + /* poll only the relevant port */ + /* for (i = 0; i < settings->input.max_users; i++) */ + for (b = 0; b < MENU_MAX_BUTTONS; b++) + state->state[port].buttons[b] = + input_joypad_button_raw(joypad, port, b); + + for (a = 0; a < MENU_MAX_AXES; a++) + state->state[port].axes[a] = + input_joypad_axis_raw(joypad, port, a); + + for (h = 0; h < MENU_MAX_HATS; h++) + { + if (input_joypad_hat_raw(joypad, port, HAT_UP_MASK, h)) + state->state[port].hats[h] |= HAT_UP_MASK; + if (input_joypad_hat_raw(joypad, port, HAT_DOWN_MASK, h)) + state->state[port].hats[h] |= HAT_DOWN_MASK; + if (input_joypad_hat_raw(joypad, port, HAT_LEFT_MASK, h)) + state->state[port].hats[h] |= HAT_LEFT_MASK; + if (input_joypad_hat_raw(joypad, port, HAT_RIGHT_MASK, h)) + state->state[port].hats[h] |= HAT_RIGHT_MASK; + } +} + +static void menu_input_key_bind_poll_bind_state( + struct menu_bind_state *state, + unsigned port, + bool timed_out) +{ + const input_device_driver_t *joypad = + input_driver_get_joypad_driver(); + const input_device_driver_t *sec_joypad = + input_driver_get_sec_joypad_driver(); + + if (!state) + return; + + memset(state->state, 0, sizeof(state->state)); + state->skip = timed_out || input_driver_state(NULL, 0, + RETRO_DEVICE_KEYBOARD, 0, RETROK_RETURN); + + menu_input_key_bind_poll_bind_state_internal( + joypad, state, port, timed_out); + + if (sec_joypad) + menu_input_key_bind_poll_bind_state_internal( + sec_joypad, state, port, timed_out); +} + +bool menu_input_key_bind_set_mode( + enum menu_input_ctl_state state, void *data) +{ + unsigned index_offset; + input_keyboard_ctx_wait_t keys; + menu_handle_t *menu = NULL; + rarch_setting_t *setting = (rarch_setting_t*)data; + settings_t *settings = config_get_ptr(); + + if (!setting) + return false; + if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) + return false; + if (menu_input_key_bind_set_mode_common(state, setting) == -1) + return false; + + index_offset = setting_get_index_offset(setting); + menu_bind_port = settings->input.joypad_map[index_offset]; + + menu_input_key_bind_poll_bind_get_rested_axes( + &menu_input_binds, menu_bind_port); + menu_input_key_bind_poll_bind_state( + &menu_input_binds, menu_bind_port, false); + + menu_input_binds.timeout_end = cpu_features_get_time_usec() + + settings->input.bind_timeout * 1000000; + + keys.userdata = menu; + keys.cb = menu_input_key_bind_custom_bind_keyboard_cb; + + input_keyboard_ctl(RARCH_INPUT_KEYBOARD_CTL_START_WAIT_KEYS, &keys); + return true; +} + +static bool menu_input_key_bind_poll_find_trigger_pad( + struct menu_bind_state *state, + struct menu_bind_state *new_state, + unsigned p) +{ + unsigned a, b, h; + const struct menu_bind_state_port *n = (const struct menu_bind_state_port*) + &new_state->state[p]; + const struct menu_bind_state_port *o = (const struct menu_bind_state_port*) + &state->state[p]; + + for (b = 0; b < MENU_MAX_BUTTONS; b++) + { + bool iterate = n->buttons[b] && !o->buttons[b]; + + if (!iterate) + continue; + + state->target->joykey = b; + state->target->joyaxis = AXIS_NONE; + return true; + } + + /* Axes are a bit tricky ... */ + for (a = 0; a < MENU_MAX_AXES; a++) + { + int locked_distance = abs(n->axes[a] - + new_state->axis_state[p].locked_axes[a]); + int rested_distance = abs(n->axes[a] - + new_state->axis_state[p].rested_axes[a]); + + if (abs(n->axes[a]) >= 20000 && + locked_distance >= 20000 && + rested_distance >= 20000) + { + /* Take care of case where axis rests on +/- 0x7fff + * (e.g. 360 controller on Linux) */ + state->target->joyaxis = n->axes[a] > 0 + ? AXIS_POS(a) : AXIS_NEG(a); + state->target->joykey = NO_BTN; + + /* Lock the current axis */ + new_state->axis_state[p].locked_axes[a] = + n->axes[a] > 0 ? + 0x7fff : -0x7fff; + return true; + } + + if (locked_distance >= 20000) /* Unlock the axis. */ + new_state->axis_state[p].locked_axes[a] = 0; + } + + for (h = 0; h < MENU_MAX_HATS; h++) + { + uint16_t trigged = n->hats[h] & (~o->hats[h]); + uint16_t sane_trigger = 0; + + if (trigged & HAT_UP_MASK) + sane_trigger = HAT_UP_MASK; + else if (trigged & HAT_DOWN_MASK) + sane_trigger = HAT_DOWN_MASK; + else if (trigged & HAT_LEFT_MASK) + sane_trigger = HAT_LEFT_MASK; + else if (trigged & HAT_RIGHT_MASK) + sane_trigger = HAT_RIGHT_MASK; + + if (sane_trigger) + { + state->target->joykey = HAT_MAP(h, sane_trigger); + state->target->joyaxis = AXIS_NONE; + return true; + } + } + + return false; +} + +static bool menu_input_key_bind_poll_find_trigger( + struct menu_bind_state *state, + struct menu_bind_state *new_state) +{ + unsigned i; + settings_t *settings = config_get_ptr(); + + if (!state || !new_state) + return false; + + for (i = 0; i < settings->input.max_users; i++) + { + if (!menu_input_key_bind_poll_find_trigger_pad( + state, new_state, i)) + continue; + + /* Update the joypad mapping automatically. + * More friendly that way. */ +#if 0 + settings->input.joypad_map[state->user] = i; +#endif + return true; + } + return false; +} + +bool menu_input_key_bind_set_min_max(menu_input_ctx_bind_limits_t *lim) +{ + if (!lim) + return false; + + menu_input_binds.begin = lim->min; + menu_input_binds.last = lim->max; + + return true; +} + +bool menu_input_key_bind_iterate(char *s, size_t len) +{ + struct menu_bind_state binds; + bool timed_out = false; + settings_t *settings = config_get_ptr(); + int64_t current = cpu_features_get_time_usec(); + int timeout = + (menu_input_binds.timeout_end - current) / 1000000; + + if (timeout <= 0) + { + input_driver_keyboard_mapping_set_block(false); + + menu_input_binds.begin++; + menu_input_binds.target++; + menu_input_binds.timeout_end = cpu_features_get_time_usec() + + settings->input.bind_timeout * 1000000; + timed_out = true; + } + + snprintf(s, len, + "[%s]\npress keyboard or joypad\n(timeout %d %s)", + input_config_bind_map_get_desc( + menu_input_binds.begin - MENU_SETTINGS_BIND_BEGIN), + timeout, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SECONDS)); + + /* binds.begin is updated in keyboard_press callback. */ + if (menu_input_binds.begin > menu_input_binds.last) + { + /* Avoid new binds triggering things right away. */ + input_driver_set_flushing_input(); + + /* We won't be getting any key events, so just cancel early. */ + if (timed_out) + input_keyboard_ctl(RARCH_INPUT_KEYBOARD_CTL_CANCEL_WAIT_KEYS, NULL); + + return true; + } + + binds = menu_input_binds; + + input_driver_keyboard_mapping_set_block(true); + menu_input_key_bind_poll_bind_state(&binds, menu_bind_port, timed_out); + + if ((binds.skip && !menu_input_binds.skip) || + menu_input_key_bind_poll_find_trigger(&menu_input_binds, &binds)) + { + input_driver_keyboard_mapping_set_block(false); + + /* Avoid new binds triggering things right away. */ + input_driver_set_flushing_input(); + + binds.begin++; + + if (binds.begin > binds.last) + { + input_keyboard_ctl(RARCH_INPUT_KEYBOARD_CTL_CANCEL_WAIT_KEYS, NULL); + return true; + } + + binds.target++; + binds.timeout_end = cpu_features_get_time_usec() + + settings->input.bind_timeout * 1000000; + } + menu_input_binds = binds; + + return false; +} diff --git a/menu/widgets/menu_input_bind_dialog.h b/menu/widgets/menu_input_bind_dialog.h new file mode 100644 index 0000000000..607ad29f65 --- /dev/null +++ b/menu/widgets/menu_input_bind_dialog.h @@ -0,0 +1,52 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2016 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#ifndef _MENU_INPUT_BIND_DIALOG_H +#define _MENU_INPUT_BIND_DIALOG_H + +#include +#include + +#include + +#include + +#include "../menu_input.h" + +RETRO_BEGIN_DECLS + +typedef struct menu_input_ctx_bind +{ + char *s; + size_t len; +} menu_input_ctx_bind_t; + +typedef struct menu_input_ctx_bind_limits +{ + unsigned min; + unsigned max; +} menu_input_ctx_bind_limits_t; + +bool menu_input_key_bind_set_mode( + enum menu_input_ctl_state state, void *data); + +bool menu_input_key_bind_set_min_max(menu_input_ctx_bind_limits_t *lim); + +bool menu_input_key_bind_iterate(char *s, size_t len); + +RETRO_END_DECLS + +#endif From 814eb5b9050048e231bdaaada927bcaacb086e9b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 20:38:07 +0200 Subject: [PATCH 107/334] (menu_input.c) Header include cleanups --- menu/menu_input.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/menu/menu_input.c b/menu/menu_input.c index 2e349065f3..9726b5134b 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -38,17 +38,11 @@ #include "menu_input.h" #include "menu_animation.h" #include "menu_display.h" -#include "menu_setting.h" -#include "menu_shader.h" #include "menu_navigation.h" #include "../managers/cheat_manager.h" -#include "../performance_counters.h" #include "../configuration.h" #include "../core.h" -#include "../input/input_joypad_driver.h" -#include "../input/input_remapping.h" -#include "../input/input_config.h" enum menu_mouse_action { From 4c702c2d360564c9bb27930e4982500ee50430a6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 20:40:19 +0200 Subject: [PATCH 108/334] Cleanups --- menu/menu_input.h | 3 +-- menu/menu_setting.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/menu/menu_input.h b/menu/menu_input.h index 5d3ea16b11..5f04b382e9 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -80,8 +80,7 @@ enum menu_input_ctl_state MENU_INPUT_CTL_BIND_NONE, MENU_INPUT_CTL_BIND_SINGLE, MENU_INPUT_CTL_BIND_ALL, - MENU_INPUT_CTL_BIND_ITERATE, - MENU_INPUT_CTL_BIND_SET_MIN_MAX + MENU_INPUT_CTL_BIND_ITERATE }; typedef struct menu_input_ctx_hitbox diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 034462435a..0dbe9b1a15 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1296,7 +1296,7 @@ static int setting_action_ok_bind_defaults(void *data, bool wraparound) lim.min = MENU_SETTINGS_BIND_BEGIN; lim.max = MENU_SETTINGS_BIND_LAST; - menu_input_ctl(MENU_INPUT_CTL_BIND_SET_MIN_MAX, &lim); + menu_input_key_bind_set_min_max(&lim); for (i = MENU_SETTINGS_BIND_BEGIN; i <= MENU_SETTINGS_BIND_LAST; i++, target++) From a9b811410916f031830a45527c160054e6631129 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 20:45:00 +0200 Subject: [PATCH 109/334] Reafctor input_bind_dialog code --- menu/drivers/menu_generic.c | 2 +- menu/menu_input.c | 7 ------- menu/menu_input.h | 3 +-- menu/widgets/menu_input_bind_dialog.c | 9 ++++++--- menu/widgets/menu_input_bind_dialog.h | 2 +- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index 1ae66039a6..a103664149 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -137,7 +137,7 @@ int generic_menu_iterate(void *data, void *userdata, enum menu_action action) bind.s = menu->menu_state.msg; bind.len = sizeof(menu->menu_state.msg); - if (menu_input_ctl(MENU_INPUT_CTL_BIND_ITERATE, &bind)) + if (menu_input_key_bind_iterate(&bind)) { menu_entries_pop_stack(&selection, 0, 0); menu_navigation_ctl( diff --git a/menu/menu_input.c b/menu/menu_input.c index 9726b5134b..cbe18a3152 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -202,13 +202,6 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data) case MENU_INPUT_CTL_BIND_SINGLE: case MENU_INPUT_CTL_BIND_ALL: return menu_input_key_bind_set_mode(state, data); - case MENU_INPUT_CTL_BIND_ITERATE: - { - menu_input_ctx_bind_t *bind = (menu_input_ctx_bind_t*)data; - if (!bind) - return false; - return menu_input_key_bind_iterate(bind->s, bind->len); - } default: case MENU_INPUT_CTL_NONE: break; diff --git a/menu/menu_input.h b/menu/menu_input.h index 5f04b382e9..1e900b8da9 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -79,8 +79,7 @@ enum menu_input_ctl_state MENU_INPUT_CTL_DEINIT, MENU_INPUT_CTL_BIND_NONE, MENU_INPUT_CTL_BIND_SINGLE, - MENU_INPUT_CTL_BIND_ALL, - MENU_INPUT_CTL_BIND_ITERATE + MENU_INPUT_CTL_BIND_ALL }; typedef struct menu_input_ctx_hitbox diff --git a/menu/widgets/menu_input_bind_dialog.c b/menu/widgets/menu_input_bind_dialog.c index 9630807bba..9fbaf14d03 100644 --- a/menu/widgets/menu_input_bind_dialog.c +++ b/menu/widgets/menu_input_bind_dialog.c @@ -383,7 +383,7 @@ bool menu_input_key_bind_set_min_max(menu_input_ctx_bind_limits_t *lim) return true; } -bool menu_input_key_bind_iterate(char *s, size_t len) +bool menu_input_key_bind_iterate(menu_input_ctx_bind_t *bind) { struct menu_bind_state binds; bool timed_out = false; @@ -392,6 +392,9 @@ bool menu_input_key_bind_iterate(char *s, size_t len) int timeout = (menu_input_binds.timeout_end - current) / 1000000; + if (!bind) + return false; + if (timeout <= 0) { input_driver_keyboard_mapping_set_block(false); @@ -403,10 +406,10 @@ bool menu_input_key_bind_iterate(char *s, size_t len) timed_out = true; } - snprintf(s, len, + snprintf(bind->s, bind->len, "[%s]\npress keyboard or joypad\n(timeout %d %s)", input_config_bind_map_get_desc( - menu_input_binds.begin - MENU_SETTINGS_BIND_BEGIN), + menu_input_binds.begin - MENU_SETTINGS_BIND_BEGIN), timeout, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SECONDS)); diff --git a/menu/widgets/menu_input_bind_dialog.h b/menu/widgets/menu_input_bind_dialog.h index 607ad29f65..30e10f2545 100644 --- a/menu/widgets/menu_input_bind_dialog.h +++ b/menu/widgets/menu_input_bind_dialog.h @@ -45,7 +45,7 @@ bool menu_input_key_bind_set_mode( bool menu_input_key_bind_set_min_max(menu_input_ctx_bind_limits_t *lim); -bool menu_input_key_bind_iterate(char *s, size_t len); +bool menu_input_key_bind_iterate(menu_input_ctx_bind_t *bind); RETRO_END_DECLS From e602f534c7e7ba1bbce500e4b30e129625f605bf Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 20:52:08 +0200 Subject: [PATCH 110/334] menu_input_bind_dialog.c - more refactors --- menu/menu_input.c | 4 ---- menu/menu_input.h | 5 +---- menu/menu_setting.c | 2 +- menu/widgets/menu_input_bind_dialog.c | 12 +++++------- menu/widgets/menu_input_bind_dialog.h | 9 ++++++++- setting_list.c | 3 ++- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/menu/menu_input.c b/menu/menu_input.c index cbe18a3152..799aa358ef 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -198,10 +198,6 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data) case MENU_INPUT_CTL_UNSET_POINTER_DRAGGED: pointer_dragging = false; break; - case MENU_INPUT_CTL_BIND_NONE: - case MENU_INPUT_CTL_BIND_SINGLE: - case MENU_INPUT_CTL_BIND_ALL: - return menu_input_key_bind_set_mode(state, data); default: case MENU_INPUT_CTL_NONE: break; diff --git a/menu/menu_input.h b/menu/menu_input.h index 1e900b8da9..e164be45da 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -76,10 +76,7 @@ enum menu_input_ctl_state MENU_INPUT_CTL_IS_POINTER_DRAGGED, MENU_INPUT_CTL_SET_POINTER_DRAGGED, MENU_INPUT_CTL_UNSET_POINTER_DRAGGED, - MENU_INPUT_CTL_DEINIT, - MENU_INPUT_CTL_BIND_NONE, - MENU_INPUT_CTL_BIND_SINGLE, - MENU_INPUT_CTL_BIND_ALL + MENU_INPUT_CTL_DEINIT }; typedef struct menu_input_ctx_hitbox diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 0dbe9b1a15..930e1ec756 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1242,7 +1242,7 @@ static int setting_action_right_bind_device(void *data, bool wraparound) static int setting_action_ok_bind_all(void *data, bool wraparound) { (void)wraparound; - if (!menu_input_ctl(MENU_INPUT_CTL_BIND_ALL, data)) + if (!menu_input_key_bind_set_mode(MENU_INPUT_BINDS_CTL_BIND_ALL, data)) return -1; return 0; } diff --git a/menu/widgets/menu_input_bind_dialog.c b/menu/widgets/menu_input_bind_dialog.c index 9fbaf14d03..d24bd9189f 100644 --- a/menu/widgets/menu_input_bind_dialog.c +++ b/menu/widgets/menu_input_bind_dialog.c @@ -78,7 +78,7 @@ static bool menu_input_key_bind_custom_bind_keyboard_cb( } static int menu_input_key_bind_set_mode_common( - enum menu_input_ctl_state state, + enum menu_input_binds_ctl_state state, rarch_setting_t *setting) { size_t selection; @@ -98,9 +98,7 @@ static int menu_input_key_bind_set_mode_common( switch (state) { - case MENU_INPUT_CTL_BIND_NONE: - return -1; - case MENU_INPUT_CTL_BIND_SINGLE: + case MENU_INPUT_BINDS_CTL_BIND_SINGLE: keybind = (struct retro_keybind*)setting_get_ptr(setting); if (!keybind) @@ -123,7 +121,7 @@ static int menu_input_key_bind_set_mode_common( if (menu_displaylist_ctl(DISPLAYLIST_INFO, &info)) menu_displaylist_ctl(DISPLAYLIST_PROCESS, &info); break; - case MENU_INPUT_CTL_BIND_ALL: + case MENU_INPUT_BINDS_CTL_BIND_ALL: menu_input_binds.target = &settings->input.binds [index_offset][0]; menu_input_binds.begin = MENU_SETTINGS_BIND_BEGIN; @@ -141,7 +139,7 @@ static int menu_input_key_bind_set_mode_common( menu_displaylist_ctl(DISPLAYLIST_PROCESS, &info); break; default: - case MENU_INPUT_CTL_NONE: + case MENU_INPUT_BINDS_CTL_BIND_NONE: break; } @@ -236,7 +234,7 @@ static void menu_input_key_bind_poll_bind_state( } bool menu_input_key_bind_set_mode( - enum menu_input_ctl_state state, void *data) + enum menu_input_binds_ctl_state state, void *data) { unsigned index_offset; input_keyboard_ctx_wait_t keys; diff --git a/menu/widgets/menu_input_bind_dialog.h b/menu/widgets/menu_input_bind_dialog.h index 30e10f2545..58c08fcb16 100644 --- a/menu/widgets/menu_input_bind_dialog.h +++ b/menu/widgets/menu_input_bind_dialog.h @@ -28,6 +28,13 @@ RETRO_BEGIN_DECLS +enum menu_input_binds_ctl_state +{ + MENU_INPUT_BINDS_CTL_BIND_NONE = 0, + MENU_INPUT_BINDS_CTL_BIND_SINGLE, + MENU_INPUT_BINDS_CTL_BIND_ALL +}; + typedef struct menu_input_ctx_bind { char *s; @@ -41,7 +48,7 @@ typedef struct menu_input_ctx_bind_limits } menu_input_ctx_bind_limits_t; bool menu_input_key_bind_set_mode( - enum menu_input_ctl_state state, void *data); + enum menu_input_binds_ctl_state state, void *data); bool menu_input_key_bind_set_min_max(menu_input_ctx_bind_limits_t *lim); diff --git a/setting_list.c b/setting_list.c index 68fb25d451..683a64c8c3 100644 --- a/setting_list.c +++ b/setting_list.c @@ -26,6 +26,7 @@ #ifdef HAVE_MENU #include "menu/menu_driver.h" #include "menu/widgets/menu_input_dialog.h" +#include "menu/widgets/menu_input_bind_dialog.h" #endif #include "configuration.h" @@ -141,7 +142,7 @@ static int setting_bind_action_ok(void *data, bool wraparound) #ifdef HAVE_MENU /* TODO - get rid of menu dependency */ - if (!menu_input_ctl(MENU_INPUT_CTL_BIND_SINGLE, data)) + if (!menu_input_key_bind_set_mode(MENU_INPUT_BINDS_CTL_BIND_SINGLE, data)) return -1; #endif return 0; From 1964491e5f476199327a3f81b01b285c291ed0ae Mon Sep 17 00:00:00 2001 From: Alcaro Date: Thu, 15 Sep 2016 20:54:05 +0200 Subject: [PATCH 111/334] Fix Linux-MinGW build --- gfx/common/win32_common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index 7559ff6532..8672b143c8 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -41,7 +41,7 @@ #include #include "../../retroarch.h" #include "../video_thread_wrapper.h" -#include +#include #ifndef _MSC_VER extern "C" { #endif From 3ed0aa5eb65087a811f472d2436271d9fad7ffa9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 20:55:06 +0200 Subject: [PATCH 112/334] Cleanups --- menu/widgets/menu_input_bind_dialog.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/menu/widgets/menu_input_bind_dialog.c b/menu/widgets/menu_input_bind_dialog.c index d24bd9189f..0dc12a65d0 100644 --- a/menu/widgets/menu_input_bind_dialog.c +++ b/menu/widgets/menu_input_bind_dialog.c @@ -186,7 +186,6 @@ static void menu_input_key_bind_poll_bind_state_internal( joypad->poll(); /* poll only the relevant port */ - /* for (i = 0; i < settings->input.max_users; i++) */ for (b = 0; b < MENU_MAX_BUTTONS; b++) state->state[port].buttons[b] = input_joypad_button_raw(joypad, port, b); @@ -360,13 +359,9 @@ static bool menu_input_key_bind_poll_find_trigger( state, new_state, i)) continue; - /* Update the joypad mapping automatically. - * More friendly that way. */ -#if 0 - settings->input.joypad_map[state->user] = i; -#endif return true; } + return false; } From 7bb5e46d2148ca57db928d2c0caa9597f5cd3d98 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 20:57:59 +0200 Subject: [PATCH 113/334] menu_cbs.h - Add retro_common_api.h --- menu/menu_cbs.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/menu/menu_cbs.h b/menu/menu_cbs.h index 16c9cfa33d..0b47eb74c1 100644 --- a/menu/menu_cbs.h +++ b/menu/menu_cbs.h @@ -19,6 +19,9 @@ #include #include +#include + +RETRO_BEGIN_DECLS enum { @@ -205,4 +208,6 @@ void menu_cbs_init(void *data, int menu_cbs_exit(void); +RETRO_END_DECLS + #endif From b14ffa45620cf34932deee28f1d03975f0409d4c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 20:58:36 +0200 Subject: [PATCH 114/334] menu_cbs.h - add HAVE_CONFIG_H ifdef --- menu/menu_cbs.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/menu/menu_cbs.h b/menu/menu_cbs.h index 0b47eb74c1..abd2423133 100644 --- a/menu/menu_cbs.h +++ b/menu/menu_cbs.h @@ -21,6 +21,10 @@ #include #include +#ifdef HAVE_CONFIG_H +#include "../config.h" +#endif + RETRO_BEGIN_DECLS enum From 06cc175311e7eb94663f58f4b1857ac562fc12e5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 21:01:11 +0200 Subject: [PATCH 115/334] Cleanups --- menu/widgets/menu_input_bind_dialog.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/menu/widgets/menu_input_bind_dialog.c b/menu/widgets/menu_input_bind_dialog.c index 0dc12a65d0..109c2cccb9 100644 --- a/menu/widgets/menu_input_bind_dialog.c +++ b/menu/widgets/menu_input_bind_dialog.c @@ -82,17 +82,12 @@ static int menu_input_key_bind_set_mode_common( rarch_setting_t *setting) { size_t selection; - unsigned index_offset, bind_type; + unsigned bind_type = 0; menu_displaylist_info_t info = {0}; struct retro_keybind *keybind = NULL; - file_list_t *menu_stack = NULL; settings_t *settings = config_get_ptr(); - - if (!setting) - return -1; - - index_offset = setting_get_index_offset(setting); - menu_stack = menu_entries_get_menu_stack_ptr(0); + unsigned index_offset = setting_get_index_offset(setting); + file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection); From 4cbc8e6f27888644120c4875f2a78f3779e3003f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 21:05:39 +0200 Subject: [PATCH 116/334] Cleanup --- menu/menu_input.c | 77 +++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/menu/menu_input.c b/menu/menu_input.c index 799aa358ef..42904c5bb3 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -309,9 +309,14 @@ static int menu_input_mouse_post_iterate(uint64_t *input_mouse, #endif ) { - /* HACK: Need to lie to avoid false hits if mouse is held when entering the RetroArch window */ - /* this happens if, for example, someone double clicks the window border to maximize it */ - /* the proper fix is, of course, triggering on WM_LBUTTONDOWN rather than this state change */ + /* HACK: Need to lie to avoid false hits if mouse is held + * when entering the RetroArch window. */ + + /* This happens if, for example, someone double clicks the + * window border to maximize it. + * + * The proper fix is, of course, triggering on WM_LBUTTONDOWN + * rather than this state change. */ mouse_oldleft = true; mouse_oldright = true; return 0; @@ -609,50 +614,17 @@ static unsigned menu_input_frame_pointer(unsigned *data) return ret; } -static unsigned menu_input_frame_build(retro_input_t trigger_input) -{ - settings_t *settings = config_get_ptr(); - unsigned ret = MENU_ACTION_NOOP; - - if (trigger_input.state & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP)) - ret = MENU_ACTION_UP; - else if (trigger_input.state & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN)) - ret = MENU_ACTION_DOWN; - else if (trigger_input.state & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT)) - ret = MENU_ACTION_LEFT; - else if (trigger_input.state & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT)) - ret = MENU_ACTION_RIGHT; - else if (trigger_input.state & (UINT64_C(1) << settings->menu_scroll_up_btn)) - ret = MENU_ACTION_SCROLL_UP; - else if (trigger_input.state & (UINT64_C(1) << settings->menu_scroll_down_btn)) - ret = MENU_ACTION_SCROLL_DOWN; - else if (trigger_input.state & (UINT64_C(1) << settings->menu_cancel_btn)) - ret = MENU_ACTION_CANCEL; - else if (trigger_input.state & (UINT64_C(1) << settings->menu_ok_btn)) - ret = MENU_ACTION_OK; - else if (trigger_input.state & (UINT64_C(1) << settings->menu_search_btn)) - ret = MENU_ACTION_SEARCH; - else if (trigger_input.state & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_Y)) - ret = MENU_ACTION_SCAN; - else if (trigger_input.state & (UINT64_C(1) << settings->menu_default_btn)) - ret = MENU_ACTION_START; - else if (trigger_input.state & (UINT64_C(1) << settings->menu_info_btn)) - ret = MENU_ACTION_INFO; - else if (trigger_input.state & (UINT64_C(1) << RARCH_MENU_TOGGLE)) - ret = MENU_ACTION_TOGGLE; - - return menu_input_frame_pointer(&ret); -} - unsigned menu_input_frame_retropad(retro_input_t input, retro_input_t trigger_input) { menu_animation_ctx_delta_t delta; float delta_time; + unsigned ret = MENU_ACTION_NOOP; static bool initial_held = true; static bool first_held = false; bool set_scroll = false; size_t new_scroll_accel = 0; + settings_t *settings = config_get_ptr(); menu_input_t *menu_input = menu_input_get_ptr(); if (!menu_input) @@ -759,5 +731,32 @@ unsigned menu_input_frame_retropad(retro_input_t input, trigger_input.state = 0; } - return menu_input_frame_build(trigger_input); + if (trigger_input.state & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP)) + ret = MENU_ACTION_UP; + else if (trigger_input.state & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN)) + ret = MENU_ACTION_DOWN; + else if (trigger_input.state & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT)) + ret = MENU_ACTION_LEFT; + else if (trigger_input.state & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT)) + ret = MENU_ACTION_RIGHT; + else if (trigger_input.state & (UINT64_C(1) << settings->menu_scroll_up_btn)) + ret = MENU_ACTION_SCROLL_UP; + else if (trigger_input.state & (UINT64_C(1) << settings->menu_scroll_down_btn)) + ret = MENU_ACTION_SCROLL_DOWN; + else if (trigger_input.state & (UINT64_C(1) << settings->menu_cancel_btn)) + ret = MENU_ACTION_CANCEL; + else if (trigger_input.state & (UINT64_C(1) << settings->menu_ok_btn)) + ret = MENU_ACTION_OK; + else if (trigger_input.state & (UINT64_C(1) << settings->menu_search_btn)) + ret = MENU_ACTION_SEARCH; + else if (trigger_input.state & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_Y)) + ret = MENU_ACTION_SCAN; + else if (trigger_input.state & (UINT64_C(1) << settings->menu_default_btn)) + ret = MENU_ACTION_START; + else if (trigger_input.state & (UINT64_C(1) << settings->menu_info_btn)) + ret = MENU_ACTION_INFO; + else if (trigger_input.state & (UINT64_C(1) << RARCH_MENU_TOGGLE)) + ret = MENU_ACTION_TOGGLE; + + return menu_input_frame_pointer(&ret); } From 121675c8e4cecf3c40f314e7608cc60eb5db3929 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 21:08:54 +0200 Subject: [PATCH 117/334] Cleanups --- menu/cbs/menu_cbs_ok.c | 14 +++++++++++++ menu/menu_input.c | 47 ------------------------------------------ menu/menu_input.h | 6 ------ setting_list.c | 33 +++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 53 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 49926c8776..cbc3e08d21 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1465,6 +1465,20 @@ static int action_ok_cheevos(const char *path, MENU_DIALOG_HELP_CHEEVOS_DESCRIPTION); } +static void menu_input_st_cheat_cb(void *userdata, const char *str) +{ + (void)userdata; + + if (str && *str) + { + unsigned cheat_index = menu_input_dialog_get_kb_type() + - MENU_SETTINGS_CHEAT_BEGIN; + cheat_manager_set_code(cheat_index, str); + } + + menu_input_dialog_end(); +} + static int action_ok_cheat(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { diff --git a/menu/menu_input.c b/menu/menu_input.c index 42904c5bb3..7a1fb9da7f 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -91,53 +91,6 @@ static menu_input_t *menu_input_get_ptr(void) return &menu_input_state; } -void menu_input_st_uint_cb(void *userdata, const char *str) -{ - if (str && *str) - { - const char *label = menu_input_dialog_get_label_buffer(); - rarch_setting_t *setting = menu_setting_find(label); - - setting_set_with_string_representation(setting, str); - } - - menu_input_dialog_end(); -} - -void menu_input_st_hex_cb(void *userdata, const char *str) -{ - if (str && *str) - { - const char *label = menu_input_dialog_get_label_buffer(); - rarch_setting_t *setting = menu_setting_find(label); - - if (setting) - { - unsigned *ptr = (unsigned*)setting_get_ptr(setting); - if (str[0] == '#') - str++; - if (ptr) - *ptr = strtoul(str, NULL, 16); - } - } - - menu_input_dialog_end(); -} - -void menu_input_st_cheat_cb(void *userdata, const char *str) -{ - (void)userdata; - - if (str && *str) - { - unsigned cheat_index = menu_input_dialog_get_kb_type() - - MENU_SETTINGS_CHEAT_BEGIN; - cheat_manager_set_code(cheat_index, str); - } - - menu_input_dialog_end(); -} - bool menu_input_mouse_check_vector_inside_hitbox(menu_input_ctx_hitbox_t *hitbox) { int16_t mouse_x = menu_input_mouse_state(MENU_MOUSE_X_AXIS); diff --git a/menu/menu_input.h b/menu/menu_input.h index e164be45da..1402e3d990 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -87,12 +87,6 @@ typedef struct menu_input_ctx_hitbox int32_t y2; } menu_input_ctx_hitbox_t; - -/* Keyboard input callbacks */ -void menu_input_st_uint_cb (void *userdata, const char *str); -void menu_input_st_hex_cb (void *userdata, const char *str); -void menu_input_st_cheat_cb (void *userdata, const char *str); - unsigned menu_input_frame_retropad(retro_input_t input, retro_input_t trigger_state); void menu_input_post_iterate(int *ret, unsigned action); diff --git a/setting_list.c b/setting_list.c index 683a64c8c3..a25e501f4c 100644 --- a/setting_list.c +++ b/setting_list.c @@ -1790,6 +1790,39 @@ static void menu_input_st_string_cb(void *userdata, const char *str) menu_input_dialog_end(); } +static void menu_input_st_uint_cb(void *userdata, const char *str) +{ + if (str && *str) + { + const char *label = menu_input_dialog_get_label_buffer(); + rarch_setting_t *setting = menu_setting_find(label); + + setting_set_with_string_representation(setting, str); + } + + menu_input_dialog_end(); +} + +static void menu_input_st_hex_cb(void *userdata, const char *str) +{ + if (str && *str) + { + const char *label = menu_input_dialog_get_label_buffer(); + rarch_setting_t *setting = menu_setting_find(label); + + if (setting) + { + unsigned *ptr = (unsigned*)setting_get_ptr(setting); + if (str[0] == '#') + str++; + if (ptr) + *ptr = strtoul(str, NULL, 16); + } + } + + menu_input_dialog_end(); +} + static int setting_generic_action_ok_linefeed(void *data, bool wraparound) { menu_input_ctx_line_t line; From 528d5edad037baabf659713b3aa0236b48c2a065 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 21:10:12 +0200 Subject: [PATCH 118/334] Cleanup --- menu/menu_input.c | 1 - 1 file changed, 1 deletion(-) diff --git a/menu/menu_input.c b/menu/menu_input.c index 7a1fb9da7f..d688d7c2ab 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -40,7 +40,6 @@ #include "menu_display.h" #include "menu_navigation.h" -#include "../managers/cheat_manager.h" #include "../configuration.h" #include "../core.h" From de1c5ec8bd9bdff0c346d5deb8f35f185274bc1b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 21:14:45 +0200 Subject: [PATCH 119/334] Rename menu_input_frame_retropad to menu_event --- menu/menu_input.c | 2 +- menu/menu_input.h | 9 ++++++++- runloop.c | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/menu/menu_input.c b/menu/menu_input.c index d688d7c2ab..96629546a5 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -566,7 +566,7 @@ static unsigned menu_input_frame_pointer(unsigned *data) return ret; } -unsigned menu_input_frame_retropad(retro_input_t input, +unsigned menu_event(retro_input_t input, retro_input_t trigger_input) { menu_animation_ctx_delta_t delta; diff --git a/menu/menu_input.h b/menu/menu_input.h index 1402e3d990..50d4527610 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -87,7 +87,14 @@ typedef struct menu_input_ctx_hitbox int32_t y2; } menu_input_ctx_hitbox_t; -unsigned menu_input_frame_retropad(retro_input_t input, retro_input_t trigger_state); +/* Send input code to menu for one frame. + * + * TODO/FIXME - needs to be overhauled so we can send multiple + * events per frame if we want to, and we shouldn't send the + * entire button state either but do a separate event per button + * state. + */ +unsigned menu_event(retro_input_t input, retro_input_t trigger_state); void menu_input_post_iterate(int *ret, unsigned action); diff --git a/runloop.c b/runloop.c index a6a019f508..9a39afad95 100644 --- a/runloop.c +++ b/runloop.c @@ -1553,7 +1553,7 @@ int runloop_iterate(unsigned *sleep_ms) if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)) { int ret = runloop_iterate_menu((enum menu_action) - menu_input_frame_retropad(cmd.state[0], cmd.state[2]), + menu_event(cmd.state[0], cmd.state[2]), sleep_ms); if (ret == -1) From 948526355524fb23df46ba48da64fd1bef21a700 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Thu, 15 Sep 2016 21:16:17 +0200 Subject: [PATCH 120/334] Fix implicit strstr --- gfx/drivers/vg.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index 614b938a5e..cb7ccdd56c 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -15,6 +15,7 @@ */ #include +#include #include #include From 8c5eb1b406ef130ac62c721697f62347848daf7b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 21:16:46 +0200 Subject: [PATCH 121/334] (iOS) BUildfix --- ui/drivers/cocoa/cocoatouch_menu.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/drivers/cocoa/cocoatouch_menu.m b/ui/drivers/cocoa/cocoatouch_menu.m index 587c97849f..9068ff9fd0 100644 --- a/ui/drivers/cocoa/cocoatouch_menu.m +++ b/ui/drivers/cocoa/cocoatouch_menu.m @@ -31,7 +31,7 @@ #include "../../../runloop.h" #ifdef HAVE_MENU -#include "../../../menu/menu_entry.h" +#include "../../../menu/widgets/menu_entry.h" #include "../../../menu/menu_navigation.h" #include "../../../menu/drivers/menu_generic.h" #endif From a71cd89379bfe507f346ae0f9cbcb38ee2cfbfbb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 21:26:10 +0200 Subject: [PATCH 122/334] Cleanup unused variable --- network/netplay/netplay.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index 6fc49d4c72..1d09b6b18d 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -764,10 +764,7 @@ netplay_t *netplay_new(const char *server, uint16_t port, bool spectate, const char *nick) { - uint32_t buffer_frames; - netplay_t *netplay = NULL; - - netplay = (netplay_t*)calloc(1, sizeof(*netplay)); + netplay_t *netplay = (netplay_t*)calloc(1, sizeof(*netplay)); if (!netplay) return NULL; From 4a30bfd1567fabdb1eb85e8e55ad5763955e3f01 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 22:05:40 +0200 Subject: [PATCH 123/334] Make these two the default --- config.def.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/config.def.h b/config.def.h index 3ff28986a5..67de519f58 100644 --- a/config.def.h +++ b/config.def.h @@ -650,10 +650,8 @@ static const bool font_enable = true; * disable VSync, and leave this at its default. */ #ifdef _3DS static const float refresh_rate = (32730.0 * 8192.0) / 4481134.0 ; -#elif defined(RARCH_CONSOLE) -static const float refresh_rate = 60/1.001; #else -static const float refresh_rate = 59.94; +static const float refresh_rate = 60/1.001; #endif /* Allow games to set rotation. If false, rotation requests are From f4d7e36ed07b25fefe1b45c3d7ded98a372fc7c4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 23:47:08 +0200 Subject: [PATCH 124/334] (menu_input.c) Cleanups --- menu/menu_input.c | 44 +++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/menu/menu_input.c b/menu/menu_input.c index 96629546a5..7735804c5f 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -23,9 +23,6 @@ #include #include -#include -#include - #ifdef HAVE_CONFIG_H #include "../config.h" #endif @@ -543,29 +540,6 @@ void menu_input_post_iterate(int *ret, unsigned action) *ret |= menu_input_pointer_post_iterate(cbs, &entry, action); } -static unsigned menu_input_frame_pointer(unsigned *data) -{ - unsigned ret = *data; - settings_t *settings = config_get_ptr(); - menu_input_t *menu_input = menu_input_get_ptr(); - bool mouse_enabled = settings->menu.mouse.enable; -#ifdef HAVE_OVERLAY - if (!mouse_enabled) - mouse_enabled = !(settings->input.overlay_enable - && input_overlay_is_alive(NULL)); -#endif - - if (!mouse_enabled) - menu_input->mouse.ptr = 0; - - if (settings->menu.pointer.enable) - menu_input_pointer(&ret); - else - memset(&menu_input->pointer, 0, sizeof(menu_input->pointer)); - - return ret; -} - unsigned menu_event(retro_input_t input, retro_input_t trigger_input) { @@ -575,6 +549,7 @@ unsigned menu_event(retro_input_t input, static bool initial_held = true; static bool first_held = false; bool set_scroll = false; + bool mouse_enabled = false; size_t new_scroll_accel = 0; settings_t *settings = config_get_ptr(); menu_input_t *menu_input = menu_input_get_ptr(); @@ -710,5 +685,20 @@ unsigned menu_event(retro_input_t input, else if (trigger_input.state & (UINT64_C(1) << RARCH_MENU_TOGGLE)) ret = MENU_ACTION_TOGGLE; - return menu_input_frame_pointer(&ret); + mouse_enabled = settings->menu.mouse.enable; +#ifdef HAVE_OVERLAY + if (!mouse_enabled) + mouse_enabled = !(settings->input.overlay_enable + && input_overlay_is_alive(NULL)); +#endif + + if (!mouse_enabled) + menu_input->mouse.ptr = 0; + + if (settings->menu.pointer.enable) + menu_input_pointer(&ret); + else + memset(&menu_input->pointer, 0, sizeof(menu_input->pointer)); + + return ret; } From 8e758bf155be52a0278f17c2b77c3ac0dae39fb6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Sep 2016 23:49:24 +0200 Subject: [PATCH 125/334] Rename menu_input_pointer to menu_event_pointer --- menu/menu_input.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/menu/menu_input.c b/menu/menu_input.c index 7735804c5f..9ec642003d 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -155,7 +155,7 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data) return true; } -static int menu_input_pointer(unsigned *action) +static int menu_event_pointer(unsigned *action) { const struct retro_keybind *binds[MAX_USERS] = {NULL}; menu_input_t *menu_input = menu_input_get_ptr(); @@ -696,7 +696,7 @@ unsigned menu_event(retro_input_t input, menu_input->mouse.ptr = 0; if (settings->menu.pointer.enable) - menu_input_pointer(&ret); + menu_event_pointer(&ret); else memset(&menu_input->pointer, 0, sizeof(menu_input->pointer)); From f6b7fc17f65c4b272e880f4bdfe544775a8c2d5d Mon Sep 17 00:00:00 2001 From: Alcaro Date: Fri, 16 Sep 2016 00:44:52 +0200 Subject: [PATCH 126/334] Those checks aren't needed. --- gfx/common/x11_common.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index da37cbb681..c4fb80d3ea 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -150,14 +150,14 @@ static void dbus_screensaver_uninhibit(void) if (!dbus_connection) return; - if (dbus_screensaver_cookie <= 0) + if (!dbus_screensaver_cookie) return; msg = dbus_message_new_method_call("org.freedesktop.ScreenSaver", "/org/freedesktop/ScreenSaver", "org.freedesktop.ScreenSaver", "UnInhibit"); - dbus_message_append_args (msg, + dbus_message_append_args(msg, DBUS_TYPE_UINT32, &dbus_screensaver_cookie, DBUS_TYPE_INVALID); @@ -173,16 +173,8 @@ static void dbus_screensaver_uninhibit(void) void x11_suspend_screensaver_dbus(bool enable) { - /* Disable requested and was not already suspended */ - if (!enable && !dbus_screensaver_cookie == 0) - return; - - /* Disable requesed and was suspended -> unsuspend */ - if (!enable && dbus_screensaver_cookie > 0) - dbus_screensaver_uninhibit(); - - if (enable) - dbus_screensaver_inhibit(); + if (enable) dbus_screensaver_inhibit(); + if (!enable) dbus_screensaver_uninhibit(); } #endif From fb133a74874df9c0fdb06ad836172b9f9e6a9869 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Sep 2016 01:14:25 +0200 Subject: [PATCH 127/334] Update GLSM --- libretro-common/glsm/glsm.c | 51 ++++++++++++++++++++++++++ libretro-common/include/glsm/glsmsym.h | 9 +++++ 2 files changed, 60 insertions(+) diff --git a/libretro-common/glsm/glsm.c b/libretro-common/glsm/glsm.c index e60ad6a56b..3e63aa26c8 100644 --- a/libretro-common/glsm/glsm.c +++ b/libretro-common/glsm/glsm.c @@ -1848,6 +1848,55 @@ void rglWaitSync(void *sync, GLbitfield flags, uint64_t timeout) #endif } +/* + * + * Core in: + * OpenGL : 4.4 + * OpenGLES : Not available + */ +void rglBufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data, GLbitfield flags) { +#if defined(HAVE_OPENGL) + glBufferStorage(target, size, data, flags); +#endif +} + +/* + * + * Core in: + * OpenGL : 3.0 + * OpenGLES : 3.0 + */ +void rglFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) { +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) + glFlushMappedBufferRange(target, offset, length); +#endif +} + +/* + * + * Core in: + * OpenGL : 3.2 + * OpenGLES : 3.0 + */ +GLenum rglClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) { +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) + return glClientWaitSync(sync, flags, timeout); +#endif +} + +/* + * + * Core in: + * OpenGL : 3.2 + * OpenGLES : Not available + */ +void rglDrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, + GLvoid *indices, GLint basevertex) { +#if defined(HAVE_OPENGL) + glDrawElementsBaseVertex(mode, count, type, indices, basevertex); +#endif +} + /* GLSM-side */ static void glsm_state_setup(void) @@ -2076,6 +2125,8 @@ static bool glsm_state_ctx_destroy(void *data) if (gl_state.bind_textures.ids) free(gl_state.bind_textures.ids); gl_state.bind_textures.ids = NULL; + + return true; } static bool glsm_state_ctx_init(void *data) diff --git a/libretro-common/include/glsm/glsmsym.h b/libretro-common/include/glsm/glsmsym.h index 5596117434..9a1f16810a 100644 --- a/libretro-common/include/glsm/glsmsym.h +++ b/libretro-common/include/glsm/glsmsym.h @@ -161,6 +161,10 @@ RETRO_BEGIN_DECLS #define glClearBufferfi rglClearBufferfi #define glWaitSync rglWaitSync #define glFenceSync rglFenceSync +#define glBufferStorage rglBufferStorage +#define glFlushMappedBufferRange rglFlushMappedBufferRange +#define glClientWaitSync rglClientWaitSync +#define glDrawElementsBaseVertex rglDrawElementsBaseVertex const GLubyte* rglGetStringi(GLenum name, GLuint index); void rglTexBuffer(GLenum target, GLenum internalFormat, GLuint buffer); @@ -397,6 +401,11 @@ void rglTexSubImage2D( GLenum target, void rglDeleteVertexArrays(GLsizei n, const GLuint *arrays); void *rglFenceSync(GLenum condition, GLbitfield flags); void rglWaitSync(void *sync, GLbitfield flags, uint64_t timeout); +void rglBufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data, GLbitfield flags); +void rglFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length); +GLenum rglClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout); +void rglDrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, + GLvoid *indices, GLint basevertex); RETRO_END_DECLS From 29529521698d72588d75db58a48e67d301b02468 Mon Sep 17 00:00:00 2001 From: fr500 Date: Thu, 15 Sep 2016 18:12:00 -0500 Subject: [PATCH 128/334] (ems) add itch.io template --- pkg/emscripten/itch/index.html | 148 ++++++++++++ pkg/emscripten/itch/itch.css | 99 ++++++++ pkg/emscripten/itch/itch.js | 401 +++++++++++++++++++++++++++++++++ 3 files changed, 648 insertions(+) create mode 100644 pkg/emscripten/itch/index.html create mode 100644 pkg/emscripten/itch/itch.css create mode 100644 pkg/emscripten/itch/itch.js diff --git a/pkg/emscripten/itch/index.html b/pkg/emscripten/itch/index.html new file mode 100644 index 0000000000..565eca97b2 --- /dev/null +++ b/pkg/emscripten/itch/index.html @@ -0,0 +1,148 @@ + + + + + RetroArch Web Player + + + + + + + + + + + + + + + +
+
+
+ + RetroArch Logo +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+

For now, we recommend you use Google Chrome for the best possible performance.

+ +
+ + + + + + + + + + diff --git a/pkg/emscripten/itch/itch.css b/pkg/emscripten/itch/itch.css new file mode 100644 index 0000000000..d5e6b52d89 --- /dev/null +++ b/pkg/emscripten/itch/itch.css @@ -0,0 +1,99 @@ +/** + * RetroArch Web Player + * + * This provides the basic styling for the RetroArch web player. + */ + +/** + * Make sure the background of the player is black. + */ +.webplayer-container { + background-color: black; +} + +/** + * Webplayer Preview when not loaded. + */ +.webplayer-preview { + margin: 0 auto; + cursor: wait; + opacity: 0.2; + transition: all 0.8s; + -webkit-animation: loading 0.8s ease-in-out infinite alternate; + -moz-animation: loading 0.8s ease-in-out infinite alternate; + animation: loading 0.8s ease-in-out infinite alternate; +} +.webplayer-preview.loaded { + cursor: pointer; + opacity: 1; + -webkit-animation: loaded 0.8s ease-in-out; + -moz-animation: loaded 0.8s ease-in-out; + animation: loaded 0.8s ease-in-out; +} +@keyframes loaded { + from { + opacity: 0.2; + } + to { + opacity: 1; + } +} +@-moz-keyframes loaded { + from { + opacity: 0.2; + } + to { + opacity: 1; + } +} +@-webkit-keyframes loaded { + from { + opacity: 0.2; + } + to { + opacity: 1; + } +} +@keyframes loading{ + from { + opacity: 0.2; + } + to { + opacity: 0.35; + } +} +@-moz-keyframes loading{ + from { + opacity: 0.2; + } + to { + opacity: 0.35; + } +} +@-webkit-keyframes loading { + from { + opacity: 0.2; + } + to { + opacity: 0.35; + } +} + +/** + * Disable the border around the player. + */ +canvas.webplayer { + border: none; + outline: none; +} + +textarea { + font-family: monospace; + font-size: 0.7em; + height: 95%; + width: 95%; + border-style: none; + border-color: transparent; + overflow: auto; + resize: none; +} diff --git a/pkg/emscripten/itch/itch.js b/pkg/emscripten/itch/itch.js new file mode 100644 index 0000000000..ba42e4274b --- /dev/null +++ b/pkg/emscripten/itch/itch.js @@ -0,0 +1,401 @@ +/** + * RetroArch Web Player + * + * This provides the basic JavaScript for the RetroArch web player. + */ +var dropbox = false; +var client = new Dropbox.Client({ key: "il6e10mfd7pgf8r" }); +var XFS; +var BrowserFS = browserfs; + +var showError = function(error) { + switch (error.status) { + case Dropbox.ApiError.INVALID_TOKEN: + // If you're using dropbox.js, the only cause behind this error is that + // the user token expired. + // Get the user through the authentication flow again. + break; + + case Dropbox.ApiError.NOT_FOUND: + // The file or folder you tried to access is not in the user's Dropbox. + // Handling this error is specific to your application. + break; + + case Dropbox.ApiError.OVER_QUOTA: + // The user is over their Dropbox quota. + // Tell them their Dropbox is full. Refreshing the page won't help. + break; + + case Dropbox.ApiError.RATE_LIMITED: + // Too many API requests. Tell the user to try again later. + // Long-term, optimize your code to use fewer API calls. + break; + + case Dropbox.ApiError.NETWORK_ERROR: + // An error occurred at the XMLHttpRequest layer. + // Most likely, the user's network connection is down. + // API calls will not succeed until the user gets back online. + break; + + case Dropbox.ApiError.INVALID_PARAM: + case Dropbox.ApiError.OAUTH_ERROR: + case Dropbox.ApiError.INVALID_METHOD: + default: + // Caused by a bug in dropbox.js, in your application, or in Dropbox. + // Tell the user an error occurred, ask them to refresh the page. + } +}; + +function dropboxInit() +{ + document.getElementById('btnRun').disabled = true; + document.getElementById('btnDrop').disabled = true; + $('#icnDrop').removeClass('fa-dropbox'); + $('#icnDrop').addClass('fa-spinner fa-spin'); + + + client.authDriver(new Dropbox.AuthDriver.Redirect()); + client.authenticate({ rememberUser: true }, function(error, client) + { + if (error) + { + return showError(error); + } + dropboxSync(client, dropboxSyncComplete); + }); +} + +function dropboxSyncComplete() +{ + document.getElementById('btnRun').disabled = false; + $('#icnDrop').removeClass('fa-spinner').removeClass('fa-spin'); + $('#icnDrop').addClass('fa-dropbox'); + console.log("WEBPLAYER: Sync successful"); + + setupFileSystem("dropbox"); + setupFolderStructure(); + preLoadingComplete(); +} + +var afs; + +function dropboxSync(dropboxClient, cb) +{ + var dbfs = new BrowserFS.FileSystem.Dropbox(dropboxClient); + // Wrap in afsFS. + afs = new BrowserFS.FileSystem.AsyncMirror( + new BrowserFS.FileSystem.InMemory(), dbfs); + + afs.initialize(function(err) + { + // Initialize it as the root file system. + //BrowserFS.initialize(afs); + cb(); + }); +} + +function preLoadingComplete() +{ + /* Make the Preview image clickable to start RetroArch. */ + $('.webplayer-preview').addClass('loaded').click(function () { + startRetroArch(); + return false; + }); +} + + +function setupFileSystem(backend) +{ + /* create a mountable filesystem that will server as a root + mountpoint for browserfs */ + var mfs = new BrowserFS.FileSystem.MountableFileSystem(); + + /* create an XmlHttpRequest filesystem for the bundled data */ + var xfs1 = new BrowserFS.FileSystem.XmlHttpRequest + (".index-xhr", "https://bot.libretro.com/assets/frontend/bundle/"); + /* create an XmlHttpRequest filesystem for core assets */ + var xfs2 = new BrowserFS.FileSystem.XmlHttpRequest + (".index-xhr", "https://bot.libretro.com/assets/cores/"); + + console.log("WEBPLAYER: Initializing Filesystem"); + if(backend == "browser") + { + console.log("WEBPLAYER: Initializing LocalStorage"); + + /* create a local filesystem */ + var lsfs = new BrowserFS.FileSystem.LocalStorage(); + + /* mount the filesystems onto mfs */ + mfs.mount('/home/web_user/retroarch/userdata', lsfs); + + /* create a memory filesystem for content only + var imfs = new BrowserFS.FileSystem.InMemory();*/ + + /* mount the filesystems onto mfs + mfs.mount('/home/web_user/retroarch/userdata/content/', imfs);*/ + } + else + { + /* mount the filesystems onto mfs */ + mfs.mount('/home/web_user/retroarch/userdata', afs); + } + + mfs.mount('/home/web_user/retroarch/bundle', xfs1); + mfs.mount('/home/web_user/retroarch/userdata/content/downloads', xfs2); + BrowserFS.initialize(mfs); + var BFS = new BrowserFS.EmscriptenFS(); + FS.mount(BFS, {root: '/home'}, '/home'); + console.log("WEBPLAYER: " + backend + " filesystem initialized"); +} + +/** + * Retrieve the value of the given GET parameter. + */ +function getParam(name) { + var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); + if (results) { + return results[1] || null; + } +} + +function setupFolderStructure() +{ + FS.createPath('/', '/home/web_user', true, true); +} + +function stat(path) +{ + try{ + FS.stat(path); + } + catch(err) + { + console.log("WEBPLAYER: file " + path + " doesn't exist"); + return false; + } + return true; +} + +function startRetroArch() +{ + $('.webplayer').show(); + $('.webplayer-preview').hide(); + document.getElementById('btnDrop').disabled = true; + document.getElementById('btnRun').disabled = true; + + $('#btnFullscreen').removeClass('disabled'); + $('#btnMenu').removeClass('disabled'); + $('#btnAdd').removeClass('disabled'); + $('#btnRom').removeClass('disabled'); + + document.getElementById("btnAdd").disabled = false; + document.getElementById("btnRom").disabled = false; + document.getElementById("btnMenu").disabled = false; + document.getElementById("btnFullscreen").disabled = false; + + Module['callMain'](Module['arguments']); + document.getElementById('canvas').focus(); +} + +function selectFiles(files) +{ + $('#btnAdd').addClass('disabled'); + $('#icnAdd').removeClass('fa-plus'); + $('#icnAdd').addClass('fa-spinner spinning'); + var count = files.length; + + for (var i = 0; i < files.length; i++) + { + filereader = new FileReader(); + filereader.file_name = files[i].name; + filereader.readAsArrayBuffer(files[i]); + filereader.onload = function(){uploadData(this.result, this.file_name)}; + filereader.onloadend = function(evt) + { + console.log("WEBPLAYER: File: " + this.file_name + " Upload Complete"); + if (evt.target.readyState == FileReader.DONE) + { + $('#btnAdd').removeClass('disabled'); + $('#icnAdd').removeClass('fa-spinner spinning'); + $('#icnAdd').addClass('fa-plus'); + } + } + } +} + +function uploadData(data,name) +{ + var dataView = new Uint8Array(data); + FS.createDataFile('/', name, dataView, true, false); + + var data = FS.readFile(name,{ encoding: 'binary' }); + FS.writeFile('/home/web_user/retroarch/userdata/content/' + name, data ,{ encoding: 'binary' }); + FS.unlink(name); +} + +var Module = +{ + noInitialRun: true, + arguments: ["-v", "--menu"], + preRun: [], + postRun: [], + print: (function() + { + var element = document.getElementById('output'); + element.value = ''; // clear browser cache + return function(text) + { + text = Array.prototype.slice.call(arguments).join(' '); + element.value += text + "\n"; + element.scrollTop = 99999; // focus on bottom + }; + })(), + + printErr: function(text) + { + var text = Array.prototype.slice.call(arguments).join(' '); + var element = document.getElementById('output'); + element.value += text + "\n"; + element.scrollTop = 99999; // focus on bottom + }, + canvas: document.getElementById('canvas'), + totalDependencies: 0, + monitorRunDependencies: function(left) + { + this.totalDependencies = Math.max(this.totalDependencies, left); + } +}; + +function switchCore(corename) { + localStorage.setItem("core", corename); +} + +function switchStorage() { + if (localStorage.getItem("backend") == "dropbox") + { + localStorage.setItem("backend", "browser"); + location.reload(); + } + else + { + localStorage.setItem("backend", "dropbox"); + location.reload(); + } +} + +// When the browser has loaded everything. +$(function() { + /** + * Attempt to disable some default browser keys. + */ + var keys = { + 9: "tab", + 13: "enter", + 16: "shift", + 18: "alt", + 27: "esc", + 33: "rePag", + 34: "avPag", + 35: "end", + 36: "home", + 37: "left", + 38: "up", + 39: "right", + 40: "down", + 112: "F1", + 113: "F2", + 114: "F3", + 115: "F4", + 116: "F5", + 117: "F6", + 118: "F7", + 119: "F8", + 120: "F9", + 121: "F10", + 122: "F11", + 123: "F12" + }; + window.addEventListener('keydown', function (e) { + if (keys[e.which]) { + e.preventDefault(); + } + }); + + // Switch the core when selecting one. + $('#core-selector a').click(function () { + var coreChoice = $(this).data('core'); + switchCore(coreChoice); + }); + + // Find which core to load. + var core = localStorage.getItem("core", core); + if (!core) { + core = 'gambatte'; + } + // Make the core the selected core in the UI. + var coreTitle = $('#core-selector a[data-core="' + core + '"]').addClass('active').text(); + $('#dropdownMenu1').text(coreTitle); + + // Load the Core's related JavaScript. + $.getScript(core + '_libretro.js', function () + { + // Activate the Start RetroArch button. + $('#btnRun').removeClass('disabled'); + $('#icnRun').removeClass('fa-spinner').removeClass('fa-spin'); + $('#icnRun').addClass('fa-play'); + + document.getElementById("btnRun").disabled = false; + + if (localStorage.getItem("backend") == "dropbox") + { + $('#icnDrop').removeClass('fa-globe'); + $('#icnDrop').addClass('fa-dropbox'); + dropboxInit(); + } + else + { + $('#icnDrop').addClass('fa-globe'); + $('#icnDrop').removeClass('fa-dropbox'); + preLoadingComplete(); + setupFileSystem("browser"); + setupFolderStructure(); + } + }); + }); + +function keyPress(k) +{ + kp(k, "keydown"); + setInterval(function(){kp(k, "keyup")}, 1000); +} + +kp = function(k, event) { + var oEvent = document.createEvent('KeyboardEvent'); + + // Chromium Hack + Object.defineProperty(oEvent, 'keyCode', { + get : function() { + return this.keyCodeVal; + } + }); + Object.defineProperty(oEvent, 'which', { + get : function() { + return this.keyCodeVal; + } + }); + + if (oEvent.initKeyboardEvent) { + oEvent.initKeyboardEvent(event, true, true, document.defaultView, false, false, false, false, k, k); + } else { + oEvent.initKeyEvent(event, true, true, document.defaultView, false, false, false, false, k, 0); + } + + oEvent.keyCodeVal = k; + + if (oEvent.keyCode !== k) { + alert("keyCode mismatch " + oEvent.keyCode + "(" + oEvent.which + ")"); + } + + document.dispatchEvent(oEvent); + document.getElementById('canvas').focus(); +} From 20999f99524eb3bc7c7265288bdf26effb954852 Mon Sep 17 00:00:00 2001 From: fr500 Date: Thu, 15 Sep 2016 18:12:31 -0500 Subject: [PATCH 129/334] (ems) remove deprecated template --- pkg/emscripten/webplayer.css | 28 ---- pkg/emscripten/webplayer.html | 138 ------------------- pkg/emscripten/webplayer.js | 249 ---------------------------------- 3 files changed, 415 deletions(-) delete mode 100644 pkg/emscripten/webplayer.css delete mode 100644 pkg/emscripten/webplayer.html delete mode 100644 pkg/emscripten/webplayer.js diff --git a/pkg/emscripten/webplayer.css b/pkg/emscripten/webplayer.css deleted file mode 100644 index 5e842aa825..0000000000 --- a/pkg/emscripten/webplayer.css +++ /dev/null @@ -1,28 +0,0 @@ -/** - * RetroArch Web Player - * - * This provides the basic styling for the RetroArch web player. - */ - -/** - * The logging textarea. - */ -textarea.webplayer { - font-family: monospace; - font-size: 0.8em; -} - -/** - * Make sure the background of the player is black. - */ -.webplayer-container { - background-color: black; -} - -/** - * Disable the border around the player. - */ -canvas.webplayer { - border: none; - outline: none; -} diff --git a/pkg/emscripten/webplayer.html b/pkg/emscripten/webplayer.html deleted file mode 100644 index 56aaad1bea..0000000000 --- a/pkg/emscripten/webplayer.html +++ /dev/null @@ -1,138 +0,0 @@ - - - - - RetroArch Web Player - - - - - - -
-
- -
-
-
-
-
- - - - - -
-
-
-
-
- -
-
-
-
- - - - - - - - - diff --git a/pkg/emscripten/webplayer.js b/pkg/emscripten/webplayer.js deleted file mode 100644 index 8a40352458..0000000000 --- a/pkg/emscripten/webplayer.js +++ /dev/null @@ -1,249 +0,0 @@ -/** - * RetroArch Web Player - * - * This provides the basic JavaScript for the RetroArch web player. - */ -var dropbox = false; -var client = new Dropbox.Client({ key: "il6e10mfd7pgf8r" }); -var BrowserFS = browserfs; - -var showError = function(error) { - switch (error.status) { - case Dropbox.ApiError.INVALID_TOKEN: - // If you're using dropbox.js, the only cause behind this error is that - // the user token expired. - // Get the user through the authentication flow again. - break; - - case Dropbox.ApiError.NOT_FOUND: - // The file or folder you tried to access is not in the user's Dropbox. - // Handling this error is specific to your application. - break; - - case Dropbox.ApiError.OVER_QUOTA: - // The user is over their Dropbox quota. - // Tell them their Dropbox is full. Refreshing the page won't help. - break; - - case Dropbox.ApiError.RATE_LIMITED: - // Too many API requests. Tell the user to try again later. - // Long-term, optimize your code to use fewer API calls. - break; - - case Dropbox.ApiError.NETWORK_ERROR: - // An error occurred at the XMLHttpRequest layer. - // Most likely, the user's network connection is down. - // API calls will not succeed until the user gets back online. - break; - - case Dropbox.ApiError.INVALID_PARAM: - case Dropbox.ApiError.OAUTH_ERROR: - case Dropbox.ApiError.INVALID_METHOD: - default: - // Caused by a bug in dropbox.js, in your application, or in Dropbox. - // Tell the user an error occurred, ask them to refresh the page. - } -}; - -function dropboxInit() -{ - document.getElementById('btnStart').disabled = true; - document.getElementById('btnAuth').disabled = true; - client.authDriver(new Dropbox.AuthDriver.Redirect()); - client.authenticate({ rememberUser: true }, function(error, client) - { - if (error) - { - return showError(error); - } - dropboxSync(client, success); - }); -} -function success() -{ - document.getElementById('btnStart').disabled = false; - console.log("WEBPLAYER: Sync successful"); -} -function dropboxSync(dropboxClient, cb) -{ - var dbfs = new BrowserFS.FileSystem.Dropbox(dropboxClient); - // Wrap in AsyncMirrorFS. - var asyncMirror = new BrowserFS.FileSystem.AsyncMirror( - new BrowserFS.FileSystem.InMemory(), dbfs); - - asyncMirror.initialize(function(err) - { - // Initialize it as the root file system. - BrowserFS.initialize(asyncMirror); - - cb(); - }); -} - -var count = 0; -function setupFileSystem() -{ - console.log("WEBPLAYER: Initializing Filesystem"); - if(!client.isAuthenticated()) - { - console.log("WEBPLAYER: Initializing LocalStorage"); - if(localStorage.getItem("fs_inited")!="true") - { - var lsfs = new BrowserFS.FileSystem.LocalStorage(); - - BrowserFS.initialize(lsfs); - var BFS = new BrowserFS.EmscriptenFS(); - FS.mount(BFS, {root: '/'}, '/home'); - console.log('WEBPLAYER: Filesystem initialized'); - } - else - { - console.log('WEBPLAYER: Filesystem already initialized'); - } - } - else - { - console.log("WEBPLAYER: Initializing DropBoxFS"); - // Grab the BrowserFS Emscripten FS plugin. - var BFS = new BrowserFS.EmscriptenFS(); - // Create the folder that we'll turn into a mount point. - FS.createPath(FS.root, 'home', true, true); - // Mount BFS's root folder into the '/data' folder. - console.log('WEBPLAYER: Mounting'); - FS.mount(BFS, {root: '/'}, '/home'); - console.log('WEBPLAYER: DropBox initialized'); - } -} - -/** - * Retrieve the value of the given GET parameter. - */ -function getParam(name) { - var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); - if (results) { - return results[1] || null; - } -} - -function setupFolderStructure() -{ - FS.createPath('/', '/home/web_user', true, true); - FS.createPath('/', '/home/web_user/.config', true, true); - FS.createPath('/', '/home/web_user/.config/retroarch', true, true); - FS.createPath('/', '/assets', true, true); - FS.createPath('/', '/content', true, true); -} - -function stat(path) -{ - try{ - FS.stat(path); - } - catch(err) - { - console.log("WEBPLAYER: file " + path + " doesn't exist"); - return false; - } - return true; -} - -function startRetroArch() -{ - document.getElementById('canvas_div').style.display = 'block'; - document.getElementById('btnLoad').disabled = false; - - setupFileSystem(); - setupFolderStructure(); - - Module['callMain'](Module['arguments']); -} - -function selectFiles(files) -{ - count = files.length; - - for (var i = 0; i < files.length; i++) - { - filereader = new FileReader(); - filereader.file_name = files[i].name; - filereader.readAsArrayBuffer(files[i]); - filereader.onload = function(){uploadData(this.result, this.file_name)}; - } -} - -function uploadData(data,name) -{ - var dataView = new Uint8Array(data); - FS.createDataFile('/', name, dataView, true, false); - - var data = FS.readFile(name,{ encoding: 'binary' }); - FS.writeFile('/content/' + name, data ,{ encoding: 'binary' }); - FS.unlink(name); - -} - -var Module = -{ - noInitialRun: true, - arguments: ["-v", "--menu"], - preRun: [], - postRun: [], - print: (function() - { - var element = document.getElementById('output'); - element.value = ''; // clear browser cache - return function(text) - { - text = Array.prototype.slice.call(arguments).join(' '); - element.value += text + "\n"; - element.scrollTop = 99999; // focus on bottom - }; - })(), - - printErr: function(text) - { - var text = Array.prototype.slice.call(arguments).join(' '); - var element = document.getElementById('output'); - element.value += text + "\n"; - element.scrollTop = 99999; // focus on bottom - }, - canvas: document.getElementById('canvas'), - - totalDependencies: 0, - monitorRunDependencies: function(left) - { - this.totalDependencies = Math.max(this.totalDependencies, left); - } -}; - -function switchCore(corename) { - localStorage.setItem("core", corename); -} - -// When the browser has loaded everything. -$(function() { - // Find which core to load. - var core = localStorage.getItem("core", core); - if (!core) { - core = 'gambatte'; - } - // Show the current core as the active core. - $('.nav-item.' + core).addClass('active'); - - // Load the Core's related JavaScript. - $.getScript(core + '_libretro.js', function () { - // Activate the Start RetroArch button. - $('#btnStart').removeClass('disabled'); - - /** - * Attempt to disable some default browser keys. - */ - - window.addEventListener('keydown', function(e) { - // Space key, arrows, and F1. - if([32, 37, 38, 39, 40, 112].indexOf(e.keyCode) > -1) { - e.preventDefault(); - } - }, false); - }); -}); From f4e35e3cdf9dc07e339de1ee49a3a57dfd12cb9a Mon Sep 17 00:00:00 2001 From: fr500 Date: Thu, 15 Sep 2016 18:18:06 -0500 Subject: [PATCH 130/334] (ems) reorganize templates --- pkg/emscripten/itch/index.html | 2 +- pkg/emscripten/{proto.html => libretro/index.html} | 4 ++-- pkg/emscripten/{proto.css => libretro/libretro.css} | 0 pkg/emscripten/{proto.js => libretro/libretro.js} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename pkg/emscripten/{proto.html => libretro/index.html} (99%) rename pkg/emscripten/{proto.css => libretro/libretro.css} (100%) rename pkg/emscripten/{proto.js => libretro/libretro.js} (100%) diff --git a/pkg/emscripten/itch/index.html b/pkg/emscripten/itch/index.html index 565eca97b2..0efde37c3c 100644 --- a/pkg/emscripten/itch/index.html +++ b/pkg/emscripten/itch/index.html @@ -95,7 +95,7 @@ - diff --git a/pkg/emscripten/proto.html b/pkg/emscripten/libretro/index.html similarity index 99% rename from pkg/emscripten/proto.html rename to pkg/emscripten/libretro/index.html index 6d6b683932..cf84c55ab3 100644 --- a/pkg/emscripten/proto.html +++ b/pkg/emscripten/libretro/index.html @@ -11,7 +11,7 @@ - + @@ -152,6 +152,6 @@ - + diff --git a/pkg/emscripten/proto.css b/pkg/emscripten/libretro/libretro.css similarity index 100% rename from pkg/emscripten/proto.css rename to pkg/emscripten/libretro/libretro.css diff --git a/pkg/emscripten/proto.js b/pkg/emscripten/libretro/libretro.js similarity index 100% rename from pkg/emscripten/proto.js rename to pkg/emscripten/libretro/libretro.js From d6e4ce51180b87aa0de3c3a743319172c723142f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Sep 2016 01:22:23 +0200 Subject: [PATCH 131/334] menu_input.c - cleanup --- menu/menu_input.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/menu/menu_input.c b/menu/menu_input.c index 9ec642003d..5e7801cf55 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -14,10 +14,6 @@ * If not, see . */ -#ifdef HAVE_CONFIG_H -#include "../../config.h" -#endif - #include #include #include From 8b2b406a85219f1126a5fed69a347dd1c4f64659 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Sep 2016 01:23:25 +0200 Subject: [PATCH 132/334] menu_content.c - add HAVE_CONFIG_H ifdef --- menu/menu_content.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/menu/menu_content.c b/menu/menu_content.c index f207170646..311481a260 100644 --- a/menu/menu_content.c +++ b/menu/menu_content.c @@ -20,6 +20,10 @@ #include #include +#ifdef HAVE_CONFIG_H +#include "../config.h" +#endif + #include "menu_content.h" #include "menu_driver.h" #include "menu_display.h" From e19699bac483ed01c0d34633a7aa9f41f4625de4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Sep 2016 01:25:04 +0200 Subject: [PATCH 133/334] Cleanups --- menu/menu_display.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/menu/menu_display.c b/menu/menu_display.c index 634c417200..b68f41c827 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -22,6 +22,14 @@ #include #include +#ifdef HAVE_CONFIG_H +#include "../config.h" +#endif + +#ifdef HAVE_THREADS +#include "../gfx/video_thread_wrapper.h" +#endif + #include "../config.def.h" #include "../retroarch.h" #include "../configuration.h" @@ -35,9 +43,6 @@ #include "menu_animation.h" #include "menu_display.h" -#ifdef HAVE_THREADS -#include "../gfx/video_thread_wrapper.h" -#endif uintptr_t menu_display_white_texture; From 8de734b702efc40e4f578cdaff9e66ff0be0ece5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Sep 2016 01:27:59 +0200 Subject: [PATCH 134/334] Header include cleanups --- menu/widgets/menu_list.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/menu/widgets/menu_list.c b/menu/widgets/menu_list.c index 470036993a..4b40506777 100644 --- a/menu/widgets/menu_list.c +++ b/menu/widgets/menu_list.c @@ -15,10 +15,6 @@ #include -#include -#include -#include - #include "menu_list.h" #include "../menu_driver.h" From 28a334318a829c0c9a5ca2582a137c0eb4a6b4e8 Mon Sep 17 00:00:00 2001 From: fr500 Date: Thu, 15 Sep 2016 18:32:37 -0500 Subject: [PATCH 135/334] (ems) itch.io template refinement --- pkg/emscripten/itch/index.html | 23 ++--------------------- pkg/emscripten/itch/itch.js | 21 ++------------------- 2 files changed, 4 insertions(+), 40 deletions(-) diff --git a/pkg/emscripten/itch/index.html b/pkg/emscripten/itch/index.html index 0efde37c3c..d659b272a3 100644 --- a/pkg/emscripten/itch/index.html +++ b/pkg/emscripten/itch/index.html @@ -46,7 +46,7 @@ FB Alpha 2012 CPS1 FB Alpha 2012 CPS2 FB Alpha 2012 NeoGeo - FCEUmm--> + FCEUmm Gambatte Genesis Plus GX @@ -59,7 +59,7 @@ Mednafen PC Engine Fast - --> + @@ -113,25 +113,6 @@
-
-
-
-
- -
-
-
-
-
-
-
- -
-
- -
-
-

For now, we recommend you use Google Chrome for the best possible performance.

diff --git a/pkg/emscripten/itch/itch.js b/pkg/emscripten/itch/itch.js index ba42e4274b..b32c79d960 100644 --- a/pkg/emscripten/itch/itch.js +++ b/pkg/emscripten/itch/itch.js @@ -68,6 +68,7 @@ function dropboxInit() function dropboxSyncComplete() { document.getElementById('btnRun').disabled = false; + document.getElementById('btnDrop').disabled = false; $('#icnDrop').removeClass('fa-spinner').removeClass('fa-spin'); $('#icnDrop').addClass('fa-dropbox'); console.log("WEBPLAYER: Sync successful"); @@ -239,25 +240,7 @@ var Module = arguments: ["-v", "--menu"], preRun: [], postRun: [], - print: (function() - { - var element = document.getElementById('output'); - element.value = ''; // clear browser cache - return function(text) - { - text = Array.prototype.slice.call(arguments).join(' '); - element.value += text + "\n"; - element.scrollTop = 99999; // focus on bottom - }; - })(), - - printErr: function(text) - { - var text = Array.prototype.slice.call(arguments).join(' '); - var element = document.getElementById('output'); - element.value += text + "\n"; - element.scrollTop = 99999; // focus on bottom - }, + canvas: document.getElementById('canvas'), totalDependencies: 0, monitorRunDependencies: function(left) From 0427ede02578e6b4908852f03cb7541baaa979b4 Mon Sep 17 00:00:00 2001 From: fr500 Date: Thu, 15 Sep 2016 18:45:32 -0500 Subject: [PATCH 136/334] (ems) update urls for itch --- pkg/emscripten/itch/index.html | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pkg/emscripten/itch/index.html b/pkg/emscripten/itch/index.html index d659b272a3..4f4ed1fec6 100644 --- a/pkg/emscripten/itch/index.html +++ b/pkg/emscripten/itch/index.html @@ -12,7 +12,7 @@ - + @@ -109,14 +109,10 @@
- RetroArch Logo + RetroArch Logo
-
-

For now, we recommend you use Google Chrome for the best possible performance.

- -
From 035259b95979ce2e1b29dba031bf87d624b0f188 Mon Sep 17 00:00:00 2001 From: fr500 Date: Thu, 15 Sep 2016 18:56:12 -0500 Subject: [PATCH 137/334] (ems) disable dropbox integration on itch.io for now --- pkg/emscripten/itch/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/emscripten/itch/index.html b/pkg/emscripten/itch/index.html index 4f4ed1fec6..15c43f632f 100644 --- a/pkg/emscripten/itch/index.html +++ b/pkg/emscripten/itch/index.html @@ -95,9 +95,9 @@ - + + + +
+
+
+ + RetroArch Logo +
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+

For now, we recommend you use Google Chrome for the best possible performance.

+ +
+ + + + + + + + + + diff --git a/pkg/emscripten/itch/index.html b/pkg/emscripten/itch/index.html index 3365917a92..d063743760 100644 --- a/pkg/emscripten/itch/index.html +++ b/pkg/emscripten/itch/index.html @@ -2,9 +2,9 @@ + RetroArch Web Player - @@ -14,7 +14,6 @@ - From 5698bd489c0ecd40d3a9732eb957308c93ef180d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Sep 2016 17:14:25 +0200 Subject: [PATCH 176/334] menu_input_pointer_post_iterate - cleanup --- menu/menu_input.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/menu/menu_input.c b/menu/menu_input.c index 01f584782d..6b7f834f1d 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -345,16 +345,18 @@ static int menu_input_pointer_post_iterate( static int16_t pointer_old_x = 0; static int16_t pointer_old_y = 0; int ret = 0; + bool check_overlay = false; menu_input_t *menu_input = menu_input_get_ptr(); settings_t *settings = config_get_ptr(); - bool check_overlay = settings ? !settings->menu.pointer.enable : false; - + if (!menu_input || !settings) return -1; + check_overlay = !settings->menu.pointer.enable; #ifdef HAVE_OVERLAY - check_overlay = check_overlay || - (settings->input.overlay_enable && input_overlay_is_alive(NULL)); + if (!check_overlay) + check_overlay = (settings->input.overlay_enable + && input_overlay_is_alive(NULL)); #endif if (check_overlay) From f395e851c409a225bb119a1161eba1a2670f7ffd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Sep 2016 17:25:47 +0200 Subject: [PATCH 177/334] Use stdstring.h --- frontend/drivers/platform_ps3.c | 3 ++- frontend/frontend_driver.c | 3 ++- frontend/frontend_salamander.c | 4 ++-- libretro-common/net/net_http.c | 3 ++- libretro-common/net/test/Makefile | 5 +++-- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/frontend/drivers/platform_ps3.c b/frontend/drivers/platform_ps3.c index 746dee3ab8..3747d7a19b 100644 --- a/frontend/drivers/platform_ps3.c +++ b/frontend/drivers/platform_ps3.c @@ -32,6 +32,7 @@ #endif #include +#include #include #ifndef IS_SALAMANDER #include @@ -125,7 +126,7 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[], /* not launched from external launcher, set default path */ // second param is multiMAN SELF file if(path_file_exists(argv[2]) && *argc > 1 - && (!strcmp(argv[2], EMULATOR_CONTENT_DIR))) + && (string_is_equal(argv[2], EMULATOR_CONTENT_DIR))) { multiman_detected = true; RARCH_LOG("Started from multiMAN, auto-game start enabled.\n"); diff --git a/frontend/frontend_driver.c b/frontend/frontend_driver.c index 070a87bd67..1e6c6073f3 100644 --- a/frontend/frontend_driver.c +++ b/frontend/frontend_driver.c @@ -17,6 +17,7 @@ #include #include +#include #ifdef HAVE_CONFIG_H #include "../config.h" @@ -82,7 +83,7 @@ frontend_ctx_driver_t *frontend_ctx_find_driver(const char *ident) for (i = 0; frontend_ctx_drivers[i]; i++) { - if (!strcmp(frontend_ctx_drivers[i]->ident, ident)) + if (string_is_equal(frontend_ctx_drivers[i]->ident, ident)) return frontend_ctx_drivers[i]; } diff --git a/frontend/frontend_salamander.c b/frontend/frontend_salamander.c index a8581aab09..7ddf61093e 100644 --- a/frontend/frontend_salamander.c +++ b/frontend/frontend_salamander.c @@ -133,7 +133,7 @@ static void salamander_init(char *s, size_t len) config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str)); config_file_free(conf); - if (strcmp(tmp_str, "builtin") != 0) + if (!string_is_equal(tmp_str, "builtin")) strlcpy(s, tmp_str, len); } #ifdef GEKKO @@ -146,7 +146,7 @@ static void salamander_init(char *s, size_t len) #endif } - if (!config_file_exists || !strcmp(s, "")) + if (!config_file_exists || string_is_equal(s, "")) { char executable_name[PATH_MAX_LENGTH]; diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index ff7f851206..0f99dccf10 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -28,6 +28,7 @@ #include #include #include +#include enum { @@ -350,7 +351,7 @@ bool net_http_update(struct http_t *state, size_t* progress, size_t* total) state->len = strtol(state->data + strlen("Content-Length: "), NULL, 10); } - if (!strcmp(state->data, "Transfer-Encoding: chunked")) + if (string_is_equal(state->data, "Transfer-Encoding: chunked")) state->bodytype = T_CHUNK; /* TODO: save headers somewhere */ diff --git a/libretro-common/net/test/Makefile b/libretro-common/net/test/Makefile index 6578f5116d..f4ae977a6b 100644 --- a/libretro-common/net/test/Makefile +++ b/libretro-common/net/test/Makefile @@ -13,9 +13,10 @@ CFLAGS += -Wall -pedantic -std=gnu99 HTTP_TEST_C = \ $(LIBRETRO_COMM_DIR)/net/net_http.c \ - net_http_test.c \ $(LIBRETRO_COMM_DIR)/net/net_compat.c \ - $(LIBRETRO_COMM_DIR)/compat/compat_strl.c + $(LIBRETRO_COMM_DIR)/compat/compat_strl.c \ + $(LIBRETRO_COMM_DIR)/string/stdstring.c \ + net_http_test.c HTTP_TEST_OBJS := $(HTTP_TEST_C:.c=.o) From 99aae8537bb55b6c78ba19a02bfe39131d98608b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Sep 2016 17:33:18 +0200 Subject: [PATCH 178/334] Use string_is_equal/stdstring.h --- gfx/drivers_shader/glslang_util.cpp | 7 ++++--- gfx/drivers_shader/shader_vulkan.cpp | 4 ++-- libretro-db/Makefile | 18 ++++++++++-------- libretro-db/c_converter.c | 15 ++++++++------- libretro-db/libretrodb_tool.c | 8 +++++--- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/gfx/drivers_shader/glslang_util.cpp b/gfx/drivers_shader/glslang_util.cpp index d00f6d3002..12923f2c98 100644 --- a/gfx/drivers_shader/glslang_util.cpp +++ b/gfx/drivers_shader/glslang_util.cpp @@ -19,10 +19,11 @@ #include #include +#include #include #include #include -#include +#include #include "glslang_util.hpp" #include "glslang.hpp" @@ -227,7 +228,7 @@ const char *glslang_format_to_string(enum glslang_format fmt) static glslang_format glslang_find_format(const char *fmt) { #undef FMT -#define FMT(x) if (!strcmp(fmt, #x)) return SLANG_FORMAT_ ## x +#define FMT(x) if (string_is_equal(fmt, #x)) return SLANG_FORMAT_ ## x FMT(R8_UNORM); FMT(R8_UINT); FMT(R8_SINT); @@ -309,7 +310,7 @@ static bool glslang_parse_meta(const vector &lines, glslang_meta *meta) * if they are exactly the same. */ if (itr != end(meta->parameters)) { - if (itr->desc != desc || + if ( itr->desc != desc || itr->initial != initial || itr->minimum != minimum || itr->maximum != maximum || diff --git a/gfx/drivers_shader/shader_vulkan.cpp b/gfx/drivers_shader/shader_vulkan.cpp index dbd999f306..614073b172 100644 --- a/gfx/drivers_shader/shader_vulkan.cpp +++ b/gfx/drivers_shader/shader_vulkan.cpp @@ -44,7 +44,7 @@ static const uint32_t opaque_frag[] = static unsigned num_miplevels(unsigned width, unsigned height) { - unsigned size = std::max(width, height); + unsigned size = std::max(width, height); unsigned levels = 0; while (size) { @@ -60,7 +60,7 @@ static void image_layout_transition_levels( VkAccessFlags src_access, VkAccessFlags dst_access, VkPipelineStageFlags src_stages, VkPipelineStageFlags dst_stages) { - VkImageMemoryBarrier barrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER }; + VkImageMemoryBarrier barrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER }; barrier.srcAccessMask = src_access; barrier.dstAccessMask = dst_access; diff --git a/libretro-db/Makefile b/libretro-db/Makefile index cb6412f5ea..d544966154 100644 --- a/libretro-db/Makefile +++ b/libretro-db/Makefile @@ -1,7 +1,7 @@ DEBUG = 0 LIBRETRODB_DIR := . -LIBRETRO_COMMON_DIR := ../libretro-common -INCFLAGS = -I. -I$(LIBRETRO_COMMON_DIR)/include +LIBRETRO_COMM_DIR := ../libretro-common +INCFLAGS = -I. -I$(LIBRETRO_COMM_DIR)/include TARGETS = rmsgpack_test libretrodb_tool c_converter @@ -12,7 +12,7 @@ CFLAGS = -g -O2 -Wall -DNDEBUG endif LIBRETRO_COMMON_C = \ - $(LIBRETRO_COMMON_DIR)/streams/file_stream.c + $(LIBRETRO_COMM_DIR)/streams/file_stream.c C_CONVERTER_C = \ $(LIBRETRODB_DIR)/rmsgpack.c \ @@ -21,10 +21,11 @@ C_CONVERTER_C = \ $(LIBRETRODB_DIR)/bintree.c \ $(LIBRETRODB_DIR)/query.c \ $(LIBRETRODB_DIR)/c_converter.c \ - $(LIBRETRO_COMMON_DIR)/hash/rhash.c \ - $(LIBRETRO_COMMON_DIR)/compat/compat_fnmatch.c \ + $(LIBRETRO_COMM_DIR)/hash/rhash.c \ + $(LIBRETRO_COMM_DIR)/compat/compat_fnmatch.c \ + $(LIBRETRO_COMM_DIR)/string/stdstring.c $(LIBRETRO_COMMON_C) \ - $(LIBRETRO_COMMON_DIR)/compat/compat_strl.c + $(LIBRETRO_COMM_DIR)/compat/compat_strl.c C_CONVERTER_OBJS := $(C_CONVERTER_C:.c=.o) @@ -35,9 +36,10 @@ RARCHDB_TOOL_C = \ $(LIBRETRODB_DIR)/bintree.c \ $(LIBRETRODB_DIR)/query.c \ $(LIBRETRODB_DIR)/libretrodb.c \ - $(LIBRETRO_COMMON_DIR)/compat/compat_fnmatch.c \ + $(LIBRETRO_COMM_DIR)/compat/compat_fnmatch.c \ + $(LIBRETRO_COMM_DIR)/string/stdstring.c $(LIBRETRO_COMMON_C) \ - $(LIBRETRO_COMMON_DIR)/compat/compat_strl.c + $(LIBRETRO_COMM_DIR)/compat/compat_strl.c RARCHDB_TOOL_OBJS := $(RARCHDB_TOOL_C:.c=.o) diff --git a/libretro-db/c_converter.c b/libretro-db/c_converter.c index 7284ef4e2b..7876e0d10d 100644 --- a/libretro-db/c_converter.c +++ b/libretro-db/c_converter.c @@ -31,6 +31,7 @@ #include #include +#include #include "libretrodb.h" @@ -341,13 +342,13 @@ static dat_converter_list_t* dat_parser_table( if (!map.key) { - if (!strcmp(current->token.label, ")")) + if (string_is_equal(current->token.label, ")")) { current++; *start_token = current; return parsed_table; } - else if (!strcmp(current->token.label, "(")) + else if (string_is_equal(current->token.label, "(")) { printf("%s:%d:%d: fatal error: Unexpected '(' instead of key\n", current->token.fname, @@ -363,14 +364,14 @@ static dat_converter_list_t* dat_parser_table( } else { - if (!strcmp(current->token.label, "(")) + if (string_is_equal(current->token.label, "(")) { current++; map.type = DAT_CONVERTER_LIST_MAP; map.value.list = dat_parser_table(¤t); dat_converter_list_append(parsed_table, &map); } - else if (!strcmp(current->token.label, ")")) + else if (string_is_equal(current->token.label, ")")) { printf("%s:%d:%d: fatal error: Unexpected ')' instead of value\n", current->token.fname, @@ -468,7 +469,7 @@ static const char* dat_converter_get_match( { if (list->values[i].map.hash == match_key->hash) { - retro_assert(!strcmp(list->values[i].map.key, match_key->value)); + retro_assert(string_is_equal(list->values[i].map.key, match_key->value)); if (match_key->next) return dat_converter_get_match( @@ -510,14 +511,14 @@ static dat_converter_list_t* dat_converter_parser( { if (!map.key) { - if (!strcmp(current->token.label, "game")) + if (string_is_equal(current->token.label, "game")) skip = false; map.key = current->token.label; current++; } else { - if (!strcmp(current->token.label, "(")) + if (string_is_equal(current->token.label, "(")) { current++; map.value.list = dat_parser_table(¤t); diff --git a/libretro-db/libretrodb_tool.c b/libretro-db/libretrodb_tool.c index b8c8f25c34..e8b5ed5f69 100644 --- a/libretro-db/libretrodb_tool.c +++ b/libretro-db/libretrodb_tool.c @@ -23,6 +23,8 @@ #include #include +#include + #include "libretrodb.h" #include "rmsgpack_dom.h" @@ -59,7 +61,7 @@ int main(int argc, char ** argv) printf("Could not open db file '%s': %s\n", path, strerror(-rv)); goto error; } - else if (!strcmp(command, "list")) + else if (string_is_equal(command, "list")) { if ((rv = libretrodb_cursor_open(db, cur, NULL)) != 0) { @@ -80,7 +82,7 @@ int main(int argc, char ** argv) rmsgpack_dom_value_free(&item); } } - else if (!strcmp(command, "find")) + else if (string_is_equal(command, "find")) { if (argc != 4) { @@ -111,7 +113,7 @@ int main(int argc, char ** argv) rmsgpack_dom_value_free(&item); } } - else if (!strcmp(command, "create-index")) + else if (string_is_equal(command, "create-index")) { const char * index_name, * field_name; From 028bb38ec5deeb086858ad50b168a27fb160502f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Sep 2016 17:45:41 +0200 Subject: [PATCH 179/334] Add vector_4 --- libretro-common/gfx/math/vector_2.c | 21 +++++-- libretro-common/gfx/math/vector_3.c | 32 +++++++---- libretro-common/gfx/math/vector_4.c | 62 +++++++++++++++++++++ libretro-common/include/gfx/math/vector_4.h | 39 +++++++++++++ 4 files changed, 136 insertions(+), 18 deletions(-) create mode 100644 libretro-common/gfx/math/vector_4.c create mode 100644 libretro-common/include/gfx/math/vector_4.h diff --git a/libretro-common/gfx/math/vector_2.c b/libretro-common/gfx/math/vector_2.c index 6719fac93a..b7745e456e 100644 --- a/libretro-common/gfx/math/vector_2.c +++ b/libretro-common/gfx/math/vector_2.c @@ -37,18 +37,27 @@ float vec2_cross(const float *a, const float *b) void vec2_add(float *dst, const float *src) { - dst[0] += src[0]; - dst[1] += src[1]; + unsigned i; + unsigned n = 2; + + for (i = 0; i < n; i++) + dst[i] += src[i]; } void vec2_subtract(float *dst, const float *src) { - dst[0] -= src[0]; - dst[1] -= src[1]; + unsigned i; + unsigned n = 2; + + for (i = 0; i < n; i++) + dst[i] -= src[i]; } void vec2_copy(float *dst, const float *src) { - dst[0] = src[0]; - dst[1] = src[1]; + unsigned i; + unsigned n = 2; + + for (i = 0; i < n; i++) + dst[i] = src[i]; } diff --git a/libretro-common/gfx/math/vector_3.c b/libretro-common/gfx/math/vector_3.c index 1ec04acab7..4f76dde269 100644 --- a/libretro-common/gfx/math/vector_3.c +++ b/libretro-common/gfx/math/vector_3.c @@ -46,30 +46,38 @@ float vec3_length(const float *a) void vec3_add(float *dst, const float *src) { - dst[0] += src[0]; - dst[1] += src[1]; - dst[2] += src[2]; + unsigned i; + unsigned n = 3; + + for (i = 0; i < n; i++) + dst[i] += src[i]; } void vec3_subtract(float *dst, const float *src) { - dst[0] -= src[0]; - dst[1] -= src[1]; - dst[2] -= src[2]; + unsigned i; + unsigned n = 3; + + for (i = 0; i < n; i++) + dst[i] -= src[i]; } void vec3_scale(float *dst, const float scale) { - dst[0] *= scale; - dst[1] *= scale; - dst[2] *= scale; + unsigned i; + unsigned n = 3; + + for (i = 0; i < n; i++) + dst[i] *= scale; } void vec3_copy(float *dst, const float *src) { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; + unsigned i; + unsigned n = 3; + + for (i = 0; i < n; i++) + dst[i] = src[i]; } void vec3_normalize(float *dst) diff --git a/libretro-common/gfx/math/vector_4.c b/libretro-common/gfx/math/vector_4.c new file mode 100644 index 0000000000..0c2d4d5fcf --- /dev/null +++ b/libretro-common/gfx/math/vector_4.c @@ -0,0 +1,62 @@ +/* Copyright (C) 2010-2016 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (vector_4.c). + * --------------------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include + +#include + +void vec4_add(float *dst, const float *src) +{ + unsigned i; + unsigned n = 4; + + for (i = 0; i < n; i++) + dst[i] += src[i]; +} + +void vec4_subtract(float *dst, const float *src) +{ + unsigned i; + unsigned n = 4; + + for (i = 0; i < n; i++) + dst[i] -= src[i]; +} + +void vec4_scale(float *dst, const float scale) +{ + unsigned i; + unsigned n = 4; + + for (i = 0; i < n; i++) + dst[i] *= scale; +} + +void vec4_copy(float *dst, const float *src) +{ + unsigned i; + unsigned n = 4; + + for (i = 0; i < n; i++) + dst[i] = src[i]; +} diff --git a/libretro-common/include/gfx/math/vector_4.h b/libretro-common/include/gfx/math/vector_4.h new file mode 100644 index 0000000000..494d8dcebd --- /dev/null +++ b/libretro-common/include/gfx/math/vector_4.h @@ -0,0 +1,39 @@ +/* Copyright (C) 2010-2016 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (vector_4.h). + * --------------------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __LIBRETRO_SDK_GFX_MATH_VECTOR_4_H__ +#define __LIBRETRO_SDK_GFX_MATH_VECTOR_4_H__ + +#include + +typedef float vec4_t[4]; + +void vec4_add(float *dst, const float *src); + +void vec4_subtract(float *dst, const float *src); + +void vec4_scale(float *dst, const float scale); + +void vec4_copy(float *dst, const float *src); + +#endif + From 1055938b672183d5ca4b881ec9158dae56eb81fb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Sep 2016 17:46:13 +0200 Subject: [PATCH 180/334] Add vector_4 to Griffin and Makefile.common --- Makefile.common | 1 + griffin/griffin.c | 1 + 2 files changed, 2 insertions(+) diff --git a/Makefile.common b/Makefile.common index dc0f40198c..586ec03e88 100644 --- a/Makefile.common +++ b/Makefile.common @@ -688,6 +688,7 @@ OBJ += gfx/video_context_driver.o \ gfx/video_state_tracker.o \ libretro-common/gfx/math/vector_2.o \ libretro-common/gfx/math/vector_3.o \ + libretro-common/gfx/math/vector_4.o \ libretro-common/gfx/math/matrix_4x4.o \ libretro-common/gfx/math/matrix_3x3.o diff --git a/griffin/griffin.c b/griffin/griffin.c index 03fe237977..1497bcee4f 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -268,6 +268,7 @@ VIDEO DRIVER #include "../libretro-common/gfx/math/matrix_3x3.c" #include "../libretro-common/gfx/math/vector_2.c" #include "../libretro-common/gfx/math/vector_3.c" +#include "../libretro-common/gfx/math/vector_4.c" #if defined(GEKKO) #ifdef HW_RVL From 6002fd9f2a7003c6c1b75cec9e0cfae2a7d62768 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Sep 2016 17:50:57 +0200 Subject: [PATCH 181/334] (shader_vulkan.cpp) Nits --- gfx/drivers_shader/shader_vulkan.cpp | 35 +++++++++++----------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/gfx/drivers_shader/shader_vulkan.cpp b/gfx/drivers_shader/shader_vulkan.cpp index 614073b172..813903caff 100644 --- a/gfx/drivers_shader/shader_vulkan.cpp +++ b/gfx/drivers_shader/shader_vulkan.cpp @@ -1218,8 +1218,7 @@ void *Buffer::map() { if (vkMapMemory(device, memory, 0, size, 0, &mapped) == VK_SUCCESS) return mapped; - else - return nullptr; + return nullptr; } return mapped; } @@ -1614,7 +1613,7 @@ CommonResources::CommonResources(VkDevice device, memcpy(ptr, vbo_data, sizeof(vbo_data)); vbo->unmap(); - VkSamplerCreateInfo info = { VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO }; + VkSamplerCreateInfo info = { VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO }; info.mipLodBias = 0.0f; info.maxAnisotropy = 1.0f; info.compareEnable = false; @@ -1739,6 +1738,10 @@ bool Pass::init_feedback() bool Pass::build() { + unordered_map semantic_map; + unsigned i; + unsigned j = 0; + framebuffer.reset(); framebuffer_feedback.reset(); @@ -1750,8 +1753,6 @@ bool Pass::build() pass_info.rt_format, pass_info.max_levels)); } - unordered_map semantic_map; - unsigned j = 0; for (auto ¶m : parameters) { if (!set_unique_map(semantic_map, param.id, @@ -1760,24 +1761,23 @@ bool Pass::build() j++; } - reflection = slang_reflection{}; - reflection.pass_number = pass_number; - reflection.texture_semantic_map = &common->texture_semantic_map; + reflection = slang_reflection{}; + reflection.pass_number = pass_number; + reflection.texture_semantic_map = &common->texture_semantic_map; reflection.texture_semantic_uniform_map = &common->texture_semantic_uniform_map; - reflection.semantic_map = &semantic_map; + reflection.semantic_map = &semantic_map; if (!slang_reflect_spirv(vertex_shader, fragment_shader, &reflection)) return false; // Filter out parameters which we will never use anyways. filtered_parameters.clear(); - for (unsigned i = 0; i < reflection.semantic_float_parameters.size(); i++) + + for (i = 0; i < reflection.semantic_float_parameters.size(); i++) { if (reflection.semantic_float_parameters[i].uniform || reflection.semantic_float_parameters[i].push_constant) - { filtered_parameters.push_back(parameters[i]); - } } if (!init_pipeline()) @@ -1837,9 +1837,7 @@ void Pass::set_semantic_texture_array(VkDescriptorSet set, { if (index < reflection.semantic_textures[semantic].size() && reflection.semantic_textures[semantic][index].texture) - { set_texture(set, reflection.semantic_textures[semantic][index].binding, texture); - } } void Pass::build_semantic_texture_array_vec4(uint8_t *data, slang_texture_semantic semantic, @@ -1850,20 +1848,16 @@ void Pass::build_semantic_texture_array_vec4(uint8_t *data, slang_texture_semant return; if (data && refl[index].uniform) - { build_vec4( reinterpret_cast(data + refl[index].ubo_offset), width, height); - } if (refl[index].push_constant) - { build_vec4( reinterpret_cast(push.buffer.data() + (refl[index].push_constant_offset >> 2)), width, height); - } } void Pass::build_semantic_texture_vec4(uint8_t *data, slang_texture_semantic semantic, @@ -1876,21 +1870,18 @@ void Pass::build_semantic_vec4(uint8_t *data, slang_semantic semantic, unsigned width, unsigned height) { auto &refl = reflection.semantics[semantic]; + if (data && refl.uniform) - { build_vec4( reinterpret_cast(data + refl.ubo_offset), width, height); - } if (refl.push_constant) - { build_vec4( reinterpret_cast(push.buffer.data() + (refl.push_constant_offset >> 2)), width, height); - } } void Pass::build_semantic_parameter(uint8_t *data, unsigned index, float value) From ee4c893c0791b90eda65dc347a748cadc67591bf Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Sep 2016 18:03:30 +0200 Subject: [PATCH 182/334] Update matrix_4x4_projection --- libretro-common/gfx/math/matrix_4x4.c | 16 ++++++++++------ libretro-common/include/gfx/math/matrix_4x4.h | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/libretro-common/gfx/math/matrix_4x4.c b/libretro-common/gfx/math/matrix_4x4.c index 1e4b72b2cd..32d86923a4 100644 --- a/libretro-common/gfx/math/matrix_4x4.c +++ b/libretro-common/gfx/math/matrix_4x4.c @@ -160,17 +160,21 @@ void matrix_4x4_translate(math_matrix_4x4 *out, float x, /* * Creates a perspective projection matrix. */ -void matrix_4x4_projection(math_matrix_4x4 *out, float znear, +void matrix_4x4_projection(math_matrix_4x4 *out, + float y_fov, + float aspect, + float znear, float zfar) { + float const a = 1.f / tan(y_fov / 2.f); float delta_z = zfar - znear; memset(out, 0, sizeof(*out)); - MAT_ELEM_4X4(*out, 0, 0) = znear; - MAT_ELEM_4X4(*out, 1, 1) = zfar; - MAT_ELEM_4X4(*out, 2, 2) = (zfar + znear) / delta_z; - MAT_ELEM_4X4(*out, 2, 3) = -2.0f * zfar * znear / delta_z; - MAT_ELEM_4X4(*out, 3, 2) = -1.0f; + MAT_ELEM_4X4(*out, 0, 0) = a / aspect; + MAT_ELEM_4X4(*out, 1, 1) = a; + MAT_ELEM_4X4(*out, 2, 2) = -((zfar + znear) / (zfar - znear)); + MAT_ELEM_4X4(*out, 2, 3) = -1.f; + MAT_ELEM_4X4(*out, 3, 2) = -((2.f * zfar * znear) / (zfar - znear)); } /* diff --git a/libretro-common/include/gfx/math/matrix_4x4.h b/libretro-common/include/gfx/math/matrix_4x4.h index 883dafbec6..aab05c2644 100644 --- a/libretro-common/include/gfx/math/matrix_4x4.h +++ b/libretro-common/include/gfx/math/matrix_4x4.h @@ -52,7 +52,7 @@ void matrix_4x4_multiply(math_matrix_4x4 *out, const math_matrix_4x4 *a, const m void matrix_4x4_scale(math_matrix_4x4 *out, float x, float y, float z); void matrix_4x4_translate(math_matrix_4x4 *out, float x, float y, float z); -void matrix_4x4_projection(math_matrix_4x4 *out, float znear, float zfar); +void matrix_4x4_projection(math_matrix_4x4 *out, float y_fov, float aspect, float znear, float zfar); #endif From eac7bcf38fc4bba489e31dab2e19d85ef1996015 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Sep 2016 18:27:00 +0200 Subject: [PATCH 183/334] Create unfinished version of matrix_4x4_lookat --- libretro-common/gfx/math/matrix_4x4.c | 44 +++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/libretro-common/gfx/math/matrix_4x4.c b/libretro-common/gfx/math/matrix_4x4.c index 32d86923a4..8b557074d1 100644 --- a/libretro-common/gfx/math/matrix_4x4.c +++ b/libretro-common/gfx/math/matrix_4x4.c @@ -24,6 +24,7 @@ #include #include +#include void matrix_4x4_copy(math_matrix_4x4 *dst, const math_matrix_4x4 *src) { @@ -172,9 +173,48 @@ void matrix_4x4_projection(math_matrix_4x4 *out, memset(out, 0, sizeof(*out)); MAT_ELEM_4X4(*out, 0, 0) = a / aspect; MAT_ELEM_4X4(*out, 1, 1) = a; - MAT_ELEM_4X4(*out, 2, 2) = -((zfar + znear) / (zfar - znear)); + MAT_ELEM_4X4(*out, 2, 2) = -((zfar + znear) / delta_z); MAT_ELEM_4X4(*out, 2, 3) = -1.f; - MAT_ELEM_4X4(*out, 3, 2) = -((2.f * zfar * znear) / (zfar - znear)); + MAT_ELEM_4X4(*out, 3, 2) = -((2.f * zfar * znear) / delta_z); +} + +/* TODO/FIXME - finish */ +void matrix_4x4_lookat(math_matrix_4x4 *out, + vec3_t eye, + vec3_t center, + vec3_t up) +{ + vec3_t s, t, f; + + vec3_copy(&f[0], center); + vec3_subtract(&f[0], eye); + vec3_normalize(&f[0]); + + vec3_cross(&s[0], &f[0], up); + vec3_normalize(&s[0]); + + vec3_cross(&t[0], &s[0], f); + + memset(out, 0, sizeof(*out)); + + MAT_ELEM_4X4(*out, 0, 0) = s[0]; + MAT_ELEM_4X4(*out, 0, 1) = t[0]; + MAT_ELEM_4X4(*out, 0, 2) = -f[0]; + + MAT_ELEM_4X4(*out, 1, 0) = s[1]; + MAT_ELEM_4X4(*out, 1, 1) = t[1]; + MAT_ELEM_4X4(*out, 1, 2) = -f[1]; + + MAT_ELEM_4X4(*out, 2, 0) = s[2]; + MAT_ELEM_4X4(*out, 2, 1) = t[2]; + MAT_ELEM_4X4(*out, 2, 2) = -f[2]; + + MAT_ELEM_4X4(*out, 3, 3) = 1.f; + +#if 0 + mat4x4_translate_in_place(m, -eye[0], -eye[1], -eye[2]); +#endif + } /* From 5f6f63081897aff516f9cb61c9b4f398685a9b20 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Sep 2016 19:15:46 +0200 Subject: [PATCH 184/334] (ffmpeg core) Cleanup --- cores/libretro-ffmpeg/fft/fft.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/cores/libretro-ffmpeg/fft/fft.cpp b/cores/libretro-ffmpeg/fft/fft.cpp index b21539ab2e..14c0d67bf2 100644 --- a/cores/libretro-ffmpeg/fft/fft.cpp +++ b/cores/libretro-ffmpeg/fft/fft.cpp @@ -153,12 +153,6 @@ static GLuint fft_compile_program(glfft_t *fft, static void fft_render(glfft_t *fft, GLuint backbuffer, unsigned width, unsigned height) { - /* Render scene. */ - glBindFramebuffer(GL_FRAMEBUFFER, fft->ms_fbo ? fft->ms_fbo : backbuffer); - glViewport(0, 0, width, height); - glClearColor(0.1f, 0.15f, 0.1f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - vec3 eye = vec3(0, 80, -60); vec3 center = eye + vec3(0.0f, 0.0f, 1.0f); vec3 up = vec3(0.0f, 1.0f, 0.0f); @@ -166,6 +160,12 @@ static void fft_render(glfft_t *fft, GLuint backbuffer, unsigned width, unsigned mat4 mvp_lookat = lookAt(eye, center, up); mat4 mvp = mvp_persp * mvp_lookat; + /* Render scene. */ + glBindFramebuffer(GL_FRAMEBUFFER, fft->ms_fbo ? fft->ms_fbo : backbuffer); + glViewport(0, 0, width, height); + glClearColor(0.1f, 0.15f, 0.1f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + glUseProgram(fft->block.prog); glUniformMatrix4fv(glGetUniformLocation(fft->block.prog, "uMVP"), 1, GL_FALSE, value_ptr(mvp)); @@ -524,12 +524,12 @@ static void fft_init(glfft_t *fft) static void fft_init_block(glfft_t *fft) { unsigned x, y; - GLuint *bp; - GLushort *block_vertices; - GLuint *block_indices; unsigned block_vertices_size; unsigned block_indices_size; - int pos = 0; + int pos = 0; + GLuint *bp = NULL; + GLushort *block_vertices = NULL; + GLuint *block_indices = NULL; fft->block.prog = fft_compile_program(fft, fft_vertex_program_heightmap, fft_fragment_program_heightmap); @@ -605,13 +605,13 @@ static bool fft_context_reset(glfft_t *fft, unsigned fft_steps, fft->block_size = fft->size / 4 + 1; fft->passes_size = fft_steps; - fft->passes = (Pass*)calloc(fft->passes_size, sizeof(Pass)); + fft->passes = (Pass*)calloc(fft->passes_size, sizeof(Pass)); if (!fft->passes) return false; fft->sliding_size = 2 * fft->size; - fft->sliding = (GLshort*)calloc(fft->sliding_size, sizeof(GLshort)); + fft->sliding = (GLshort*)calloc(fft->sliding_size, sizeof(GLshort)); if (!fft->sliding) return false; From c4c96aa84337e1eabab8cbc8f80d71b0d2058aef Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Sep 2016 19:20:45 +0200 Subject: [PATCH 185/334] Don't show ffmpeg_fft_ core options when HAVE_OPENGL is not defined --- cores/libretro-ffmpeg/ffmpeg_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cores/libretro-ffmpeg/ffmpeg_core.c b/cores/libretro-ffmpeg/ffmpeg_core.c index bfbe5beff7..a44ec1b36d 100644 --- a/cores/libretro-ffmpeg/ffmpeg_core.c +++ b/cores/libretro-ffmpeg/ffmpeg_core.c @@ -272,10 +272,10 @@ void CORE_PREFIX(retro_set_environment)(retro_environment_t cb) static const struct retro_variable vars[] = { #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) { "ffmpeg_temporal_interp", "Temporal Interpolation; enabled|disabled" }, -#endif #ifdef HAVE_GL_FFT { "ffmpeg_fft_resolution", "GLFFT Resolution; 1280x720|1920x1080|640x360|320x180" }, { "ffmpeg_fft_multisample", "GLFFT Multisample; 1x|2x|4x" }, +#endif #endif { "ffmpeg_color_space", "Colorspace; auto|BT.709|BT.601|FCC|SMPTE240M" }, { NULL, NULL }, @@ -343,7 +343,6 @@ static void check_variables(void) else if (!strcmp(var.value, "disabled")) temporal_interpolation = false; } -#endif #ifdef HAVE_GL_FFT fft_var.key = "ffmpeg_fft_resolution"; @@ -365,6 +364,7 @@ static void check_variables(void) if (CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &fft_ms_var) && fft_ms_var.value) fft_multisample = strtoul(fft_ms_var.value, NULL, 0); +#endif #endif color_var.key = "ffmpeg_color_space"; From 955c399386decf930e560b862d59d1c884344367 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Sep 2016 19:23:42 +0200 Subject: [PATCH 186/334] (ffmpeg_core.c) nits --- cores/libretro-ffmpeg/ffmpeg_core.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cores/libretro-ffmpeg/ffmpeg_core.c b/cores/libretro-ffmpeg/ffmpeg_core.c index a44ec1b36d..c0eefbb081 100644 --- a/cores/libretro-ffmpeg/ffmpeg_core.c +++ b/cores/libretro-ffmpeg/ffmpeg_core.c @@ -436,9 +436,9 @@ void CORE_PREFIX(retro_run)(void) double min_pts; int16_t audio_buffer[2048]; bool left, right, up, down, l, r; - size_t to_read_frames = 0; - int seek_frames = 0; - bool updated = false; + size_t to_read_frames = 0; + int seek_frames = 0; + bool updated = false; #ifdef HAVE_GL_FFT unsigned old_fft_width = fft_width; unsigned old_fft_height = fft_height; @@ -1172,12 +1172,10 @@ static void decode_thread(void *data) (void)data; if (video_stream >= 0) - { sws = sws_getCachedContext(NULL, media.width, media.height, vctx->pix_fmt, media.width, media.height, PIX_FMT_RGB32, SWS_POINT, NULL, NULL, NULL); - } for (i = 0; (int)i < audio_streams_num; i++) { From d96386cd18b4813713be0244c508af3b6e016743 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Sep 2016 20:34:34 +0200 Subject: [PATCH 187/334] (iOS) Buildfix --- ui/drivers/cocoa/cocoatouch_menu.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/drivers/cocoa/cocoatouch_menu.m b/ui/drivers/cocoa/cocoatouch_menu.m index 3f4b3839ee..6b2b931d6f 100644 --- a/ui/drivers/cocoa/cocoatouch_menu.m +++ b/ui/drivers/cocoa/cocoatouch_menu.m @@ -429,7 +429,7 @@ replacementString:(NSString *)string field = [alertView textFieldAtIndex:0]; field.delegate = self.formatter; - menu_entry_get_value(self.i, buffer, sizeof(buffer)); + menu_entry_get_value(self.i, NULL, buffer, sizeof(buffer)); if (string_is_empty(buffer)) strlcpy(buffer, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), From 32ce489eed809a682c0cc71043ac71a27c4fe9ee Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 16 Sep 2016 20:35:38 +0200 Subject: [PATCH 188/334] Get rid of unused variable --- core_impl.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/core_impl.c b/core_impl.c index 2175ca0dab..0dd8f537b0 100644 --- a/core_impl.c +++ b/core_impl.c @@ -87,9 +87,6 @@ void core_set_input_state(retro_ctx_input_state_info_t *info) static bool core_init_libretro_cbs(void *data) { struct retro_callbacks *cbs = (struct retro_callbacks*)data; -#ifdef HAVE_NETPLAY - global_t *global = global_get_ptr(); -#endif if (!cbs) return false; From 4caee1ca5fceff3a6b098f05e556dff48673e2ec Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 00:22:55 +0200 Subject: [PATCH 189/334] Get rid of one ifdef --- tasks/tasks_internal.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index d264355f62..29c1403343 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -59,14 +59,6 @@ enum nbio_status_enum NBIO_STATUS_TRANSFER_PARSE_FREE }; -#ifdef HAVE_NETWORKING -typedef struct -{ - char *data; - size_t len; -} http_transfer_data_t; -#endif - typedef struct nbio_handle { enum image_type_enum image_type; @@ -81,6 +73,12 @@ typedef struct nbio_handle #ifdef HAVE_NETWORKING +typedef struct +{ + char *data; + size_t len; +} http_transfer_data_t; + void *task_push_http_transfer(const char *url, bool mute, const char *type, retro_task_callback_t cb, void *userdata); From fb8237f1bb11573d19ef2f4bcdce84051a0781c3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 00:28:47 +0200 Subject: [PATCH 190/334] Cleanup command_event_save_current_config --- command.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/command.c b/command.c index 321b14e883..798a0f5f27 100644 --- a/command.c +++ b/command.c @@ -1589,16 +1589,17 @@ static bool command_event_save_core_config(void) **/ void command_event_save_current_config(int override_type) { - settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); + char msg[128] = {0}; if (!override_type) { + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); - if (settings->config_save_on_exit && !string_is_empty(global->path.config)) + if ( settings->config_save_on_exit + && !string_is_empty(global->path.config)) { bool ret = false; - char msg[128] = {0}; const char *config_path = config_get_active_path(); /* Save last core-specific config to the default config location, @@ -1624,18 +1625,11 @@ void command_event_save_current_config(int override_type) global->path.config); RARCH_ERR("%s\n", msg); } - - runloop_msg_queue_push(msg, 1, 180, true); } } else { - bool ret = false; - char msg[128] = {0}; - - ret = config_save_overrides(override_type); - - if (ret) + if (config_save_overrides(override_type)) { snprintf(msg, sizeof(msg), "Overrides saved successfully"); RARCH_LOG("[overrides] %s\n", msg); @@ -1649,10 +1643,10 @@ void command_event_save_current_config(int override_type) snprintf(msg, sizeof(msg), "Error saving overrides"); RARCH_ERR("[overrides] %s\n", msg); } - - runloop_msg_queue_push(msg, 1, 180, true); - return; } + + if (!string_is_empty(msg)) + runloop_msg_queue_push(msg, 1, 180, true); } /** From 7e87ba4dcbb655c45ddd0047066a419e24de8b9a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 00:33:42 +0200 Subject: [PATCH 191/334] Dont use HAVE_GLES - turn it into HAVE_OPENGLES --- menu/menu_displaylist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index e01b84d658..df96b36e17 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -462,7 +462,7 @@ static uint64_t bytes_to_gb(uint64_t bytes) static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) { int controller; -#if defined(HAVE_OPENGL) || defined(HAVE_GLES) +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) gfx_ctx_ident_t ident_info; #endif char tmp[PATH_MAX_LENGTH] = {0}; @@ -798,7 +798,7 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) } } -#if defined(HAVE_OPENGL) || defined(HAVE_GLES) +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) video_context_driver_get_ident(&ident_info); tmp_string = ident_info.ident; From e3c560014c6c616cccbb9d29ae565ce502991a20 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 00:38:35 +0200 Subject: [PATCH 192/334] Turn HAVE_GLES into HAVE_OPENGLES --- Makefile.common | 12 ++++++------ Makefile.emscripten | 3 +-- qb/config.libs.sh | 16 ++++++++-------- qb/config.params.sh | 8 ++++---- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Makefile.common b/Makefile.common index 586ec03e88..c005e803d1 100644 --- a/Makefile.common +++ b/Makefile.common @@ -5,11 +5,11 @@ ifeq ($(HAVE_GL_CONTEXT),) HAVE_GL_CONTEXT=1 endif - ifeq ($(HAVE_GLES), 1) + ifeq ($(HAVE_OPENGLES), 1) HAVE_GL_CONTEXT=1 endif - ifeq ($(HAVE_GLES3), 1) + ifeq ($(HAVE_OPENGLES3), 1) HAVE_GL_CONTEXT=1 endif endif @@ -600,7 +600,7 @@ ifeq ($(HAVE_X11), 1) ifeq ($(HAVE_XCB),1) LIBS += -lX11-xcb endif -ifneq ($(HAVE_GLES), 1) +ifneq ($(HAVE_OPENGLES), 1) OBJ += gfx/drivers_context/x_ctx.o endif endif @@ -753,7 +753,7 @@ ifeq ($(HAVE_GL_CONTEXT), 1) endif ifeq ($(HAVE_FFMPEG), 1) ifneq ($(C89_BUILD), 1) -ifneq ($(HAVE_GLES), 1) +ifneq ($(HAVE_OPENGLES), 1) OBJ += cores/libretro-ffmpeg/fft/fft.o DEFINES += -Ideps -DHAVE_GL_FFT NEED_CXX_LINKER=1 @@ -761,10 +761,10 @@ endif endif endif - ifeq ($(HAVE_GLES), 1) + ifeq ($(HAVE_OPENGLES), 1) LIBS += $(GLES_LIBS) DEFINES += $(GLES_CFLAGS) -DHAVE_OPENGLES - ifeq ($(HAVE_GLES3), 1) + ifeq ($(HAVE_OPENGLES3), 1) DEFINES += -DHAVE_OPENGLES3 else DEFINES += -DHAVE_OPENGLES2 diff --git a/Makefile.emscripten b/Makefile.emscripten index 7ff0221912..d3efe609cd 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -9,8 +9,7 @@ DEFINES := -DRARCH_INTERNAL -DHAVE_OVERLAY -DHAVE_MAIN DEFINES += -DHAVE_OPENGL -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DHAVE_EGL -DHAVE_OVERLAY -DHAVE_GLSL -DHAVE_FILTERS_BUILTIN HAVE_EGL = 1 -HAVE_OPENGL = 1 -HAVE_GLES = 1 +HAVE_OPENGLES = 1 HAVE_RJPEG = 1 HAVE_RPNG = 1 HAVE_EMSCRIPTEN = 1 diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 8a7b2fec22..9cd67b5c0c 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -41,7 +41,7 @@ if [ "$HAVE_VIDEOCORE" = 'yes' ]; then [ -d /opt/vc/include ] && add_include_dirs /opt/vc/include [ -d /opt/vc/include/interface/vcos/pthreads ] && add_include_dirs /opt/vc/include/interface/vcos/pthreads [ -d /opt/vc/include/interface/vmcs_host/linux ] && add_include_dirs /opt/vc/include/interface/vmcs_host/linux - HAVE_GLES='auto' + HAVE_OPENGLES='auto' EXTRA_GL_LIBS="-lEGL -lGLESv2 -lbcm_host -lvcos -lvchiq_arm" fi @@ -255,7 +255,7 @@ else HAVE_D3D9=no fi -if [ "$HAVE_OPENGL" != 'no' ] && [ "$HAVE_GLES" != 'yes' ]; then +if [ "$HAVE_OPENGL" != 'no' ] && [ "$HAVE_OPENGLES" != 'yes' ]; then if [ "$OS" = 'Darwin' ]; then check_header OPENGL "OpenGL/gl.h" check_lib OPENGL "-framework OpenGL" @@ -338,14 +338,14 @@ fi check_pkgconf LIBXML2 libxml-2.0 if [ "$HAVE_EGL" = "yes" ]; then - if [ "$HAVE_GLES" != "no" ]; then + if [ "$HAVE_OPENGLES" != "no" ]; then if [ "$GLES_LIBS" ] || [ "$GLES_CFLAGS" ]; then echo "Notice: Using custom OpenGLES CFLAGS ($GLES_CFLAGS) and LDFLAGS ($GLES_LIBS)." add_define_make GLES_LIBS "$GLES_LIBS" add_define_make GLES_CFLAGS "$GLES_CFLAGS" else - HAVE_GLES=auto check_pkgconf GLES glesv2 - [ "$HAVE_GLES" = "no" ] && HAVE_GLES=auto check_lib GLES "-lGLESv2 $EXTRA_GL_LIBS" && add_define_make GLES_LIBS "-lGLESv2 $EXTRA_GL_LIBS" + HAVE_OPENGLES=auto check_pkgconf GLES glesv2 + [ "$HAVE_OPENGLES" = "no" ] && HAVE_OPENGLES=auto check_lib GLES "-lGLESv2 $EXTRA_GL_LIBS" && add_define_make GLES_LIBS "-lGLESv2 $EXTRA_GL_LIBS" fi fi if [ "$HAVE_VG" != "no" ]; then @@ -357,7 +357,7 @@ if [ "$HAVE_EGL" = "yes" ]; then fi else HAVE_VG=no - HAVE_GLES=no + HAVE_OPENGLES=no fi check_pkgconf V4L2 libv4l2 @@ -367,7 +367,7 @@ if [ "$OS" = 'Darwin' ]; then elif [ "$OS" = 'Win32' ]; then HAVE_FBO=yes else - if [ "$HAVE_GLES" = "yes" ]; then + if [ "$HAVE_OPENGLES" = "yes" ]; then [ $HAVE_FBO != "no" ] && HAVE_FBO=yes else check_lib FBO -lGL glFramebufferTexture2D @@ -434,7 +434,7 @@ if [ "$HAVE_MATERIALUI" != 'no' ] || [ "$HAVE_XMB" != 'no' ] || [ "$HAVE_ZARCH" HAVE_XMB=no HAVE_ZARCH=no echo "Notice: RGUI not available, MaterialUI, XMB and ZARCH will also be disabled." - elif [ "$HAVE_OPENGL" = 'no' ] && [ "$HAVE_GLES" = 'no' ] && [ "$HAVE_VULKAN" = 'no' ]; then + elif [ "$HAVE_OPENGL" = 'no' ] && [ "$HAVE_OPENGLES" = 'no' ] && [ "$HAVE_VULKAN" = 'no' ]; then HAVE_MATERIALUI=no HAVE_XMB=no HAVE_ZARCH=no diff --git a/qb/config.params.sh b/qb/config.params.sh index b510dec607..4e57866dac 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -17,8 +17,8 @@ HAVE_LIBRETRO= # Libretro library used HAVE_ASSETS_DIR= # Assets install directory HAVE_BIN_DIR= # Binary install directory HAVE_MAN_DIR= # Manpage install directory -HAVE_GLES_LIBS= # Link flags for custom GLES library -HAVE_GLES_CFLAGS= # C-flags for custom GLES library +HAVE_OPENGLES_LIBS= # Link flags for custom GLES library +HAVE_OPENGLES_CFLAGS= # C-flags for custom GLES library HAVE_THREADS=auto # Threading support HAVE_FFMPEG=auto # FFmpeg recording support C89_FFMPEG=no @@ -30,11 +30,11 @@ C89_NETWORKGAMEPAD=no HAVE_NETPLAY=auto # Netplay support (requires networking) HAVE_D3D9=yes # Direct3D 9 support HAVE_OPENGL=auto # OpenGL support -HAVE_GLES=no # Use GLESv2 instead of desktop GL HAVE_MALI_FBDEV=no # Mali fbdev context support HAVE_VIVANTE_FBDEV=no # Vivante fbdev context support HAVE_OPENDINGUX_FBDEV=no # Opendingux fbdev context support -HAVE_GLES3=no # OpenGLES3 support +HAVE_OPENGLES=no # Use GLESv2 instead of desktop GL +HAVE_OPENGLES3=no # OpenGLES3 support HAVE_X11=auto # everything X11. HAVE_OMAP=no # OMAP video support HAVE_XINERAMA=auto # Xinerama support. From 7c0ba42c09e7e36e01f677fbfdbe116a676330b0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 00:44:29 +0200 Subject: [PATCH 193/334] driver.c - Cleanups --- driver.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/driver.c b/driver.c index a2b0e2648d..7bf7f0e094 100644 --- a/driver.c +++ b/driver.c @@ -167,15 +167,16 @@ static bool driver_find_first(const char *label, char *s, size_t len) static bool driver_find_prev(const char *label, char *s, size_t len) { int i = driver_find_index(label, s); + if (i > 0) - find_driver_nonempty(label, i - 1, s, len); - else { - RARCH_WARN( - "Couldn't find any previous driver (current one: \"%s\").\n", s); - return false; + find_driver_nonempty(label, i - 1, s, len); + return true; } - return true; + + RARCH_WARN( + "Couldn't find any previous driver (current one: \"%s\").\n", s); + return false; } /** @@ -189,16 +190,17 @@ static bool driver_find_prev(const char *label, char *s, size_t len) bool driver_find_next(const char *label, char *s, size_t len) { int i = driver_find_index(label, s); + if (i >= 0 && !string_is_equal(s, "null")) - find_driver_nonempty(label, i + 1, s, len); - else { - RARCH_WARN("%s (current one: \"%s\").\n", - msg_hash_to_str(MSG_COULD_NOT_FIND_ANY_NEXT_DRIVER), - s); - return false; + find_driver_nonempty(label, i + 1, s, len); + return true; } - return true; + + RARCH_WARN("%s (current one: \"%s\").\n", + msg_hash_to_str(MSG_COULD_NOT_FIND_ANY_NEXT_DRIVER), + s); + return false; } static void driver_adjust_system_rates(void) From 9d7798d52a05accb4cfeae12478e57cd32227a4a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 01:40:11 +0200 Subject: [PATCH 194/334] (configuration.c) Cleanup --- configuration.c | 73 ++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/configuration.c b/configuration.c index d120cc0935..ce4bd3954a 100644 --- a/configuration.c +++ b/configuration.c @@ -407,38 +407,6 @@ const char *config_get_default_joypad(void) return "null"; } -#ifdef HAVE_MENU -/** - * config_get_default_menu: - * - * Gets default menu driver. - * - * Returns: Default menu driver. - **/ -const char *config_get_default_menu(void) -{ - if (!string_is_empty(g_defaults.settings.menu)) - return g_defaults.settings.menu; - - switch (MENU_DEFAULT_DRIVER) - { - case MENU_RGUI: - return "rgui"; - case MENU_XUI: - return "xui"; - case MENU_MATERIALUI: - return "glui"; - case MENU_XMB: - return "xmb"; - case MENU_NUKLEAR: - return "nuklear"; - default: - break; - } - - return "null"; -} -#endif /** * config_get_default_camera: @@ -488,14 +456,38 @@ const char *config_get_default_location(void) return "null"; } -bool config_overlay_enable_default(void) +#ifdef HAVE_MENU +/** + * config_get_default_menu: + * + * Gets default menu driver. + * + * Returns: Default menu driver. + **/ +const char *config_get_default_menu(void) { - if (g_defaults.overlay.set) - return g_defaults.overlay.enable; - return true; + if (!string_is_empty(g_defaults.settings.menu)) + return g_defaults.settings.menu; + + switch (MENU_DEFAULT_DRIVER) + { + case MENU_RGUI: + return "rgui"; + case MENU_XUI: + return "xui"; + case MENU_MATERIALUI: + return "glui"; + case MENU_XMB: + return "xmb"; + case MENU_NUKLEAR: + return "nuklear"; + default: + break; + } + + return "null"; } -#ifdef HAVE_MENU static unsigned config_menu_btn_ok_default(void) { if (g_defaults.menu.controls.set) @@ -511,6 +503,13 @@ static unsigned config_menu_btn_cancel_default(void) } #endif +bool config_overlay_enable_default(void) +{ + if (g_defaults.overlay.set) + return g_defaults.overlay.enable; + return true; +} + static int populate_settings_array(settings_t *settings, struct config_array_setting **out) { unsigned count = 0; From dbbdc56df919a97ee3651045e88e3424de556dac Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 01:42:52 +0200 Subject: [PATCH 195/334] Fix libretro-db Makefile --- libretro-db/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libretro-db/Makefile b/libretro-db/Makefile index d544966154..52db777aeb 100644 --- a/libretro-db/Makefile +++ b/libretro-db/Makefile @@ -23,7 +23,7 @@ C_CONVERTER_C = \ $(LIBRETRODB_DIR)/c_converter.c \ $(LIBRETRO_COMM_DIR)/hash/rhash.c \ $(LIBRETRO_COMM_DIR)/compat/compat_fnmatch.c \ - $(LIBRETRO_COMM_DIR)/string/stdstring.c + $(LIBRETRO_COMM_DIR)/string/stdstring.c \ $(LIBRETRO_COMMON_C) \ $(LIBRETRO_COMM_DIR)/compat/compat_strl.c @@ -37,7 +37,7 @@ RARCHDB_TOOL_C = \ $(LIBRETRODB_DIR)/query.c \ $(LIBRETRODB_DIR)/libretrodb.c \ $(LIBRETRO_COMM_DIR)/compat/compat_fnmatch.c \ - $(LIBRETRO_COMM_DIR)/string/stdstring.c + $(LIBRETRO_COMM_DIR)/string/stdstring.c \ $(LIBRETRO_COMMON_C) \ $(LIBRETRO_COMM_DIR)/compat/compat_strl.c From 7b26c43adc9d3e851a52b16f1aa86149c2b88b1d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 01:45:24 +0200 Subject: [PATCH 196/334] dynamic.c - cleanup --- dynamic.c | 159 +++++++++++++++++++++++++++--------------------------- 1 file changed, 78 insertions(+), 81 deletions(-) diff --git a/dynamic.c b/dynamic.c index f7c22ded28..6f31667c73 100644 --- a/dynamic.c +++ b/dynamic.c @@ -168,6 +168,84 @@ static bool environ_cb_get_system_info(unsigned cmd, void *data) } #ifdef HAVE_DYNAMIC +/** + * libretro_get_environment_info: + * @func : Function pointer for get_environment_info. + * @load_no_content : If true, core should be able to auto-start + * without any content loaded. + * + * Sets environment callback in order to get statically known + * information from it. + * + * Fetched via environment callbacks instead of + * retro_get_system_info(), as this info is part of extensions. + * + * Should only be called once right after core load to + * avoid overwriting the "real" environ callback. + * + * For statically linked cores, pass retro_set_environment as argument. + */ +void libretro_get_environment_info(void (*func)(retro_environment_t), + bool *load_no_content) +{ + load_no_content_hook = load_no_content; + + /* load_no_content gets set in this callback. */ + func(environ_cb_get_system_info); + + /* It's possible that we just set get_system_info callback + * to the currently running core. + * + * Make sure we reset it to the actual environment callback. + * Ignore any environment callbacks here in case we're running + * on the non-current core. */ + ignore_environment_cb = true; + func(rarch_environment_cb); + ignore_environment_cb = false; +} + +static void load_dynamic_core(void) +{ + function_t sym = dylib_proc(NULL, "retro_init"); + + if (sym) + { + /* Try to verify that -lretro was not linked in from other modules + * since loading it dynamically and with -l will fail hard. */ + RARCH_ERR("Serious problem. RetroArch wants to load libretro cores" + "dyamically, but it is already linked.\n"); + RARCH_ERR("This could happen if other modules RetroArch depends on " + "link against libretro directly.\n"); + RARCH_ERR("Proceeding could cause a crash. Aborting ...\n"); + retroarch_fail(1, "init_libretro_sym()"); + } + + if (string_is_empty(config_get_active_core_path())) + { + RARCH_ERR("RetroArch is built for dynamic libretro cores, but " + "libretro_path is not set. Cannot continue.\n"); + retroarch_fail(1, "init_libretro_sym()"); + } + + /* Need to use absolute path for this setting. It can be + * saved to content history, and a relative path would + * break in that scenario. */ + path_resolve_realpath( + config_get_active_core_path_ptr(), + config_get_active_core_path_size()); + + RARCH_LOG("Loading dynamic libretro core from: \"%s\"\n", + config_get_active_core_path()); + lib_handle = dylib_load(config_get_active_core_path()); + if (!lib_handle) + { + RARCH_ERR("Failed to open libretro core: \"%s\"\n", + config_get_active_core_path()); + RARCH_ERR("Error(s): %s\n", dylib_error()); + retroarch_fail(1, "load_dynamic()"); + } +} + static dylib_t libretro_get_system_info_lib(const char *path, struct retro_system_info *info, bool *load_no_content) { @@ -279,87 +357,6 @@ bool libretro_get_system_info(const char *path, return true; } -#ifdef HAVE_DYNAMIC -/** - * libretro_get_environment_info: - * @func : Function pointer for get_environment_info. - * @load_no_content : If true, core should be able to auto-start - * without any content loaded. - * - * Sets environment callback in order to get statically known - * information from it. - * - * Fetched via environment callbacks instead of - * retro_get_system_info(), as this info is part of extensions. - * - * Should only be called once right after core load to - * avoid overwriting the "real" environ callback. - * - * For statically linked cores, pass retro_set_environment as argument. - */ -void libretro_get_environment_info(void (*func)(retro_environment_t), - bool *load_no_content) -{ - load_no_content_hook = load_no_content; - - /* load_no_content gets set in this callback. */ - func(environ_cb_get_system_info); - - /* It's possible that we just set get_system_info callback - * to the currently running core. - * - * Make sure we reset it to the actual environment callback. - * Ignore any environment callbacks here in case we're running - * on the non-current core. */ - ignore_environment_cb = true; - func(rarch_environment_cb); - ignore_environment_cb = false; -} - - - -static void load_dynamic_core(void) -{ - function_t sym = dylib_proc(NULL, "retro_init"); - - if (sym) - { - /* Try to verify that -lretro was not linked in from other modules - * since loading it dynamically and with -l will fail hard. */ - RARCH_ERR("Serious problem. RetroArch wants to load libretro cores" - "dyamically, but it is already linked.\n"); - RARCH_ERR("This could happen if other modules RetroArch depends on " - "link against libretro directly.\n"); - RARCH_ERR("Proceeding could cause a crash. Aborting ...\n"); - retroarch_fail(1, "init_libretro_sym()"); - } - - if (string_is_empty(config_get_active_core_path())) - { - RARCH_ERR("RetroArch is built for dynamic libretro cores, but " - "libretro_path is not set. Cannot continue.\n"); - retroarch_fail(1, "init_libretro_sym()"); - } - - /* Need to use absolute path for this setting. It can be - * saved to content history, and a relative path would - * break in that scenario. */ - path_resolve_realpath( - config_get_active_core_path_ptr(), - config_get_active_core_path_size()); - - RARCH_LOG("Loading dynamic libretro core from: \"%s\"\n", - config_get_active_core_path()); - lib_handle = dylib_load(config_get_active_core_path()); - if (!lib_handle) - { - RARCH_ERR("Failed to open libretro core: \"%s\"\n", - config_get_active_core_path()); - RARCH_ERR("Error(s): %s\n", dylib_error()); - retroarch_fail(1, "load_dynamic()"); - } -} -#endif /** * load_symbols: From 1cf7d758b593c32dcc3052893171c10b70c81d46 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 01:54:33 +0200 Subject: [PATCH 197/334] Move code to movie.c --- movie.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ movie.h | 2 ++ runloop.c | 93 +----------------------------------------------------- 3 files changed, 97 insertions(+), 92 deletions(-) diff --git a/movie.c b/movie.c index d7f0366660..7a5d2b97db 100644 --- a/movie.c +++ b/movie.c @@ -31,6 +31,9 @@ #include "msg_hash.h" #include "verbosity.h" +#include "command.h" +#include "file_path_special.h" + struct bsv_movie { FILE *file; @@ -458,3 +461,94 @@ bool bsv_movie_init_handle(const char *path, return false; return true; } + +/* Checks if movie is being played back. */ +static bool runloop_check_movie_playback(void) +{ + if (!bsv_movie_ctl(BSV_MOVIE_CTL_END, NULL)) + return false; + + runloop_msg_queue_push( + msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED), 2, 180, false); + RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED)); + + command_event(CMD_EVENT_BSV_MOVIE_DEINIT, NULL); + + bsv_movie_ctl(BSV_MOVIE_CTL_UNSET_END, NULL); + bsv_movie_ctl(BSV_MOVIE_CTL_UNSET_PLAYBACK, NULL); + + return true; +} + +/* Checks if movie is being recorded. */ +static bool runloop_check_movie_record(void) +{ + if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) + return false; + + runloop_msg_queue_push( + msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED), 2, 180, true); + RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED)); + + command_event(CMD_EVENT_BSV_MOVIE_DEINIT, NULL); + + return true; +} + +static bool runloop_check_movie_init(void) +{ + char msg[128] = {0}; + char path[PATH_MAX_LENGTH] = {0}; + settings_t *settings = config_get_ptr(); + + if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) + return false; + + settings->rewind_granularity = 1; + + if (settings->state_slot > 0) + snprintf(path, sizeof(path), "%s%d", + bsv_movie_get_path(), settings->state_slot); + else + strlcpy(path, bsv_movie_get_path(), sizeof(path)); + + strlcat(path, + file_path_str(FILE_PATH_BSV_EXTENSION), + sizeof(path)); + + snprintf(msg, sizeof(msg), "%s \"%s\".", + msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO), + path); + + bsv_movie_init_handle(path, RARCH_MOVIE_RECORD); + + if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) + return false; + + if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) + { + runloop_msg_queue_push(msg, 2, 180, true); + RARCH_LOG("%s \"%s\".\n", + msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO), + path); + } + else + { + runloop_msg_queue_push( + msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD), + 2, 180, true); + RARCH_ERR("%s\n", + msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD)); + } + + return true; +} + +bool bsv_movie_check(void) +{ + if (bsv_movie_ctl(BSV_MOVIE_CTL_PLAYBACK_ON, NULL)) + return runloop_check_movie_playback(); + if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) + return runloop_check_movie_init(); + return runloop_check_movie_record(); +} diff --git a/movie.h b/movie.h index 91a40c218c..533b0889ae 100644 --- a/movie.h +++ b/movie.h @@ -77,6 +77,8 @@ void bsv_movie_set_start_path(const char *path); bool bsv_movie_ctl(enum bsv_ctl_state state, void *data); +bool bsv_movie_check(void); + bool bsv_movie_init_handle(const char *path, enum rarch_movie_type type); RETRO_END_DECLS diff --git a/runloop.c b/runloop.c index 8fb884ac72..7f213d5c94 100644 --- a/runloop.c +++ b/runloop.c @@ -207,97 +207,6 @@ char* runloop_msg_queue_pull(void) return strdup(msg_info.msg); } -/* Checks if movie is being played back. */ -static bool runloop_check_movie_playback(void) -{ - if (!bsv_movie_ctl(BSV_MOVIE_CTL_END, NULL)) - return false; - - runloop_msg_queue_push( - msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED), 2, 180, false); - RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED)); - - command_event(CMD_EVENT_BSV_MOVIE_DEINIT, NULL); - - bsv_movie_ctl(BSV_MOVIE_CTL_UNSET_END, NULL); - bsv_movie_ctl(BSV_MOVIE_CTL_UNSET_PLAYBACK, NULL); - - return true; -} - -/* Checks if movie is being recorded. */ -static bool runloop_check_movie_record(void) -{ - if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) - return false; - - runloop_msg_queue_push( - msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED), 2, 180, true); - RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED)); - - command_event(CMD_EVENT_BSV_MOVIE_DEINIT, NULL); - - return true; -} - -static bool runloop_check_movie_init(void) -{ - char msg[128] = {0}; - char path[PATH_MAX_LENGTH] = {0}; - settings_t *settings = config_get_ptr(); - - if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) - return false; - - settings->rewind_granularity = 1; - - if (settings->state_slot > 0) - snprintf(path, sizeof(path), "%s%d", - bsv_movie_get_path(), settings->state_slot); - else - strlcpy(path, bsv_movie_get_path(), sizeof(path)); - - strlcat(path, - file_path_str(FILE_PATH_BSV_EXTENSION), - sizeof(path)); - - snprintf(msg, sizeof(msg), "%s \"%s\".", - msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO), - path); - - bsv_movie_init_handle(path, RARCH_MOVIE_RECORD); - - if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) - return false; - - if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) - { - runloop_msg_queue_push(msg, 2, 180, true); - RARCH_LOG("%s \"%s\".\n", - msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO), - path); - } - else - { - runloop_msg_queue_push( - msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD), - 2, 180, true); - RARCH_ERR("%s\n", - msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD)); - } - - return true; -} - -static bool runloop_check_movie(void) -{ - if (bsv_movie_ctl(BSV_MOVIE_CTL_PLAYBACK_ON, NULL)) - return runloop_check_movie_playback(); - if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) - return runloop_check_movie_init(); - return runloop_check_movie_record(); -} - /* Checks if slowmotion toggle/hold was being pressed and/or held. */ static bool runloop_check_slowmotion(bool *ptr) { @@ -727,7 +636,7 @@ static bool runloop_check_state(event_cmd_state_t *cmd, runloop_check_slowmotion(&tmp); if (runloop_cmd_triggered(cmd, RARCH_MOVIE_RECORD_TOGGLE)) - runloop_check_movie(); + bsv_movie_check(); if (runloop_cmd_triggered(cmd, RARCH_SHADER_NEXT) || runloop_cmd_triggered(cmd, RARCH_SHADER_PREV)) From 0515e9f75348fd445b2baae225329cc48487e83c Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 17 Sep 2016 02:00:55 -0500 Subject: [PATCH 198/334] (ems) remove some unused code --- pkg/emscripten/libretro/libretro.js | 35 ++--------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/pkg/emscripten/libretro/libretro.js b/pkg/emscripten/libretro/libretro.js index 72091f9d23..5954a21474 100644 --- a/pkg/emscripten/libretro/libretro.js +++ b/pkg/emscripten/libretro/libretro.js @@ -3,10 +3,9 @@ * * This provides the basic JavaScript for the RetroArch web player. */ -var dropbox = false; var client = new Dropbox.Client({ key: "il6e10mfd7pgf8r" }); -var XFS; var BrowserFS = browserfs; +var afs; var showError = function(error) { switch (error.status) { @@ -73,12 +72,9 @@ function dropboxSyncComplete() console.log("WEBPLAYER: Sync successful"); setupFileSystem("dropbox"); - setupFolderStructure(); preLoadingComplete(); } -var afs; - function dropboxSync(dropboxClient, cb) { var dbfs = new BrowserFS.FileSystem.Dropbox(dropboxClient); @@ -121,18 +117,10 @@ function setupFileSystem(backend) if(backend == "browser") { console.log("WEBPLAYER: Initializing LocalStorage"); - /* create a local filesystem */ - var lsfs = new BrowserFS.FileSystem.LocalStorage(); - + var lsfs = new BrowserFS.FileSystem.LocalStorage() /* mount the filesystems onto mfs */ mfs.mount('/home/web_user/retroarch/userdata', lsfs); - - /* create a memory filesystem for content only - var imfs = new BrowserFS.FileSystem.InMemory();*/ - - /* mount the filesystems onto mfs - mfs.mount('/home/web_user/retroarch/userdata/content/', imfs);*/ } else { @@ -158,24 +146,6 @@ function getParam(name) { } } -function setupFolderStructure() -{ - FS.createPath('/', '/home/web_user', true, true); -} - -function stat(path) -{ - try{ - FS.stat(path); - } - catch(err) - { - console.log("WEBPLAYER: file " + path + " doesn't exist"); - return false; - } - return true; -} - function startRetroArch() { $('.webplayer').show(); @@ -353,7 +323,6 @@ $(function() { $('#lblLocal').addClass('active'); preLoadingComplete(); setupFileSystem("browser"); - setupFolderStructure(); } }); }); From 10222178b0156c425fadc6f45205192d125a8437 Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 17 Sep 2016 02:01:59 -0500 Subject: [PATCH 199/334] (ems) we don't need rjpg --- Makefile.emscripten | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.emscripten b/Makefile.emscripten index d3efe609cd..d095c78631 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -10,7 +10,7 @@ DEFINES += -DHAVE_OPENGL -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DHAVE_EGL -DHAVE_OVER HAVE_EGL = 1 HAVE_OPENGLES = 1 -HAVE_RJPEG = 1 +HAVE_RJPEG = 0 HAVE_RPNG = 1 HAVE_EMSCRIPTEN = 1 HAVE_RGUI = 1 From 6f195ddc6d25dab10bf50319928ffd41e563e5c2 Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 17 Sep 2016 02:05:49 -0500 Subject: [PATCH 200/334] (ems) template cleanup --- pkg/emscripten/embed/embed.js | 25 +------------------------ pkg/emscripten/itch/itch.js | 25 +------------------------ pkg/emscripten/libretro/libretro.js | 6 ++++++ 3 files changed, 8 insertions(+), 48 deletions(-) diff --git a/pkg/emscripten/embed/embed.js b/pkg/emscripten/embed/embed.js index 4745878a53..50c285730d 100644 --- a/pkg/emscripten/embed/embed.js +++ b/pkg/emscripten/embed/embed.js @@ -3,10 +3,9 @@ * * This provides the basic JavaScript for the RetroArch web player. */ -var dropbox = false; var client = new Dropbox.Client({ key: "--your-api-key--" }); -var XFS; var BrowserFS = browserfs; +var afs; var showError = function(error) { switch (error.status) { @@ -73,12 +72,9 @@ function dropboxSyncComplete() console.log("WEBPLAYER: Sync successful"); setupFileSystem("dropbox"); - setupFolderStructure(); preLoadingComplete(); } -var afs; - function dropboxSync(dropboxClient, cb) { var dbfs = new BrowserFS.FileSystem.Dropbox(dropboxClient); @@ -162,24 +158,6 @@ function getParam(name) { } } -function setupFolderStructure() -{ - FS.createPath('/', '/home/web_user', true, true); -} - -function stat(path) -{ - try{ - FS.stat(path); - } - catch(err) - { - console.log("WEBPLAYER: file " + path + " doesn't exist"); - return false; - } - return true; -} - function startRetroArch() { $('.webplayer').show(); @@ -357,7 +335,6 @@ $(function() { $('#lblLocal').addClass('active'); preLoadingComplete(); setupFileSystem("browser"); - setupFolderStructure(); } }); }); diff --git a/pkg/emscripten/itch/itch.js b/pkg/emscripten/itch/itch.js index 0bed2ac93b..7a1a985d16 100644 --- a/pkg/emscripten/itch/itch.js +++ b/pkg/emscripten/itch/itch.js @@ -3,9 +3,9 @@ * * This provides the basic JavaScript for the RetroArch web player. */ -var dropbox = false; var client = new Dropbox.Client({ key: "il6e10mfd7pgf8r" }); var BrowserFS = browserfs; +var afs; var showError = function(error) { switch (error.status) { @@ -78,12 +78,9 @@ function dropboxSyncComplete() console.log("WEBPLAYER: Sync successful"); setupFileSystem("dropbox"); - setupFolderStructure(); preLoadingComplete(); } -var afs; - function dropboxSync(dropboxClient, cb) { var dbfs = new BrowserFS.FileSystem.Dropbox(dropboxClient); @@ -108,7 +105,6 @@ function preLoadingComplete() }); } - function setupFileSystem(backend) { /* create a mountable filesystem that will server as a root @@ -163,24 +159,6 @@ function getParam(name) { } } -function setupFolderStructure() -{ - FS.createPath('/', '/home/web_user', true, true); -} - -function stat(path) -{ - try{ - FS.stat(path); - } - catch(err) - { - console.log("WEBPLAYER: file " + path + " doesn't exist"); - return false; - } - return true; -} - function startRetroArch() { $('.webplayer').show(); @@ -363,7 +341,6 @@ $(function() { //$('#icnDrop').removeClass('fa-dropbox'); preLoadingComplete(); setupFileSystem("browser"); - setupFolderStructure(); } }); }); diff --git a/pkg/emscripten/libretro/libretro.js b/pkg/emscripten/libretro/libretro.js index 5954a21474..76205bb2f8 100644 --- a/pkg/emscripten/libretro/libretro.js +++ b/pkg/emscripten/libretro/libretro.js @@ -121,6 +121,12 @@ function setupFileSystem(backend) var lsfs = new BrowserFS.FileSystem.LocalStorage() /* mount the filesystems onto mfs */ mfs.mount('/home/web_user/retroarch/userdata', lsfs); + + /* create a memory filesystem for content only + var imfs = new BrowserFS.FileSystem.InMemory();*/ + + /* mount the filesystems onto mfs + mfs.mount('/home/web_user/retroarch/userdata/content/', imfs);*/ } else { From 042eadd39e954a4f25f41065819a17f8cf65ca7b Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 17 Sep 2016 03:12:22 -0500 Subject: [PATCH 201/334] (ems) we don't need rjpg in emscripten --- Makefile.emscripten | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.emscripten b/Makefile.emscripten index d095c78631..e3bc40f6eb 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -83,7 +83,7 @@ else CFLAGS += -O2 endif -CFLAGS += -DHAVE_RPNG -DHAVE_RJPEG -Wall -Wno-unused-result -Wno-unused-variable -I. -Ilibretro-common/include -std=gnu99 -s USE_ZLIB=1 \ +CFLAGS += -DHAVE_RPNG -Wall -Wno-unused-result -Wno-unused-variable -I. -Ilibretro-common/include -std=gnu99 -s USE_ZLIB=1 \ -s EXPORTED_FUNCTIONS="['_main', '_malloc', '_cmd_savefiles', '_cmd_save_state', '_cmd_take_screenshot']" all: $(TARGET) From 96d4347c4a7292d487c8bdfcef43cd5641b05195 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 12:05:00 +0200 Subject: [PATCH 202/334] Go back to only calling core_poll() if menu is alive or RetroArch is paused --- runloop.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/runloop.c b/runloop.c index 7f213d5c94..78ac4b27a8 100644 --- a/runloop.c +++ b/runloop.c @@ -1459,12 +1459,13 @@ int runloop_iterate(unsigned *sleep_ms) return -1; } - core_poll(); - #ifdef HAVE_MENU if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)) { - int ret = runloop_iterate_menu((enum menu_action) + int ret; + + core_poll(); + ret = runloop_iterate_menu((enum menu_action) menu_event(cmd.state[0], cmd.state[2]), sleep_ms); @@ -1483,6 +1484,7 @@ int runloop_iterate(unsigned *sleep_ms) if (!runloop_check_state(&cmd, &runloop_shader_dir)) { /* RetroArch has been paused. */ + core_poll(); #ifdef HAVE_NETPLAY /* FIXME: This is an ugly way to tell Netplay this... */ netplay_driver_ctl(RARCH_NETPLAY_CTL_PAUSE, NULL); From 005b86eb5ddf2e55421252351eb329fa30be826b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 12:10:46 +0200 Subject: [PATCH 203/334] Create paths.c --- Makefile.common | 1 + griffin/griffin.c | 1 + paths.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++ paths.h | 28 ++++++++++++++++++++++ retroarch.c | 41 +++---------------------------- 5 files changed, 94 insertions(+), 38 deletions(-) create mode 100644 paths.c create mode 100644 paths.h diff --git a/Makefile.common b/Makefile.common index c005e803d1..52aad9b2cf 100644 --- a/Makefile.common +++ b/Makefile.common @@ -132,6 +132,7 @@ OBJ += frontend/frontend.o \ ui/drivers/null/ui_null_application.o \ core_impl.o \ retroarch.o \ + paths.o \ input/input_keyboard.o \ command.o \ msg_hash.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index 1497bcee4f..939740d40c 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -797,6 +797,7 @@ RETROARCH ============================================================ */ #include "../core_impl.c" #include "../retroarch.c" +#include "../paths.c" #include "../runloop.c" #include "../libretro-common/queues/task_queue.c" diff --git a/paths.c b/paths.c new file mode 100644 index 0000000000..17023cfb2d --- /dev/null +++ b/paths.c @@ -0,0 +1,61 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2011-2016 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include +#include + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "paths.h" + +#include "runloop.h" + +void path_set_basename(const char *path) +{ + char *dst = NULL; + global_t *global = global_get_ptr(); + + runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)path); + strlcpy(global->name.base, path, sizeof(global->name.base)); + +#ifdef HAVE_COMPRESSION + /* Removing extension is a bit tricky for compressed files. + * Basename means: + * /file/to/path/game.extension should be: + * /file/to/path/game + * + * Two things to consider here are: /file/to/path/ is expected + * to be a directory and "game" is a single file. This is used for + * states and srm default paths. + * + * For compressed files we have: + * + * /file/to/path/comp.7z#game.extension and + * /file/to/path/comp.7z#folder/game.extension + * + * The choice I take here is: + * /file/to/path/game as basename. We might end up in a writable + * directory then and the name of srm and states are meaningful. + * + */ + path_basedir(global->name.base); + fill_pathname_dir(global->name.base, path, "", sizeof(global->name.base)); +#endif + + if ((dst = strrchr(global->name.base, '.'))) + *dst = '\0'; +} diff --git a/paths.h b/paths.h new file mode 100644 index 0000000000..414f03cb8d --- /dev/null +++ b/paths.h @@ -0,0 +1,28 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2011-2016 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#ifndef __PATHS_H +#define __PATHS_H + +#include +#include + +RETRO_BEGIN_DECLS + +void path_set_basename(const char *path); + +RETRO_END_DECLS + +#endif diff --git a/retroarch.c b/retroarch.c index ca5559f93e..03a1668ab7 100644 --- a/retroarch.c +++ b/retroarch.c @@ -64,6 +64,7 @@ #include "driver.h" #include "msg_hash.h" #include "movie.h" +#include "paths.h" #include "file_path_special.h" #include "verbosity.h" @@ -338,42 +339,6 @@ static void retroarch_print_help(const char *arg0) "then exits.\n"); } -static void retroarch_set_basename(const char *path) -{ - char *dst = NULL; - global_t *global = global_get_ptr(); - - runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)path); - strlcpy(global->name.base, path, sizeof(global->name.base)); - -#ifdef HAVE_COMPRESSION - /* Removing extension is a bit tricky for compressed files. - * Basename means: - * /file/to/path/game.extension should be: - * /file/to/path/game - * - * Two things to consider here are: /file/to/path/ is expected - * to be a directory and "game" is a single file. This is used for - * states and srm default paths. - * - * For compressed files we have: - * - * /file/to/path/comp.7z#game.extension and - * /file/to/path/comp.7z#folder/game.extension - * - * The choice I take here is: - * /file/to/path/game as basename. We might end up in a writable - * directory then and the name of srm and states are meaningful. - * - */ - path_basedir(global->name.base); - fill_pathname_dir(global->name.base, path, "", sizeof(global->name.base)); -#endif - - if ((dst = strrchr(global->name.base, '.'))) - *dst = '\0'; -} - static void retroarch_set_special_paths(char **argv, unsigned num_content) { unsigned i; @@ -381,7 +346,7 @@ static void retroarch_set_special_paths(char **argv, unsigned num_content) global_t *global = global_get_ptr(); /* First content file is the significant one. */ - retroarch_set_basename(argv[0]); + path_set_basename(argv[0]); global->subsystem_fullpaths = string_list_new(); retro_assert(global->subsystem_fullpaths); @@ -1603,7 +1568,7 @@ void retroarch_set_pathnames(const char *path) { global_t *global = global_get_ptr(); - retroarch_set_basename(path); + path_set_basename(path); if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH)) fill_pathname_noext(global->name.savefile, global->name.base, From 069dbce5c57d2f17ff3aae66edbf2fc0e6429ee1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 12:16:11 +0200 Subject: [PATCH 204/334] Add more functions to paths.c --- paths.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++++++++ paths.h | 4 ++ retroarch.c | 161 +------------------------------------------------- 3 files changed, 173 insertions(+), 159 deletions(-) diff --git a/paths.c b/paths.c index 17023cfb2d..4ae36c20c1 100644 --- a/paths.c +++ b/paths.c @@ -15,6 +15,8 @@ #include #include +#include +#include #ifdef HAVE_CONFIG_H #include "config.h" @@ -22,7 +24,160 @@ #include "paths.h" +#include "configuration.h" +#include "content.h" +#include "file_path_special.h" + +#include "core.h" +#include "msg_hash.h" #include "runloop.h" +#include "verbosity.h" + +#define MENU_VALUE_NO_CORE 0x7d5472cbU + +static char current_savefile_dir[PATH_MAX_LENGTH] = {0}; + +void path_set_redirect(void) +{ + char current_savestate_dir[PATH_MAX_LENGTH] = {0}; + uint32_t global_library_name_hash = 0; + bool check_global_library_name_hash = false; + global_t *global = global_get_ptr(); + settings_t *settings = config_get_ptr(); + rarch_system_info_t *info = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + + if (!global) + return; + + if (info->info.library_name && + !string_is_empty(info->info.library_name)) + global_library_name_hash = + msg_hash_calculate(info->info.library_name); + + /* Initialize current save directories + * with the values from the config. */ + strlcpy(current_savefile_dir, + global->dir.savefile, + sizeof(current_savefile_dir)); + strlcpy(current_savestate_dir, + global->dir.savestate, + sizeof(current_savestate_dir)); + + check_global_library_name_hash = (global_library_name_hash != 0); +#ifdef HAVE_MENU + check_global_library_name_hash = check_global_library_name_hash && + (global_library_name_hash != MENU_VALUE_NO_CORE); +#endif + + if (check_global_library_name_hash) + { + /* per-core saves: append the library_name to the save location */ + if (settings->sort_savefiles_enable + && !string_is_empty(global->dir.savefile)) + { + fill_pathname_join( + current_savefile_dir, + global->dir.savefile, + info->info.library_name, + sizeof(global->dir.savefile)); + + /* If path doesn't exist, try to create it, + * if everything fails revert to the original path. */ + if(!path_is_directory(current_savefile_dir) + && !string_is_empty(current_savefile_dir)) + { + path_mkdir(current_savefile_dir); + if(!path_is_directory(current_savefile_dir)) + { + RARCH_LOG("%s %s\n", + msg_hash_to_str(MSG_REVERTING_SAVEFILE_DIRECTORY_TO), + global->dir.savefile); + + strlcpy(current_savefile_dir, + global->dir.savefile, + sizeof(current_savefile_dir)); + } + } + } + + /* per-core states: append the library_name to the save location */ + if (settings->sort_savestates_enable + && !string_is_empty(global->dir.savestate)) + { + fill_pathname_join( + current_savestate_dir, + global->dir.savestate, + info->info.library_name, + sizeof(global->dir.savestate)); + + /* If path doesn't exist, try to create it. + * If everything fails, revert to the original path. */ + if(!path_is_directory(current_savestate_dir) && + !string_is_empty(current_savestate_dir)) + { + path_mkdir(current_savestate_dir); + if(!path_is_directory(current_savestate_dir)) + { + RARCH_LOG("%s %s\n", + msg_hash_to_str(MSG_REVERTING_SAVESTATE_DIRECTORY_TO), + global->dir.savestate); + strlcpy(current_savestate_dir, + global->dir.savestate, + sizeof(current_savestate_dir)); + } + } + } + } + + /* Set savefile directory if empty based on content directory */ + if (string_is_empty(current_savefile_dir)) + { + global_t *global = global_get_ptr(); + strlcpy(current_savefile_dir, global->name.base, + sizeof(current_savefile_dir)); + path_basedir(current_savefile_dir); + } + + if(path_is_directory(current_savefile_dir)) + strlcpy(global->name.savefile, current_savefile_dir, + sizeof(global->name.savefile)); + + if(path_is_directory(current_savestate_dir)) + strlcpy(global->name.savestate, current_savestate_dir, + sizeof(global->name.savestate)); + + if (path_is_directory(global->name.savefile)) + { + fill_pathname_dir(global->name.savefile, global->name.base, + file_path_str(FILE_PATH_SRM_EXTENSION), + sizeof(global->name.savefile)); + RARCH_LOG("%s \"%s\".\n", + msg_hash_to_str(MSG_REDIRECTING_SAVEFILE_TO), + global->name.savefile); + } + + if (path_is_directory(global->name.savestate)) + { + fill_pathname_dir(global->name.savestate, global->name.base, + file_path_str(FILE_PATH_STATE_EXTENSION), + sizeof(global->name.savestate)); + RARCH_LOG("%s \"%s\".\n", + msg_hash_to_str(MSG_REDIRECTING_SAVESTATE_TO), + global->name.savestate); + } + + if (path_is_directory(global->name.cheatfile)) + { + fill_pathname_dir(global->name.cheatfile, global->name.base, + file_path_str(FILE_PATH_STATE_EXTENSION), + sizeof(global->name.cheatfile)); + RARCH_LOG("%s \"%s\".\n", + msg_hash_to_str(MSG_REDIRECTING_CHEATFILE_TO), + global->name.cheatfile); + } +} void path_set_basename(const char *path) { @@ -59,3 +214,15 @@ void path_set_basename(const char *path) if ((dst = strrchr(global->name.base, '.'))) *dst = '\0'; } + +const char *path_get_current_savefile_dir(void) +{ + char *ret = current_savefile_dir; + + /* try to infer the path in case it's still empty by calling + path_set_redirect */ + if (string_is_empty(ret) && !content_does_not_need_content()) + path_set_redirect(); + + return ret; +} diff --git a/paths.h b/paths.h index 414f03cb8d..ce8bc5f8d5 100644 --- a/paths.h +++ b/paths.h @@ -21,8 +21,12 @@ RETRO_BEGIN_DECLS +void path_set_redirect(void); + void path_set_basename(const char *path); +const char *path_get_current_savefile_dir(void); + RETRO_END_DECLS #endif diff --git a/retroarch.c b/retroarch.c index 03a1668ab7..d26dcf5dd9 100644 --- a/retroarch.c +++ b/retroarch.c @@ -113,7 +113,6 @@ enum static bool current_core_explicitly_set = false; static enum rarch_core_type current_core_type = CORE_TYPE_PLAIN; static enum rarch_core_type explicit_current_core_type = CORE_TYPE_PLAIN; -static char current_savefile_dir[PATH_MAX_LENGTH] = {0}; static char error_string[PATH_MAX_LENGTH] = {0}; static jmp_buf error_sjlj_context; @@ -375,162 +374,6 @@ static void retroarch_set_special_paths(char **argv, unsigned num_content) } } -#define MENU_VALUE_NO_CORE 0x7d5472cbU - -static void retroarch_set_paths_redirect(void) -{ - char current_savestate_dir[PATH_MAX_LENGTH] = {0}; - uint32_t global_library_name_hash = 0; - bool check_global_library_name_hash = false; - global_t *global = global_get_ptr(); - settings_t *settings = config_get_ptr(); - rarch_system_info_t *info = NULL; - - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); - - if (!global) - return; - - if (info->info.library_name && - !string_is_empty(info->info.library_name)) - global_library_name_hash = - msg_hash_calculate(info->info.library_name); - - /* Initialize current save directories - * with the values from the config. */ - strlcpy(current_savefile_dir, - global->dir.savefile, - sizeof(current_savefile_dir)); - strlcpy(current_savestate_dir, - global->dir.savestate, - sizeof(current_savestate_dir)); - - check_global_library_name_hash = (global_library_name_hash != 0); -#ifdef HAVE_MENU - check_global_library_name_hash = check_global_library_name_hash && - (global_library_name_hash != MENU_VALUE_NO_CORE); -#endif - - if (check_global_library_name_hash) - { - /* per-core saves: append the library_name to the save location */ - if (settings->sort_savefiles_enable - && !string_is_empty(global->dir.savefile)) - { - fill_pathname_join( - current_savefile_dir, - global->dir.savefile, - info->info.library_name, - sizeof(global->dir.savefile)); - - /* If path doesn't exist, try to create it, - * if everything fails revert to the original path. */ - if(!path_is_directory(current_savefile_dir) - && !string_is_empty(current_savefile_dir)) - { - path_mkdir(current_savefile_dir); - if(!path_is_directory(current_savefile_dir)) - { - RARCH_LOG("%s %s\n", - msg_hash_to_str(MSG_REVERTING_SAVEFILE_DIRECTORY_TO), - global->dir.savefile); - - strlcpy(current_savefile_dir, - global->dir.savefile, - sizeof(current_savefile_dir)); - } - } - } - - /* per-core states: append the library_name to the save location */ - if (settings->sort_savestates_enable - && !string_is_empty(global->dir.savestate)) - { - fill_pathname_join( - current_savestate_dir, - global->dir.savestate, - info->info.library_name, - sizeof(global->dir.savestate)); - - /* If path doesn't exist, try to create it. - * If everything fails, revert to the original path. */ - if(!path_is_directory(current_savestate_dir) && - !string_is_empty(current_savestate_dir)) - { - path_mkdir(current_savestate_dir); - if(!path_is_directory(current_savestate_dir)) - { - RARCH_LOG("%s %s\n", - msg_hash_to_str(MSG_REVERTING_SAVESTATE_DIRECTORY_TO), - global->dir.savestate); - strlcpy(current_savestate_dir, - global->dir.savestate, - sizeof(current_savestate_dir)); - } - } - } - } - - /* Set savefile directory if empty based on content directory */ - if (string_is_empty(current_savefile_dir)) - { - global_t *global = global_get_ptr(); - strlcpy(current_savefile_dir, global->name.base, - sizeof(current_savefile_dir)); - path_basedir(current_savefile_dir); - } - - if(path_is_directory(current_savefile_dir)) - strlcpy(global->name.savefile, current_savefile_dir, - sizeof(global->name.savefile)); - - if(path_is_directory(current_savestate_dir)) - strlcpy(global->name.savestate, current_savestate_dir, - sizeof(global->name.savestate)); - - if (path_is_directory(global->name.savefile)) - { - fill_pathname_dir(global->name.savefile, global->name.base, - file_path_str(FILE_PATH_SRM_EXTENSION), - sizeof(global->name.savefile)); - RARCH_LOG("%s \"%s\".\n", - msg_hash_to_str(MSG_REDIRECTING_SAVEFILE_TO), - global->name.savefile); - } - - if (path_is_directory(global->name.savestate)) - { - fill_pathname_dir(global->name.savestate, global->name.base, - file_path_str(FILE_PATH_STATE_EXTENSION), - sizeof(global->name.savestate)); - RARCH_LOG("%s \"%s\".\n", - msg_hash_to_str(MSG_REDIRECTING_SAVESTATE_TO), - global->name.savestate); - } - - if (path_is_directory(global->name.cheatfile)) - { - fill_pathname_dir(global->name.cheatfile, global->name.base, - file_path_str(FILE_PATH_STATE_EXTENSION), - sizeof(global->name.cheatfile)); - RARCH_LOG("%s \"%s\".\n", - msg_hash_to_str(MSG_REDIRECTING_CHEATFILE_TO), - global->name.cheatfile); - } -} - -const char *retroarch_get_current_savefile_dir(void) -{ - char *ret = current_savefile_dir; - - /* try to infer the path in case it's still empty by calling - set_paths_redirect */ - if (string_is_empty(ret) && !content_does_not_need_content()) - retroarch_set_paths_redirect(); - - return ret; -} - enum rarch_content_type retroarch_path_is_media_type(const char *path) { char ext_lower[PATH_MAX_LENGTH] = {0}; @@ -1502,7 +1345,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) case RARCH_CTL_SET_PATHS_REDIRECT: if (content_does_not_need_content()) return false; - retroarch_set_paths_redirect(); + path_set_redirect(); break; case RARCH_CTL_SET_SRAM_ENABLE: { @@ -1581,7 +1424,7 @@ void retroarch_set_pathnames(const char *path) fill_pathname_noext(global->name.cheatfile, global->name.base, file_path_str(FILE_PATH_CHT_EXTENSION), sizeof(global->name.cheatfile)); - retroarch_set_paths_redirect(); + path_set_redirect(); } void retroarch_fill_pathnames(void) From 0b0314d4ff409eb6b9619d9b609069eb2693c717 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 12:19:17 +0200 Subject: [PATCH 205/334] Move more functions to paths.c --- dynamic.c | 3 ++- paths.c | 39 +++++++++++++++++++++++++++++++++++++++ paths.h | 2 ++ retroarch.c | 38 +------------------------------------- 4 files changed, 44 insertions(+), 38 deletions(-) diff --git a/dynamic.c b/dynamic.c index 6f31667c73..13f2afd1ab 100644 --- a/dynamic.c +++ b/dynamic.c @@ -51,6 +51,7 @@ #include "cores/internal_cores.h" #include "frontend/frontend_driver.h" #include "content.h" +#include "paths.h" #include "retroarch.h" #include "runloop.h" #include "configuration.h" @@ -1049,7 +1050,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) break; case RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY: - *(const char**)data = retroarch_get_current_savefile_dir(); + *(const char**)data = path_get_current_savefile_dir(); break; case RETRO_ENVIRONMENT_GET_USERNAME: diff --git a/paths.c b/paths.c index 4ae36c20c1..8d6f0893df 100644 --- a/paths.c +++ b/paths.c @@ -15,7 +15,9 @@ #include #include +#include #include +#include #include #ifdef HAVE_CONFIG_H @@ -30,6 +32,7 @@ #include "core.h" #include "msg_hash.h" +#include "retroarch.h" #include "runloop.h" #include "verbosity.h" @@ -226,3 +229,39 @@ const char *path_get_current_savefile_dir(void) return ret; } + +void path_set_special(char **argv, unsigned num_content) +{ + unsigned i; + union string_list_elem_attr attr; + global_t *global = global_get_ptr(); + + /* First content file is the significant one. */ + path_set_basename(argv[0]); + + global->subsystem_fullpaths = string_list_new(); + retro_assert(global->subsystem_fullpaths); + + attr.i = 0; + + for (i = 0; i < num_content; i++) + string_list_append(global->subsystem_fullpaths, argv[i], attr); + + /* We defer SRAM path updates until we can resolve it. + * It is more complicated for special content types. */ + + if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_STATE_PATH)) + fill_pathname_noext(global->name.savestate, global->name.base, + file_path_str(FILE_PATH_STATE_EXTENSION), + sizeof(global->name.savestate)); + + if (path_is_directory(global->name.savestate)) + { + fill_pathname_dir(global->name.savestate, global->name.base, + file_path_str(FILE_PATH_STATE_EXTENSION), + sizeof(global->name.savestate)); + RARCH_LOG("%s \"%s\".\n", + msg_hash_to_str(MSG_REDIRECTING_SAVESTATE_TO), + global->name.savestate); + } +} diff --git a/paths.h b/paths.h index ce8bc5f8d5..cb3449701e 100644 --- a/paths.h +++ b/paths.h @@ -23,6 +23,8 @@ RETRO_BEGIN_DECLS void path_set_redirect(void); +void path_set_special(char **argv, unsigned num_content); + void path_set_basename(const char *path); const char *path_get_current_savefile_dir(void); diff --git a/retroarch.c b/retroarch.c index d26dcf5dd9..1be266cf07 100644 --- a/retroarch.c +++ b/retroarch.c @@ -338,42 +338,6 @@ static void retroarch_print_help(const char *arg0) "then exits.\n"); } -static void retroarch_set_special_paths(char **argv, unsigned num_content) -{ - unsigned i; - union string_list_elem_attr attr; - global_t *global = global_get_ptr(); - - /* First content file is the significant one. */ - path_set_basename(argv[0]); - - global->subsystem_fullpaths = string_list_new(); - retro_assert(global->subsystem_fullpaths); - - attr.i = 0; - - for (i = 0; i < num_content; i++) - string_list_append(global->subsystem_fullpaths, argv[i], attr); - - /* We defer SRAM path updates until we can resolve it. - * It is more complicated for special content types. */ - - if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_STATE_PATH)) - fill_pathname_noext(global->name.savestate, global->name.base, - file_path_str(FILE_PATH_STATE_EXTENSION), - sizeof(global->name.savestate)); - - if (path_is_directory(global->name.savestate)) - { - fill_pathname_dir(global->name.savestate, global->name.base, - file_path_str(FILE_PATH_STATE_EXTENSION), - sizeof(global->name.savestate)); - RARCH_LOG("%s \"%s\".\n", - msg_hash_to_str(MSG_REDIRECTING_SAVESTATE_TO), - global->name.savestate); - } -} - enum rarch_content_type retroarch_path_is_media_type(const char *path) { char ext_lower[PATH_MAX_LENGTH] = {0}; @@ -909,7 +873,7 @@ static void retroarch_parse_input(int argc, char *argv[]) { /* We requested explicit ROM, so use PLAIN core type. */ retroarch_set_current_core_type(CORE_TYPE_PLAIN, false); - retroarch_set_special_paths(argv + optind, argc - optind); + path_set_special(argv + optind, argc - optind); } else content_set_does_not_need_content(); From d8b5e3c1ec509dbfe0657d22d3994e628a1ccf25 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 12:22:51 +0200 Subject: [PATCH 206/334] Move more code to paths.c --- paths.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++ paths.h | 2 ++ retroarch.c | 100 +--------------------------------------------------- 3 files changed, 103 insertions(+), 99 deletions(-) diff --git a/paths.c b/paths.c index 8d6f0893df..37a13a403f 100644 --- a/paths.c +++ b/paths.c @@ -27,7 +27,9 @@ #include "paths.h" #include "configuration.h" +#include "command.h" #include "content.h" +#include "dynamic.h" #include "file_path_special.h" #include "core.h" @@ -265,3 +267,101 @@ void path_set_special(char **argv, unsigned num_content) global->name.savestate); } } + +void path_init_savefile(void) +{ + global_t *global = global_get_ptr(); + rarch_system_info_t *system = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + + command_event(CMD_EVENT_SAVEFILES_DEINIT, NULL); + + global->savefiles = string_list_new(); + retro_assert(global->savefiles); + + if (system && !string_is_empty(global->subsystem)) + { + /* For subsystems, we know exactly which RAM types are supported. */ + + unsigned i, j; + const struct retro_subsystem_info *info = + libretro_find_subsystem_info( + system->subsystem.data, + system->subsystem.size, + global->subsystem); + + /* We'll handle this error gracefully later. */ + unsigned num_content = MIN(info ? info->num_roms : 0, + global->subsystem_fullpaths ? + global->subsystem_fullpaths->size : 0); + + bool use_sram_dir = path_is_directory(global->dir.savefile); + + for (i = 0; i < num_content; i++) + { + for (j = 0; j < info->roms[i].num_memory; j++) + { + union string_list_elem_attr attr; + char path[PATH_MAX_LENGTH] = {0}; + char ext[32] = {0}; + const struct retro_subsystem_memory_info *mem = + (const struct retro_subsystem_memory_info*) + &info->roms[i].memory[j]; + + snprintf(ext, sizeof(ext), ".%s", mem->extension); + + if (use_sram_dir) + { + /* Redirect content fullpath to save directory. */ + strlcpy(path, global->dir.savefile, sizeof(path)); + fill_pathname_dir(path, + global->subsystem_fullpaths->elems[i].data, ext, + sizeof(path)); + } + else + { + fill_pathname(path, global->subsystem_fullpaths->elems[i].data, + ext, sizeof(path)); + } + + attr.i = mem->type; + string_list_append(global->savefiles, path, attr); + } + } + + /* Let other relevant paths be inferred from the main SRAM location. */ + if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH)) + fill_pathname_noext(global->name.savefile, + global->name.base, + file_path_str(FILE_PATH_SRM_EXTENSION), + sizeof(global->name.savefile)); + + if (path_is_directory(global->name.savefile)) + { + fill_pathname_dir(global->name.savefile, + global->name.base, + file_path_str(FILE_PATH_SRM_EXTENSION), + sizeof(global->name.savefile)); + RARCH_LOG("%s \"%s\".\n", + msg_hash_to_str(MSG_REDIRECTING_SAVEFILE_TO), + global->name.savefile); + } + } + else + { + union string_list_elem_attr attr; + char savefile_name_rtc[PATH_MAX_LENGTH] = {0}; + + attr.i = RETRO_MEMORY_SAVE_RAM; + string_list_append(global->savefiles, global->name.savefile, attr); + + /* Infer .rtc save path from save ram path. */ + attr.i = RETRO_MEMORY_RTC; + fill_pathname(savefile_name_rtc, + global->name.savefile, + file_path_str(FILE_PATH_RTC_EXTENSION), + sizeof(savefile_name_rtc)); + string_list_append(global->savefiles, savefile_name_rtc, attr); + } +} diff --git a/paths.h b/paths.h index cb3449701e..39318cec4a 100644 --- a/paths.h +++ b/paths.h @@ -21,6 +21,8 @@ RETRO_BEGIN_DECLS +void path_init_savefile(void); + void path_set_redirect(void); void path_set_special(char **argv, unsigned num_content); diff --git a/retroarch.c b/retroarch.c index 1be266cf07..d4609ff3af 100644 --- a/retroarch.c +++ b/retroarch.c @@ -890,104 +890,6 @@ static void retroarch_parse_input(int argc, char *argv[]) sizeof(global->dir.savestate)); } -static void retroarch_init_savefile_paths(void) -{ - global_t *global = global_get_ptr(); - rarch_system_info_t *system = NULL; - - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); - - command_event(CMD_EVENT_SAVEFILES_DEINIT, NULL); - - global->savefiles = string_list_new(); - retro_assert(global->savefiles); - - if (system && !string_is_empty(global->subsystem)) - { - /* For subsystems, we know exactly which RAM types are supported. */ - - unsigned i, j; - const struct retro_subsystem_info *info = - libretro_find_subsystem_info( - system->subsystem.data, - system->subsystem.size, - global->subsystem); - - /* We'll handle this error gracefully later. */ - unsigned num_content = MIN(info ? info->num_roms : 0, - global->subsystem_fullpaths ? - global->subsystem_fullpaths->size : 0); - - bool use_sram_dir = path_is_directory(global->dir.savefile); - - for (i = 0; i < num_content; i++) - { - for (j = 0; j < info->roms[i].num_memory; j++) - { - union string_list_elem_attr attr; - char path[PATH_MAX_LENGTH] = {0}; - char ext[32] = {0}; - const struct retro_subsystem_memory_info *mem = - (const struct retro_subsystem_memory_info*) - &info->roms[i].memory[j]; - - snprintf(ext, sizeof(ext), ".%s", mem->extension); - - if (use_sram_dir) - { - /* Redirect content fullpath to save directory. */ - strlcpy(path, global->dir.savefile, sizeof(path)); - fill_pathname_dir(path, - global->subsystem_fullpaths->elems[i].data, ext, - sizeof(path)); - } - else - { - fill_pathname(path, global->subsystem_fullpaths->elems[i].data, - ext, sizeof(path)); - } - - attr.i = mem->type; - string_list_append(global->savefiles, path, attr); - } - } - - /* Let other relevant paths be inferred from the main SRAM location. */ - if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH)) - fill_pathname_noext(global->name.savefile, - global->name.base, - file_path_str(FILE_PATH_SRM_EXTENSION), - sizeof(global->name.savefile)); - - if (path_is_directory(global->name.savefile)) - { - fill_pathname_dir(global->name.savefile, - global->name.base, - file_path_str(FILE_PATH_SRM_EXTENSION), - sizeof(global->name.savefile)); - RARCH_LOG("%s \"%s\".\n", - msg_hash_to_str(MSG_REDIRECTING_SAVEFILE_TO), - global->name.savefile); - } - } - else - { - union string_list_elem_attr attr; - char savefile_name_rtc[PATH_MAX_LENGTH] = {0}; - - attr.i = RETRO_MEMORY_SAVE_RAM; - string_list_append(global->savefiles, global->name.savefile, attr); - - /* Infer .rtc save path from save ram path. */ - attr.i = RETRO_MEMORY_RTC; - fill_pathname(savefile_name_rtc, - global->name.savefile, - file_path_str(FILE_PATH_RTC_EXTENSION), - sizeof(savefile_name_rtc)); - string_list_append(global->savefiles, savefile_name_rtc, attr); - } -} - static bool retroarch_init_state(void) { video_driver_set_active(); @@ -1395,7 +1297,7 @@ void retroarch_fill_pathnames(void) { global_t *global = global_get_ptr(); - retroarch_init_savefile_paths(); + path_init_savefile(); bsv_movie_set_path(global->name.savefile); if (string_is_empty(global->name.base)) From 1dd28bdf9ff6115ba946f92d768419b3aa7a87a1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 12:25:26 +0200 Subject: [PATCH 207/334] Move retroarch_set_pathnames/retroarch_fill_pathnames --- command.c | 7 ++++--- paths.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ paths.h | 4 ++++ retroarch.c | 48 +----------------------------------------------- retroarch.h | 4 ---- 5 files changed, 55 insertions(+), 54 deletions(-) diff --git a/command.c b/command.c index 798a0f5f27..01a49c8b60 100644 --- a/command.c +++ b/command.c @@ -74,6 +74,7 @@ #include "dynamic.h" #include "content.h" #include "movie.h" +#include "paths.h" #include "msg_hash.h" #include "retroarch.h" #include "managers/cheat_manager.h" @@ -989,8 +990,8 @@ static bool command_event_disk_control_append_image(const char *path) * If we actually use append_image, we assume that we * started out in a single disk case, and that this way * of doing it makes the most sense. */ - retroarch_set_pathnames(path); - retroarch_fill_pathnames(); + path_set_names(path); + path_fill_names(); } command_event(CMD_EVENT_AUTOSAVE_INIT, NULL); @@ -1327,7 +1328,7 @@ static bool event_init_content(void) return true; if (!content_does_not_need_content()) - retroarch_fill_pathnames(); + path_fill_names(); if (!content_init()) return false; diff --git a/paths.c b/paths.c index 37a13a403f..3e3d68d3b4 100644 --- a/paths.c +++ b/paths.c @@ -365,3 +365,49 @@ void path_init_savefile(void) string_list_append(global->savefiles, savefile_name_rtc, attr); } } + +void path_set_names(const char *path) +{ + global_t *global = global_get_ptr(); + + path_set_basename(path); + + if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH)) + fill_pathname_noext(global->name.savefile, global->name.base, + file_path_str(FILE_PATH_SRM_EXTENSION), sizeof(global->name.savefile)); + + if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_STATE_PATH)) + fill_pathname_noext(global->name.savestate, global->name.base, + file_path_str(FILE_PATH_STATE_EXTENSION), sizeof(global->name.savestate)); + + fill_pathname_noext(global->name.cheatfile, global->name.base, + file_path_str(FILE_PATH_CHT_EXTENSION), sizeof(global->name.cheatfile)); + + path_set_redirect(); +} + +void path_fill_names(void) +{ + global_t *global = global_get_ptr(); + + path_init_savefile(); + bsv_movie_set_path(global->name.savefile); + + if (string_is_empty(global->name.base)) + return; + + if (string_is_empty(global->name.ups)) + fill_pathname_noext(global->name.ups, global->name.base, + file_path_str(FILE_PATH_UPS_EXTENSION), + sizeof(global->name.ups)); + + if (string_is_empty(global->name.bps)) + fill_pathname_noext(global->name.bps, global->name.base, + file_path_str(FILE_PATH_BPS_EXTENSION), + sizeof(global->name.bps)); + + if (string_is_empty(global->name.ips)) + fill_pathname_noext(global->name.ips, global->name.base, + file_path_str(FILE_PATH_IPS_EXTENSION), + sizeof(global->name.ips)); +} diff --git a/paths.h b/paths.h index 39318cec4a..adc2a92ba4 100644 --- a/paths.h +++ b/paths.h @@ -23,6 +23,10 @@ RETRO_BEGIN_DECLS void path_init_savefile(void); +void path_set_names(const char *path); + +void path_fill_names(void); + void path_set_redirect(void); void path_set_special(char **argv, unsigned num_content); diff --git a/retroarch.c b/retroarch.c index d4609ff3af..899d41550f 100644 --- a/retroarch.c +++ b/retroarch.c @@ -867,7 +867,7 @@ static void retroarch_parse_input(int argc, char *argv[]) { /* We requested explicit ROM, so use PLAIN core type. */ retroarch_set_current_core_type(CORE_TYPE_PLAIN, false); - retroarch_set_pathnames((const char*)argv[optind]); + path_set_names((const char*)argv[optind]); } else if (!string_is_empty(global->subsystem) && optind < argc) { @@ -1273,52 +1273,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) return true; } -void retroarch_set_pathnames(const char *path) -{ - global_t *global = global_get_ptr(); - - path_set_basename(path); - - if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH)) - fill_pathname_noext(global->name.savefile, global->name.base, - file_path_str(FILE_PATH_SRM_EXTENSION), sizeof(global->name.savefile)); - - if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_STATE_PATH)) - fill_pathname_noext(global->name.savestate, global->name.base, - file_path_str(FILE_PATH_STATE_EXTENSION), sizeof(global->name.savestate)); - - fill_pathname_noext(global->name.cheatfile, global->name.base, - file_path_str(FILE_PATH_CHT_EXTENSION), sizeof(global->name.cheatfile)); - - path_set_redirect(); -} - -void retroarch_fill_pathnames(void) -{ - global_t *global = global_get_ptr(); - - path_init_savefile(); - bsv_movie_set_path(global->name.savefile); - - if (string_is_empty(global->name.base)) - return; - - if (string_is_empty(global->name.ups)) - fill_pathname_noext(global->name.ups, global->name.base, - file_path_str(FILE_PATH_UPS_EXTENSION), - sizeof(global->name.ups)); - - if (string_is_empty(global->name.bps)) - fill_pathname_noext(global->name.bps, global->name.base, - file_path_str(FILE_PATH_BPS_EXTENSION), - sizeof(global->name.bps)); - - if (string_is_empty(global->name.ips)) - fill_pathname_noext(global->name.ips, global->name.base, - file_path_str(FILE_PATH_IPS_EXTENSION), - sizeof(global->name.ips)); -} - static bool has_set_verbosity = false; static bool has_set_libretro = false; static bool has_set_libretro_directory = false; diff --git a/retroarch.h b/retroarch.h index eab78907c1..5835e2900f 100644 --- a/retroarch.h +++ b/retroarch.h @@ -152,10 +152,6 @@ const char *retroarch_get_current_savefile_dir(void); bool retroarch_validate_game_options(char *s, size_t len, bool mkdir); -void retroarch_set_pathnames(const char *path); - -void retroarch_fill_pathnames(void); - void retroarch_set_current_core_type(enum rarch_core_type type, bool explicitly_set); /** From 5aebdb748415047c7be8b5f20bb0d6917a235a5e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 12:35:29 +0200 Subject: [PATCH 208/334] Mov code to paths.c --- configuration.c | 43 +------------------------------------------ configuration.h | 14 -------------- frontend/frontend.c | 2 +- menu/menu_setting.c | 2 +- menu/menu_shader.c | 1 + paths.c | 43 +++++++++++++++++++++++++++++++++++++++++++ paths.h | 14 ++++++++++++++ runloop.c | 1 + tasks/task_content.c | 1 + 9 files changed, 63 insertions(+), 58 deletions(-) diff --git a/configuration.c b/configuration.c index ce4bd3954a..4628c96fde 100644 --- a/configuration.c +++ b/configuration.c @@ -38,6 +38,7 @@ #include "input/input_remapping.h" #include "defaults.h" #include "core.h" +#include "paths.h" #include "retroarch.h" #include "runloop.h" #include "verbosity.h" @@ -3217,48 +3218,6 @@ bool config_replace(char *path) return true; } -static char path_libretro[PATH_MAX_LENGTH]; - -char *config_get_active_core_path_ptr(void) -{ - return path_libretro; -} - -const char *config_get_active_core_path(void) -{ - return path_libretro; -} - -bool config_active_core_path_is_empty(void) -{ - return !path_libretro[0]; -} - -size_t config_get_active_core_path_size(void) -{ - return sizeof(path_libretro); -} - -void config_set_active_core_path(const char *path) -{ - strlcpy(path_libretro, path, sizeof(path_libretro)); -} - -void config_clear_active_core_path(void) -{ - *path_libretro = '\0'; -} - -const char *config_get_active_path(void) -{ - global_t *global = global_get_ptr(); - - if (!string_is_empty(global->path.config)) - return global->path.config; - - return NULL; -} - void config_free_state(void) { } diff --git a/configuration.h b/configuration.h index 602e3cb25c..a2f38187ae 100644 --- a/configuration.h +++ b/configuration.h @@ -631,20 +631,6 @@ bool config_overlay_enable_default(void); void config_free(void); -const char *config_get_active_path(void); - -const char *config_get_active_core_path(void); - -char *config_get_active_core_path_ptr(void); - -void config_set_active_core_path(const char *path); - -void config_clear_active_core_path(void); - -bool config_active_core_path_is_empty(void); - -size_t config_get_active_core_path_size(void); - void config_free_state(void); settings_t *config_get_ptr(void); diff --git a/frontend/frontend.c b/frontend/frontend.c index 577f8409b1..766a0dd659 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -30,8 +30,8 @@ #include "../ui/ui_companion_driver.h" #include "../tasks/tasks_internal.h" -#include "../configuration.h" #include "../driver.h" +#include "../paths.h" #include "../retroarch.h" #include "../runloop.h" diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 4bbc769230..c6e24eec76 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -56,7 +56,7 @@ #include "../msg_hash.h" #include "../defaults.h" #include "../driver.h" -#include "../core.h" +#include "../paths.h" #include "../dynamic.h" #include "../runloop.h" #include "../verbosity.h" diff --git a/menu/menu_shader.c b/menu/menu_shader.c index 11c41c3bd4..e09134bb54 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -29,6 +29,7 @@ #include "menu_shader.h" #include "../file_path_special.h" #include "../configuration.h" +#include "../paths.h" #include "../runloop.h" #include "../verbosity.h" diff --git a/paths.c b/paths.c index 3e3d68d3b4..f21d949823 100644 --- a/paths.c +++ b/paths.c @@ -13,6 +13,7 @@ * If not, see . */ +#include #include #include #include @@ -30,6 +31,7 @@ #include "command.h" #include "content.h" #include "dynamic.h" +#include "movie.h" #include "file_path_special.h" #include "core.h" @@ -41,6 +43,7 @@ #define MENU_VALUE_NO_CORE 0x7d5472cbU static char current_savefile_dir[PATH_MAX_LENGTH] = {0}; +static char path_libretro[PATH_MAX_LENGTH] = {0}; void path_set_redirect(void) { @@ -411,3 +414,43 @@ void path_fill_names(void) file_path_str(FILE_PATH_IPS_EXTENSION), sizeof(global->name.ips)); } + +char *config_get_active_core_path_ptr(void) +{ + return path_libretro; +} + +const char *config_get_active_core_path(void) +{ + return path_libretro; +} + +bool config_active_core_path_is_empty(void) +{ + return !path_libretro[0]; +} + +size_t config_get_active_core_path_size(void) +{ + return sizeof(path_libretro); +} + +void config_set_active_core_path(const char *path) +{ + strlcpy(path_libretro, path, sizeof(path_libretro)); +} + +void config_clear_active_core_path(void) +{ + *path_libretro = '\0'; +} + +const char *config_get_active_path(void) +{ + global_t *global = global_get_ptr(); + + if (!string_is_empty(global->path.config)) + return global->path.config; + + return NULL; +} diff --git a/paths.h b/paths.h index adc2a92ba4..043b6a27d6 100644 --- a/paths.h +++ b/paths.h @@ -35,6 +35,20 @@ void path_set_basename(const char *path); const char *path_get_current_savefile_dir(void); +const char *config_get_active_path(void); + +const char *config_get_active_core_path(void); + +char *config_get_active_core_path_ptr(void); + +void config_set_active_core_path(const char *path); + +void config_clear_active_core_path(void); + +bool config_active_core_path_is_empty(void); + +size_t config_get_active_core_path_size(void); + RETRO_END_DECLS #endif diff --git a/runloop.c b/runloop.c index 78ac4b27a8..24b6f5950f 100644 --- a/runloop.c +++ b/runloop.c @@ -61,6 +61,7 @@ #include "configuration.h" #include "driver.h" #include "movie.h" +#include "paths.h" #include "retroarch.h" #include "runloop.h" #include "file_path_special.h" diff --git a/tasks/task_content.c b/tasks/task_content.c index b994179a8f..8ceeeea6d6 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -85,6 +85,7 @@ #include "../retroarch.h" #include "../file_path_special.h" #include "../core.h" +#include "../paths.h" #include "../verbosity.h" #ifdef HAVE_7ZIP From 56d8be90ec6e8611d9fa8a003f6ceed28e81f137 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 12:37:53 +0200 Subject: [PATCH 209/334] Cleanup --- configuration.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration.c b/configuration.c index 4628c96fde..f574926947 100644 --- a/configuration.c +++ b/configuration.c @@ -2411,7 +2411,7 @@ static bool check_shader_compatibility(enum file_path_enum enum_idx) bool config_load_shader_preset(void) { unsigned idx; - char shader_directory[PATH_MAX_LENGTH] = {0}; /* path to the directory containing retroarch.cfg (prefix) */ + char shader_directory[PATH_MAX_LENGTH] = {0}; /* path to the directory containing retroarch.cfg (prefix) */ char core_path[PATH_MAX_LENGTH] = {0}; /* final path for core-specific configuration (prefix+suffix) */ char game_path[PATH_MAX_LENGTH] = {0}; /* final path for game-specific configuration (prefix+suffix) */ const char *core_name = NULL; From b89def5d8fa9306c0dfcd081c9bc8cb20db5577b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 12:51:44 +0200 Subject: [PATCH 210/334] Rename config_get/config_set functions --- command.c | 13 ++++++------- configuration.c | 16 ++++++++-------- dynamic.c | 14 +++++++------- frontend/frontend.c | 4 +--- menu/menu_setting.c | 4 ++-- menu/menu_shader.c | 2 +- paths.c | 14 +++++++------- paths.h | 14 +++++++------- retroarch.c | 2 +- runloop.c | 2 +- tasks/task_content.c | 6 +++--- 11 files changed, 44 insertions(+), 47 deletions(-) diff --git a/command.c b/command.c index 01a49c8b60..ca68dbcd72 100644 --- a/command.c +++ b/command.c @@ -1497,8 +1497,7 @@ static bool command_event_save_core_config(void) } /* Infer file name based on libretro core. */ - if (!string_is_empty(config_get_active_core_path()) - && path_file_exists(config_get_active_core_path())) + if (!string_is_empty(path_get_core()) && path_file_exists(path_get_core())) { unsigned i; RARCH_LOG("%s\n", msg_hash_to_str(MSG_USING_CORE_NAME_FOR_NEW_CONFIG)); @@ -1510,7 +1509,7 @@ static bool command_event_save_core_config(void) fill_pathname_base_noext( config_name, - config_get_active_core_path(), + path_get_core(), sizeof(config_name)); fill_pathname_join(config_path, config_dir, config_name, @@ -1601,7 +1600,7 @@ void command_event_save_current_config(int override_type) && !string_is_empty(global->path.config)) { bool ret = false; - const char *config_path = config_get_active_path(); + const char *config_path = path_get_config(); /* Save last core-specific config to the default config location, * needed on consoles for core switching and reusing last good @@ -1883,14 +1882,14 @@ bool command_event(enum event_command cmd, void *data) core_info_ctx_find_t info_find; #if defined(HAVE_DYNAMIC) - if (string_is_empty(config_get_active_core_path())) + if (string_is_empty(path_get_core())) return false; #endif libretro_get_system_info( - config_get_active_core_path(), + path_get_core(), system, ptr); - info_find.path = config_get_active_core_path(); + info_find.path = path_get_core(); if (!core_info_load(&info_find)) { diff --git a/configuration.c b/configuration.c index f574926947..629be0da2a 100644 --- a/configuration.c +++ b/configuration.c @@ -655,7 +655,7 @@ static int populate_settings_path(settings_t *settings, struct config_path_setti #endif #ifndef HAVE_DYNAMIC SETTING_PATH("libretro_path", - config_get_active_core_path_ptr(), false, NULL, false); + path_get_core_ptr(), false, NULL, false); #endif SETTING_PATH( "screenshot_directory", @@ -1868,7 +1868,7 @@ static bool config_load_file(const char *path, bool set_defaults, #ifndef HAVE_DYNAMIC if (config_get_path(conf, "libretro_path", tmp_str, sizeof(tmp_str))) - config_set_active_core_path(tmp_str); + path_set_core(tmp_str); #endif #ifdef RARCH_CONSOLE @@ -1991,12 +1991,12 @@ static bool config_load_file(const char *path, bool set_defaults, } /* Safe-guard against older behavior. */ - if (path_is_directory(config_get_active_core_path())) + if (path_is_directory(path_get_core())) { RARCH_WARN("\"libretro_path\" is a directory, using this for \"libretro_directory\" instead.\n"); - strlcpy(settings->directory.libretro, config_get_active_core_path(), + strlcpy(settings->directory.libretro, path_get_core(), sizeof(settings->directory.libretro)); - config_clear_active_core_path(); + path_clear_core(); } if (string_is_equal(settings->path.menu_wallpaper, "default")) @@ -2216,7 +2216,7 @@ bool config_load_override(void) /* Store the libretro_path we're using since it will be * overwritten by the override when reloading. */ - strlcpy(buf, config_get_active_core_path(), sizeof(buf)); + strlcpy(buf, path_get_core(), sizeof(buf)); /* Toggle has_save_path to false so it resets */ retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH); @@ -2227,7 +2227,7 @@ bool config_load_override(void) /* Restore the libretro_path we're using * since it will be overwritten by the override when reloading. */ - config_set_active_core_path(buf); + path_set_core(buf); runloop_msg_queue_push("Configuration override loaded.", 1, 100, true); /* Reset save paths. */ @@ -3205,7 +3205,7 @@ bool config_replace(char *path) rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL); /* Load core in new config. */ - config_clear_active_core_path(); + path_clear_core(); if (!task_push_content_load_default( NULL, NULL, diff --git a/dynamic.c b/dynamic.c index 13f2afd1ab..abd6e37c2d 100644 --- a/dynamic.c +++ b/dynamic.c @@ -221,7 +221,7 @@ static void load_dynamic_core(void) retroarch_fail(1, "init_libretro_sym()"); } - if (string_is_empty(config_get_active_core_path())) + if (string_is_empty(path_get_core())) { RARCH_ERR("RetroArch is built for dynamic libretro cores, but " "libretro_path is not set. Cannot continue.\n"); @@ -232,16 +232,16 @@ static void load_dynamic_core(void) * saved to content history, and a relative path would * break in that scenario. */ path_resolve_realpath( - config_get_active_core_path_ptr(), - config_get_active_core_path_size()); + path_get_core_ptr(), + path_get_core_size()); RARCH_LOG("Loading dynamic libretro core from: \"%s\"\n", - config_get_active_core_path()); - lib_handle = dylib_load(config_get_active_core_path()); + path_get_core()); + lib_handle = dylib_load(path_get_core()); if (!lib_handle) { RARCH_ERR("Failed to open libretro core: \"%s\"\n", - config_get_active_core_path()); + path_get_core()); RARCH_ERR("Error(s): %s\n", dylib_error()); retroarch_fail(1, "load_dynamic()"); } @@ -1264,7 +1264,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) { const char **path = (const char**)data; #ifdef HAVE_DYNAMIC - *path = config_get_active_core_path(); + *path = path_get_core(); #else *path = NULL; #endif diff --git a/frontend/frontend.c b/frontend/frontend.c index 766a0dd659..13df9a5a2b 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -60,9 +60,7 @@ void main_exit(void *args) #endif frontend_driver_deinit(args); - frontend_driver_exitspawn( - config_get_active_core_path_ptr(), - config_get_active_core_path_size()); + frontend_driver_exitspawn(path_get_core_ptr(), path_get_core_size()); rarch_ctl(RARCH_CTL_DESTROY, NULL); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index c6e24eec76..4d615d4245 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -2144,8 +2144,8 @@ static bool setting_append_list( &group_info, &subgroup_info, parent_group); - (*list)[list_info->index - 1].size = config_get_active_core_path_size(); - (*list)[list_info->index - 1].value.target.string = config_get_active_core_path_ptr(); + (*list)[list_info->index - 1].size = path_get_core_size(); + (*list)[list_info->index - 1].value.target.string = path_get_core_ptr(); (*list)[list_info->index - 1].values = ext_name; menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_LOAD_CORE); settings_data_list_current_add_flags(list, list_info, SD_FLAG_BROWSER_ACTION); diff --git a/menu/menu_shader.c b/menu/menu_shader.c index e09134bb54..24b005f2e3 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -53,7 +53,7 @@ void menu_shader_manager_init(void) struct video_shader *shader = NULL; config_file_t *conf = NULL; settings_t *settings = config_get_ptr(); - const char *config_path = config_get_active_path(); + const char *config_path = path_get_config(); menu_driver_ctl(RARCH_MENU_CTL_SHADER_GET, &shader); diff --git a/paths.c b/paths.c index f21d949823..1f5f1853ed 100644 --- a/paths.c +++ b/paths.c @@ -415,37 +415,37 @@ void path_fill_names(void) sizeof(global->name.ips)); } -char *config_get_active_core_path_ptr(void) +char *path_get_core_ptr(void) { return path_libretro; } -const char *config_get_active_core_path(void) +const char *path_get_core(void) { return path_libretro; } -bool config_active_core_path_is_empty(void) +bool path_is_core_empty(void) { return !path_libretro[0]; } -size_t config_get_active_core_path_size(void) +size_t path_get_core_size(void) { return sizeof(path_libretro); } -void config_set_active_core_path(const char *path) +void path_set_core(const char *path) { strlcpy(path_libretro, path, sizeof(path_libretro)); } -void config_clear_active_core_path(void) +void path_clear_core(void) { *path_libretro = '\0'; } -const char *config_get_active_path(void) +const char *path_get_config(void) { global_t *global = global_get_ptr(); diff --git a/paths.h b/paths.h index 043b6a27d6..69cdf993dd 100644 --- a/paths.h +++ b/paths.h @@ -35,19 +35,19 @@ void path_set_basename(const char *path); const char *path_get_current_savefile_dir(void); -const char *config_get_active_path(void); +char *path_get_core_ptr(void); -const char *config_get_active_core_path(void); +const char *path_get_core(void); -char *config_get_active_core_path_ptr(void); +bool path_is_core_empty(void); -void config_set_active_core_path(const char *path); +size_t path_get_core_size(void); -void config_clear_active_core_path(void); +void path_set_core(const char *path); -bool config_active_core_path_is_empty(void); +void path_clear_core(void); -size_t config_get_active_core_path_size(void); +const char *path_get_config(void); RETRO_END_DECLS diff --git a/retroarch.c b/retroarch.c index 899d41550f..aa3eb5eab9 100644 --- a/retroarch.c +++ b/retroarch.c @@ -639,7 +639,7 @@ static void retroarch_parse_input(int argc, char *argv[]) case 'L': if (path_is_directory(optarg)) { - config_clear_active_core_path(); + path_clear_core(); strlcpy(settings->directory.libretro, optarg, sizeof(settings->directory.libretro)); diff --git a/runloop.c b/runloop.c index 24b6f5950f..e900bb8c22 100644 --- a/runloop.c +++ b/runloop.c @@ -842,7 +842,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) const char *fullpath = (const char*)data; if (!fullpath) return false; - config_set_active_core_path(fullpath); + path_set_core(fullpath); } break; case RUNLOOP_CTL_CLEAR_CONTENT_PATH: diff --git a/tasks/task_content.c b/tasks/task_content.c index 8ceeeea6d6..8240347451 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -1613,8 +1613,8 @@ static void menu_content_environment_get(int *argc, char *argv[], if (fullpath && *fullpath) wrap_args->content_path = fullpath; if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_LIBRETRO)) - wrap_args->libretro_path = string_is_empty(config_get_active_core_path()) ? NULL : - config_get_active_core_path(); + wrap_args->libretro_path = string_is_empty(path_get_core()) ? NULL : + path_get_core(); } #endif @@ -1717,7 +1717,7 @@ static bool task_load_content(content_ctx_info_t *content_info, #endif break; default: - core_path = config_get_active_core_path(); + core_path = path_get_core(); core_name = info->library_name; break; } From ec45dbaf0cd067b2d862dd117fa52de3a6746b9a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 12:56:19 +0200 Subject: [PATCH 211/334] Move retroarch_path_is_media_type to paths.c --- menu/menu_displaylist.c | 3 ++- paths.c | 57 +++++++++++++++++++++++++++++++++++++++ paths.h | 2 ++ retroarch.c | 59 +---------------------------------------- tasks/task_content.c | 2 +- 5 files changed, 63 insertions(+), 60 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index df96b36e17..0e435de683 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -53,6 +53,7 @@ #include "../defaults.h" #include "../managers/cheat_manager.h" #include "../managers/core_option_manager.h" +#include "../paths.h" #include "../retroarch.h" #include "../runloop.h" #include "../core.h" @@ -3485,7 +3486,7 @@ static int menu_displaylist_parse_generic( if (settings->multimedia.builtin_mediaplayer_enable || settings->multimedia.builtin_imageviewer_enable) { - switch (retroarch_path_is_media_type(path)) + switch (path_is_media_type(path)) { case RARCH_CONTENT_MOVIE: #ifdef HAVE_FFMPEG diff --git a/paths.c b/paths.c index 1f5f1853ed..799fc26538 100644 --- a/paths.c +++ b/paths.c @@ -454,3 +454,60 @@ const char *path_get_config(void) return NULL; } + +enum rarch_content_type path_is_media_type(const char *path) +{ + char ext_lower[PATH_MAX_LENGTH] = {0}; + + strlcpy(ext_lower, path_get_extension(path), sizeof(ext_lower)); + + string_to_lower(ext_lower); + + switch (msg_hash_to_file_type(msg_hash_calculate(ext_lower))) + { +#ifdef HAVE_FFMPEG + case FILE_TYPE_OGM: + case FILE_TYPE_MKV: + case FILE_TYPE_AVI: + case FILE_TYPE_MP4: + case FILE_TYPE_FLV: + case FILE_TYPE_WEBM: + case FILE_TYPE_3GP: + case FILE_TYPE_3G2: + case FILE_TYPE_F4F: + case FILE_TYPE_F4V: + case FILE_TYPE_MOV: + case FILE_TYPE_WMV: + case FILE_TYPE_MPG: + case FILE_TYPE_MPEG: + case FILE_TYPE_VOB: + case FILE_TYPE_ASF: + case FILE_TYPE_DIVX: + case FILE_TYPE_M2P: + case FILE_TYPE_M2TS: + case FILE_TYPE_PS: + case FILE_TYPE_TS: + case FILE_TYPE_MXF: + return RARCH_CONTENT_MOVIE; + case FILE_TYPE_WMA: + case FILE_TYPE_OGG: + case FILE_TYPE_MP3: + case FILE_TYPE_M4A: + case FILE_TYPE_FLAC: + case FILE_TYPE_WAV: + return RARCH_CONTENT_MUSIC; +#endif +#ifdef HAVE_IMAGEVIEWER + case FILE_TYPE_JPEG: + case FILE_TYPE_PNG: + case FILE_TYPE_TGA: + case FILE_TYPE_BMP: + return RARCH_CONTENT_IMAGE; +#endif + case FILE_TYPE_NONE: + default: + break; + } + + return RARCH_CONTENT_NONE; +} diff --git a/paths.h b/paths.h index 69cdf993dd..f50829b2dd 100644 --- a/paths.h +++ b/paths.h @@ -49,6 +49,8 @@ void path_clear_core(void); const char *path_get_config(void); +enum rarch_content_type path_is_media_type(const char *path); + RETRO_END_DECLS #endif diff --git a/retroarch.c b/retroarch.c index aa3eb5eab9..bfcd9b2166 100644 --- a/retroarch.c +++ b/retroarch.c @@ -338,63 +338,6 @@ static void retroarch_print_help(const char *arg0) "then exits.\n"); } -enum rarch_content_type retroarch_path_is_media_type(const char *path) -{ - char ext_lower[PATH_MAX_LENGTH] = {0}; - - strlcpy(ext_lower, path_get_extension(path), sizeof(ext_lower)); - - string_to_lower(ext_lower); - - switch (msg_hash_to_file_type(msg_hash_calculate(ext_lower))) - { -#ifdef HAVE_FFMPEG - case FILE_TYPE_OGM: - case FILE_TYPE_MKV: - case FILE_TYPE_AVI: - case FILE_TYPE_MP4: - case FILE_TYPE_FLV: - case FILE_TYPE_WEBM: - case FILE_TYPE_3GP: - case FILE_TYPE_3G2: - case FILE_TYPE_F4F: - case FILE_TYPE_F4V: - case FILE_TYPE_MOV: - case FILE_TYPE_WMV: - case FILE_TYPE_MPG: - case FILE_TYPE_MPEG: - case FILE_TYPE_VOB: - case FILE_TYPE_ASF: - case FILE_TYPE_DIVX: - case FILE_TYPE_M2P: - case FILE_TYPE_M2TS: - case FILE_TYPE_PS: - case FILE_TYPE_TS: - case FILE_TYPE_MXF: - return RARCH_CONTENT_MOVIE; - case FILE_TYPE_WMA: - case FILE_TYPE_OGG: - case FILE_TYPE_MP3: - case FILE_TYPE_M4A: - case FILE_TYPE_FLAC: - case FILE_TYPE_WAV: - return RARCH_CONTENT_MUSIC; -#endif -#ifdef HAVE_IMAGEVIEWER - case FILE_TYPE_JPEG: - case FILE_TYPE_PNG: - case FILE_TYPE_TGA: - case FILE_TYPE_BMP: - return RARCH_CONTENT_IMAGE; -#endif - case FILE_TYPE_NONE: - default: - break; - } - - return RARCH_CONTENT_NONE; -} - #define FFMPEG_RECORD_ARG "r:" #ifdef HAVE_DYNAMIC @@ -984,7 +927,7 @@ static void retroarch_main_init_media(void) if (string_is_empty(fullpath)) return; - switch (retroarch_path_is_media_type(fullpath)) + switch (path_is_media_type(fullpath)) { case RARCH_CONTENT_MOVIE: case RARCH_CONTENT_MUSIC: diff --git a/tasks/task_content.c b/tasks/task_content.c index 8240347451..152e2f8c1a 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -1693,7 +1693,7 @@ static bool task_load_content(content_ctx_info_t *content_info, const char *core_name = NULL; playlist_t *playlist_tmp = g_defaults.content_history; - switch (retroarch_path_is_media_type(tmp)) + switch (path_is_media_type(tmp)) { case RARCH_CONTENT_MOVIE: #ifdef HAVE_FFMPEG From 0aa2cf50190268e85bcaa18a4ad5750f7e3dd150 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 13:04:12 +0200 Subject: [PATCH 212/334] Create path_set_config and path_is_config_empty --- paths.c | 26 +++++++++++++++++++++++--- paths.h | 4 ++++ retroarch.c | 3 +-- runloop.c | 6 ++---- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/paths.c b/paths.c index 799fc26538..93d018854d 100644 --- a/paths.c +++ b/paths.c @@ -445,12 +445,32 @@ void path_clear_core(void) *path_libretro = '\0'; } -const char *path_get_config(void) +bool path_is_config_empty(void) { global_t *global = global_get_ptr(); - if (!string_is_empty(global->path.config)) - return global->path.config; + if (global && string_is_empty(global->path.config)) + return true; + + return false; +} + +void path_set_config(const char *path) +{ + global_t *global = global_get_ptr(); + if (!global) + return; + strlcpy(global->path.config, path, sizeof(global->path.config)); +} + +const char *path_get_config(void) +{ + if (!path_is_config_empty()) + { + global_t *global = global_get_ptr(); + if (global) + return global->path.config; + } return NULL; } diff --git a/paths.h b/paths.h index f50829b2dd..fa9bf34287 100644 --- a/paths.h +++ b/paths.h @@ -49,6 +49,10 @@ void path_clear_core(void); const char *path_get_config(void); +void path_set_config(const char *path); + +bool path_is_config_empty(void); + enum rarch_content_type path_is_media_type(const char *path); RETRO_END_DECLS diff --git a/retroarch.c b/retroarch.c index bfcd9b2166..0ca262dd07 100644 --- a/retroarch.c +++ b/retroarch.c @@ -563,8 +563,7 @@ static void retroarch_parse_input(int argc, char *argv[]) break; case 'c': - strlcpy(global->path.config, optarg, - sizeof(global->path.config)); + path_set_config(optarg); break; case 'r': diff --git a/runloop.c b/runloop.c index e900bb8c22..f1370b171d 100644 --- a/runloop.c +++ b/runloop.c @@ -1085,16 +1085,14 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) char *game_options_path = NULL; bool ret = false; char buf[PATH_MAX_LENGTH] = {0}; - global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); const char *options_path = settings->path.core_options; const struct retro_variable *vars = (const struct retro_variable*)data; - if (string_is_empty(options_path) - && !string_is_empty(global->path.config)) + if (string_is_empty(options_path) && !path_is_config_empty()) { - fill_pathname_resolve_relative(buf, global->path.config, + fill_pathname_resolve_relative(buf, path_get_config(), file_path_str(FILE_PATH_CORE_OPTIONS_CONFIG), sizeof(buf)); options_path = buf; } From 075599e8186bc90e20682fa34bc4484d1f5985f5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 13:14:14 +0200 Subject: [PATCH 213/334] Start using path_ functions for accessing and modifying global->path.config --- command.c | 17 +++++-------- configuration.c | 45 +++++++++++++++-------------------- file_path_special.c | 7 +++--- menu/cbs/menu_cbs_get_value.c | 8 +++---- menu/menu_shader.c | 5 ++-- tasks/task_content.c | 5 ++-- 6 files changed, 38 insertions(+), 49 deletions(-) diff --git a/command.c b/command.c index ca68dbcd72..ca4402a8a5 100644 --- a/command.c +++ b/command.c @@ -1480,14 +1480,12 @@ static bool command_event_save_core_config(void) bool found_path = false; bool overrides_active = false; settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); - *config_dir = '\0'; if (!string_is_empty(settings->directory.menu_config)) strlcpy(config_dir, settings->directory.menu_config, sizeof(config_dir)); - else if (!string_is_empty(global->path.config)) /* Fallback */ - fill_pathname_basedir(config_dir, global->path.config, + else if (!path_is_config_empty()) /* Fallback */ + fill_pathname_basedir(config_dir, path_get_config(), sizeof(config_dir)); else { @@ -1556,8 +1554,7 @@ static bool command_event_save_core_config(void) if ((ret = config_save_file(config_path))) { - strlcpy(global->path.config, config_path, - sizeof(global->path.config)); + path_set_config(config_path); snprintf(msg, sizeof(msg), "%s \"%s\".", msg_hash_to_str(MSG_SAVED_NEW_CONFIG_TO), config_path); @@ -1594,10 +1591,8 @@ void command_event_save_current_config(int override_type) if (!override_type) { settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); - if ( settings->config_save_on_exit - && !string_is_empty(global->path.config)) + if (settings->config_save_on_exit && !path_is_config_empty()) { bool ret = false; const char *config_path = path_get_config(); @@ -1615,14 +1610,14 @@ void command_event_save_current_config(int override_type) { snprintf(msg, sizeof(msg), "%s \"%s\".", msg_hash_to_str(MSG_SAVED_NEW_CONFIG_TO), - global->path.config); + path_get_config()); RARCH_LOG("%s\n", msg); } else { snprintf(msg, sizeof(msg), "%s \"%s\".", msg_hash_to_str(MSG_FAILED_SAVING_CONFIG_TO), - global->path.config); + path_get_config()); RARCH_ERR("%s\n", msg); } } diff --git a/configuration.c b/configuration.c index 629be0da2a..1bc491c5d7 100644 --- a/configuration.c +++ b/configuration.c @@ -1336,7 +1336,6 @@ static config_file_t *open_default_config_file(void) char conf_path[PATH_MAX_LENGTH] = {0}; char app_path[PATH_MAX_LENGTH] = {0}; config_file_t *conf = NULL; - global_t *global = NULL; #if defined(_WIN32) && !defined(_XBOX) fill_pathname_application_path(app_path, sizeof(app_path)); @@ -1501,10 +1500,8 @@ static config_file_t *open_default_config_file(void) if (!conf) return NULL; - global = global_get_ptr(); + path_set_config(conf_path); - if (global) - strlcpy(global->path.config, conf_path, sizeof(global->path.config)); return conf; } @@ -1908,7 +1905,7 @@ static bool config_load_file(const char *path, bool set_defaults, { fill_pathname_resolve_relative( settings->path.content_history, - global->path.config, + path_get_config(), file_path_str(FILE_PATH_CONTENT_HISTORY), sizeof(settings->path.content_history)); } @@ -1927,7 +1924,7 @@ static bool config_load_file(const char *path, bool set_defaults, { fill_pathname_resolve_relative( settings->path.content_music_history, - global->path.config, + path_get_config(), file_path_str(FILE_PATH_CONTENT_MUSIC_HISTORY), sizeof(settings->path.content_music_history)); } @@ -1946,7 +1943,7 @@ static bool config_load_file(const char *path, bool set_defaults, { fill_pathname_resolve_relative( settings->path.content_video_history, - global->path.config, + path_get_config(), file_path_str(FILE_PATH_CONTENT_VIDEO_HISTORY), sizeof(settings->path.content_video_history)); } @@ -1965,7 +1962,7 @@ static bool config_load_file(const char *path, bool set_defaults, { fill_pathname_resolve_relative( settings->path.content_image_history, - global->path.config, + path_get_config(), file_path_str(FILE_PATH_CONTENT_IMAGE_HISTORY), sizeof(settings->path.content_image_history)); } @@ -2222,7 +2219,7 @@ bool config_load_override(void) retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH); retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_SAVE_PATH); - if (!config_load_file(global->path.config, false, config_get_ptr())) + if (!config_load_file(path_get_config(), false, config_get_ptr())) return false; /* Restore the libretro_path we're using @@ -2258,7 +2255,7 @@ bool config_unload_override(void) retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH); retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_SAVE_PATH); - if (config_load_file(global->path.config, false, config_get_ptr())) + if (config_load_file(path_get_config(), false, config_get_ptr())) { RARCH_LOG("[overrides] configuration overrides unloaded, original configuration restored.\n"); @@ -2510,26 +2507,23 @@ bool config_load_shader_preset(void) static void parse_config_file(void) { - global_t *global = global_get_ptr(); - bool ret = config_load_file((*global->path.config) - ? global->path.config : NULL, false, config_get_ptr()); + bool ret = config_load_file(path_get_config(), false, config_get_ptr()); - if (!string_is_empty(global->path.config)) + if (!path_is_config_empty()) { - RARCH_LOG("Config: loading config from: %s.\n", global->path.config); + RARCH_LOG("Config: loading config from: %s.\n", path_get_config()); } else { RARCH_LOG("Loading default config.\n"); - if (!string_is_empty(global->path.config)) - RARCH_LOG("Config: found default config: %s.\n", global->path.config); + if (!path_is_config_empty()) + RARCH_LOG("Config: found default config: %s.\n", path_get_config()); } if (ret) return; - RARCH_ERR("Config: couldn't find config at path: \"%s\"\n", - global->path.config); + RARCH_ERR("Config: couldn't find config at path: \"%s\"\n", path_get_config()); } @@ -3062,7 +3056,7 @@ bool config_save_overrides(int override_type) conf = config_file_new(NULL); /* Load the original config file in memory */ - config_load_file(global->path.config, false, settings); + config_load_file(path_get_config(), false, settings); bool_settings_size = populate_settings_bool(settings, &bool_settings); populate_settings_bool (overrides, &bool_overrides); @@ -3187,20 +3181,19 @@ bool config_replace(char *path) { content_ctx_info_t content_info = {0}; settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); - if (!path || !global) + if (!path) return false; /* If config file to be replaced is the same as the * current config file, exit. */ - if (string_is_equal(path, global->path.config)) + if (string_is_equal(path, path_get_config())) return false; - if (settings->config_save_on_exit && !string_is_empty(global->path.config)) - config_save_file(global->path.config); + if (settings->config_save_on_exit && !path_is_config_empty()) + config_save_file(path_get_config()); - strlcpy(global->path.config, path, sizeof(global->path.config)); + path_set_config(path); rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL); diff --git a/file_path_special.c b/file_path_special.c index 76a569a7c0..3c094566ba 100644 --- a/file_path_special.c +++ b/file_path_special.c @@ -45,6 +45,7 @@ #include "configuration.h" #include "file_path_special.h" +#include "paths.h" #include "runloop.h" #include "verbosity.h" @@ -284,13 +285,13 @@ void fill_pathname_application_special(char *s, size_t len, enum application_spe case APPLICATION_SPECIAL_DIRECTORY_CONFIG: { settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); + /* Try config directory setting first, * fallback to the location of the current configuration file. */ if (!string_is_empty(settings->directory.menu_config)) strlcpy(s, settings->directory.menu_config, len); - else if (!string_is_empty(global->path.config)) - fill_pathname_basedir(s, global->path.config, len); + else if (!path_is_config_empty()) + fill_pathname_basedir(s, path_get_config(), len); } break; case APPLICATION_SPECIAL_DIRECTORY_ASSETS_ZARCH_ICONS: diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 762858fd09..fbac1ea4c0 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -38,6 +38,7 @@ #include "../../managers/core_option_manager.h" #include "../../managers/cheat_manager.h" #include "../../performance_counters.h" +#include "../../paths.h" #include "../../runloop.h" #include "../../intl/intl.h" @@ -125,12 +126,11 @@ static void menu_action_setting_disp_set_label_configurations( const char *path, char *s2, size_t len2) { - global_t *global = global_get_ptr(); - *w = 19; strlcpy(s2, path, len2); - if (global && *global->path.config) - fill_pathname_base(s, global->path.config, + + if (!path_is_config_empty()) + fill_pathname_base(s, path_get_config(), len); else strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DIRECTORY_DEFAULT), len); diff --git a/menu/menu_shader.c b/menu/menu_shader.c index 24b005f2e3..96455461d3 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -222,7 +222,6 @@ bool menu_shader_manager_save_preset( config_file_t *conf = NULL; bool ret = false; struct video_shader *shader = NULL; - global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); menu_handle_t *menu = NULL; @@ -296,10 +295,10 @@ bool menu_shader_manager_save_preset( strlcpy(buffer, conf_path, sizeof(buffer)); } - if (!string_is_empty(global->path.config)) + if (!path_is_config_empty()) fill_pathname_basedir( config_directory, - global->path.config, + path_get_config(), sizeof(config_directory)); if (!fullpath) diff --git a/tasks/task_content.c b/tasks/task_content.c index 152e2f8c1a..1ce411cd40 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -43,6 +43,7 @@ #include "../defaults.h" #include "../configuration.h" #include "../frontend/frontend.h" +#include "../paths.h" #include "../retroarch.h" #include "../verbosity.h" @@ -1604,8 +1605,8 @@ static void menu_content_environment_get(int *argc, char *argv[], wrap_args->state_path = NULL; wrap_args->content_path = NULL; - if (!string_is_empty(global->path.config)) - wrap_args->config_path = global->path.config; + if (!path_is_config_empty()) + wrap_args->config_path = path_get_config(); if (!string_is_empty(global->dir.savefile)) wrap_args->sram_path = global->dir.savefile; if (!string_is_empty(global->dir.savestate)) From b51aca2fa56efa783daa187b50f0eaf1844d640f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 13:37:37 +0200 Subject: [PATCH 214/334] Add core options path accessors --- paths.c | 38 ++++++++++++++++++++++++++++++++++++++ paths.h | 38 +++++++++++++++++++++++--------------- 2 files changed, 61 insertions(+), 15 deletions(-) diff --git a/paths.c b/paths.c index 93d018854d..64cd7a51cf 100644 --- a/paths.c +++ b/paths.c @@ -475,6 +475,44 @@ const char *path_get_config(void) return NULL; } +bool path_is_core_options_empty(void) +{ + global_t *global = global_get_ptr(); + + if (global && string_is_empty(global->path.core_options_path)) + return true; + + return false; +} + +void path_clear_core_options(void) +{ + global_t *global = global_get_ptr(); + if (!global) + return; + *global->path.core_options_path = '\0'; +} + +void path_set_core_options(const char *path) +{ + global_t *global = global_get_ptr(); + if (!global) + return; + strlcpy(global->path.core_options_path, path, sizeof(global->path.core_options_path)); +} + +const char *path_get_core_options(void) +{ + if (!path_is_core_options_empty()) + { + global_t *global = global_get_ptr(); + if (global) + return global->path.core_options_path; + } + + return NULL; +} + enum rarch_content_type path_is_media_type(const char *path) { char ext_lower[PATH_MAX_LENGTH] = {0}; diff --git a/paths.h b/paths.h index fa9bf34287..2279f2b6ff 100644 --- a/paths.h +++ b/paths.h @@ -23,36 +23,44 @@ RETRO_BEGIN_DECLS void path_init_savefile(void); -void path_set_names(const char *path); - void path_fill_names(void); void path_set_redirect(void); +void path_set_names(const char *path); + void path_set_special(char **argv, unsigned num_content); void path_set_basename(const char *path); -const char *path_get_current_savefile_dir(void); - -char *path_get_core_ptr(void); - -const char *path_get_core(void); - -bool path_is_core_empty(void); - -size_t path_get_core_size(void); - void path_set_core(const char *path); -void path_clear_core(void); - -const char *path_get_config(void); +void path_set_core_options(const char *path); void path_set_config(const char *path); +char *path_get_core_ptr(void); + +const char *path_get_current_savefile_dir(void); + +const char *path_get_core(void); + +const char *path_get_core_options(void); + +const char *path_get_config(void); + +size_t path_get_core_size(void); + +bool path_is_core_empty(void); + bool path_is_config_empty(void); +bool path_is_core_options_empty(void); + +void path_clear_core(void); + +void path_clear_core_options(void); + enum rarch_content_type path_is_media_type(const char *path); RETRO_END_DECLS From e338b787929300a8b12567021a552484381e227d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 13:40:25 +0200 Subject: [PATCH 215/334] Use new core options accessors --- menu/cbs/menu_cbs_ok.c | 7 ++----- runloop.c | 7 +++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index cbc3e08d21..67d41cfaa6 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -43,6 +43,7 @@ #include "../../managers/cheat_manager.h" #include "../../tasks/tasks_internal.h" #include "../../input/input_remapping.h" +#include "../../paths.h" #include "../../retroarch.h" #include "../../runloop.h" #include "../../verbosity.h" @@ -2497,14 +2498,10 @@ static int action_ok_option_create(const char *path, if(config_file_write(conf, game_path)) { - global_t *global = global_get_ptr(); - runloop_msg_queue_push( msg_hash_to_str(MSG_CORE_OPTIONS_FILE_CREATED_SUCCESSFULLY), 1, 100, true); - - strlcpy(global->path.core_options_path, - game_path, sizeof(global->path.core_options_path)); + path_set_core_options(game_path); } config_file_free(conf); diff --git a/runloop.c b/runloop.c index f1370b171d..41cf62f4e9 100644 --- a/runloop.c +++ b/runloop.c @@ -1124,17 +1124,16 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) break; case RUNLOOP_CTL_CORE_OPTIONS_DEINIT: { - global_t *global = global_get_ptr(); if (!runloop_core_options) return false; /* check if game options file was just created and flush to that file instead */ - if(global && !string_is_empty(global->path.core_options_path)) + if(!path_is_core_options_empty()) { core_option_manager_flush_game_specific(runloop_core_options, - global->path.core_options_path); - global->path.core_options_path[0] = '\0'; + path_get_core_options()); + path_clear_core_options(); } else core_option_manager_flush(runloop_core_options); From f4e1ffeabfbe5ae522d0080f9d654469342e1d31 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 13:42:48 +0200 Subject: [PATCH 216/334] Don't access global->path.config directly --- configuration.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/configuration.c b/configuration.c index 1bc491c5d7..dc141006e2 100644 --- a/configuration.c +++ b/configuration.c @@ -1302,8 +1302,12 @@ static void config_set_defaults(void) sizeof(settings->directory.content_history)); if (!string_is_empty(g_defaults.path.config)) - fill_pathname_expand_special(global->path.config, - g_defaults.path.config, sizeof(global->path.config)); + { + char temp_str[PATH_MAX_LENGTH]; + fill_pathname_expand_special(temp_str, + g_defaults.path.config, sizeof(temp_str)); + path_set_config(temp_str); + } /* Avoid reloading config on every content load */ if (default_block_config_read) From 471347689d1cb7160a4b69bb70ded38d74b9a6bb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 13:47:26 +0200 Subject: [PATCH 217/334] Create path_clear_all --- managers/core_option_manager.c | 2 +- managers/core_option_manager.h | 2 +- paths.c | 11 +++++++++++ paths.h | 2 ++ runloop.c | 1 + 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/managers/core_option_manager.c b/managers/core_option_manager.c index df6575adde..70ca896b96 100644 --- a/managers/core_option_manager.c +++ b/managers/core_option_manager.c @@ -247,7 +247,7 @@ bool core_option_manager_flush(core_option_manager_t *opt) * successfully saved to disk, otherwise false (0). **/ bool core_option_manager_flush_game_specific( - core_option_manager_t *opt, char* path) + core_option_manager_t *opt, const char* path) { size_t i; for (i = 0; i < opt->size; i++) diff --git a/managers/core_option_manager.h b/managers/core_option_manager.h index 2ee2db3354..46929df1f8 100644 --- a/managers/core_option_manager.h +++ b/managers/core_option_manager.h @@ -90,7 +90,7 @@ bool core_option_manager_flush(core_option_manager_t *opt); * successfully saved to disk, otherwise false (0). **/ bool core_option_manager_flush_game_specific( - core_option_manager_t *opt, char* path); + core_option_manager_t *opt, const char* path); /** * core_option_manager_free: diff --git a/paths.c b/paths.c index 64cd7a51cf..600335268e 100644 --- a/paths.c +++ b/paths.c @@ -513,6 +513,17 @@ const char *path_get_core_options(void) return NULL; } +void path_clear_all(void) +{ + global_t *global = global_get_ptr(); + + path_clear_core(); + path_clear_core_options(); + + if (global) + memset(&global->path, 0, sizeof(struct rarch_path)); +} + enum rarch_content_type path_is_media_type(const char *path) { char ext_lower[PATH_MAX_LENGTH] = {0}; diff --git a/paths.h b/paths.h index 2279f2b6ff..e0d897f33d 100644 --- a/paths.h +++ b/paths.h @@ -61,6 +61,8 @@ void path_clear_core(void); void path_clear_core_options(void); +void path_clear_all(void); + enum rarch_content_type path_is_media_type(const char *path); RETRO_END_DECLS diff --git a/runloop.c b/runloop.c index 41cf62f4e9..38969dd04c 100644 --- a/runloop.c +++ b/runloop.c @@ -745,6 +745,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) runloop_frontend_key_event = NULL; audio_driver_unset_callback(); + path_clear_all(); memset(&runloop_system, 0, sizeof(rarch_system_info_t)); break; case RUNLOOP_CTL_SET_FRAME_TIME_LAST: From fa5db51b0255e0d1cb216fd63507d0c43e919845 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 13:50:34 +0200 Subject: [PATCH 218/334] Divorce config variable from global struct --- paths.c | 21 +++++++++++---------- paths.h | 2 ++ runloop.h | 1 - 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/paths.c b/paths.c index 600335268e..5abe56fbb6 100644 --- a/paths.c +++ b/paths.c @@ -44,6 +44,7 @@ static char current_savefile_dir[PATH_MAX_LENGTH] = {0}; static char path_libretro[PATH_MAX_LENGTH] = {0}; +static char path_config_file[PATH_MAX_LENGTH] = {0}; void path_set_redirect(void) { @@ -447,9 +448,7 @@ void path_clear_core(void) bool path_is_config_empty(void) { - global_t *global = global_get_ptr(); - - if (global && string_is_empty(global->path.config)) + if (string_is_empty(path_config_file)) return true; return false; @@ -460,21 +459,22 @@ void path_set_config(const char *path) global_t *global = global_get_ptr(); if (!global) return; - strlcpy(global->path.config, path, sizeof(global->path.config)); + strlcpy(path_config_file, path, sizeof(path_config_file)); } const char *path_get_config(void) { if (!path_is_config_empty()) - { - global_t *global = global_get_ptr(); - if (global) - return global->path.config; - } + return path_config_file; return NULL; } +void path_clear_config(void) +{ + *path_config_file = '\0'; +} + bool path_is_core_options_empty(void) { global_t *global = global_get_ptr(); @@ -516,7 +516,8 @@ const char *path_get_core_options(void) void path_clear_all(void) { global_t *global = global_get_ptr(); - + + path_clear_config(); path_clear_core(); path_clear_core_options(); diff --git a/paths.h b/paths.h index e0d897f33d..8c5c631f20 100644 --- a/paths.h +++ b/paths.h @@ -59,6 +59,8 @@ bool path_is_core_options_empty(void); void path_clear_core(void); +void path_clear_config(void); + void path_clear_core_options(void); void path_clear_all(void); diff --git a/runloop.h b/runloop.h index b3920a9d85..29c273dc50 100644 --- a/runloop.h +++ b/runloop.h @@ -157,7 +157,6 @@ typedef struct rarch_path char bsx_rom[PATH_MAX_LENGTH]; char sufami_rom[2][PATH_MAX_LENGTH]; /* Config associated with global "default" config. */ - char config[PATH_MAX_LENGTH]; char append_config[PATH_MAX_LENGTH]; char input_config[PATH_MAX_LENGTH]; #ifdef HAVE_FILE_LOGGER From f5d0325b2f8a6c0ca9eed2ef9e312b5918852454 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 13:56:41 +0200 Subject: [PATCH 219/334] Fix bug in path_clear_all --- paths.c | 1 - 1 file changed, 1 deletion(-) diff --git a/paths.c b/paths.c index 5abe56fbb6..9d3f30306e 100644 --- a/paths.c +++ b/paths.c @@ -518,7 +518,6 @@ void path_clear_all(void) global_t *global = global_get_ptr(); path_clear_config(); - path_clear_core(); path_clear_core_options(); if (global) From 392fad75b8de4e09ed05f3e53d3c003e26629ff6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 13:57:38 +0200 Subject: [PATCH 220/334] Cleanups --- paths.c | 25 ++++++------------------- runloop.h | 2 -- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/paths.c b/paths.c index 9d3f30306e..761f2f4e7c 100644 --- a/paths.c +++ b/paths.c @@ -45,6 +45,8 @@ static char current_savefile_dir[PATH_MAX_LENGTH] = {0}; static char path_libretro[PATH_MAX_LENGTH] = {0}; static char path_config_file[PATH_MAX_LENGTH] = {0}; +/* Config file associated with per-core configs. */ +static char path_core_options_file[PATH_MAX_LENGTH] = {0}; void path_set_redirect(void) { @@ -456,9 +458,6 @@ bool path_is_config_empty(void) void path_set_config(const char *path) { - global_t *global = global_get_ptr(); - if (!global) - return; strlcpy(path_config_file, path, sizeof(path_config_file)); } @@ -477,9 +476,7 @@ void path_clear_config(void) bool path_is_core_options_empty(void) { - global_t *global = global_get_ptr(); - - if (global && string_is_empty(global->path.core_options_path)) + if (string_is_empty(path_core_options_file)) return true; return false; @@ -487,28 +484,18 @@ bool path_is_core_options_empty(void) void path_clear_core_options(void) { - global_t *global = global_get_ptr(); - if (!global) - return; - *global->path.core_options_path = '\0'; + *path_core_options_file = '\0'; } void path_set_core_options(const char *path) { - global_t *global = global_get_ptr(); - if (!global) - return; - strlcpy(global->path.core_options_path, path, sizeof(global->path.core_options_path)); + strlcpy(path_core_options_file, path, sizeof(path_core_options_file)); } const char *path_get_core_options(void) { if (!path_is_core_options_empty()) - { - global_t *global = global_get_ptr(); - if (global) - return global->path.core_options_path; - } + return path_core_options_file; return NULL; } diff --git a/runloop.h b/runloop.h index 29c273dc50..a8a9aa87f3 100644 --- a/runloop.h +++ b/runloop.h @@ -162,8 +162,6 @@ typedef struct rarch_path #ifdef HAVE_FILE_LOGGER char default_log[PATH_MAX_LENGTH]; #endif - /* Config file associated with per-core configs. */ - char core_options_path[PATH_MAX_LENGTH]; } rarch_path_t; typedef struct rarch_resolution From 74d8ce4b957a7b92eeea4684b6a1ca7c0461d944 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 13:58:03 +0200 Subject: [PATCH 221/334] Remove this unused variable --- runloop.h | 1 - 1 file changed, 1 deletion(-) diff --git a/runloop.h b/runloop.h index a8a9aa87f3..1f87ddfd62 100644 --- a/runloop.h +++ b/runloop.h @@ -158,7 +158,6 @@ typedef struct rarch_path char sufami_rom[2][PATH_MAX_LENGTH]; /* Config associated with global "default" config. */ char append_config[PATH_MAX_LENGTH]; - char input_config[PATH_MAX_LENGTH]; #ifdef HAVE_FILE_LOGGER char default_log[PATH_MAX_LENGTH]; #endif From 3f7643304c1fb5024a3e4d6347c91a1df0d07bbf Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 13:59:21 +0200 Subject: [PATCH 222/334] Remove unused paths --- runloop.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/runloop.h b/runloop.h index 1f87ddfd62..86c621c543 100644 --- a/runloop.h +++ b/runloop.h @@ -153,9 +153,6 @@ typedef struct rarch_dir typedef struct rarch_path { - char gb_rom[PATH_MAX_LENGTH]; - char bsx_rom[PATH_MAX_LENGTH]; - char sufami_rom[2][PATH_MAX_LENGTH]; /* Config associated with global "default" config. */ char append_config[PATH_MAX_LENGTH]; #ifdef HAVE_FILE_LOGGER From 98d325ad673e72d35d37124519031261afa64efb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 14:00:42 +0200 Subject: [PATCH 223/334] Remove unused default_log --- runloop.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/runloop.h b/runloop.h index 86c621c543..bd67c7dbeb 100644 --- a/runloop.h +++ b/runloop.h @@ -155,9 +155,6 @@ typedef struct rarch_path { /* Config associated with global "default" config. */ char append_config[PATH_MAX_LENGTH]; -#ifdef HAVE_FILE_LOGGER - char default_log[PATH_MAX_LENGTH]; -#endif } rarch_path_t; typedef struct rarch_resolution From 0254d8714d8f57446934749f907fd17d344a71e1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 14:04:19 +0200 Subject: [PATCH 224/334] Create config append functions --- paths.c | 36 ++++++++++++++++++++++++++++++++++++ paths.h | 8 ++++++++ 2 files changed, 44 insertions(+) diff --git a/paths.c b/paths.c index 761f2f4e7c..de8a56faf5 100644 --- a/paths.c +++ b/paths.c @@ -45,6 +45,7 @@ static char current_savefile_dir[PATH_MAX_LENGTH] = {0}; static char path_libretro[PATH_MAX_LENGTH] = {0}; static char path_config_file[PATH_MAX_LENGTH] = {0}; +static char path_config_append_file[PATH_MAX_LENGTH] = {0}; /* Config file associated with per-core configs. */ static char path_core_options_file[PATH_MAX_LENGTH] = {0}; @@ -418,6 +419,8 @@ void path_fill_names(void) sizeof(global->name.ips)); } +/* Core file path */ + char *path_get_core_ptr(void) { return path_libretro; @@ -448,6 +451,8 @@ void path_clear_core(void) *path_libretro = '\0'; } +/* Config file path */ + bool path_is_config_empty(void) { if (string_is_empty(path_config_file)) @@ -474,6 +479,8 @@ void path_clear_config(void) *path_config_file = '\0'; } +/* Core options file path */ + bool path_is_core_options_empty(void) { if (string_is_empty(path_core_options_file)) @@ -500,11 +507,40 @@ const char *path_get_core_options(void) return NULL; } +/* Append config file path */ + +bool path_is_config_append_empty(void) +{ + if (string_is_empty(path_config_append_file)) + return true; + + return false; +} + +void path_clear_config_append(void) +{ + *path_config_append_file = '\0'; +} + +void path_set_config_append(const char *path) +{ + strlcpy(path_config_append_file, path, sizeof(path_config_append_file)); +} + +const char *path_get_config_append(void) +{ + if (!path_is_config_append_empty()) + return path_config_append_file; + + return NULL; +} + void path_clear_all(void) { global_t *global = global_get_ptr(); path_clear_config(); + path_clear_config_append(); path_clear_core_options(); if (global) diff --git a/paths.h b/paths.h index 8c5c631f20..3edebe37ac 100644 --- a/paths.h +++ b/paths.h @@ -39,6 +39,8 @@ void path_set_core_options(const char *path); void path_set_config(const char *path); +void path_set_config_append(const char *path); + char *path_get_core_ptr(void); const char *path_get_current_savefile_dir(void); @@ -49,6 +51,8 @@ const char *path_get_core_options(void); const char *path_get_config(void); +const char *path_get_config_append(void); + size_t path_get_core_size(void); bool path_is_core_empty(void); @@ -57,12 +61,16 @@ bool path_is_config_empty(void); bool path_is_core_options_empty(void); +bool path_is_config_append_empty(void); + void path_clear_core(void); void path_clear_config(void); void path_clear_core_options(void); +void path_clear_config_append(void); + void path_clear_all(void); enum rarch_content_type path_is_media_type(const char *path); From ef02fb8a969b861c35977e2a84a4e21c74703c40 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 14:14:58 +0200 Subject: [PATCH 225/334] Refactor append config code --- configuration.c | 61 +++++++++++++++++++++++++++++-------------------- paths.c | 5 ---- retroarch.c | 3 +-- runloop.h | 7 ------ 4 files changed, 37 insertions(+), 39 deletions(-) diff --git a/configuration.c b/configuration.c index dc141006e2..94d22b5b0d 100644 --- a/configuration.c +++ b/configuration.c @@ -1642,9 +1642,7 @@ static bool config_load_file(const char *path, bool set_defaults, unsigned i; bool tmp_bool = false; char *save = NULL; - const char *extra_path = NULL; char tmp_str[PATH_MAX_LENGTH] = {0}; - char tmp_append_path[PATH_MAX_LENGTH] = {0}; /* Don't destroy append_config_path. */ unsigned msg_color = 0; config_file_t *conf = NULL; struct config_int_setting *int_settings = NULL; @@ -1678,20 +1676,29 @@ static bool config_load_file(const char *path, bool set_defaults, if (set_defaults) config_set_defaults(); - strlcpy(tmp_append_path, global->path.append_config, - sizeof(tmp_append_path)); - extra_path = strtok_r(tmp_append_path, "|", &save); - - while (extra_path) + if (!path_is_config_append_empty()) { - bool ret = config_append_file(conf, extra_path); + /* Don't destroy append_config_path, store in temporary + * variable. */ + char tmp_append_path[PATH_MAX_LENGTH] = {0}; + const char *extra_path = NULL; - RARCH_LOG("Config: appending config \"%s\"\n", extra_path); + strlcpy(tmp_append_path, path_get_config_append(), + sizeof(tmp_append_path)); + extra_path = strtok_r(tmp_append_path, "|", &save); - if (!ret) - RARCH_ERR("Config: failed to append config \"%s\"\n", extra_path); - extra_path = strtok_r(NULL, "|", &save); + while (extra_path) + { + bool ret = config_append_file(conf, extra_path); + + RARCH_LOG("Config: appending config \"%s\"\n", extra_path); + + if (!ret) + RARCH_ERR("Config: failed to append config \"%s\"\n", extra_path); + extra_path = strtok_r(NULL, "|", &save); + } } + #if 0 if (verbosity_is_enabled()) { @@ -1719,6 +1726,7 @@ static bool config_load_file(const char *path, bool set_defaults, if (config_get_bool(conf, bool_settings[i].ident, &tmp)) *bool_settings[i].ptr = tmp; } + if (!rarch_ctl(RARCH_CTL_IS_FORCE_FULLSCREEN, NULL)) CONFIG_GET_BOOL_BASE(conf, settings, video.fullscreen, "video_fullscreen"); @@ -2171,10 +2179,10 @@ bool config_load_override(void) /* If a core override exists, add its location to append_config_path */ if (new_conf) { - config_file_free(new_conf); - RARCH_LOG("[overrides] core-specific overrides found at %s.\n", core_path); - strlcpy(global->path.append_config, core_path, sizeof(global->path.append_config)); + + config_file_free(new_conf); + path_set_config_append(core_path); should_append = true; } @@ -2187,16 +2195,22 @@ bool config_load_override(void) /* If a game override exists, add it's location to append_config_path */ if (new_conf) { + char temp_path[PATH_MAX_LENGTH] = {0}; + config_file_free(new_conf); RARCH_LOG("[overrides] game-specific overrides found at %s.\n", game_path); + if (should_append) { - strlcat(global->path.append_config, "|", sizeof(global->path.append_config)); - strlcat(global->path.append_config, game_path, sizeof(global->path.append_config)); + strlcpy(temp_path, path_get_config_append(), sizeof(temp_path)); + strlcat(temp_path, "|", sizeof(temp_path)); + strlcat(temp_path, game_path, sizeof(temp_path)); } else - strlcpy(global->path.append_config, game_path, sizeof(global->path.append_config)); + strlcpy(temp_path, game_path, sizeof(temp_path)); + + path_set_config_append(temp_path); should_append = true; } @@ -2234,7 +2248,9 @@ bool config_load_override(void) /* Reset save paths. */ retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_STATE_PATH); retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_SAVE_PATH); - global->path.append_config[0] = '\0'; + + path_clear_config_append(); + return true; } @@ -2248,12 +2264,7 @@ bool config_load_override(void) */ bool config_unload_override(void) { - global_t *global = global_get_ptr(); - - if (!global) - return false; - - *global->path.append_config = '\0'; + path_clear_config_append(); /* Toggle has_save_path to false so it resets */ retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH); diff --git a/paths.c b/paths.c index de8a56faf5..45b5240f70 100644 --- a/paths.c +++ b/paths.c @@ -537,14 +537,9 @@ const char *path_get_config_append(void) void path_clear_all(void) { - global_t *global = global_get_ptr(); - path_clear_config(); path_clear_config_append(); path_clear_core_options(); - - if (global) - memset(&global->path, 0, sizeof(struct rarch_path)); } enum rarch_content_type path_is_media_type(const char *path) diff --git a/retroarch.c b/retroarch.c index 0ca262dd07..f821091982 100644 --- a/retroarch.c +++ b/retroarch.c @@ -728,8 +728,7 @@ static void retroarch_parse_input(int argc, char *argv[]) #endif case RA_OPT_APPENDCONFIG: - strlcpy(global->path.append_config, optarg, - sizeof(global->path.append_config)); + path_set_config_append(optarg); break; case RA_OPT_SIZE: diff --git a/runloop.h b/runloop.h index bd67c7dbeb..0095427b1f 100644 --- a/runloop.h +++ b/runloop.h @@ -151,12 +151,6 @@ typedef struct rarch_dir #endif } rarch_dir_t; -typedef struct rarch_path -{ - /* Config associated with global "default" config. */ - char append_config[PATH_MAX_LENGTH]; -} rarch_path_t; - typedef struct rarch_resolution { unsigned idx; @@ -167,7 +161,6 @@ typedef struct rarch_resolution typedef struct global { - rarch_path_t path; rarch_dir_t dir; struct From 16de70a9d955ac213551e34eb3bdfeb526e70af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Jos=C3=A9=20Garc=C3=ADa=20Garc=C3=ADa?= Date: Sat, 17 Sep 2016 14:19:26 +0200 Subject: [PATCH 226/334] Update psp_joypad.c --- input/drivers_joypad/psp_joypad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input/drivers_joypad/psp_joypad.c b/input/drivers_joypad/psp_joypad.c index 0880915bba..fe2309ba9a 100644 --- a/input/drivers_joypad/psp_joypad.c +++ b/input/drivers_joypad/psp_joypad.c @@ -148,7 +148,7 @@ static void psp_joypad_poll(void) * can be 0 or 1 to read the first controller on * a PSTV, but HAS to be 0 for a real VITA and 2 * for the 2nd controller on a PSTV */ - unsigned p = (player == 1) ? 2 : player; + unsigned p = (player > 0) ? player+1 : player; int32_t ret = CtrlPeekBufferPositive(p, &state_tmp, 1); pad_state[i] = 0; From 16257d58ef7ef8df4ad8730158510e054d1d1725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Jos=C3=A9=20Garc=C3=ADa=20Garc=C3=ADa?= Date: Sat, 17 Sep 2016 14:22:45 +0200 Subject: [PATCH 227/334] Add up to 4 players --- input/drivers_joypad/psp_joypad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input/drivers_joypad/psp_joypad.c b/input/drivers_joypad/psp_joypad.c index fe2309ba9a..1eae1fbda5 100644 --- a/input/drivers_joypad/psp_joypad.c +++ b/input/drivers_joypad/psp_joypad.c @@ -21,7 +21,7 @@ #include "../../configuration.h" #if defined(SN_TARGET_PSP2) || defined(VITA) -#define PSP_MAX_PADS 2 +#define PSP_MAX_PADS 4 #else #define PSP_MAX_PADS 1 #endif From d03b6df5736193ab55b222d88bc012d7335727d0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 14:23:44 +0200 Subject: [PATCH 228/334] retroarch.c - cleanup --- retroarch.c | 86 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 37 deletions(-) diff --git a/retroarch.c b/retroarch.c index f821091982..5915c61934 100644 --- a/retroarch.c +++ b/retroarch.c @@ -84,6 +84,13 @@ #include "command.h" +#define _PSUPP(var, name, desc) printf(" %s:\n\t\t%s: %s\n", name, desc, _##var##_supp ? "yes" : "no") + +#define FAIL_CPU(simd_type) do { \ + RARCH_ERR(simd_type " code is compiled in, but CPU does not support this feature. Cannot continue.\n"); \ + retroarch_fail(1, "validate_cpu_features()"); \ +} while(0) + /* Descriptive names for options without short variant. * * Please keep the name in sync with the option name. @@ -110,13 +117,30 @@ enum RA_OPT_MAX_FRAMES }; +static jmp_buf error_sjlj_context; static bool current_core_explicitly_set = false; static enum rarch_core_type current_core_type = CORE_TYPE_PLAIN; static enum rarch_core_type explicit_current_core_type = CORE_TYPE_PLAIN; static char error_string[PATH_MAX_LENGTH] = {0}; -static jmp_buf error_sjlj_context; -#define _PSUPP(var, name, desc) printf(" %s:\n\t\t%s: %s\n", name, desc, _##var##_supp ? "yes" : "no") +static bool has_set_username = false; +static bool rarch_is_inited = false; +static bool rarch_error_on_init = false; +static bool rarch_block_config_read = false; +static bool rarch_force_fullscreen = false; +static bool has_set_verbosity = false; +static bool has_set_libretro = false; +static bool has_set_libretro_directory = false; +static bool has_set_save_path = false; +static bool has_set_state_path = false; +static bool has_set_netplay_mode = false; +static bool has_set_netplay_ip_address = false; +static bool has_set_netplay_ip_port = false; +static bool has_set_netplay_delay_frames = false; +static bool has_set_netplay_check_frames = false; +static bool has_set_ups_pref = false; +static bool has_set_bps_pref = false; +static bool has_set_ips_pref = false; static void retroarch_print_features(void) { @@ -352,7 +376,6 @@ static void retroarch_print_help(const char *arg0) #define NETPLAY_ARG #endif - #define BSV_MOVIE_ARG "P:R:M:" /** @@ -531,7 +554,8 @@ static void retroarch_parse_input(int argc, char *argv[]) case 's': strlcpy(global->name.savefile, optarg, sizeof(global->name.savefile)); - retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_SAVE_PATH); + retroarch_override_setting_set( + RARCH_OVERRIDE_SETTING_SAVE_PATH); break; case 'f': @@ -541,12 +565,14 @@ static void retroarch_parse_input(int argc, char *argv[]) case 'S': strlcpy(global->name.savestate, optarg, sizeof(global->name.savestate)); - retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_STATE_PATH); + retroarch_override_setting_set( + RARCH_OVERRIDE_SETTING_STATE_PATH); break; case 'v': verbosity_enable(); - retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_VERBOSITY); + retroarch_override_setting_set( + RARCH_OVERRIDE_SETTING_VERBOSITY); break; case 'N': @@ -642,13 +668,15 @@ static void retroarch_parse_input(int argc, char *argv[]) #ifdef HAVE_NETPLAY case 'H': - retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_NETPLAY_IP_ADDRESS); + retroarch_override_setting_set( + RARCH_OVERRIDE_SETTING_NETPLAY_IP_ADDRESS); global->netplay.enable = true; *global->netplay.server = '\0'; break; case 'C': - retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_NETPLAY_IP_ADDRESS); + retroarch_override_setting_set( + RARCH_OVERRIDE_SETTING_NETPLAY_IP_ADDRESS); global->netplay.enable = true; strlcpy(global->netplay.server, optarg, sizeof(global->netplay.server)); @@ -656,7 +684,8 @@ static void retroarch_parse_input(int argc, char *argv[]) case 'F': global->netplay.sync_frames = strtol(optarg, NULL, 0); - retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_NETPLAY_DELAY_FRAMES); + retroarch_override_setting_set( + RARCH_OVERRIDE_SETTING_NETPLAY_DELAY_FRAMES); break; #endif @@ -697,17 +726,20 @@ static void retroarch_parse_input(int argc, char *argv[]) #ifdef HAVE_NETPLAY case RA_OPT_CHECK_FRAMES: - retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_NETPLAY_CHECK_FRAMES); + retroarch_override_setting_set( + RARCH_OVERRIDE_SETTING_NETPLAY_CHECK_FRAMES); global->netplay.check_frames = strtoul(optarg, NULL, 0); break; case RA_OPT_PORT: - retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_NETPLAY_IP_PORT); + retroarch_override_setting_set( + RARCH_OVERRIDE_SETTING_NETPLAY_IP_PORT); global->netplay.port = strtoul(optarg, NULL, 0); break; case RA_OPT_SPECTATE: - retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_NETPLAY_MODE); + retroarch_override_setting_set( + RARCH_OVERRIDE_SETTING_NETPLAY_MODE); global->netplay.is_spectate = true; break; @@ -797,8 +829,11 @@ static void retroarch_parse_input(int argc, char *argv[]) #ifdef HAVE_DYNAMIC else { - /* Allow stray -L arguments to go through to workaround cases where it's used as "config file". - * This seems to still be the case for Android, which should be properly fixed. */ + /* Allow stray -L arguments to go through to workaround cases + * where it's used as "config file". + * + * This seems to still be the case for Android, which + * should be properly fixed. */ retroarch_set_current_core_type(CORE_TYPE_DUMMY, false); } #endif @@ -878,11 +913,6 @@ bool retroarch_validate_game_options(char *s, size_t len, bool mkdir) return true; } -#define FAIL_CPU(simd_type) do { \ - RARCH_ERR(simd_type " code is compiled in, but CPU does not support this feature. Cannot continue.\n"); \ - retroarch_fail(1, "validate_cpu_features()"); \ -} while(0) - /* Validates CPU features for given processor architecture. * Make sure we haven't compiled for something we cannot run. * Ideally, code would get swapped out depending on CPU support, @@ -1055,11 +1085,6 @@ error: bool rarch_ctl(enum rarch_ctl_state state, void *data) { - static bool has_set_username = false; - static bool rarch_is_inited = false; - static bool rarch_error_on_init = false; - static bool rarch_block_config_read = false; - static bool rarch_force_fullscreen = false; settings_t *settings = config_get_ptr(); switch(state) @@ -1214,19 +1239,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) return true; } -static bool has_set_verbosity = false; -static bool has_set_libretro = false; -static bool has_set_libretro_directory = false; -static bool has_set_save_path = false; -static bool has_set_state_path = false; -static bool has_set_netplay_mode = false; -static bool has_set_netplay_ip_address = false; -static bool has_set_netplay_ip_port = false; -static bool has_set_netplay_delay_frames= false; -static bool has_set_netplay_check_frames= false; -static bool has_set_ups_pref = false; -static bool has_set_bps_pref = false; -static bool has_set_ips_pref = false; bool retroarch_override_setting_is_set(enum rarch_override_setting enum_idx) { From 16289a86226c11fc13e7380595bf836fc89e00a3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 14:25:29 +0200 Subject: [PATCH 229/334] Cleanup --- runloop.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runloop.c b/runloop.c index 38969dd04c..ae9db94d32 100644 --- a/runloop.c +++ b/runloop.c @@ -886,7 +886,8 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) } break; case RUNLOOP_CTL_FRAME_TIME_FREE: - memset(&runloop_frame_time, 0, sizeof(struct retro_frame_time_callback)); + memset(&runloop_frame_time, 0, + sizeof(struct retro_frame_time_callback)); runloop_frame_time_last = 0; runloop_max_frames = 0; break; From 5a80e31e5d47f61fa1442a16010b5e85160ba195 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 14:31:39 +0200 Subject: [PATCH 230/334] paths.c - cleanups --- paths.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/paths.c b/paths.c index 45b5240f70..df96b60db8 100644 --- a/paths.c +++ b/paths.c @@ -57,12 +57,17 @@ void path_set_redirect(void) global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); rarch_system_info_t *info = NULL; + const char *old_savefile_dir = NULL; + const char *old_savestate_dir = NULL; runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (!global) return; + old_savefile_dir = global->dir.savefile; + old_savestate_dir = global->dir.savestate; + if (info->info.library_name && !string_is_empty(info->info.library_name)) global_library_name_hash = @@ -71,10 +76,10 @@ void path_set_redirect(void) /* Initialize current save directories * with the values from the config. */ strlcpy(current_savefile_dir, - global->dir.savefile, + old_savefile_dir, sizeof(current_savefile_dir)); strlcpy(current_savestate_dir, - global->dir.savestate, + old_savestate_dir, sizeof(current_savestate_dir)); check_global_library_name_hash = (global_library_name_hash != 0); @@ -87,13 +92,13 @@ void path_set_redirect(void) { /* per-core saves: append the library_name to the save location */ if (settings->sort_savefiles_enable - && !string_is_empty(global->dir.savefile)) + && !string_is_empty(old_savefile_dir)) { fill_pathname_join( current_savefile_dir, - global->dir.savefile, + old_savefile_dir, info->info.library_name, - sizeof(global->dir.savefile)); + sizeof(current_savefile_dir)); /* If path doesn't exist, try to create it, * if everything fails revert to the original path. */ @@ -105,10 +110,10 @@ void path_set_redirect(void) { RARCH_LOG("%s %s\n", msg_hash_to_str(MSG_REVERTING_SAVEFILE_DIRECTORY_TO), - global->dir.savefile); + old_savefile_dir); strlcpy(current_savefile_dir, - global->dir.savefile, + old_savefile_dir, sizeof(current_savefile_dir)); } } @@ -116,13 +121,13 @@ void path_set_redirect(void) /* per-core states: append the library_name to the save location */ if (settings->sort_savestates_enable - && !string_is_empty(global->dir.savestate)) + && !string_is_empty(old_savestate_dir)) { fill_pathname_join( current_savestate_dir, - global->dir.savestate, + old_savestate_dir, info->info.library_name, - sizeof(global->dir.savestate)); + sizeof(current_savestate_dir)); /* If path doesn't exist, try to create it. * If everything fails, revert to the original path. */ @@ -134,9 +139,9 @@ void path_set_redirect(void) { RARCH_LOG("%s %s\n", msg_hash_to_str(MSG_REVERTING_SAVESTATE_DIRECTORY_TO), - global->dir.savestate); + old_savestate_dir); strlcpy(current_savestate_dir, - global->dir.savestate, + old_savestate_dir, sizeof(current_savestate_dir)); } } From ad6da2d45fa6556a67747fb4a5f1c53c02932a8d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 14:36:36 +0200 Subject: [PATCH 231/334] Remove stray variable --- paths.c | 1 - 1 file changed, 1 deletion(-) diff --git a/paths.c b/paths.c index df96b60db8..357ad83c8c 100644 --- a/paths.c +++ b/paths.c @@ -151,7 +151,6 @@ void path_set_redirect(void) /* Set savefile directory if empty based on content directory */ if (string_is_empty(current_savefile_dir)) { - global_t *global = global_get_ptr(); strlcpy(current_savefile_dir, global->name.base, sizeof(current_savefile_dir)); path_basedir(current_savefile_dir); From 6bd6245f0a75e02f6d1f54d5ff36decce9db7a9b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 14:41:49 +0200 Subject: [PATCH 232/334] Move path_clear_all call --- runloop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runloop.c b/runloop.c index ae9db94d32..3e17ba2b4e 100644 --- a/runloop.c +++ b/runloop.c @@ -745,7 +745,6 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) runloop_frontend_key_event = NULL; audio_driver_unset_callback(); - path_clear_all(); memset(&runloop_system, 0, sizeof(rarch_system_info_t)); break; case RUNLOOP_CTL_SET_FRAME_TIME_LAST: @@ -916,6 +915,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) core_unset_input_descriptors(); global = global_get_ptr(); + path_clear_all(); memset(global, 0, sizeof(struct global)); retroarch_override_setting_free_state(); config_free_state(); From 1a554cf1bcaaad766ec7de70a2e1eb043ffcaae9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 14:44:19 +0200 Subject: [PATCH 233/334] Add dirs.c --- Makefile.common | 1 + dirs.c | 28 ++++++++++++++++++++++++++++ dirs.h | 26 ++++++++++++++++++++++++++ griffin/griffin.c | 1 + 4 files changed, 56 insertions(+) create mode 100644 dirs.c create mode 100644 dirs.h diff --git a/Makefile.common b/Makefile.common index 52aad9b2cf..9ee8934c3a 100644 --- a/Makefile.common +++ b/Makefile.common @@ -132,6 +132,7 @@ OBJ += frontend/frontend.o \ ui/drivers/null/ui_null_application.o \ core_impl.o \ retroarch.o \ + dirs.o \ paths.o \ input/input_keyboard.o \ command.o \ diff --git a/dirs.c b/dirs.c new file mode 100644 index 0000000000..3db92fb660 --- /dev/null +++ b/dirs.c @@ -0,0 +1,28 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2011-2016 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "dirs.h" diff --git a/dirs.h b/dirs.h new file mode 100644 index 0000000000..b1e01582ae --- /dev/null +++ b/dirs.h @@ -0,0 +1,26 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2011-2016 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#ifndef __DIRS_H +#define __DIRS_H + +#include +#include + +RETRO_BEGIN_DECLS + +RETRO_END_DECLS + +#endif diff --git a/griffin/griffin.c b/griffin/griffin.c index 939740d40c..248e56f934 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -797,6 +797,7 @@ RETROARCH ============================================================ */ #include "../core_impl.c" #include "../retroarch.c" +#include "../dirs.c" #include "../paths.c" #include "../runloop.c" #include "../libretro-common/queues/task_queue.c" From 4d317ba5d7a5dad493a9acafc189310309d78f4f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 14:49:35 +0200 Subject: [PATCH 234/334] Update dirs.c --- configuration.c | 24 ++++++++++++------------ dirs.c | 24 ++++++++++++++++++++++++ dirs.h | 6 ++++++ retroarch.c | 7 +++---- runloop.c | 2 ++ 5 files changed, 47 insertions(+), 16 deletions(-) diff --git a/configuration.c b/configuration.c index 94d22b5b0d..9031ecaf36 100644 --- a/configuration.c +++ b/configuration.c @@ -38,6 +38,7 @@ #include "input/input_remapping.h" #include "defaults.h" #include "core.h" +#include "dirs.h" #include "paths.h" #include "retroarch.h" #include "runloop.h" @@ -1279,12 +1280,12 @@ static void config_set_defaults(void) if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_STATE_PATH) && !string_is_empty(g_defaults.dir.savestate)) - strlcpy(global->dir.savestate, - g_defaults.dir.savestate, sizeof(global->dir.savestate)); + dir_set_savestate(g_defaults.dir.savestate); + if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH) && !string_is_empty(g_defaults.dir.sram)) - strlcpy(global->dir.savefile, - g_defaults.dir.sram, sizeof(global->dir.savefile)); + dir_set_savefile(g_defaults.dir.sram); + if (!string_is_empty(g_defaults.dir.system)) strlcpy(settings->directory.system, g_defaults.dir.system, sizeof(settings->directory.system)); @@ -2060,12 +2061,12 @@ static bool config_load_file(const char *path, bool set_defaults, config_get_path(conf, "savefile_directory", tmp_str, sizeof(tmp_str))) { if (string_is_equal(tmp_str, "default")) - strlcpy(global->dir.savefile, g_defaults.dir.sram, - sizeof(global->dir.savefile)); + dir_set_savefile(g_defaults.dir.sram); + else if (path_is_directory(tmp_str)) { - strlcpy(global->dir.savefile, tmp_str, - sizeof(global->dir.savefile)); + dir_set_savefile(tmp_str); + strlcpy(global->name.savefile, tmp_str, sizeof(global->name.savefile)); fill_pathname_dir(global->name.savefile, @@ -2081,12 +2082,11 @@ static bool config_load_file(const char *path, bool set_defaults, config_get_path(conf, "savestate_directory", tmp_str, sizeof(tmp_str))) { if (string_is_equal(tmp_str, "default")) - strlcpy(global->dir.savestate, g_defaults.dir.savestate, - sizeof(global->dir.savestate)); + dir_set_savestate(g_defaults.dir.savestate); else if (path_is_directory(tmp_str)) { - strlcpy(global->dir.savestate, tmp_str, - sizeof(global->dir.savestate)); + dir_set_savestate(tmp_str); + strlcpy(global->name.savestate, tmp_str, sizeof(global->name.savestate)); fill_pathname_dir(global->name.savestate, diff --git a/dirs.c b/dirs.c index 3db92fb660..d887c9442c 100644 --- a/dirs.c +++ b/dirs.c @@ -26,3 +26,27 @@ #endif #include "dirs.h" + +#include "runloop.h" + +void dir_set_savestate(const char *path) +{ + global_t *global = global_get_ptr(); + + if (global) + strlcpy(global->dir.savestate, global->name.savefile, + sizeof(global->dir.savestate)); +} + +void dir_set_savefile(const char *path) +{ + global_t *global = global_get_ptr(); + + if (global) + strlcpy(global->dir.savefile, global->name.savefile, + sizeof(global->dir.savefile)); +} + +void dir_clear_all(void) +{ +} diff --git a/dirs.h b/dirs.h index b1e01582ae..2b6ccca3f3 100644 --- a/dirs.h +++ b/dirs.h @@ -21,6 +21,12 @@ RETRO_BEGIN_DECLS +void dir_set_savefile(const char *path); + +void dir_set_savestate(const char *path); + +void dir_clear_all(void); + RETRO_END_DECLS #endif diff --git a/retroarch.c b/retroarch.c index 5915c61934..12b6b7c9d2 100644 --- a/retroarch.c +++ b/retroarch.c @@ -64,6 +64,7 @@ #include "driver.h" #include "msg_hash.h" #include "movie.h" +#include "dirs.h" #include "paths.h" #include "file_path_special.h" #include "verbosity.h" @@ -857,13 +858,11 @@ static void retroarch_parse_input(int argc, char *argv[]) /* Copy SRM/state dirs used, so they can be reused on reentrancy. */ if (retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH) && path_is_directory(global->name.savefile)) - strlcpy(global->dir.savefile, global->name.savefile, - sizeof(global->dir.savefile)); + dir_set_savefile(global->name.savefile); if (retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_STATE_PATH) && path_is_directory(global->name.savestate)) - strlcpy(global->dir.savestate, global->name.savestate, - sizeof(global->dir.savestate)); + dir_set_savestate(global->name.savestate); } static bool retroarch_init_state(void) diff --git a/runloop.c b/runloop.c index 3e17ba2b4e..75a0e57c8a 100644 --- a/runloop.c +++ b/runloop.c @@ -61,6 +61,7 @@ #include "configuration.h" #include "driver.h" #include "movie.h" +#include "dirs.h" #include "paths.h" #include "retroarch.h" #include "runloop.h" @@ -916,6 +917,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) global = global_get_ptr(); path_clear_all(); + dir_clear_all(); memset(global, 0, sizeof(struct global)); retroarch_override_setting_free_state(); config_free_state(); From 017d05fd36820e9817dea0993e184bb2b19dd48a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 14:53:30 +0200 Subject: [PATCH 235/334] Create more dirs functions --- configuration.c | 8 ++++---- dirs.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ dirs.h | 12 ++++++++++++ 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/configuration.c b/configuration.c index 9031ecaf36..28dfeacd61 100644 --- a/configuration.c +++ b/configuration.c @@ -637,9 +637,9 @@ static int populate_settings_path(settings_t *settings, struct config_path_setti SETTING_PATH("audio_filter_dir", settings->directory.audio_filter, true, NULL, true); SETTING_PATH("savefile_directory", - global->dir.savefile, true, NULL, false); + dir_get_savefile_ptr(), true, NULL, false); SETTING_PATH("savestate_directory", - global->dir.savestate, true, NULL, false); + dir_get_savestate_ptr(), true, NULL, false); #ifdef HAVE_MENU SETTING_PATH("rgui_browser_directory", settings->directory.menu_content, true, NULL, true); @@ -1119,9 +1119,9 @@ static void config_set_defaults(void) /* Make sure settings from other configs carry over into defaults * for another config. */ if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH)) - *global->dir.savefile = '\0'; + dir_clear_savefile(); if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_STATE_PATH)) - *global->dir.savestate = '\0'; + dir_clear_savestate(); *settings->path.libretro_info = '\0'; if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_LIBRETRO_DIRECTORY)) diff --git a/dirs.c b/dirs.c index d887c9442c..b975f0989e 100644 --- a/dirs.c +++ b/dirs.c @@ -29,6 +29,58 @@ #include "runloop.h" +void dir_clear_savefile(void) +{ + global_t *global = global_get_ptr(); + + if (global) + *global->dir.savefile = '\0'; +} + +void dir_clear_savestate(void) +{ + global_t *global = global_get_ptr(); + + if (global) + *global->dir.savestate = '\0'; +} + +char *dir_get_savefile_ptr(void) +{ + global_t *global = global_get_ptr(); + + if (!global) + return NULL; + return global->dir.savefile; +} + +const char *dir_get_savefile(void) +{ + global_t *global = global_get_ptr(); + + if (!global) + return NULL; + return global->dir.savefile; +} + +char *dir_get_savestate_ptr(void) +{ + global_t *global = global_get_ptr(); + + if (!global) + return NULL; + return global->dir.savestate; +} + +const char *dir_get_savestate(void) +{ + global_t *global = global_get_ptr(); + + if (!global) + return NULL; + return global->dir.savestate; +} + void dir_set_savestate(const char *path) { global_t *global = global_get_ptr(); diff --git a/dirs.h b/dirs.h index 2b6ccca3f3..7537371084 100644 --- a/dirs.h +++ b/dirs.h @@ -21,6 +21,18 @@ RETRO_BEGIN_DECLS +void dir_clear_savefile(void); + +void dir_clear_savestate(void); + +char *dir_get_savefile_ptr(void); + +const char *dir_get_savefile(void); + +char *dir_get_savestate_ptr(void); + +const char *dir_get_savestate(void); + void dir_set_savefile(const char *path); void dir_set_savestate(const char *path); From 413d14ad49ca84f8c6b44c9be0353c9e42e05e2d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 14:57:53 +0200 Subject: [PATCH 236/334] Start using dirs functions --- menu/menu_setting.c | 5 +++-- paths.c | 9 +++++---- tasks/task_content.c | 5 +++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 4d615d4245..2c8d7e9f40 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -56,6 +56,7 @@ #include "../msg_hash.h" #include "../defaults.h" #include "../driver.h" +#include "../dirs.h" #include "../paths.h" #include "../dynamic.h" #include "../runloop.h" @@ -6544,7 +6545,7 @@ static bool setting_append_list( CONFIG_DIR( list, list_info, - global->dir.savefile, + dir_get_savefile_ptr(), sizeof(global->dir.savefile), msg_hash_to_str(MENU_ENUM_LABEL_SAVEFILE_DIRECTORY), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SAVEFILE_DIRECTORY), @@ -6559,7 +6560,7 @@ static bool setting_append_list( CONFIG_DIR( list, list_info, - global->dir.savestate, + dir_get_savestate_ptr(), sizeof(global->dir.savestate), msg_hash_to_str(MENU_ENUM_LABEL_SAVESTATE_DIRECTORY), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SAVESTATE_DIRECTORY), diff --git a/paths.c b/paths.c index 357ad83c8c..19c9622838 100644 --- a/paths.c +++ b/paths.c @@ -25,6 +25,7 @@ #include "config.h" #endif +#include "dirs.h" #include "paths.h" #include "configuration.h" @@ -65,8 +66,8 @@ void path_set_redirect(void) if (!global) return; - old_savefile_dir = global->dir.savefile; - old_savestate_dir = global->dir.savestate; + old_savefile_dir = dir_get_savefile(); + old_savestate_dir = dir_get_savestate(); if (info->info.library_name && !string_is_empty(info->info.library_name)) @@ -307,7 +308,7 @@ void path_init_savefile(void) global->subsystem_fullpaths ? global->subsystem_fullpaths->size : 0); - bool use_sram_dir = path_is_directory(global->dir.savefile); + bool use_sram_dir = path_is_directory(dir_get_savefile()); for (i = 0; i < num_content; i++) { @@ -325,7 +326,7 @@ void path_init_savefile(void) if (use_sram_dir) { /* Redirect content fullpath to save directory. */ - strlcpy(path, global->dir.savefile, sizeof(path)); + strlcpy(path, dir_get_savefile(), sizeof(path)); fill_pathname_dir(path, global->subsystem_fullpaths->elems[i].data, ext, sizeof(path)); diff --git a/tasks/task_content.c b/tasks/task_content.c index 1ce411cd40..0635255068 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -86,6 +86,7 @@ #include "../retroarch.h" #include "../file_path_special.h" #include "../core.h" +#include "../dirs.h" #include "../paths.h" #include "../verbosity.h" @@ -1608,9 +1609,9 @@ static void menu_content_environment_get(int *argc, char *argv[], if (!path_is_config_empty()) wrap_args->config_path = path_get_config(); if (!string_is_empty(global->dir.savefile)) - wrap_args->sram_path = global->dir.savefile; + wrap_args->sram_path = dir_get_savefile(); if (!string_is_empty(global->dir.savestate)) - wrap_args->state_path = global->dir.savestate; + wrap_args->state_path = dir_get_savestate(); if (fullpath && *fullpath) wrap_args->content_path = fullpath; if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_LIBRETRO)) From 8c451ac71f0cd31f4bb9658bde811fe69ae1bdfd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 14:59:51 +0200 Subject: [PATCH 237/334] Create dir_is_savefile_empty/dir_is_savestate_empty --- dirs.c | 18 ++++++++++++++++++ dirs.h | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/dirs.c b/dirs.c index b975f0989e..e5c0f3c209 100644 --- a/dirs.c +++ b/dirs.c @@ -29,6 +29,24 @@ #include "runloop.h" +bool dir_is_savefile_empty(void) +{ + global_t *global = global_get_ptr(); + + if (!global) + return false; + return string_is_empty(global->dir.savefile); +} + +bool dir_is_savestate_empty(void) +{ + global_t *global = global_get_ptr(); + + if (!global) + return false; + return string_is_empty(global->dir.savestate); +} + void dir_clear_savefile(void) { global_t *global = global_get_ptr(); diff --git a/dirs.h b/dirs.h index 7537371084..41fa9f654b 100644 --- a/dirs.h +++ b/dirs.h @@ -21,6 +21,10 @@ RETRO_BEGIN_DECLS +bool dir_is_savefile_empty(void); + +bool dir_is_savestate_empty(void); + void dir_clear_savefile(void); void dir_clear_savestate(void); From b775ee303c2f2b9e788c2d2db660c31257dd221b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 15:01:32 +0200 Subject: [PATCH 238/334] Use dir_is_savefile_empty/dir_is_savestate_empty --- tasks/task_content.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tasks/task_content.c b/tasks/task_content.c index 0635255068..236f759def 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -1587,7 +1587,6 @@ static void menu_content_environment_get(int *argc, char *argv[], { char *fullpath = NULL; struct rarch_main_wrap *wrap_args = (struct rarch_main_wrap*)params_data; - global_t *global = global_get_ptr(); if (!wrap_args) return; @@ -1608,9 +1607,9 @@ static void menu_content_environment_get(int *argc, char *argv[], if (!path_is_config_empty()) wrap_args->config_path = path_get_config(); - if (!string_is_empty(global->dir.savefile)) + if (!dir_is_savefile_empty()) wrap_args->sram_path = dir_get_savefile(); - if (!string_is_empty(global->dir.savestate)) + if (!dir_is_savestate_empty()) wrap_args->state_path = dir_get_savestate(); if (fullpath && *fullpath) wrap_args->content_path = fullpath; From 2f6459fa9c6863003b713487aaa70b34ec2e1e97 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 15:05:28 +0200 Subject: [PATCH 239/334] (GX) Buildfix --- frontend/drivers/platform_gx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index 392cf9e479..4590fecb80 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -65,6 +65,7 @@ static enum frontend_fork gx_fork_mode = FRONTEND_FORK_NONE; #endif #ifndef IS_SALAMANDER +#include "../../paths.h" enum { @@ -414,7 +415,7 @@ static void frontend_gx_process_args(int *argc, char *argv[]) /* A big hack: sometimes Salamander doesn't save the new core * it loads on first boot, so we make sure * active core path is set here. */ - if (config_active_core_path_is_empty() && *argc >= 1 && strrchr(argv[0], '/')) + if (path_is_core_empty() && *argc >= 1 && strrchr(argv[0], '/')) { char path[PATH_MAX_LENGTH] = {0}; strlcpy(path, strrchr(argv[0], '/') + 1, sizeof(path)); From 12949420b68bb399e81243302946a725138e01fa Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 15:07:45 +0200 Subject: [PATCH 240/334] (Windows) Buildfix --- gfx/common/win32_common.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index 8672b143c8..0ea3b22de8 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -25,6 +25,7 @@ #include "../../configuration.h" #include "../../verbosity.h" #include "../../driver.h" +#include "../../paths.h" #include "../../runloop.h" #include "../../tasks/tasks_internal.h" #include "../../core_info.h" @@ -287,7 +288,7 @@ static int win32_drag_query_file(HWND hwnd, WPARAM wparam) runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH,szFilename); - if (!string_is_empty(config_get_active_core_path())) + if (!path_is_core_empty()) { unsigned i; core_info_t *current_core = NULL; @@ -301,7 +302,7 @@ static int win32_drag_query_file(HWND hwnd, WPARAM wparam) if(!string_is_equal(info->systemname, current_core->systemname)) break; - if(string_is_equal(config_get_active_core_path(), info->path)) + if(string_is_equal(path_get_core(), info->path)) { /* Our previous core supports the current rom */ content_ctx_info_t content_info = {0}; From 0c48555ba27ecac4ed2111f77953bee3f063f5c4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 15:16:52 +0200 Subject: [PATCH 241/334] Move rarch_content_type to paths.h --- paths.h | 8 ++++++++ retroarch.h | 10 ---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/paths.h b/paths.h index 3edebe37ac..43f86c13ab 100644 --- a/paths.h +++ b/paths.h @@ -21,6 +21,14 @@ RETRO_BEGIN_DECLS +enum rarch_content_type +{ + RARCH_CONTENT_NONE = 0, + RARCH_CONTENT_MOVIE, + RARCH_CONTENT_MUSIC, + RARCH_CONTENT_IMAGE +}; + void path_init_savefile(void); void path_fill_names(void); diff --git a/retroarch.h b/retroarch.h index 5835e2900f..69c4b20905 100644 --- a/retroarch.h +++ b/retroarch.h @@ -83,14 +83,6 @@ enum rarch_ctl_state }; -enum rarch_content_type -{ - RARCH_CONTENT_NONE = 0, - RARCH_CONTENT_MOVIE, - RARCH_CONTENT_MUSIC, - RARCH_CONTENT_IMAGE -}; - enum rarch_capabilities { RARCH_CAPABILITIES_NONE = 0, @@ -146,8 +138,6 @@ void retroarch_override_setting_free_state(void); bool retroarch_override_setting_is_set(enum rarch_override_setting enum_idx); -enum rarch_content_type retroarch_path_is_media_type(const char *path); - const char *retroarch_get_current_savefile_dir(void); bool retroarch_validate_game_options(char *s, size_t len, bool mkdir); From f8a4f44b3b0ec7331136461932e24713e7b1513a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 15:25:04 +0200 Subject: [PATCH 242/334] Add dir_get_savestate_size / dir_get_savefile_size --- dirs.c | 18 ++++++++++++++++++ dirs.h | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/dirs.c b/dirs.c index e5c0f3c209..0a86e9cfa2 100644 --- a/dirs.c +++ b/dirs.c @@ -47,6 +47,24 @@ bool dir_is_savestate_empty(void) return string_is_empty(global->dir.savestate); } +size_t dir_get_savestate_size(void) +{ + global_t *global = global_get_ptr(); + + if (!global) + return 0; + return sizeof(global->dir.savestate); +} + +size_t dir_get_savefile_size(void) +{ + global_t *global = global_get_ptr(); + + if (!global) + return 0; + return sizeof(global->dir.savefile); +} + void dir_clear_savefile(void) { global_t *global = global_get_ptr(); diff --git a/dirs.h b/dirs.h index 41fa9f654b..bb6757d25a 100644 --- a/dirs.h +++ b/dirs.h @@ -41,6 +41,10 @@ void dir_set_savefile(const char *path); void dir_set_savestate(const char *path); +size_t dir_get_savestate_size(void); + +size_t dir_get_savefile_size(void); + void dir_clear_all(void); RETRO_END_DECLS From baf2862b8505a8ec6c8fc8a4326d270795f124cc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 15:25:46 +0200 Subject: [PATCH 243/334] Use dir_get_savefile_size/dir_get_savestate_size --- menu/menu_setting.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 2c8d7e9f40..ff4d37eab8 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -6546,7 +6546,7 @@ static bool setting_append_list( CONFIG_DIR( list, list_info, dir_get_savefile_ptr(), - sizeof(global->dir.savefile), + dir_get_savefile_size(), msg_hash_to_str(MENU_ENUM_LABEL_SAVEFILE_DIRECTORY), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SAVEFILE_DIRECTORY), "", @@ -6561,7 +6561,7 @@ static bool setting_append_list( CONFIG_DIR( list, list_info, dir_get_savestate_ptr(), - sizeof(global->dir.savestate), + dir_get_savestate_size(), msg_hash_to_str(MENU_ENUM_LABEL_SAVESTATE_DIRECTORY), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SAVESTATE_DIRECTORY), "", From edb3edfef1ac71a47fbd4c16dcb24fa2f8cd1479 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 15:29:38 +0200 Subject: [PATCH 244/334] Don't use global state anymore for dirs --- dirs.c | 77 +++++++++++++------------------------------------------ runloop.h | 2 -- 2 files changed, 18 insertions(+), 61 deletions(-) diff --git a/dirs.c b/dirs.c index 0a86e9cfa2..b1d3ebdb53 100644 --- a/dirs.c +++ b/dirs.c @@ -27,114 +27,73 @@ #include "dirs.h" -#include "runloop.h" +static char dir_savefile[PATH_MAX_LENGTH] = {0}; +static char dir_savestate[PATH_MAX_LENGTH] = {0}; bool dir_is_savefile_empty(void) { - global_t *global = global_get_ptr(); - - if (!global) - return false; - return string_is_empty(global->dir.savefile); + return string_is_empty(dir_savefile); } bool dir_is_savestate_empty(void) { - global_t *global = global_get_ptr(); - - if (!global) - return false; - return string_is_empty(global->dir.savestate); + return string_is_empty(dir_savestate); } size_t dir_get_savestate_size(void) { - global_t *global = global_get_ptr(); - - if (!global) - return 0; - return sizeof(global->dir.savestate); + return sizeof(dir_savestate); } size_t dir_get_savefile_size(void) { - global_t *global = global_get_ptr(); - - if (!global) - return 0; - return sizeof(global->dir.savefile); + return sizeof(dir_savefile); } void dir_clear_savefile(void) { - global_t *global = global_get_ptr(); - - if (global) - *global->dir.savefile = '\0'; + *dir_savefile = '\0'; } void dir_clear_savestate(void) { - global_t *global = global_get_ptr(); - - if (global) - *global->dir.savestate = '\0'; + *dir_savestate = '\0'; } char *dir_get_savefile_ptr(void) { - global_t *global = global_get_ptr(); - - if (!global) - return NULL; - return global->dir.savefile; + return dir_savefile; } const char *dir_get_savefile(void) { - global_t *global = global_get_ptr(); - - if (!global) - return NULL; - return global->dir.savefile; + return dir_savefile; } char *dir_get_savestate_ptr(void) { - global_t *global = global_get_ptr(); - - if (!global) - return NULL; - return global->dir.savestate; + return dir_savestate; } const char *dir_get_savestate(void) { - global_t *global = global_get_ptr(); - - if (!global) - return NULL; - return global->dir.savestate; + return dir_savestate; } void dir_set_savestate(const char *path) { - global_t *global = global_get_ptr(); - - if (global) - strlcpy(global->dir.savestate, global->name.savefile, - sizeof(global->dir.savestate)); + strlcpy(dir_savestate, path, + sizeof(dir_savestate)); } void dir_set_savefile(const char *path) { - global_t *global = global_get_ptr(); - - if (global) - strlcpy(global->dir.savefile, global->name.savefile, - sizeof(global->dir.savefile)); + strlcpy(dir_savefile, path, + sizeof(dir_savefile)); } void dir_clear_all(void) { + dir_clear_savefile(); + dir_clear_savestate(); } diff --git a/runloop.h b/runloop.h index 0095427b1f..b33eb8968e 100644 --- a/runloop.h +++ b/runloop.h @@ -143,8 +143,6 @@ enum runloop_ctl_state typedef struct rarch_dir { /* Used on reentrancy to use a savestate dir. */ - char savefile[PATH_MAX_LENGTH]; - char savestate[PATH_MAX_LENGTH]; char systemdir[PATH_MAX_LENGTH]; #ifdef HAVE_OVERLAY char osk_overlay[PATH_MAX_LENGTH]; From 63270de821a70fc17533d24c9413495f257fe2fb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 16:10:49 +0200 Subject: [PATCH 245/334] Create dir_system functions --- dirs.c | 28 ++++++++++++++++++++++++++++ dirs.h | 10 ++++++++++ 2 files changed, 38 insertions(+) diff --git a/dirs.c b/dirs.c index b1d3ebdb53..a42784bc58 100644 --- a/dirs.c +++ b/dirs.c @@ -27,9 +27,15 @@ #include "dirs.h" +static char dir_system[PATH_MAX_LENGTH] = {0}; static char dir_savefile[PATH_MAX_LENGTH] = {0}; static char dir_savestate[PATH_MAX_LENGTH] = {0}; +bool dir_is_system_empty(void) +{ + return string_is_empty(dir_savefile); +} + bool dir_is_savefile_empty(void) { return string_is_empty(dir_savefile); @@ -40,6 +46,11 @@ bool dir_is_savestate_empty(void) return string_is_empty(dir_savestate); } +size_t dir_get_system_size(void) +{ + return sizeof(dir_system); +} + size_t dir_get_savestate_size(void) { return sizeof(dir_savestate); @@ -50,6 +61,11 @@ size_t dir_get_savefile_size(void) return sizeof(dir_savefile); } +void dir_clear_system(void) +{ + *dir_system = '\0'; +} + void dir_clear_savefile(void) { *dir_savefile = '\0'; @@ -65,6 +81,11 @@ char *dir_get_savefile_ptr(void) return dir_savefile; } +const char *dir_get_system(void) +{ + return dir_system; +} + const char *dir_get_savefile(void) { return dir_savefile; @@ -80,6 +101,12 @@ const char *dir_get_savestate(void) return dir_savestate; } +void dir_set_system(const char *path) +{ + strlcpy(dir_system, path, + sizeof(dir_system)); +} + void dir_set_savestate(const char *path) { strlcpy(dir_savestate, path, @@ -94,6 +121,7 @@ void dir_set_savefile(const char *path) void dir_clear_all(void) { + dir_clear_system(); dir_clear_savefile(); dir_clear_savestate(); } diff --git a/dirs.h b/dirs.h index bb6757d25a..3550f66b44 100644 --- a/dirs.h +++ b/dirs.h @@ -25,6 +25,10 @@ bool dir_is_savefile_empty(void); bool dir_is_savestate_empty(void); +bool dir_is_system_empty(void); + +void dir_clear_system(void); + void dir_clear_savefile(void); void dir_clear_savestate(void); @@ -37,10 +41,16 @@ char *dir_get_savestate_ptr(void); const char *dir_get_savestate(void); +const char *dir_get_system(void); + void dir_set_savefile(const char *path); void dir_set_savestate(const char *path); +void dir_set_system(const char *path); + +size_t dir_get_system_size(void); + size_t dir_get_savestate_size(void); size_t dir_get_savefile_size(void); From 4a4c613ee14e4360efe44f0f28ff5ff4cd983c63 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 16:14:25 +0200 Subject: [PATCH 246/334] Start using dir_system functions --- dirs.c | 5 +++++ dirs.h | 2 ++ dynamic.c | 11 +++++++---- runloop.h | 1 - 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/dirs.c b/dirs.c index a42784bc58..89fada36cb 100644 --- a/dirs.c +++ b/dirs.c @@ -81,6 +81,11 @@ char *dir_get_savefile_ptr(void) return dir_savefile; } +char *dir_get_system_ptr(void) +{ + return dir_system; +} + const char *dir_get_system(void) { return dir_system; diff --git a/dirs.h b/dirs.h index 3550f66b44..ef18ff1cfa 100644 --- a/dirs.h +++ b/dirs.h @@ -41,6 +41,8 @@ char *dir_get_savestate_ptr(void); const char *dir_get_savestate(void); +char *dir_get_system_ptr(void); + const char *dir_get_system(void); void dir_set_savefile(const char *path); diff --git a/dynamic.c b/dynamic.c index abd6e37c2d..b82a360c41 100644 --- a/dynamic.c +++ b/dynamic.c @@ -51,6 +51,7 @@ #include "cores/internal_cores.h" #include "frontend/frontend_driver.h" #include "content.h" +#include "dirs.h" #include "paths.h" #include "retroarch.h" #include "runloop.h" @@ -1030,15 +1031,17 @@ bool rarch_environment_cb(unsigned cmd, void *data) if (runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath) && fullpath) { + char temp_path[PATH_MAX_LENGTH] = {0}; + RARCH_WARN("SYSTEM DIR is empty, assume CONTENT DIR %s\n", fullpath); - fill_pathname_basedir(global->dir.systemdir, fullpath, - sizeof(global->dir.systemdir)); + fill_pathname_basedir(temp_path, fullpath, sizeof(temp_path)); + dir_set_system(temp_path); } - *(const char**)data = global->dir.systemdir; + *(const char**)data = dir_get_system_ptr(); RARCH_LOG("Environ SYSTEM_DIRECTORY: \"%s\".\n", - global->dir.systemdir); + dir_get_system()); } else { diff --git a/runloop.h b/runloop.h index b33eb8968e..9587b66bd3 100644 --- a/runloop.h +++ b/runloop.h @@ -143,7 +143,6 @@ enum runloop_ctl_state typedef struct rarch_dir { /* Used on reentrancy to use a savestate dir. */ - char systemdir[PATH_MAX_LENGTH]; #ifdef HAVE_OVERLAY char osk_overlay[PATH_MAX_LENGTH]; #endif From 272f045c406f8a5408339fcbfb5ff7afd337a9f4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 16:15:08 +0200 Subject: [PATCH 247/334] Get rid of unused global variable --- dynamic.c | 1 - 1 file changed, 1 deletion(-) diff --git a/dynamic.c b/dynamic.c index b82a360c41..b504844c87 100644 --- a/dynamic.c +++ b/dynamic.c @@ -940,7 +940,6 @@ bool rarch_environment_cb(unsigned cmd, void *data) { unsigned p; settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); rarch_system_info_t *system = NULL; runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); From 9852195c9300a73009fe5c886ea446f02234d9f0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 16:21:48 +0200 Subject: [PATCH 248/334] Create osk overlay dir functions --- dirs.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++----------- dirs.h | 56 ++++++++++++++++++++++++++++++++------------- 2 files changed, 99 insertions(+), 28 deletions(-) diff --git a/dirs.c b/dirs.c index 89fada36cb..3e76c4c252 100644 --- a/dirs.c +++ b/dirs.c @@ -27,9 +27,12 @@ #include "dirs.h" -static char dir_system[PATH_MAX_LENGTH] = {0}; -static char dir_savefile[PATH_MAX_LENGTH] = {0}; -static char dir_savestate[PATH_MAX_LENGTH] = {0}; +static char dir_osk_overlay[PATH_MAX_LENGTH] = {0}; +static char dir_system[PATH_MAX_LENGTH] = {0}; +static char dir_savefile[PATH_MAX_LENGTH] = {0}; +static char dir_savestate[PATH_MAX_LENGTH] = {0}; + +/* empty functions */ bool dir_is_system_empty(void) { @@ -46,6 +49,13 @@ bool dir_is_savestate_empty(void) return string_is_empty(dir_savestate); } +bool dir_is_osk_overlay_empty(void) +{ + return string_is_empty(dir_osk_overlay); +} + +/* get size functions */ + size_t dir_get_system_size(void) { return sizeof(dir_system); @@ -61,6 +71,13 @@ size_t dir_get_savefile_size(void) return sizeof(dir_savefile); } +size_t dir_get_osk_overlay_size(void) +{ + return sizeof(dir_osk_overlay); +} + +/* clear functions */ + void dir_clear_system(void) { *dir_system = '\0'; @@ -76,6 +93,26 @@ void dir_clear_savestate(void) *dir_savestate = '\0'; } +void dir_clear_osk_overlay(void) +{ + *dir_osk_overlay = '\0'; +} + +void dir_clear_all(void) +{ + dir_clear_system(); + dir_clear_osk_overlay(); + dir_clear_savefile(); + dir_clear_savestate(); +} + +/* get ptr functions */ + +char *dir_get_osk_overlay_ptr(void) +{ + return dir_osk_overlay; +} + char *dir_get_savefile_ptr(void) { return dir_savefile; @@ -86,6 +123,18 @@ char *dir_get_system_ptr(void) return dir_system; } +char *dir_get_savestate_ptr(void) +{ + return dir_savestate; +} + +/* get functions */ + +const char *dir_get_osk_overlay(void) +{ + return dir_osk_overlay; +} + const char *dir_get_system(void) { return dir_system; @@ -96,14 +145,17 @@ const char *dir_get_savefile(void) return dir_savefile; } -char *dir_get_savestate_ptr(void) +const char *dir_get_savestate(void) { return dir_savestate; } -const char *dir_get_savestate(void) +/* set functions */ + +void dir_set_osk_overlay(const char *path) { - return dir_savestate; + strlcpy(dir_osk_overlay, path, + sizeof(dir_osk_overlay)); } void dir_set_system(const char *path) @@ -123,10 +175,3 @@ void dir_set_savefile(const char *path) strlcpy(dir_savefile, path, sizeof(dir_savefile)); } - -void dir_clear_all(void) -{ - dir_clear_system(); - dir_clear_savefile(); - dir_clear_savestate(); -} diff --git a/dirs.h b/dirs.h index ef18ff1cfa..b8296c1b5b 100644 --- a/dirs.h +++ b/dirs.h @@ -21,35 +21,31 @@ RETRO_BEGIN_DECLS +/* empty functions */ + bool dir_is_savefile_empty(void); bool dir_is_savestate_empty(void); bool dir_is_system_empty(void); +bool dir_is_osk_overlay_empty(void); + +/* clear functions */ + void dir_clear_system(void); void dir_clear_savefile(void); void dir_clear_savestate(void); -char *dir_get_savefile_ptr(void); +void dir_clear_osk_overlay(void); -const char *dir_get_savefile(void); +void dir_clear_all(void); -char *dir_get_savestate_ptr(void); +/* get size functions */ -const char *dir_get_savestate(void); - -char *dir_get_system_ptr(void); - -const char *dir_get_system(void); - -void dir_set_savefile(const char *path); - -void dir_set_savestate(const char *path); - -void dir_set_system(const char *path); +size_t dir_get_osk_overlay_size(void); size_t dir_get_system_size(void); @@ -57,7 +53,37 @@ size_t dir_get_savestate_size(void); size_t dir_get_savefile_size(void); -void dir_clear_all(void); +/* get ptr functions */ + +char *dir_get_osk_overlay_ptr(void); + +char *dir_get_savefile_ptr(void); + +char *dir_get_savestate_ptr(void); + +char *dir_get_system_ptr(void); + +char *dir_get_osk_overlay_ptr(void); + +/* get functions */ + +const char *dir_get_osk_overlay(void); + +const char *dir_get_savefile(void); + +const char *dir_get_savestate(void); + +const char *dir_get_system(void); + +/* set functions */ + +void dir_set_osk_overlay(const char *path); + +void dir_set_savefile(const char *path); + +void dir_set_savestate(const char *path); + +void dir_set_system(const char *path); RETRO_END_DECLS From 5a48f32d6b1ba1b6fe93bd51cf3a81e7d551d980 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 16:28:46 +0200 Subject: [PATCH 249/334] Cleanups --- configuration.c | 26 ++++++++++++++++++-------- menu/menu_setting.c | 6 +++--- runloop.h | 10 ---------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/configuration.c b/configuration.c index 28dfeacd61..3c31c19697 100644 --- a/configuration.c +++ b/configuration.c @@ -652,7 +652,7 @@ static int populate_settings_path(settings_t *settings, struct config_path_setti #endif #ifdef HAVE_OVERLAY SETTING_PATH("osk_overlay_directory", - global->dir.osk_overlay, true, NULL, true); + dir_get_osk_overlay_ptr(), true, NULL, true); #endif #ifndef HAVE_DYNAMIC SETTING_PATH("libretro_path", @@ -1248,20 +1248,30 @@ static void config_set_defaults(void) if (!string_is_empty(g_defaults.dir.osk_overlay)) { - fill_pathname_expand_special(global->dir.osk_overlay, - g_defaults.dir.osk_overlay, sizeof(global->dir.osk_overlay)); + char temp_path[PATH_MAX_LENGTH] = {0}; + + fill_pathname_expand_special(temp_path, + g_defaults.dir.osk_overlay, sizeof(temp_path)); #ifdef RARCH_MOBILE if (string_is_empty(settings->path.osk_overlay)) fill_pathname_join(settings->path.osk_overlay, - global->dir.osk_overlay, + temp_path, "keyboards/modular-keyboard/opaque/big.cfg", sizeof(settings->path.osk_overlay)); #endif + + dir_set_osk_overlay(temp_path); } else - strlcpy(global->dir.osk_overlay, + { + char temp_path[PATH_MAX_LENGTH] = {0}; + + strlcpy(temp_path, settings->directory.overlay, - sizeof(global->dir.osk_overlay)); + sizeof(temp_path)); + + dir_set_osk_overlay(temp_path); + } #endif #ifdef HAVE_MENU if (!string_is_empty(g_defaults.dir.menu_config)) @@ -2037,8 +2047,8 @@ static bool config_load_file(const char *path, bool set_defaults, #ifdef HAVE_OVERLAY if (string_is_equal(settings->directory.overlay, "default")) *settings->directory.overlay = '\0'; - if (string_is_equal(global->dir.osk_overlay, "default")) - *global->dir.osk_overlay = '\0'; + if (string_is_equal(dir_get_osk_overlay(), "default")) + dir_clear_osk_overlay(); #endif if (string_is_equal(settings->directory.system, "default")) *settings->directory.system = '\0'; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index ff4d37eab8..080ec912ee 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -4760,7 +4760,7 @@ static bool setting_append_list( sizeof(settings->path.osk_overlay), msg_hash_to_str(MENU_ENUM_LABEL_KEYBOARD_OVERLAY_PRESET), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_KEYBOARD_OVERLAY_PRESET), - global->dir.osk_overlay, + dir_get_osk_overlay_ptr(), &group_info, &subgroup_info, parent_group, @@ -6469,8 +6469,8 @@ static bool setting_append_list( CONFIG_DIR( list, list_info, - global->dir.osk_overlay, - sizeof(global->dir.osk_overlay), + dir_get_osk_overlay_ptr(), + dir_get_osk_overlay_size(), msg_hash_to_str(MENU_ENUM_LABEL_OSK_OVERLAY_DIRECTORY), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OSK_OVERLAY_DIRECTORY), g_defaults.dir.osk_overlay, diff --git a/runloop.h b/runloop.h index 9587b66bd3..4ab7a9b418 100644 --- a/runloop.h +++ b/runloop.h @@ -140,14 +140,6 @@ enum runloop_ctl_state RUNLOOP_CTL_HTTPSERVER_DESTROY }; -typedef struct rarch_dir -{ - /* Used on reentrancy to use a savestate dir. */ -#ifdef HAVE_OVERLAY - char osk_overlay[PATH_MAX_LENGTH]; -#endif -} rarch_dir_t; - typedef struct rarch_resolution { unsigned idx; @@ -158,8 +150,6 @@ typedef struct rarch_resolution typedef struct global { - rarch_dir_t dir; - struct { bool libretro_device[MAX_USERS]; From 08862746e74eb590c9e5d897d49eed88dbac04df Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 16:31:14 +0200 Subject: [PATCH 250/334] (paths.h) Add comments --- paths.h | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/paths.h b/paths.h index 43f86c13ab..9bbb69f057 100644 --- a/paths.h +++ b/paths.h @@ -29,10 +29,16 @@ enum rarch_content_type RARCH_CONTENT_IMAGE }; +/* init functions */ + void path_init_savefile(void); +/* fill functions */ + void path_fill_names(void); +/* set functions */ + void path_set_redirect(void); void path_set_names(const char *path); @@ -49,8 +55,16 @@ void path_set_config(const char *path); void path_set_config_append(const char *path); +/* get size functions */ + +size_t path_get_core_size(void); + +/* get ptr functions */ + char *path_get_core_ptr(void); +/* get functions */ + const char *path_get_current_savefile_dir(void); const char *path_get_core(void); @@ -61,15 +75,7 @@ const char *path_get_config(void); const char *path_get_config_append(void); -size_t path_get_core_size(void); - -bool path_is_core_empty(void); - -bool path_is_config_empty(void); - -bool path_is_core_options_empty(void); - -bool path_is_config_append_empty(void); +/* clear functions */ void path_clear_core(void); @@ -81,6 +87,16 @@ void path_clear_config_append(void); void path_clear_all(void); +/* is functions */ + +bool path_is_core_empty(void); + +bool path_is_config_empty(void); + +bool path_is_core_options_empty(void); + +bool path_is_config_append_empty(void); + enum rarch_content_type path_is_media_type(const char *path); RETRO_END_DECLS From 70b10e6059c9ead859c1dddcc6340181f37d4fc9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 16:35:38 +0200 Subject: [PATCH 251/334] Get rid of HAVE_CONFIG_H ifdef in dirs.c --- dirs.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/dirs.c b/dirs.c index 3e76c4c252..eabaadf7ff 100644 --- a/dirs.c +++ b/dirs.c @@ -21,10 +21,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include "dirs.h" static char dir_osk_overlay[PATH_MAX_LENGTH] = {0}; From d53373a5cb8b3e0f6ba909a3972d9b4088865908 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Sat, 17 Sep 2016 11:24:23 -0400 Subject: [PATCH 252/334] Netplay savestate loading frontend changes Support for the frontend to inform Netplay when a savestate has been loaded, so Netplay can in turn inform the peer. --- command.c | 8 ++++++++ network/netplay/netplay.c | 23 ++++++++++++++++++----- network/netplay/netplay.h | 2 +- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/command.c b/command.c index ca4402a8a5..c5332f9b7c 100644 --- a/command.c +++ b/command.c @@ -1713,6 +1713,10 @@ static void command_event_load_state(const char *path, char *s, size_t len) return; } +#ifdef HAVE_NETPLAY + netplay_driver_ctl(RARCH_NETPLAY_CTL_LOAD_SAVESTATE, NULL); +#endif + if (settings->state_slot < 0) snprintf(s, len, "%s #-1 (auto).", msg_hash_to_str(MSG_LOADED_STATE_FROM_SLOT)); @@ -1740,6 +1744,10 @@ static void command_event_undo_load_state(char *s, size_t len) return; } +#ifdef HAVE_NETPLAY + netplay_driver_ctl(RARCH_NETPLAY_CTL_LOAD_SAVESTATE, NULL); +#endif + strlcpy(s, msg_hash_to_str(MSG_UNDID_LOAD_STATE), len); } diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index 8ae9e7a11d..8f2c2bd616 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -1170,7 +1170,7 @@ void netplay_frontend_paused(netplay_t *netplay, bool paused) /** * netplay_load_savestate * @netplay : pointer to netplay object - * @serial_info : the savestate being loaded + * @serial_info : the savestate being loaded, NULL means "load it yourself" * @save : whether to save the provided serial_info into the frame buffer * * Inform Netplay of a savestate load and send it to the other side @@ -1178,17 +1178,30 @@ void netplay_frontend_paused(netplay_t *netplay, bool paused) void netplay_load_savestate(netplay_t *netplay, retro_ctx_serialize_info_t *serial_info, bool save) { uint32_t header[3]; + retro_ctx_serialize_info_t tmp_serial_info; if (!netplay->has_connection) return; /* Record it in our own buffer */ - if (save && netplay_delta_frame_ready(netplay, &netplay->buffer[netplay->self_ptr], netplay->self_frame_count)) + if ((save || !serial_info) && netplay_delta_frame_ready(netplay, &netplay->buffer[netplay->self_ptr], netplay->self_frame_count)) { - if (serial_info->size <= netplay->state_size) + if (!serial_info) { - memcpy(netplay->buffer[netplay->self_ptr].state, - serial_info->data_const, serial_info->size); + tmp_serial_info.size = netplay->state_size; + tmp_serial_info.data = netplay->buffer[netplay->self_ptr].state; + if (!core_serialize(&tmp_serial_info)) + return; + tmp_serial_info.data_const = tmp_serial_info.data; + serial_info = &tmp_serial_info; + } + else + { + if (serial_info->size <= netplay->state_size) + { + memcpy(netplay->buffer[netplay->self_ptr].state, + serial_info->data_const, serial_info->size); + } } } diff --git a/network/netplay/netplay.h b/network/netplay/netplay.h index ecac020d55..a2bb44efba 100644 --- a/network/netplay/netplay.h +++ b/network/netplay/netplay.h @@ -187,7 +187,7 @@ void netplay_frontend_paused(netplay_t *netplay, bool paused); /** * netplay_load_savestate * @netplay : pointer to netplay object - * @serial_info : the savestate being loaded + * @serial_info : the savestate being loaded, NULL means "load it yourself" * @save : whether to save the provided serial_info into the frame buffer * * Inform Netplay of a savestate load and send it to the other side From a2a1f34fca3cb604fa84c89b2e2a9f6d92155150 Mon Sep 17 00:00:00 2001 From: gouchi Date: Sat, 17 Sep 2016 17:26:13 +0200 Subject: [PATCH 253/334] Add Coverity Scan to Travis CI --- .travis.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.travis.yml b/.travis.yml index c519643cca..406868fd86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,9 @@ script: - ./configure - make +env: + global: + - secure: "JTh3ZOkb8UhxvkVfhevS79nPfxZ50vqTxoyhDCu0GrOUlhRbwwOswoZty4RwMFu5qpSK5TDRgTYMbyEa9mmiHQSevf3gOA9hXjwjzeYldDQzfrUJ83If9Ci3U7xA7M73AW2vMo4zFNvat/EEGFsUM+z0XagMoUX52kjjrs+7x+w=" addons: apt: packages: @@ -35,3 +38,11 @@ addons: - libsdl-image1.2-dev - libsdl-mixer1.2-dev - libsdl-ttf2.0-dev + coverity_scan: + project: + name: "RetroArch" + description: "RetroArch is the official reference frontend for the libretro API." + notification_email: libretro@gmail.com + build_command_prepend: "./configure; make clean" + build_command: "make" + branch_pattern: coverity_scan From ec2fd5ebd75729469b4ebff546266bf0e7fbf3d3 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Sat, 17 Sep 2016 17:55:42 +0200 Subject: [PATCH 254/334] Fix warning --- network/netplay/netplay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index 8ae9e7a11d..6b5eadc4bc 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -792,7 +792,7 @@ static int init_tcp_connection(const struct addrinfo *res, #if defined(IPPROTO_TCP) && defined(TCP_NODELAY) { int flag = 1; - setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(int)); + setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void*)&flag, sizeof(int)); } #endif From d7e9c198e63d9f9011c2dfe564ef5bd8974d5fa3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 18:21:29 +0200 Subject: [PATCH 255/334] Cleanups to netplay --- network/netplay/netplay.c | 63 ++++++++++++++++++------------- network/netplay/netplay_private.h | 2 - 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index 8f15ec6e7a..2955c660a8 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -45,7 +45,7 @@ enum CMD_OPT_REQUIRE_SYNC = 0x10 }; -void *netplay_data; +static void *netplay_data = NULL; /** * warn_hangup: @@ -58,7 +58,8 @@ static void warn_hangup(void) runloop_msg_queue_push("Netplay has disconnected. Will continue without connection.", 0, 480, false); } -static bool netplay_info_cb(netplay_t* netplay, unsigned frames) { +static bool netplay_info_cb(netplay_t* netplay, unsigned frames) +{ return netplay->net_cbs->info_cb(netplay, frames); } @@ -97,7 +98,7 @@ static bool netplay_can_poll(netplay_t *netplay) static bool get_self_input_state(netplay_t *netplay) { uint32_t state[WORDS_PER_FRAME - 1] = {0, 0, 0}; - struct delta_frame *ptr = &netplay->buffer[netplay->self_ptr]; + struct delta_frame *ptr = &netplay->buffer[netplay->self_ptr]; if (!netplay_delta_frame_ready(netplay, ptr, netplay->self_frame_count)) return false; @@ -159,7 +160,8 @@ static bool get_self_input_state(netplay_t *netplay) if (!netplay->spectate.enabled) /* Spectate sends in its own way */ { - if (!socket_send_all_blocking(netplay->fd, netplay->packet_buffer, sizeof(netplay->packet_buffer), false)) + if (!socket_send_all_blocking(netplay->fd, + netplay->packet_buffer, sizeof(netplay->packet_buffer), false)) { warn_hangup(); netplay->has_connection = false; @@ -274,7 +276,8 @@ static bool netplay_get_cmd(netplay_t *netplay) /* The data's good! */ netplay->buffer[netplay->read_ptr].have_remote = true; - memcpy(netplay->buffer[netplay->read_ptr].real_input_state, buffer + 1, sizeof(buffer) - sizeof(uint32_t)); + memcpy(netplay->buffer[netplay->read_ptr].real_input_state, + buffer + 1, sizeof(buffer) - sizeof(uint32_t)); netplay->read_ptr = NEXT_PTR(netplay->read_ptr); netplay->read_frame_count++; return true; @@ -348,7 +351,8 @@ static bool netplay_get_cmd(netplay_t *netplay) /* Received a CRC for some frame. If we still have it, check if it * matched. This approach could be improved with some quick modular * arithmetic. */ - do { + do + { if (netplay->buffer[tmp_ptr].frame == buffer[0]) { found = true; @@ -1063,9 +1067,9 @@ error: static void netplay_flip_users(netplay_t *netplay) { /* Must be in the future because we may have already sent this frame's data */ - uint32_t flip_frame = netplay->self_frame_count + 1; + uint32_t flip_frame = netplay->self_frame_count + 1; uint32_t flip_frame_net = htonl(flip_frame); - bool command = netplay_command( + bool command = netplay_command( netplay, NETPLAY_CMD_FLIP_PLAYERS, &flip_frame_net, sizeof flip_frame_net, CMD_OPT_HOST_ONLY | CMD_OPT_REQUIRE_SYNC, @@ -1125,13 +1129,14 @@ void netplay_free(netplay_t *netplay) bool netplay_pre_frame(netplay_t *netplay) { retro_assert(netplay && netplay->net_cbs->pre_frame); + + /* FIXME: This is an ugly way to learn we're not paused anymore */ if (netplay->local_paused) - { - /* FIXME: This is an ugly way to learn we're not paused anymore */ netplay_frontend_paused(netplay, false); - } + if (!netplay->net_cbs->pre_frame(netplay)) return false; + return (!netplay->has_connection || (!netplay->stall && !netplay->remote_paused)); } @@ -1164,7 +1169,8 @@ void netplay_frontend_paused(netplay_t *netplay, bool paused) netplay->local_paused = paused; if (netplay->has_connection && !netplay->spectate.enabled) - netplay_send_raw_cmd(netplay, paused ? NETPLAY_CMD_PAUSE : NETPLAY_CMD_RESUME, NULL, 0); + netplay_send_raw_cmd(netplay, paused + ? NETPLAY_CMD_PAUSE : NETPLAY_CMD_RESUME, NULL, 0); } /** @@ -1184,23 +1190,27 @@ void netplay_load_savestate(netplay_t *netplay, retro_ctx_serialize_info_t *seri return; /* Record it in our own buffer */ - if ((save || !serial_info) && netplay_delta_frame_ready(netplay, &netplay->buffer[netplay->self_ptr], netplay->self_frame_count)) + if (save || !serial_info) { - if (!serial_info) + if (netplay_delta_frame_ready(netplay, + &netplay->buffer[netplay->self_ptr], netplay->self_frame_count)) { - tmp_serial_info.size = netplay->state_size; - tmp_serial_info.data = netplay->buffer[netplay->self_ptr].state; - if (!core_serialize(&tmp_serial_info)) - return; - tmp_serial_info.data_const = tmp_serial_info.data; - serial_info = &tmp_serial_info; - } - else - { - if (serial_info->size <= netplay->state_size) + if (!serial_info) { - memcpy(netplay->buffer[netplay->self_ptr].state, - serial_info->data_const, serial_info->size); + tmp_serial_info.size = netplay->state_size; + tmp_serial_info.data = netplay->buffer[netplay->self_ptr].state; + if (!core_serialize(&tmp_serial_info)) + return; + tmp_serial_info.data_const = tmp_serial_info.data; + serial_info = &tmp_serial_info; + } + else + { + if (serial_info->size <= netplay->state_size) + { + memcpy(netplay->buffer[netplay->self_ptr].state, + serial_info->data_const, serial_info->size); + } } } } @@ -1221,6 +1231,7 @@ void netplay_load_savestate(netplay_t *netplay, retro_ctx_serialize_info_t *seri header[0] = htonl(NETPLAY_CMD_LOAD_SAVESTATE); header[1] = htonl(serial_info->size + sizeof(uint32_t)); header[2] = htonl(netplay->self_frame_count); + if (!socket_send_all_blocking(netplay->fd, header, sizeof(header), false)) { warn_hangup(); diff --git a/network/netplay/netplay_private.h b/network/netplay/netplay_private.h index 49fe4fd280..852cf158c4 100644 --- a/network/netplay/netplay_private.h +++ b/network/netplay/netplay_private.h @@ -167,8 +167,6 @@ struct netplay struct netplay_callbacks* net_cbs; }; -extern void *netplay_data; - struct netplay_callbacks* netplay_get_cbs_net(void); struct netplay_callbacks* netplay_get_cbs_spectate(void); From bca82f7413e5251aebb9fe40491a83d92c4a0c0c Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 17 Sep 2016 11:23:59 -0500 Subject: [PATCH 256/334] use a generic globe instead of a chrome icon --- pkg/emscripten/libretro/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/emscripten/libretro/index.html b/pkg/emscripten/libretro/index.html index cf84c55ab3..70f5b9cb2d 100644 --- a/pkg/emscripten/libretro/index.html +++ b/pkg/emscripten/libretro/index.html @@ -118,7 +118,7 @@
@@ -114,18 +114,18 @@
-
+
-
@@ -136,7 +136,6 @@
- diff --git a/pkg/emscripten/libretro/libretro.js b/pkg/emscripten/libretro/libretro.js index 76205bb2f8..e34de6d80a 100644 --- a/pkg/emscripten/libretro/libretro.js +++ b/pkg/emscripten/libretro/libretro.js @@ -45,6 +45,11 @@ var showError = function(error) { } }; +function cleanupStorage() +{ + localStorage.clear(); +} + function dropboxInit() { document.getElementById('btnRun').disabled = true; @@ -329,6 +334,7 @@ $(function() { $('#lblLocal').addClass('active'); preLoadingComplete(); setupFileSystem("browser"); + document.getElementById("btnClean").disabled = false; } }); }); From 64b802b47a0953ef48495ac5e745a48d180b8c04 Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 17 Sep 2016 12:37:35 -0500 Subject: [PATCH 259/334] (ems) add to the other templates too --- pkg/emscripten/embed/embed.js | 18 +++++++++++++----- pkg/emscripten/embed/index.html | 8 ++++++-- pkg/emscripten/itch/index.html | 2 +- pkg/emscripten/itch/itch.js | 2 ++ pkg/emscripten/libretro/index.html | 2 +- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/pkg/emscripten/embed/embed.js b/pkg/emscripten/embed/embed.js index 50c285730d..2d876b2de3 100644 --- a/pkg/emscripten/embed/embed.js +++ b/pkg/emscripten/embed/embed.js @@ -3,6 +3,8 @@ * * This provides the basic JavaScript for the RetroArch web player. */ + +/* setup your key for dropbox support */ var client = new Dropbox.Client({ key: "--your-api-key--" }); var BrowserFS = browserfs; var afs; @@ -45,6 +47,12 @@ var showError = function(error) { } }; +function cleanupStorage() +{ + localStorage.clear(); + document.getElementById('btnClean').disabled = true; +} + function dropboxInit() { document.getElementById('btnRun').disabled = true; @@ -106,6 +114,9 @@ function setupFileSystem(backend) mountpoint for browserfs */ var mfs = new BrowserFS.FileSystem.MountableFileSystem(); + /* setup this if you setup your server to serve assets or core assets, + you can find more information in the included README */ + /* create an XmlHttpRequest filesystem for the bundled data uncomment this section if you want XMB assets, Overlays, Shaders, etc. var xfs1 = new BrowserFS.FileSystem.XmlHttpRequest @@ -126,11 +137,6 @@ function setupFileSystem(backend) /* mount the filesystems onto mfs */ mfs.mount('/home/web_user/retroarch/userdata', lsfs); - /* create a memory filesystem for content only - var imfs = new BrowserFS.FileSystem.InMemory();*/ - - /* mount the filesystems onto mfs - mfs.mount('/home/web_user/retroarch/userdata/content/', imfs);*/ } else { @@ -138,6 +144,8 @@ function setupFileSystem(backend) mfs.mount('/home/web_user/retroarch/userdata', afs); } + /* setup this if you setup your server to serve assets or core assets, + you can find more information in the included README */ /* mfs.mount('/home/web_user/retroarch/bundle', xfs1); mfs.mount('/home/web_user/retroarch/userdata/content/', xfs2); diff --git a/pkg/emscripten/embed/index.html b/pkg/emscripten/embed/index.html index 4dde75f28e..273eda2c21 100644 --- a/pkg/emscripten/embed/index.html +++ b/pkg/emscripten/embed/index.html @@ -89,6 +89,9 @@ + - @@ -152,7 +152,7 @@ - + diff --git a/pkg/emscripten/itch/index.html b/pkg/emscripten/itch/index.html index e9d200ceeb..db25960ae8 100644 --- a/pkg/emscripten/itch/index.html +++ b/pkg/emscripten/itch/index.html @@ -88,7 +88,7 @@ - From 29e354a3c6c72329a31da79400763952559f788e Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 17 Sep 2016 15:11:54 -0500 Subject: [PATCH 264/334] (ems) template cleanups --- pkg/emscripten/embed/index.html | 2 +- pkg/emscripten/itch/index.html | 2 +- pkg/emscripten/itch/itch.js | 6 ------ pkg/emscripten/libretro/index.html | 2 +- pkg/emscripten/libretro/libretro.js | 2 +- 5 files changed, 4 insertions(+), 10 deletions(-) diff --git a/pkg/emscripten/embed/index.html b/pkg/emscripten/embed/index.html index e061a243e8..7e9e9b5647 100644 --- a/pkg/emscripten/embed/index.html +++ b/pkg/emscripten/embed/index.html @@ -89,7 +89,7 @@ - diff --git a/pkg/emscripten/itch/index.html b/pkg/emscripten/itch/index.html index db25960ae8..96c6059319 100644 --- a/pkg/emscripten/itch/index.html +++ b/pkg/emscripten/itch/index.html @@ -88,7 +88,7 @@ - diff --git a/pkg/emscripten/itch/itch.js b/pkg/emscripten/itch/itch.js index 240980b641..fa7a0d1136 100644 --- a/pkg/emscripten/itch/itch.js +++ b/pkg/emscripten/itch/itch.js @@ -45,12 +45,6 @@ var showError = function(error) { } }; -function reload() -{ - window.top.location.reload(); - document.getElementById('btnClean').disabled = true; -} - function cleanupStorage() { localStorage.clear(); diff --git a/pkg/emscripten/libretro/index.html b/pkg/emscripten/libretro/index.html index e196fbc911..872002c4f8 100644 --- a/pkg/emscripten/libretro/index.html +++ b/pkg/emscripten/libretro/index.html @@ -87,7 +87,7 @@ - diff --git a/pkg/emscripten/libretro/libretro.js b/pkg/emscripten/libretro/libretro.js index e34de6d80a..868b96fc3a 100644 --- a/pkg/emscripten/libretro/libretro.js +++ b/pkg/emscripten/libretro/libretro.js @@ -48,6 +48,7 @@ var showError = function(error) { function cleanupStorage() { localStorage.clear(); + document.getElementById("btnClean").disabled = true; } function dropboxInit() @@ -334,7 +335,6 @@ $(function() { $('#lblLocal').addClass('active'); preLoadingComplete(); setupFileSystem("browser"); - document.getElementById("btnClean").disabled = false; } }); }); From ed326e047935e5e5e82c52d00539fabd445f6003 Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 17 Sep 2016 15:19:34 -0500 Subject: [PATCH 265/334] (ems) template fixes --- pkg/emscripten/embed/embed.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/emscripten/embed/embed.js b/pkg/emscripten/embed/embed.js index 2d876b2de3..8b0e908a00 100644 --- a/pkg/emscripten/embed/embed.js +++ b/pkg/emscripten/embed/embed.js @@ -56,9 +56,9 @@ function cleanupStorage() function dropboxInit() { document.getElementById('btnRun').disabled = true; - document.getElementById('btnDrop').disabled = true; - $('#icnDrop').removeClass('fa-dropbox'); - $('#icnDrop').addClass('fa-spinner fa-spin'); + //document.getElementById('btnDrop').disabled = true; + //$('#icnDrop').removeClass('fa-dropbox'); + //$('#icnDrop').addClass('fa-spinner fa-spin'); client.authDriver(new Dropbox.AuthDriver.Redirect()); @@ -75,8 +75,8 @@ function dropboxInit() function dropboxSyncComplete() { document.getElementById('btnRun').disabled = false; - $('#icnDrop').removeClass('fa-spinner').removeClass('fa-spin'); - $('#icnDrop').addClass('fa-check'); + //$('#icnDrop').removeClass('fa-spinner').removeClass('fa-spin'); + //$('#icnDrop').addClass('fa-check'); console.log("WEBPLAYER: Sync successful"); setupFileSystem("dropbox"); @@ -170,7 +170,7 @@ function startRetroArch() { $('.webplayer').show(); $('.webplayer-preview').hide(); - document.getElementById('btnDrop').disabled = true; + //document.getElementById('btnDrop').disabled = true; document.getElementById('btnRun').disabled = true; $('#btnFullscreen').removeClass('disabled'); From 7c40d808dfc5df5bb6f3545bc2f61b92e300360e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 17 Sep 2016 23:21:11 +0200 Subject: [PATCH 266/334] (libretro-common) Update --- libretro-common/glsm/glsm.c | 12 ++++++++++++ libretro-common/include/glsm/glsmsym.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/libretro-common/glsm/glsm.c b/libretro-common/glsm/glsm.c index fc92cb8b96..4c4546a1e0 100644 --- a/libretro-common/glsm/glsm.c +++ b/libretro-common/glsm/glsm.c @@ -1851,6 +1851,18 @@ void *rglFenceSync(GLenum condition, GLbitfield flags) #endif } +/* + * + * Core in: + * OpenGL : 3.2 + * OpenGLES : 3.0 + */ +void rglDeleteSync(GLsync sync) { +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) + glDeleteSync(sync); +#endif +} + /* * * Core in: diff --git a/libretro-common/include/glsm/glsmsym.h b/libretro-common/include/glsm/glsmsym.h index 2ef21bed99..40caa27fcc 100644 --- a/libretro-common/include/glsm/glsmsym.h +++ b/libretro-common/include/glsm/glsmsym.h @@ -161,6 +161,7 @@ RETRO_BEGIN_DECLS #define glClearBufferfi rglClearBufferfi #define glWaitSync rglWaitSync #define glFenceSync rglFenceSync +#define glDeleteSync rglDeleteSync #define glBufferStorage rglBufferStorage #define glFlushMappedBufferRange rglFlushMappedBufferRange #define glClientWaitSync rglClientWaitSync @@ -400,6 +401,7 @@ void rglTexSubImage2D( GLenum target, const GLvoid * pixels); void rglDeleteVertexArrays(GLsizei n, const GLuint *arrays); void *rglFenceSync(GLenum condition, GLbitfield flags); +void rglDeleteSync(GLsync sync); void rglWaitSync(void *sync, GLbitfield flags, uint64_t timeout); void rglBufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data, GLbitfield flags); void rglFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length); From be6bce0eb0332ebe87bc7cef93f12fa1ff399aa3 Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 17 Sep 2016 16:58:28 -0500 Subject: [PATCH 267/334] (ems) template fixes --- pkg/emscripten/embed/index.html | 9 --------- pkg/emscripten/itch/index.html | 19 ++++++------------- pkg/emscripten/libretro/index.html | 9 +-------- 3 files changed, 7 insertions(+), 30 deletions(-) diff --git a/pkg/emscripten/embed/index.html b/pkg/emscripten/embed/index.html index 7e9e9b5647..6cc4198c7a 100644 --- a/pkg/emscripten/embed/index.html +++ b/pkg/emscripten/embed/index.html @@ -17,18 +17,9 @@