From c32c98e667e352bd8f44dcab496050339d4af043 Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Sat, 17 Nov 2018 16:01:51 +0400 Subject: [PATCH 001/153] Very WIP: xdg-shell support --- Makefile.common | 10 ++ gfx/common/wayland/generate_wayland_protos.sh | 12 ++ gfx/drivers_context/wayland_ctx.c | 156 +++++++++--------- qb/config.libs.sh | 13 +- 4 files changed, 114 insertions(+), 77 deletions(-) create mode 100755 gfx/common/wayland/generate_wayland_protos.sh diff --git a/Makefile.common b/Makefile.common index 0ec1079549..4bbb694a77 100644 --- a/Makefile.common +++ b/Makefile.common @@ -858,6 +858,15 @@ ifeq ($(TARGET), retroarch_switch) endif ifeq ($(HAVE_WAYLAND), 1) + OBJ += gfx/drivers_context/wayland_ctx.o \ + input/drivers/wayland_input.o \ + gfx/common/wayland/xdg-shell.o + ifeq ($(HAVE_EGL), 1) + LIBS += $(EGL_LIBS) + endif + DEFINES += $(WAYLAND_CFLAGS) $(WAYLAND_CURSOR_CFLAGS) + LIBS += $(WAYLAND_LIBS) $(WAYLAND_CURSOR_LIBS) + OBJ += gfx/drivers_context/wayland_ctx.o \ input/drivers/wayland_input.o ifeq ($(HAVE_EGL), 1) @@ -865,6 +874,7 @@ ifeq ($(HAVE_WAYLAND), 1) endif DEFINES += $(WAYLAND_CFLAGS) $(WAYLAND_CURSOR_CFLAGS) LIBS += $(WAYLAND_LIBS) $(WAYLAND_CURSOR_LIBS) + endif #Input diff --git a/gfx/common/wayland/generate_wayland_protos.sh b/gfx/common/wayland/generate_wayland_protos.sh new file mode 100755 index 0000000000..8abc2ed1a0 --- /dev/null +++ b/gfx/common/wayland/generate_wayland_protos.sh @@ -0,0 +1,12 @@ +#!/bin/sh +WAYSCAN=/usr/bin/wayland-scanner +WAYLAND_PROTOS=/usr/share/wayland-protocols +OUTPUT=gfx/common/wayland + +if [ ! -d $OUTPUT ]; then + mkdir $OUTPUT +fi + +#Generate xdg-shell header and .c files +$WAYSCAN client-header $WAYLAND_PROTOS/stable/xdg-shell/xdg-shell.xml $OUTPUT/xdg-shell.h +$WAYSCAN private-code $WAYLAND_PROTOS/stable/xdg-shell/xdg-shell.xml $OUTPUT/xdg-shell.c diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index f22d184849..84bfcf47db 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -51,6 +51,8 @@ #include "../../input/input_driver.h" #include "../../input/input_keymaps.h" +// Generated from xdg-shell.xml +#include "../common/wayland/xdg-shell.h" typedef struct touch_pos { @@ -71,6 +73,8 @@ typedef struct gfx_ctx_wayland_data struct wl_egl_window *win; #endif bool resize; + bool fullscreen; + bool maximized; unsigned width; unsigned height; unsigned physical_width; @@ -79,8 +83,9 @@ typedef struct gfx_ctx_wayland_data struct wl_registry *registry; struct wl_compositor *compositor; struct wl_surface *surface; - struct wl_shell_surface *shell_surf; - struct wl_shell *shell; + struct xdg_surface *xdg_surface; + struct xdg_wm_base *shell; + struct xdg_toplevel *xdg_toplevel; struct wl_keyboard *wl_keyboard; struct wl_pointer *wl_pointer; struct wl_touch *wl_touch; @@ -242,7 +247,7 @@ static const struct wl_keyboard_listener keyboard_listener = { keyboard_handle_repeat_info }; -static void gfx_ctx_wl_show_mouse(void *data, bool state); +static int gfx_ctx_wl_show_mouse(void *data, bool state); static void pointer_handle_enter(void *data, struct wl_pointer *pointer, @@ -303,9 +308,6 @@ static void pointer_handle_button(void *data, { wl->input.mouse.left = true; - /* This behavior matches mpv, seems like a decent way to support window moving for now. */ - if (BIT_GET(wl->input.key_state, KEY_LEFTALT) && wl->shell_surf) - wl_shell_surface_move(wl->shell_surf, wl->seat, serial); } else if (button == BTN_RIGHT) wl->input.mouse.right = true; @@ -344,6 +346,8 @@ static const struct wl_pointer_listener pointer_listener = { pointer_handle_axis, }; +// Check for resize + static void touch_handle_down(void *data, struct wl_touch *wl_touch, uint32_t serial, @@ -542,41 +546,57 @@ bool wayland_context_gettouchpos(void *data, unsigned id, /* Shell surface callbacks. */ -static void shell_surface_handle_ping(void *data, - struct wl_shell_surface *shell_surface, - uint32_t serial) +static void xdg_shell_ping (void *data, struct xdg_wm_base *shell, uint32_t serial) { - (void)data; - wl_shell_surface_pong(shell_surface, serial); + xdg_wm_base_pong(shell, serial); +} +static const struct xdg_wm_base_listener xdg_shell_listener = { + xdg_shell_ping, +}; + +static void handle_surface_config(void *data, struct xdg_surface *surface, + uint32_t serial) +{ + xdg_surface_ack_configure(surface, serial); } -static void shell_surface_handle_configure(void *data, - struct wl_shell_surface *shell_surface, - uint32_t edges, int32_t width, int32_t height) +static const struct xdg_surface_listener xdg_surface_listener = { + handle_surface_config, +}; + +static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, + int width, int height, struct wl_array *states) { - gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; - - (void)shell_surface; - (void)edges; - - wl->width = wl->buffer_scale * width; - wl->height = wl->buffer_scale * height; - - RARCH_LOG("[Wayland]: Surface configure: %u x %u.\n", - wl->width, wl->height); + gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; + int prev_fs_state = wl->fullscreen; + wl->maximized = false; + wl->fullscreen = false; + enum xdg_toplevel_state *state; + wl_array_for_each(state, states) { + switch (*state) { + case XDG_TOPLEVEL_STATE_FULLSCREEN: + wl->fullscreen = true; + break; + case XDG_TOPLEVEL_STATE_RESIZING: + wl->resize = true; + break; + case XDG_TOPLEVEL_STATE_ACTIVATED: + break; + case XDG_TOPLEVEL_STATE_TILED_TOP: + case XDG_TOPLEVEL_STATE_TILED_LEFT: + case XDG_TOPLEVEL_STATE_TILED_RIGHT: + case XDG_TOPLEVEL_STATE_TILED_BOTTOM: + case XDG_TOPLEVEL_STATE_MAXIMIZED: + wl->maximized = true; + break; + } + } } -static void shell_surface_handle_popup_done(void *data, - struct wl_shell_surface *shell_surface) -{ - (void)data; - (void)shell_surface; -} +//TODO: Setup resize here -static const struct wl_shell_surface_listener shell_surface_listener = { - shell_surface_handle_ping, - shell_surface_handle_configure, - shell_surface_handle_popup_done, +static const struct xdg_toplevel_listener xdg_toplevel_listener = { + handle_toplevel_config, }; static void display_handle_geometry(void *data, @@ -666,12 +686,11 @@ static void registry_handle_global(void *data, struct wl_registry *reg, { output = (struct wl_output*)wl_registry_bind(reg, id, &wl_output_interface, 2); - wl_output_add_listener(output, &output_listener, wl); wl_display_roundtrip(wl->input.dpy); } - else if (string_is_equal(interface, "wl_shell")) - wl->shell = (struct wl_shell*) - wl_registry_bind(reg, id, &wl_shell_interface, 1); + else if (string_is_equal(interface, "xdg_wm_base")) + wl->shell = (struct xdg_wm_base*) + wl_registry_bind(reg, id, &xdg_wm_base_interface, 1); else if (string_is_equal(interface, "wl_shm")) wl->shm = (struct wl_shm*)wl_registry_bind(reg, id, &wl_shm_interface, 1); else if (string_is_equal(interface, "wl_seat")) @@ -752,13 +771,13 @@ static void gfx_ctx_wl_destroy_resources(gfx_ctx_wayland_data_t *wl) if (wl->seat) wl_seat_destroy(wl->seat); if (wl->shell) - wl_shell_destroy(wl->shell); + xdg_wm_base_destroy(wl->shell); if (wl->compositor) wl_compositor_destroy(wl->compositor); if (wl->registry) wl_registry_destroy(wl->registry); - if (wl->shell_surf) - wl_shell_surface_destroy(wl->shell_surf); + if (wl->xdg_surface) + xdg_surface_destroy(wl->xdg_surface); if (wl->surface) wl_surface_destroy(wl->surface); @@ -775,7 +794,7 @@ static void gfx_ctx_wl_destroy_resources(gfx_ctx_wayland_data_t *wl) wl->compositor = NULL; wl->registry = NULL; wl->input.dpy = NULL; - wl->shell_surf = NULL; + wl->xdg_surface = NULL; wl->surface = NULL; wl->width = 0; @@ -892,18 +911,18 @@ static bool gfx_ctx_wl_set_resize(void *data, unsigned width, unsigned height) return true; } -static void gfx_ctx_wl_update_title(void *data, void *data2) -{ - gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; - char title[128]; +//static void gfx_ctx_wl_update_title(void *data, void *data2) +//{ +// gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; +// char title[128]; - title[0] = '\0'; +// title[0] = '\0'; - video_driver_get_window_title(title, sizeof(title)); +// video_driver_get_window_title(title, sizeof(title)); - if (wl && title[0]) - wl_shell_surface_set_title(wl->shell_surf, title); -} +// if (wl && title[0]) +// xdg_surface_set_title(wl->xdg_surface, title); +//} static bool gfx_ctx_wl_get_metrics(void *data, @@ -1064,7 +1083,7 @@ static void *gfx_ctx_wl_init(video_frame_info_t *video_info, void *video_driver) if (!wl->shell) { - RARCH_ERR("[Wayland]: Failed to create shell.\n"); + RARCH_ERR("[Wayland]: Compositor doesn't support xdg-shell interface.\n"); goto error; } @@ -1293,12 +1312,15 @@ static bool gfx_ctx_wl_set_video_mode(void *data, default: break; } - wl->shell_surf = wl_shell_get_shell_surface(wl->shell, wl->surface); + wl->xdg_surface = xdg_wm_base_get_xdg_surface(wl->shell, wl->surface); + xdg_surface_add_listener(wl->xdg_surface, &xdg_surface_listener, wl); + + wl->xdg_toplevel = xdg_surface_get_toplevel(wl->xdg_surface); + xdg_toplevel_add_listener(wl->xdg_toplevel, &xdg_toplevel_listener, wl); + + xdg_toplevel_set_title (wl->xdg_toplevel, "RetroArch"); + xdg_toplevel_set_app_id (wl->xdg_toplevel, "RetroArch"); - wl_shell_surface_add_listener(wl->shell_surf, &shell_surface_listener, wl); - wl_shell_surface_set_toplevel(wl->shell_surf); - wl_shell_surface_set_class(wl->shell_surf, "RetroArch"); - wl_shell_surface_set_title(wl->shell_surf, "RetroArch"); switch (wl_api) { @@ -1323,12 +1345,6 @@ static bool gfx_ctx_wl_set_video_mode(void *data, break; } - if (fullscreen) - wl_shell_surface_set_fullscreen(wl->shell_surf, - WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, NULL); - - flush_wayland_fd(&wl->input); - switch (wl_api) { case GFX_CTX_VULKAN_API: @@ -1400,12 +1416,6 @@ static bool gfx_ctx_wl_suppress_screensaver(void *data, bool enable) return true; } -static bool gfx_ctx_wl_has_windowed(void *data) -{ - (void)data; - return true; -} - static enum gfx_ctx_api gfx_ctx_wl_get_api(void *data) { return wl_api; @@ -1557,11 +1567,11 @@ static void gfx_ctx_wl_set_flags(void *data, uint32_t flags) wl->core_hw_context_enable = true; } -static void gfx_ctx_wl_show_mouse(void *data, bool state) +static int gfx_ctx_wl_show_mouse(void *data, bool state) { gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; if (!wl->wl_pointer) - return; + return 1; if (state) { @@ -1591,19 +1601,15 @@ const gfx_ctx_driver_t gfx_ctx_wayland = { gfx_ctx_wl_bind_api, gfx_ctx_wl_set_swap_interval, gfx_ctx_wl_set_video_mode, - gfx_ctx_wl_get_video_size, gfx_ctx_wl_get_refresh_rate, NULL, /* get_video_output_size */ NULL, /* get_video_output_prev */ NULL, /* get_video_output_next */ gfx_ctx_wl_get_metrics, NULL, - gfx_ctx_wl_update_title, gfx_ctx_wl_check_window, - gfx_ctx_wl_set_resize, gfx_ctx_wl_has_focus, gfx_ctx_wl_suppress_screensaver, - gfx_ctx_wl_has_windowed, gfx_ctx_wl_swap_buffers, gfx_ctx_wl_input_driver, gfx_ctx_wl_get_proc_address, diff --git a/qb/config.libs.sh b/qb/config.libs.sh index a679058d35..0fd0fe4aa3 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -455,8 +455,9 @@ check_pkgconf V4L2 libv4l2 check_pkgconf FREETYPE freetype2 check_pkgconf X11 x11 check_pkgconf XCB xcb -check_pkgconf WAYLAND wayland-egl -check_pkgconf WAYLAND_CURSOR wayland-cursor +check_pkgconf WAYLAND wayland-egl 1.15 +check_pkgconf WAYLAND_CURSOR wayland-cursor 1.15 +check_pkgconf WAYLAND_PROTOS wayland-protocols 1.15 check_pkgconf XKBCOMMON xkbcommon 0.3.2 check_pkgconf DBUS dbus-1 check_pkgconf XEXT xext @@ -472,6 +473,14 @@ check_val '' XKBCOMMON -lxkbcommon check_val '' XEXT -lXext check_val '' XF86VM -lXxf86vm +if [ "$HAVE_WAYLAND_PROTOS" = yes ] && [ "$HAVE_WAYLAND" = yes ]; then + check_pkgconf WAYLAND_SCANNER wayland-scanner 1.15 + ./gfx/common/wayland/generate_wayland_protos.sh +else + die : 'Notice: wayland-egl or wayland-protocols not present. Skiping Wayland code paths.' + HAVE_WAYLAND='no' +fi + if [ "$HAVE_X11" = 'no' ]; then HAVE_XEXT=no; HAVE_XF86VM=no; HAVE_XINERAMA=no; HAVE_XSHM=no fi From c0adb18eff4c5d02fd66779a1d51e69e325bc862 Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Sun, 18 Nov 2018 21:29:31 +0400 Subject: [PATCH 002/153] Fix build --- Makefile.common | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Makefile.common b/Makefile.common index 4bbb694a77..0554d01f7f 100644 --- a/Makefile.common +++ b/Makefile.common @@ -867,14 +867,6 @@ ifeq ($(HAVE_WAYLAND), 1) DEFINES += $(WAYLAND_CFLAGS) $(WAYLAND_CURSOR_CFLAGS) LIBS += $(WAYLAND_LIBS) $(WAYLAND_CURSOR_LIBS) - OBJ += gfx/drivers_context/wayland_ctx.o \ - input/drivers/wayland_input.o - ifeq ($(HAVE_EGL), 1) - LIBS += $(EGL_LIBS) - endif - DEFINES += $(WAYLAND_CFLAGS) $(WAYLAND_CURSOR_CFLAGS) - LIBS += $(WAYLAND_LIBS) $(WAYLAND_CURSOR_LIBS) - endif #Input From 4d8defb4c98b815d5e95435d56d4963a6859ed7f Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Sun, 18 Nov 2018 21:50:39 +0400 Subject: [PATCH 003/153] Remove D-bus based screensaver inhibition (will replaced to idle-inhibit in future) --- gfx/drivers_context/wayland_ctx.c | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 84bfcf47db..5045f77cd0 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -42,10 +42,6 @@ #include "../common/gl_common.h" #endif -#ifdef HAVE_DBUS -#include "../common/dbus_common.h" -#endif - #include "../common/wayland_common.h" #include "../../frontend/frontend_driver.h" #include "../../input/input_driver.h" @@ -799,11 +795,6 @@ static void gfx_ctx_wl_destroy_resources(gfx_ctx_wayland_data_t *wl) wl->width = 0; wl->height = 0; - -#ifdef HAVE_DBUS - dbus_screensaver_uninhibit(); - dbus_close_connection(); -#endif } void flush_wayland_fd(void *data) @@ -1138,10 +1129,6 @@ static void *gfx_ctx_wl_init(video_frame_info_t *video_info, void *video_driver) flush_wayland_fd(&wl->input); -#ifdef HAVE_DBUS - dbus_ensure_connection(); -#endif - return wl; error: @@ -1404,18 +1391,6 @@ static bool gfx_ctx_wl_has_focus(void *data) return wl->input.keyboard_focus; } -static bool gfx_ctx_wl_suppress_screensaver(void *data, bool enable) -{ - (void)data; - (void)enable; - -#ifdef HAVE_DBUS - return dbus_suspend_screensaver(enable); -#endif - - return true; -} - static enum gfx_ctx_api gfx_ctx_wl_get_api(void *data) { return wl_api; @@ -1609,7 +1584,6 @@ const gfx_ctx_driver_t gfx_ctx_wayland = { NULL, gfx_ctx_wl_check_window, gfx_ctx_wl_has_focus, - gfx_ctx_wl_suppress_screensaver, gfx_ctx_wl_swap_buffers, gfx_ctx_wl_input_driver, gfx_ctx_wl_get_proc_address, From b64f302eb7c53f730543b5321033e212d31c32d1 Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Mon, 19 Nov 2018 22:31:17 +0400 Subject: [PATCH 004/153] Check for resize --- gfx/drivers_context/wayland_ctx.c | 60 +++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 11 deletions(-) diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 5045f77cd0..4171d05088 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -68,14 +68,15 @@ typedef struct gfx_ctx_wayland_data egl_ctx_data_t egl; struct wl_egl_window *win; #endif - bool resize; bool fullscreen; bool maximized; + bool resize; unsigned width; unsigned height; unsigned physical_width; unsigned physical_height; int refresh_rate; + int touch_entries; struct wl_registry *registry; struct wl_compositor *compositor; struct wl_surface *surface; @@ -342,7 +343,42 @@ static const struct wl_pointer_listener pointer_listener = { pointer_handle_axis, }; -// Check for resize +static int check_for_resize(void *data, wl_fixed_t x_w, wl_fixed_t y_w, + enum xdg_toplevel_resize_edge *edge) +{ + gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; + + if (wl->touch_entries || wl->fullscreen || wl->maximized) + return 0; + + const int edge_pixels = 64; + int pos[2] = { wl_fixed_to_double(x_w), wl_fixed_to_double(y_w) }; + int left_edge = pos[0] < edge_pixels; + int top_edge = pos[1] < edge_pixels; + int right_edge = pos[0] > edge_pixels; + int bottom_edge = pos[1] > edge_pixels; + + if (left_edge) { + *edge = XDG_TOPLEVEL_RESIZE_EDGE_LEFT; + if (top_edge) + *edge = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT; + } else if (right_edge) { + *edge = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT; + if (top_edge) + *edge = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT; + else if (bottom_edge) + *edge = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT; + } else if (top_edge) { + *edge = XDG_TOPLEVEL_RESIZE_EDGE_TOP; + } else if (bottom_edge) { + *edge = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM; + } else { + *edge = 0; + return 0; + } + + return 1; +} static void touch_handle_down(void *data, struct wl_touch *wl_touch, @@ -902,18 +938,18 @@ static bool gfx_ctx_wl_set_resize(void *data, unsigned width, unsigned height) return true; } -//static void gfx_ctx_wl_update_title(void *data, void *data2) -//{ -// gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; -// char title[128]; +static void gfx_ctx_wl_update_title(void *data, void *data2) +{ + gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; + char title[128]; -// title[0] = '\0'; + title[0] = '\0'; -// video_driver_get_window_title(title, sizeof(title)); + video_driver_get_window_title(title, sizeof(title)); -// if (wl && title[0]) -// xdg_surface_set_title(wl->xdg_surface, title); -//} + if (wl && title[0]) + xdg_toplevel_set_title (wl->xdg_toplevel, title); +} static bool gfx_ctx_wl_get_metrics(void *data, @@ -1582,7 +1618,9 @@ const gfx_ctx_driver_t gfx_ctx_wayland = { NULL, /* get_video_output_next */ gfx_ctx_wl_get_metrics, NULL, + gfx_ctx_wl_update_title, gfx_ctx_wl_check_window, + gfx_ctx_wl_set_resize, gfx_ctx_wl_has_focus, gfx_ctx_wl_swap_buffers, gfx_ctx_wl_input_driver, From 930b1214fd45575a89849eea68c1528b1566b525 Mon Sep 17 00:00:00 2001 From: Ayssia Date: Wed, 21 Nov 2018 16:32:52 +0800 Subject: [PATCH 005/153] Minor Update --- intl/msg_hash_chs.h | 48 +++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/intl/msg_hash_chs.h b/intl/msg_hash_chs.h index 813689be7c..bfd16b16bf 100644 --- a/intl/msg_hash_chs.h +++ b/intl/msg_hash_chs.h @@ -210,7 +210,7 @@ MSG_HASH( MSG_HASH( MENU_ENUM_LABEL_VALUE_ACHIEVEMENT_LIST_HARDCORE, - "成就列表(硬核)" /*FIXME:"Achievement List (Hardcore)"*/ + "成就列表(硬核模式)" ) MSG_HASH( MENU_ENUM_LABEL_VALUE_ADD_CONTENT_LIST, @@ -650,9 +650,11 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_ENTRY_HOVER_COLOR, MSG_HASH(MENU_ENUM_LABEL_VALUE_ENTRY_NORMAL_COLOR, "菜单项正常颜色") MSG_HASH(MENU_ENUM_LABEL_VALUE_FALSE, - "假") + "否") MSG_HASH(MENU_ENUM_LABEL_VALUE_FASTFORWARD_RATIO, "最大运行速度") +MSG_HASH(MENU_ENUM_LABEL_VALUE_FAVORITES_TAB, + "收藏夹") MSG_HASH(MENU_ENUM_LABEL_VALUE_FPS_SHOW, "显示帧率") MSG_HASH(MENU_ENUM_LABEL_VALUE_FRAME_THROTTLE_ENABLE, @@ -1707,7 +1709,7 @@ MSG_HASH( MSG_HASH(MENU_ENUM_LABEL_VALUE_TITLE_COLOR, "菜单标题颜色") MSG_HASH(MENU_ENUM_LABEL_VALUE_TRUE, - "真") + "是") MSG_HASH(MENU_ENUM_LABEL_VALUE_UI_COMPANION_ENABLE, "UI Companion Enable") MSG_HASH(MENU_ENUM_LABEL_VALUE_UI_COMPANION_START_ON_BOOT, @@ -4613,7 +4615,7 @@ MSG_HASH( "Output Display ID") MSG_HASH( MENU_ENUM_LABEL_VALUE_QUICK_MENU_START_RECORDING, - "Start Recording" + "开始录制" ) MSG_HASH( MENU_ENUM_SUBLABEL_QUICK_MENU_START_RECORDING, @@ -4621,7 +4623,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_QUICK_MENU_STOP_RECORDING, - "Stop Recording" + "停止录制" ) MSG_HASH( MENU_ENUM_SUBLABEL_QUICK_MENU_STOP_RECORDING, @@ -4676,11 +4678,11 @@ MSG_HASH( "YouTube" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_TWITCH_STREAM_KEY, - "Twitch Stream Key") + "Twitch 直播密钥") MSG_HASH(MENU_ENUM_LABEL_VALUE_YOUTUBE_STREAM_KEY, - "YouTube Stream Key") + "YouTube 直播密钥") MSG_HASH(MENU_ENUM_LABEL_VALUE_STREAMING_MODE, - "Streaming Mode") + "直播模式") MSG_HASH(MENU_ENUM_LABEL_VALUE_STREAMING_TITLE, "直播标题") MSG_HASH( @@ -4700,46 +4702,50 @@ MSG_HASH( "OK" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_OZONE_MENU_COLOR_THEME, - "菜单颜色主题") + "菜单主题颜色") MSG_HASH( MENU_ENUM_LABEL_VALUE_OZONE_COLOR_THEME_BASIC_WHITE, - "Basic White" + "白色" ) MSG_HASH( MENU_ENUM_LABEL_VALUE_OZONE_COLOR_THEME_BASIC_BLACK, - "Basic Black" + "黑色" ) MSG_HASH( MENU_ENUM_SUBLABEL_OZONE_MENU_COLOR_THEME, - "Select a different color theme." + "选择不同的主题颜色。" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_MENU_USE_PREFERRED_SYSTEM_COLOR_THEME, "Use preferred system color theme") MSG_HASH(MENU_ENUM_SUBLABEL_MENU_USE_PREFERRED_SYSTEM_COLOR_THEME, "Use your operating system's color theme (if any) - overrides theme settings.") MSG_HASH(MSG_RESAMPLER_QUALITY_LOWEST, - "Lowest") + "最低") MSG_HASH(MSG_RESAMPLER_QUALITY_LOWER, - "Lower") + "较低") MSG_HASH(MSG_RESAMPLER_QUALITY_NORMAL, - "Normal") + "一般") MSG_HASH(MSG_RESAMPLER_QUALITY_HIGHER, - "Higher") + "较高") MSG_HASH(MSG_RESAMPLER_QUALITY_HIGHEST, - "Highest") + "最高") MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_MUSIC_AVAILABLE, - "No music available." + "没有音乐。" ) MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_VIDEOS_AVAILABLE, - "No videos available." + "没有视频。" ) MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_IMAGES_AVAILABLE, - "No images available." + "没有图片。" ) MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_FAVORITES_AVAILABLE, - "No favorites available." + "没有收藏。" ) +MSG_HASH( + MSG_MISSING_ASSETS, + "Warning: Missing assets, use the Online Updater if available" + ) \ No newline at end of file From 1372d408ebf42ca0a60274bfaea5833145f8f8eb Mon Sep 17 00:00:00 2001 From: Ayssia Date: Wed, 21 Nov 2018 16:34:27 +0800 Subject: [PATCH 006/153] Fix newline at eof --- intl/msg_hash_chs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intl/msg_hash_chs.h b/intl/msg_hash_chs.h index bfd16b16bf..11f7b11bb2 100644 --- a/intl/msg_hash_chs.h +++ b/intl/msg_hash_chs.h @@ -4748,4 +4748,4 @@ MSG_HASH( MSG_HASH( MSG_MISSING_ASSETS, "Warning: Missing assets, use the Online Updater if available" - ) \ No newline at end of file + ) From 2615ad3f5538f2f19c2b83f782030746ed042fd1 Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Wed, 21 Nov 2018 21:28:32 +0400 Subject: [PATCH 007/153] Make it works! --- gfx/drivers_context/wayland_ctx.c | 124 +++++++++++++++++++----------- 1 file changed, 78 insertions(+), 46 deletions(-) diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 4171d05088..2e6937f976 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -42,6 +42,10 @@ #include "../common/gl_common.h" #endif +#ifdef HAVE_DBUS +#include "../common/dbus_common.h" +#endif + #include "../common/wayland_common.h" #include "../../frontend/frontend_driver.h" #include "../../input/input_driver.h" @@ -50,6 +54,7 @@ // Generated from xdg-shell.xml #include "../common/wayland/xdg-shell.h" + typedef struct touch_pos { bool active; @@ -76,7 +81,6 @@ typedef struct gfx_ctx_wayland_data unsigned physical_width; unsigned physical_height; int refresh_rate; - int touch_entries; struct wl_registry *registry; struct wl_compositor *compositor; struct wl_surface *surface; @@ -244,7 +248,7 @@ static const struct wl_keyboard_listener keyboard_listener = { keyboard_handle_repeat_info }; -static int gfx_ctx_wl_show_mouse(void *data, bool state); +static void gfx_ctx_wl_show_mouse(void *data, bool state); static void pointer_handle_enter(void *data, struct wl_pointer *pointer, @@ -305,6 +309,8 @@ static void pointer_handle_button(void *data, { wl->input.mouse.left = true; + if (BIT_GET(wl->input.key_state, KEY_LEFTALT) && wl->xdg_toplevel) + xdg_toplevel_move(wl->xdg_toplevel, wl->seat, serial); } else if (button == BTN_RIGHT) wl->input.mouse.right = true; @@ -343,43 +349,6 @@ static const struct wl_pointer_listener pointer_listener = { pointer_handle_axis, }; -static int check_for_resize(void *data, wl_fixed_t x_w, wl_fixed_t y_w, - enum xdg_toplevel_resize_edge *edge) -{ - gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; - - if (wl->touch_entries || wl->fullscreen || wl->maximized) - return 0; - - const int edge_pixels = 64; - int pos[2] = { wl_fixed_to_double(x_w), wl_fixed_to_double(y_w) }; - int left_edge = pos[0] < edge_pixels; - int top_edge = pos[1] < edge_pixels; - int right_edge = pos[0] > edge_pixels; - int bottom_edge = pos[1] > edge_pixels; - - if (left_edge) { - *edge = XDG_TOPLEVEL_RESIZE_EDGE_LEFT; - if (top_edge) - *edge = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT; - } else if (right_edge) { - *edge = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT; - if (top_edge) - *edge = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT; - else if (bottom_edge) - *edge = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT; - } else if (top_edge) { - *edge = XDG_TOPLEVEL_RESIZE_EDGE_TOP; - } else if (bottom_edge) { - *edge = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM; - } else { - *edge = 0; - return 0; - } - - return 1; -} - static void touch_handle_down(void *data, struct wl_touch *wl_touch, uint32_t serial, @@ -625,12 +594,39 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, } } -//TODO: Setup resize here - static const struct xdg_toplevel_listener xdg_toplevel_listener = { handle_toplevel_config, }; +//static void shell_surface_handle_configure(void *data, + //struct xdg_surface *xdg_surface, + //uint32_t edges, int32_t width, int32_t height) +//{ + //gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; + + //(void)xdg_surface; + //(void)edges; + + //wl->width = wl->buffer_scale * width; + //wl->height = wl->buffer_scale * height; + + //RARCH_LOG("[Wayland]: Surface configure: %u x %u.\n", + //wl->width, wl->height); +//} + +//static void shell_surface_handle_popup_done(void *data, + //struct wl_shell_surface *shell_surface) +//{ + //(void)data; + //(void)shell_surface; +//} + +//static const struct wl_shell_surface_listener shell_surface_listener = { + //shell_surface_handle_ping, + //shell_surface_handle_configure, + //shell_surface_handle_popup_done, +//}; + static void display_handle_geometry(void *data, struct wl_output *output, int x, int y, @@ -718,6 +714,7 @@ static void registry_handle_global(void *data, struct wl_registry *reg, { output = (struct wl_output*)wl_registry_bind(reg, id, &wl_output_interface, 2); + wl_output_add_listener(output, &output_listener, wl); wl_display_roundtrip(wl->input.dpy); } else if (string_is_equal(interface, "xdg_wm_base")) @@ -831,6 +828,11 @@ static void gfx_ctx_wl_destroy_resources(gfx_ctx_wayland_data_t *wl) wl->width = 0; wl->height = 0; + +#ifdef HAVE_DBUS + dbus_screensaver_uninhibit(); + dbus_close_connection(); +#endif } void flush_wayland_fd(void *data) @@ -1110,7 +1112,7 @@ static void *gfx_ctx_wl_init(video_frame_info_t *video_info, void *video_driver) if (!wl->shell) { - RARCH_ERR("[Wayland]: Compositor doesn't support xdg-shell interface.\n"); + RARCH_ERR("[Wayland]: Failed to create shell.\n"); goto error; } @@ -1165,6 +1167,10 @@ static void *gfx_ctx_wl_init(video_frame_info_t *video_info, void *video_driver) flush_wayland_fd(&wl->input); +#ifdef HAVE_DBUS + dbus_ensure_connection(); +#endif + return wl; error: @@ -1341,9 +1347,8 @@ static bool gfx_ctx_wl_set_video_mode(void *data, wl->xdg_toplevel = xdg_surface_get_toplevel(wl->xdg_surface); xdg_toplevel_add_listener(wl->xdg_toplevel, &xdg_toplevel_listener, wl); - xdg_toplevel_set_title (wl->xdg_toplevel, "RetroArch"); xdg_toplevel_set_app_id (wl->xdg_toplevel, "RetroArch"); - + xdg_toplevel_set_title (wl->xdg_toplevel, "RetroArch"); switch (wl_api) { @@ -1368,6 +1373,12 @@ static bool gfx_ctx_wl_set_video_mode(void *data, break; } + //if (fullscreen) + //wl_shell_surface_set_fullscreen(wl->shell_surf, + //WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, NULL); + + //flush_wayland_fd(&wl->input); + switch (wl_api) { case GFX_CTX_VULKAN_API: @@ -1427,6 +1438,24 @@ static bool gfx_ctx_wl_has_focus(void *data) return wl->input.keyboard_focus; } +static bool gfx_ctx_wl_suppress_screensaver(void *data, bool enable) +{ + (void)data; + (void)enable; + +#ifdef HAVE_DBUS + return dbus_suspend_screensaver(enable); +#endif + + return true; +} + +static bool gfx_ctx_wl_has_windowed(void *data) +{ + (void)data; + return true; +} + static enum gfx_ctx_api gfx_ctx_wl_get_api(void *data) { return wl_api; @@ -1578,11 +1607,11 @@ static void gfx_ctx_wl_set_flags(void *data, uint32_t flags) wl->core_hw_context_enable = true; } -static int gfx_ctx_wl_show_mouse(void *data, bool state) +static void gfx_ctx_wl_show_mouse(void *data, bool state) { gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; if (!wl->wl_pointer) - return 1; + return; if (state) { @@ -1612,6 +1641,7 @@ const gfx_ctx_driver_t gfx_ctx_wayland = { gfx_ctx_wl_bind_api, gfx_ctx_wl_set_swap_interval, gfx_ctx_wl_set_video_mode, + gfx_ctx_wl_get_video_size, gfx_ctx_wl_get_refresh_rate, NULL, /* get_video_output_size */ NULL, /* get_video_output_prev */ @@ -1622,6 +1652,8 @@ const gfx_ctx_driver_t gfx_ctx_wayland = { gfx_ctx_wl_check_window, gfx_ctx_wl_set_resize, gfx_ctx_wl_has_focus, + gfx_ctx_wl_suppress_screensaver, + gfx_ctx_wl_has_windowed, gfx_ctx_wl_swap_buffers, gfx_ctx_wl_input_driver, gfx_ctx_wl_get_proc_address, From ba435ce22a9ec0ca71ef240b6edc4b5aeaf002fe Mon Sep 17 00:00:00 2001 From: Royerson Date: Wed, 21 Nov 2018 14:06:34 -0700 Subject: [PATCH 008/153] add more model names for Xperia Play hack --- input/drivers/android_input.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 6a9050381f..3e0339e9a0 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -1057,8 +1057,17 @@ static void handle_hotplug(android_input_t *android, * This device is composed of two hid devices * We make it look like one device */ - else if((strstr(device_model, "R800") || strstr(device_model, "Xperia Play")) && + else if( ( + strstr(device_model, "R800x") || + strstr(device_model, "R800at") || + strstr(device_model, "R800i") || + strstr(device_model, "R800a") || + strstr(device_model, "R800") || + strstr(device_model, "Xperia Play") || + strstr(device_model, "Play") || + strstr(device_model, "SO-01D") + ) && ( strstr(device_name, "keypad-game-zeus") || strstr(device_name, "keypad-zeus") || strstr(device_name, "Android Gamepad") From 3e7328b00a12f16e3c13111ceb6ee901907576a8 Mon Sep 17 00:00:00 2001 From: Alfrix Date: Thu, 22 Nov 2018 16:18:11 -0300 Subject: [PATCH 009/153] Fix shader warnings --- gfx/drivers/gl_shaders/shaders_common.h | 4 ++-- gfx/drivers_shader/shader_glsl.c | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gfx/drivers/gl_shaders/shaders_common.h b/gfx/drivers/gl_shaders/shaders_common.h index 3ea1fbc955..1f31aa2bd1 100644 --- a/gfx/drivers/gl_shaders/shaders_common.h +++ b/gfx/drivers/gl_shaders/shaders_common.h @@ -23,11 +23,11 @@ "#else\n" \ " precision mediump float;\n" \ "#endif\n" #src +#define GLSL_300(src) "#version 300 es\n" #src #else #define CG(src) "" #src #define GLSL(src) "" #src -#define GLSL_300(src) "#version 300 es\n" #src -#define GLSL_330(src) "#version 330 core\n" #src +#define GLSL_330(src) "#version 330\n" #src #endif #endif diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index 784cf41c7f..8f3a854f3a 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -344,7 +344,6 @@ static bool gl_glsl_compile_shader(glsl_shader_data_t *glsl, } #endif snprintf(version, sizeof(version), "#version %u%s\n", version_no, version_extra); - RARCH_LOG("[GLSL]: Using GLSL version %u%s.\n", version_no, version_extra); } else if (glsl_core) { @@ -368,9 +367,14 @@ static bool gl_glsl_compile_shader(glsl_shader_data_t *glsl, } snprintf(version, sizeof(version), "#version %u\n", version_no); - RARCH_LOG("[GLSL]: Using GLSL version %u.\n", version_no); + } + else + { + /* Don't leave version empty, prevent the compiler warning */ + snprintf(version, sizeof(version), "#version 110\n"); } + RARCH_LOG("[GLSL]: Using GLSL %s", version); source[0] = version; source[1] = define; source[2] = glsl->alias_define; From 129beaefb09a0099097d63bc190a4b89fad85a10 Mon Sep 17 00:00:00 2001 From: meepingsnesroms Date: Thu, 22 Nov 2018 18:46:33 -0800 Subject: [PATCH 010/153] This should fix netplay passwords --- network/netplay/netplay_handshake.c | 3 ++- network/netplay/netplay_private.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/network/netplay/netplay_handshake.c b/network/netplay/netplay_handshake.c index 7b52bbb9c9..258caa5f81 100644 --- a/network/netplay/netplay_handshake.c +++ b/network/netplay/netplay_handshake.c @@ -278,7 +278,8 @@ static void handshake_password(void *ignore, const char *line) struct netplay_connection *connection = &netplay->connections[0]; snprintf(password, sizeof(password), "%08X", connection->salt); - strlcpy(password + 8, line, sizeof(password)-8); + if (line) + strlcpy(password + 8, line, sizeof(password)-8); password_buf.cmd[0] = htonl(NETPLAY_CMD_PASSWORD); password_buf.cmd[1] = htonl(sizeof(password_buf.password)); diff --git a/network/netplay/netplay_private.h b/network/netplay/netplay_private.h index d607b5e84f..0d8d793855 100644 --- a/network/netplay/netplay_private.h +++ b/network/netplay/netplay_private.h @@ -35,7 +35,7 @@ #define NETPLAY_NICK_LEN 32 #define NETPLAY_PASS_LEN 128 -#define NETPLAY_PASS_HASH_LEN 64 /* length of a SHA-256 hash */ +#define NETPLAY_PASS_HASH_LEN 65 /* length of a SHA-256 hash + NULL terminator*/ #define MAX_SERVER_STALL_TIME_USEC (5*1000*1000) #define MAX_CLIENT_STALL_TIME_USEC (10*1000*1000) From 8514d6ccc86ba3871c8ab95229a6eda0b9a4b470 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 23 Nov 2018 04:18:38 +0100 Subject: [PATCH 011/153] Revert "Fix shader warnings" --- gfx/drivers/gl_shaders/shaders_common.h | 4 ++-- gfx/drivers_shader/shader_glsl.c | 8 ++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/gfx/drivers/gl_shaders/shaders_common.h b/gfx/drivers/gl_shaders/shaders_common.h index 1f31aa2bd1..3ea1fbc955 100644 --- a/gfx/drivers/gl_shaders/shaders_common.h +++ b/gfx/drivers/gl_shaders/shaders_common.h @@ -23,11 +23,11 @@ "#else\n" \ " precision mediump float;\n" \ "#endif\n" #src -#define GLSL_300(src) "#version 300 es\n" #src #else #define CG(src) "" #src #define GLSL(src) "" #src -#define GLSL_330(src) "#version 330\n" #src +#define GLSL_300(src) "#version 300 es\n" #src +#define GLSL_330(src) "#version 330 core\n" #src #endif #endif diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index 8f3a854f3a..784cf41c7f 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -344,6 +344,7 @@ static bool gl_glsl_compile_shader(glsl_shader_data_t *glsl, } #endif snprintf(version, sizeof(version), "#version %u%s\n", version_no, version_extra); + RARCH_LOG("[GLSL]: Using GLSL version %u%s.\n", version_no, version_extra); } else if (glsl_core) { @@ -367,14 +368,9 @@ static bool gl_glsl_compile_shader(glsl_shader_data_t *glsl, } snprintf(version, sizeof(version), "#version %u\n", version_no); - } - else - { - /* Don't leave version empty, prevent the compiler warning */ - snprintf(version, sizeof(version), "#version 110\n"); + RARCH_LOG("[GLSL]: Using GLSL version %u.\n", version_no); } - RARCH_LOG("[GLSL]: Using GLSL %s", version); source[0] = version; source[1] = define; source[2] = glsl->alias_define; From 2a67be3a7c38c3a654ed6299e7ef6263e0796c9c Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Fri, 23 Nov 2018 08:15:22 -0500 Subject: [PATCH 012/153] Revert "This should fix netplay passwords" --- network/netplay/netplay_handshake.c | 3 +-- network/netplay/netplay_private.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/network/netplay/netplay_handshake.c b/network/netplay/netplay_handshake.c index 258caa5f81..7b52bbb9c9 100644 --- a/network/netplay/netplay_handshake.c +++ b/network/netplay/netplay_handshake.c @@ -278,8 +278,7 @@ static void handshake_password(void *ignore, const char *line) struct netplay_connection *connection = &netplay->connections[0]; snprintf(password, sizeof(password), "%08X", connection->salt); - if (line) - strlcpy(password + 8, line, sizeof(password)-8); + strlcpy(password + 8, line, sizeof(password)-8); password_buf.cmd[0] = htonl(NETPLAY_CMD_PASSWORD); password_buf.cmd[1] = htonl(sizeof(password_buf.password)); diff --git a/network/netplay/netplay_private.h b/network/netplay/netplay_private.h index 0d8d793855..d607b5e84f 100644 --- a/network/netplay/netplay_private.h +++ b/network/netplay/netplay_private.h @@ -35,7 +35,7 @@ #define NETPLAY_NICK_LEN 32 #define NETPLAY_PASS_LEN 128 -#define NETPLAY_PASS_HASH_LEN 65 /* length of a SHA-256 hash + NULL terminator*/ +#define NETPLAY_PASS_HASH_LEN 64 /* length of a SHA-256 hash */ #define MAX_SERVER_STALL_TIME_USEC (5*1000*1000) #define MAX_CLIENT_STALL_TIME_USEC (10*1000*1000) From f897b95d09e4ae8e28bed2b63f0adddfc22b6203 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Fri, 23 Nov 2018 08:24:54 -0500 Subject: [PATCH 013/153] Avoid buffer overflows due to sha256_hash's nul-terminator. --- network/netplay/netplay_handshake.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/network/netplay/netplay_handshake.c b/network/netplay/netplay_handshake.c index 7b52bbb9c9..dc277c8b93 100644 --- a/network/netplay/netplay_handshake.c +++ b/network/netplay/netplay_handshake.c @@ -274,6 +274,7 @@ static void handshake_password(void *ignore, const char *line) { struct password_buf_s password_buf; char password[8+NETPLAY_PASS_LEN]; /* 8 for salt, 128 for password */ + char hash[NETPLAY_PASS_HASH_LEN+1]; /* + NULL terminator */ netplay_t *netplay = handshake_password_netplay; struct netplay_connection *connection = &netplay->connections[0]; @@ -282,7 +283,8 @@ static void handshake_password(void *ignore, const char *line) password_buf.cmd[0] = htonl(NETPLAY_CMD_PASSWORD); password_buf.cmd[1] = htonl(sizeof(password_buf.password)); - sha256_hash(password_buf.password, (uint8_t *) password, strlen(password)); + sha256_hash(hash, (uint8_t *) password, strlen(password)); + memcpy(password_buf.password, hash, NETPLAY_PASS_HASH_LEN); /* We have no way to handle an error here, so we'll let the next function error out */ if (netplay_send(&connection->send_packet_buffer, connection->fd, &password_buf, sizeof(password_buf))) @@ -750,8 +752,9 @@ bool netplay_handshake_pre_nick(netplay_t *netplay, bool netplay_handshake_pre_password(netplay_t *netplay, struct netplay_connection *connection, bool *had_input) { - struct password_buf_s password_buf, corr_password_buf; + struct password_buf_s password_buf; char password[8+NETPLAY_PASS_LEN]; /* 8 for salt */ + char hash[NETPLAY_PASS_HASH_LEN+1]; /* + NULL terminator */ ssize_t recvd; char msg[512]; bool correct = false; @@ -787,11 +790,9 @@ bool netplay_handshake_pre_password(netplay_t *netplay, strlcpy(password + 8, settings->paths.netplay_password, sizeof(password)-8); - sha256_hash(corr_password_buf.password, - (uint8_t *) password, strlen(password)); + sha256_hash(hash, (uint8_t *) password, strlen(password)); - if (!memcmp(password_buf.password, - corr_password_buf.password, sizeof(password_buf.password))) + if (!memcmp(password_buf.password, hash, NETPLAY_PASS_HASH_LEN)) { correct = true; connection->can_play = true; @@ -802,11 +803,9 @@ bool netplay_handshake_pre_password(netplay_t *netplay, strlcpy(password + 8, settings->paths.netplay_spectate_password, sizeof(password)-8); - sha256_hash(corr_password_buf.password, - (uint8_t *) password, strlen(password)); + sha256_hash(hash, (uint8_t *) password, strlen(password)); - if (!memcmp(password_buf.password, - corr_password_buf.password, sizeof(password_buf.password))) + if (!memcmp(password_buf.password, hash, NETPLAY_PASS_HASH_LEN)) correct = true; } From 9d5cb529c1249e6ceaa6d139cabb4d994b0243cd Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Fri, 23 Nov 2018 21:08:42 +0400 Subject: [PATCH 014/153] Add wait event for surface configure --- gfx/drivers_context/wayland_ctx.c | 71 ++++++------------------------- 1 file changed, 13 insertions(+), 58 deletions(-) diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 2e6937f976..f17b79f614 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -76,6 +76,7 @@ typedef struct gfx_ctx_wayland_data bool fullscreen; bool maximized; bool resize; + bool configured; unsigned width; unsigned height; unsigned physical_width; @@ -557,7 +558,7 @@ static const struct xdg_wm_base_listener xdg_shell_listener = { static void handle_surface_config(void *data, struct xdg_surface *surface, uint32_t serial) -{ +{ xdg_surface_ack_configure(surface, serial); } @@ -568,65 +569,14 @@ static const struct xdg_surface_listener xdg_surface_listener = { static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, int width, int height, struct wl_array *states) { - gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; - int prev_fs_state = wl->fullscreen; - wl->maximized = false; - wl->fullscreen = false; - enum xdg_toplevel_state *state; - wl_array_for_each(state, states) { - switch (*state) { - case XDG_TOPLEVEL_STATE_FULLSCREEN: - wl->fullscreen = true; - break; - case XDG_TOPLEVEL_STATE_RESIZING: - wl->resize = true; - break; - case XDG_TOPLEVEL_STATE_ACTIVATED: - break; - case XDG_TOPLEVEL_STATE_TILED_TOP: - case XDG_TOPLEVEL_STATE_TILED_LEFT: - case XDG_TOPLEVEL_STATE_TILED_RIGHT: - case XDG_TOPLEVEL_STATE_TILED_BOTTOM: - case XDG_TOPLEVEL_STATE_MAXIMIZED: - wl->maximized = true; - break; - } - } + // TODO } + static const struct xdg_toplevel_listener xdg_toplevel_listener = { handle_toplevel_config, }; -//static void shell_surface_handle_configure(void *data, - //struct xdg_surface *xdg_surface, - //uint32_t edges, int32_t width, int32_t height) -//{ - //gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; - - //(void)xdg_surface; - //(void)edges; - - //wl->width = wl->buffer_scale * width; - //wl->height = wl->buffer_scale * height; - - //RARCH_LOG("[Wayland]: Surface configure: %u x %u.\n", - //wl->width, wl->height); -//} - -//static void shell_surface_handle_popup_done(void *data, - //struct wl_shell_surface *shell_surface) -//{ - //(void)data; - //(void)shell_surface; -//} - -//static const struct wl_shell_surface_listener shell_surface_listener = { - //shell_surface_handle_ping, - //shell_surface_handle_configure, - //shell_surface_handle_popup_done, -//}; - static void display_handle_geometry(void *data, struct wl_output *output, int x, int y, @@ -1341,6 +1291,7 @@ static bool gfx_ctx_wl_set_video_mode(void *data, default: break; } + wl->xdg_surface = xdg_wm_base_get_xdg_surface(wl->shell, wl->surface); xdg_surface_add_listener(wl->xdg_surface, &xdg_surface_listener, wl); @@ -1349,6 +1300,12 @@ static bool gfx_ctx_wl_set_video_mode(void *data, xdg_toplevel_set_app_id (wl->xdg_toplevel, "RetroArch"); xdg_toplevel_set_title (wl->xdg_toplevel, "RetroArch"); + + wl_surface_commit(wl->surface); + wl->configured = true; + + while (wl->configured) + wl_display_dispatch(wl->input.dpy); switch (wl_api) { @@ -1373,11 +1330,9 @@ static bool gfx_ctx_wl_set_video_mode(void *data, break; } - //if (fullscreen) - //wl_shell_surface_set_fullscreen(wl->shell_surf, - //WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, NULL); + //TODO: fullscreen; - //flush_wayland_fd(&wl->input); + flush_wayland_fd(&wl->input); switch (wl_api) { From cd8bf003d12af4591e8eb5bf9a91a823275f9bfe Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Fri, 23 Nov 2018 21:23:53 +0400 Subject: [PATCH 015/153] Add toplevel configuration --- gfx/drivers_context/wayland_ctx.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index f17b79f614..e7a94c9d9a 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -569,7 +569,15 @@ static const struct xdg_surface_listener xdg_surface_listener = { static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, int width, int height, struct wl_array *states) { - // TODO + gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; + + wl->width = wl->buffer_scale * width; + wl->height = wl->buffer_scale * height; + + RARCH_LOG("[Wayland]: Surface configure: %u x %u.\n", + wl->width, wl->height); + + wl->configured = false; } From fbcab67d8b04b3d812cc017266e3c780ba355025 Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Fri, 23 Nov 2018 23:04:06 +0400 Subject: [PATCH 016/153] Fix wrong toplevel geometry --- gfx/drivers_context/wayland_ctx.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index e7a94c9d9a..d50bb6db54 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -571,11 +571,7 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, { gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; - wl->width = wl->buffer_scale * width; - wl->height = wl->buffer_scale * height; - - RARCH_LOG("[Wayland]: Surface configure: %u x %u.\n", - wl->width, wl->height); + // TODO: implement resizing wl->configured = false; } @@ -1338,7 +1334,8 @@ static bool gfx_ctx_wl_set_video_mode(void *data, break; } - //TODO: fullscreen; + if (fullscreen) + xdg_toplevel_set_fullscreen(wl->xdg_toplevel, NULL); flush_wayland_fd(&wl->input); From 747bf136f2fa9ea0c650ff0f0c17bdd3f8736859 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 23 Nov 2018 23:41:57 +0100 Subject: [PATCH 017/153] Simplify strip_parameter_pragmas --- gfx/drivers_shader/shader_glsl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index 784cf41c7f..f9bed812e8 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -480,11 +480,11 @@ error: return false; } -static void gl_glsl_strip_parameter_pragmas(char *source) +static void gl_glsl_strip_parameter_pragmas(char *source, const char *str) { /* #pragma parameter lines tend to have " characters in them, * which is not legal GLSL. */ - char *s = strstr(source, "#pragma parameter"); + char *s = strstr(source, str); while (s) { @@ -492,7 +492,7 @@ static void gl_glsl_strip_parameter_pragmas(char *source) * so we can just replace the entire line with spaces. */ while (*s != '\0' && *s != '\n') *s++ = ' '; - s = strstr(s, "#pragma parameter"); + s = strstr(s, str); } } @@ -506,7 +506,7 @@ static bool gl_glsl_load_source_path(struct video_shader_pass *pass, if (nitems <= 0 || len <= 0) return false; - gl_glsl_strip_parameter_pragmas(pass->source.string.vertex); + gl_glsl_strip_parameter_pragmas(pass->source.string.vertex, "#pragma parameter"); pass->source.string.fragment = strdup(pass->source.string.vertex); return pass->source.string.fragment && pass->source.string.vertex; } From c1de2e569770837d42f0099f95b8838c5f33dc27 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 23 Nov 2018 23:57:22 +0100 Subject: [PATCH 018/153] Cleanup shaders_common.h --- gfx/drivers/gl_shaders/shaders_common.h | 44 +++++++++++-------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/gfx/drivers/gl_shaders/shaders_common.h b/gfx/drivers/gl_shaders/shaders_common.h index 3ea1fbc955..8a97a09ba6 100644 --- a/gfx/drivers/gl_shaders/shaders_common.h +++ b/gfx/drivers/gl_shaders/shaders_common.h @@ -1,33 +1,27 @@ #ifndef _SHADERS_COMMON #define _SHADERS_COMMON +#define GLSL_DERIV_PREAMBLE() "#extension GL_OES_standard_derivatives : enable\n" +#define GLSL_PREAMBLE() \ + "#ifdef GL_ES\n" \ + " #ifdef GL_FRAGMENT_PRECISION_HIGH\n" \ + " precision highp float;\n" \ + " #else\n" \ + " precision mediump float;\n" \ + " #endif\n" \ + "#else\n" \ + " precision mediump float;\n" \ + "#endif\n" + #if defined(HAVE_OPENGLES) -#define CG(src) "" #src -#define GLSL(src) "#extension GL_OES_standard_derivatives : enable\n" \ - "#ifdef GL_ES\n" \ - " #ifdef GL_FRAGMENT_PRECISION_HIGH\n" \ - " precision highp float;\n" \ - " #else\n" \ - " precision mediump float;\n" \ - " #endif\n" \ - "#else\n" \ - " precision mediump float;\n" \ - "#endif\n" #src -#define GLSL_330(src) "#version 330 es\n" \ - "#ifdef GL_ES\n" \ - " #ifdef GL_FRAGMENT_PRECISION_HIGH\n" \ - " precision highp float;\n" \ - " #else\n" \ - " precision mediump float;\n" \ - " #endif\n" \ - "#else\n" \ - " precision mediump float;\n" \ - "#endif\n" #src +#define CG(src) "" #src +#define GLSL(src) GLSL_DERIV_PREAMBLE() GLSL_PREAMBLE() #src +#define GLSL_330(src) "#version 330 es\n" GLSL_PREAMBLE() #src #else -#define CG(src) "" #src -#define GLSL(src) "" #src -#define GLSL_300(src) "#version 300 es\n" #src -#define GLSL_330(src) "#version 330 core\n" #src +#define CG(src) "" #src +#define GLSL(src) "" GLSL_PREAMBLE() #src +#define GLSL_300(src) "#version 300 es\n" GLSL_PREAMBLE() #src +#define GLSL_330(src) "#version 330 core\n" GLSL_PREAMBLE() #src #endif #endif From 03a8bc9875ef4e0e942ab6d8d0d9402c4e1830fe Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 24 Nov 2018 00:30:46 +0100 Subject: [PATCH 019/153] Rename some files --- gfx/drivers/gl_shaders/{ => cg}/opaque.cg.h | 0 .../gl_shaders/{ => cg}/pipeline_nuklear.cg.h | 0 .../gl_shaders/{ => cg}/pipeline_snow.cg.h | 0 .../{ => cg}/pipeline_xmb_ribbon_simple.cg.h | 0 gfx/drivers/gl_shaders/cg/shaders_common.h | 6 ++ .../frag}/core_alpha_blend.glsl.frag.h | 0 .../{ => glsl/frag}/core_opaque.glsl.frag.h | 0 .../frag}/core_pipeline_bokeh.glsl.frag.h | 0 .../frag}/core_pipeline_snow.glsl.frag.h | 0 .../core_pipeline_snow_simple.glsl.frag.h | 0 .../frag}/core_pipeline_snowflake.glsl.frag.h | 0 .../core_pipeline_xmb_ribbon.glsl.frag.h | 0 ...ore_pipeline_xmb_ribbon_simple.glsl.frag.h | 0 .../{ => glsl/frag}/legacy_opaque.glsl.frag.h | 0 .../frag}/modern_alpha_blend.glsl.frag.h | 0 .../{ => glsl/frag}/modern_opaque.glsl.frag.h | 0 .../frag}/pipeline_bokeh.glsl.frag.h | 0 .../frag}/pipeline_nuklear.glsl.frag.h | 0 .../{ => glsl/frag}/pipeline_snow.glsl.frag.h | 0 .../frag}/pipeline_snow_simple.glsl.frag.h | 0 .../frag}/pipeline_snowflake.glsl.frag.h | 0 .../frag}/pipeline_xmb_ribbon.glsl.frag.h | 0 .../pipeline_xmb_ribbon_simple.glsl.frag.h | 0 .../gl_shaders/glsl/frag/shaders_common.h | 6 ++ .../{shaders_common.h => glsl/glsl_common.h} | 2 - .../vert}/core_alpha_blend.glsl.vert.h | 0 .../{ => glsl/vert}/core_opaque.glsl.vert.h | 0 .../{ => glsl/vert}/legacy_opaque.glsl.vert.h | 0 .../vert}/legacy_pipeline_snow.glsl.vert.h | 0 .../legacy_pipeline_xmb_ribbon.glsl.vert.h | 0 ...acy_pipeline_xmb_ribbon_simple.glsl.vert.h | 0 .../vert}/modern_alpha_blend.glsl.vert.h | 0 .../{ => glsl/vert}/modern_opaque.glsl.vert.h | 0 .../modern_pipeline_xmb_ribbon.glsl.vert.h | 0 ...ern_pipeline_xmb_ribbon_simple.glsl.vert.h | 0 .../vert}/pipeline_nuklear.glsl.vert.h | 0 .../{ => glsl/vert}/pipeline_snow.glsl.vert.h | 0 .../vert}/pipeline_snow_core.glsl.vert.h | 0 .../gl_shaders/glsl/vert/shaders_common.h | 6 ++ gfx/drivers_shader/shader_gl_cg.c | 6 +- gfx/drivers_shader/shader_glsl.c | 60 ++++++++++--------- 41 files changed, 52 insertions(+), 34 deletions(-) rename gfx/drivers/gl_shaders/{ => cg}/opaque.cg.h (100%) rename gfx/drivers/gl_shaders/{ => cg}/pipeline_nuklear.cg.h (100%) rename gfx/drivers/gl_shaders/{ => cg}/pipeline_snow.cg.h (100%) rename gfx/drivers/gl_shaders/{ => cg}/pipeline_xmb_ribbon_simple.cg.h (100%) create mode 100644 gfx/drivers/gl_shaders/cg/shaders_common.h rename gfx/drivers/gl_shaders/{ => glsl/frag}/core_alpha_blend.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/frag}/core_opaque.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/frag}/core_pipeline_bokeh.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/frag}/core_pipeline_snow.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/frag}/core_pipeline_snow_simple.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/frag}/core_pipeline_snowflake.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/frag}/core_pipeline_xmb_ribbon.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/frag}/core_pipeline_xmb_ribbon_simple.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/frag}/legacy_opaque.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/frag}/modern_alpha_blend.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/frag}/modern_opaque.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/frag}/pipeline_bokeh.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/frag}/pipeline_nuklear.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/frag}/pipeline_snow.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/frag}/pipeline_snow_simple.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/frag}/pipeline_snowflake.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/frag}/pipeline_xmb_ribbon.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/frag}/pipeline_xmb_ribbon_simple.glsl.frag.h (100%) create mode 100644 gfx/drivers/gl_shaders/glsl/frag/shaders_common.h rename gfx/drivers/gl_shaders/{shaders_common.h => glsl/glsl_common.h} (92%) rename gfx/drivers/gl_shaders/{ => glsl/vert}/core_alpha_blend.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/vert}/core_opaque.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/vert}/legacy_opaque.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/vert}/legacy_pipeline_snow.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/vert}/legacy_pipeline_xmb_ribbon.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/vert}/legacy_pipeline_xmb_ribbon_simple.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/vert}/modern_alpha_blend.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/vert}/modern_opaque.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/vert}/modern_pipeline_xmb_ribbon.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/vert}/modern_pipeline_xmb_ribbon_simple.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/vert}/pipeline_nuklear.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/vert}/pipeline_snow.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{ => glsl/vert}/pipeline_snow_core.glsl.vert.h (100%) create mode 100644 gfx/drivers/gl_shaders/glsl/vert/shaders_common.h diff --git a/gfx/drivers/gl_shaders/opaque.cg.h b/gfx/drivers/gl_shaders/cg/opaque.cg.h similarity index 100% rename from gfx/drivers/gl_shaders/opaque.cg.h rename to gfx/drivers/gl_shaders/cg/opaque.cg.h diff --git a/gfx/drivers/gl_shaders/pipeline_nuklear.cg.h b/gfx/drivers/gl_shaders/cg/pipeline_nuklear.cg.h similarity index 100% rename from gfx/drivers/gl_shaders/pipeline_nuklear.cg.h rename to gfx/drivers/gl_shaders/cg/pipeline_nuklear.cg.h diff --git a/gfx/drivers/gl_shaders/pipeline_snow.cg.h b/gfx/drivers/gl_shaders/cg/pipeline_snow.cg.h similarity index 100% rename from gfx/drivers/gl_shaders/pipeline_snow.cg.h rename to gfx/drivers/gl_shaders/cg/pipeline_snow.cg.h diff --git a/gfx/drivers/gl_shaders/pipeline_xmb_ribbon_simple.cg.h b/gfx/drivers/gl_shaders/cg/pipeline_xmb_ribbon_simple.cg.h similarity index 100% rename from gfx/drivers/gl_shaders/pipeline_xmb_ribbon_simple.cg.h rename to gfx/drivers/gl_shaders/cg/pipeline_xmb_ribbon_simple.cg.h diff --git a/gfx/drivers/gl_shaders/cg/shaders_common.h b/gfx/drivers/gl_shaders/cg/shaders_common.h new file mode 100644 index 0000000000..e9494fe841 --- /dev/null +++ b/gfx/drivers/gl_shaders/cg/shaders_common.h @@ -0,0 +1,6 @@ +#ifndef _SHADERS_COMMON +#define _SHADERS_COMMON + +#define CG(src) "" #src + +#endif diff --git a/gfx/drivers/gl_shaders/core_alpha_blend.glsl.frag.h b/gfx/drivers/gl_shaders/glsl/frag/core_alpha_blend.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/core_alpha_blend.glsl.frag.h rename to gfx/drivers/gl_shaders/glsl/frag/core_alpha_blend.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/core_opaque.glsl.frag.h b/gfx/drivers/gl_shaders/glsl/frag/core_opaque.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/core_opaque.glsl.frag.h rename to gfx/drivers/gl_shaders/glsl/frag/core_opaque.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/core_pipeline_bokeh.glsl.frag.h b/gfx/drivers/gl_shaders/glsl/frag/core_pipeline_bokeh.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/core_pipeline_bokeh.glsl.frag.h rename to gfx/drivers/gl_shaders/glsl/frag/core_pipeline_bokeh.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/core_pipeline_snow.glsl.frag.h b/gfx/drivers/gl_shaders/glsl/frag/core_pipeline_snow.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/core_pipeline_snow.glsl.frag.h rename to gfx/drivers/gl_shaders/glsl/frag/core_pipeline_snow.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/core_pipeline_snow_simple.glsl.frag.h b/gfx/drivers/gl_shaders/glsl/frag/core_pipeline_snow_simple.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/core_pipeline_snow_simple.glsl.frag.h rename to gfx/drivers/gl_shaders/glsl/frag/core_pipeline_snow_simple.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/core_pipeline_snowflake.glsl.frag.h b/gfx/drivers/gl_shaders/glsl/frag/core_pipeline_snowflake.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/core_pipeline_snowflake.glsl.frag.h rename to gfx/drivers/gl_shaders/glsl/frag/core_pipeline_snowflake.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/core_pipeline_xmb_ribbon.glsl.frag.h b/gfx/drivers/gl_shaders/glsl/frag/core_pipeline_xmb_ribbon.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/core_pipeline_xmb_ribbon.glsl.frag.h rename to gfx/drivers/gl_shaders/glsl/frag/core_pipeline_xmb_ribbon.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/core_pipeline_xmb_ribbon_simple.glsl.frag.h b/gfx/drivers/gl_shaders/glsl/frag/core_pipeline_xmb_ribbon_simple.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/core_pipeline_xmb_ribbon_simple.glsl.frag.h rename to gfx/drivers/gl_shaders/glsl/frag/core_pipeline_xmb_ribbon_simple.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/legacy_opaque.glsl.frag.h b/gfx/drivers/gl_shaders/glsl/frag/legacy_opaque.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/legacy_opaque.glsl.frag.h rename to gfx/drivers/gl_shaders/glsl/frag/legacy_opaque.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/modern_alpha_blend.glsl.frag.h b/gfx/drivers/gl_shaders/glsl/frag/modern_alpha_blend.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/modern_alpha_blend.glsl.frag.h rename to gfx/drivers/gl_shaders/glsl/frag/modern_alpha_blend.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/modern_opaque.glsl.frag.h b/gfx/drivers/gl_shaders/glsl/frag/modern_opaque.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/modern_opaque.glsl.frag.h rename to gfx/drivers/gl_shaders/glsl/frag/modern_opaque.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/pipeline_bokeh.glsl.frag.h b/gfx/drivers/gl_shaders/glsl/frag/pipeline_bokeh.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/pipeline_bokeh.glsl.frag.h rename to gfx/drivers/gl_shaders/glsl/frag/pipeline_bokeh.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/pipeline_nuklear.glsl.frag.h b/gfx/drivers/gl_shaders/glsl/frag/pipeline_nuklear.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/pipeline_nuklear.glsl.frag.h rename to gfx/drivers/gl_shaders/glsl/frag/pipeline_nuklear.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/pipeline_snow.glsl.frag.h b/gfx/drivers/gl_shaders/glsl/frag/pipeline_snow.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/pipeline_snow.glsl.frag.h rename to gfx/drivers/gl_shaders/glsl/frag/pipeline_snow.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/pipeline_snow_simple.glsl.frag.h b/gfx/drivers/gl_shaders/glsl/frag/pipeline_snow_simple.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/pipeline_snow_simple.glsl.frag.h rename to gfx/drivers/gl_shaders/glsl/frag/pipeline_snow_simple.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h b/gfx/drivers/gl_shaders/glsl/frag/pipeline_snowflake.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h rename to gfx/drivers/gl_shaders/glsl/frag/pipeline_snowflake.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/pipeline_xmb_ribbon.glsl.frag.h b/gfx/drivers/gl_shaders/glsl/frag/pipeline_xmb_ribbon.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/pipeline_xmb_ribbon.glsl.frag.h rename to gfx/drivers/gl_shaders/glsl/frag/pipeline_xmb_ribbon.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/pipeline_xmb_ribbon_simple.glsl.frag.h b/gfx/drivers/gl_shaders/glsl/frag/pipeline_xmb_ribbon_simple.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/pipeline_xmb_ribbon_simple.glsl.frag.h rename to gfx/drivers/gl_shaders/glsl/frag/pipeline_xmb_ribbon_simple.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/glsl/frag/shaders_common.h b/gfx/drivers/gl_shaders/glsl/frag/shaders_common.h new file mode 100644 index 0000000000..655861381c --- /dev/null +++ b/gfx/drivers/gl_shaders/glsl/frag/shaders_common.h @@ -0,0 +1,6 @@ +#ifndef _SHADERS_COMMON +#define _SHADERS_COMMON + +#include "../glsl_common.h" + +#endif diff --git a/gfx/drivers/gl_shaders/shaders_common.h b/gfx/drivers/gl_shaders/glsl/glsl_common.h similarity index 92% rename from gfx/drivers/gl_shaders/shaders_common.h rename to gfx/drivers/gl_shaders/glsl/glsl_common.h index 8a97a09ba6..0c9640a08b 100644 --- a/gfx/drivers/gl_shaders/shaders_common.h +++ b/gfx/drivers/gl_shaders/glsl/glsl_common.h @@ -14,11 +14,9 @@ "#endif\n" #if defined(HAVE_OPENGLES) -#define CG(src) "" #src #define GLSL(src) GLSL_DERIV_PREAMBLE() GLSL_PREAMBLE() #src #define GLSL_330(src) "#version 330 es\n" GLSL_PREAMBLE() #src #else -#define CG(src) "" #src #define GLSL(src) "" GLSL_PREAMBLE() #src #define GLSL_300(src) "#version 300 es\n" GLSL_PREAMBLE() #src #define GLSL_330(src) "#version 330 core\n" GLSL_PREAMBLE() #src diff --git a/gfx/drivers/gl_shaders/core_alpha_blend.glsl.vert.h b/gfx/drivers/gl_shaders/glsl/vert/core_alpha_blend.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/core_alpha_blend.glsl.vert.h rename to gfx/drivers/gl_shaders/glsl/vert/core_alpha_blend.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/core_opaque.glsl.vert.h b/gfx/drivers/gl_shaders/glsl/vert/core_opaque.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/core_opaque.glsl.vert.h rename to gfx/drivers/gl_shaders/glsl/vert/core_opaque.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/legacy_opaque.glsl.vert.h b/gfx/drivers/gl_shaders/glsl/vert/legacy_opaque.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/legacy_opaque.glsl.vert.h rename to gfx/drivers/gl_shaders/glsl/vert/legacy_opaque.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/legacy_pipeline_snow.glsl.vert.h b/gfx/drivers/gl_shaders/glsl/vert/legacy_pipeline_snow.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/legacy_pipeline_snow.glsl.vert.h rename to gfx/drivers/gl_shaders/glsl/vert/legacy_pipeline_snow.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/legacy_pipeline_xmb_ribbon.glsl.vert.h b/gfx/drivers/gl_shaders/glsl/vert/legacy_pipeline_xmb_ribbon.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/legacy_pipeline_xmb_ribbon.glsl.vert.h rename to gfx/drivers/gl_shaders/glsl/vert/legacy_pipeline_xmb_ribbon.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/legacy_pipeline_xmb_ribbon_simple.glsl.vert.h b/gfx/drivers/gl_shaders/glsl/vert/legacy_pipeline_xmb_ribbon_simple.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/legacy_pipeline_xmb_ribbon_simple.glsl.vert.h rename to gfx/drivers/gl_shaders/glsl/vert/legacy_pipeline_xmb_ribbon_simple.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/modern_alpha_blend.glsl.vert.h b/gfx/drivers/gl_shaders/glsl/vert/modern_alpha_blend.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/modern_alpha_blend.glsl.vert.h rename to gfx/drivers/gl_shaders/glsl/vert/modern_alpha_blend.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/modern_opaque.glsl.vert.h b/gfx/drivers/gl_shaders/glsl/vert/modern_opaque.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/modern_opaque.glsl.vert.h rename to gfx/drivers/gl_shaders/glsl/vert/modern_opaque.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/modern_pipeline_xmb_ribbon.glsl.vert.h b/gfx/drivers/gl_shaders/glsl/vert/modern_pipeline_xmb_ribbon.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/modern_pipeline_xmb_ribbon.glsl.vert.h rename to gfx/drivers/gl_shaders/glsl/vert/modern_pipeline_xmb_ribbon.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/modern_pipeline_xmb_ribbon_simple.glsl.vert.h b/gfx/drivers/gl_shaders/glsl/vert/modern_pipeline_xmb_ribbon_simple.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/modern_pipeline_xmb_ribbon_simple.glsl.vert.h rename to gfx/drivers/gl_shaders/glsl/vert/modern_pipeline_xmb_ribbon_simple.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/pipeline_nuklear.glsl.vert.h b/gfx/drivers/gl_shaders/glsl/vert/pipeline_nuklear.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/pipeline_nuklear.glsl.vert.h rename to gfx/drivers/gl_shaders/glsl/vert/pipeline_nuklear.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/pipeline_snow.glsl.vert.h b/gfx/drivers/gl_shaders/glsl/vert/pipeline_snow.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/pipeline_snow.glsl.vert.h rename to gfx/drivers/gl_shaders/glsl/vert/pipeline_snow.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/pipeline_snow_core.glsl.vert.h b/gfx/drivers/gl_shaders/glsl/vert/pipeline_snow_core.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/pipeline_snow_core.glsl.vert.h rename to gfx/drivers/gl_shaders/glsl/vert/pipeline_snow_core.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/glsl/vert/shaders_common.h b/gfx/drivers/gl_shaders/glsl/vert/shaders_common.h new file mode 100644 index 0000000000..655861381c --- /dev/null +++ b/gfx/drivers/gl_shaders/glsl/vert/shaders_common.h @@ -0,0 +1,6 @@ +#ifndef _SHADERS_COMMON +#define _SHADERS_COMMON + +#include "../glsl_common.h" + +#endif diff --git a/gfx/drivers_shader/shader_gl_cg.c b/gfx/drivers_shader/shader_gl_cg.c index 4e89540b63..73619ee64f 100644 --- a/gfx/drivers_shader/shader_gl_cg.c +++ b/gfx/drivers_shader/shader_gl_cg.c @@ -39,8 +39,8 @@ #endif #ifdef HAVE_SHADERPIPELINE -#include "../drivers/gl_shaders/pipeline_xmb_ribbon_simple.cg.h" -#include "../drivers/gl_shaders/pipeline_snow.cg.h" +#include "../drivers/gl_shaders/cg/pipeline_xmb_ribbon_simple.cg.h" +#include "../drivers/gl_shaders/cg/pipeline_snow.cg.h" #endif #include "../include/Cg/cg.h" @@ -132,7 +132,7 @@ struct uniform_cg } -#include "../drivers/gl_shaders/opaque.cg.h" +#include "../drivers/gl_shaders/cg/opaque.cg.h" static void gl_cg_set_uniform_parameter( void *data, diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index f9bed812e8..8193b997f0 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -105,37 +105,39 @@ static const char *glsl_prefixes[] = { "ruby", }; -#include "../drivers/gl_shaders/modern_opaque.glsl.vert.h" -#include "../drivers/gl_shaders/modern_opaque.glsl.frag.h" -#include "../drivers/gl_shaders/core_opaque.glsl.vert.h" -#include "../drivers/gl_shaders/core_opaque.glsl.frag.h" -#include "../drivers/gl_shaders/legacy_opaque.glsl.vert.h" -#include "../drivers/gl_shaders/legacy_opaque.glsl.frag.h" -#include "../drivers/gl_shaders/modern_alpha_blend.glsl.vert.h" -#include "../drivers/gl_shaders/modern_alpha_blend.glsl.frag.h" -#include "../drivers/gl_shaders/core_alpha_blend.glsl.vert.h" -#include "../drivers/gl_shaders/core_alpha_blend.glsl.frag.h" +#include "../drivers/gl_shaders/glsl/vert/modern_opaque.glsl.vert.h" +#include "../drivers/gl_shaders/glsl/vert/core_opaque.glsl.vert.h" +#include "../drivers/gl_shaders/glsl/vert/legacy_opaque.glsl.vert.h" +#include "../drivers/gl_shaders/glsl/vert/modern_alpha_blend.glsl.vert.h" +#include "../drivers/gl_shaders/glsl/vert/core_alpha_blend.glsl.vert.h" + +#include "../drivers/gl_shaders/glsl/frag/modern_opaque.glsl.frag.h" +#include "../drivers/gl_shaders/glsl/frag/core_opaque.glsl.frag.h" +#include "../drivers/gl_shaders/glsl/frag/legacy_opaque.glsl.frag.h" +#include "../drivers/gl_shaders/glsl/frag/modern_alpha_blend.glsl.frag.h" +#include "../drivers/gl_shaders/glsl/frag/core_alpha_blend.glsl.frag.h" #ifdef HAVE_SHADERPIPELINE -#include "../drivers/gl_shaders/core_pipeline_snow.glsl.frag.h" -#include "../drivers/gl_shaders/core_pipeline_snow_simple.glsl.frag.h" -#include "../drivers/gl_shaders/core_pipeline_xmb_ribbon.glsl.frag.h" -#include "../drivers/gl_shaders/core_pipeline_xmb_ribbon_simple.glsl.frag.h" -#include "../drivers/gl_shaders/core_pipeline_bokeh.glsl.frag.h" -#include "../drivers/gl_shaders/core_pipeline_snowflake.glsl.frag.h" -#include "../drivers/gl_shaders/legacy_pipeline_xmb_ribbon_simple.glsl.vert.h" -#include "../drivers/gl_shaders/modern_pipeline_xmb_ribbon_simple.glsl.vert.h" -#include "../drivers/gl_shaders/pipeline_xmb_ribbon_simple.glsl.frag.h" -#include "../drivers/gl_shaders/pipeline_snow.glsl.frag.h" -#include "../drivers/gl_shaders/pipeline_snow.glsl.vert.h" -#include "../drivers/gl_shaders/pipeline_snow_core.glsl.vert.h" -#include "../drivers/gl_shaders/pipeline_snow_simple.glsl.frag.h" -#include "../drivers/gl_shaders/legacy_pipeline_snow.glsl.vert.h" -#include "../drivers/gl_shaders/legacy_pipeline_xmb_ribbon.glsl.vert.h" -#include "../drivers/gl_shaders/modern_pipeline_xmb_ribbon.glsl.vert.h" -#include "../drivers/gl_shaders/pipeline_xmb_ribbon.glsl.frag.h" -#include "../drivers/gl_shaders/pipeline_bokeh.glsl.frag.h" -#include "../drivers/gl_shaders/pipeline_snowflake.glsl.frag.h" +#include "../drivers/gl_shaders/glsl/vert/legacy_pipeline_xmb_ribbon_simple.glsl.vert.h" +#include "../drivers/gl_shaders/glsl/vert/modern_pipeline_xmb_ribbon_simple.glsl.vert.h" +#include "../drivers/gl_shaders/glsl/vert/pipeline_snow.glsl.vert.h" +#include "../drivers/gl_shaders/glsl/vert/pipeline_snow_core.glsl.vert.h" +#include "../drivers/gl_shaders/glsl/vert/legacy_pipeline_snow.glsl.vert.h" +#include "../drivers/gl_shaders/glsl/vert/legacy_pipeline_xmb_ribbon.glsl.vert.h" +#include "../drivers/gl_shaders/glsl/vert/modern_pipeline_xmb_ribbon.glsl.vert.h" + +#include "../drivers/gl_shaders/glsl/frag/core_pipeline_snow.glsl.frag.h" +#include "../drivers/gl_shaders/glsl/frag/core_pipeline_snow_simple.glsl.frag.h" +#include "../drivers/gl_shaders/glsl/frag/core_pipeline_xmb_ribbon.glsl.frag.h" +#include "../drivers/gl_shaders/glsl/frag/core_pipeline_xmb_ribbon_simple.glsl.frag.h" +#include "../drivers/gl_shaders/glsl/frag/core_pipeline_bokeh.glsl.frag.h" +#include "../drivers/gl_shaders/glsl/frag/core_pipeline_snowflake.glsl.frag.h" +#include "../drivers/gl_shaders/glsl/frag/pipeline_xmb_ribbon_simple.glsl.frag.h" +#include "../drivers/gl_shaders/glsl/frag/pipeline_snow.glsl.frag.h" +#include "../drivers/gl_shaders/glsl/frag/pipeline_snow_simple.glsl.frag.h" +#include "../drivers/gl_shaders/glsl/frag/pipeline_xmb_ribbon.glsl.frag.h" +#include "../drivers/gl_shaders/glsl/frag/pipeline_bokeh.glsl.frag.h" +#include "../drivers/gl_shaders/glsl/frag/pipeline_snowflake.glsl.frag.h" #endif typedef struct glsl_shader_data From eef67ee0cda98af45e9ef7c54a95cdc7a90ac23f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 24 Nov 2018 00:37:07 +0100 Subject: [PATCH 020/153] Get rid of the header guards in shaders_common.h/glsl_common.h --- gfx/drivers/gl_shaders/glsl/frag/shaders_common.h | 7 ++----- gfx/drivers/gl_shaders/glsl/glsl_common.h | 9 +++++---- gfx/drivers/gl_shaders/glsl/vert/shaders_common.h | 8 +++----- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/gfx/drivers/gl_shaders/glsl/frag/shaders_common.h b/gfx/drivers/gl_shaders/glsl/frag/shaders_common.h index 655861381c..23bd261f07 100644 --- a/gfx/drivers/gl_shaders/glsl/frag/shaders_common.h +++ b/gfx/drivers/gl_shaders/glsl/frag/shaders_common.h @@ -1,6 +1,3 @@ -#ifndef _SHADERS_COMMON -#define _SHADERS_COMMON - +#undef VERTEX +#define FRAGMENT #include "../glsl_common.h" - -#endif diff --git a/gfx/drivers/gl_shaders/glsl/glsl_common.h b/gfx/drivers/gl_shaders/glsl/glsl_common.h index 0c9640a08b..36e0c06cd7 100644 --- a/gfx/drivers/gl_shaders/glsl/glsl_common.h +++ b/gfx/drivers/gl_shaders/glsl/glsl_common.h @@ -1,5 +1,8 @@ -#ifndef _SHADERS_COMMON -#define _SHADERS_COMMON +#undef GLSL_DERIV_PREAMBLE +#undef GLSL_PREAMBLE +#undef GLSL +#undef GLSL_300 +#undef GLSL_330 #define GLSL_DERIV_PREAMBLE() "#extension GL_OES_standard_derivatives : enable\n" #define GLSL_PREAMBLE() \ @@ -21,5 +24,3 @@ #define GLSL_300(src) "#version 300 es\n" GLSL_PREAMBLE() #src #define GLSL_330(src) "#version 330 core\n" GLSL_PREAMBLE() #src #endif - -#endif diff --git a/gfx/drivers/gl_shaders/glsl/vert/shaders_common.h b/gfx/drivers/gl_shaders/glsl/vert/shaders_common.h index 655861381c..60d4782bee 100644 --- a/gfx/drivers/gl_shaders/glsl/vert/shaders_common.h +++ b/gfx/drivers/gl_shaders/glsl/vert/shaders_common.h @@ -1,6 +1,4 @@ -#ifndef _SHADERS_COMMON -#define _SHADERS_COMMON - +#undef FRAGMENT +#undef VERTEX +#define VERTEX #include "../glsl_common.h" - -#endif From 08d024ecad75a2cd7b9a3d5f51d8d331c01c9fdc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 24 Nov 2018 01:25:55 +0100 Subject: [PATCH 021/153] Revert "Get rid of the header guards in shaders_common.h/glsl_common.h" This reverts commit eef67ee0cda98af45e9ef7c54a95cdc7a90ac23f. --- gfx/drivers/gl_shaders/glsl/frag/shaders_common.h | 7 +++++-- gfx/drivers/gl_shaders/glsl/glsl_common.h | 9 ++++----- gfx/drivers/gl_shaders/glsl/vert/shaders_common.h | 8 +++++--- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/gfx/drivers/gl_shaders/glsl/frag/shaders_common.h b/gfx/drivers/gl_shaders/glsl/frag/shaders_common.h index 23bd261f07..655861381c 100644 --- a/gfx/drivers/gl_shaders/glsl/frag/shaders_common.h +++ b/gfx/drivers/gl_shaders/glsl/frag/shaders_common.h @@ -1,3 +1,6 @@ -#undef VERTEX -#define FRAGMENT +#ifndef _SHADERS_COMMON +#define _SHADERS_COMMON + #include "../glsl_common.h" + +#endif diff --git a/gfx/drivers/gl_shaders/glsl/glsl_common.h b/gfx/drivers/gl_shaders/glsl/glsl_common.h index 36e0c06cd7..0c9640a08b 100644 --- a/gfx/drivers/gl_shaders/glsl/glsl_common.h +++ b/gfx/drivers/gl_shaders/glsl/glsl_common.h @@ -1,8 +1,5 @@ -#undef GLSL_DERIV_PREAMBLE -#undef GLSL_PREAMBLE -#undef GLSL -#undef GLSL_300 -#undef GLSL_330 +#ifndef _SHADERS_COMMON +#define _SHADERS_COMMON #define GLSL_DERIV_PREAMBLE() "#extension GL_OES_standard_derivatives : enable\n" #define GLSL_PREAMBLE() \ @@ -24,3 +21,5 @@ #define GLSL_300(src) "#version 300 es\n" GLSL_PREAMBLE() #src #define GLSL_330(src) "#version 330 core\n" GLSL_PREAMBLE() #src #endif + +#endif diff --git a/gfx/drivers/gl_shaders/glsl/vert/shaders_common.h b/gfx/drivers/gl_shaders/glsl/vert/shaders_common.h index 60d4782bee..655861381c 100644 --- a/gfx/drivers/gl_shaders/glsl/vert/shaders_common.h +++ b/gfx/drivers/gl_shaders/glsl/vert/shaders_common.h @@ -1,4 +1,6 @@ -#undef FRAGMENT -#undef VERTEX -#define VERTEX +#ifndef _SHADERS_COMMON +#define _SHADERS_COMMON + #include "../glsl_common.h" + +#endif From c5b9352c347f6b08d7ce192741ee83e465959a64 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 24 Nov 2018 01:26:05 +0100 Subject: [PATCH 022/153] Revert "Rename some files" This reverts commit 03a8bc9875ef4e0e942ab6d8d0d9402c4e1830fe. --- gfx/drivers/gl_shaders/cg/shaders_common.h | 6 -- .../frag => }/core_alpha_blend.glsl.frag.h | 0 .../vert => }/core_alpha_blend.glsl.vert.h | 0 .../{glsl/frag => }/core_opaque.glsl.frag.h | 0 .../{glsl/vert => }/core_opaque.glsl.vert.h | 0 .../frag => }/core_pipeline_bokeh.glsl.frag.h | 0 .../frag => }/core_pipeline_snow.glsl.frag.h | 0 .../core_pipeline_snow_simple.glsl.frag.h | 0 .../core_pipeline_snowflake.glsl.frag.h | 0 .../core_pipeline_xmb_ribbon.glsl.frag.h | 0 ...ore_pipeline_xmb_ribbon_simple.glsl.frag.h | 0 .../gl_shaders/glsl/frag/shaders_common.h | 6 -- .../gl_shaders/glsl/vert/shaders_common.h | 6 -- .../{glsl/frag => }/legacy_opaque.glsl.frag.h | 0 .../{glsl/vert => }/legacy_opaque.glsl.vert.h | 0 .../legacy_pipeline_snow.glsl.vert.h | 0 .../legacy_pipeline_xmb_ribbon.glsl.vert.h | 0 ...acy_pipeline_xmb_ribbon_simple.glsl.vert.h | 0 .../frag => }/modern_alpha_blend.glsl.frag.h | 0 .../vert => }/modern_alpha_blend.glsl.vert.h | 0 .../{glsl/frag => }/modern_opaque.glsl.frag.h | 0 .../{glsl/vert => }/modern_opaque.glsl.vert.h | 0 .../modern_pipeline_xmb_ribbon.glsl.vert.h | 0 ...ern_pipeline_xmb_ribbon_simple.glsl.vert.h | 0 gfx/drivers/gl_shaders/{cg => }/opaque.cg.h | 0 .../frag => }/pipeline_bokeh.glsl.frag.h | 0 .../gl_shaders/{cg => }/pipeline_nuklear.cg.h | 0 .../frag => }/pipeline_nuklear.glsl.frag.h | 0 .../vert => }/pipeline_nuklear.glsl.vert.h | 0 .../gl_shaders/{cg => }/pipeline_snow.cg.h | 0 .../{glsl/frag => }/pipeline_snow.glsl.frag.h | 0 .../{glsl/vert => }/pipeline_snow.glsl.vert.h | 0 .../vert => }/pipeline_snow_core.glsl.vert.h | 0 .../pipeline_snow_simple.glsl.frag.h | 0 .../frag => }/pipeline_snowflake.glsl.frag.h | 0 .../frag => }/pipeline_xmb_ribbon.glsl.frag.h | 0 .../{cg => }/pipeline_xmb_ribbon_simple.cg.h | 0 .../pipeline_xmb_ribbon_simple.glsl.frag.h | 0 .../{glsl/glsl_common.h => shaders_common.h} | 2 + gfx/drivers_shader/shader_gl_cg.c | 6 +- gfx/drivers_shader/shader_glsl.c | 60 +++++++++---------- 41 files changed, 34 insertions(+), 52 deletions(-) delete mode 100644 gfx/drivers/gl_shaders/cg/shaders_common.h rename gfx/drivers/gl_shaders/{glsl/frag => }/core_alpha_blend.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{glsl/vert => }/core_alpha_blend.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{glsl/frag => }/core_opaque.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{glsl/vert => }/core_opaque.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{glsl/frag => }/core_pipeline_bokeh.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{glsl/frag => }/core_pipeline_snow.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{glsl/frag => }/core_pipeline_snow_simple.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{glsl/frag => }/core_pipeline_snowflake.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{glsl/frag => }/core_pipeline_xmb_ribbon.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{glsl/frag => }/core_pipeline_xmb_ribbon_simple.glsl.frag.h (100%) delete mode 100644 gfx/drivers/gl_shaders/glsl/frag/shaders_common.h delete mode 100644 gfx/drivers/gl_shaders/glsl/vert/shaders_common.h rename gfx/drivers/gl_shaders/{glsl/frag => }/legacy_opaque.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{glsl/vert => }/legacy_opaque.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{glsl/vert => }/legacy_pipeline_snow.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{glsl/vert => }/legacy_pipeline_xmb_ribbon.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{glsl/vert => }/legacy_pipeline_xmb_ribbon_simple.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{glsl/frag => }/modern_alpha_blend.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{glsl/vert => }/modern_alpha_blend.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{glsl/frag => }/modern_opaque.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{glsl/vert => }/modern_opaque.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{glsl/vert => }/modern_pipeline_xmb_ribbon.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{glsl/vert => }/modern_pipeline_xmb_ribbon_simple.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{cg => }/opaque.cg.h (100%) rename gfx/drivers/gl_shaders/{glsl/frag => }/pipeline_bokeh.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{cg => }/pipeline_nuklear.cg.h (100%) rename gfx/drivers/gl_shaders/{glsl/frag => }/pipeline_nuklear.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{glsl/vert => }/pipeline_nuklear.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{cg => }/pipeline_snow.cg.h (100%) rename gfx/drivers/gl_shaders/{glsl/frag => }/pipeline_snow.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{glsl/vert => }/pipeline_snow.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{glsl/vert => }/pipeline_snow_core.glsl.vert.h (100%) rename gfx/drivers/gl_shaders/{glsl/frag => }/pipeline_snow_simple.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{glsl/frag => }/pipeline_snowflake.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{glsl/frag => }/pipeline_xmb_ribbon.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{cg => }/pipeline_xmb_ribbon_simple.cg.h (100%) rename gfx/drivers/gl_shaders/{glsl/frag => }/pipeline_xmb_ribbon_simple.glsl.frag.h (100%) rename gfx/drivers/gl_shaders/{glsl/glsl_common.h => shaders_common.h} (92%) diff --git a/gfx/drivers/gl_shaders/cg/shaders_common.h b/gfx/drivers/gl_shaders/cg/shaders_common.h deleted file mode 100644 index e9494fe841..0000000000 --- a/gfx/drivers/gl_shaders/cg/shaders_common.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _SHADERS_COMMON -#define _SHADERS_COMMON - -#define CG(src) "" #src - -#endif diff --git a/gfx/drivers/gl_shaders/glsl/frag/core_alpha_blend.glsl.frag.h b/gfx/drivers/gl_shaders/core_alpha_blend.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/frag/core_alpha_blend.glsl.frag.h rename to gfx/drivers/gl_shaders/core_alpha_blend.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/glsl/vert/core_alpha_blend.glsl.vert.h b/gfx/drivers/gl_shaders/core_alpha_blend.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/vert/core_alpha_blend.glsl.vert.h rename to gfx/drivers/gl_shaders/core_alpha_blend.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/glsl/frag/core_opaque.glsl.frag.h b/gfx/drivers/gl_shaders/core_opaque.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/frag/core_opaque.glsl.frag.h rename to gfx/drivers/gl_shaders/core_opaque.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/glsl/vert/core_opaque.glsl.vert.h b/gfx/drivers/gl_shaders/core_opaque.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/vert/core_opaque.glsl.vert.h rename to gfx/drivers/gl_shaders/core_opaque.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/glsl/frag/core_pipeline_bokeh.glsl.frag.h b/gfx/drivers/gl_shaders/core_pipeline_bokeh.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/frag/core_pipeline_bokeh.glsl.frag.h rename to gfx/drivers/gl_shaders/core_pipeline_bokeh.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/glsl/frag/core_pipeline_snow.glsl.frag.h b/gfx/drivers/gl_shaders/core_pipeline_snow.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/frag/core_pipeline_snow.glsl.frag.h rename to gfx/drivers/gl_shaders/core_pipeline_snow.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/glsl/frag/core_pipeline_snow_simple.glsl.frag.h b/gfx/drivers/gl_shaders/core_pipeline_snow_simple.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/frag/core_pipeline_snow_simple.glsl.frag.h rename to gfx/drivers/gl_shaders/core_pipeline_snow_simple.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/glsl/frag/core_pipeline_snowflake.glsl.frag.h b/gfx/drivers/gl_shaders/core_pipeline_snowflake.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/frag/core_pipeline_snowflake.glsl.frag.h rename to gfx/drivers/gl_shaders/core_pipeline_snowflake.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/glsl/frag/core_pipeline_xmb_ribbon.glsl.frag.h b/gfx/drivers/gl_shaders/core_pipeline_xmb_ribbon.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/frag/core_pipeline_xmb_ribbon.glsl.frag.h rename to gfx/drivers/gl_shaders/core_pipeline_xmb_ribbon.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/glsl/frag/core_pipeline_xmb_ribbon_simple.glsl.frag.h b/gfx/drivers/gl_shaders/core_pipeline_xmb_ribbon_simple.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/frag/core_pipeline_xmb_ribbon_simple.glsl.frag.h rename to gfx/drivers/gl_shaders/core_pipeline_xmb_ribbon_simple.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/glsl/frag/shaders_common.h b/gfx/drivers/gl_shaders/glsl/frag/shaders_common.h deleted file mode 100644 index 655861381c..0000000000 --- a/gfx/drivers/gl_shaders/glsl/frag/shaders_common.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _SHADERS_COMMON -#define _SHADERS_COMMON - -#include "../glsl_common.h" - -#endif diff --git a/gfx/drivers/gl_shaders/glsl/vert/shaders_common.h b/gfx/drivers/gl_shaders/glsl/vert/shaders_common.h deleted file mode 100644 index 655861381c..0000000000 --- a/gfx/drivers/gl_shaders/glsl/vert/shaders_common.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _SHADERS_COMMON -#define _SHADERS_COMMON - -#include "../glsl_common.h" - -#endif diff --git a/gfx/drivers/gl_shaders/glsl/frag/legacy_opaque.glsl.frag.h b/gfx/drivers/gl_shaders/legacy_opaque.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/frag/legacy_opaque.glsl.frag.h rename to gfx/drivers/gl_shaders/legacy_opaque.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/glsl/vert/legacy_opaque.glsl.vert.h b/gfx/drivers/gl_shaders/legacy_opaque.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/vert/legacy_opaque.glsl.vert.h rename to gfx/drivers/gl_shaders/legacy_opaque.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/glsl/vert/legacy_pipeline_snow.glsl.vert.h b/gfx/drivers/gl_shaders/legacy_pipeline_snow.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/vert/legacy_pipeline_snow.glsl.vert.h rename to gfx/drivers/gl_shaders/legacy_pipeline_snow.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/glsl/vert/legacy_pipeline_xmb_ribbon.glsl.vert.h b/gfx/drivers/gl_shaders/legacy_pipeline_xmb_ribbon.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/vert/legacy_pipeline_xmb_ribbon.glsl.vert.h rename to gfx/drivers/gl_shaders/legacy_pipeline_xmb_ribbon.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/glsl/vert/legacy_pipeline_xmb_ribbon_simple.glsl.vert.h b/gfx/drivers/gl_shaders/legacy_pipeline_xmb_ribbon_simple.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/vert/legacy_pipeline_xmb_ribbon_simple.glsl.vert.h rename to gfx/drivers/gl_shaders/legacy_pipeline_xmb_ribbon_simple.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/glsl/frag/modern_alpha_blend.glsl.frag.h b/gfx/drivers/gl_shaders/modern_alpha_blend.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/frag/modern_alpha_blend.glsl.frag.h rename to gfx/drivers/gl_shaders/modern_alpha_blend.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/glsl/vert/modern_alpha_blend.glsl.vert.h b/gfx/drivers/gl_shaders/modern_alpha_blend.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/vert/modern_alpha_blend.glsl.vert.h rename to gfx/drivers/gl_shaders/modern_alpha_blend.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/glsl/frag/modern_opaque.glsl.frag.h b/gfx/drivers/gl_shaders/modern_opaque.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/frag/modern_opaque.glsl.frag.h rename to gfx/drivers/gl_shaders/modern_opaque.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/glsl/vert/modern_opaque.glsl.vert.h b/gfx/drivers/gl_shaders/modern_opaque.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/vert/modern_opaque.glsl.vert.h rename to gfx/drivers/gl_shaders/modern_opaque.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/glsl/vert/modern_pipeline_xmb_ribbon.glsl.vert.h b/gfx/drivers/gl_shaders/modern_pipeline_xmb_ribbon.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/vert/modern_pipeline_xmb_ribbon.glsl.vert.h rename to gfx/drivers/gl_shaders/modern_pipeline_xmb_ribbon.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/glsl/vert/modern_pipeline_xmb_ribbon_simple.glsl.vert.h b/gfx/drivers/gl_shaders/modern_pipeline_xmb_ribbon_simple.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/vert/modern_pipeline_xmb_ribbon_simple.glsl.vert.h rename to gfx/drivers/gl_shaders/modern_pipeline_xmb_ribbon_simple.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/cg/opaque.cg.h b/gfx/drivers/gl_shaders/opaque.cg.h similarity index 100% rename from gfx/drivers/gl_shaders/cg/opaque.cg.h rename to gfx/drivers/gl_shaders/opaque.cg.h diff --git a/gfx/drivers/gl_shaders/glsl/frag/pipeline_bokeh.glsl.frag.h b/gfx/drivers/gl_shaders/pipeline_bokeh.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/frag/pipeline_bokeh.glsl.frag.h rename to gfx/drivers/gl_shaders/pipeline_bokeh.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/cg/pipeline_nuklear.cg.h b/gfx/drivers/gl_shaders/pipeline_nuklear.cg.h similarity index 100% rename from gfx/drivers/gl_shaders/cg/pipeline_nuklear.cg.h rename to gfx/drivers/gl_shaders/pipeline_nuklear.cg.h diff --git a/gfx/drivers/gl_shaders/glsl/frag/pipeline_nuklear.glsl.frag.h b/gfx/drivers/gl_shaders/pipeline_nuklear.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/frag/pipeline_nuklear.glsl.frag.h rename to gfx/drivers/gl_shaders/pipeline_nuklear.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/glsl/vert/pipeline_nuklear.glsl.vert.h b/gfx/drivers/gl_shaders/pipeline_nuklear.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/vert/pipeline_nuklear.glsl.vert.h rename to gfx/drivers/gl_shaders/pipeline_nuklear.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/cg/pipeline_snow.cg.h b/gfx/drivers/gl_shaders/pipeline_snow.cg.h similarity index 100% rename from gfx/drivers/gl_shaders/cg/pipeline_snow.cg.h rename to gfx/drivers/gl_shaders/pipeline_snow.cg.h diff --git a/gfx/drivers/gl_shaders/glsl/frag/pipeline_snow.glsl.frag.h b/gfx/drivers/gl_shaders/pipeline_snow.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/frag/pipeline_snow.glsl.frag.h rename to gfx/drivers/gl_shaders/pipeline_snow.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/glsl/vert/pipeline_snow.glsl.vert.h b/gfx/drivers/gl_shaders/pipeline_snow.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/vert/pipeline_snow.glsl.vert.h rename to gfx/drivers/gl_shaders/pipeline_snow.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/glsl/vert/pipeline_snow_core.glsl.vert.h b/gfx/drivers/gl_shaders/pipeline_snow_core.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/vert/pipeline_snow_core.glsl.vert.h rename to gfx/drivers/gl_shaders/pipeline_snow_core.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/glsl/frag/pipeline_snow_simple.glsl.frag.h b/gfx/drivers/gl_shaders/pipeline_snow_simple.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/frag/pipeline_snow_simple.glsl.frag.h rename to gfx/drivers/gl_shaders/pipeline_snow_simple.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/glsl/frag/pipeline_snowflake.glsl.frag.h b/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/frag/pipeline_snowflake.glsl.frag.h rename to gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/glsl/frag/pipeline_xmb_ribbon.glsl.frag.h b/gfx/drivers/gl_shaders/pipeline_xmb_ribbon.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/frag/pipeline_xmb_ribbon.glsl.frag.h rename to gfx/drivers/gl_shaders/pipeline_xmb_ribbon.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/cg/pipeline_xmb_ribbon_simple.cg.h b/gfx/drivers/gl_shaders/pipeline_xmb_ribbon_simple.cg.h similarity index 100% rename from gfx/drivers/gl_shaders/cg/pipeline_xmb_ribbon_simple.cg.h rename to gfx/drivers/gl_shaders/pipeline_xmb_ribbon_simple.cg.h diff --git a/gfx/drivers/gl_shaders/glsl/frag/pipeline_xmb_ribbon_simple.glsl.frag.h b/gfx/drivers/gl_shaders/pipeline_xmb_ribbon_simple.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/glsl/frag/pipeline_xmb_ribbon_simple.glsl.frag.h rename to gfx/drivers/gl_shaders/pipeline_xmb_ribbon_simple.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/glsl/glsl_common.h b/gfx/drivers/gl_shaders/shaders_common.h similarity index 92% rename from gfx/drivers/gl_shaders/glsl/glsl_common.h rename to gfx/drivers/gl_shaders/shaders_common.h index 0c9640a08b..8a97a09ba6 100644 --- a/gfx/drivers/gl_shaders/glsl/glsl_common.h +++ b/gfx/drivers/gl_shaders/shaders_common.h @@ -14,9 +14,11 @@ "#endif\n" #if defined(HAVE_OPENGLES) +#define CG(src) "" #src #define GLSL(src) GLSL_DERIV_PREAMBLE() GLSL_PREAMBLE() #src #define GLSL_330(src) "#version 330 es\n" GLSL_PREAMBLE() #src #else +#define CG(src) "" #src #define GLSL(src) "" GLSL_PREAMBLE() #src #define GLSL_300(src) "#version 300 es\n" GLSL_PREAMBLE() #src #define GLSL_330(src) "#version 330 core\n" GLSL_PREAMBLE() #src diff --git a/gfx/drivers_shader/shader_gl_cg.c b/gfx/drivers_shader/shader_gl_cg.c index 73619ee64f..4e89540b63 100644 --- a/gfx/drivers_shader/shader_gl_cg.c +++ b/gfx/drivers_shader/shader_gl_cg.c @@ -39,8 +39,8 @@ #endif #ifdef HAVE_SHADERPIPELINE -#include "../drivers/gl_shaders/cg/pipeline_xmb_ribbon_simple.cg.h" -#include "../drivers/gl_shaders/cg/pipeline_snow.cg.h" +#include "../drivers/gl_shaders/pipeline_xmb_ribbon_simple.cg.h" +#include "../drivers/gl_shaders/pipeline_snow.cg.h" #endif #include "../include/Cg/cg.h" @@ -132,7 +132,7 @@ struct uniform_cg } -#include "../drivers/gl_shaders/cg/opaque.cg.h" +#include "../drivers/gl_shaders/opaque.cg.h" static void gl_cg_set_uniform_parameter( void *data, diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index 8193b997f0..f9bed812e8 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -105,39 +105,37 @@ static const char *glsl_prefixes[] = { "ruby", }; -#include "../drivers/gl_shaders/glsl/vert/modern_opaque.glsl.vert.h" -#include "../drivers/gl_shaders/glsl/vert/core_opaque.glsl.vert.h" -#include "../drivers/gl_shaders/glsl/vert/legacy_opaque.glsl.vert.h" -#include "../drivers/gl_shaders/glsl/vert/modern_alpha_blend.glsl.vert.h" -#include "../drivers/gl_shaders/glsl/vert/core_alpha_blend.glsl.vert.h" - -#include "../drivers/gl_shaders/glsl/frag/modern_opaque.glsl.frag.h" -#include "../drivers/gl_shaders/glsl/frag/core_opaque.glsl.frag.h" -#include "../drivers/gl_shaders/glsl/frag/legacy_opaque.glsl.frag.h" -#include "../drivers/gl_shaders/glsl/frag/modern_alpha_blend.glsl.frag.h" -#include "../drivers/gl_shaders/glsl/frag/core_alpha_blend.glsl.frag.h" +#include "../drivers/gl_shaders/modern_opaque.glsl.vert.h" +#include "../drivers/gl_shaders/modern_opaque.glsl.frag.h" +#include "../drivers/gl_shaders/core_opaque.glsl.vert.h" +#include "../drivers/gl_shaders/core_opaque.glsl.frag.h" +#include "../drivers/gl_shaders/legacy_opaque.glsl.vert.h" +#include "../drivers/gl_shaders/legacy_opaque.glsl.frag.h" +#include "../drivers/gl_shaders/modern_alpha_blend.glsl.vert.h" +#include "../drivers/gl_shaders/modern_alpha_blend.glsl.frag.h" +#include "../drivers/gl_shaders/core_alpha_blend.glsl.vert.h" +#include "../drivers/gl_shaders/core_alpha_blend.glsl.frag.h" #ifdef HAVE_SHADERPIPELINE -#include "../drivers/gl_shaders/glsl/vert/legacy_pipeline_xmb_ribbon_simple.glsl.vert.h" -#include "../drivers/gl_shaders/glsl/vert/modern_pipeline_xmb_ribbon_simple.glsl.vert.h" -#include "../drivers/gl_shaders/glsl/vert/pipeline_snow.glsl.vert.h" -#include "../drivers/gl_shaders/glsl/vert/pipeline_snow_core.glsl.vert.h" -#include "../drivers/gl_shaders/glsl/vert/legacy_pipeline_snow.glsl.vert.h" -#include "../drivers/gl_shaders/glsl/vert/legacy_pipeline_xmb_ribbon.glsl.vert.h" -#include "../drivers/gl_shaders/glsl/vert/modern_pipeline_xmb_ribbon.glsl.vert.h" - -#include "../drivers/gl_shaders/glsl/frag/core_pipeline_snow.glsl.frag.h" -#include "../drivers/gl_shaders/glsl/frag/core_pipeline_snow_simple.glsl.frag.h" -#include "../drivers/gl_shaders/glsl/frag/core_pipeline_xmb_ribbon.glsl.frag.h" -#include "../drivers/gl_shaders/glsl/frag/core_pipeline_xmb_ribbon_simple.glsl.frag.h" -#include "../drivers/gl_shaders/glsl/frag/core_pipeline_bokeh.glsl.frag.h" -#include "../drivers/gl_shaders/glsl/frag/core_pipeline_snowflake.glsl.frag.h" -#include "../drivers/gl_shaders/glsl/frag/pipeline_xmb_ribbon_simple.glsl.frag.h" -#include "../drivers/gl_shaders/glsl/frag/pipeline_snow.glsl.frag.h" -#include "../drivers/gl_shaders/glsl/frag/pipeline_snow_simple.glsl.frag.h" -#include "../drivers/gl_shaders/glsl/frag/pipeline_xmb_ribbon.glsl.frag.h" -#include "../drivers/gl_shaders/glsl/frag/pipeline_bokeh.glsl.frag.h" -#include "../drivers/gl_shaders/glsl/frag/pipeline_snowflake.glsl.frag.h" +#include "../drivers/gl_shaders/core_pipeline_snow.glsl.frag.h" +#include "../drivers/gl_shaders/core_pipeline_snow_simple.glsl.frag.h" +#include "../drivers/gl_shaders/core_pipeline_xmb_ribbon.glsl.frag.h" +#include "../drivers/gl_shaders/core_pipeline_xmb_ribbon_simple.glsl.frag.h" +#include "../drivers/gl_shaders/core_pipeline_bokeh.glsl.frag.h" +#include "../drivers/gl_shaders/core_pipeline_snowflake.glsl.frag.h" +#include "../drivers/gl_shaders/legacy_pipeline_xmb_ribbon_simple.glsl.vert.h" +#include "../drivers/gl_shaders/modern_pipeline_xmb_ribbon_simple.glsl.vert.h" +#include "../drivers/gl_shaders/pipeline_xmb_ribbon_simple.glsl.frag.h" +#include "../drivers/gl_shaders/pipeline_snow.glsl.frag.h" +#include "../drivers/gl_shaders/pipeline_snow.glsl.vert.h" +#include "../drivers/gl_shaders/pipeline_snow_core.glsl.vert.h" +#include "../drivers/gl_shaders/pipeline_snow_simple.glsl.frag.h" +#include "../drivers/gl_shaders/legacy_pipeline_snow.glsl.vert.h" +#include "../drivers/gl_shaders/legacy_pipeline_xmb_ribbon.glsl.vert.h" +#include "../drivers/gl_shaders/modern_pipeline_xmb_ribbon.glsl.vert.h" +#include "../drivers/gl_shaders/pipeline_xmb_ribbon.glsl.frag.h" +#include "../drivers/gl_shaders/pipeline_bokeh.glsl.frag.h" +#include "../drivers/gl_shaders/pipeline_snowflake.glsl.frag.h" #endif typedef struct glsl_shader_data From 62c6d60c57b9d4ca1af676beae8fb87779c9d0af Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 24 Nov 2018 01:29:35 +0100 Subject: [PATCH 023/153] Revert "Cleanup shaders_common.h" This reverts commit c1de2e569770837d42f0099f95b8838c5f33dc27. --- gfx/drivers/gl_shaders/shaders_common.h | 44 ++++++++++++++----------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/gfx/drivers/gl_shaders/shaders_common.h b/gfx/drivers/gl_shaders/shaders_common.h index 8a97a09ba6..3ea1fbc955 100644 --- a/gfx/drivers/gl_shaders/shaders_common.h +++ b/gfx/drivers/gl_shaders/shaders_common.h @@ -1,27 +1,33 @@ #ifndef _SHADERS_COMMON #define _SHADERS_COMMON -#define GLSL_DERIV_PREAMBLE() "#extension GL_OES_standard_derivatives : enable\n" -#define GLSL_PREAMBLE() \ - "#ifdef GL_ES\n" \ - " #ifdef GL_FRAGMENT_PRECISION_HIGH\n" \ - " precision highp float;\n" \ - " #else\n" \ - " precision mediump float;\n" \ - " #endif\n" \ - "#else\n" \ - " precision mediump float;\n" \ - "#endif\n" - #if defined(HAVE_OPENGLES) -#define CG(src) "" #src -#define GLSL(src) GLSL_DERIV_PREAMBLE() GLSL_PREAMBLE() #src -#define GLSL_330(src) "#version 330 es\n" GLSL_PREAMBLE() #src +#define CG(src) "" #src +#define GLSL(src) "#extension GL_OES_standard_derivatives : enable\n" \ + "#ifdef GL_ES\n" \ + " #ifdef GL_FRAGMENT_PRECISION_HIGH\n" \ + " precision highp float;\n" \ + " #else\n" \ + " precision mediump float;\n" \ + " #endif\n" \ + "#else\n" \ + " precision mediump float;\n" \ + "#endif\n" #src +#define GLSL_330(src) "#version 330 es\n" \ + "#ifdef GL_ES\n" \ + " #ifdef GL_FRAGMENT_PRECISION_HIGH\n" \ + " precision highp float;\n" \ + " #else\n" \ + " precision mediump float;\n" \ + " #endif\n" \ + "#else\n" \ + " precision mediump float;\n" \ + "#endif\n" #src #else -#define CG(src) "" #src -#define GLSL(src) "" GLSL_PREAMBLE() #src -#define GLSL_300(src) "#version 300 es\n" GLSL_PREAMBLE() #src -#define GLSL_330(src) "#version 330 core\n" GLSL_PREAMBLE() #src +#define CG(src) "" #src +#define GLSL(src) "" #src +#define GLSL_300(src) "#version 300 es\n" #src +#define GLSL_330(src) "#version 330 core\n" #src #endif #endif From 45e075c8fe1b8e0274eb3ec20d51f2503992f55f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 24 Nov 2018 01:54:39 +0100 Subject: [PATCH 024/153] Cleanup --- gfx/display_servers/dispserv_win32.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/gfx/display_servers/dispserv_win32.c b/gfx/display_servers/dispserv_win32.c index 54c3a79d02..c680ba4124 100644 --- a/gfx/display_servers/dispserv_win32.c +++ b/gfx/display_servers/dispserv_win32.c @@ -204,13 +204,9 @@ static bool win32_display_server_set_window_decorations(void *data, bool on) static bool win32_display_server_set_resolution(void *data, unsigned width, unsigned height, int int_hz, float hz, int center) { - LONG res; DEVMODE curDevmode; - DEVMODE devmode; - int iModeNum; int freq = int_hz; - DWORD flags = 0; int depth = 0; dispserv_win32_t *serv = (dispserv_win32_t*)data; @@ -239,6 +235,9 @@ static bool win32_display_server_set_resolution(void *data, for (iModeNum = 0;; iModeNum++) { + LONG res; + DEVMODE devmode; + if (!EnumDisplaySettings(NULL, iModeNum, &devmode)) break; @@ -262,15 +261,15 @@ static bool win32_display_server_set_resolution(void *data, switch (res) { case DISP_CHANGE_SUCCESSFUL: - res = win32_change_display_settings(NULL, &devmode, flags); + res = win32_change_display_settings(NULL, &devmode, 0); switch (res) { - case DISP_CHANGE_SUCCESSFUL: - return true; - case DISP_CHANGE_NOTUPDATED: - return true; - default: - break; + case DISP_CHANGE_SUCCESSFUL: + return true; + case DISP_CHANGE_NOTUPDATED: + return true; + default: + break; } break; case DISP_CHANGE_RESTART: From 5d8666e2267672838bed828ff54ec78d64016f8a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 24 Nov 2018 02:06:28 +0100 Subject: [PATCH 025/153] Only one function calls EnumDisplaySettings now --- gfx/common/win32_common.c | 43 ++++++++++++++++------------ gfx/common/win32_common.h | 2 ++ gfx/display_servers/dispserv_win32.c | 4 +-- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index b580a1bcb0..0b77ce9f88 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -1353,15 +1353,13 @@ void win32_get_video_output_prev( unsigned curr_width = 0; unsigned curr_height = 0; - memset(&dm, 0, sizeof(dm)); + if (win32_get_video_output(&dm, -1, sizeof(dm))) + { + curr_width = dm.dmPelsWidth; + curr_height = dm.dmPelsHeight; + } - dm.dmSize = sizeof(dm); - - win32_get_video_output_size(&curr_width, &curr_height); - - for (i = 0; - EnumDisplaySettings(NULL, i, &dm) != 0; - i++) + for (i = 0; win32_get_video_output(&dm, i, sizeof(dm)); i++) { if ( dm.dmPelsWidth == curr_width && dm.dmPelsHeight == curr_height) @@ -1458,14 +1456,13 @@ void win32_get_video_output_next( unsigned curr_width = 0; unsigned curr_height = 0; - memset(&dm, 0, sizeof(dm)); - dm.dmSize = sizeof(dm); + if (win32_get_video_output(&dm, -1, sizeof(dm))) + { + curr_width = dm.dmPelsWidth; + curr_height = dm.dmPelsHeight; + } - win32_get_video_output_size(&curr_width, &curr_height); - - for (i = 0; - EnumDisplaySettings(NULL, i, &dm) != 0; - i++) + for (i = 0; win32_get_video_output(&dm, i, sizeof(dm)); i++) { if (found) { @@ -1480,13 +1477,23 @@ void win32_get_video_output_next( } } +bool win32_get_video_output(DEVMODE *dm, int mode, size_t len) +{ + memset(dm, 0, len); + dm->dmSize = len; + + if (EnumDisplaySettings(NULL, + (mode == -1) ? ENUM_CURRENT_SETTINGS : mode, dm) == 0) + return false; + + return true; +} + void win32_get_video_output_size(unsigned *width, unsigned *height) { DEVMODE dm; - memset(&dm, 0, sizeof(dm)); - dm.dmSize = sizeof(dm); - if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm) != 0) + if (win32_get_video_output(&dm, -1, sizeof(dm))) { *width = dm.dmPelsWidth; *height = dm.dmPelsHeight; diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 04eeeef936..6f899ad491 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -101,6 +101,8 @@ void win32_check_window(bool *quit, void win32_set_window(unsigned *width, unsigned *height, bool fullscreen, bool windowed_full, void *rect_data); +bool win32_get_video_output(DEVMODE *dm, int mode, size_t len); + void win32_get_video_output_size( unsigned *width, unsigned *height); diff --git a/gfx/display_servers/dispserv_win32.c b/gfx/display_servers/dispserv_win32.c index c680ba4124..97469906c6 100644 --- a/gfx/display_servers/dispserv_win32.c +++ b/gfx/display_servers/dispserv_win32.c @@ -213,7 +213,7 @@ static bool win32_display_server_set_resolution(void *data, if (!serv) return false; - EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &curDevmode); + win32_get_video_output(&curDevmode, -1, sizeof(curDevmode)); if (win32_orig_width == 0) win32_orig_width = GetSystemMetrics(SM_CXSCREEN); @@ -238,7 +238,7 @@ static bool win32_display_server_set_resolution(void *data, LONG res; DEVMODE devmode; - if (!EnumDisplaySettings(NULL, iModeNum, &devmode)) + if (!win32_get_video_output(&devmode, iModeNum, sizeof(devmode))) break; if (devmode.dmPelsWidth != width) From fdb4d2b6ad8b2060e65b31e7d5bcfdcd075de76a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 24 Nov 2018 02:47:22 +0100 Subject: [PATCH 026/153] Add get_resolution_list for Win32 --- gfx/display_servers/dispserv_null.c | 7 +++--- gfx/display_servers/dispserv_win32.c | 34 ++++++++++++++++++++++++++++ gfx/display_servers/dispserv_x11.c | 3 ++- gfx/video_display_server.h | 11 +++++++++ 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/gfx/display_servers/dispserv_null.c b/gfx/display_servers/dispserv_null.c index 22b326cbda..8e17292762 100644 --- a/gfx/display_servers/dispserv_null.c +++ b/gfx/display_servers/dispserv_null.c @@ -48,9 +48,10 @@ const video_display_server_t dispserv_null = { null_display_server_destroy, null_display_server_set_window_opacity, null_display_server_set_window_progress, - NULL, - NULL, - NULL, + NULL, /* set_window_decorations */ + NULL, /* set_resolution */ + NULL, /* get_resolution_list */ + NULL, /* get_output_options */ "null" }; diff --git a/gfx/display_servers/dispserv_win32.c b/gfx/display_servers/dispserv_win32.c index 97469906c6..da7e1f4508 100644 --- a/gfx/display_servers/dispserv_win32.c +++ b/gfx/display_servers/dispserv_win32.c @@ -282,6 +282,39 @@ static bool win32_display_server_set_resolution(void *data, return true; } +unsigned win32_display_server_get_resolution_list(struct video_display_config **conf) +{ + unsigned i; + unsigned len = 0; + + for (i = 0;; i++) + { + void *optr = NULL; + DEVMODE dm; + + if (!win32_get_video_output(&dm, i, sizeof(dm))) + continue; + + len++; + + if (*conf) + optr = realloc(*conf, len); + else + optr = malloc(len); + + if (optr) + *conf = optr; + + conf[i]->width = dm.dmPelsWidth; + conf[i]->height = dm.dmPelsHeight; + conf[i]->bpp = dm.dmBitsPerPel; + conf[i]->refreshrate = dm.dmDisplayFrequency; + conf[i]->idx = i; + } + + return len; +} + const video_display_server_t dispserv_win32 = { win32_display_server_init, win32_display_server_destroy, @@ -289,6 +322,7 @@ const video_display_server_t dispserv_win32 = { win32_display_server_set_window_progress, win32_display_server_set_window_decorations, win32_display_server_set_resolution, + win32_display_server_get_resolution_list, NULL, /* get_output_options */ "win32" }; diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index f4f6f16f7a..92dcf34d4b 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -306,9 +306,10 @@ const video_display_server_t dispserv_x11 = { x11_display_server_init, x11_display_server_destroy, x11_display_server_set_window_opacity, - NULL, + NULL, /* set_window_progress */ x11_display_server_set_window_decorations, x11_display_server_set_resolution, + NULL, /* get_resolution_list */ x11_display_server_get_output_options, "x11" }; diff --git a/gfx/video_display_server.h b/gfx/video_display_server.h index 9a39100807..ee8ddf7266 100644 --- a/gfx/video_display_server.h +++ b/gfx/video_display_server.h @@ -23,6 +23,16 @@ RETRO_BEGIN_DECLS +typedef struct video_display_config +{ + unsigned width; + unsigned height; + unsigned bpp; + unsigned refreshrate; + unsigned idx; + bool current; +} video_display_config_t; + typedef struct video_display_server { void *(*init)(void); @@ -32,6 +42,7 @@ typedef struct video_display_server bool (*set_window_decorations)(void *data, bool on); bool (*switch_resolution)(void *data, unsigned width, unsigned height, int int_hz, float hz, int center); + unsigned (*get_resolution_list)(struct video_display_config **conf); const char *(*get_output_options)(void *data); const char *ident; } video_display_server_t; From 0ae3d3873df2cc0ae60bec990ad623ff90f1640a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 24 Nov 2018 02:50:04 +0100 Subject: [PATCH 027/153] Create video_display_server_get_resolution_list --- gfx/display_servers/dispserv_win32.c | 3 ++- gfx/video_display_server.c | 7 +++++++ gfx/video_display_server.h | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gfx/display_servers/dispserv_win32.c b/gfx/display_servers/dispserv_win32.c index da7e1f4508..869941e9dc 100644 --- a/gfx/display_servers/dispserv_win32.c +++ b/gfx/display_servers/dispserv_win32.c @@ -282,7 +282,8 @@ static bool win32_display_server_set_resolution(void *data, return true; } -unsigned win32_display_server_get_resolution_list(struct video_display_config **conf) +unsigned win32_display_server_get_resolution_list(void *data, + struct video_display_config **conf) { unsigned i; unsigned len = 0; diff --git a/gfx/video_display_server.c b/gfx/video_display_server.c index 98fd57eca1..8e10af2727 100644 --- a/gfx/video_display_server.c +++ b/gfx/video_display_server.c @@ -98,6 +98,13 @@ bool video_display_server_switch_resolution(unsigned width, unsigned height, return false; } +unsigned video_display_server_get_resolution_list(struct video_display_config **list) +{ + if (current_display_server && current_display_server->get_resolution_list) + return current_display_server->get_resolution_list(current_display_server_data, list); + return 0; +} + const char *video_display_server_get_output_options(void) { if (current_display_server && current_display_server->get_output_options) diff --git a/gfx/video_display_server.h b/gfx/video_display_server.h index ee8ddf7266..43b9b4cefb 100644 --- a/gfx/video_display_server.h +++ b/gfx/video_display_server.h @@ -42,7 +42,8 @@ typedef struct video_display_server bool (*set_window_decorations)(void *data, bool on); bool (*switch_resolution)(void *data, unsigned width, unsigned height, int int_hz, float hz, int center); - unsigned (*get_resolution_list)(struct video_display_config **conf); + unsigned (*get_resolution_list)(void *data, + struct video_display_config **conf); const char *(*get_output_options)(void *data); const char *ident; } video_display_server_t; @@ -61,6 +62,9 @@ bool video_display_server_switch_resolution( unsigned width, unsigned height, int int_hz, float hz, int center); +unsigned video_display_server_get_resolution_list( + struct video_display_config **list); + const char *video_display_server_get_output_options(void); const char *video_display_server_get_ident(void); From 7730828560924c87c1b45f8b3b3dffdab34cb62e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 24 Nov 2018 10:31:05 +0100 Subject: [PATCH 028/153] Start implementing dropdown list for resolution - Win32 right now at first - now need to make OK button do something --- gfx/display_servers/dispserv_win32.c | 49 +-- gfx/video_display_server.c | 6 +- gfx/video_display_server.h | 7 +- gfx/video_driver.c | 9 - intl/msg_hash_lbl.h | 2 + menu/cbs/menu_cbs_deferred_push.c | 6 + menu/cbs/menu_cbs_ok.c | 33 ++ menu/cbs/menu_cbs_title.c | 6 + menu/menu_cbs.h | 1 + menu/menu_displaylist.c | 555 ++++++++++++++------------- menu/menu_displaylist.h | 1 + menu/menu_driver.h | 1 + menu/menu_setting.c | 8 + msg_hash.h | 1 + 14 files changed, 385 insertions(+), 300 deletions(-) diff --git a/gfx/display_servers/dispserv_win32.c b/gfx/display_servers/dispserv_win32.c index 869941e9dc..5634a044a5 100644 --- a/gfx/display_servers/dispserv_win32.c +++ b/gfx/display_servers/dispserv_win32.c @@ -282,38 +282,43 @@ static bool win32_display_server_set_resolution(void *data, return true; } -unsigned win32_display_server_get_resolution_list(void *data, - struct video_display_config **conf) +void *win32_display_server_get_resolution_list(void *data, + unsigned *len) { - unsigned i; - unsigned len = 0; + unsigned i, count = 0; + struct video_display_config *conf = NULL; for (i = 0;; i++) { - void *optr = NULL; DEVMODE dm; if (!win32_get_video_output(&dm, i, sizeof(dm))) - continue; + break; - len++; - - if (*conf) - optr = realloc(*conf, len); - else - optr = malloc(len); - - if (optr) - *conf = optr; - - conf[i]->width = dm.dmPelsWidth; - conf[i]->height = dm.dmPelsHeight; - conf[i]->bpp = dm.dmBitsPerPel; - conf[i]->refreshrate = dm.dmDisplayFrequency; - conf[i]->idx = i; + count++; } - return len; + *len = count; + conf = (struct video_display_config*)calloc(*len, sizeof(struct video_display_config)); + + if (!conf) + return NULL; + + for (i = 0;; i++) + { + DEVMODE dm; + + if (!win32_get_video_output(&dm, i, sizeof(dm))) + break; + + conf[i].width = dm.dmPelsWidth; + conf[i].height = dm.dmPelsHeight; + conf[i].bpp = dm.dmBitsPerPel; + conf[i].refreshrate = dm.dmDisplayFrequency; + conf[i].idx = i; + } + + return conf; } const video_display_server_t dispserv_win32 = { diff --git a/gfx/video_display_server.c b/gfx/video_display_server.c index 8e10af2727..94d6186469 100644 --- a/gfx/video_display_server.c +++ b/gfx/video_display_server.c @@ -98,11 +98,11 @@ bool video_display_server_switch_resolution(unsigned width, unsigned height, return false; } -unsigned video_display_server_get_resolution_list(struct video_display_config **list) +void *video_display_server_get_resolution_list(unsigned *size) { if (current_display_server && current_display_server->get_resolution_list) - return current_display_server->get_resolution_list(current_display_server_data, list); - return 0; + return current_display_server->get_resolution_list(current_display_server_data, size); + return NULL; } const char *video_display_server_get_output_options(void) diff --git a/gfx/video_display_server.h b/gfx/video_display_server.h index 43b9b4cefb..97a06bd018 100644 --- a/gfx/video_display_server.h +++ b/gfx/video_display_server.h @@ -42,8 +42,8 @@ typedef struct video_display_server bool (*set_window_decorations)(void *data, bool on); bool (*switch_resolution)(void *data, unsigned width, unsigned height, int int_hz, float hz, int center); - unsigned (*get_resolution_list)(void *data, - struct video_display_config **conf); + void *(*get_resolution_list)(void *data, + unsigned *size); const char *(*get_output_options)(void *data); const char *ident; } video_display_server_t; @@ -62,8 +62,7 @@ bool video_display_server_switch_resolution( unsigned width, unsigned height, int int_hz, float hz, int center); -unsigned video_display_server_get_resolution_list( - struct video_display_config **list); +void *video_display_server_get_resolution_list(unsigned *size); const char *video_display_server_get_output_options(void); diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 75f2f46bfb..aae7a7c4c3 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -1491,15 +1491,6 @@ void video_driver_menu_settings(void **list_data, void *list_info_data, (void)subgroup_info; (void)global; -#if defined(GEKKO) || defined(__CELLOS_LV2__) - CONFIG_ACTION( - list, list_info, - MENU_ENUM_LABEL_SCREEN_RESOLUTION, - MENU_ENUM_LABEL_VALUE_SCREEN_RESOLUTION, - group_info, - subgroup_info, - parent_group); -#endif #if defined(__CELLOS_LV2__) CONFIG_BOOL( list, list_info, diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index 9ac9cf2db7..4620278a65 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -259,6 +259,8 @@ MSG_HASH(MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST, "deferred_dropdown_box_list") MSG_HASH(MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_SPECIAL, "deferred_dropdown_box_list_special") +MSG_HASH(MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_RESOLUTION, + "deferred_dropdown_box_list_resolution") MSG_HASH(MENU_ENUM_LABEL_DEFERRED_CONFIGURATIONS_LIST, "deferred_configurations_list") MSG_HASH(MENU_ENUM_LABEL_DEFERRED_PLAYLIST_LIST, diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 39fd92b9ff..7f8d37d4cc 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -613,6 +613,7 @@ generic_deferred_push_clear_general(deferred_image_history_list, PUSH_DEFAULT, D generic_deferred_push_clear_general(deferred_video_history_list, PUSH_DEFAULT, DISPLAYLIST_VIDEO_HISTORY) generic_deferred_push_clear_general(deferred_push_dropdown_box_list, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST) generic_deferred_push_clear_general(deferred_push_dropdown_box_list_special, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_SPECIAL) +generic_deferred_push_clear_general(deferred_push_dropdown_box_list_resolution, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_RESOLUTION) static int menu_cbs_init_bind_deferred_push_compare_label( menu_file_list_cbs_t *cbs, @@ -633,6 +634,11 @@ static int menu_cbs_init_bind_deferred_push_compare_label( BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_dropdown_box_list_special); return 0; } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_RESOLUTION))) + { + BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_dropdown_box_list_resolution); + return 0; + } else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_BROWSE_URL_LIST))) { BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_browse_url_list); diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 577e7d993e..909c1116b9 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -150,6 +150,8 @@ static enum msg_hash_enums action_ok_dl_to_enum(unsigned lbl) return MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST; case ACTION_OK_DL_DROPDOWN_BOX_LIST_SPECIAL: return MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_SPECIAL; + case ACTION_OK_DL_DROPDOWN_BOX_LIST_RESOLUTION: + return MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_RESOLUTION; case ACTION_OK_DL_MIXER_STREAM_SETTINGS_LIST: return MENU_ENUM_LABEL_DEFERRED_MIXER_STREAM_SETTINGS_LIST; case ACTION_OK_DL_ACCOUNTS_LIST: @@ -323,6 +325,15 @@ int generic_action_ok_displaylist_push(const char *path, info.enum_idx = MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_SPECIAL; dl_type = DISPLAYLIST_GENERIC; break; + case ACTION_OK_DL_DROPDOWN_BOX_LIST_RESOLUTION: + info.type = type; + info.directory_ptr = idx; + info_path = path; + info_label = msg_hash_to_str( + MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_RESOLUTION); + info.enum_idx = MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_RESOLUTION; + dl_type = DISPLAYLIST_GENERIC; + break; case ACTION_OK_DL_USER_BINDS_LIST: info.type = type; info.directory_ptr = idx; @@ -4449,6 +4460,18 @@ static int action_ok_push_dropdown_item(const char *path, return 0; } +static int action_ok_push_dropdown_item_resolution(const char *path, + const char *label, unsigned type, size_t idx, size_t entry_idx) +{ + RARCH_LOG("dropdown: \n"); + RARCH_LOG("path: %s \n", path); + RARCH_LOG("label: %s \n", label); + RARCH_LOG("type: %d \n", type); + RARCH_LOG("idx: %d \n", idx); + RARCH_LOG("entry_idx: %d \n", entry_idx); + return 0; +} + static int action_ok_push_default(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { @@ -4587,6 +4610,7 @@ default_action_ok_help(action_ok_help_load_content, MENU_ENUM_LABEL_HELP_LOADING static int action_ok_video_resolution(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { +#if defined(__CELLOS_LV2__) || defined(GEKKO) unsigned width = 0; unsigned height = 0; @@ -4610,6 +4634,12 @@ static int action_ok_video_resolution(const char *path, width, height); runloop_msg_queue_push(msg, 1, 100, true); } +#else + generic_action_ok_displaylist_push( + NULL, + NULL, NULL, 0, 0, 0, + ACTION_OK_DL_DROPDOWN_BOX_LIST_RESOLUTION); +#endif return 0; } @@ -5555,6 +5585,9 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs, case MENU_SETTING_DROPDOWN_ITEM: BIND_ACTION_OK(cbs, action_ok_push_dropdown_item); break; + case MENU_SETTING_DROPDOWN_ITEM_RESOLUTION: + BIND_ACTION_OK(cbs, action_ok_push_dropdown_item_resolution); + break; case MENU_SETTING_ACTION_CORE_DISK_OPTIONS: BIND_ACTION_OK(cbs, action_ok_push_default); break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index de5b97afa9..b3dc2440b8 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -1251,6 +1251,12 @@ int menu_cbs_init_bind_title(menu_file_list_cbs_t *cbs, BIND_ACTION_GET_TITLE(cbs, action_get_title_dropdown_item); return 0; } + if (string_is_equal(label, + msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_RESOLUTION))) + { + BIND_ACTION_GET_TITLE(cbs, action_get_title_dropdown_item); + return 0; + } if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_RPL_ENTRY_ACTIONS))) { BIND_ACTION_GET_TITLE(cbs, action_get_quick_menu_views_settings_list); diff --git a/menu/menu_cbs.h b/menu/menu_cbs.h index 1b69dffcd7..ed34b73021 100644 --- a/menu/menu_cbs.h +++ b/menu/menu_cbs.h @@ -45,6 +45,7 @@ enum ACTION_OK_DL_DEFAULT = 0, ACTION_OK_DL_DROPDOWN_BOX_LIST, ACTION_OK_DL_DROPDOWN_BOX_LIST_SPECIAL, + ACTION_OK_DL_DROPDOWN_BOX_LIST_RESOLUTION, ACTION_OK_DL_OPEN_ARCHIVE, ACTION_OK_DL_OPEN_ARCHIVE_DETECT_CORE, ACTION_OK_DL_MUSIC, diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index ac59ae52a7..ededbc3812 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -8322,56 +8322,201 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist info->need_push = true; } break; - case DISPLAYLIST_DROPDOWN_LIST_SPECIAL: + case DISPLAYLIST_DROPDOWN_LIST_RESOLUTION: + menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); { - menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); + unsigned i, size = 0; + struct video_display_config *list = video_display_server_get_resolution_list(&size); - if (strstr(info->path, "core_option_")) + if (list) { - struct string_list *tmp_str_list = string_split(info->path, "_"); - - if (tmp_str_list && tmp_str_list->size > 0) + for (i = 0; i < size; i++) { - core_option_manager_t *coreopts = NULL; + char val_d[256], str[256]; + snprintf(str, sizeof(str), "%dx%d (%dHz)", list[i].width, list[i].height, list[i].refreshrate); + snprintf(val_d, sizeof(val_d), "%d", i); + menu_entries_append_enum(info->list, + str, + val_d, + MENU_ENUM_LABEL_NO_ITEMS, + MENU_SETTING_DROPDOWN_ITEM_RESOLUTION, list[i].idx, 0); + } - rarch_ctl(RARCH_CTL_CORE_OPTIONS_LIST_GET, &coreopts); + free(list); + } + else + menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_ENTRIES_TO_DISPLAY), + msg_hash_to_str(MENU_ENUM_LABEL_NO_ENTRIES_TO_DISPLAY), + MENU_ENUM_LABEL_NO_ENTRIES_TO_DISPLAY, + FILE_TYPE_NONE, 0, 0); - if (coreopts) + } + info->need_refresh = true; + info->need_push = true; + break; + case DISPLAYLIST_DROPDOWN_LIST_SPECIAL: + menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); + + if (strstr(info->path, "core_option_")) + { + struct string_list *tmp_str_list = string_split(info->path, "_"); + + if (tmp_str_list && tmp_str_list->size > 0) + { + core_option_manager_t *coreopts = NULL; + + rarch_ctl(RARCH_CTL_CORE_OPTIONS_LIST_GET, &coreopts); + + if (coreopts) + { + unsigned size = (unsigned)tmp_str_list->size; + unsigned i = atoi(tmp_str_list->elems[size-1].data); + struct core_option *option = NULL; + bool checked_found = false; + unsigned checked = 0; + const char *val = core_option_manager_get_val(coreopts, i-1); + + i--; + + option = (struct core_option*)&coreopts->opts[i]; + + if (option) { - unsigned size = (unsigned)tmp_str_list->size; - unsigned i = atoi(tmp_str_list->elems[size-1].data); - struct core_option *option = NULL; - bool checked_found = false; - unsigned checked = 0; - const char *val = core_option_manager_get_val(coreopts, i-1); - - i--; - - option = (struct core_option*)&coreopts->opts[i]; - - if (option) + unsigned k; + for (k = 0; k < option->vals->size; k++) { - unsigned k; - for (k = 0; k < option->vals->size; k++) - { - const char *str = option->vals->elems[k].data; + const char *str = option->vals->elems[k].data; - if (!string_is_empty(str)) + if (!string_is_empty(str)) + { + char val_d[256]; + snprintf(val_d, sizeof(val_d), "%d", i); + menu_entries_append_enum(info->list, + str, + val_d, + MENU_ENUM_LABEL_NO_ITEMS, + MENU_SETTING_DROPDOWN_SETTING_CORE_OPTIONS_ITEM_SPECIAL, k, 0); + + if (!checked_found && string_is_equal(str, val)) + { + checked = k; + checked_found = true; + } + + count++; + } + } + + if (checked_found) + menu_entries_set_checked(info->list, checked, true); + } + } + } + + } + else + { + enum msg_hash_enums enum_idx = (enum msg_hash_enums)atoi(info->path); + rarch_setting_t *setting = menu_setting_find_enum(enum_idx); + + if (setting) + { + switch (setting->type) + { + case ST_STRING_OPTIONS: + { + struct string_list *tmp_str_list = string_split(setting->values, "|"); + + if (tmp_str_list && tmp_str_list->size > 0) + { + unsigned i; + unsigned size = (unsigned)tmp_str_list->size; + bool checked_found = false; + unsigned checked = 0; + + for (i = 0; i < size; i++) { char val_d[256]; - snprintf(val_d, sizeof(val_d), "%d", i); + snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx); menu_entries_append_enum(info->list, - str, + tmp_str_list->elems[i].data, val_d, MENU_ENUM_LABEL_NO_ITEMS, - MENU_SETTING_DROPDOWN_SETTING_CORE_OPTIONS_ITEM_SPECIAL, k, 0); + MENU_SETTING_DROPDOWN_SETTING_STRING_OPTIONS_ITEM_SPECIAL, i, 0); - if (!checked_found && string_is_equal(str, val)) + if (!checked_found && string_is_equal(tmp_str_list->elems[i].data, setting->value.target.string)) { - checked = k; + checked = i; checked_found = true; } + } + if (checked_found) + menu_entries_set_checked(info->list, checked, true); + } + } + break; + case ST_INT: + { + float i; + int32_t orig_value = *setting->value.target.integer; + unsigned setting_type = MENU_SETTING_DROPDOWN_SETTING_INT_ITEM_SPECIAL; + float step = setting->step; + double min = setting->enforce_minrange ? setting->min : 0.00; + double max = setting->enforce_maxrange ? setting->max : 999.00; + bool checked_found = false; + unsigned checked = 0; + + if (setting->get_string_representation) + { + for (i = min; i <= max; i += step) + { + char val_s[256], val_d[256]; + int val = (int)i; + + *setting->value.target.integer = val; + + setting->get_string_representation(setting, + val_s, sizeof(val_s)); + snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx); + menu_entries_append_enum(info->list, + val_s, + val_d, + MENU_ENUM_LABEL_NO_ITEMS, + setting_type, val, 0); + + if (!checked_found && val == orig_value) + { + checked = count; + checked_found = true; + } + count++; + } + + *setting->value.target.integer = orig_value; + } + else + { + for (i = min; i <= max; i += step) + { + char val_s[16], val_d[16]; + int val = (int)i; + + snprintf(val_s, sizeof(val_s), "%d", val); + snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx); + + menu_entries_append_enum(info->list, + val_s, + val_d, + MENU_ENUM_LABEL_NO_ITEMS, + setting_type, val, 0); + + if (!checked_found && val == orig_value) + { + checked = count; + checked_found = true; + } count++; } } @@ -8379,263 +8524,149 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist if (checked_found) menu_entries_set_checked(info->list, checked, true); } - } - } + break; + case ST_FLOAT: + { + float i; + float orig_value = *setting->value.target.fraction; + unsigned setting_type = MENU_SETTING_DROPDOWN_SETTING_FLOAT_ITEM_SPECIAL; + float step = setting->step; + double min = setting->enforce_minrange ? setting->min : 0.00; + double max = setting->enforce_maxrange ? setting->max : 999.00; + bool checked_found = false; + unsigned checked = 0; - } - else - { - enum msg_hash_enums enum_idx = (enum msg_hash_enums)atoi(info->path); - rarch_setting_t *setting = menu_setting_find_enum(enum_idx); - - if (setting) - { - switch (setting->type) - { - case ST_STRING_OPTIONS: + if (setting->get_string_representation) { - struct string_list *tmp_str_list = string_split(setting->values, "|"); - - if (tmp_str_list && tmp_str_list->size > 0) + for (i = min; i <= max; i += step) { - unsigned i; - unsigned size = (unsigned)tmp_str_list->size; - bool checked_found = false; - unsigned checked = 0; + char val_s[256], val_d[256]; - for (i = 0; i < size; i++) + *setting->value.target.fraction = i; + + setting->get_string_representation(setting, + val_s, sizeof(val_s)); + snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx); + menu_entries_append_enum(info->list, + val_s, + val_d, + MENU_ENUM_LABEL_NO_ITEMS, + setting_type, 0, 0); + + if (!checked_found && fabs(i - orig_value) <= 0.01f) { - char val_d[256]; - snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx); - menu_entries_append_enum(info->list, - tmp_str_list->elems[i].data, - val_d, - MENU_ENUM_LABEL_NO_ITEMS, - MENU_SETTING_DROPDOWN_SETTING_STRING_OPTIONS_ITEM_SPECIAL, i, 0); - - if (!checked_found && string_is_equal(tmp_str_list->elems[i].data, setting->value.target.string)) - { - checked = i; - checked_found = true; - } + checked = count; + checked_found = true; } + count++; + } - if (checked_found) - menu_entries_set_checked(info->list, checked, true); + *setting->value.target.fraction = orig_value; + } + else + { + for (i = min; i <= max; i += step) + { + char val_s[16], val_d[16]; + + snprintf(val_s, sizeof(val_s), "%.2f", i); + snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx); + + menu_entries_append_enum(info->list, + val_s, + val_d, + MENU_ENUM_LABEL_NO_ITEMS, + setting_type, 0, 0); + + if (!checked_found && fabs(i - orig_value) <= 0.01f) + { + checked = count; + checked_found = true; + } + count++; } } - break; - case ST_INT: + + if (checked_found) + menu_entries_set_checked(info->list, checked, true); + } + break; + case ST_UINT: + { + float i; + unsigned orig_value = *setting->value.target.unsigned_integer; + unsigned setting_type = MENU_SETTING_DROPDOWN_SETTING_UINT_ITEM_SPECIAL; + float step = setting->step; + double min = setting->enforce_minrange ? setting->min : 0.00; + double max = setting->enforce_maxrange ? setting->max : 999.00; + bool checked_found = false; + unsigned checked = 0; + + if (setting->get_string_representation) { - float i; - int32_t orig_value = *setting->value.target.integer; - unsigned setting_type = MENU_SETTING_DROPDOWN_SETTING_INT_ITEM_SPECIAL; - float step = setting->step; - double min = setting->enforce_minrange ? setting->min : 0.00; - double max = setting->enforce_maxrange ? setting->max : 999.00; - bool checked_found = false; - unsigned checked = 0; - - if (setting->get_string_representation) + for (i = min; i <= max; i += step) { - for (i = min; i <= max; i += step) + char val_s[256], val_d[256]; + int val = (int)i; + + *setting->value.target.unsigned_integer = val; + + setting->get_string_representation(setting, + val_s, sizeof(val_s)); + snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx); + menu_entries_append_enum(info->list, + val_s, + val_d, + MENU_ENUM_LABEL_NO_ITEMS, + setting_type, val, 0); + + if (!checked_found && val == orig_value) { - char val_s[256], val_d[256]; - int val = (int)i; - - *setting->value.target.integer = val; - - setting->get_string_representation(setting, - val_s, sizeof(val_s)); - snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx); - menu_entries_append_enum(info->list, - val_s, - val_d, - MENU_ENUM_LABEL_NO_ITEMS, - setting_type, val, 0); - - if (!checked_found && val == orig_value) - { - checked = count; - checked_found = true; - } - count++; - } - - *setting->value.target.integer = orig_value; - } - else - { - for (i = min; i <= max; i += step) - { - char val_s[16], val_d[16]; - int val = (int)i; - - snprintf(val_s, sizeof(val_s), "%d", val); - snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx); - - menu_entries_append_enum(info->list, - val_s, - val_d, - MENU_ENUM_LABEL_NO_ITEMS, - setting_type, val, 0); - - if (!checked_found && val == orig_value) - { - checked = count; - checked_found = true; - } - count++; + checked = count; + checked_found = true; } + count++; } - if (checked_found) - menu_entries_set_checked(info->list, checked, true); + *setting->value.target.unsigned_integer = orig_value; } - break; - case ST_FLOAT: + else { - float i; - float orig_value = *setting->value.target.fraction; - unsigned setting_type = MENU_SETTING_DROPDOWN_SETTING_FLOAT_ITEM_SPECIAL; - float step = setting->step; - double min = setting->enforce_minrange ? setting->min : 0.00; - double max = setting->enforce_maxrange ? setting->max : 999.00; - bool checked_found = false; - unsigned checked = 0; - - if (setting->get_string_representation) + for (i = min; i <= max; i += step) { - for (i = min; i <= max; i += step) + char val_s[16], val_d[16]; + int val = (int)i; + + snprintf(val_s, sizeof(val_s), "%d", val); + snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx); + + menu_entries_append_enum(info->list, + val_s, + val_d, + MENU_ENUM_LABEL_NO_ITEMS, + setting_type, val, 0); + + if (!checked_found && val == orig_value) { - char val_s[256], val_d[256]; - - *setting->value.target.fraction = i; - - setting->get_string_representation(setting, - val_s, sizeof(val_s)); - snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx); - menu_entries_append_enum(info->list, - val_s, - val_d, - MENU_ENUM_LABEL_NO_ITEMS, - setting_type, 0, 0); - - if (!checked_found && fabs(i - orig_value) <= 0.01f) - { - checked = count; - checked_found = true; - } - count++; + checked = count; + checked_found = true; } - - *setting->value.target.fraction = orig_value; + count++; } - else - { - for (i = min; i <= max; i += step) - { - char val_s[16], val_d[16]; - - snprintf(val_s, sizeof(val_s), "%.2f", i); - snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx); - - menu_entries_append_enum(info->list, - val_s, - val_d, - MENU_ENUM_LABEL_NO_ITEMS, - setting_type, 0, 0); - - if (!checked_found && fabs(i - orig_value) <= 0.01f) - { - checked = count; - checked_found = true; - } - count++; - } - } - - if (checked_found) - menu_entries_set_checked(info->list, checked, true); } - break; - case ST_UINT: - { - float i; - unsigned orig_value = *setting->value.target.unsigned_integer; - unsigned setting_type = MENU_SETTING_DROPDOWN_SETTING_UINT_ITEM_SPECIAL; - float step = setting->step; - double min = setting->enforce_minrange ? setting->min : 0.00; - double max = setting->enforce_maxrange ? setting->max : 999.00; - bool checked_found = false; - unsigned checked = 0; - if (setting->get_string_representation) - { - for (i = min; i <= max; i += step) - { - char val_s[256], val_d[256]; - int val = (int)i; - - *setting->value.target.unsigned_integer = val; - - setting->get_string_representation(setting, - val_s, sizeof(val_s)); - snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx); - menu_entries_append_enum(info->list, - val_s, - val_d, - MENU_ENUM_LABEL_NO_ITEMS, - setting_type, val, 0); - - if (!checked_found && val == orig_value) - { - checked = count; - checked_found = true; - } - count++; - } - - *setting->value.target.unsigned_integer = orig_value; - } - else - { - for (i = min; i <= max; i += step) - { - char val_s[16], val_d[16]; - int val = (int)i; - - snprintf(val_s, sizeof(val_s), "%d", val); - snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx); - - menu_entries_append_enum(info->list, - val_s, - val_d, - MENU_ENUM_LABEL_NO_ITEMS, - setting_type, val, 0); - - if (!checked_found && val == orig_value) - { - checked = count; - checked_found = true; - } - count++; - } - } - - if (checked_found) - menu_entries_set_checked(info->list, checked, true); - } - break; - default: - break; - } + if (checked_found) + menu_entries_set_checked(info->list, checked, true); + } + break; + default: + break; } } - - info->need_refresh = true; - info->need_push = true; } + + info->need_refresh = true; + info->need_push = true; break; case DISPLAYLIST_NONE: break; diff --git a/menu/menu_displaylist.h b/menu/menu_displaylist.h index 79b8603dbd..a2a71f2af2 100644 --- a/menu/menu_displaylist.h +++ b/menu/menu_displaylist.h @@ -56,6 +56,7 @@ enum menu_displaylist_ctl_state DISPLAYLIST_NONE = 0, DISPLAYLIST_DROPDOWN_LIST, DISPLAYLIST_DROPDOWN_LIST_SPECIAL, + DISPLAYLIST_DROPDOWN_LIST_RESOLUTION, DISPLAYLIST_INFO, DISPLAYLIST_HELP, DISPLAYLIST_HELP_SCREEN_LIST, diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 25fc929b50..0e97b73a3f 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -143,6 +143,7 @@ enum menu_settings_type MENU_ADD_TAB, MENU_PLAYLISTS_TAB, MENU_SETTING_DROPDOWN_ITEM, + MENU_SETTING_DROPDOWN_ITEM_RESOLUTION, MENU_SETTING_DROPDOWN_SETTING_CORE_OPTIONS_ITEM, MENU_SETTING_DROPDOWN_SETTING_STRING_OPTIONS_ITEM, MENU_SETTING_DROPDOWN_SETTING_FLOAT_ITEM, diff --git a/menu/menu_setting.c b/menu/menu_setting.c index b7af68fac5..cd1904ea0d 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -5381,6 +5381,14 @@ static bool setting_append_list( CMD_EVENT_VIDEO_APPLY_STATE_CHANGES); settings_data_list_current_add_flags(list, list_info, SD_FLAG_LAKKA_ADVANCED); + CONFIG_ACTION( + list, list_info, + MENU_ENUM_LABEL_SCREEN_RESOLUTION, + MENU_ENUM_LABEL_VALUE_SCREEN_RESOLUTION, + &group_info, + &subgroup_info, + parent_group); + CONFIG_UINT( list, list_info, &custom_vp->width, diff --git a/msg_hash.h b/msg_hash.h index 08fba9705c..1351b68b7a 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1015,6 +1015,7 @@ enum msg_hash_enums /* Deferred */ MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST, MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_SPECIAL, + MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_RESOLUTION, MENU_ENUM_LABEL_DEFERRED_MIXER_STREAM_SETTINGS_LIST, MENU_ENUM_LABEL_DEFERRED_CONFIGURATIONS_LIST, MENU_ENUM_LABEL_DEFERRED_FAVORITES_LIST, From a561f789e28dd244fdcd0bdd7c07609cb262d6d6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 24 Nov 2018 10:35:32 +0100 Subject: [PATCH 029/153] Rename switch_resolution to set_resolution --- gfx/display_servers/dispserv_win32.c | 2 +- gfx/video_crt_switch.c | 2 +- gfx/video_display_server.c | 6 +++--- gfx/video_display_server.h | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gfx/display_servers/dispserv_win32.c b/gfx/display_servers/dispserv_win32.c index 5634a044a5..e2fb65800a 100644 --- a/gfx/display_servers/dispserv_win32.c +++ b/gfx/display_servers/dispserv_win32.c @@ -107,7 +107,7 @@ static void win32_display_server_destroy(void *data) dispserv_win32_t *dispserv = (dispserv_win32_t*)data; if (win32_orig_width > 0 && win32_orig_height > 0) - video_display_server_switch_resolution(win32_orig_width, win32_orig_height, + video_display_server_set_resolution(win32_orig_width, win32_orig_height, win32_orig_refresh, (float)win32_orig_refresh, crt_center ); #ifdef HAS_TASKBAR_EXT diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index 282d2aea39..d154cfa41b 100644 --- a/gfx/video_crt_switch.c +++ b/gfx/video_crt_switch.c @@ -88,7 +88,7 @@ static void switch_res_crt(unsigned width, unsigned height) { if (height > 100) { - video_display_server_switch_resolution(width, height, + video_display_server_set_resolution(width, height, ra_set_core_hz, ra_core_hz, crt_center_adjust); video_driver_apply_state_changes(); } diff --git a/gfx/video_display_server.c b/gfx/video_display_server.c index 94d6186469..0f77f6697a 100644 --- a/gfx/video_display_server.c +++ b/gfx/video_display_server.c @@ -90,11 +90,11 @@ bool video_display_server_set_window_decorations(bool on) } -bool video_display_server_switch_resolution(unsigned width, unsigned height, +bool video_display_server_set_resolution(unsigned width, unsigned height, int int_hz, float hz, int center) { - if (current_display_server && current_display_server->switch_resolution) - return current_display_server->switch_resolution(current_display_server_data, width, height, int_hz, hz, center); + if (current_display_server && current_display_server->set_resolution) + return current_display_server->set_resolution(current_display_server_data, width, height, int_hz, hz, center); return false; } diff --git a/gfx/video_display_server.h b/gfx/video_display_server.h index 97a06bd018..2824b4b4ee 100644 --- a/gfx/video_display_server.h +++ b/gfx/video_display_server.h @@ -40,7 +40,7 @@ typedef struct video_display_server bool (*set_window_opacity)(void *data, unsigned opacity); bool (*set_window_progress)(void *data, int progress, bool finished); bool (*set_window_decorations)(void *data, bool on); - bool (*switch_resolution)(void *data, unsigned width, + bool (*set_resolution)(void *data, unsigned width, unsigned height, int int_hz, float hz, int center); void *(*get_resolution_list)(void *data, unsigned *size); @@ -58,7 +58,7 @@ bool video_display_server_set_window_progress(int progress, bool finished); bool video_display_server_set_window_decorations(bool on); -bool video_display_server_switch_resolution( +bool video_display_server_set_resolution( unsigned width, unsigned height, int int_hz, float hz, int center); From 1356577c2e53c1b81a63326d6f34516aa3b22f9e Mon Sep 17 00:00:00 2001 From: Alfrix Date: Sat, 24 Nov 2018 13:21:43 -0300 Subject: [PATCH 030/153] Add more icons --- menu/drivers/ozone/ozone_texture.c | 25 +++++++++++++++++++++---- menu/drivers/ozone/ozone_texture.h | 3 +++ menu/drivers/xmb.c | 28 ++++++++++++++++++++++++---- 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/menu/drivers/ozone/ozone_texture.c b/menu/drivers/ozone/ozone_texture.c index 19b0654be7..7af3843ee1 100644 --- a/menu/drivers/ozone/ozone_texture.c +++ b/menu/drivers/ozone/ozone_texture.c @@ -45,6 +45,9 @@ menu_texture_item ozone_entries_icon_get_texture(ozone_handle_t *ozone, case MENU_ENUM_LABEL_CORE_CHEAT_OPTIONS: return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_CHEAT_OPTIONS]; case MENU_ENUM_LABEL_DISK_OPTIONS: + case MENU_ENUM_LABEL_DISK_CYCLE_TRAY_STATUS: + case MENU_ENUM_LABEL_DISK_IMAGE_APPEND: + case MENU_ENUM_LABEL_DISK_INDEX: return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_DISK_OPTIONS]; case MENU_ENUM_LABEL_SHADER_OPTIONS: return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_SHADER_OPTIONS]; @@ -266,6 +269,11 @@ menu_texture_item ozone_entries_icon_get_texture(ozone_handle_t *ozone, case MENU_ENUM_LABEL_CHEAT_APPLY_CHANGES: case MENU_ENUM_LABEL_SHADER_APPLY_CHANGES: return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_CHECKMARK]; + case MENU_ENUM_LABEL_CHEAT_ADD_NEW_AFTER: + case MENU_ENUM_LABEL_CHEAT_ADD_NEW_BEFORE: + case MENU_ENUM_LABEL_CHEAT_ADD_NEW_TOP: + case MENU_ENUM_LABEL_CHEAT_ADD_NEW_BOTTOM: + return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_MENU_ADD]; default: break; } @@ -300,7 +308,7 @@ menu_texture_item ozone_entries_icon_get_texture(ozone_handle_t *ozone, case FILE_TYPE_PLAYLIST_ENTRY: case MENU_SETTING_ACTION_RUN: case MENU_SETTING_ACTION_RESUME_ACHIEVEMENTS: - return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_RUN]; + return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_RESUME]; case MENU_SETTING_ACTION_CLOSE: case MENU_SETTING_ACTION_DELETE_ENTRY: return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_CLOSE]; @@ -326,13 +334,13 @@ menu_texture_item ozone_entries_icon_get_texture(ozone_handle_t *ozone, case MENU_SETTING_ACTION_RESET: return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_RELOAD]; case MENU_SETTING_ACTION_PAUSE_ACHIEVEMENTS: - return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_RESUME]; - + return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_PAUSE]; case MENU_SETTING_GROUP: + return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_SETTING]; #ifdef HAVE_LAKKA_SWITCH case MENU_SET_SWITCH_BRIGHTNESS: + return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_BRIGHTNESS]; #endif - return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_SETTING]; case MENU_INFO_MESSAGE: return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_CORE_INFO]; case MENU_WIFI: @@ -761,6 +769,15 @@ switch (id) case OZONE_ENTRIES_ICONS_TEXTURE_CHECKMARK: icon_name = "menu_check.png"; break; + case OZONE_ENTRIES_ICONS_TEXTURE_MENU_ADD: + icon_name = "menu_add.png"; + break; + case OZONE_ENTRIES_ICONS_TEXTURE_BRIGHTNESS: + icon_name = "menu_brightnes.png"; + break; + case OZONE_ENTRIES_ICONS_TEXTURE_PAUSE: + icon_name = "menu_pause.png"; + break; } fill_pathname_join( diff --git a/menu/drivers/ozone/ozone_texture.h b/menu/drivers/ozone/ozone_texture.h index 0ef5828667..e06bea008f 100644 --- a/menu/drivers/ozone/ozone_texture.h +++ b/menu/drivers/ozone/ozone_texture.h @@ -193,6 +193,9 @@ enum OZONE_ENTRIES_ICONS_TEXTURE_INPUT_LT, OZONE_ENTRIES_ICONS_TEXTURE_INPUT_RT, OZONE_ENTRIES_ICONS_TEXTURE_CHECKMARK, + OZONE_ENTRIES_ICONS_TEXTURE_MENU_ADD, + OZONE_ENTRIES_ICONS_TEXTURE_BRIGHTNESS, + OZONE_ENTRIES_ICONS_TEXTURE_PAUSE, OZONE_ENTRIES_ICONS_TEXTURE_LAST }; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 9993d46512..0f803d5c00 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -201,6 +201,9 @@ enum XMB_TEXTURE_INPUT_LT, XMB_TEXTURE_INPUT_RT, XMB_TEXTURE_CHECKMARK, + XMB_TEXTURE_MENU_ADD, + XMB_TEXTURE_BRIGHTNESS, + XMB_TEXTURE_PAUSE, XMB_TEXTURE_LAST }; @@ -2270,6 +2273,9 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, case MENU_ENUM_LABEL_CORE_CHEAT_OPTIONS: return xmb->textures.list[XMB_TEXTURE_CHEAT_OPTIONS]; case MENU_ENUM_LABEL_DISK_OPTIONS: + case MENU_ENUM_LABEL_DISK_CYCLE_TRAY_STATUS: + case MENU_ENUM_LABEL_DISK_IMAGE_APPEND: + case MENU_ENUM_LABEL_DISK_INDEX: return xmb->textures.list[XMB_TEXTURE_DISK_OPTIONS]; case MENU_ENUM_LABEL_SHADER_OPTIONS: return xmb->textures.list[XMB_TEXTURE_SHADER_OPTIONS]; @@ -2499,6 +2505,11 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, case MENU_ENUM_LABEL_CHEAT_APPLY_CHANGES: case MENU_ENUM_LABEL_SHADER_APPLY_CHANGES: return xmb->textures.list[XMB_TEXTURE_CHECKMARK]; + case MENU_ENUM_LABEL_CHEAT_ADD_NEW_AFTER: + case MENU_ENUM_LABEL_CHEAT_ADD_NEW_BEFORE: + case MENU_ENUM_LABEL_CHEAT_ADD_NEW_TOP: + case MENU_ENUM_LABEL_CHEAT_ADD_NEW_BOTTOM: + return xmb->textures.list[XMB_TEXTURE_MENU_ADD]; default: break; } @@ -2559,7 +2570,7 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, case FILE_TYPE_PLAYLIST_ENTRY: case MENU_SETTING_ACTION_RUN: case MENU_SETTING_ACTION_RESUME_ACHIEVEMENTS: - return xmb->textures.list[XMB_TEXTURE_RUN]; + return xmb->textures.list[XMB_TEXTURE_RESUME]; case MENU_SETTING_ACTION_CLOSE: case MENU_SETTING_ACTION_DELETE_ENTRY: return xmb->textures.list[XMB_TEXTURE_CLOSE]; @@ -2585,12 +2596,12 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, case MENU_SETTING_ACTION_RESET: return xmb->textures.list[XMB_TEXTURE_RELOAD]; case MENU_SETTING_ACTION_PAUSE_ACHIEVEMENTS: - return xmb->textures.list[XMB_TEXTURE_RESUME]; - - case MENU_SETTING_GROUP: + return xmb->textures.list[XMB_TEXTURE_PAUSE]; #ifdef HAVE_LAKKA_SWITCH case MENU_SET_SWITCH_BRIGHTNESS: + return xmb->textures.list[XMB_TEXTURE_BRIGHTNESS]; #endif + case MENU_SETTING_GROUP: return xmb->textures.list[XMB_TEXTURE_SETTING]; case MENU_INFO_MESSAGE: return xmb->textures.list[XMB_TEXTURE_CORE_INFO]; @@ -4913,6 +4924,15 @@ static const char *xmb_texture_path(unsigned id) case XMB_TEXTURE_CHECKMARK: icon_name = "menu_check.png"; break; + case XMB_TEXTURE_MENU_ADD: + icon_name = "menu_add.png"; + break; + case XMB_TEXTURE_BRIGHTNESS: + icon_name = "menu_brightness.png"; + break; + case XMB_TEXTURE_PAUSE: + icon_name = "menu_pause.png"; + break; } fill_pathname_application_special(iconpath, From 17fd203141c575e4769f7d82591808c2fe37cef5 Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Sat, 24 Nov 2018 20:52:22 +0400 Subject: [PATCH 031/153] Waiting for the "initial" set of globals to appear (fixed xdg_wm_base_ping working) --- gfx/drivers_context/wayland_ctx.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index d50bb6db54..480cb20c03 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -350,6 +350,8 @@ static const struct wl_pointer_listener pointer_listener = { pointer_handle_axis, }; +// TODO: implement check for resize + static void touch_handle_down(void *data, struct wl_touch *wl_touch, uint32_t serial, @@ -548,10 +550,11 @@ bool wayland_context_gettouchpos(void *data, unsigned id, /* Shell surface callbacks. */ -static void xdg_shell_ping (void *data, struct xdg_wm_base *shell, uint32_t serial) +static void xdg_shell_ping(void *data, struct xdg_wm_base *shell, uint32_t serial) { xdg_wm_base_pong(shell, serial); } + static const struct xdg_wm_base_listener xdg_shell_listener = { xdg_shell_ping, }; @@ -576,6 +579,8 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, wl->configured = false; } +// TODO: implement xdg_toplevel close + static const struct xdg_toplevel_listener xdg_toplevel_listener = { handle_toplevel_config, @@ -1305,11 +1310,16 @@ static bool gfx_ctx_wl_set_video_mode(void *data, xdg_toplevel_set_app_id (wl->xdg_toplevel, "RetroArch"); xdg_toplevel_set_title (wl->xdg_toplevel, "RetroArch"); + // Waiting for xdg_toplevel to be configured before starting to draw wl_surface_commit(wl->surface); wl->configured = true; while (wl->configured) wl_display_dispatch(wl->input.dpy); + + // Waiting for the "initial" set of globals to appear + wl_display_roundtrip(wl->input.dpy); + xdg_wm_base_add_listener(wl->shell, &xdg_shell_listener, NULL); switch (wl_api) { From 2945d450f3534e95076ceb48ae2162a9680c3390 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 24 Nov 2018 19:38:01 +0100 Subject: [PATCH 032/153] Cleanups --- gfx/display_servers/dispserv_x11.c | 81 ++++++++++++------------------ 1 file changed, 31 insertions(+), 50 deletions(-) diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index 92dcf34d4b..d82014caa4 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -92,7 +92,8 @@ static bool x11_display_server_set_window_opacity(void *data, unsigned opacity) if (opacity == (unsigned)-1) XDeleteProperty(g_x11_dpy, g_x11_win, net_wm_opacity); else - XChangeProperty(g_x11_dpy, g_x11_win, net_wm_opacity, cardinal, 32, PropModeReplace, (const unsigned char*)&opacity, 1); + XChangeProperty(g_x11_dpy, g_x11_win, net_wm_opacity, cardinal, + 32, PropModeReplace, (const unsigned char*)&opacity, 1); return true; } @@ -101,9 +102,11 @@ static bool x11_display_server_set_window_decorations(void *data, bool on) { dispserv_x11_t *serv = (dispserv_x11_t*)data; - serv->decorations = on; + if (serv) + serv->decorations = on; - /* menu_setting performs a reinit instead to properly apply decoration changes */ + /* menu_setting performs a reinit instead to properly apply + * decoration changes */ return true; } @@ -131,7 +134,7 @@ static bool x11_display_server_set_resolution(void *data, /* set core refresh from hz */ video_monitor_set_refresh_rate(hz); - /* following code is the mode line genorator */ + /* following code is the mode line generator */ hsp = width * 1.140; hfp = width * 1.055; @@ -144,9 +147,7 @@ static bool x11_display_server_set_resolution(void *data, roundw = roundf((float)pwidth / (float)height * 100) / 100; if (height > width) - { roundw = roundf((float)height / (float)width * 100) / 100; - } if (roundw > 1.35) roundw = 1.25; @@ -158,111 +159,88 @@ static bool x11_display_server_set_resolution(void *data, hmax = hbp; if (height < 241) - { vmax = 261; - } if (height < 241 && hz > 56 && hz < 58) - { vmax = 280; - } if (height < 241 && hz < 55) - { vmax = 313; - } if (height > 250 && height < 260 && hz > 54) - { vmax = 296; - } if (height > 250 && height < 260 && hz > 52 && hz < 54) - { vmax = 285; - } if (height > 250 && height < 260 && hz < 52) - { vmax = 313; - } if (height > 260 && height < 300) - { vmax = 318; - } if (height > 400 && hz > 56) - { vmax = 533; - } if (height > 520 && hz < 57) - { vmax = 580; - } if (height > 300 && hz < 56) - { vmax = 615; - } if (height > 500 && hz < 56) - { vmax = 624; - } if (height > 300) - { pdefault = pdefault * 2; - } vfp = height + ((vmax - height) / 2) - pdefault; if (height < 300) - { - vsp = vfp + 3; /* needs to me 3 for progressive */ - } + vsp = vfp + 3; /* needs to be 3 for progressive */ if (height > 300) - { - vsp = vfp + 6; /* needs to me 6 for interlaced */ - } + vsp = vfp + 6; /* needs to be 6 for interlaced */ vbp = vmax; if (height < 300) - { pixel_clock = (hmax * vmax * hz) / 1000000; - } if (height > 300) - { pixel_clock = ((hmax * vmax * hz) / 1000000) / 2; - } - /* above code is the modeline genorator */ + /* above code is the modeline generator */ /* create interlaced newmode from modline variables */ if (height < 300) { - snprintf(xrandr, sizeof(xrandr), "xrandr --newmode \"%dx%d_%0.2f\" %lf %d %d %d %d %d %d %d %d -hsync -vsync", width, height, hz, pixel_clock, width, hfp, hsp, hbp, height, vfp, vsp, vbp); + snprintf(xrandr, sizeof(xrandr), "xrandr --newmode \"%dx%d_%0.2f\" %lf %d %d %d %d %d %d %d %d -hsync -vsync", width, height, hz, pixel_clock, + width, hfp, hsp, hbp, height, vfp, vsp, vbp); system(xrandr); } /* create interlaced newmode from modline variables */ if (height > 300) { - snprintf(xrandr, sizeof(xrandr), "xrandr --newmode \"%dx%d_%0.2f\" %lf %d %d %d %d %d %d %d %d interlace -hsync -vsync", width, height, hz, pixel_clock, width, hfp, hsp, hbp, height, vfp, vsp, vbp); + snprintf(xrandr, sizeof(xrandr), "xrandr --newmode \"%dx%d_%0.2f\" %lf %d %d %d %d %d %d %d %d interlace -hsync -vsync", width, height, hz, pixel_clock, + width, hfp, hsp, hbp, height, vfp, vsp, vbp); system(xrandr); } /* variable for new mode */ snprintf(new_mode, sizeof(new_mode), "%dx%d_%0.2f", width, height, hz); - /* need to run loops for DVI0 - DVI-2 and VGA0 - VGA-2 outputs to add and delete modes */ + /* need to run loops for DVI0 - DVI-2 and VGA0 - VGA-2 outputs to + * add and delete modes */ for (i = 0; i < 3; i++) { - snprintf(output, sizeof(output), "xrandr --addmode %s%d %s", "DVI", i, new_mode); + snprintf(output, sizeof(output), "xrandr --addmode %s%d %s", "DVI", i, + new_mode); system(output); - snprintf(output, sizeof(output), "xrandr --delmode %s%d %s", "DVI", i, old_mode); + snprintf(output, sizeof(output), "xrandr --delmode %s%d %s", "DVI", i, + old_mode); system(output); } + for (i = 0; i < 3; i++) { - snprintf(output, sizeof(output), "xrandr --addmode %s-%d %s", "DVI", i, new_mode); + snprintf(output, sizeof(output), "xrandr --addmode %s-%d %s", "DVI", i, + new_mode); system(output); - snprintf(output, sizeof(output), "xrandr --delmode %s-%d %s", "DVI", i, old_mode); + snprintf(output, sizeof(output), "xrandr --delmode %s-%d %s", "DVI", i, + old_mode); system(output); } + for (i = 0; i < 3; i++) { snprintf(output, sizeof(output), "xrandr --addmode %s%d %s", "VGA", i, new_mode); @@ -270,6 +248,7 @@ static bool x11_display_server_set_resolution(void *data, snprintf(output, sizeof(output), "xrandr --delmode %s%d %s", "VGA", i, old_mode); system(output); } + for (i = 0; i < 3; i++) { snprintf(output, sizeof(output), "xrandr --addmode %s-%d %s", "VGA", i, new_mode); @@ -285,12 +264,14 @@ static bool x11_display_server_set_resolution(void *data, snprintf(output, sizeof(output), "xrandr --rmmode %s", old_mode); system(output); - system("xdotool windowactivate $(xdotool search --class RetroArch)"); /* needs xdotool installed. needed to recapture window. */ + /* needs xdotool installed. needed to recapture window. */ + system("xdotool windowactivate $(xdotool search --class RetroArch)"); /* variable for old mode */ snprintf(old_mode, sizeof(old_mode), "%s", new_mode); - system("xdotool windowactivate $(xdotool search --class RetroArch)"); /* needs xdotool installed. needed to recapture window. */ + /* needs xdotool installed. needed to recapture window. */ + system("xdotool windowactivate $(xdotool search --class RetroArch)"); /* Second run needed as some times it runs to fast to capture first time */ return true; From 7d9e5646674371f7f923d4446170e8d55e3f50dd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 24 Nov 2018 19:40:14 +0100 Subject: [PATCH 033/153] Turn some C++ comments into C comments --- gfx/drivers_context/wayland_ctx.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 480cb20c03..aaaf22e36c 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -51,7 +51,7 @@ #include "../../input/input_driver.h" #include "../../input/input_keymaps.h" -// Generated from xdg-shell.xml +/* Generated from xdg-shell.xml */ #include "../common/wayland/xdg-shell.h" @@ -350,7 +350,7 @@ static const struct wl_pointer_listener pointer_listener = { pointer_handle_axis, }; -// TODO: implement check for resize +/* TODO: implement check for resize */ static void touch_handle_down(void *data, struct wl_touch *wl_touch, @@ -574,14 +574,12 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, { gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; - // TODO: implement resizing + /* TODO: implement resizing */ wl->configured = false; } -// TODO: implement xdg_toplevel close - - +/* TODO: implement xdg_toplevel close */ static const struct xdg_toplevel_listener xdg_toplevel_listener = { handle_toplevel_config, }; @@ -1310,14 +1308,14 @@ static bool gfx_ctx_wl_set_video_mode(void *data, xdg_toplevel_set_app_id (wl->xdg_toplevel, "RetroArch"); xdg_toplevel_set_title (wl->xdg_toplevel, "RetroArch"); - // Waiting for xdg_toplevel to be configured before starting to draw + /* Waiting for xdg_toplevel to be configured before starting to draw */ wl_surface_commit(wl->surface); wl->configured = true; while (wl->configured) wl_display_dispatch(wl->input.dpy); - // Waiting for the "initial" set of globals to appear + /* Waiting for the "initial" set of globals to appear */ wl_display_roundtrip(wl->input.dpy); xdg_wm_base_add_listener(wl->shell, &xdg_shell_listener, NULL); From 0eb8acd766f7fbc4c98f264239d2300527fb67ef Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 24 Nov 2018 19:50:25 +0100 Subject: [PATCH 034/153] (Win32 display server) Try to set current resolution --- gfx/display_servers/dispserv_win32.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/gfx/display_servers/dispserv_win32.c b/gfx/display_servers/dispserv_win32.c index e2fb65800a..6563441bd5 100644 --- a/gfx/display_servers/dispserv_win32.c +++ b/gfx/display_servers/dispserv_win32.c @@ -285,19 +285,30 @@ static bool win32_display_server_set_resolution(void *data, void *win32_display_server_get_resolution_list(void *data, unsigned *len) { - unsigned i, count = 0; + DEVMODE dm; + unsigned i, count = 0; + unsigned curr_width = 0; + unsigned curr_height = 0; + unsigned curr_bpp = 0; + unsigned curr_refreshrate = 0; struct video_display_config *conf = NULL; for (i = 0;; i++) { - DEVMODE dm; - if (!win32_get_video_output(&dm, i, sizeof(dm))) break; count++; } + if (win32_get_video_output(&dm, -1, sizeof(dm))) + { + curr_width = dm.dmPelsWidth; + curr_height = dm.dmPelsHeight; + curr_bpp = dm.dmBitsPerPel; + curr_refreshrate = dm.dmDisplayFrequency; + } + *len = count; conf = (struct video_display_config*)calloc(*len, sizeof(struct video_display_config)); @@ -306,8 +317,6 @@ void *win32_display_server_get_resolution_list(void *data, for (i = 0;; i++) { - DEVMODE dm; - if (!win32_get_video_output(&dm, i, sizeof(dm))) break; @@ -316,6 +325,14 @@ void *win32_display_server_get_resolution_list(void *data, conf[i].bpp = dm.dmBitsPerPel; conf[i].refreshrate = dm.dmDisplayFrequency; conf[i].idx = i; + conf[i].current = false; + + if ( (conf[i].width == curr_width) + && (conf[i].height == curr_height) + && (conf[i].refreshrate == curr_refreshrate) + && (conf[i].bpp == curr_bpp) + ) + conf[i].current = true; } return conf; From d04f3c01a1c64d061fcb7b98d39829e6fa2f851a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 24 Nov 2018 20:12:57 +0100 Subject: [PATCH 035/153] Add initial implementation for resolution switching for Win32 --- menu/cbs/menu_cbs_ok.c | 38 ++++++++++++++++++++++++++++++++------ menu/menu_displaylist.c | 2 +- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 909c1116b9..1c88da1049 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -60,6 +60,7 @@ #include "../../verbosity.h" #include "../../lakka.h" #include "../../wifi/wifi_driver.h" +#include "../../gfx/video_display_server.h" #include @@ -4463,12 +4464,37 @@ static int action_ok_push_dropdown_item(const char *path, static int action_ok_push_dropdown_item_resolution(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - RARCH_LOG("dropdown: \n"); - RARCH_LOG("path: %s \n", path); - RARCH_LOG("label: %s \n", label); - RARCH_LOG("type: %d \n", type); - RARCH_LOG("idx: %d \n", idx); - RARCH_LOG("entry_idx: %d \n", entry_idx); + char str[100]; + char *pch = NULL; + unsigned width = 0; + unsigned height = 0; + unsigned refreshrate = 0; + + snprintf(str, sizeof(str), "%s", path); + + pch = strtok(str, "x"); + if (pch) + width = strtoul(pch, NULL, 0); + pch = strtok(NULL, " "); + if (pch) + height = strtoul(pch, NULL, 0); + pch = strtok(NULL, "("); + if (pch) + refreshrate = strtoul(pch, NULL, 0); + + if (video_display_server_set_resolution(width, height, + refreshrate, (float)refreshrate, 0)) + { + settings_t *settings = config_get_ptr(); + + video_monitor_set_refresh_rate((float)refreshrate); + + settings->uints.video_fullscreen_x = width; + settings->uints.video_fullscreen_y = height; + + /* TODO/FIXME - menu drivers like XMB don't rescale + * automatically */ + } return 0; } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index ededbc3812..19699ba94c 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -8333,7 +8333,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist for (i = 0; i < size; i++) { char val_d[256], str[256]; - snprintf(str, sizeof(str), "%dx%d (%dHz)", list[i].width, list[i].height, list[i].refreshrate); + snprintf(str, sizeof(str), "%dx%d (%d Hz)", list[i].width, list[i].height, list[i].refreshrate); snprintf(val_d, sizeof(val_d), "%d", i); menu_entries_append_enum(info->list, str, From 3a666373b44c9e0dfba952f688ee8b6c123078ec Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 24 Nov 2018 20:26:34 +0100 Subject: [PATCH 036/153] Set currently selected icon --- menu/cbs/menu_cbs_ok.c | 2 ++ menu/menu_displaylist.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 1c88da1049..a4d9230bce 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -4494,7 +4494,9 @@ static int action_ok_push_dropdown_item_resolution(const char *path, /* TODO/FIXME - menu drivers like XMB don't rescale * automatically */ + return menu_cbs_exit(); } + return 0; } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 19699ba94c..c009494f51 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -8340,6 +8340,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist val_d, MENU_ENUM_LABEL_NO_ITEMS, MENU_SETTING_DROPDOWN_ITEM_RESOLUTION, list[i].idx, 0); + + if (list[i].current) + menu_entries_set_checked(info->list, i, true); } free(list); From bcb4d615109f889b1c9ab65786507dee2fb192ec Mon Sep 17 00:00:00 2001 From: meepingsnesroms Date: Sat, 24 Nov 2018 12:58:17 -0800 Subject: [PATCH 037/153] Add NULL check to prevent empty password from crashing RetroArch --- network/netplay/netplay_handshake.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/network/netplay/netplay_handshake.c b/network/netplay/netplay_handshake.c index dc277c8b93..f8400e5d89 100644 --- a/network/netplay/netplay_handshake.c +++ b/network/netplay/netplay_handshake.c @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -279,7 +280,8 @@ static void handshake_password(void *ignore, const char *line) struct netplay_connection *connection = &netplay->connections[0]; snprintf(password, sizeof(password), "%08X", connection->salt); - strlcpy(password + 8, line, sizeof(password)-8); + if (!string_is_empty(line)) + strlcpy(password + 8, line, sizeof(password)-8); password_buf.cmd[0] = htonl(NETPLAY_CMD_PASSWORD); password_buf.cmd[1] = htonl(sizeof(password_buf.password)); From c9bb537cdd33736c800a4c9ed30f8ead33bf4369 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 25 Nov 2018 02:45:13 +0100 Subject: [PATCH 038/153] Should now correctly rescale after resolution changes --- menu/drivers/xmb.c | 1452 ++++++++++++++++++++++---------------------- 1 file changed, 729 insertions(+), 723 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 0f803d5c00..bae14a630e 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -3318,6 +3318,683 @@ static void xmb_draw_dark_layer( menu_display_blend_end(video_info); } +static const char *xmb_texture_path(unsigned id) +{ + char *iconpath = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); + char *icon_name = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); + char *icon_fullpath = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); + + iconpath[0] = icon_name[0] = icon_fullpath[0] = '\0'; + + switch (id) + { + case XMB_TEXTURE_MAIN_MENU: +#if defined(HAVE_LAKKA) + icon_name = "lakka.png"; + break; +#else + icon_name = "retroarch.png"; + break; +#endif + case XMB_TEXTURE_SETTINGS: + icon_name = "settings.png"; + break; + case XMB_TEXTURE_HISTORY: + icon_name = "history.png"; + break; + case XMB_TEXTURE_FAVORITES: + icon_name = "favorites.png"; + break; + case XMB_TEXTURE_ADD_FAVORITE: + icon_name = "add-favorite.png"; + break; + case XMB_TEXTURE_MUSICS: + icon_name = "musics.png"; + break; +#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) + case XMB_TEXTURE_MOVIES: + icon_name = "movies.png"; + break; +#endif +#ifdef HAVE_IMAGEVIEWER + case XMB_TEXTURE_IMAGES: + icon_name = "images.png"; + break; +#endif + case XMB_TEXTURE_SETTING: + icon_name = "setting.png"; + break; + case XMB_TEXTURE_SUBSETTING: + icon_name = "subsetting.png"; + break; + case XMB_TEXTURE_ARROW: + icon_name = "arrow.png"; + break; + case XMB_TEXTURE_RUN: + icon_name = "run.png"; + break; + case XMB_TEXTURE_CLOSE: + icon_name = "close.png"; + break; + case XMB_TEXTURE_RESUME: + icon_name = "resume.png"; + break; + case XMB_TEXTURE_CLOCK: + icon_name = "clock.png"; + break; + case XMB_TEXTURE_BATTERY_FULL: + icon_name = "battery-full.png"; + break; + case XMB_TEXTURE_BATTERY_CHARGING: + icon_name = "battery-charging.png"; + break; + case XMB_TEXTURE_POINTER: + icon_name = "pointer.png"; + break; + case XMB_TEXTURE_SAVESTATE: + icon_name = "savestate.png"; + break; + case XMB_TEXTURE_LOADSTATE: + icon_name = "loadstate.png"; + break; + case XMB_TEXTURE_UNDO: + icon_name = "undo.png"; + break; + case XMB_TEXTURE_CORE_INFO: + icon_name = "core-infos.png"; + break; + case XMB_TEXTURE_WIFI: + icon_name = "wifi.png"; + break; + case XMB_TEXTURE_CORE_OPTIONS: + icon_name = "core-options.png"; + break; + case XMB_TEXTURE_INPUT_REMAPPING_OPTIONS: + icon_name = "core-input-remapping-options.png"; + break; + case XMB_TEXTURE_CHEAT_OPTIONS: + icon_name = "core-cheat-options.png"; + break; + case XMB_TEXTURE_DISK_OPTIONS: + icon_name = "core-disk-options.png"; + break; + case XMB_TEXTURE_SHADER_OPTIONS: + icon_name = "core-shader-options.png"; + break; + case XMB_TEXTURE_ACHIEVEMENT_LIST: + icon_name = "achievement-list.png"; + break; + case XMB_TEXTURE_SCREENSHOT: + icon_name = "screenshot.png"; + break; + case XMB_TEXTURE_RELOAD: + icon_name = "reload.png"; + break; + case XMB_TEXTURE_RENAME: + icon_name = "rename.png"; + break; + case XMB_TEXTURE_FILE: + icon_name = "file.png"; + break; + case XMB_TEXTURE_FOLDER: + icon_name = "folder.png"; + break; + case XMB_TEXTURE_ZIP: + icon_name = "zip.png"; + break; + case XMB_TEXTURE_MUSIC: + icon_name = "music.png"; + break; + case XMB_TEXTURE_FAVORITE: + icon_name = "favorites-content.png"; + break; + case XMB_TEXTURE_IMAGE: + icon_name = "image.png"; + break; + case XMB_TEXTURE_MOVIE: + icon_name = "movie.png"; + break; + case XMB_TEXTURE_CORE: + icon_name = "core.png"; + break; + case XMB_TEXTURE_RDB: + icon_name = "database.png"; + break; + case XMB_TEXTURE_CURSOR: + icon_name = "cursor.png"; + break; + case XMB_TEXTURE_SWITCH_ON: + icon_name = "on.png"; + break; + case XMB_TEXTURE_SWITCH_OFF: + icon_name = "off.png"; + break; + case XMB_TEXTURE_ADD: + icon_name = "add.png"; + break; +#ifdef HAVE_NETWORKING + case XMB_TEXTURE_NETPLAY: + icon_name = "netplay.png"; + break; + case XMB_TEXTURE_ROOM: + icon_name = "menu_room.png"; + break; + case XMB_TEXTURE_ROOM_LAN: + icon_name = "menu_room_lan.png"; + break; + case XMB_TEXTURE_ROOM_RELAY: + icon_name = "menu_room_relay.png"; + break; +#endif + case XMB_TEXTURE_KEY: + icon_name = "key.png"; + break; + case XMB_TEXTURE_KEY_HOVER: + icon_name = "key-hover.png"; + break; + case XMB_TEXTURE_DIALOG_SLICE: + icon_name = "dialog-slice.png"; + break; + case XMB_TEXTURE_ACHIEVEMENTS: + icon_name = "menu_achievements.png"; + break; + case XMB_TEXTURE_AUDIO: + icon_name = "menu_audio.png"; + break; + case XMB_TEXTURE_DRIVERS: + icon_name = "menu_drivers.png"; + break; + case XMB_TEXTURE_EXIT: + icon_name = "menu_exit.png"; + break; + case XMB_TEXTURE_FRAMESKIP: + icon_name = "menu_frameskip.png"; + break; + case XMB_TEXTURE_HELP: + icon_name = "menu_help.png"; + break; + case XMB_TEXTURE_INFO: + icon_name = "menu_info.png"; + break; + case XMB_TEXTURE_INPUT_SETTINGS: + icon_name = "Libretro - Pad.png"; + break; + case XMB_TEXTURE_LATENCY: + icon_name = "menu_latency.png"; + break; + case XMB_TEXTURE_NETWORK: + icon_name = "menu_network.png"; + break; + case XMB_TEXTURE_POWER: + icon_name = "menu_power.png"; + break; + case XMB_TEXTURE_RECORD: + icon_name = "menu_record.png"; + break; + case XMB_TEXTURE_SAVING: + icon_name = "menu_saving.png"; + break; + case XMB_TEXTURE_UPDATER: + icon_name = "menu_updater.png"; + break; + case XMB_TEXTURE_VIDEO: + icon_name = "menu_video.png"; + break; + case XMB_TEXTURE_MIXER: + icon_name = "menu_mixer.png"; + break; + case XMB_TEXTURE_LOG: + icon_name = "menu_log.png"; + break; + case XMB_TEXTURE_OSD: + icon_name = "menu_osd.png"; + break; + case XMB_TEXTURE_UI: + icon_name = "menu_ui.png"; + break; + case XMB_TEXTURE_USER: + icon_name = "menu_user.png"; + break; + case XMB_TEXTURE_PRIVACY: + icon_name = "menu_privacy.png"; + break; + case XMB_TEXTURE_PLAYLIST: + icon_name = "menu_playlist.png"; + break; + case XMB_TEXTURE_QUICKMENU: + icon_name = "menu_quickmenu.png"; + break; + case XMB_TEXTURE_REWIND: + icon_name = "menu_rewind.png"; + break; + case XMB_TEXTURE_OVERLAY: + icon_name = "menu_overlay.png"; + break; + case XMB_TEXTURE_OVERRIDE: + icon_name = "menu_override.png"; + break; + case XMB_TEXTURE_NOTIFICATIONS: + icon_name = "menu_notifications.png"; + break; + case XMB_TEXTURE_STREAM: + icon_name = "menu_stream.png"; + break; + case XMB_TEXTURE_SHUTDOWN: + icon_name = "menu_shutdown.png"; + break; + case XMB_TEXTURE_INPUT_DPAD_U: + icon_name = "input_DPAD-U.png"; + break; + case XMB_TEXTURE_INPUT_DPAD_D: + icon_name = "input_DPAD-D.png"; + break; + case XMB_TEXTURE_INPUT_DPAD_L: + icon_name = "input_DPAD-L.png"; + break; + case XMB_TEXTURE_INPUT_DPAD_R: + icon_name = "input_DPAD-R.png"; + break; + case XMB_TEXTURE_INPUT_STCK_U: + icon_name = "input_STCK-U.png"; + break; + case XMB_TEXTURE_INPUT_STCK_D: + icon_name = "input_STCK-D.png"; + break; + case XMB_TEXTURE_INPUT_STCK_L: + icon_name = "input_STCK-L.png"; + break; + case XMB_TEXTURE_INPUT_STCK_R: + icon_name = "input_STCK-R.png"; + break; + case XMB_TEXTURE_INPUT_STCK_P: + icon_name = "input_STCK-P.png"; + break; + case XMB_TEXTURE_INPUT_BTN_U: + icon_name = "input_BTN-U.png"; + break; + case XMB_TEXTURE_INPUT_BTN_D: + icon_name = "input_BTN-D.png"; + break; + case XMB_TEXTURE_INPUT_BTN_L: + icon_name = "input_BTN-L.png"; + break; + case XMB_TEXTURE_INPUT_BTN_R: + icon_name = "input_BTN-R.png"; + break; + case XMB_TEXTURE_INPUT_LB: + icon_name = "input_LB.png"; + break; + case XMB_TEXTURE_INPUT_RB: + icon_name = "input_RB.png"; + break; + case XMB_TEXTURE_INPUT_LT: + icon_name = "input_LT.png"; + break; + case XMB_TEXTURE_INPUT_RT: + icon_name = "input_RT.png"; + break; + case XMB_TEXTURE_INPUT_SELECT: + icon_name = "input_SELECT.png"; + break; + case XMB_TEXTURE_INPUT_START: + icon_name = "input_START.png"; + break; + case XMB_TEXTURE_CHECKMARK: + icon_name = "menu_check.png"; + break; + case XMB_TEXTURE_MENU_ADD: + icon_name = "menu_add.png"; + break; + case XMB_TEXTURE_BRIGHTNESS: + icon_name = "menu_brightness.png"; + break; + case XMB_TEXTURE_PAUSE: + icon_name = "menu_pause.png"; + break; + } + + fill_pathname_application_special(iconpath, + PATH_MAX_LENGTH * sizeof(char), + APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); + + icon_fullpath = iconpath; + strlcat(icon_fullpath, icon_name, PATH_MAX_LENGTH * sizeof(char)); + + if (!filestream_exists(icon_fullpath)) + { + RARCH_WARN("[XMB] Asset missing: %s\n", icon_fullpath); + return NULL; + } + else + return icon_name; + +} + + +static void xmb_context_reset_textures( + xmb_handle_t *xmb, const char *iconpath) +{ + unsigned i; + settings_t *settings = config_get_ptr(); + + for (i = 0; i < XMB_TEXTURE_LAST; i++) + { + if (xmb_texture_path(i) == NULL) + { + /* If the icon doesn't exist at least try to return the subsetting icon*/ + if (!(i == XMB_TEXTURE_DIALOG_SLICE || i == XMB_TEXTURE_KEY_HOVER || i == XMB_TEXTURE_KEY_HOVER)) + menu_display_reset_textures_list(xmb_texture_path(XMB_TEXTURE_SUBSETTING), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); + continue; + } + menu_display_reset_textures_list(xmb_texture_path(i), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); + } + + /* Warn only if critical assets are missing, some themes are incomplete */ + if ( + ((xmb_texture_path(XMB_TEXTURE_SUBSETTING) == NULL)) && !(settings->uints.menu_xmb_theme == XMB_ICON_THEME_CUSTOM) + ) + runloop_msg_queue_push(msg_hash_to_str(MSG_MISSING_ASSETS), 1, 256, false); + + menu_display_allocate_white_texture(); + + xmb->main_menu_node.icon = xmb->textures.list[XMB_TEXTURE_MAIN_MENU]; + xmb->main_menu_node.alpha = xmb->categories_active_alpha; + xmb->main_menu_node.zoom = xmb->categories_active_zoom; + + xmb->settings_tab_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS]; + xmb->settings_tab_node.alpha = xmb->categories_active_alpha; + xmb->settings_tab_node.zoom = xmb->categories_active_zoom; + + xmb->history_tab_node.icon = xmb->textures.list[XMB_TEXTURE_HISTORY]; + xmb->history_tab_node.alpha = xmb->categories_active_alpha; + xmb->history_tab_node.zoom = xmb->categories_active_zoom; + + xmb->favorites_tab_node.icon = xmb->textures.list[XMB_TEXTURE_FAVORITES]; + xmb->favorites_tab_node.alpha = xmb->categories_active_alpha; + xmb->favorites_tab_node.zoom = xmb->categories_active_zoom; + + xmb->music_tab_node.icon = xmb->textures.list[XMB_TEXTURE_MUSICS]; + xmb->music_tab_node.alpha = xmb->categories_active_alpha; + xmb->music_tab_node.zoom = xmb->categories_active_zoom; + +#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) + xmb->video_tab_node.icon = xmb->textures.list[XMB_TEXTURE_MOVIES]; + xmb->video_tab_node.alpha = xmb->categories_active_alpha; + xmb->video_tab_node.zoom = xmb->categories_active_zoom; +#endif + +#ifdef HAVE_IMAGEVIEWER + xmb->images_tab_node.icon = xmb->textures.list[XMB_TEXTURE_IMAGES]; + xmb->images_tab_node.alpha = xmb->categories_active_alpha; + xmb->images_tab_node.zoom = xmb->categories_active_zoom; +#endif + + xmb->add_tab_node.icon = xmb->textures.list[XMB_TEXTURE_ADD]; + xmb->add_tab_node.alpha = xmb->categories_active_alpha; + xmb->add_tab_node.zoom = xmb->categories_active_zoom; + +#ifdef HAVE_NETWORKING + xmb->netplay_tab_node.icon = xmb->textures.list[XMB_TEXTURE_NETPLAY]; + xmb->netplay_tab_node.alpha = xmb->categories_active_alpha; + xmb->netplay_tab_node.zoom = xmb->categories_active_zoom; +#endif + +} + +static void xmb_context_reset_background(const char *iconpath) +{ + char *path = NULL; + settings_t *settings = config_get_ptr(); + const char *path_menu_wp = settings->paths.path_menu_wallpaper; + + if (!string_is_empty(path_menu_wp)) + path = strdup(path_menu_wp); + else if (!string_is_empty(iconpath)) + { + path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + path[0] = '\0'; + + fill_pathname_join(path, iconpath, "bg.png", + PATH_MAX_LENGTH * sizeof(char)); + } + + if (filestream_exists(path)) + task_push_image_load(path, + menu_display_handle_wallpaper_upload, NULL); + + if (path) + free(path); +} + +static void xmb_context_reset(void *data, bool is_threaded) +{ +} + +static void xmb_layout_ps3(xmb_handle_t *xmb, int width) +{ + unsigned new_font_size, new_header_height; + settings_t *settings = config_get_ptr(); + + float scale_factor = + (settings->uints.menu_xmb_scale_factor * width) / (1920.0 * 100); + + xmb->above_subitem_offset = 1.5; + xmb->above_item_offset = -1.0; + xmb->active_item_factor = 3.0; + xmb->under_item_offset = 5.0; + + xmb->categories_active_zoom = 1.0; + xmb->categories_passive_zoom = 0.5; + xmb->items_active_zoom = 1.0; + xmb->items_passive_zoom = 0.5; + + xmb->categories_active_alpha = 1.0; + xmb->categories_passive_alpha = 0.85; + xmb->items_active_alpha = 1.0; + xmb->items_passive_alpha = 0.85; + + xmb->shadow_offset = 2.0; + + new_font_size = 32.0 * scale_factor; + xmb->font2_size = 24.0 * scale_factor; + new_header_height = 128.0 * scale_factor; + + + xmb->thumbnail_width = 1024.0 * scale_factor; + xmb->left_thumbnail_width = 1024.0 * scale_factor; + xmb->savestate_thumbnail_width= 460.0 * scale_factor; + xmb->cursor_size = 64.0 * scale_factor; + + xmb->icon_spacing_horizontal = 200.0 * scale_factor; + xmb->icon_spacing_vertical = 64.0 * scale_factor; + + xmb->margins_screen_top = (256+32) * scale_factor; + xmb->margins_screen_left = 336.0 * scale_factor; + + xmb->margins_title_left = 60 * scale_factor; + xmb->margins_title_top = 60 * scale_factor + new_font_size / 3; + xmb->margins_title_bottom = 60 * scale_factor - new_font_size / 3; + + xmb->margins_label_left = 85.0 * scale_factor; + xmb->margins_label_top = new_font_size / 3.0; + + xmb->margins_setting_left = 600.0 * scale_factor * scale_mod[6]; + xmb->margins_dialog = 48 * scale_factor; + + xmb->margins_slice = 16; + + xmb->icon_size = 128.0 * scale_factor; + xmb->font_size = new_font_size; + + menu_display_set_header_height(new_header_height); +} + +static void xmb_layout_psp(xmb_handle_t *xmb, int width) +{ + unsigned new_font_size, new_header_height; + settings_t *settings = config_get_ptr(); + float scale_factor = + ((settings->uints.menu_xmb_scale_factor * width) / (1920.0 * 100)) * 1.5; +#ifdef _3DS + scale_factor = + settings->uints.menu_xmb_scale_factor / 400.0; +#endif + + xmb->above_subitem_offset = 1.5; + xmb->above_item_offset = -1.0; + xmb->active_item_factor = 2.0; + xmb->under_item_offset = 3.0; + + xmb->categories_active_zoom = 1.0; + xmb->categories_passive_zoom = 1.0; + xmb->items_active_zoom = 1.0; + xmb->items_passive_zoom = 1.0; + + xmb->categories_active_alpha = 1.0; + xmb->categories_passive_alpha = 0.85; + xmb->items_active_alpha = 1.0; + xmb->items_passive_alpha = 0.85; + + xmb->shadow_offset = 1.0; + + new_font_size = 32.0 * scale_factor; + xmb->font2_size = 24.0 * scale_factor; + new_header_height = 128.0 * scale_factor; + xmb->margins_screen_top = (256+32) * scale_factor; + + xmb->thumbnail_width = 460.0 * scale_factor; + xmb->left_thumbnail_width = 400.0 * scale_factor; + xmb->savestate_thumbnail_width= 460.0 * scale_factor; + xmb->cursor_size = 64.0; + + xmb->icon_spacing_horizontal = 250.0 * scale_factor; + xmb->icon_spacing_vertical = 108.0 * scale_factor; + + xmb->margins_screen_left = 136.0 * scale_factor; + xmb->margins_title_left = 60 * scale_factor; + xmb->margins_title_top = 60 * scale_factor + new_font_size / 3; + xmb->margins_title_bottom = 60 * scale_factor - new_font_size / 3; + xmb->margins_label_left = 85.0 * scale_factor; + xmb->margins_label_top = new_font_size / 3.0; + xmb->margins_setting_left = 600.0 * scale_factor; + xmb->margins_dialog = 48 * scale_factor; + xmb->margins_slice = 16; + xmb->icon_size = 128.0 * scale_factor; + xmb->font_size = new_font_size; + + menu_display_set_header_height(new_header_height); +} + +static void xmb_layout(xmb_handle_t *xmb) +{ + unsigned width, height, i, current, end; + settings_t *settings = config_get_ptr(); + file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); + size_t selection = menu_navigation_get_selection(); + + video_driver_get_size(&width, &height); + + switch (settings->uints.menu_xmb_layout) + { + /* Automatic */ + case 0: + { + xmb->use_ps3_layout = false; + xmb->use_ps3_layout = width > 320 && height > 240; + + /* Mimic the layout of the PSP instead of the PS3 on tiny screens */ + if (xmb->use_ps3_layout) + xmb_layout_ps3(xmb, width); + else + xmb_layout_psp(xmb, width); + } + break; + /* PS3 */ + case 1: + { + xmb->use_ps3_layout = true; + xmb_layout_ps3(xmb, width); + } + break; + /* PSP */ + case 2: + { + xmb->use_ps3_layout = false; + xmb_layout_psp(xmb, width); + } + break; + } + +#ifdef XMB_DEBUG + RARCH_LOG("[XMB] margin screen left: %.2f\n", xmb->margins_screen_left); + RARCH_LOG("[XMB] margin screen top: %.2f\n", xmb->margins_screen_top); + RARCH_LOG("[XMB] margin title left: %.2f\n", xmb->margins_title_left); + RARCH_LOG("[XMB] margin title top: %.2f\n", xmb->margins_title_top); + RARCH_LOG("[XMB] margin title bott: %.2f\n", xmb->margins_title_bottom); + RARCH_LOG("[XMB] margin label left: %.2f\n", xmb->margins_label_left); + RARCH_LOG("[XMB] margin label top: %.2f\n", xmb->margins_label_top); + RARCH_LOG("[XMB] margin sett left: %.2f\n", xmb->margins_setting_left); + RARCH_LOG("[XMB] icon spacing hor: %.2f\n", xmb->icon_spacing_horizontal); + RARCH_LOG("[XMB] icon spacing ver: %.2f\n", xmb->icon_spacing_vertical); + RARCH_LOG("[XMB] icon size: %.2f\n", xmb->icon_size); +#endif + + current = (unsigned)selection; + end = (unsigned)menu_entries_get_size(); + + for (i = 0; i < end; i++) + { + float ia = xmb->items_passive_alpha; + float iz = xmb->items_passive_zoom; + xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset( + selection_buf, i); + + if (!node) + continue; + + if (i == current) + { + ia = xmb->items_active_alpha; + iz = xmb->items_active_alpha; + } + + node->alpha = ia; + node->label_alpha = ia; + node->zoom = iz; + node->y = xmb_item_y(xmb, i, current); + } + + if (xmb->depth <= 1) + return; + + current = (unsigned)xmb->selection_ptr_old; + end = (unsigned)file_list_get_size(xmb->selection_buf_old); + + for (i = 0; i < end; i++) + { + float ia = 0; + float iz = xmb->items_passive_zoom; + xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset( + xmb->selection_buf_old, i); + + if (!node) + continue; + + if (i == current) + { + ia = xmb->items_active_alpha; + iz = xmb->items_active_alpha; + } + + node->alpha = ia; + node->label_alpha = 0; + node->zoom = iz; + node->y = xmb_item_y(xmb, i, current); + node->x = xmb->icon_size * 1 * -2; + } +} + + static void xmb_frame(void *data, video_frame_info_t *video_info) { math_matrix_4x4 mymat; @@ -3334,6 +4011,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) unsigned width = video_info->width; unsigned height = video_info->height; const float under_thumb_margin = 0.96; + static float previous_scale_factor = 0.0f; float scale_factor = 0.0f; float pseudo_font_length = 0.0f; xmb_handle_t *xmb = (xmb_handle_t*)data; @@ -3347,6 +4025,56 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) scale_factor = (settings->uints.menu_xmb_scale_factor * (float)width) / (1920.0 * 100); pseudo_font_length = xmb->icon_spacing_horizontal * 4 - xmb->icon_size / 4; + if (scale_factor != previous_scale_factor) + { + char bg_file_path[PATH_MAX_LENGTH] = {0}; + char *iconpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + iconpath[0] = '\0'; + + fill_pathname_application_special(bg_file_path, + sizeof(bg_file_path), APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_BG); + + if (!string_is_empty(bg_file_path)) + { + if (!string_is_empty(xmb->bg_file_path)) + free(xmb->bg_file_path); + xmb->bg_file_path = strdup(bg_file_path); + } + + fill_pathname_application_special(iconpath, + PATH_MAX_LENGTH * sizeof(char), + APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); + + menu_display_font_free(xmb->font); + menu_display_font_free(xmb->font2); + xmb_layout(xmb); + xmb->font = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, + xmb->font_size, + video_driver_is_threaded()); + xmb->font2 = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, + xmb->font2_size, + video_driver_is_threaded()); + xmb_context_reset_textures(xmb, iconpath); + xmb_context_reset_background(iconpath); + xmb_context_reset_horizontal_list(xmb); + + if (!string_is_equal(xmb_thumbnails_ident('R'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + xmb_update_thumbnail_path(xmb, 0, 'R'); + xmb_update_thumbnail_image(xmb); + } + if (!string_is_equal(xmb_thumbnails_ident('L'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + xmb_update_thumbnail_path(xmb, 0, 'L'); + xmb_update_thumbnail_image(xmb); + } + xmb_update_savestate_thumbnail_image(xmb); + + free(iconpath); + } + xmb->frame_count++; msg[0] = '\0'; @@ -4096,230 +4824,8 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) } menu_display_unset_viewport(video_info->width, video_info->height); -} -static void xmb_layout_ps3(xmb_handle_t *xmb, int width) -{ - unsigned new_font_size, new_header_height; - settings_t *settings = config_get_ptr(); - - float scale_factor = - (settings->uints.menu_xmb_scale_factor * width) / (1920.0 * 100); - - xmb->above_subitem_offset = 1.5; - xmb->above_item_offset = -1.0; - xmb->active_item_factor = 3.0; - xmb->under_item_offset = 5.0; - - xmb->categories_active_zoom = 1.0; - xmb->categories_passive_zoom = 0.5; - xmb->items_active_zoom = 1.0; - xmb->items_passive_zoom = 0.5; - - xmb->categories_active_alpha = 1.0; - xmb->categories_passive_alpha = 0.85; - xmb->items_active_alpha = 1.0; - xmb->items_passive_alpha = 0.85; - - xmb->shadow_offset = 2.0; - - new_font_size = 32.0 * scale_factor; - xmb->font2_size = 24.0 * scale_factor; - new_header_height = 128.0 * scale_factor; - - - xmb->thumbnail_width = 1024.0 * scale_factor; - xmb->left_thumbnail_width = 1024.0 * scale_factor; - xmb->savestate_thumbnail_width= 460.0 * scale_factor; - xmb->cursor_size = 64.0 * scale_factor; - - xmb->icon_spacing_horizontal = 200.0 * scale_factor; - xmb->icon_spacing_vertical = 64.0 * scale_factor; - - xmb->margins_screen_top = (256+32) * scale_factor; - xmb->margins_screen_left = 336.0 * scale_factor; - - xmb->margins_title_left = 60 * scale_factor; - xmb->margins_title_top = 60 * scale_factor + new_font_size / 3; - xmb->margins_title_bottom = 60 * scale_factor - new_font_size / 3; - - xmb->margins_label_left = 85.0 * scale_factor; - xmb->margins_label_top = new_font_size / 3.0; - - xmb->margins_setting_left = 600.0 * scale_factor * scale_mod[6]; - xmb->margins_dialog = 48 * scale_factor; - - xmb->margins_slice = 16; - - xmb->icon_size = 128.0 * scale_factor; - xmb->font_size = new_font_size; - - menu_display_set_header_height(new_header_height); -} - -static void xmb_layout_psp(xmb_handle_t *xmb, int width) -{ - unsigned new_font_size, new_header_height; - settings_t *settings = config_get_ptr(); - float scale_factor = - ((settings->uints.menu_xmb_scale_factor * width) / (1920.0 * 100)) * 1.5; -#ifdef _3DS - scale_factor = - settings->uints.menu_xmb_scale_factor / 400.0; -#endif - - xmb->above_subitem_offset = 1.5; - xmb->above_item_offset = -1.0; - xmb->active_item_factor = 2.0; - xmb->under_item_offset = 3.0; - - xmb->categories_active_zoom = 1.0; - xmb->categories_passive_zoom = 1.0; - xmb->items_active_zoom = 1.0; - xmb->items_passive_zoom = 1.0; - - xmb->categories_active_alpha = 1.0; - xmb->categories_passive_alpha = 0.85; - xmb->items_active_alpha = 1.0; - xmb->items_passive_alpha = 0.85; - - xmb->shadow_offset = 1.0; - - new_font_size = 32.0 * scale_factor; - xmb->font2_size = 24.0 * scale_factor; - new_header_height = 128.0 * scale_factor; - xmb->margins_screen_top = (256+32) * scale_factor; - - xmb->thumbnail_width = 460.0 * scale_factor; - xmb->left_thumbnail_width = 400.0 * scale_factor; - xmb->savestate_thumbnail_width= 460.0 * scale_factor; - xmb->cursor_size = 64.0; - - xmb->icon_spacing_horizontal = 250.0 * scale_factor; - xmb->icon_spacing_vertical = 108.0 * scale_factor; - - xmb->margins_screen_left = 136.0 * scale_factor; - xmb->margins_title_left = 60 * scale_factor; - xmb->margins_title_top = 60 * scale_factor + new_font_size / 3; - xmb->margins_title_bottom = 60 * scale_factor - new_font_size / 3; - xmb->margins_label_left = 85.0 * scale_factor; - xmb->margins_label_top = new_font_size / 3.0; - xmb->margins_setting_left = 600.0 * scale_factor; - xmb->margins_dialog = 48 * scale_factor; - xmb->margins_slice = 16; - xmb->icon_size = 128.0 * scale_factor; - xmb->font_size = new_font_size; - - menu_display_set_header_height(new_header_height); -} - -static void xmb_layout(xmb_handle_t *xmb) -{ - unsigned width, height, i, current, end; - settings_t *settings = config_get_ptr(); - file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); - size_t selection = menu_navigation_get_selection(); - - video_driver_get_size(&width, &height); - - switch (settings->uints.menu_xmb_layout) - { - /* Automatic */ - case 0: - { - xmb->use_ps3_layout = false; - xmb->use_ps3_layout = width > 320 && height > 240; - - /* Mimic the layout of the PSP instead of the PS3 on tiny screens */ - if (xmb->use_ps3_layout) - xmb_layout_ps3(xmb, width); - else - xmb_layout_psp(xmb, width); - } - break; - /* PS3 */ - case 1: - { - xmb->use_ps3_layout = true; - xmb_layout_ps3(xmb, width); - } - break; - /* PSP */ - case 2: - { - xmb->use_ps3_layout = false; - xmb_layout_psp(xmb, width); - } - break; - } - -#ifdef XMB_DEBUG - RARCH_LOG("[XMB] margin screen left: %.2f\n", xmb->margins_screen_left); - RARCH_LOG("[XMB] margin screen top: %.2f\n", xmb->margins_screen_top); - RARCH_LOG("[XMB] margin title left: %.2f\n", xmb->margins_title_left); - RARCH_LOG("[XMB] margin title top: %.2f\n", xmb->margins_title_top); - RARCH_LOG("[XMB] margin title bott: %.2f\n", xmb->margins_title_bottom); - RARCH_LOG("[XMB] margin label left: %.2f\n", xmb->margins_label_left); - RARCH_LOG("[XMB] margin label top: %.2f\n", xmb->margins_label_top); - RARCH_LOG("[XMB] margin sett left: %.2f\n", xmb->margins_setting_left); - RARCH_LOG("[XMB] icon spacing hor: %.2f\n", xmb->icon_spacing_horizontal); - RARCH_LOG("[XMB] icon spacing ver: %.2f\n", xmb->icon_spacing_vertical); - RARCH_LOG("[XMB] icon size: %.2f\n", xmb->icon_size); -#endif - - current = (unsigned)selection; - end = (unsigned)menu_entries_get_size(); - - for (i = 0; i < end; i++) - { - float ia = xmb->items_passive_alpha; - float iz = xmb->items_passive_zoom; - xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset( - selection_buf, i); - - if (!node) - continue; - - if (i == current) - { - ia = xmb->items_active_alpha; - iz = xmb->items_active_alpha; - } - - node->alpha = ia; - node->label_alpha = ia; - node->zoom = iz; - node->y = xmb_item_y(xmb, i, current); - } - - if (xmb->depth <= 1) - return; - - current = (unsigned)xmb->selection_ptr_old; - end = (unsigned)file_list_get_size(xmb->selection_buf_old); - - for (i = 0; i < end; i++) - { - float ia = 0; - float iz = xmb->items_passive_zoom; - xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset( - xmb->selection_buf_old, i); - - if (!node) - continue; - - if (i == current) - { - ia = xmb->items_active_alpha; - iz = xmb->items_active_alpha; - } - - node->alpha = ia; - node->label_alpha = 0; - node->zoom = iz; - node->y = xmb_item_y(xmb, i, current); - node->x = xmb->icon_size * 1 * -2; - } + previous_scale_factor = scale_factor; } static void xmb_ribbon_set_vertex(float *ribbon_verts, @@ -4600,506 +5106,6 @@ static bool xmb_load_image(void *userdata, void *data, enum menu_image_type type return true; } -static const char *xmb_texture_path(unsigned id) -{ - char *iconpath = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); - char *icon_name = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); - char *icon_fullpath = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); - - iconpath[0] = icon_name[0] = icon_fullpath[0] = '\0'; - - switch (id) - { - case XMB_TEXTURE_MAIN_MENU: -#if defined(HAVE_LAKKA) - icon_name = "lakka.png"; - break; -#else - icon_name = "retroarch.png"; - break; -#endif - case XMB_TEXTURE_SETTINGS: - icon_name = "settings.png"; - break; - case XMB_TEXTURE_HISTORY: - icon_name = "history.png"; - break; - case XMB_TEXTURE_FAVORITES: - icon_name = "favorites.png"; - break; - case XMB_TEXTURE_ADD_FAVORITE: - icon_name = "add-favorite.png"; - break; - case XMB_TEXTURE_MUSICS: - icon_name = "musics.png"; - break; -#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) - case XMB_TEXTURE_MOVIES: - icon_name = "movies.png"; - break; -#endif -#ifdef HAVE_IMAGEVIEWER - case XMB_TEXTURE_IMAGES: - icon_name = "images.png"; - break; -#endif - case XMB_TEXTURE_SETTING: - icon_name = "setting.png"; - break; - case XMB_TEXTURE_SUBSETTING: - icon_name = "subsetting.png"; - break; - case XMB_TEXTURE_ARROW: - icon_name = "arrow.png"; - break; - case XMB_TEXTURE_RUN: - icon_name = "run.png"; - break; - case XMB_TEXTURE_CLOSE: - icon_name = "close.png"; - break; - case XMB_TEXTURE_RESUME: - icon_name = "resume.png"; - break; - case XMB_TEXTURE_CLOCK: - icon_name = "clock.png"; - break; - case XMB_TEXTURE_BATTERY_FULL: - icon_name = "battery-full.png"; - break; - case XMB_TEXTURE_BATTERY_CHARGING: - icon_name = "battery-charging.png"; - break; - case XMB_TEXTURE_POINTER: - icon_name = "pointer.png"; - break; - case XMB_TEXTURE_SAVESTATE: - icon_name = "savestate.png"; - break; - case XMB_TEXTURE_LOADSTATE: - icon_name = "loadstate.png"; - break; - case XMB_TEXTURE_UNDO: - icon_name = "undo.png"; - break; - case XMB_TEXTURE_CORE_INFO: - icon_name = "core-infos.png"; - break; - case XMB_TEXTURE_WIFI: - icon_name = "wifi.png"; - break; - case XMB_TEXTURE_CORE_OPTIONS: - icon_name = "core-options.png"; - break; - case XMB_TEXTURE_INPUT_REMAPPING_OPTIONS: - icon_name = "core-input-remapping-options.png"; - break; - case XMB_TEXTURE_CHEAT_OPTIONS: - icon_name = "core-cheat-options.png"; - break; - case XMB_TEXTURE_DISK_OPTIONS: - icon_name = "core-disk-options.png"; - break; - case XMB_TEXTURE_SHADER_OPTIONS: - icon_name = "core-shader-options.png"; - break; - case XMB_TEXTURE_ACHIEVEMENT_LIST: - icon_name = "achievement-list.png"; - break; - case XMB_TEXTURE_SCREENSHOT: - icon_name = "screenshot.png"; - break; - case XMB_TEXTURE_RELOAD: - icon_name = "reload.png"; - break; - case XMB_TEXTURE_RENAME: - icon_name = "rename.png"; - break; - case XMB_TEXTURE_FILE: - icon_name = "file.png"; - break; - case XMB_TEXTURE_FOLDER: - icon_name = "folder.png"; - break; - case XMB_TEXTURE_ZIP: - icon_name = "zip.png"; - break; - case XMB_TEXTURE_MUSIC: - icon_name = "music.png"; - break; - case XMB_TEXTURE_FAVORITE: - icon_name = "favorites-content.png"; - break; - case XMB_TEXTURE_IMAGE: - icon_name = "image.png"; - break; - case XMB_TEXTURE_MOVIE: - icon_name = "movie.png"; - break; - case XMB_TEXTURE_CORE: - icon_name = "core.png"; - break; - case XMB_TEXTURE_RDB: - icon_name = "database.png"; - break; - case XMB_TEXTURE_CURSOR: - icon_name = "cursor.png"; - break; - case XMB_TEXTURE_SWITCH_ON: - icon_name = "on.png"; - break; - case XMB_TEXTURE_SWITCH_OFF: - icon_name = "off.png"; - break; - case XMB_TEXTURE_ADD: - icon_name = "add.png"; - break; -#ifdef HAVE_NETWORKING - case XMB_TEXTURE_NETPLAY: - icon_name = "netplay.png"; - break; - case XMB_TEXTURE_ROOM: - icon_name = "menu_room.png"; - break; - case XMB_TEXTURE_ROOM_LAN: - icon_name = "menu_room_lan.png"; - break; - case XMB_TEXTURE_ROOM_RELAY: - icon_name = "menu_room_relay.png"; - break; -#endif - case XMB_TEXTURE_KEY: - icon_name = "key.png"; - break; - case XMB_TEXTURE_KEY_HOVER: - icon_name = "key-hover.png"; - break; - case XMB_TEXTURE_DIALOG_SLICE: - icon_name = "dialog-slice.png"; - break; - case XMB_TEXTURE_ACHIEVEMENTS: - icon_name = "menu_achievements.png"; - break; - case XMB_TEXTURE_AUDIO: - icon_name = "menu_audio.png"; - break; - case XMB_TEXTURE_DRIVERS: - icon_name = "menu_drivers.png"; - break; - case XMB_TEXTURE_EXIT: - icon_name = "menu_exit.png"; - break; - case XMB_TEXTURE_FRAMESKIP: - icon_name = "menu_frameskip.png"; - break; - case XMB_TEXTURE_HELP: - icon_name = "menu_help.png"; - break; - case XMB_TEXTURE_INFO: - icon_name = "menu_info.png"; - break; - case XMB_TEXTURE_INPUT_SETTINGS: - icon_name = "Libretro - Pad.png"; - break; - case XMB_TEXTURE_LATENCY: - icon_name = "menu_latency.png"; - break; - case XMB_TEXTURE_NETWORK: - icon_name = "menu_network.png"; - break; - case XMB_TEXTURE_POWER: - icon_name = "menu_power.png"; - break; - case XMB_TEXTURE_RECORD: - icon_name = "menu_record.png"; - break; - case XMB_TEXTURE_SAVING: - icon_name = "menu_saving.png"; - break; - case XMB_TEXTURE_UPDATER: - icon_name = "menu_updater.png"; - break; - case XMB_TEXTURE_VIDEO: - icon_name = "menu_video.png"; - break; - case XMB_TEXTURE_MIXER: - icon_name = "menu_mixer.png"; - break; - case XMB_TEXTURE_LOG: - icon_name = "menu_log.png"; - break; - case XMB_TEXTURE_OSD: - icon_name = "menu_osd.png"; - break; - case XMB_TEXTURE_UI: - icon_name = "menu_ui.png"; - break; - case XMB_TEXTURE_USER: - icon_name = "menu_user.png"; - break; - case XMB_TEXTURE_PRIVACY: - icon_name = "menu_privacy.png"; - break; - case XMB_TEXTURE_PLAYLIST: - icon_name = "menu_playlist.png"; - break; - case XMB_TEXTURE_QUICKMENU: - icon_name = "menu_quickmenu.png"; - break; - case XMB_TEXTURE_REWIND: - icon_name = "menu_rewind.png"; - break; - case XMB_TEXTURE_OVERLAY: - icon_name = "menu_overlay.png"; - break; - case XMB_TEXTURE_OVERRIDE: - icon_name = "menu_override.png"; - break; - case XMB_TEXTURE_NOTIFICATIONS: - icon_name = "menu_notifications.png"; - break; - case XMB_TEXTURE_STREAM: - icon_name = "menu_stream.png"; - break; - case XMB_TEXTURE_SHUTDOWN: - icon_name = "menu_shutdown.png"; - break; - case XMB_TEXTURE_INPUT_DPAD_U: - icon_name = "input_DPAD-U.png"; - break; - case XMB_TEXTURE_INPUT_DPAD_D: - icon_name = "input_DPAD-D.png"; - break; - case XMB_TEXTURE_INPUT_DPAD_L: - icon_name = "input_DPAD-L.png"; - break; - case XMB_TEXTURE_INPUT_DPAD_R: - icon_name = "input_DPAD-R.png"; - break; - case XMB_TEXTURE_INPUT_STCK_U: - icon_name = "input_STCK-U.png"; - break; - case XMB_TEXTURE_INPUT_STCK_D: - icon_name = "input_STCK-D.png"; - break; - case XMB_TEXTURE_INPUT_STCK_L: - icon_name = "input_STCK-L.png"; - break; - case XMB_TEXTURE_INPUT_STCK_R: - icon_name = "input_STCK-R.png"; - break; - case XMB_TEXTURE_INPUT_STCK_P: - icon_name = "input_STCK-P.png"; - break; - case XMB_TEXTURE_INPUT_BTN_U: - icon_name = "input_BTN-U.png"; - break; - case XMB_TEXTURE_INPUT_BTN_D: - icon_name = "input_BTN-D.png"; - break; - case XMB_TEXTURE_INPUT_BTN_L: - icon_name = "input_BTN-L.png"; - break; - case XMB_TEXTURE_INPUT_BTN_R: - icon_name = "input_BTN-R.png"; - break; - case XMB_TEXTURE_INPUT_LB: - icon_name = "input_LB.png"; - break; - case XMB_TEXTURE_INPUT_RB: - icon_name = "input_RB.png"; - break; - case XMB_TEXTURE_INPUT_LT: - icon_name = "input_LT.png"; - break; - case XMB_TEXTURE_INPUT_RT: - icon_name = "input_RT.png"; - break; - case XMB_TEXTURE_INPUT_SELECT: - icon_name = "input_SELECT.png"; - break; - case XMB_TEXTURE_INPUT_START: - icon_name = "input_START.png"; - break; - case XMB_TEXTURE_CHECKMARK: - icon_name = "menu_check.png"; - break; - case XMB_TEXTURE_MENU_ADD: - icon_name = "menu_add.png"; - break; - case XMB_TEXTURE_BRIGHTNESS: - icon_name = "menu_brightness.png"; - break; - case XMB_TEXTURE_PAUSE: - icon_name = "menu_pause.png"; - break; - } - - fill_pathname_application_special(iconpath, - PATH_MAX_LENGTH * sizeof(char), - APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); - - icon_fullpath = iconpath; - strlcat(icon_fullpath, icon_name, PATH_MAX_LENGTH * sizeof(char)); - - if (!filestream_exists(icon_fullpath)) - { - RARCH_WARN("[XMB] Asset missing: %s\n", icon_fullpath); - return NULL; - } - else - return icon_name; - -} - -static void xmb_context_reset_textures( - xmb_handle_t *xmb, const char *iconpath) -{ - unsigned i; - settings_t *settings = config_get_ptr(); - - for (i = 0; i < XMB_TEXTURE_LAST; i++) - { - if (xmb_texture_path(i) == NULL) - { - /* If the icon doesn't exist at least try to return the subsetting icon*/ - if (!(i == XMB_TEXTURE_DIALOG_SLICE || i == XMB_TEXTURE_KEY_HOVER || i == XMB_TEXTURE_KEY_HOVER)) - menu_display_reset_textures_list(xmb_texture_path(XMB_TEXTURE_SUBSETTING), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); - continue; - } - menu_display_reset_textures_list(xmb_texture_path(i), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); - } - - /* Warn only if critical assets are missing, some themes are incomplete */ - if ( - ((xmb_texture_path(XMB_TEXTURE_SUBSETTING) == NULL)) && !(settings->uints.menu_xmb_theme == XMB_ICON_THEME_CUSTOM) - ) - runloop_msg_queue_push(msg_hash_to_str(MSG_MISSING_ASSETS), 1, 256, false); - - menu_display_allocate_white_texture(); - - xmb->main_menu_node.icon = xmb->textures.list[XMB_TEXTURE_MAIN_MENU]; - xmb->main_menu_node.alpha = xmb->categories_active_alpha; - xmb->main_menu_node.zoom = xmb->categories_active_zoom; - - xmb->settings_tab_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS]; - xmb->settings_tab_node.alpha = xmb->categories_active_alpha; - xmb->settings_tab_node.zoom = xmb->categories_active_zoom; - - xmb->history_tab_node.icon = xmb->textures.list[XMB_TEXTURE_HISTORY]; - xmb->history_tab_node.alpha = xmb->categories_active_alpha; - xmb->history_tab_node.zoom = xmb->categories_active_zoom; - - xmb->favorites_tab_node.icon = xmb->textures.list[XMB_TEXTURE_FAVORITES]; - xmb->favorites_tab_node.alpha = xmb->categories_active_alpha; - xmb->favorites_tab_node.zoom = xmb->categories_active_zoom; - - xmb->music_tab_node.icon = xmb->textures.list[XMB_TEXTURE_MUSICS]; - xmb->music_tab_node.alpha = xmb->categories_active_alpha; - xmb->music_tab_node.zoom = xmb->categories_active_zoom; - -#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) - xmb->video_tab_node.icon = xmb->textures.list[XMB_TEXTURE_MOVIES]; - xmb->video_tab_node.alpha = xmb->categories_active_alpha; - xmb->video_tab_node.zoom = xmb->categories_active_zoom; -#endif - -#ifdef HAVE_IMAGEVIEWER - xmb->images_tab_node.icon = xmb->textures.list[XMB_TEXTURE_IMAGES]; - xmb->images_tab_node.alpha = xmb->categories_active_alpha; - xmb->images_tab_node.zoom = xmb->categories_active_zoom; -#endif - - xmb->add_tab_node.icon = xmb->textures.list[XMB_TEXTURE_ADD]; - xmb->add_tab_node.alpha = xmb->categories_active_alpha; - xmb->add_tab_node.zoom = xmb->categories_active_zoom; - -#ifdef HAVE_NETWORKING - xmb->netplay_tab_node.icon = xmb->textures.list[XMB_TEXTURE_NETPLAY]; - xmb->netplay_tab_node.alpha = xmb->categories_active_alpha; - xmb->netplay_tab_node.zoom = xmb->categories_active_zoom; -#endif - -} - -static void xmb_context_reset_background(const char *iconpath) -{ - char *path = NULL; - settings_t *settings = config_get_ptr(); - const char *path_menu_wp = settings->paths.path_menu_wallpaper; - - if (!string_is_empty(path_menu_wp)) - path = strdup(path_menu_wp); - else if (!string_is_empty(iconpath)) - { - path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - path[0] = '\0'; - - fill_pathname_join(path, iconpath, "bg.png", - PATH_MAX_LENGTH * sizeof(char)); - } - - if (filestream_exists(path)) - task_push_image_load(path, - menu_display_handle_wallpaper_upload, NULL); - - if (path) - free(path); -} - -static void xmb_context_reset(void *data, bool is_threaded) -{ - xmb_handle_t *xmb = (xmb_handle_t*)data; - - if (xmb) - { - char bg_file_path[PATH_MAX_LENGTH] = {0}; - char *iconpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - iconpath[0] = '\0'; - - fill_pathname_application_special(bg_file_path, - sizeof(bg_file_path), APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_BG); - - if (!string_is_empty(bg_file_path)) - { - if (!string_is_empty(xmb->bg_file_path)) - free(xmb->bg_file_path); - xmb->bg_file_path = strdup(bg_file_path); - } - - fill_pathname_application_special(iconpath, - PATH_MAX_LENGTH * sizeof(char), - APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); - - xmb_layout(xmb); - xmb->font = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, - xmb->font_size, - is_threaded); - xmb->font2 = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, - xmb->font2_size, - is_threaded); - xmb_context_reset_textures(xmb, iconpath); - xmb_context_reset_background(iconpath); - xmb_context_reset_horizontal_list(xmb); - - if (!string_is_equal(xmb_thumbnails_ident('R'), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) - { - xmb_update_thumbnail_path(xmb, 0, 'R'); - xmb_update_thumbnail_image(xmb); - } - if (!string_is_equal(xmb_thumbnails_ident('L'), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) - { - xmb_update_thumbnail_path(xmb, 0, 'L'); - xmb_update_thumbnail_image(xmb); - } - xmb_update_savestate_thumbnail_image(xmb); - - free(iconpath); - } -} - static void xmb_navigation_clear(void *data, bool pending_push) { xmb_handle_t *xmb = (xmb_handle_t*)data; From 006a002f195a5493645bde00f50b995adbc43704 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 25 Nov 2018 02:48:14 +0100 Subject: [PATCH 039/153] Revert "Should now correctly rescale after resolution changes" This reverts commit c9bb537cdd33736c800a4c9ed30f8ead33bf4369. --- menu/drivers/xmb.c | 1452 ++++++++++++++++++++++---------------------- 1 file changed, 723 insertions(+), 729 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index bae14a630e..0f803d5c00 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -3318,683 +3318,6 @@ static void xmb_draw_dark_layer( menu_display_blend_end(video_info); } -static const char *xmb_texture_path(unsigned id) -{ - char *iconpath = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); - char *icon_name = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); - char *icon_fullpath = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); - - iconpath[0] = icon_name[0] = icon_fullpath[0] = '\0'; - - switch (id) - { - case XMB_TEXTURE_MAIN_MENU: -#if defined(HAVE_LAKKA) - icon_name = "lakka.png"; - break; -#else - icon_name = "retroarch.png"; - break; -#endif - case XMB_TEXTURE_SETTINGS: - icon_name = "settings.png"; - break; - case XMB_TEXTURE_HISTORY: - icon_name = "history.png"; - break; - case XMB_TEXTURE_FAVORITES: - icon_name = "favorites.png"; - break; - case XMB_TEXTURE_ADD_FAVORITE: - icon_name = "add-favorite.png"; - break; - case XMB_TEXTURE_MUSICS: - icon_name = "musics.png"; - break; -#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) - case XMB_TEXTURE_MOVIES: - icon_name = "movies.png"; - break; -#endif -#ifdef HAVE_IMAGEVIEWER - case XMB_TEXTURE_IMAGES: - icon_name = "images.png"; - break; -#endif - case XMB_TEXTURE_SETTING: - icon_name = "setting.png"; - break; - case XMB_TEXTURE_SUBSETTING: - icon_name = "subsetting.png"; - break; - case XMB_TEXTURE_ARROW: - icon_name = "arrow.png"; - break; - case XMB_TEXTURE_RUN: - icon_name = "run.png"; - break; - case XMB_TEXTURE_CLOSE: - icon_name = "close.png"; - break; - case XMB_TEXTURE_RESUME: - icon_name = "resume.png"; - break; - case XMB_TEXTURE_CLOCK: - icon_name = "clock.png"; - break; - case XMB_TEXTURE_BATTERY_FULL: - icon_name = "battery-full.png"; - break; - case XMB_TEXTURE_BATTERY_CHARGING: - icon_name = "battery-charging.png"; - break; - case XMB_TEXTURE_POINTER: - icon_name = "pointer.png"; - break; - case XMB_TEXTURE_SAVESTATE: - icon_name = "savestate.png"; - break; - case XMB_TEXTURE_LOADSTATE: - icon_name = "loadstate.png"; - break; - case XMB_TEXTURE_UNDO: - icon_name = "undo.png"; - break; - case XMB_TEXTURE_CORE_INFO: - icon_name = "core-infos.png"; - break; - case XMB_TEXTURE_WIFI: - icon_name = "wifi.png"; - break; - case XMB_TEXTURE_CORE_OPTIONS: - icon_name = "core-options.png"; - break; - case XMB_TEXTURE_INPUT_REMAPPING_OPTIONS: - icon_name = "core-input-remapping-options.png"; - break; - case XMB_TEXTURE_CHEAT_OPTIONS: - icon_name = "core-cheat-options.png"; - break; - case XMB_TEXTURE_DISK_OPTIONS: - icon_name = "core-disk-options.png"; - break; - case XMB_TEXTURE_SHADER_OPTIONS: - icon_name = "core-shader-options.png"; - break; - case XMB_TEXTURE_ACHIEVEMENT_LIST: - icon_name = "achievement-list.png"; - break; - case XMB_TEXTURE_SCREENSHOT: - icon_name = "screenshot.png"; - break; - case XMB_TEXTURE_RELOAD: - icon_name = "reload.png"; - break; - case XMB_TEXTURE_RENAME: - icon_name = "rename.png"; - break; - case XMB_TEXTURE_FILE: - icon_name = "file.png"; - break; - case XMB_TEXTURE_FOLDER: - icon_name = "folder.png"; - break; - case XMB_TEXTURE_ZIP: - icon_name = "zip.png"; - break; - case XMB_TEXTURE_MUSIC: - icon_name = "music.png"; - break; - case XMB_TEXTURE_FAVORITE: - icon_name = "favorites-content.png"; - break; - case XMB_TEXTURE_IMAGE: - icon_name = "image.png"; - break; - case XMB_TEXTURE_MOVIE: - icon_name = "movie.png"; - break; - case XMB_TEXTURE_CORE: - icon_name = "core.png"; - break; - case XMB_TEXTURE_RDB: - icon_name = "database.png"; - break; - case XMB_TEXTURE_CURSOR: - icon_name = "cursor.png"; - break; - case XMB_TEXTURE_SWITCH_ON: - icon_name = "on.png"; - break; - case XMB_TEXTURE_SWITCH_OFF: - icon_name = "off.png"; - break; - case XMB_TEXTURE_ADD: - icon_name = "add.png"; - break; -#ifdef HAVE_NETWORKING - case XMB_TEXTURE_NETPLAY: - icon_name = "netplay.png"; - break; - case XMB_TEXTURE_ROOM: - icon_name = "menu_room.png"; - break; - case XMB_TEXTURE_ROOM_LAN: - icon_name = "menu_room_lan.png"; - break; - case XMB_TEXTURE_ROOM_RELAY: - icon_name = "menu_room_relay.png"; - break; -#endif - case XMB_TEXTURE_KEY: - icon_name = "key.png"; - break; - case XMB_TEXTURE_KEY_HOVER: - icon_name = "key-hover.png"; - break; - case XMB_TEXTURE_DIALOG_SLICE: - icon_name = "dialog-slice.png"; - break; - case XMB_TEXTURE_ACHIEVEMENTS: - icon_name = "menu_achievements.png"; - break; - case XMB_TEXTURE_AUDIO: - icon_name = "menu_audio.png"; - break; - case XMB_TEXTURE_DRIVERS: - icon_name = "menu_drivers.png"; - break; - case XMB_TEXTURE_EXIT: - icon_name = "menu_exit.png"; - break; - case XMB_TEXTURE_FRAMESKIP: - icon_name = "menu_frameskip.png"; - break; - case XMB_TEXTURE_HELP: - icon_name = "menu_help.png"; - break; - case XMB_TEXTURE_INFO: - icon_name = "menu_info.png"; - break; - case XMB_TEXTURE_INPUT_SETTINGS: - icon_name = "Libretro - Pad.png"; - break; - case XMB_TEXTURE_LATENCY: - icon_name = "menu_latency.png"; - break; - case XMB_TEXTURE_NETWORK: - icon_name = "menu_network.png"; - break; - case XMB_TEXTURE_POWER: - icon_name = "menu_power.png"; - break; - case XMB_TEXTURE_RECORD: - icon_name = "menu_record.png"; - break; - case XMB_TEXTURE_SAVING: - icon_name = "menu_saving.png"; - break; - case XMB_TEXTURE_UPDATER: - icon_name = "menu_updater.png"; - break; - case XMB_TEXTURE_VIDEO: - icon_name = "menu_video.png"; - break; - case XMB_TEXTURE_MIXER: - icon_name = "menu_mixer.png"; - break; - case XMB_TEXTURE_LOG: - icon_name = "menu_log.png"; - break; - case XMB_TEXTURE_OSD: - icon_name = "menu_osd.png"; - break; - case XMB_TEXTURE_UI: - icon_name = "menu_ui.png"; - break; - case XMB_TEXTURE_USER: - icon_name = "menu_user.png"; - break; - case XMB_TEXTURE_PRIVACY: - icon_name = "menu_privacy.png"; - break; - case XMB_TEXTURE_PLAYLIST: - icon_name = "menu_playlist.png"; - break; - case XMB_TEXTURE_QUICKMENU: - icon_name = "menu_quickmenu.png"; - break; - case XMB_TEXTURE_REWIND: - icon_name = "menu_rewind.png"; - break; - case XMB_TEXTURE_OVERLAY: - icon_name = "menu_overlay.png"; - break; - case XMB_TEXTURE_OVERRIDE: - icon_name = "menu_override.png"; - break; - case XMB_TEXTURE_NOTIFICATIONS: - icon_name = "menu_notifications.png"; - break; - case XMB_TEXTURE_STREAM: - icon_name = "menu_stream.png"; - break; - case XMB_TEXTURE_SHUTDOWN: - icon_name = "menu_shutdown.png"; - break; - case XMB_TEXTURE_INPUT_DPAD_U: - icon_name = "input_DPAD-U.png"; - break; - case XMB_TEXTURE_INPUT_DPAD_D: - icon_name = "input_DPAD-D.png"; - break; - case XMB_TEXTURE_INPUT_DPAD_L: - icon_name = "input_DPAD-L.png"; - break; - case XMB_TEXTURE_INPUT_DPAD_R: - icon_name = "input_DPAD-R.png"; - break; - case XMB_TEXTURE_INPUT_STCK_U: - icon_name = "input_STCK-U.png"; - break; - case XMB_TEXTURE_INPUT_STCK_D: - icon_name = "input_STCK-D.png"; - break; - case XMB_TEXTURE_INPUT_STCK_L: - icon_name = "input_STCK-L.png"; - break; - case XMB_TEXTURE_INPUT_STCK_R: - icon_name = "input_STCK-R.png"; - break; - case XMB_TEXTURE_INPUT_STCK_P: - icon_name = "input_STCK-P.png"; - break; - case XMB_TEXTURE_INPUT_BTN_U: - icon_name = "input_BTN-U.png"; - break; - case XMB_TEXTURE_INPUT_BTN_D: - icon_name = "input_BTN-D.png"; - break; - case XMB_TEXTURE_INPUT_BTN_L: - icon_name = "input_BTN-L.png"; - break; - case XMB_TEXTURE_INPUT_BTN_R: - icon_name = "input_BTN-R.png"; - break; - case XMB_TEXTURE_INPUT_LB: - icon_name = "input_LB.png"; - break; - case XMB_TEXTURE_INPUT_RB: - icon_name = "input_RB.png"; - break; - case XMB_TEXTURE_INPUT_LT: - icon_name = "input_LT.png"; - break; - case XMB_TEXTURE_INPUT_RT: - icon_name = "input_RT.png"; - break; - case XMB_TEXTURE_INPUT_SELECT: - icon_name = "input_SELECT.png"; - break; - case XMB_TEXTURE_INPUT_START: - icon_name = "input_START.png"; - break; - case XMB_TEXTURE_CHECKMARK: - icon_name = "menu_check.png"; - break; - case XMB_TEXTURE_MENU_ADD: - icon_name = "menu_add.png"; - break; - case XMB_TEXTURE_BRIGHTNESS: - icon_name = "menu_brightness.png"; - break; - case XMB_TEXTURE_PAUSE: - icon_name = "menu_pause.png"; - break; - } - - fill_pathname_application_special(iconpath, - PATH_MAX_LENGTH * sizeof(char), - APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); - - icon_fullpath = iconpath; - strlcat(icon_fullpath, icon_name, PATH_MAX_LENGTH * sizeof(char)); - - if (!filestream_exists(icon_fullpath)) - { - RARCH_WARN("[XMB] Asset missing: %s\n", icon_fullpath); - return NULL; - } - else - return icon_name; - -} - - -static void xmb_context_reset_textures( - xmb_handle_t *xmb, const char *iconpath) -{ - unsigned i; - settings_t *settings = config_get_ptr(); - - for (i = 0; i < XMB_TEXTURE_LAST; i++) - { - if (xmb_texture_path(i) == NULL) - { - /* If the icon doesn't exist at least try to return the subsetting icon*/ - if (!(i == XMB_TEXTURE_DIALOG_SLICE || i == XMB_TEXTURE_KEY_HOVER || i == XMB_TEXTURE_KEY_HOVER)) - menu_display_reset_textures_list(xmb_texture_path(XMB_TEXTURE_SUBSETTING), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); - continue; - } - menu_display_reset_textures_list(xmb_texture_path(i), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); - } - - /* Warn only if critical assets are missing, some themes are incomplete */ - if ( - ((xmb_texture_path(XMB_TEXTURE_SUBSETTING) == NULL)) && !(settings->uints.menu_xmb_theme == XMB_ICON_THEME_CUSTOM) - ) - runloop_msg_queue_push(msg_hash_to_str(MSG_MISSING_ASSETS), 1, 256, false); - - menu_display_allocate_white_texture(); - - xmb->main_menu_node.icon = xmb->textures.list[XMB_TEXTURE_MAIN_MENU]; - xmb->main_menu_node.alpha = xmb->categories_active_alpha; - xmb->main_menu_node.zoom = xmb->categories_active_zoom; - - xmb->settings_tab_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS]; - xmb->settings_tab_node.alpha = xmb->categories_active_alpha; - xmb->settings_tab_node.zoom = xmb->categories_active_zoom; - - xmb->history_tab_node.icon = xmb->textures.list[XMB_TEXTURE_HISTORY]; - xmb->history_tab_node.alpha = xmb->categories_active_alpha; - xmb->history_tab_node.zoom = xmb->categories_active_zoom; - - xmb->favorites_tab_node.icon = xmb->textures.list[XMB_TEXTURE_FAVORITES]; - xmb->favorites_tab_node.alpha = xmb->categories_active_alpha; - xmb->favorites_tab_node.zoom = xmb->categories_active_zoom; - - xmb->music_tab_node.icon = xmb->textures.list[XMB_TEXTURE_MUSICS]; - xmb->music_tab_node.alpha = xmb->categories_active_alpha; - xmb->music_tab_node.zoom = xmb->categories_active_zoom; - -#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) - xmb->video_tab_node.icon = xmb->textures.list[XMB_TEXTURE_MOVIES]; - xmb->video_tab_node.alpha = xmb->categories_active_alpha; - xmb->video_tab_node.zoom = xmb->categories_active_zoom; -#endif - -#ifdef HAVE_IMAGEVIEWER - xmb->images_tab_node.icon = xmb->textures.list[XMB_TEXTURE_IMAGES]; - xmb->images_tab_node.alpha = xmb->categories_active_alpha; - xmb->images_tab_node.zoom = xmb->categories_active_zoom; -#endif - - xmb->add_tab_node.icon = xmb->textures.list[XMB_TEXTURE_ADD]; - xmb->add_tab_node.alpha = xmb->categories_active_alpha; - xmb->add_tab_node.zoom = xmb->categories_active_zoom; - -#ifdef HAVE_NETWORKING - xmb->netplay_tab_node.icon = xmb->textures.list[XMB_TEXTURE_NETPLAY]; - xmb->netplay_tab_node.alpha = xmb->categories_active_alpha; - xmb->netplay_tab_node.zoom = xmb->categories_active_zoom; -#endif - -} - -static void xmb_context_reset_background(const char *iconpath) -{ - char *path = NULL; - settings_t *settings = config_get_ptr(); - const char *path_menu_wp = settings->paths.path_menu_wallpaper; - - if (!string_is_empty(path_menu_wp)) - path = strdup(path_menu_wp); - else if (!string_is_empty(iconpath)) - { - path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - path[0] = '\0'; - - fill_pathname_join(path, iconpath, "bg.png", - PATH_MAX_LENGTH * sizeof(char)); - } - - if (filestream_exists(path)) - task_push_image_load(path, - menu_display_handle_wallpaper_upload, NULL); - - if (path) - free(path); -} - -static void xmb_context_reset(void *data, bool is_threaded) -{ -} - -static void xmb_layout_ps3(xmb_handle_t *xmb, int width) -{ - unsigned new_font_size, new_header_height; - settings_t *settings = config_get_ptr(); - - float scale_factor = - (settings->uints.menu_xmb_scale_factor * width) / (1920.0 * 100); - - xmb->above_subitem_offset = 1.5; - xmb->above_item_offset = -1.0; - xmb->active_item_factor = 3.0; - xmb->under_item_offset = 5.0; - - xmb->categories_active_zoom = 1.0; - xmb->categories_passive_zoom = 0.5; - xmb->items_active_zoom = 1.0; - xmb->items_passive_zoom = 0.5; - - xmb->categories_active_alpha = 1.0; - xmb->categories_passive_alpha = 0.85; - xmb->items_active_alpha = 1.0; - xmb->items_passive_alpha = 0.85; - - xmb->shadow_offset = 2.0; - - new_font_size = 32.0 * scale_factor; - xmb->font2_size = 24.0 * scale_factor; - new_header_height = 128.0 * scale_factor; - - - xmb->thumbnail_width = 1024.0 * scale_factor; - xmb->left_thumbnail_width = 1024.0 * scale_factor; - xmb->savestate_thumbnail_width= 460.0 * scale_factor; - xmb->cursor_size = 64.0 * scale_factor; - - xmb->icon_spacing_horizontal = 200.0 * scale_factor; - xmb->icon_spacing_vertical = 64.0 * scale_factor; - - xmb->margins_screen_top = (256+32) * scale_factor; - xmb->margins_screen_left = 336.0 * scale_factor; - - xmb->margins_title_left = 60 * scale_factor; - xmb->margins_title_top = 60 * scale_factor + new_font_size / 3; - xmb->margins_title_bottom = 60 * scale_factor - new_font_size / 3; - - xmb->margins_label_left = 85.0 * scale_factor; - xmb->margins_label_top = new_font_size / 3.0; - - xmb->margins_setting_left = 600.0 * scale_factor * scale_mod[6]; - xmb->margins_dialog = 48 * scale_factor; - - xmb->margins_slice = 16; - - xmb->icon_size = 128.0 * scale_factor; - xmb->font_size = new_font_size; - - menu_display_set_header_height(new_header_height); -} - -static void xmb_layout_psp(xmb_handle_t *xmb, int width) -{ - unsigned new_font_size, new_header_height; - settings_t *settings = config_get_ptr(); - float scale_factor = - ((settings->uints.menu_xmb_scale_factor * width) / (1920.0 * 100)) * 1.5; -#ifdef _3DS - scale_factor = - settings->uints.menu_xmb_scale_factor / 400.0; -#endif - - xmb->above_subitem_offset = 1.5; - xmb->above_item_offset = -1.0; - xmb->active_item_factor = 2.0; - xmb->under_item_offset = 3.0; - - xmb->categories_active_zoom = 1.0; - xmb->categories_passive_zoom = 1.0; - xmb->items_active_zoom = 1.0; - xmb->items_passive_zoom = 1.0; - - xmb->categories_active_alpha = 1.0; - xmb->categories_passive_alpha = 0.85; - xmb->items_active_alpha = 1.0; - xmb->items_passive_alpha = 0.85; - - xmb->shadow_offset = 1.0; - - new_font_size = 32.0 * scale_factor; - xmb->font2_size = 24.0 * scale_factor; - new_header_height = 128.0 * scale_factor; - xmb->margins_screen_top = (256+32) * scale_factor; - - xmb->thumbnail_width = 460.0 * scale_factor; - xmb->left_thumbnail_width = 400.0 * scale_factor; - xmb->savestate_thumbnail_width= 460.0 * scale_factor; - xmb->cursor_size = 64.0; - - xmb->icon_spacing_horizontal = 250.0 * scale_factor; - xmb->icon_spacing_vertical = 108.0 * scale_factor; - - xmb->margins_screen_left = 136.0 * scale_factor; - xmb->margins_title_left = 60 * scale_factor; - xmb->margins_title_top = 60 * scale_factor + new_font_size / 3; - xmb->margins_title_bottom = 60 * scale_factor - new_font_size / 3; - xmb->margins_label_left = 85.0 * scale_factor; - xmb->margins_label_top = new_font_size / 3.0; - xmb->margins_setting_left = 600.0 * scale_factor; - xmb->margins_dialog = 48 * scale_factor; - xmb->margins_slice = 16; - xmb->icon_size = 128.0 * scale_factor; - xmb->font_size = new_font_size; - - menu_display_set_header_height(new_header_height); -} - -static void xmb_layout(xmb_handle_t *xmb) -{ - unsigned width, height, i, current, end; - settings_t *settings = config_get_ptr(); - file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); - size_t selection = menu_navigation_get_selection(); - - video_driver_get_size(&width, &height); - - switch (settings->uints.menu_xmb_layout) - { - /* Automatic */ - case 0: - { - xmb->use_ps3_layout = false; - xmb->use_ps3_layout = width > 320 && height > 240; - - /* Mimic the layout of the PSP instead of the PS3 on tiny screens */ - if (xmb->use_ps3_layout) - xmb_layout_ps3(xmb, width); - else - xmb_layout_psp(xmb, width); - } - break; - /* PS3 */ - case 1: - { - xmb->use_ps3_layout = true; - xmb_layout_ps3(xmb, width); - } - break; - /* PSP */ - case 2: - { - xmb->use_ps3_layout = false; - xmb_layout_psp(xmb, width); - } - break; - } - -#ifdef XMB_DEBUG - RARCH_LOG("[XMB] margin screen left: %.2f\n", xmb->margins_screen_left); - RARCH_LOG("[XMB] margin screen top: %.2f\n", xmb->margins_screen_top); - RARCH_LOG("[XMB] margin title left: %.2f\n", xmb->margins_title_left); - RARCH_LOG("[XMB] margin title top: %.2f\n", xmb->margins_title_top); - RARCH_LOG("[XMB] margin title bott: %.2f\n", xmb->margins_title_bottom); - RARCH_LOG("[XMB] margin label left: %.2f\n", xmb->margins_label_left); - RARCH_LOG("[XMB] margin label top: %.2f\n", xmb->margins_label_top); - RARCH_LOG("[XMB] margin sett left: %.2f\n", xmb->margins_setting_left); - RARCH_LOG("[XMB] icon spacing hor: %.2f\n", xmb->icon_spacing_horizontal); - RARCH_LOG("[XMB] icon spacing ver: %.2f\n", xmb->icon_spacing_vertical); - RARCH_LOG("[XMB] icon size: %.2f\n", xmb->icon_size); -#endif - - current = (unsigned)selection; - end = (unsigned)menu_entries_get_size(); - - for (i = 0; i < end; i++) - { - float ia = xmb->items_passive_alpha; - float iz = xmb->items_passive_zoom; - xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset( - selection_buf, i); - - if (!node) - continue; - - if (i == current) - { - ia = xmb->items_active_alpha; - iz = xmb->items_active_alpha; - } - - node->alpha = ia; - node->label_alpha = ia; - node->zoom = iz; - node->y = xmb_item_y(xmb, i, current); - } - - if (xmb->depth <= 1) - return; - - current = (unsigned)xmb->selection_ptr_old; - end = (unsigned)file_list_get_size(xmb->selection_buf_old); - - for (i = 0; i < end; i++) - { - float ia = 0; - float iz = xmb->items_passive_zoom; - xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset( - xmb->selection_buf_old, i); - - if (!node) - continue; - - if (i == current) - { - ia = xmb->items_active_alpha; - iz = xmb->items_active_alpha; - } - - node->alpha = ia; - node->label_alpha = 0; - node->zoom = iz; - node->y = xmb_item_y(xmb, i, current); - node->x = xmb->icon_size * 1 * -2; - } -} - - static void xmb_frame(void *data, video_frame_info_t *video_info) { math_matrix_4x4 mymat; @@ -4011,7 +3334,6 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) unsigned width = video_info->width; unsigned height = video_info->height; const float under_thumb_margin = 0.96; - static float previous_scale_factor = 0.0f; float scale_factor = 0.0f; float pseudo_font_length = 0.0f; xmb_handle_t *xmb = (xmb_handle_t*)data; @@ -4025,56 +3347,6 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) scale_factor = (settings->uints.menu_xmb_scale_factor * (float)width) / (1920.0 * 100); pseudo_font_length = xmb->icon_spacing_horizontal * 4 - xmb->icon_size / 4; - if (scale_factor != previous_scale_factor) - { - char bg_file_path[PATH_MAX_LENGTH] = {0}; - char *iconpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - iconpath[0] = '\0'; - - fill_pathname_application_special(bg_file_path, - sizeof(bg_file_path), APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_BG); - - if (!string_is_empty(bg_file_path)) - { - if (!string_is_empty(xmb->bg_file_path)) - free(xmb->bg_file_path); - xmb->bg_file_path = strdup(bg_file_path); - } - - fill_pathname_application_special(iconpath, - PATH_MAX_LENGTH * sizeof(char), - APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); - - menu_display_font_free(xmb->font); - menu_display_font_free(xmb->font2); - xmb_layout(xmb); - xmb->font = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, - xmb->font_size, - video_driver_is_threaded()); - xmb->font2 = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, - xmb->font2_size, - video_driver_is_threaded()); - xmb_context_reset_textures(xmb, iconpath); - xmb_context_reset_background(iconpath); - xmb_context_reset_horizontal_list(xmb); - - if (!string_is_equal(xmb_thumbnails_ident('R'), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) - { - xmb_update_thumbnail_path(xmb, 0, 'R'); - xmb_update_thumbnail_image(xmb); - } - if (!string_is_equal(xmb_thumbnails_ident('L'), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) - { - xmb_update_thumbnail_path(xmb, 0, 'L'); - xmb_update_thumbnail_image(xmb); - } - xmb_update_savestate_thumbnail_image(xmb); - - free(iconpath); - } - xmb->frame_count++; msg[0] = '\0'; @@ -4824,8 +4096,230 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) } menu_display_unset_viewport(video_info->width, video_info->height); +} - previous_scale_factor = scale_factor; +static void xmb_layout_ps3(xmb_handle_t *xmb, int width) +{ + unsigned new_font_size, new_header_height; + settings_t *settings = config_get_ptr(); + + float scale_factor = + (settings->uints.menu_xmb_scale_factor * width) / (1920.0 * 100); + + xmb->above_subitem_offset = 1.5; + xmb->above_item_offset = -1.0; + xmb->active_item_factor = 3.0; + xmb->under_item_offset = 5.0; + + xmb->categories_active_zoom = 1.0; + xmb->categories_passive_zoom = 0.5; + xmb->items_active_zoom = 1.0; + xmb->items_passive_zoom = 0.5; + + xmb->categories_active_alpha = 1.0; + xmb->categories_passive_alpha = 0.85; + xmb->items_active_alpha = 1.0; + xmb->items_passive_alpha = 0.85; + + xmb->shadow_offset = 2.0; + + new_font_size = 32.0 * scale_factor; + xmb->font2_size = 24.0 * scale_factor; + new_header_height = 128.0 * scale_factor; + + + xmb->thumbnail_width = 1024.0 * scale_factor; + xmb->left_thumbnail_width = 1024.0 * scale_factor; + xmb->savestate_thumbnail_width= 460.0 * scale_factor; + xmb->cursor_size = 64.0 * scale_factor; + + xmb->icon_spacing_horizontal = 200.0 * scale_factor; + xmb->icon_spacing_vertical = 64.0 * scale_factor; + + xmb->margins_screen_top = (256+32) * scale_factor; + xmb->margins_screen_left = 336.0 * scale_factor; + + xmb->margins_title_left = 60 * scale_factor; + xmb->margins_title_top = 60 * scale_factor + new_font_size / 3; + xmb->margins_title_bottom = 60 * scale_factor - new_font_size / 3; + + xmb->margins_label_left = 85.0 * scale_factor; + xmb->margins_label_top = new_font_size / 3.0; + + xmb->margins_setting_left = 600.0 * scale_factor * scale_mod[6]; + xmb->margins_dialog = 48 * scale_factor; + + xmb->margins_slice = 16; + + xmb->icon_size = 128.0 * scale_factor; + xmb->font_size = new_font_size; + + menu_display_set_header_height(new_header_height); +} + +static void xmb_layout_psp(xmb_handle_t *xmb, int width) +{ + unsigned new_font_size, new_header_height; + settings_t *settings = config_get_ptr(); + float scale_factor = + ((settings->uints.menu_xmb_scale_factor * width) / (1920.0 * 100)) * 1.5; +#ifdef _3DS + scale_factor = + settings->uints.menu_xmb_scale_factor / 400.0; +#endif + + xmb->above_subitem_offset = 1.5; + xmb->above_item_offset = -1.0; + xmb->active_item_factor = 2.0; + xmb->under_item_offset = 3.0; + + xmb->categories_active_zoom = 1.0; + xmb->categories_passive_zoom = 1.0; + xmb->items_active_zoom = 1.0; + xmb->items_passive_zoom = 1.0; + + xmb->categories_active_alpha = 1.0; + xmb->categories_passive_alpha = 0.85; + xmb->items_active_alpha = 1.0; + xmb->items_passive_alpha = 0.85; + + xmb->shadow_offset = 1.0; + + new_font_size = 32.0 * scale_factor; + xmb->font2_size = 24.0 * scale_factor; + new_header_height = 128.0 * scale_factor; + xmb->margins_screen_top = (256+32) * scale_factor; + + xmb->thumbnail_width = 460.0 * scale_factor; + xmb->left_thumbnail_width = 400.0 * scale_factor; + xmb->savestate_thumbnail_width= 460.0 * scale_factor; + xmb->cursor_size = 64.0; + + xmb->icon_spacing_horizontal = 250.0 * scale_factor; + xmb->icon_spacing_vertical = 108.0 * scale_factor; + + xmb->margins_screen_left = 136.0 * scale_factor; + xmb->margins_title_left = 60 * scale_factor; + xmb->margins_title_top = 60 * scale_factor + new_font_size / 3; + xmb->margins_title_bottom = 60 * scale_factor - new_font_size / 3; + xmb->margins_label_left = 85.0 * scale_factor; + xmb->margins_label_top = new_font_size / 3.0; + xmb->margins_setting_left = 600.0 * scale_factor; + xmb->margins_dialog = 48 * scale_factor; + xmb->margins_slice = 16; + xmb->icon_size = 128.0 * scale_factor; + xmb->font_size = new_font_size; + + menu_display_set_header_height(new_header_height); +} + +static void xmb_layout(xmb_handle_t *xmb) +{ + unsigned width, height, i, current, end; + settings_t *settings = config_get_ptr(); + file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); + size_t selection = menu_navigation_get_selection(); + + video_driver_get_size(&width, &height); + + switch (settings->uints.menu_xmb_layout) + { + /* Automatic */ + case 0: + { + xmb->use_ps3_layout = false; + xmb->use_ps3_layout = width > 320 && height > 240; + + /* Mimic the layout of the PSP instead of the PS3 on tiny screens */ + if (xmb->use_ps3_layout) + xmb_layout_ps3(xmb, width); + else + xmb_layout_psp(xmb, width); + } + break; + /* PS3 */ + case 1: + { + xmb->use_ps3_layout = true; + xmb_layout_ps3(xmb, width); + } + break; + /* PSP */ + case 2: + { + xmb->use_ps3_layout = false; + xmb_layout_psp(xmb, width); + } + break; + } + +#ifdef XMB_DEBUG + RARCH_LOG("[XMB] margin screen left: %.2f\n", xmb->margins_screen_left); + RARCH_LOG("[XMB] margin screen top: %.2f\n", xmb->margins_screen_top); + RARCH_LOG("[XMB] margin title left: %.2f\n", xmb->margins_title_left); + RARCH_LOG("[XMB] margin title top: %.2f\n", xmb->margins_title_top); + RARCH_LOG("[XMB] margin title bott: %.2f\n", xmb->margins_title_bottom); + RARCH_LOG("[XMB] margin label left: %.2f\n", xmb->margins_label_left); + RARCH_LOG("[XMB] margin label top: %.2f\n", xmb->margins_label_top); + RARCH_LOG("[XMB] margin sett left: %.2f\n", xmb->margins_setting_left); + RARCH_LOG("[XMB] icon spacing hor: %.2f\n", xmb->icon_spacing_horizontal); + RARCH_LOG("[XMB] icon spacing ver: %.2f\n", xmb->icon_spacing_vertical); + RARCH_LOG("[XMB] icon size: %.2f\n", xmb->icon_size); +#endif + + current = (unsigned)selection; + end = (unsigned)menu_entries_get_size(); + + for (i = 0; i < end; i++) + { + float ia = xmb->items_passive_alpha; + float iz = xmb->items_passive_zoom; + xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset( + selection_buf, i); + + if (!node) + continue; + + if (i == current) + { + ia = xmb->items_active_alpha; + iz = xmb->items_active_alpha; + } + + node->alpha = ia; + node->label_alpha = ia; + node->zoom = iz; + node->y = xmb_item_y(xmb, i, current); + } + + if (xmb->depth <= 1) + return; + + current = (unsigned)xmb->selection_ptr_old; + end = (unsigned)file_list_get_size(xmb->selection_buf_old); + + for (i = 0; i < end; i++) + { + float ia = 0; + float iz = xmb->items_passive_zoom; + xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset( + xmb->selection_buf_old, i); + + if (!node) + continue; + + if (i == current) + { + ia = xmb->items_active_alpha; + iz = xmb->items_active_alpha; + } + + node->alpha = ia; + node->label_alpha = 0; + node->zoom = iz; + node->y = xmb_item_y(xmb, i, current); + node->x = xmb->icon_size * 1 * -2; + } } static void xmb_ribbon_set_vertex(float *ribbon_verts, @@ -5106,6 +4600,506 @@ static bool xmb_load_image(void *userdata, void *data, enum menu_image_type type return true; } +static const char *xmb_texture_path(unsigned id) +{ + char *iconpath = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); + char *icon_name = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); + char *icon_fullpath = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); + + iconpath[0] = icon_name[0] = icon_fullpath[0] = '\0'; + + switch (id) + { + case XMB_TEXTURE_MAIN_MENU: +#if defined(HAVE_LAKKA) + icon_name = "lakka.png"; + break; +#else + icon_name = "retroarch.png"; + break; +#endif + case XMB_TEXTURE_SETTINGS: + icon_name = "settings.png"; + break; + case XMB_TEXTURE_HISTORY: + icon_name = "history.png"; + break; + case XMB_TEXTURE_FAVORITES: + icon_name = "favorites.png"; + break; + case XMB_TEXTURE_ADD_FAVORITE: + icon_name = "add-favorite.png"; + break; + case XMB_TEXTURE_MUSICS: + icon_name = "musics.png"; + break; +#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) + case XMB_TEXTURE_MOVIES: + icon_name = "movies.png"; + break; +#endif +#ifdef HAVE_IMAGEVIEWER + case XMB_TEXTURE_IMAGES: + icon_name = "images.png"; + break; +#endif + case XMB_TEXTURE_SETTING: + icon_name = "setting.png"; + break; + case XMB_TEXTURE_SUBSETTING: + icon_name = "subsetting.png"; + break; + case XMB_TEXTURE_ARROW: + icon_name = "arrow.png"; + break; + case XMB_TEXTURE_RUN: + icon_name = "run.png"; + break; + case XMB_TEXTURE_CLOSE: + icon_name = "close.png"; + break; + case XMB_TEXTURE_RESUME: + icon_name = "resume.png"; + break; + case XMB_TEXTURE_CLOCK: + icon_name = "clock.png"; + break; + case XMB_TEXTURE_BATTERY_FULL: + icon_name = "battery-full.png"; + break; + case XMB_TEXTURE_BATTERY_CHARGING: + icon_name = "battery-charging.png"; + break; + case XMB_TEXTURE_POINTER: + icon_name = "pointer.png"; + break; + case XMB_TEXTURE_SAVESTATE: + icon_name = "savestate.png"; + break; + case XMB_TEXTURE_LOADSTATE: + icon_name = "loadstate.png"; + break; + case XMB_TEXTURE_UNDO: + icon_name = "undo.png"; + break; + case XMB_TEXTURE_CORE_INFO: + icon_name = "core-infos.png"; + break; + case XMB_TEXTURE_WIFI: + icon_name = "wifi.png"; + break; + case XMB_TEXTURE_CORE_OPTIONS: + icon_name = "core-options.png"; + break; + case XMB_TEXTURE_INPUT_REMAPPING_OPTIONS: + icon_name = "core-input-remapping-options.png"; + break; + case XMB_TEXTURE_CHEAT_OPTIONS: + icon_name = "core-cheat-options.png"; + break; + case XMB_TEXTURE_DISK_OPTIONS: + icon_name = "core-disk-options.png"; + break; + case XMB_TEXTURE_SHADER_OPTIONS: + icon_name = "core-shader-options.png"; + break; + case XMB_TEXTURE_ACHIEVEMENT_LIST: + icon_name = "achievement-list.png"; + break; + case XMB_TEXTURE_SCREENSHOT: + icon_name = "screenshot.png"; + break; + case XMB_TEXTURE_RELOAD: + icon_name = "reload.png"; + break; + case XMB_TEXTURE_RENAME: + icon_name = "rename.png"; + break; + case XMB_TEXTURE_FILE: + icon_name = "file.png"; + break; + case XMB_TEXTURE_FOLDER: + icon_name = "folder.png"; + break; + case XMB_TEXTURE_ZIP: + icon_name = "zip.png"; + break; + case XMB_TEXTURE_MUSIC: + icon_name = "music.png"; + break; + case XMB_TEXTURE_FAVORITE: + icon_name = "favorites-content.png"; + break; + case XMB_TEXTURE_IMAGE: + icon_name = "image.png"; + break; + case XMB_TEXTURE_MOVIE: + icon_name = "movie.png"; + break; + case XMB_TEXTURE_CORE: + icon_name = "core.png"; + break; + case XMB_TEXTURE_RDB: + icon_name = "database.png"; + break; + case XMB_TEXTURE_CURSOR: + icon_name = "cursor.png"; + break; + case XMB_TEXTURE_SWITCH_ON: + icon_name = "on.png"; + break; + case XMB_TEXTURE_SWITCH_OFF: + icon_name = "off.png"; + break; + case XMB_TEXTURE_ADD: + icon_name = "add.png"; + break; +#ifdef HAVE_NETWORKING + case XMB_TEXTURE_NETPLAY: + icon_name = "netplay.png"; + break; + case XMB_TEXTURE_ROOM: + icon_name = "menu_room.png"; + break; + case XMB_TEXTURE_ROOM_LAN: + icon_name = "menu_room_lan.png"; + break; + case XMB_TEXTURE_ROOM_RELAY: + icon_name = "menu_room_relay.png"; + break; +#endif + case XMB_TEXTURE_KEY: + icon_name = "key.png"; + break; + case XMB_TEXTURE_KEY_HOVER: + icon_name = "key-hover.png"; + break; + case XMB_TEXTURE_DIALOG_SLICE: + icon_name = "dialog-slice.png"; + break; + case XMB_TEXTURE_ACHIEVEMENTS: + icon_name = "menu_achievements.png"; + break; + case XMB_TEXTURE_AUDIO: + icon_name = "menu_audio.png"; + break; + case XMB_TEXTURE_DRIVERS: + icon_name = "menu_drivers.png"; + break; + case XMB_TEXTURE_EXIT: + icon_name = "menu_exit.png"; + break; + case XMB_TEXTURE_FRAMESKIP: + icon_name = "menu_frameskip.png"; + break; + case XMB_TEXTURE_HELP: + icon_name = "menu_help.png"; + break; + case XMB_TEXTURE_INFO: + icon_name = "menu_info.png"; + break; + case XMB_TEXTURE_INPUT_SETTINGS: + icon_name = "Libretro - Pad.png"; + break; + case XMB_TEXTURE_LATENCY: + icon_name = "menu_latency.png"; + break; + case XMB_TEXTURE_NETWORK: + icon_name = "menu_network.png"; + break; + case XMB_TEXTURE_POWER: + icon_name = "menu_power.png"; + break; + case XMB_TEXTURE_RECORD: + icon_name = "menu_record.png"; + break; + case XMB_TEXTURE_SAVING: + icon_name = "menu_saving.png"; + break; + case XMB_TEXTURE_UPDATER: + icon_name = "menu_updater.png"; + break; + case XMB_TEXTURE_VIDEO: + icon_name = "menu_video.png"; + break; + case XMB_TEXTURE_MIXER: + icon_name = "menu_mixer.png"; + break; + case XMB_TEXTURE_LOG: + icon_name = "menu_log.png"; + break; + case XMB_TEXTURE_OSD: + icon_name = "menu_osd.png"; + break; + case XMB_TEXTURE_UI: + icon_name = "menu_ui.png"; + break; + case XMB_TEXTURE_USER: + icon_name = "menu_user.png"; + break; + case XMB_TEXTURE_PRIVACY: + icon_name = "menu_privacy.png"; + break; + case XMB_TEXTURE_PLAYLIST: + icon_name = "menu_playlist.png"; + break; + case XMB_TEXTURE_QUICKMENU: + icon_name = "menu_quickmenu.png"; + break; + case XMB_TEXTURE_REWIND: + icon_name = "menu_rewind.png"; + break; + case XMB_TEXTURE_OVERLAY: + icon_name = "menu_overlay.png"; + break; + case XMB_TEXTURE_OVERRIDE: + icon_name = "menu_override.png"; + break; + case XMB_TEXTURE_NOTIFICATIONS: + icon_name = "menu_notifications.png"; + break; + case XMB_TEXTURE_STREAM: + icon_name = "menu_stream.png"; + break; + case XMB_TEXTURE_SHUTDOWN: + icon_name = "menu_shutdown.png"; + break; + case XMB_TEXTURE_INPUT_DPAD_U: + icon_name = "input_DPAD-U.png"; + break; + case XMB_TEXTURE_INPUT_DPAD_D: + icon_name = "input_DPAD-D.png"; + break; + case XMB_TEXTURE_INPUT_DPAD_L: + icon_name = "input_DPAD-L.png"; + break; + case XMB_TEXTURE_INPUT_DPAD_R: + icon_name = "input_DPAD-R.png"; + break; + case XMB_TEXTURE_INPUT_STCK_U: + icon_name = "input_STCK-U.png"; + break; + case XMB_TEXTURE_INPUT_STCK_D: + icon_name = "input_STCK-D.png"; + break; + case XMB_TEXTURE_INPUT_STCK_L: + icon_name = "input_STCK-L.png"; + break; + case XMB_TEXTURE_INPUT_STCK_R: + icon_name = "input_STCK-R.png"; + break; + case XMB_TEXTURE_INPUT_STCK_P: + icon_name = "input_STCK-P.png"; + break; + case XMB_TEXTURE_INPUT_BTN_U: + icon_name = "input_BTN-U.png"; + break; + case XMB_TEXTURE_INPUT_BTN_D: + icon_name = "input_BTN-D.png"; + break; + case XMB_TEXTURE_INPUT_BTN_L: + icon_name = "input_BTN-L.png"; + break; + case XMB_TEXTURE_INPUT_BTN_R: + icon_name = "input_BTN-R.png"; + break; + case XMB_TEXTURE_INPUT_LB: + icon_name = "input_LB.png"; + break; + case XMB_TEXTURE_INPUT_RB: + icon_name = "input_RB.png"; + break; + case XMB_TEXTURE_INPUT_LT: + icon_name = "input_LT.png"; + break; + case XMB_TEXTURE_INPUT_RT: + icon_name = "input_RT.png"; + break; + case XMB_TEXTURE_INPUT_SELECT: + icon_name = "input_SELECT.png"; + break; + case XMB_TEXTURE_INPUT_START: + icon_name = "input_START.png"; + break; + case XMB_TEXTURE_CHECKMARK: + icon_name = "menu_check.png"; + break; + case XMB_TEXTURE_MENU_ADD: + icon_name = "menu_add.png"; + break; + case XMB_TEXTURE_BRIGHTNESS: + icon_name = "menu_brightness.png"; + break; + case XMB_TEXTURE_PAUSE: + icon_name = "menu_pause.png"; + break; + } + + fill_pathname_application_special(iconpath, + PATH_MAX_LENGTH * sizeof(char), + APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); + + icon_fullpath = iconpath; + strlcat(icon_fullpath, icon_name, PATH_MAX_LENGTH * sizeof(char)); + + if (!filestream_exists(icon_fullpath)) + { + RARCH_WARN("[XMB] Asset missing: %s\n", icon_fullpath); + return NULL; + } + else + return icon_name; + +} + +static void xmb_context_reset_textures( + xmb_handle_t *xmb, const char *iconpath) +{ + unsigned i; + settings_t *settings = config_get_ptr(); + + for (i = 0; i < XMB_TEXTURE_LAST; i++) + { + if (xmb_texture_path(i) == NULL) + { + /* If the icon doesn't exist at least try to return the subsetting icon*/ + if (!(i == XMB_TEXTURE_DIALOG_SLICE || i == XMB_TEXTURE_KEY_HOVER || i == XMB_TEXTURE_KEY_HOVER)) + menu_display_reset_textures_list(xmb_texture_path(XMB_TEXTURE_SUBSETTING), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); + continue; + } + menu_display_reset_textures_list(xmb_texture_path(i), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); + } + + /* Warn only if critical assets are missing, some themes are incomplete */ + if ( + ((xmb_texture_path(XMB_TEXTURE_SUBSETTING) == NULL)) && !(settings->uints.menu_xmb_theme == XMB_ICON_THEME_CUSTOM) + ) + runloop_msg_queue_push(msg_hash_to_str(MSG_MISSING_ASSETS), 1, 256, false); + + menu_display_allocate_white_texture(); + + xmb->main_menu_node.icon = xmb->textures.list[XMB_TEXTURE_MAIN_MENU]; + xmb->main_menu_node.alpha = xmb->categories_active_alpha; + xmb->main_menu_node.zoom = xmb->categories_active_zoom; + + xmb->settings_tab_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS]; + xmb->settings_tab_node.alpha = xmb->categories_active_alpha; + xmb->settings_tab_node.zoom = xmb->categories_active_zoom; + + xmb->history_tab_node.icon = xmb->textures.list[XMB_TEXTURE_HISTORY]; + xmb->history_tab_node.alpha = xmb->categories_active_alpha; + xmb->history_tab_node.zoom = xmb->categories_active_zoom; + + xmb->favorites_tab_node.icon = xmb->textures.list[XMB_TEXTURE_FAVORITES]; + xmb->favorites_tab_node.alpha = xmb->categories_active_alpha; + xmb->favorites_tab_node.zoom = xmb->categories_active_zoom; + + xmb->music_tab_node.icon = xmb->textures.list[XMB_TEXTURE_MUSICS]; + xmb->music_tab_node.alpha = xmb->categories_active_alpha; + xmb->music_tab_node.zoom = xmb->categories_active_zoom; + +#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) + xmb->video_tab_node.icon = xmb->textures.list[XMB_TEXTURE_MOVIES]; + xmb->video_tab_node.alpha = xmb->categories_active_alpha; + xmb->video_tab_node.zoom = xmb->categories_active_zoom; +#endif + +#ifdef HAVE_IMAGEVIEWER + xmb->images_tab_node.icon = xmb->textures.list[XMB_TEXTURE_IMAGES]; + xmb->images_tab_node.alpha = xmb->categories_active_alpha; + xmb->images_tab_node.zoom = xmb->categories_active_zoom; +#endif + + xmb->add_tab_node.icon = xmb->textures.list[XMB_TEXTURE_ADD]; + xmb->add_tab_node.alpha = xmb->categories_active_alpha; + xmb->add_tab_node.zoom = xmb->categories_active_zoom; + +#ifdef HAVE_NETWORKING + xmb->netplay_tab_node.icon = xmb->textures.list[XMB_TEXTURE_NETPLAY]; + xmb->netplay_tab_node.alpha = xmb->categories_active_alpha; + xmb->netplay_tab_node.zoom = xmb->categories_active_zoom; +#endif + +} + +static void xmb_context_reset_background(const char *iconpath) +{ + char *path = NULL; + settings_t *settings = config_get_ptr(); + const char *path_menu_wp = settings->paths.path_menu_wallpaper; + + if (!string_is_empty(path_menu_wp)) + path = strdup(path_menu_wp); + else if (!string_is_empty(iconpath)) + { + path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + path[0] = '\0'; + + fill_pathname_join(path, iconpath, "bg.png", + PATH_MAX_LENGTH * sizeof(char)); + } + + if (filestream_exists(path)) + task_push_image_load(path, + menu_display_handle_wallpaper_upload, NULL); + + if (path) + free(path); +} + +static void xmb_context_reset(void *data, bool is_threaded) +{ + xmb_handle_t *xmb = (xmb_handle_t*)data; + + if (xmb) + { + char bg_file_path[PATH_MAX_LENGTH] = {0}; + char *iconpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + iconpath[0] = '\0'; + + fill_pathname_application_special(bg_file_path, + sizeof(bg_file_path), APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_BG); + + if (!string_is_empty(bg_file_path)) + { + if (!string_is_empty(xmb->bg_file_path)) + free(xmb->bg_file_path); + xmb->bg_file_path = strdup(bg_file_path); + } + + fill_pathname_application_special(iconpath, + PATH_MAX_LENGTH * sizeof(char), + APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); + + xmb_layout(xmb); + xmb->font = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, + xmb->font_size, + is_threaded); + xmb->font2 = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, + xmb->font2_size, + is_threaded); + xmb_context_reset_textures(xmb, iconpath); + xmb_context_reset_background(iconpath); + xmb_context_reset_horizontal_list(xmb); + + if (!string_is_equal(xmb_thumbnails_ident('R'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + xmb_update_thumbnail_path(xmb, 0, 'R'); + xmb_update_thumbnail_image(xmb); + } + if (!string_is_equal(xmb_thumbnails_ident('L'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + xmb_update_thumbnail_path(xmb, 0, 'L'); + xmb_update_thumbnail_image(xmb); + } + xmb_update_savestate_thumbnail_image(xmb); + + free(iconpath); + } +} + static void xmb_navigation_clear(void *data, bool pending_push) { xmb_handle_t *xmb = (xmb_handle_t*)data; From 0486979bc9fb87ba72c734e228fead018e3fb72f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 25 Nov 2018 03:01:41 +0100 Subject: [PATCH 040/153] Should now work across core context resets --- menu/drivers/xmb.c | 1455 ++++++++++++++++++++++---------------------- 1 file changed, 732 insertions(+), 723 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 0f803d5c00..3a78f4f1d0 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -267,6 +267,7 @@ typedef struct xmb_handle float shadow_offset; float font_size; float font2_size; + float previous_scale_factor; float margins_screen_left; float margins_screen_top; @@ -3318,6 +3319,686 @@ static void xmb_draw_dark_layer( menu_display_blend_end(video_info); } +static const char *xmb_texture_path(unsigned id) +{ + char *iconpath = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); + char *icon_name = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); + char *icon_fullpath = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); + + iconpath[0] = icon_name[0] = icon_fullpath[0] = '\0'; + + switch (id) + { + case XMB_TEXTURE_MAIN_MENU: +#if defined(HAVE_LAKKA) + icon_name = "lakka.png"; + break; +#else + icon_name = "retroarch.png"; + break; +#endif + case XMB_TEXTURE_SETTINGS: + icon_name = "settings.png"; + break; + case XMB_TEXTURE_HISTORY: + icon_name = "history.png"; + break; + case XMB_TEXTURE_FAVORITES: + icon_name = "favorites.png"; + break; + case XMB_TEXTURE_ADD_FAVORITE: + icon_name = "add-favorite.png"; + break; + case XMB_TEXTURE_MUSICS: + icon_name = "musics.png"; + break; +#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) + case XMB_TEXTURE_MOVIES: + icon_name = "movies.png"; + break; +#endif +#ifdef HAVE_IMAGEVIEWER + case XMB_TEXTURE_IMAGES: + icon_name = "images.png"; + break; +#endif + case XMB_TEXTURE_SETTING: + icon_name = "setting.png"; + break; + case XMB_TEXTURE_SUBSETTING: + icon_name = "subsetting.png"; + break; + case XMB_TEXTURE_ARROW: + icon_name = "arrow.png"; + break; + case XMB_TEXTURE_RUN: + icon_name = "run.png"; + break; + case XMB_TEXTURE_CLOSE: + icon_name = "close.png"; + break; + case XMB_TEXTURE_RESUME: + icon_name = "resume.png"; + break; + case XMB_TEXTURE_CLOCK: + icon_name = "clock.png"; + break; + case XMB_TEXTURE_BATTERY_FULL: + icon_name = "battery-full.png"; + break; + case XMB_TEXTURE_BATTERY_CHARGING: + icon_name = "battery-charging.png"; + break; + case XMB_TEXTURE_POINTER: + icon_name = "pointer.png"; + break; + case XMB_TEXTURE_SAVESTATE: + icon_name = "savestate.png"; + break; + case XMB_TEXTURE_LOADSTATE: + icon_name = "loadstate.png"; + break; + case XMB_TEXTURE_UNDO: + icon_name = "undo.png"; + break; + case XMB_TEXTURE_CORE_INFO: + icon_name = "core-infos.png"; + break; + case XMB_TEXTURE_WIFI: + icon_name = "wifi.png"; + break; + case XMB_TEXTURE_CORE_OPTIONS: + icon_name = "core-options.png"; + break; + case XMB_TEXTURE_INPUT_REMAPPING_OPTIONS: + icon_name = "core-input-remapping-options.png"; + break; + case XMB_TEXTURE_CHEAT_OPTIONS: + icon_name = "core-cheat-options.png"; + break; + case XMB_TEXTURE_DISK_OPTIONS: + icon_name = "core-disk-options.png"; + break; + case XMB_TEXTURE_SHADER_OPTIONS: + icon_name = "core-shader-options.png"; + break; + case XMB_TEXTURE_ACHIEVEMENT_LIST: + icon_name = "achievement-list.png"; + break; + case XMB_TEXTURE_SCREENSHOT: + icon_name = "screenshot.png"; + break; + case XMB_TEXTURE_RELOAD: + icon_name = "reload.png"; + break; + case XMB_TEXTURE_RENAME: + icon_name = "rename.png"; + break; + case XMB_TEXTURE_FILE: + icon_name = "file.png"; + break; + case XMB_TEXTURE_FOLDER: + icon_name = "folder.png"; + break; + case XMB_TEXTURE_ZIP: + icon_name = "zip.png"; + break; + case XMB_TEXTURE_MUSIC: + icon_name = "music.png"; + break; + case XMB_TEXTURE_FAVORITE: + icon_name = "favorites-content.png"; + break; + case XMB_TEXTURE_IMAGE: + icon_name = "image.png"; + break; + case XMB_TEXTURE_MOVIE: + icon_name = "movie.png"; + break; + case XMB_TEXTURE_CORE: + icon_name = "core.png"; + break; + case XMB_TEXTURE_RDB: + icon_name = "database.png"; + break; + case XMB_TEXTURE_CURSOR: + icon_name = "cursor.png"; + break; + case XMB_TEXTURE_SWITCH_ON: + icon_name = "on.png"; + break; + case XMB_TEXTURE_SWITCH_OFF: + icon_name = "off.png"; + break; + case XMB_TEXTURE_ADD: + icon_name = "add.png"; + break; +#ifdef HAVE_NETWORKING + case XMB_TEXTURE_NETPLAY: + icon_name = "netplay.png"; + break; + case XMB_TEXTURE_ROOM: + icon_name = "menu_room.png"; + break; + case XMB_TEXTURE_ROOM_LAN: + icon_name = "menu_room_lan.png"; + break; + case XMB_TEXTURE_ROOM_RELAY: + icon_name = "menu_room_relay.png"; + break; +#endif + case XMB_TEXTURE_KEY: + icon_name = "key.png"; + break; + case XMB_TEXTURE_KEY_HOVER: + icon_name = "key-hover.png"; + break; + case XMB_TEXTURE_DIALOG_SLICE: + icon_name = "dialog-slice.png"; + break; + case XMB_TEXTURE_ACHIEVEMENTS: + icon_name = "menu_achievements.png"; + break; + case XMB_TEXTURE_AUDIO: + icon_name = "menu_audio.png"; + break; + case XMB_TEXTURE_DRIVERS: + icon_name = "menu_drivers.png"; + break; + case XMB_TEXTURE_EXIT: + icon_name = "menu_exit.png"; + break; + case XMB_TEXTURE_FRAMESKIP: + icon_name = "menu_frameskip.png"; + break; + case XMB_TEXTURE_HELP: + icon_name = "menu_help.png"; + break; + case XMB_TEXTURE_INFO: + icon_name = "menu_info.png"; + break; + case XMB_TEXTURE_INPUT_SETTINGS: + icon_name = "Libretro - Pad.png"; + break; + case XMB_TEXTURE_LATENCY: + icon_name = "menu_latency.png"; + break; + case XMB_TEXTURE_NETWORK: + icon_name = "menu_network.png"; + break; + case XMB_TEXTURE_POWER: + icon_name = "menu_power.png"; + break; + case XMB_TEXTURE_RECORD: + icon_name = "menu_record.png"; + break; + case XMB_TEXTURE_SAVING: + icon_name = "menu_saving.png"; + break; + case XMB_TEXTURE_UPDATER: + icon_name = "menu_updater.png"; + break; + case XMB_TEXTURE_VIDEO: + icon_name = "menu_video.png"; + break; + case XMB_TEXTURE_MIXER: + icon_name = "menu_mixer.png"; + break; + case XMB_TEXTURE_LOG: + icon_name = "menu_log.png"; + break; + case XMB_TEXTURE_OSD: + icon_name = "menu_osd.png"; + break; + case XMB_TEXTURE_UI: + icon_name = "menu_ui.png"; + break; + case XMB_TEXTURE_USER: + icon_name = "menu_user.png"; + break; + case XMB_TEXTURE_PRIVACY: + icon_name = "menu_privacy.png"; + break; + case XMB_TEXTURE_PLAYLIST: + icon_name = "menu_playlist.png"; + break; + case XMB_TEXTURE_QUICKMENU: + icon_name = "menu_quickmenu.png"; + break; + case XMB_TEXTURE_REWIND: + icon_name = "menu_rewind.png"; + break; + case XMB_TEXTURE_OVERLAY: + icon_name = "menu_overlay.png"; + break; + case XMB_TEXTURE_OVERRIDE: + icon_name = "menu_override.png"; + break; + case XMB_TEXTURE_NOTIFICATIONS: + icon_name = "menu_notifications.png"; + break; + case XMB_TEXTURE_STREAM: + icon_name = "menu_stream.png"; + break; + case XMB_TEXTURE_SHUTDOWN: + icon_name = "menu_shutdown.png"; + break; + case XMB_TEXTURE_INPUT_DPAD_U: + icon_name = "input_DPAD-U.png"; + break; + case XMB_TEXTURE_INPUT_DPAD_D: + icon_name = "input_DPAD-D.png"; + break; + case XMB_TEXTURE_INPUT_DPAD_L: + icon_name = "input_DPAD-L.png"; + break; + case XMB_TEXTURE_INPUT_DPAD_R: + icon_name = "input_DPAD-R.png"; + break; + case XMB_TEXTURE_INPUT_STCK_U: + icon_name = "input_STCK-U.png"; + break; + case XMB_TEXTURE_INPUT_STCK_D: + icon_name = "input_STCK-D.png"; + break; + case XMB_TEXTURE_INPUT_STCK_L: + icon_name = "input_STCK-L.png"; + break; + case XMB_TEXTURE_INPUT_STCK_R: + icon_name = "input_STCK-R.png"; + break; + case XMB_TEXTURE_INPUT_STCK_P: + icon_name = "input_STCK-P.png"; + break; + case XMB_TEXTURE_INPUT_BTN_U: + icon_name = "input_BTN-U.png"; + break; + case XMB_TEXTURE_INPUT_BTN_D: + icon_name = "input_BTN-D.png"; + break; + case XMB_TEXTURE_INPUT_BTN_L: + icon_name = "input_BTN-L.png"; + break; + case XMB_TEXTURE_INPUT_BTN_R: + icon_name = "input_BTN-R.png"; + break; + case XMB_TEXTURE_INPUT_LB: + icon_name = "input_LB.png"; + break; + case XMB_TEXTURE_INPUT_RB: + icon_name = "input_RB.png"; + break; + case XMB_TEXTURE_INPUT_LT: + icon_name = "input_LT.png"; + break; + case XMB_TEXTURE_INPUT_RT: + icon_name = "input_RT.png"; + break; + case XMB_TEXTURE_INPUT_SELECT: + icon_name = "input_SELECT.png"; + break; + case XMB_TEXTURE_INPUT_START: + icon_name = "input_START.png"; + break; + case XMB_TEXTURE_CHECKMARK: + icon_name = "menu_check.png"; + break; + case XMB_TEXTURE_MENU_ADD: + icon_name = "menu_add.png"; + break; + case XMB_TEXTURE_BRIGHTNESS: + icon_name = "menu_brightness.png"; + break; + case XMB_TEXTURE_PAUSE: + icon_name = "menu_pause.png"; + break; + } + + fill_pathname_application_special(iconpath, + PATH_MAX_LENGTH * sizeof(char), + APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); + + icon_fullpath = iconpath; + strlcat(icon_fullpath, icon_name, PATH_MAX_LENGTH * sizeof(char)); + + if (!filestream_exists(icon_fullpath)) + { + RARCH_WARN("[XMB] Asset missing: %s\n", icon_fullpath); + return NULL; + } + else + return icon_name; + +} + + +static void xmb_context_reset_textures( + xmb_handle_t *xmb, const char *iconpath) +{ + unsigned i; + settings_t *settings = config_get_ptr(); + + for (i = 0; i < XMB_TEXTURE_LAST; i++) + { + if (xmb_texture_path(i) == NULL) + { + /* If the icon doesn't exist at least try to return the subsetting icon*/ + if (!(i == XMB_TEXTURE_DIALOG_SLICE || i == XMB_TEXTURE_KEY_HOVER || i == XMB_TEXTURE_KEY_HOVER)) + menu_display_reset_textures_list(xmb_texture_path(XMB_TEXTURE_SUBSETTING), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); + continue; + } + menu_display_reset_textures_list(xmb_texture_path(i), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); + } + + /* Warn only if critical assets are missing, some themes are incomplete */ + if ( + ((xmb_texture_path(XMB_TEXTURE_SUBSETTING) == NULL)) && !(settings->uints.menu_xmb_theme == XMB_ICON_THEME_CUSTOM) + ) + runloop_msg_queue_push(msg_hash_to_str(MSG_MISSING_ASSETS), 1, 256, false); + + menu_display_allocate_white_texture(); + + xmb->main_menu_node.icon = xmb->textures.list[XMB_TEXTURE_MAIN_MENU]; + xmb->main_menu_node.alpha = xmb->categories_active_alpha; + xmb->main_menu_node.zoom = xmb->categories_active_zoom; + + xmb->settings_tab_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS]; + xmb->settings_tab_node.alpha = xmb->categories_active_alpha; + xmb->settings_tab_node.zoom = xmb->categories_active_zoom; + + xmb->history_tab_node.icon = xmb->textures.list[XMB_TEXTURE_HISTORY]; + xmb->history_tab_node.alpha = xmb->categories_active_alpha; + xmb->history_tab_node.zoom = xmb->categories_active_zoom; + + xmb->favorites_tab_node.icon = xmb->textures.list[XMB_TEXTURE_FAVORITES]; + xmb->favorites_tab_node.alpha = xmb->categories_active_alpha; + xmb->favorites_tab_node.zoom = xmb->categories_active_zoom; + + xmb->music_tab_node.icon = xmb->textures.list[XMB_TEXTURE_MUSICS]; + xmb->music_tab_node.alpha = xmb->categories_active_alpha; + xmb->music_tab_node.zoom = xmb->categories_active_zoom; + +#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) + xmb->video_tab_node.icon = xmb->textures.list[XMB_TEXTURE_MOVIES]; + xmb->video_tab_node.alpha = xmb->categories_active_alpha; + xmb->video_tab_node.zoom = xmb->categories_active_zoom; +#endif + +#ifdef HAVE_IMAGEVIEWER + xmb->images_tab_node.icon = xmb->textures.list[XMB_TEXTURE_IMAGES]; + xmb->images_tab_node.alpha = xmb->categories_active_alpha; + xmb->images_tab_node.zoom = xmb->categories_active_zoom; +#endif + + xmb->add_tab_node.icon = xmb->textures.list[XMB_TEXTURE_ADD]; + xmb->add_tab_node.alpha = xmb->categories_active_alpha; + xmb->add_tab_node.zoom = xmb->categories_active_zoom; + +#ifdef HAVE_NETWORKING + xmb->netplay_tab_node.icon = xmb->textures.list[XMB_TEXTURE_NETPLAY]; + xmb->netplay_tab_node.alpha = xmb->categories_active_alpha; + xmb->netplay_tab_node.zoom = xmb->categories_active_zoom; +#endif + +} + +static void xmb_context_reset_background(const char *iconpath) +{ + char *path = NULL; + settings_t *settings = config_get_ptr(); + const char *path_menu_wp = settings->paths.path_menu_wallpaper; + + if (!string_is_empty(path_menu_wp)) + path = strdup(path_menu_wp); + else if (!string_is_empty(iconpath)) + { + path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + path[0] = '\0'; + + fill_pathname_join(path, iconpath, "bg.png", + PATH_MAX_LENGTH * sizeof(char)); + } + + if (filestream_exists(path)) + task_push_image_load(path, + menu_display_handle_wallpaper_upload, NULL); + + if (path) + free(path); +} + +static void xmb_context_reset(void *data, bool is_threaded) +{ + xmb_handle_t *xmb = (xmb_handle_t*)data; + + xmb->previous_scale_factor = 0.0; +} + +static void xmb_layout_ps3(xmb_handle_t *xmb, int width) +{ + unsigned new_font_size, new_header_height; + settings_t *settings = config_get_ptr(); + + float scale_factor = + (settings->uints.menu_xmb_scale_factor * width) / (1920.0 * 100); + + xmb->above_subitem_offset = 1.5; + xmb->above_item_offset = -1.0; + xmb->active_item_factor = 3.0; + xmb->under_item_offset = 5.0; + + xmb->categories_active_zoom = 1.0; + xmb->categories_passive_zoom = 0.5; + xmb->items_active_zoom = 1.0; + xmb->items_passive_zoom = 0.5; + + xmb->categories_active_alpha = 1.0; + xmb->categories_passive_alpha = 0.85; + xmb->items_active_alpha = 1.0; + xmb->items_passive_alpha = 0.85; + + xmb->shadow_offset = 2.0; + + new_font_size = 32.0 * scale_factor; + xmb->font2_size = 24.0 * scale_factor; + new_header_height = 128.0 * scale_factor; + + + xmb->thumbnail_width = 1024.0 * scale_factor; + xmb->left_thumbnail_width = 1024.0 * scale_factor; + xmb->savestate_thumbnail_width= 460.0 * scale_factor; + xmb->cursor_size = 64.0 * scale_factor; + + xmb->icon_spacing_horizontal = 200.0 * scale_factor; + xmb->icon_spacing_vertical = 64.0 * scale_factor; + + xmb->margins_screen_top = (256+32) * scale_factor; + xmb->margins_screen_left = 336.0 * scale_factor; + + xmb->margins_title_left = 60 * scale_factor; + xmb->margins_title_top = 60 * scale_factor + new_font_size / 3; + xmb->margins_title_bottom = 60 * scale_factor - new_font_size / 3; + + xmb->margins_label_left = 85.0 * scale_factor; + xmb->margins_label_top = new_font_size / 3.0; + + xmb->margins_setting_left = 600.0 * scale_factor * scale_mod[6]; + xmb->margins_dialog = 48 * scale_factor; + + xmb->margins_slice = 16; + + xmb->icon_size = 128.0 * scale_factor; + xmb->font_size = new_font_size; + + menu_display_set_header_height(new_header_height); +} + +static void xmb_layout_psp(xmb_handle_t *xmb, int width) +{ + unsigned new_font_size, new_header_height; + settings_t *settings = config_get_ptr(); + float scale_factor = + ((settings->uints.menu_xmb_scale_factor * width) / (1920.0 * 100)) * 1.5; +#ifdef _3DS + scale_factor = + settings->uints.menu_xmb_scale_factor / 400.0; +#endif + + xmb->above_subitem_offset = 1.5; + xmb->above_item_offset = -1.0; + xmb->active_item_factor = 2.0; + xmb->under_item_offset = 3.0; + + xmb->categories_active_zoom = 1.0; + xmb->categories_passive_zoom = 1.0; + xmb->items_active_zoom = 1.0; + xmb->items_passive_zoom = 1.0; + + xmb->categories_active_alpha = 1.0; + xmb->categories_passive_alpha = 0.85; + xmb->items_active_alpha = 1.0; + xmb->items_passive_alpha = 0.85; + + xmb->shadow_offset = 1.0; + + new_font_size = 32.0 * scale_factor; + xmb->font2_size = 24.0 * scale_factor; + new_header_height = 128.0 * scale_factor; + xmb->margins_screen_top = (256+32) * scale_factor; + + xmb->thumbnail_width = 460.0 * scale_factor; + xmb->left_thumbnail_width = 400.0 * scale_factor; + xmb->savestate_thumbnail_width= 460.0 * scale_factor; + xmb->cursor_size = 64.0; + + xmb->icon_spacing_horizontal = 250.0 * scale_factor; + xmb->icon_spacing_vertical = 108.0 * scale_factor; + + xmb->margins_screen_left = 136.0 * scale_factor; + xmb->margins_title_left = 60 * scale_factor; + xmb->margins_title_top = 60 * scale_factor + new_font_size / 3; + xmb->margins_title_bottom = 60 * scale_factor - new_font_size / 3; + xmb->margins_label_left = 85.0 * scale_factor; + xmb->margins_label_top = new_font_size / 3.0; + xmb->margins_setting_left = 600.0 * scale_factor; + xmb->margins_dialog = 48 * scale_factor; + xmb->margins_slice = 16; + xmb->icon_size = 128.0 * scale_factor; + xmb->font_size = new_font_size; + + menu_display_set_header_height(new_header_height); +} + +static void xmb_layout(xmb_handle_t *xmb) +{ + unsigned width, height, i, current, end; + settings_t *settings = config_get_ptr(); + file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); + size_t selection = menu_navigation_get_selection(); + + video_driver_get_size(&width, &height); + + switch (settings->uints.menu_xmb_layout) + { + /* Automatic */ + case 0: + { + xmb->use_ps3_layout = false; + xmb->use_ps3_layout = width > 320 && height > 240; + + /* Mimic the layout of the PSP instead of the PS3 on tiny screens */ + if (xmb->use_ps3_layout) + xmb_layout_ps3(xmb, width); + else + xmb_layout_psp(xmb, width); + } + break; + /* PS3 */ + case 1: + { + xmb->use_ps3_layout = true; + xmb_layout_ps3(xmb, width); + } + break; + /* PSP */ + case 2: + { + xmb->use_ps3_layout = false; + xmb_layout_psp(xmb, width); + } + break; + } + +#ifdef XMB_DEBUG + RARCH_LOG("[XMB] margin screen left: %.2f\n", xmb->margins_screen_left); + RARCH_LOG("[XMB] margin screen top: %.2f\n", xmb->margins_screen_top); + RARCH_LOG("[XMB] margin title left: %.2f\n", xmb->margins_title_left); + RARCH_LOG("[XMB] margin title top: %.2f\n", xmb->margins_title_top); + RARCH_LOG("[XMB] margin title bott: %.2f\n", xmb->margins_title_bottom); + RARCH_LOG("[XMB] margin label left: %.2f\n", xmb->margins_label_left); + RARCH_LOG("[XMB] margin label top: %.2f\n", xmb->margins_label_top); + RARCH_LOG("[XMB] margin sett left: %.2f\n", xmb->margins_setting_left); + RARCH_LOG("[XMB] icon spacing hor: %.2f\n", xmb->icon_spacing_horizontal); + RARCH_LOG("[XMB] icon spacing ver: %.2f\n", xmb->icon_spacing_vertical); + RARCH_LOG("[XMB] icon size: %.2f\n", xmb->icon_size); +#endif + + current = (unsigned)selection; + end = (unsigned)menu_entries_get_size(); + + for (i = 0; i < end; i++) + { + float ia = xmb->items_passive_alpha; + float iz = xmb->items_passive_zoom; + xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset( + selection_buf, i); + + if (!node) + continue; + + if (i == current) + { + ia = xmb->items_active_alpha; + iz = xmb->items_active_alpha; + } + + node->alpha = ia; + node->label_alpha = ia; + node->zoom = iz; + node->y = xmb_item_y(xmb, i, current); + } + + if (xmb->depth <= 1) + return; + + current = (unsigned)xmb->selection_ptr_old; + end = (unsigned)file_list_get_size(xmb->selection_buf_old); + + for (i = 0; i < end; i++) + { + float ia = 0; + float iz = xmb->items_passive_zoom; + xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset( + xmb->selection_buf_old, i); + + if (!node) + continue; + + if (i == current) + { + ia = xmb->items_active_alpha; + iz = xmb->items_active_alpha; + } + + node->alpha = ia; + node->label_alpha = 0; + node->zoom = iz; + node->y = xmb_item_y(xmb, i, current); + node->x = xmb->icon_size * 1 * -2; + } +} + + static void xmb_frame(void *data, video_frame_info_t *video_info) { math_matrix_4x4 mymat; @@ -3347,6 +4028,56 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) scale_factor = (settings->uints.menu_xmb_scale_factor * (float)width) / (1920.0 * 100); pseudo_font_length = xmb->icon_spacing_horizontal * 4 - xmb->icon_size / 4; + if (scale_factor != xmb->previous_scale_factor) + { + char bg_file_path[PATH_MAX_LENGTH] = {0}; + char *iconpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + iconpath[0] = '\0'; + + fill_pathname_application_special(bg_file_path, + sizeof(bg_file_path), APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_BG); + + if (!string_is_empty(bg_file_path)) + { + if (!string_is_empty(xmb->bg_file_path)) + free(xmb->bg_file_path); + xmb->bg_file_path = strdup(bg_file_path); + } + + fill_pathname_application_special(iconpath, + PATH_MAX_LENGTH * sizeof(char), + APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); + + menu_display_font_free(xmb->font); + menu_display_font_free(xmb->font2); + xmb_layout(xmb); + xmb->font = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, + xmb->font_size, + video_driver_is_threaded()); + xmb->font2 = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, + xmb->font2_size, + video_driver_is_threaded()); + xmb_context_reset_textures(xmb, iconpath); + xmb_context_reset_background(iconpath); + xmb_context_reset_horizontal_list(xmb); + + if (!string_is_equal(xmb_thumbnails_ident('R'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + xmb_update_thumbnail_path(xmb, 0, 'R'); + xmb_update_thumbnail_image(xmb); + } + if (!string_is_equal(xmb_thumbnails_ident('L'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + xmb_update_thumbnail_path(xmb, 0, 'L'); + xmb_update_thumbnail_image(xmb); + } + xmb_update_savestate_thumbnail_image(xmb); + + free(iconpath); + } + xmb->frame_count++; msg[0] = '\0'; @@ -4096,230 +4827,8 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) } menu_display_unset_viewport(video_info->width, video_info->height); -} -static void xmb_layout_ps3(xmb_handle_t *xmb, int width) -{ - unsigned new_font_size, new_header_height; - settings_t *settings = config_get_ptr(); - - float scale_factor = - (settings->uints.menu_xmb_scale_factor * width) / (1920.0 * 100); - - xmb->above_subitem_offset = 1.5; - xmb->above_item_offset = -1.0; - xmb->active_item_factor = 3.0; - xmb->under_item_offset = 5.0; - - xmb->categories_active_zoom = 1.0; - xmb->categories_passive_zoom = 0.5; - xmb->items_active_zoom = 1.0; - xmb->items_passive_zoom = 0.5; - - xmb->categories_active_alpha = 1.0; - xmb->categories_passive_alpha = 0.85; - xmb->items_active_alpha = 1.0; - xmb->items_passive_alpha = 0.85; - - xmb->shadow_offset = 2.0; - - new_font_size = 32.0 * scale_factor; - xmb->font2_size = 24.0 * scale_factor; - new_header_height = 128.0 * scale_factor; - - - xmb->thumbnail_width = 1024.0 * scale_factor; - xmb->left_thumbnail_width = 1024.0 * scale_factor; - xmb->savestate_thumbnail_width= 460.0 * scale_factor; - xmb->cursor_size = 64.0 * scale_factor; - - xmb->icon_spacing_horizontal = 200.0 * scale_factor; - xmb->icon_spacing_vertical = 64.0 * scale_factor; - - xmb->margins_screen_top = (256+32) * scale_factor; - xmb->margins_screen_left = 336.0 * scale_factor; - - xmb->margins_title_left = 60 * scale_factor; - xmb->margins_title_top = 60 * scale_factor + new_font_size / 3; - xmb->margins_title_bottom = 60 * scale_factor - new_font_size / 3; - - xmb->margins_label_left = 85.0 * scale_factor; - xmb->margins_label_top = new_font_size / 3.0; - - xmb->margins_setting_left = 600.0 * scale_factor * scale_mod[6]; - xmb->margins_dialog = 48 * scale_factor; - - xmb->margins_slice = 16; - - xmb->icon_size = 128.0 * scale_factor; - xmb->font_size = new_font_size; - - menu_display_set_header_height(new_header_height); -} - -static void xmb_layout_psp(xmb_handle_t *xmb, int width) -{ - unsigned new_font_size, new_header_height; - settings_t *settings = config_get_ptr(); - float scale_factor = - ((settings->uints.menu_xmb_scale_factor * width) / (1920.0 * 100)) * 1.5; -#ifdef _3DS - scale_factor = - settings->uints.menu_xmb_scale_factor / 400.0; -#endif - - xmb->above_subitem_offset = 1.5; - xmb->above_item_offset = -1.0; - xmb->active_item_factor = 2.0; - xmb->under_item_offset = 3.0; - - xmb->categories_active_zoom = 1.0; - xmb->categories_passive_zoom = 1.0; - xmb->items_active_zoom = 1.0; - xmb->items_passive_zoom = 1.0; - - xmb->categories_active_alpha = 1.0; - xmb->categories_passive_alpha = 0.85; - xmb->items_active_alpha = 1.0; - xmb->items_passive_alpha = 0.85; - - xmb->shadow_offset = 1.0; - - new_font_size = 32.0 * scale_factor; - xmb->font2_size = 24.0 * scale_factor; - new_header_height = 128.0 * scale_factor; - xmb->margins_screen_top = (256+32) * scale_factor; - - xmb->thumbnail_width = 460.0 * scale_factor; - xmb->left_thumbnail_width = 400.0 * scale_factor; - xmb->savestate_thumbnail_width= 460.0 * scale_factor; - xmb->cursor_size = 64.0; - - xmb->icon_spacing_horizontal = 250.0 * scale_factor; - xmb->icon_spacing_vertical = 108.0 * scale_factor; - - xmb->margins_screen_left = 136.0 * scale_factor; - xmb->margins_title_left = 60 * scale_factor; - xmb->margins_title_top = 60 * scale_factor + new_font_size / 3; - xmb->margins_title_bottom = 60 * scale_factor - new_font_size / 3; - xmb->margins_label_left = 85.0 * scale_factor; - xmb->margins_label_top = new_font_size / 3.0; - xmb->margins_setting_left = 600.0 * scale_factor; - xmb->margins_dialog = 48 * scale_factor; - xmb->margins_slice = 16; - xmb->icon_size = 128.0 * scale_factor; - xmb->font_size = new_font_size; - - menu_display_set_header_height(new_header_height); -} - -static void xmb_layout(xmb_handle_t *xmb) -{ - unsigned width, height, i, current, end; - settings_t *settings = config_get_ptr(); - file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); - size_t selection = menu_navigation_get_selection(); - - video_driver_get_size(&width, &height); - - switch (settings->uints.menu_xmb_layout) - { - /* Automatic */ - case 0: - { - xmb->use_ps3_layout = false; - xmb->use_ps3_layout = width > 320 && height > 240; - - /* Mimic the layout of the PSP instead of the PS3 on tiny screens */ - if (xmb->use_ps3_layout) - xmb_layout_ps3(xmb, width); - else - xmb_layout_psp(xmb, width); - } - break; - /* PS3 */ - case 1: - { - xmb->use_ps3_layout = true; - xmb_layout_ps3(xmb, width); - } - break; - /* PSP */ - case 2: - { - xmb->use_ps3_layout = false; - xmb_layout_psp(xmb, width); - } - break; - } - -#ifdef XMB_DEBUG - RARCH_LOG("[XMB] margin screen left: %.2f\n", xmb->margins_screen_left); - RARCH_LOG("[XMB] margin screen top: %.2f\n", xmb->margins_screen_top); - RARCH_LOG("[XMB] margin title left: %.2f\n", xmb->margins_title_left); - RARCH_LOG("[XMB] margin title top: %.2f\n", xmb->margins_title_top); - RARCH_LOG("[XMB] margin title bott: %.2f\n", xmb->margins_title_bottom); - RARCH_LOG("[XMB] margin label left: %.2f\n", xmb->margins_label_left); - RARCH_LOG("[XMB] margin label top: %.2f\n", xmb->margins_label_top); - RARCH_LOG("[XMB] margin sett left: %.2f\n", xmb->margins_setting_left); - RARCH_LOG("[XMB] icon spacing hor: %.2f\n", xmb->icon_spacing_horizontal); - RARCH_LOG("[XMB] icon spacing ver: %.2f\n", xmb->icon_spacing_vertical); - RARCH_LOG("[XMB] icon size: %.2f\n", xmb->icon_size); -#endif - - current = (unsigned)selection; - end = (unsigned)menu_entries_get_size(); - - for (i = 0; i < end; i++) - { - float ia = xmb->items_passive_alpha; - float iz = xmb->items_passive_zoom; - xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset( - selection_buf, i); - - if (!node) - continue; - - if (i == current) - { - ia = xmb->items_active_alpha; - iz = xmb->items_active_alpha; - } - - node->alpha = ia; - node->label_alpha = ia; - node->zoom = iz; - node->y = xmb_item_y(xmb, i, current); - } - - if (xmb->depth <= 1) - return; - - current = (unsigned)xmb->selection_ptr_old; - end = (unsigned)file_list_get_size(xmb->selection_buf_old); - - for (i = 0; i < end; i++) - { - float ia = 0; - float iz = xmb->items_passive_zoom; - xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset( - xmb->selection_buf_old, i); - - if (!node) - continue; - - if (i == current) - { - ia = xmb->items_active_alpha; - iz = xmb->items_active_alpha; - } - - node->alpha = ia; - node->label_alpha = 0; - node->zoom = iz; - node->y = xmb_item_y(xmb, i, current); - node->x = xmb->icon_size * 1 * -2; - } + xmb->previous_scale_factor = scale_factor; } static void xmb_ribbon_set_vertex(float *ribbon_verts, @@ -4600,506 +5109,6 @@ static bool xmb_load_image(void *userdata, void *data, enum menu_image_type type return true; } -static const char *xmb_texture_path(unsigned id) -{ - char *iconpath = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); - char *icon_name = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); - char *icon_fullpath = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); - - iconpath[0] = icon_name[0] = icon_fullpath[0] = '\0'; - - switch (id) - { - case XMB_TEXTURE_MAIN_MENU: -#if defined(HAVE_LAKKA) - icon_name = "lakka.png"; - break; -#else - icon_name = "retroarch.png"; - break; -#endif - case XMB_TEXTURE_SETTINGS: - icon_name = "settings.png"; - break; - case XMB_TEXTURE_HISTORY: - icon_name = "history.png"; - break; - case XMB_TEXTURE_FAVORITES: - icon_name = "favorites.png"; - break; - case XMB_TEXTURE_ADD_FAVORITE: - icon_name = "add-favorite.png"; - break; - case XMB_TEXTURE_MUSICS: - icon_name = "musics.png"; - break; -#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) - case XMB_TEXTURE_MOVIES: - icon_name = "movies.png"; - break; -#endif -#ifdef HAVE_IMAGEVIEWER - case XMB_TEXTURE_IMAGES: - icon_name = "images.png"; - break; -#endif - case XMB_TEXTURE_SETTING: - icon_name = "setting.png"; - break; - case XMB_TEXTURE_SUBSETTING: - icon_name = "subsetting.png"; - break; - case XMB_TEXTURE_ARROW: - icon_name = "arrow.png"; - break; - case XMB_TEXTURE_RUN: - icon_name = "run.png"; - break; - case XMB_TEXTURE_CLOSE: - icon_name = "close.png"; - break; - case XMB_TEXTURE_RESUME: - icon_name = "resume.png"; - break; - case XMB_TEXTURE_CLOCK: - icon_name = "clock.png"; - break; - case XMB_TEXTURE_BATTERY_FULL: - icon_name = "battery-full.png"; - break; - case XMB_TEXTURE_BATTERY_CHARGING: - icon_name = "battery-charging.png"; - break; - case XMB_TEXTURE_POINTER: - icon_name = "pointer.png"; - break; - case XMB_TEXTURE_SAVESTATE: - icon_name = "savestate.png"; - break; - case XMB_TEXTURE_LOADSTATE: - icon_name = "loadstate.png"; - break; - case XMB_TEXTURE_UNDO: - icon_name = "undo.png"; - break; - case XMB_TEXTURE_CORE_INFO: - icon_name = "core-infos.png"; - break; - case XMB_TEXTURE_WIFI: - icon_name = "wifi.png"; - break; - case XMB_TEXTURE_CORE_OPTIONS: - icon_name = "core-options.png"; - break; - case XMB_TEXTURE_INPUT_REMAPPING_OPTIONS: - icon_name = "core-input-remapping-options.png"; - break; - case XMB_TEXTURE_CHEAT_OPTIONS: - icon_name = "core-cheat-options.png"; - break; - case XMB_TEXTURE_DISK_OPTIONS: - icon_name = "core-disk-options.png"; - break; - case XMB_TEXTURE_SHADER_OPTIONS: - icon_name = "core-shader-options.png"; - break; - case XMB_TEXTURE_ACHIEVEMENT_LIST: - icon_name = "achievement-list.png"; - break; - case XMB_TEXTURE_SCREENSHOT: - icon_name = "screenshot.png"; - break; - case XMB_TEXTURE_RELOAD: - icon_name = "reload.png"; - break; - case XMB_TEXTURE_RENAME: - icon_name = "rename.png"; - break; - case XMB_TEXTURE_FILE: - icon_name = "file.png"; - break; - case XMB_TEXTURE_FOLDER: - icon_name = "folder.png"; - break; - case XMB_TEXTURE_ZIP: - icon_name = "zip.png"; - break; - case XMB_TEXTURE_MUSIC: - icon_name = "music.png"; - break; - case XMB_TEXTURE_FAVORITE: - icon_name = "favorites-content.png"; - break; - case XMB_TEXTURE_IMAGE: - icon_name = "image.png"; - break; - case XMB_TEXTURE_MOVIE: - icon_name = "movie.png"; - break; - case XMB_TEXTURE_CORE: - icon_name = "core.png"; - break; - case XMB_TEXTURE_RDB: - icon_name = "database.png"; - break; - case XMB_TEXTURE_CURSOR: - icon_name = "cursor.png"; - break; - case XMB_TEXTURE_SWITCH_ON: - icon_name = "on.png"; - break; - case XMB_TEXTURE_SWITCH_OFF: - icon_name = "off.png"; - break; - case XMB_TEXTURE_ADD: - icon_name = "add.png"; - break; -#ifdef HAVE_NETWORKING - case XMB_TEXTURE_NETPLAY: - icon_name = "netplay.png"; - break; - case XMB_TEXTURE_ROOM: - icon_name = "menu_room.png"; - break; - case XMB_TEXTURE_ROOM_LAN: - icon_name = "menu_room_lan.png"; - break; - case XMB_TEXTURE_ROOM_RELAY: - icon_name = "menu_room_relay.png"; - break; -#endif - case XMB_TEXTURE_KEY: - icon_name = "key.png"; - break; - case XMB_TEXTURE_KEY_HOVER: - icon_name = "key-hover.png"; - break; - case XMB_TEXTURE_DIALOG_SLICE: - icon_name = "dialog-slice.png"; - break; - case XMB_TEXTURE_ACHIEVEMENTS: - icon_name = "menu_achievements.png"; - break; - case XMB_TEXTURE_AUDIO: - icon_name = "menu_audio.png"; - break; - case XMB_TEXTURE_DRIVERS: - icon_name = "menu_drivers.png"; - break; - case XMB_TEXTURE_EXIT: - icon_name = "menu_exit.png"; - break; - case XMB_TEXTURE_FRAMESKIP: - icon_name = "menu_frameskip.png"; - break; - case XMB_TEXTURE_HELP: - icon_name = "menu_help.png"; - break; - case XMB_TEXTURE_INFO: - icon_name = "menu_info.png"; - break; - case XMB_TEXTURE_INPUT_SETTINGS: - icon_name = "Libretro - Pad.png"; - break; - case XMB_TEXTURE_LATENCY: - icon_name = "menu_latency.png"; - break; - case XMB_TEXTURE_NETWORK: - icon_name = "menu_network.png"; - break; - case XMB_TEXTURE_POWER: - icon_name = "menu_power.png"; - break; - case XMB_TEXTURE_RECORD: - icon_name = "menu_record.png"; - break; - case XMB_TEXTURE_SAVING: - icon_name = "menu_saving.png"; - break; - case XMB_TEXTURE_UPDATER: - icon_name = "menu_updater.png"; - break; - case XMB_TEXTURE_VIDEO: - icon_name = "menu_video.png"; - break; - case XMB_TEXTURE_MIXER: - icon_name = "menu_mixer.png"; - break; - case XMB_TEXTURE_LOG: - icon_name = "menu_log.png"; - break; - case XMB_TEXTURE_OSD: - icon_name = "menu_osd.png"; - break; - case XMB_TEXTURE_UI: - icon_name = "menu_ui.png"; - break; - case XMB_TEXTURE_USER: - icon_name = "menu_user.png"; - break; - case XMB_TEXTURE_PRIVACY: - icon_name = "menu_privacy.png"; - break; - case XMB_TEXTURE_PLAYLIST: - icon_name = "menu_playlist.png"; - break; - case XMB_TEXTURE_QUICKMENU: - icon_name = "menu_quickmenu.png"; - break; - case XMB_TEXTURE_REWIND: - icon_name = "menu_rewind.png"; - break; - case XMB_TEXTURE_OVERLAY: - icon_name = "menu_overlay.png"; - break; - case XMB_TEXTURE_OVERRIDE: - icon_name = "menu_override.png"; - break; - case XMB_TEXTURE_NOTIFICATIONS: - icon_name = "menu_notifications.png"; - break; - case XMB_TEXTURE_STREAM: - icon_name = "menu_stream.png"; - break; - case XMB_TEXTURE_SHUTDOWN: - icon_name = "menu_shutdown.png"; - break; - case XMB_TEXTURE_INPUT_DPAD_U: - icon_name = "input_DPAD-U.png"; - break; - case XMB_TEXTURE_INPUT_DPAD_D: - icon_name = "input_DPAD-D.png"; - break; - case XMB_TEXTURE_INPUT_DPAD_L: - icon_name = "input_DPAD-L.png"; - break; - case XMB_TEXTURE_INPUT_DPAD_R: - icon_name = "input_DPAD-R.png"; - break; - case XMB_TEXTURE_INPUT_STCK_U: - icon_name = "input_STCK-U.png"; - break; - case XMB_TEXTURE_INPUT_STCK_D: - icon_name = "input_STCK-D.png"; - break; - case XMB_TEXTURE_INPUT_STCK_L: - icon_name = "input_STCK-L.png"; - break; - case XMB_TEXTURE_INPUT_STCK_R: - icon_name = "input_STCK-R.png"; - break; - case XMB_TEXTURE_INPUT_STCK_P: - icon_name = "input_STCK-P.png"; - break; - case XMB_TEXTURE_INPUT_BTN_U: - icon_name = "input_BTN-U.png"; - break; - case XMB_TEXTURE_INPUT_BTN_D: - icon_name = "input_BTN-D.png"; - break; - case XMB_TEXTURE_INPUT_BTN_L: - icon_name = "input_BTN-L.png"; - break; - case XMB_TEXTURE_INPUT_BTN_R: - icon_name = "input_BTN-R.png"; - break; - case XMB_TEXTURE_INPUT_LB: - icon_name = "input_LB.png"; - break; - case XMB_TEXTURE_INPUT_RB: - icon_name = "input_RB.png"; - break; - case XMB_TEXTURE_INPUT_LT: - icon_name = "input_LT.png"; - break; - case XMB_TEXTURE_INPUT_RT: - icon_name = "input_RT.png"; - break; - case XMB_TEXTURE_INPUT_SELECT: - icon_name = "input_SELECT.png"; - break; - case XMB_TEXTURE_INPUT_START: - icon_name = "input_START.png"; - break; - case XMB_TEXTURE_CHECKMARK: - icon_name = "menu_check.png"; - break; - case XMB_TEXTURE_MENU_ADD: - icon_name = "menu_add.png"; - break; - case XMB_TEXTURE_BRIGHTNESS: - icon_name = "menu_brightness.png"; - break; - case XMB_TEXTURE_PAUSE: - icon_name = "menu_pause.png"; - break; - } - - fill_pathname_application_special(iconpath, - PATH_MAX_LENGTH * sizeof(char), - APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); - - icon_fullpath = iconpath; - strlcat(icon_fullpath, icon_name, PATH_MAX_LENGTH * sizeof(char)); - - if (!filestream_exists(icon_fullpath)) - { - RARCH_WARN("[XMB] Asset missing: %s\n", icon_fullpath); - return NULL; - } - else - return icon_name; - -} - -static void xmb_context_reset_textures( - xmb_handle_t *xmb, const char *iconpath) -{ - unsigned i; - settings_t *settings = config_get_ptr(); - - for (i = 0; i < XMB_TEXTURE_LAST; i++) - { - if (xmb_texture_path(i) == NULL) - { - /* If the icon doesn't exist at least try to return the subsetting icon*/ - if (!(i == XMB_TEXTURE_DIALOG_SLICE || i == XMB_TEXTURE_KEY_HOVER || i == XMB_TEXTURE_KEY_HOVER)) - menu_display_reset_textures_list(xmb_texture_path(XMB_TEXTURE_SUBSETTING), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); - continue; - } - menu_display_reset_textures_list(xmb_texture_path(i), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); - } - - /* Warn only if critical assets are missing, some themes are incomplete */ - if ( - ((xmb_texture_path(XMB_TEXTURE_SUBSETTING) == NULL)) && !(settings->uints.menu_xmb_theme == XMB_ICON_THEME_CUSTOM) - ) - runloop_msg_queue_push(msg_hash_to_str(MSG_MISSING_ASSETS), 1, 256, false); - - menu_display_allocate_white_texture(); - - xmb->main_menu_node.icon = xmb->textures.list[XMB_TEXTURE_MAIN_MENU]; - xmb->main_menu_node.alpha = xmb->categories_active_alpha; - xmb->main_menu_node.zoom = xmb->categories_active_zoom; - - xmb->settings_tab_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS]; - xmb->settings_tab_node.alpha = xmb->categories_active_alpha; - xmb->settings_tab_node.zoom = xmb->categories_active_zoom; - - xmb->history_tab_node.icon = xmb->textures.list[XMB_TEXTURE_HISTORY]; - xmb->history_tab_node.alpha = xmb->categories_active_alpha; - xmb->history_tab_node.zoom = xmb->categories_active_zoom; - - xmb->favorites_tab_node.icon = xmb->textures.list[XMB_TEXTURE_FAVORITES]; - xmb->favorites_tab_node.alpha = xmb->categories_active_alpha; - xmb->favorites_tab_node.zoom = xmb->categories_active_zoom; - - xmb->music_tab_node.icon = xmb->textures.list[XMB_TEXTURE_MUSICS]; - xmb->music_tab_node.alpha = xmb->categories_active_alpha; - xmb->music_tab_node.zoom = xmb->categories_active_zoom; - -#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) - xmb->video_tab_node.icon = xmb->textures.list[XMB_TEXTURE_MOVIES]; - xmb->video_tab_node.alpha = xmb->categories_active_alpha; - xmb->video_tab_node.zoom = xmb->categories_active_zoom; -#endif - -#ifdef HAVE_IMAGEVIEWER - xmb->images_tab_node.icon = xmb->textures.list[XMB_TEXTURE_IMAGES]; - xmb->images_tab_node.alpha = xmb->categories_active_alpha; - xmb->images_tab_node.zoom = xmb->categories_active_zoom; -#endif - - xmb->add_tab_node.icon = xmb->textures.list[XMB_TEXTURE_ADD]; - xmb->add_tab_node.alpha = xmb->categories_active_alpha; - xmb->add_tab_node.zoom = xmb->categories_active_zoom; - -#ifdef HAVE_NETWORKING - xmb->netplay_tab_node.icon = xmb->textures.list[XMB_TEXTURE_NETPLAY]; - xmb->netplay_tab_node.alpha = xmb->categories_active_alpha; - xmb->netplay_tab_node.zoom = xmb->categories_active_zoom; -#endif - -} - -static void xmb_context_reset_background(const char *iconpath) -{ - char *path = NULL; - settings_t *settings = config_get_ptr(); - const char *path_menu_wp = settings->paths.path_menu_wallpaper; - - if (!string_is_empty(path_menu_wp)) - path = strdup(path_menu_wp); - else if (!string_is_empty(iconpath)) - { - path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - path[0] = '\0'; - - fill_pathname_join(path, iconpath, "bg.png", - PATH_MAX_LENGTH * sizeof(char)); - } - - if (filestream_exists(path)) - task_push_image_load(path, - menu_display_handle_wallpaper_upload, NULL); - - if (path) - free(path); -} - -static void xmb_context_reset(void *data, bool is_threaded) -{ - xmb_handle_t *xmb = (xmb_handle_t*)data; - - if (xmb) - { - char bg_file_path[PATH_MAX_LENGTH] = {0}; - char *iconpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - iconpath[0] = '\0'; - - fill_pathname_application_special(bg_file_path, - sizeof(bg_file_path), APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_BG); - - if (!string_is_empty(bg_file_path)) - { - if (!string_is_empty(xmb->bg_file_path)) - free(xmb->bg_file_path); - xmb->bg_file_path = strdup(bg_file_path); - } - - fill_pathname_application_special(iconpath, - PATH_MAX_LENGTH * sizeof(char), - APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); - - xmb_layout(xmb); - xmb->font = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, - xmb->font_size, - is_threaded); - xmb->font2 = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, - xmb->font2_size, - is_threaded); - xmb_context_reset_textures(xmb, iconpath); - xmb_context_reset_background(iconpath); - xmb_context_reset_horizontal_list(xmb); - - if (!string_is_equal(xmb_thumbnails_ident('R'), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) - { - xmb_update_thumbnail_path(xmb, 0, 'R'); - xmb_update_thumbnail_image(xmb); - } - if (!string_is_equal(xmb_thumbnails_ident('L'), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) - { - xmb_update_thumbnail_path(xmb, 0, 'L'); - xmb_update_thumbnail_image(xmb); - } - xmb_update_savestate_thumbnail_image(xmb); - - free(iconpath); - } -} - static void xmb_navigation_clear(void *data, bool pending_push) { xmb_handle_t *xmb = (xmb_handle_t*)data; From 8be504e5e5c5d14be04c2199e77be579f43fec70 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 25 Nov 2018 03:39:46 +0100 Subject: [PATCH 041/153] Don't reupload the textures all the time --- menu/drivers/xmb.c | 104 +++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 50 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 3a78f4f1d0..2a2f542a0e 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2111,7 +2111,6 @@ static void xmb_context_reset_horizontal_list( } } - xmb_toggle_horizontal_list(xmb); } static void xmb_refresh_horizontal_list(xmb_handle_t *xmb) @@ -2133,6 +2132,7 @@ static void xmb_refresh_horizontal_list(xmb_handle_t *xmb) xmb_init_horizontal_list(xmb); xmb_context_reset_horizontal_list(xmb); + xmb_toggle_horizontal_list(xmb); } static int xmb_environ(enum menu_environ_cb type, void *data, void *userdata) @@ -3671,33 +3671,8 @@ static const char *xmb_texture_path(unsigned id) } - -static void xmb_context_reset_textures( - xmb_handle_t *xmb, const char *iconpath) +static void xmb_context_reset_textures_nodes(xmb_handle_t *xmb) { - unsigned i; - settings_t *settings = config_get_ptr(); - - for (i = 0; i < XMB_TEXTURE_LAST; i++) - { - if (xmb_texture_path(i) == NULL) - { - /* If the icon doesn't exist at least try to return the subsetting icon*/ - if (!(i == XMB_TEXTURE_DIALOG_SLICE || i == XMB_TEXTURE_KEY_HOVER || i == XMB_TEXTURE_KEY_HOVER)) - menu_display_reset_textures_list(xmb_texture_path(XMB_TEXTURE_SUBSETTING), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); - continue; - } - menu_display_reset_textures_list(xmb_texture_path(i), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); - } - - /* Warn only if critical assets are missing, some themes are incomplete */ - if ( - ((xmb_texture_path(XMB_TEXTURE_SUBSETTING) == NULL)) && !(settings->uints.menu_xmb_theme == XMB_ICON_THEME_CUSTOM) - ) - runloop_msg_queue_push(msg_hash_to_str(MSG_MISSING_ASSETS), 1, 256, false); - - menu_display_allocate_white_texture(); - xmb->main_menu_node.icon = xmb->textures.list[XMB_TEXTURE_MAIN_MENU]; xmb->main_menu_node.alpha = xmb->categories_active_alpha; xmb->main_menu_node.zoom = xmb->categories_active_zoom; @@ -3739,6 +3714,34 @@ static void xmb_context_reset_textures( xmb->netplay_tab_node.alpha = xmb->categories_active_alpha; xmb->netplay_tab_node.zoom = xmb->categories_active_zoom; #endif +} + +static void xmb_context_reset_textures( + xmb_handle_t *xmb, const char *iconpath) +{ + unsigned i; + settings_t *settings = config_get_ptr(); + + for (i = 0; i < XMB_TEXTURE_LAST; i++) + { + if (xmb_texture_path(i) == NULL) + { + /* If the icon doesn't exist at least try to return the subsetting icon*/ + if (!(i == XMB_TEXTURE_DIALOG_SLICE || i == XMB_TEXTURE_KEY_HOVER || i == XMB_TEXTURE_KEY_HOVER)) + menu_display_reset_textures_list(xmb_texture_path(XMB_TEXTURE_SUBSETTING), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); + continue; + } + menu_display_reset_textures_list(xmb_texture_path(i), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); + } + + /* Warn only if critical assets are missing, some themes are incomplete */ + if ( + ((xmb_texture_path(XMB_TEXTURE_SUBSETTING) == NULL)) && !(settings->uints.menu_xmb_theme == XMB_ICON_THEME_CUSTOM) + ) + runloop_msg_queue_push(msg_hash_to_str(MSG_MISSING_ASSETS), 1, 256, false); + + menu_display_allocate_white_texture(); + } @@ -3770,8 +3773,30 @@ static void xmb_context_reset_background(const char *iconpath) static void xmb_context_reset(void *data, bool is_threaded) { xmb_handle_t *xmb = (xmb_handle_t*)data; + char *iconpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + + char bg_file_path[PATH_MAX_LENGTH] = {0}; + iconpath[0] = '\0'; + fill_pathname_application_special(iconpath, + PATH_MAX_LENGTH * sizeof(char), + APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); + fill_pathname_application_special(bg_file_path, + sizeof(bg_file_path), APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_BG); + + if (!string_is_empty(bg_file_path)) + { + if (!string_is_empty(xmb->bg_file_path)) + free(xmb->bg_file_path); + xmb->bg_file_path = strdup(bg_file_path); + } + + xmb_context_reset_textures(xmb, iconpath); + xmb_context_reset_background(iconpath); + xmb_context_reset_horizontal_list(xmb); xmb->previous_scale_factor = 0.0; + + free(iconpath); } static void xmb_layout_ps3(xmb_handle_t *xmb, int width) @@ -4030,24 +4055,6 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) if (scale_factor != xmb->previous_scale_factor) { - char bg_file_path[PATH_MAX_LENGTH] = {0}; - char *iconpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - iconpath[0] = '\0'; - - fill_pathname_application_special(bg_file_path, - sizeof(bg_file_path), APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_BG); - - if (!string_is_empty(bg_file_path)) - { - if (!string_is_empty(xmb->bg_file_path)) - free(xmb->bg_file_path); - xmb->bg_file_path = strdup(bg_file_path); - } - - fill_pathname_application_special(iconpath, - PATH_MAX_LENGTH * sizeof(char), - APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); - menu_display_font_free(xmb->font); menu_display_font_free(xmb->font2); xmb_layout(xmb); @@ -4057,9 +4064,8 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) xmb->font2 = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, xmb->font2_size, video_driver_is_threaded()); - xmb_context_reset_textures(xmb, iconpath); - xmb_context_reset_background(iconpath); - xmb_context_reset_horizontal_list(xmb); + xmb_context_reset_textures_nodes(xmb); + xmb_toggle_horizontal_list(xmb); if (!string_is_equal(xmb_thumbnails_ident('R'), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) @@ -4074,8 +4080,6 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) xmb_update_thumbnail_image(xmb); } xmb_update_savestate_thumbnail_image(xmb); - - free(iconpath); } xmb->frame_count++; From 4e796ae86e5f1c09046fde58104be6120e326d9b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 25 Nov 2018 05:29:40 +0100 Subject: [PATCH 042/153] (XMB) Cleanups --- menu/drivers/xmb.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 2a2f542a0e..0d85039a14 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -4055,15 +4055,18 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) if (scale_factor != xmb->previous_scale_factor) { + bool video_is_threaded = video_driver_is_threaded(); menu_display_font_free(xmb->font); menu_display_font_free(xmb->font2); xmb_layout(xmb); - xmb->font = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, + xmb->font = menu_display_font( + APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, xmb->font_size, - video_driver_is_threaded()); - xmb->font2 = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, + video_is_threaded); + xmb->font2 = menu_display_font( + APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, xmb->font2_size, - video_driver_is_threaded()); + video_is_threaded); xmb_context_reset_textures_nodes(xmb); xmb_toggle_horizontal_list(xmb); From 77faf4ac4a1eb43ef93076751f6017d385626dc5 Mon Sep 17 00:00:00 2001 From: radius Date: Mon, 29 Oct 2018 21:23:53 -0500 Subject: [PATCH 043/153] [subsystem] try to load subsystems without loading content --- .vscode/settings.json | 2 + command.c | 9 +++++ dynamic.c | 69 +++++++++++++++++++++++++++++++- dynamic.h | 4 ++ menu/cbs/menu_cbs_sublabel.c | 17 ++++---- menu/drivers/nuklear/nk_common.c | 4 +- menu/drivers/ozone/ozone.c | 9 +++-- menu/drivers/xmb.c | 12 +++--- menu/menu_displaylist.c | 25 ++---------- menu/widgets/menu_filebrowser.c | 12 +++--- paths.c | 2 +- tasks/task_content.c | 4 +- 12 files changed, 116 insertions(+), 53 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index c44832dca4..386e8341f9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -41,6 +41,8 @@ "ozone_texture.h": "c", "string_list.h": "c", "core_info.h": "c" + "thread": "c", + "xlocale": "c" }, "C_Cpp.dimInactiveRegions": false, } \ No newline at end of file diff --git a/command.c b/command.c index a87a52e1e4..a378a97de9 100644 --- a/command.c +++ b/command.c @@ -1899,6 +1899,8 @@ bool command_event(enum event_command cmd, void *data) break; case CMD_EVENT_LOAD_CORE: { + subsystem_size = 0; + content_clear_subsystem(); bool success = command_event(CMD_EVENT_LOAD_CORE_PERSIST, NULL); (void)success; @@ -2019,8 +2021,10 @@ bool command_event(enum event_command cmd, void *data) command_event(CMD_EVENT_RESTORE_REMAPS, NULL); if (is_inited) + { if (!task_push_start_dummy_core(&content_info)) return false; + } #ifdef HAVE_DYNAMIC path_clear(RARCH_PATH_CORE); rarch_ctl(RARCH_CTL_SYSTEM_INFO_FREE, NULL); @@ -2037,6 +2041,11 @@ bool command_event(enum event_command cmd, void *data) command_event(CMD_EVENT_DISCORD_UPDATE, &userdata); } #endif + if (is_inited) + { + subsystem_size = 0; + content_clear_subsystem(); + } } break; case CMD_EVENT_QUIT: diff --git a/dynamic.c b/dynamic.c index 04698748e3..bacbefde07 100644 --- a/dynamic.c +++ b/dynamic.c @@ -176,12 +176,80 @@ void libretro_free_system_info(struct retro_system_info *info) static bool environ_cb_get_system_info(unsigned cmd, void *data) { + rarch_system_info_t *system = runloop_get_system_info(); switch (cmd) { case RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME: *load_no_content_hook = *(const bool*)data; break; + case RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO: + { + unsigned i, j; + const struct retro_subsystem_info *info = + (const struct retro_subsystem_info*)data; + subsystem_size = 0; + RARCH_LOG("Environ SET_SUBSYSTEM_INFO.\n"); + for (i = 0; info[i].ident; i++) + { + RARCH_LOG("Subsystem ID: %d\n", i); + RARCH_LOG("Special game type: %s\n", info[i].desc); + RARCH_LOG(" Ident: %s\n", info[i].ident); + RARCH_LOG(" ID: %u\n", info[i].id); + RARCH_LOG(" Content:\n"); + for (j = 0; j < info[i].num_roms; j++) + { + RARCH_LOG(" %s (%s)\n", + info[i].roms[j].desc, info[i].roms[j].required ? + "required" : "optional"); + } + } + + RARCH_LOG("Subsystems: %d\n", i); + unsigned size = i; + + if (system) + { + for (i = 0; i < size; i++) + { + subsystem_data[i].desc = strdup(info[i].desc); + subsystem_data[i].ident = strdup(info[i].ident); + subsystem_data[i].id = info[i].id; + subsystem_data[i].num_roms = info[i].num_roms; + + for (j = 0; j < subsystem_data[i].num_roms; j++) + { + subsystem_data_roms[i][j].desc = strdup(info[i].roms[j].desc); + subsystem_data_roms[i][j].valid_extensions = strdup(info[i].roms[j].valid_extensions); + subsystem_data_roms[i][j].required = info[i].roms[j].required; + subsystem_data_roms[i][j].block_extract = info[i].roms[j].block_extract; + subsystem_data_roms[i][j].need_fullpath = info[i].roms[j].need_fullpath; + } + subsystem_data[i].roms = subsystem_data_roms[i]; + } + + for (i = 0; i < size; i++) + { +#if 1 + RARCH_LOG("Subsystem ID: %d\n", i); + RARCH_LOG("Special game type: %s\n", subsystem_data[i].desc); + RARCH_LOG(" Ident: %s\n", subsystem_data[i].ident); + RARCH_LOG(" ID: %u\n", subsystem_data[i].id); + RARCH_LOG(" Content:\n"); +#endif + for (j = 0; j < subsystem_data[i].num_roms; j++) + { + RARCH_LOG(" %s (%s)\n", + subsystem_data[i].roms[j].desc, subsystem_data[i].roms[j].required ? + "required" : "optional"); + } + } + RARCH_LOG("Subsystems: %d\n", subsystem_size); + subsystem_size = size; + RARCH_LOG("Subsystems: %d\n", subsystem_size); + } + break; + } default: return false; } @@ -396,7 +464,6 @@ bool libretro_get_system_info(const char *path, #ifdef HAVE_DYNAMIC dylib_close(lib); #endif - return true; } diff --git a/dynamic.h b/dynamic.h index e930a2edc8..505082bc97 100644 --- a/dynamic.h +++ b/dynamic.h @@ -146,6 +146,10 @@ bool init_libretro_sym_custom(enum rarch_core_type type, struct retro_core_t *cu **/ void uninit_libretro_sym(struct retro_core_t *core); +struct retro_subsystem_info subsystem_data[20]; +struct retro_subsystem_rom_info subsystem_data_roms[10][10]; +unsigned subsystem_size; + RETRO_END_DECLS #endif diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index c4ff5f6cf5..0c61484fc3 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -40,6 +40,7 @@ #include "../../retroarch.h" #include "../../content.h" +#include "../../dynamic.h" #include "../../configuration.h" #include "../../managers/cheat_manager.h" @@ -513,14 +514,14 @@ static int action_bind_sublabel_subsystem_add( char *s, size_t len) { rarch_system_info_t *system = runloop_get_system_info(); - const struct retro_subsystem_info *subsystem = (system && system->subsystem.data) ? - system->subsystem.data + (type - MENU_SETTINGS_SUBSYSTEM_ADD) : NULL; + const struct retro_subsystem_info *subsystem = (system && subsystem_size > 0) ? + subsystem_data + (type - MENU_SETTINGS_SUBSYSTEM_ADD) : NULL; - if (subsystem && content_get_subsystem_rom_id() < subsystem->num_roms) + if (subsystem_size > 0 && content_get_subsystem_rom_id() < subsystem->num_roms) snprintf(s, len, " Current Content: %s", - content_get_subsystem() == type - MENU_SETTINGS_SUBSYSTEM_ADD - ? subsystem->roms[content_get_subsystem_rom_id()].desc - : subsystem->roms[0].desc); + content_get_subsystem() == type - MENU_SETTINGS_SUBSYSTEM_ADD + ? subsystem->roms[content_get_subsystem_rom_id()].desc + : subsystem->roms[0].desc); return 0; } @@ -539,8 +540,8 @@ static int action_bind_sublabel_remap_kbd_sublabel( input_config_get_device_display_name(user_idx) ? input_config_get_device_display_name(user_idx) : (input_config_get_device_name(user_idx) ? - input_config_get_device_name(user_idx) : - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE))); + input_config_get_device_name(user_idx) : + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE))); return 0; } diff --git a/menu/drivers/nuklear/nk_common.c b/menu/drivers/nuklear/nk_common.c index 67323c0cf1..61800585fd 100644 --- a/menu/drivers/nuklear/nk_common.c +++ b/menu/drivers/nuklear/nk_common.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * Copyright (C) 2014-2017 - Jean-Andr� Santoni - * Copyright (C) 2016-2017 - Andr�s Su�rez + * Copyright (C) 2014-2017 - Jean-André Santoni + * Copyright (C) 2016-2017 - Andrés Suárez * * 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/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 556b59fe20..4dbea26628 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -45,6 +45,7 @@ #include "../../../core.h" #include "../../../verbosity.h" #include "../../../tasks/tasks_internal.h" +#include "../../../dynamic.h" ozone_node_t *ozone_alloc_node() { @@ -583,16 +584,16 @@ static int ozone_list_push(void *data, void *userdata, if (settings->bools.menu_show_load_content) { - const struct retro_subsystem_info* subsystem = NULL; - entry.enum_idx = MENU_ENUM_LABEL_LOAD_CONTENT_LIST; menu_displaylist_setting(&entry); subsystem = system->subsystem.data; - if (subsystem) + if (subsystem_size > 0) { - for (i = 0; i < (unsigned)system->subsystem.size; i++, subsystem++) + const struct retro_subsystem_info* subsystem = NULL; + subsystem = subsystem_data; + for (i = 0; i < subsystem_size; i++, subsystem++) { char s[PATH_MAX_LENGTH]; if (content_get_subsystem() == i) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 2a2f542a0e..da7dbb0a25 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -55,6 +55,7 @@ #include "../widgets/menu_filebrowser.h" #include "../../verbosity.h" +#include "../../dynamic.h" #include "../../configuration.h" #include "../../playlist.h" #include "../../retroarch.h" @@ -5597,16 +5598,15 @@ static int xmb_list_push(void *data, void *userdata, if (settings->bools.menu_show_load_content) { - const struct retro_subsystem_info* subsystem = NULL; + entry.enum_idx = MENU_ENUM_LABEL_LOAD_CONTENT_LIST; menu_displaylist_setting(&entry); - - subsystem = system->subsystem.data; - - if (subsystem) + if (subsystem_size > 0) { - for (i = 0; i < (unsigned)system->subsystem.size; i++, subsystem++) + const struct retro_subsystem_info* subsystem = NULL; + subsystem = subsystem_data; + for (i = 0; i < subsystem_size; i++, subsystem++) { char s[PATH_MAX_LENGTH]; if (content_get_subsystem() == i) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index c009494f51..2aa5f9348d 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * Copyright (C) 2014-2017 - Jean-Andr Santoni - * Copyright (C) 2015-2017 - Andrs Surez + * Copyright (C) 2014-2017 - Jean-André Santoni + * Copyright (C) 2015-2017 - Andrés Suárez * Copyright (C) 2016-2017 - Brad Parker * * RetroArch is free software: you can redistribute it and/or modify it under the terms @@ -2584,25 +2584,6 @@ static int menu_displaylist_parse_load_content_settings( #endif rarch_system_info_t *system = runloop_get_system_info(); -#if 0 - const struct retro_subsystem_info* subsystem = system ? system->subsystem.data : NULL; - - if (subsystem) - { - unsigned p; - - for (p = 0; p < system->subsystem.size; p++, subsystem++) - { - char s[PATH_MAX_LENGTH]; - snprintf(s, sizeof(s), "%s (%s)", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_LOAD_CONTENT_LIST), subsystem->desc); - menu_entries_append_enum(info->list, - s, - msg_hash_to_str(MENU_ENUM_LABEL_LOAD_CONTENT_SPECIAL), - MENU_ENUM_LABEL_LOAD_CONTENT_SPECIAL, - MENU_SETTING_ACTION, 0, 0); - } - } -#endif menu_entries_append_enum(info->list, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RESUME_CONTENT), msg_hash_to_str(MENU_ENUM_LABEL_RESUME_CONTENT), @@ -2633,7 +2614,7 @@ static int menu_displaylist_parse_load_content_settings( if (settings->bools.quick_menu_show_save_load_state #ifdef HAVE_CHEEVOS - && !cheevos_hardcore_active + && !cheevos_hardcore_active #endif ) { diff --git a/menu/widgets/menu_filebrowser.c b/menu/widgets/menu_filebrowser.c index 89fe44c091..ee19acefbe 100644 --- a/menu/widgets/menu_filebrowser.c +++ b/menu/widgets/menu_filebrowser.c @@ -39,6 +39,7 @@ #include "../../core.h" #include "../../content.h" #include "../../verbosity.h" +#include "../../dynamic.h" static enum filebrowser_enums filebrowser_types = FILEBROWSER_NONE; @@ -83,10 +84,9 @@ void filebrowser_parse(menu_displaylist_info_t *info, unsigned type_data) str_list = file_archive_get_file_list(path, info->exts); else { - rarch_system_info_t *system = runloop_get_system_info(); - const struct retro_subsystem_info *subsystem = system->subsystem.data + content_get_subsystem(); + const struct retro_subsystem_info *subsystem = &subsystem_data[content_get_subsystem()]; - if (subsystem) + if (subsystem_size > 0) str_list = file_archive_get_file_list(path, subsystem->roms[content_get_subsystem_rom_id()].valid_extensions); } } @@ -94,11 +94,9 @@ void filebrowser_parse(menu_displaylist_info_t *info, unsigned type_data) { if (filebrowser_types == FILEBROWSER_SELECT_FILE_SUBSYSTEM) { - rarch_system_info_t *system = runloop_get_system_info(); - const struct retro_subsystem_info *subsystem = - system->subsystem.data + content_get_subsystem(); + const struct retro_subsystem_info *subsystem = &subsystem_data[content_get_subsystem()]; - if (subsystem && content_get_subsystem_rom_id() < subsystem->num_roms) + if (subsystem_size > 0 && content_get_subsystem_rom_id() < subsystem->num_roms) str_list = dir_list_new(path, (filter_ext && info) ? subsystem->roms[content_get_subsystem_rom_id()].valid_extensions : NULL, true, settings->bools.show_hidden_files, true, false); diff --git a/paths.c b/paths.c index b956989638..869d6b8e34 100644 --- a/paths.c +++ b/paths.c @@ -311,7 +311,7 @@ static bool path_init_subsystem(void) /* For subsystems, we know exactly which RAM types are supported. */ info = libretro_find_subsystem_info( - system->subsystem.data, + subsystem_data, system->subsystem.size, path_get(RARCH_PATH_SUBSYSTEM)); diff --git a/tasks/task_content.c b/tasks/task_content.c index af28c4fcac..3db8f943b0 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -1782,11 +1782,11 @@ void content_set_subsystem(unsigned idx) { rarch_system_info_t *system = runloop_get_system_info(); const struct retro_subsystem_info *subsystem = system ? - system->subsystem.data + idx : NULL; + subsystem_data + idx : NULL; pending_subsystem_id = idx; - if (subsystem) + if (subsystem_size > 0) { strlcpy(pending_subsystem_ident, subsystem->ident, sizeof(pending_subsystem_ident)); From 881a7d571e38853f614628e443fd2c9efd825941 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 25 Nov 2018 07:19:23 +0100 Subject: [PATCH 044/153] Add unfinished patch --- 10bpc-gl.diff | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 10bpc-gl.diff diff --git a/10bpc-gl.diff b/10bpc-gl.diff new file mode 100644 index 0000000000..9436f12f82 --- /dev/null +++ b/10bpc-gl.diff @@ -0,0 +1,96 @@ +diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c +index b90a8e40c3..e57c4df194 100644 +--- a/gfx/drivers_context/wgl_ctx.c ++++ b/gfx/drivers_context/wgl_ctx.c +@@ -78,6 +78,47 @@ + #ifndef WGL_CONTEXT_DEBUG_BIT_ARB + #define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 + #endif ++ ++#ifndef WGL_ACCELERATION_ARB ++#define WGL_ACCELERATION_ARB 0x2003 ++#endif ++ ++#ifndef WGL_FULL_ACCELERATION_ARB ++#define WGL_FULL_ACCELERATION_ARB 0x2027 ++#endif ++ ++#ifndef WGL_DRAW_TO_WINDOW_ARB ++#define WGL_DRAW_TO_WINDOW_ARB 0x2001 ++#endif ++ ++#ifndef WGL_DOUBLE_BUFFER_ARB ++#define WGL_DOUBLE_BUFFER_ARB 0x2011 ++#endif ++ ++#ifndef WGL_RED_BITS_ARB ++#define WGL_RED_BITS_ARB 0x2015 ++#endif ++ ++#ifndef WGL_GREEN_BITS_ARB ++#define WGL_GREEN_BITS_ARB 0x2017 ++#endif ++ ++#ifndef WGL_BLUE_BITS_ARB ++#define WGL_BLUE_BITS_ARB 0x2019 ++#endif ++ ++#ifndef WGL_ALPHA_BITS_ARB ++#define WGL_ALPHA_BITS_ARB 0x201B ++#endif ++ ++#ifndef WGL_PIXEL_TYPE_ARB ++#define WGL_PIXEL_TYPE_ARB 0x2013 ++#endif ++ ++#ifndef WGL_TYPE_RGBA_ARB ++#define WGL_TYPE_RGBA_ARB 0x202B ++#endif ++ + #endif + + #if defined(HAVE_OPENGL) +@@ -313,6 +354,43 @@ static void create_gl_context(HWND hwnd, bool *quit) + RARCH_LOG("[WGL]: Adaptive VSync supported.\n"); + wgl_adaptive_vsync = true; + } ++ if (wgl_has_extension("WGL_ARB_pixel_format", extensions)) ++ { ++ BOOL (WINAPI * wglChoosePixelFormatARB) ++ (HDC hdc, ++ const int *piAttribIList, ++ const FLOAT *pfAttribFList, ++ UINT nMaxFormats, ++ int *piFormats, ++ UINT *nNumFormats); ++ UINT nMatchingFormats; ++ int index = 0; ++ int attribsDesired[] = { ++ WGL_DRAW_TO_WINDOW_ARB, 1, ++ WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB, ++ WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB, ++ WGL_RED_BITS_ARB, 10, ++ WGL_GREEN_BITS_ARB, 10, ++ WGL_BLUE_BITS_ARB, 10, ++ WGL_ALPHA_BITS_ARB, 2, ++ WGL_DOUBLE_BUFFER_ARB, 1, ++ 0,0 ++ }; ++ wglChoosePixelFormatARB = (BOOL (WINAPI *) (HDC, const int *, ++ const FLOAT*, UINT, int*, UINT*)) ++ gfx_ctx_wgl_get_proc_address("wglChoosePixelFormatARB"); ++ ++ RARCH_LOG("[WGL]: ARB pixel format supported.\n"); ++ ++ if (wglChoosePixelFormatARB(win32_hdc, attribsDesired, ++ NULL, 1, &index, &nMatchingFormats)) ++ { ++ if (nMatchingFormats == 0) ++ { ++ RARCH_WARN("No 10bpc WGL_ARB_pixel_formats found!\n"); ++ } ++ } ++ } + } + } + #endif From e1afdf8c3cf201e6481493c2cd98c12eecd02040 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 25 Nov 2018 09:02:32 +0100 Subject: [PATCH 045/153] (Windows) Start implementing 'remember window positions'. Right now only saves/remembers X, Y position --- configuration.c | 3 +++ configuration.h | 4 ++++ gfx/common/win32_common.c | 44 +++++++++++++++++++++++++++++---------- intl/msg_hash_ar.h | 2 ++ intl/msg_hash_chs.h | 2 ++ intl/msg_hash_cht.h | 2 ++ intl/msg_hash_de.h | 2 ++ intl/msg_hash_el.h | 2 ++ intl/msg_hash_eo.h | 2 ++ intl/msg_hash_es.h | 4 +++- intl/msg_hash_fr.h | 2 ++ intl/msg_hash_it.h | 2 ++ intl/msg_hash_ja.h | 2 ++ intl/msg_hash_ko.h | 2 ++ intl/msg_hash_lbl.h | 2 ++ intl/msg_hash_nl.h | 2 ++ intl/msg_hash_pl.h | 2 ++ intl/msg_hash_pt_br.h | 4 +++- intl/msg_hash_pt_pt.h | 2 ++ intl/msg_hash_ru.h | 2 ++ intl/msg_hash_us.h | 4 +++- intl/msg_hash_vn.h | 2 ++ menu/menu_displaylist.c | 3 +++ menu/menu_setting.c | 15 +++++++++++++ msg_hash.h | 1 + 25 files changed, 100 insertions(+), 14 deletions(-) diff --git a/configuration.c b/configuration.c index 299f475e99..a7476b318f 100644 --- a/configuration.c +++ b/configuration.c @@ -1514,6 +1514,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, SETTING_BOOL("video_msg_bgcolor_enable", &settings->bools.video_msg_bgcolor_enable, true, message_bgcolor_enable, false); SETTING_BOOL("video_window_show_decorations", &settings->bools.video_window_show_decorations, true, window_decorations, false); + SETTING_BOOL("video_window_save_positions", &settings->bools.video_window_save_positions, true, false, false); SETTING_BOOL("sustained_performance_mode", &settings->bools.sustained_performance_mode, true, sustained_performance_mode, false); @@ -1672,6 +1673,8 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings, SETTING_UINT("video_stream_quality", &settings->uints.video_stream_quality, true, RECORD_CONFIG_TYPE_STREAMING_LOW_QUALITY, false); SETTING_UINT("video_record_scale_factor", &settings->uints.video_record_scale_factor, true, 1, false); SETTING_UINT("video_stream_scale_factor", &settings->uints.video_stream_scale_factor, true, 1, false); + SETTING_UINT("video_windowed_position_x", &settings->uints.window_position_x, true, 0, false); + SETTING_UINT("video_windowed_position_y", &settings->uints.window_position_y, true, 0, false); *size = count; diff --git a/configuration.h b/configuration.h index 5ca67844fb..8ba5ba8c7c 100644 --- a/configuration.h +++ b/configuration.h @@ -293,6 +293,7 @@ typedef struct settings bool automatically_add_content_to_playlist; bool video_window_show_decorations; + bool video_window_save_positions; bool sustained_performance_mode; } bools; @@ -439,6 +440,9 @@ typedef struct settings unsigned midi_volume; unsigned streaming_mode; + + unsigned window_position_x; + unsigned window_position_y; } uints; struct diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 0b77ce9f88..137c74957f 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -617,6 +617,24 @@ static LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, } #endif +static void win32_save_position(void) +{ + WINDOWPLACEMENT placement; + settings_t *settings = config_get_ptr(); + memset(&placement, 0, sizeof(placement)); + placement.length = sizeof(placement); + + GetWindowPlacement(main_window.hwnd, &placement); + + g_win32_pos_x = placement.rcNormalPosition.left; + g_win32_pos_y = placement.rcNormalPosition.top; + if (settings && settings->bools.video_window_save_positions) + { + settings->uints.window_position_x = g_win32_pos_x; + settings->uints.window_position_y = g_win32_pos_y; + } +} + static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { @@ -649,21 +667,16 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message, *quit = true; return win32_handle_keyboard_event(hwnd, message, wparam, lparam); + case WM_MOVE: + win32_save_position(); + break; case WM_CLOSE: case WM_DESTROY: case WM_QUIT: - { - WINDOWPLACEMENT placement; - memset(&placement, 0, sizeof(placement)); - placement.length = sizeof(placement); + win32_save_position(); - GetWindowPlacement(main_window.hwnd, &placement); - - g_win32_pos_x = placement.rcNormalPosition.left; - g_win32_pos_y = placement.rcNormalPosition.top; - g_win32_quit = true; - *quit = true; - } + g_win32_quit = true; + *quit = true; break; case WM_SIZE: /* Do not send resize message if we minimize. */ @@ -678,6 +691,7 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message, g_win32_resized = true; } } + win32_save_position(); *quit = true; break; case WM_COMMAND: @@ -719,6 +733,7 @@ LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message, case WM_CLOSE: case WM_DESTROY: case WM_QUIT: + case WM_MOVE: case WM_SIZE: case WM_COMMAND: ret = WndProcCommon(&quit, hwnd, message, wparam, lparam); @@ -779,6 +794,7 @@ LRESULT CALLBACK WndProcGL(HWND hwnd, UINT message, case WM_CLOSE: case WM_DESTROY: case WM_QUIT: + case WM_MOVE: case WM_SIZE: case WM_COMMAND: ret = WndProcCommon(&quit, @@ -878,6 +894,7 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message, case WM_CLOSE: case WM_DESTROY: case WM_QUIT: + case WM_MOVE: case WM_SIZE: case WM_COMMAND: ret = WndProcCommon(&quit, hwnd, message, wparam, lparam); @@ -918,6 +935,11 @@ bool win32_window_create(void *data, unsigned style, #endif settings_t *settings = config_get_ptr(); #ifndef _XBOX + if (settings->bools.video_window_save_positions) + { + g_win32_pos_x = settings->uints.window_position_x; + g_win32_pos_y = settings->uints.window_position_y; + } main_window.hwnd = CreateWindowEx(0, "RetroArch", "RetroArch", style, diff --git a/intl/msg_hash_ar.h b/intl/msg_hash_ar.h index 88b3ade95b..1845a492d9 100644 --- a/intl/msg_hash_ar.h +++ b/intl/msg_hash_ar.h @@ -3722,3 +3722,5 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_FAVORITES_AVAILABLE, "No favorites available." ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, + "Save Window Positions") diff --git a/intl/msg_hash_chs.h b/intl/msg_hash_chs.h index 11f7b11bb2..15b4897550 100644 --- a/intl/msg_hash_chs.h +++ b/intl/msg_hash_chs.h @@ -4749,3 +4749,5 @@ MSG_HASH( MSG_MISSING_ASSETS, "Warning: Missing assets, use the Online Updater if available" ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, + "Save Window Positions") diff --git a/intl/msg_hash_cht.h b/intl/msg_hash_cht.h index c025ffed0a..684cee966b 100644 --- a/intl/msg_hash_cht.h +++ b/intl/msg_hash_cht.h @@ -3500,3 +3500,5 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_FAVORITES_AVAILABLE, "No favorites available." ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, + "Save Window Positions") diff --git a/intl/msg_hash_de.h b/intl/msg_hash_de.h index f87411aa60..b9545d62c5 100644 --- a/intl/msg_hash_de.h +++ b/intl/msg_hash_de.h @@ -3636,3 +3636,5 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_FAVORITES_AVAILABLE, "No favorites available." ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, + "Save Window Positions") diff --git a/intl/msg_hash_el.h b/intl/msg_hash_el.h index e3bc73e9e9..dde7d94f57 100644 --- a/intl/msg_hash_el.h +++ b/intl/msg_hash_el.h @@ -7730,3 +7730,5 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_FAVORITES_AVAILABLE, "No favorites available." ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, + "Save Window Positions") diff --git a/intl/msg_hash_eo.h b/intl/msg_hash_eo.h index c28eff54ef..949bf7f894 100644 --- a/intl/msg_hash_eo.h +++ b/intl/msg_hash_eo.h @@ -3375,3 +3375,5 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_FAVORITES_AVAILABLE, "No favorites available." ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, + "Save Window Positions") diff --git a/intl/msg_hash_es.h b/intl/msg_hash_es.h index 19ac3b8b90..c90bb1e917 100644 --- a/intl/msg_hash_es.h +++ b/intl/msg_hash_es.h @@ -7747,4 +7747,6 @@ MSG_HASH( MSG_HASH( MSG_MISSING_ASSETS, "ADVERTENCIA: Faltan recursos, use el Actualizador si está disponible" - ) \ No newline at end of file + ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, + "Save Window Positions") diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index 2d9a560a34..1d49b75509 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -3534,3 +3534,5 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_FAVORITES_AVAILABLE, "No favorites available." ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, + "Save Window Positions") diff --git a/intl/msg_hash_it.h b/intl/msg_hash_it.h index fe7be6d34a..101c33f6d2 100644 --- a/intl/msg_hash_it.h +++ b/intl/msg_hash_it.h @@ -3594,3 +3594,5 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_FAVORITES_AVAILABLE, "Nessun preferito disponibile." ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, + "Save Window Positions") diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index 813efe054a..6ec2dd4c08 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -4043,3 +4043,5 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_FAVORITES_AVAILABLE, "No favorites available." ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, + "Save Window Positions") diff --git a/intl/msg_hash_ko.h b/intl/msg_hash_ko.h index 60b669cbfb..d137039946 100644 --- a/intl/msg_hash_ko.h +++ b/intl/msg_hash_ko.h @@ -3495,3 +3495,5 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_FAVORITES_AVAILABLE, "No favorites available." ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, + "Save Window Positions") diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index 4620278a65..1571d7e991 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -1567,6 +1567,8 @@ MSG_HASH(MENU_ENUM_LABEL_INPUT_DRIVER_LINUXRAW, "linuxraw") MSG_HASH(MENU_ENUM_LABEL_VIDEO_WINDOW_SHOW_DECORATIONS, "video_window_show_decorations") +MSG_HASH(MENU_ENUM_LABEL_VIDEO_WINDOW_SAVE_POSITION, + "video_window_save_position") MSG_HASH(MENU_ENUM_LABEL_MENU_RGUI_BORDER_FILLER_ENABLE, "menu_rgui_border_filler_enable") MSG_HASH(MENU_ENUM_LABEL_MENU_RGUI_BORDER_FILLER_THICKNESS_ENABLE, diff --git a/intl/msg_hash_nl.h b/intl/msg_hash_nl.h index b32f6d954e..2082e58e64 100644 --- a/intl/msg_hash_nl.h +++ b/intl/msg_hash_nl.h @@ -3381,3 +3381,5 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_FAVORITES_AVAILABLE, "Geen favorieten beschikbaar." ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, + "Save Window Positions") diff --git a/intl/msg_hash_pl.h b/intl/msg_hash_pl.h index 882a39f1bc..979e87a539 100644 --- a/intl/msg_hash_pl.h +++ b/intl/msg_hash_pl.h @@ -3797,3 +3797,5 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_FAVORITES_AVAILABLE, "Brak ulubionych." ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, + "Save Window Positions") diff --git a/intl/msg_hash_pt_br.h b/intl/msg_hash_pt_br.h index adcad4badf..0492c6eaeb 100644 --- a/intl/msg_hash_pt_br.h +++ b/intl/msg_hash_pt_br.h @@ -7779,4 +7779,6 @@ MSG_HASH( MSG_HASH( MSG_MISSING_ASSETS, "Aviso: Recursos ausentes, use o Atualizador Online se disponível" - ) \ No newline at end of file + ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, + "Save Window Positions") diff --git a/intl/msg_hash_pt_pt.h b/intl/msg_hash_pt_pt.h index 056b071dca..e7f6ab56e4 100644 --- a/intl/msg_hash_pt_pt.h +++ b/intl/msg_hash_pt_pt.h @@ -3461,3 +3461,5 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_FAVORITES_AVAILABLE, "No favorites available." ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, + "Save Window Positions") diff --git a/intl/msg_hash_ru.h b/intl/msg_hash_ru.h index 51bb95d1de..388844764c 100644 --- a/intl/msg_hash_ru.h +++ b/intl/msg_hash_ru.h @@ -3664,3 +3664,5 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_FAVORITES_AVAILABLE, "No favorites available." ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, + "Save Window Positions") diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 9a4ae85a39..5b2f9e522b 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -7779,4 +7779,6 @@ MSG_HASH( MSG_HASH( MSG_MISSING_ASSETS, "Warning: Missing assets, use the Online Updater if available" - ) \ No newline at end of file + ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, + "Save Window Positions") diff --git a/intl/msg_hash_vn.h b/intl/msg_hash_vn.h index 56937789be..a009077a26 100644 --- a/intl/msg_hash_vn.h +++ b/intl/msg_hash_vn.h @@ -3534,3 +3534,5 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_FAVORITES_AVAILABLE, "No favorites available." ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, + "Save Window Positions") diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index c009494f51..865980f621 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -6621,6 +6621,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_VIDEO_WINDOW_SHOW_DECORATIONS, PARSE_ONLY_BOOL, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_VIDEO_WINDOW_SAVE_POSITION, + PARSE_ONLY_BOOL, false); menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_VIDEO_SCALE_INTEGER, PARSE_ONLY_BOOL, false); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index cd1904ea0d..b55e28a2c5 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -5516,6 +5516,21 @@ static bool setting_append_list( SD_FLAG_NONE); menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_REINIT); + CONFIG_BOOL( + list, list_info, + &settings->bools.video_window_save_positions, + MENU_ENUM_LABEL_VIDEO_WINDOW_SAVE_POSITION, + MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, + false, + MENU_ENUM_LABEL_VALUE_OFF, + MENU_ENUM_LABEL_VALUE_ON, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler, + SD_FLAG_NONE); + CONFIG_BOOL( list, list_info, &settings->bools.video_scale_integer, diff --git a/msg_hash.h b/msg_hash.h index 1351b68b7a..e457eb3c30 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1941,6 +1941,7 @@ enum msg_hash_enums MENU_LABEL(NETPLAY_USE_MITM_SERVER), MENU_LABEL(NETPLAY_MITM_SERVER), MENU_LABEL(VIDEO_WINDOW_SHOW_DECORATIONS), + MENU_LABEL(VIDEO_WINDOW_SAVE_POSITION), MENU_ENUM_LABEL_VALUE_QT_INFO, MENU_ENUM_LABEL_VALUE_QT_MENU_FILE, From cc4f834d7419b9c2a4203d79a3b1ca8508d4d765 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 25 Nov 2018 09:08:43 +0100 Subject: [PATCH 046/153] Rename string to 'Remember Window Positions' --- intl/msg_hash_ar.h | 2 +- intl/msg_hash_chs.h | 2 +- intl/msg_hash_cht.h | 2 +- intl/msg_hash_de.h | 2 +- intl/msg_hash_el.h | 2 +- intl/msg_hash_eo.h | 2 +- intl/msg_hash_es.h | 2 +- intl/msg_hash_fr.h | 2 +- intl/msg_hash_it.h | 2 +- intl/msg_hash_ja.h | 2 +- intl/msg_hash_ko.h | 2 +- intl/msg_hash_nl.h | 2 +- intl/msg_hash_pl.h | 2 +- intl/msg_hash_pt_br.h | 2 +- intl/msg_hash_pt_pt.h | 2 +- intl/msg_hash_ru.h | 2 +- intl/msg_hash_us.h | 2 +- intl/msg_hash_vn.h | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/intl/msg_hash_ar.h b/intl/msg_hash_ar.h index 1845a492d9..4231e13b4b 100644 --- a/intl/msg_hash_ar.h +++ b/intl/msg_hash_ar.h @@ -3723,4 +3723,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Save Window Positions") + "Remember Window Positions") diff --git a/intl/msg_hash_chs.h b/intl/msg_hash_chs.h index 15b4897550..d9cf167985 100644 --- a/intl/msg_hash_chs.h +++ b/intl/msg_hash_chs.h @@ -4750,4 +4750,4 @@ MSG_HASH( "Warning: Missing assets, use the Online Updater if available" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Save Window Positions") + "Remember Window Positions") diff --git a/intl/msg_hash_cht.h b/intl/msg_hash_cht.h index 684cee966b..6718972493 100644 --- a/intl/msg_hash_cht.h +++ b/intl/msg_hash_cht.h @@ -3501,4 +3501,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Save Window Positions") + "Remember Window Positions") diff --git a/intl/msg_hash_de.h b/intl/msg_hash_de.h index b9545d62c5..0ba3a04029 100644 --- a/intl/msg_hash_de.h +++ b/intl/msg_hash_de.h @@ -3637,4 +3637,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Save Window Positions") + "Remember Window Positions") diff --git a/intl/msg_hash_el.h b/intl/msg_hash_el.h index dde7d94f57..6e080a7c78 100644 --- a/intl/msg_hash_el.h +++ b/intl/msg_hash_el.h @@ -7731,4 +7731,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Save Window Positions") + "Remember Window Positions") diff --git a/intl/msg_hash_eo.h b/intl/msg_hash_eo.h index 949bf7f894..80e3e3c412 100644 --- a/intl/msg_hash_eo.h +++ b/intl/msg_hash_eo.h @@ -3376,4 +3376,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Save Window Positions") + "Remember Window Positions") diff --git a/intl/msg_hash_es.h b/intl/msg_hash_es.h index c90bb1e917..e4c0f02968 100644 --- a/intl/msg_hash_es.h +++ b/intl/msg_hash_es.h @@ -7749,4 +7749,4 @@ MSG_HASH( "ADVERTENCIA: Faltan recursos, use el Actualizador si está disponible" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Save Window Positions") + "Remember Window Positions") diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index 1d49b75509..a6d00bcdc7 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -3535,4 +3535,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Save Window Positions") + "Remember Window Positions") diff --git a/intl/msg_hash_it.h b/intl/msg_hash_it.h index 101c33f6d2..a9584919b0 100644 --- a/intl/msg_hash_it.h +++ b/intl/msg_hash_it.h @@ -3595,4 +3595,4 @@ MSG_HASH( "Nessun preferito disponibile." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Save Window Positions") + "Remember Window Positions") diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index 6ec2dd4c08..f71fddf035 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -4044,4 +4044,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Save Window Positions") + "Remember Window Positions") diff --git a/intl/msg_hash_ko.h b/intl/msg_hash_ko.h index d137039946..76127c76fd 100644 --- a/intl/msg_hash_ko.h +++ b/intl/msg_hash_ko.h @@ -3496,4 +3496,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Save Window Positions") + "Remember Window Positions") diff --git a/intl/msg_hash_nl.h b/intl/msg_hash_nl.h index 2082e58e64..c843570f03 100644 --- a/intl/msg_hash_nl.h +++ b/intl/msg_hash_nl.h @@ -3382,4 +3382,4 @@ MSG_HASH( "Geen favorieten beschikbaar." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Save Window Positions") + "Remember Window Positions") diff --git a/intl/msg_hash_pl.h b/intl/msg_hash_pl.h index 979e87a539..924afd0a8e 100644 --- a/intl/msg_hash_pl.h +++ b/intl/msg_hash_pl.h @@ -3798,4 +3798,4 @@ MSG_HASH( "Brak ulubionych." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Save Window Positions") + "Remember Window Positions") diff --git a/intl/msg_hash_pt_br.h b/intl/msg_hash_pt_br.h index 0492c6eaeb..b1c799e9cf 100644 --- a/intl/msg_hash_pt_br.h +++ b/intl/msg_hash_pt_br.h @@ -7781,4 +7781,4 @@ MSG_HASH( "Aviso: Recursos ausentes, use o Atualizador Online se disponível" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Save Window Positions") + "Remember Window Positions") diff --git a/intl/msg_hash_pt_pt.h b/intl/msg_hash_pt_pt.h index e7f6ab56e4..24f37afc9b 100644 --- a/intl/msg_hash_pt_pt.h +++ b/intl/msg_hash_pt_pt.h @@ -3462,4 +3462,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Save Window Positions") + "Remember Window Positions") diff --git a/intl/msg_hash_ru.h b/intl/msg_hash_ru.h index 388844764c..df76bbb7f1 100644 --- a/intl/msg_hash_ru.h +++ b/intl/msg_hash_ru.h @@ -3665,4 +3665,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Save Window Positions") + "Remember Window Positions") diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 5b2f9e522b..fc3ec43e66 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -7781,4 +7781,4 @@ MSG_HASH( "Warning: Missing assets, use the Online Updater if available" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Save Window Positions") + "Remember Window Positions") diff --git a/intl/msg_hash_vn.h b/intl/msg_hash_vn.h index a009077a26..fcc90e9f8e 100644 --- a/intl/msg_hash_vn.h +++ b/intl/msg_hash_vn.h @@ -3535,4 +3535,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Save Window Positions") + "Remember Window Positions") From 5313c50b0e14e45cfc29d72824b67d7faf60f22a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 25 Nov 2018 09:50:08 +0100 Subject: [PATCH 047/153] (Windows) Saves/remembers window size now too - still some edge case when clicking maximize button - you need to then move the window slightly in order for x/y position to be saved - just clicking maximize alone is not enough --- configuration.c | 2 ++ configuration.h | 2 ++ gfx/common/win32_common.c | 61 ++++++++++++++++++++++++++++++++------- 3 files changed, 54 insertions(+), 11 deletions(-) diff --git a/configuration.c b/configuration.c index a7476b318f..d416670772 100644 --- a/configuration.c +++ b/configuration.c @@ -1675,6 +1675,8 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings, SETTING_UINT("video_stream_scale_factor", &settings->uints.video_stream_scale_factor, true, 1, false); SETTING_UINT("video_windowed_position_x", &settings->uints.window_position_x, true, 0, false); SETTING_UINT("video_windowed_position_y", &settings->uints.window_position_y, true, 0, false); + SETTING_UINT("video_windowed_position_width", &settings->uints.window_position_width, true, 0, false); + SETTING_UINT("video_windowed_position_height", &settings->uints.window_position_height, true, 0, false); *size = count; diff --git a/configuration.h b/configuration.h index 8ba5ba8c7c..89b65c52b6 100644 --- a/configuration.h +++ b/configuration.h @@ -443,6 +443,8 @@ typedef struct settings unsigned window_position_x; unsigned window_position_y; + unsigned window_position_width; + unsigned window_position_height; } uints; struct diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 137c74957f..900dec62d6 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -200,6 +200,8 @@ static bool g_win32_quit = false; static int g_win32_pos_x = CW_USEDEFAULT; static int g_win32_pos_y = CW_USEDEFAULT; +static unsigned g_win32_pos_width = 0; +static unsigned g_win32_pos_height = 0; unsigned g_win32_resize_width = 0; unsigned g_win32_resize_height = 0; @@ -617,8 +619,21 @@ static LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, } #endif +static void win32_set_position_from_config(void) +{ + settings_t *settings = config_get_ptr(); + if (!settings->bools.video_window_save_positions) + return; + + g_win32_pos_x = settings->uints.window_position_x; + g_win32_pos_y = settings->uints.window_position_y; + g_win32_pos_width = settings->uints.window_position_width; + g_win32_pos_height= settings->uints.window_position_height; +} + static void win32_save_position(void) { + RECT rect; WINDOWPLACEMENT placement; settings_t *settings = config_get_ptr(); memset(&placement, 0, sizeof(placement)); @@ -628,10 +643,18 @@ static void win32_save_position(void) g_win32_pos_x = placement.rcNormalPosition.left; g_win32_pos_y = placement.rcNormalPosition.top; + + if (GetWindowRect(main_window.hwnd, &rect)) + { + g_win32_pos_width = rect.right - rect.left; + g_win32_pos_height = rect.bottom - rect.top; + } if (settings && settings->bools.video_window_save_positions) { - settings->uints.window_position_x = g_win32_pos_x; - settings->uints.window_position_y = g_win32_pos_y; + settings->uints.window_position_x = g_win32_pos_x; + settings->uints.window_position_y = g_win32_pos_y; + settings->uints.window_position_width = g_win32_pos_width; + settings->uints.window_position_height= g_win32_pos_height; } } @@ -652,6 +675,7 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message, *quit = true; break; } + win32_save_position(); break; case WM_DROPFILES: { @@ -935,17 +959,16 @@ bool win32_window_create(void *data, unsigned style, #endif settings_t *settings = config_get_ptr(); #ifndef _XBOX - if (settings->bools.video_window_save_positions) - { - g_win32_pos_x = settings->uints.window_position_x; - g_win32_pos_y = settings->uints.window_position_y; - } + win32_set_position_from_config(); main_window.hwnd = CreateWindowEx(0, "RetroArch", "RetroArch", style, fullscreen ? mon_rect->left : g_win32_pos_x, fullscreen ? mon_rect->top : g_win32_pos_y, - width, height, + (settings->bools.video_window_save_positions) ? g_win32_pos_width : + width, + (settings->bools.video_window_save_positions) ? g_win32_pos_height : + height, NULL, NULL, NULL, data); if (!main_window.hwnd) return false; @@ -1161,9 +1184,10 @@ void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use, RECT *rect, RECT *mon_rect, DWORD *style) { #if !defined(_XBOX) + bool position_set_from_config = false; + settings_t *settings = config_get_ptr(); if (fullscreen) { - settings_t *settings = config_get_ptr(); /* Windows only reports the refresh rates for modelines as * an integer, so video_refresh_rate needs to be rounded. Also, account * for black frame insertion using video_refresh_rate set to half @@ -1198,8 +1222,23 @@ void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use, AdjustWindowRect(rect, *style, FALSE); - g_win32_resize_width = *width = rect->right - rect->left; - g_win32_resize_height = *height = rect->bottom - rect->top; + if (settings->bools.video_window_save_positions) + { + win32_set_position_from_config(); + if (g_win32_pos_width != 0 && g_win32_pos_height != 0) + position_set_from_config = true; + } + + if (position_set_from_config) + { + g_win32_resize_width = *width = g_win32_pos_width; + g_win32_resize_height = *height = g_win32_pos_height; + } + else + { + g_win32_resize_width = *width = rect->right - rect->left; + g_win32_resize_height = *height = rect->bottom - rect->top; + } } #endif } From 4a4a6511e0bf26d684ecf74a1dd102abc7b0db48 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 25 Nov 2018 10:08:50 +0100 Subject: [PATCH 048/153] Workaround - fullscreen mode was no longer working properly --- gfx/common/win32_common.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 900dec62d6..7f7aa3861e 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -959,16 +959,23 @@ bool win32_window_create(void *data, unsigned style, #endif settings_t *settings = config_get_ptr(); #ifndef _XBOX + unsigned user_width = width; + unsigned user_height = height; win32_set_position_from_config(); + + if (settings->bools.video_window_save_positions + && !fullscreen) + { + user_width = g_win32_pos_width; + user_height= g_win32_pos_height; + } main_window.hwnd = CreateWindowEx(0, "RetroArch", "RetroArch", style, fullscreen ? mon_rect->left : g_win32_pos_x, fullscreen ? mon_rect->top : g_win32_pos_y, - (settings->bools.video_window_save_positions) ? g_win32_pos_width : - width, - (settings->bools.video_window_save_positions) ? g_win32_pos_height : - height, + user_width, + user_height, NULL, NULL, NULL, data); if (!main_window.hwnd) return false; From 44ae11ee605f0f40e47a2dfd090a1791c718672b Mon Sep 17 00:00:00 2001 From: natinusala Date: Sun, 25 Nov 2018 15:46:41 +0100 Subject: [PATCH 049/153] ozone: fix toggle crash and cheevos badges opacity --- menu/drivers/ozone/ozone_entries.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/menu/drivers/ozone/ozone_entries.c b/menu/drivers/ozone/ozone_entries.c index 7fb8ba0814..bb166168d8 100644 --- a/menu/drivers/ozone/ozone_entries.c +++ b/menu/drivers/ozone/ozone_entries.c @@ -244,7 +244,7 @@ border_iterate: sublabel_str = menu_entry_get_sublabel(&entry); - if (node->wrap) + if (node->wrap && sublabel_str) word_wrap(sublabel_str, sublabel_str, (video_info->width - 548) / ozone->sublabel_font_glyph_width, false); /* Icon */ @@ -271,19 +271,28 @@ border_iterate: )) { icon_color = ozone->theme_dynamic.entries_icon; - ozone_color_alpha(ozone->theme_dynamic.entries_icon, alpha); } + else + { + icon_color = ozone_pure_white; + } + + ozone_color_alpha(icon_color, alpha); menu_display_blend_begin(video_info); ozone_draw_icon(video_info, 46, 46, texture, x_offset + 451+5+10, y + scroll_y, video_info->width, video_info->height, 0, 1, icon_color); menu_display_blend_end(video_info); + if (icon_color == ozone_pure_white) + ozone_color_alpha(icon_color, 1.0f); + text_offset = 0; } /* Draw text */ ozone_draw_text(video_info, ozone, rich_label, text_offset + x_offset + 521, y + FONT_SIZE_ENTRIES_LABEL + 8 - 1 + scroll_y, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.entries_label, COLOR_TEXT_ALPHA(ozone->theme->text_rgba, alpha_uint32), false); - ozone_draw_text(video_info, ozone, sublabel_str, x_offset + 470, y + FONT_SIZE_ENTRIES_SUBLABEL + 80 - 20 - 3 + scroll_y, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.entries_sublabel, COLOR_TEXT_ALPHA(ozone->theme->text_sublabel_rgba, alpha_uint32), false); + if (sublabel_str) + ozone_draw_text(video_info, ozone, sublabel_str, x_offset + 470, y + FONT_SIZE_ENTRIES_SUBLABEL + 80 - 20 - 3 + scroll_y, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.entries_sublabel, COLOR_TEXT_ALPHA(ozone->theme->text_sublabel_rgba, alpha_uint32), false); /* Value */ ticker.idx = ozone->frame_count / 20; @@ -296,7 +305,9 @@ border_iterate: ozone_draw_entry_value(ozone, video_info, entry_value_ticker, x_offset + 426 + entry_width, y + FONT_SIZE_ENTRIES_LABEL + 8 - 1 + scroll_y,alpha_uint32, &entry); free(entry_rich_label); - free(sublabel_str); + + if (sublabel_str) + free(sublabel_str); icons_iterate: y += node->height; From 8b86c49b39a46f02c4d166f20c7da4f168b188a1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 25 Nov 2018 17:06:55 +0100 Subject: [PATCH 050/153] Fix some warnings --- gfx/display_servers/dispserv_x11.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index d82014caa4..268a0cb79f 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -29,7 +29,7 @@ static char old_mode[250] = {0}; static char new_mode[250] = {0}; static char xrandr[250] = {0}; static char fbset[150] = {0}; -static char output[250] = {0}; +static char output[500] = {0}; static bool crt_en = false; typedef struct @@ -277,7 +277,7 @@ static bool x11_display_server_set_resolution(void *data, return true; } -const char *x11_display_server_get_output_options(void) +const char *x11_display_server_get_output_options(void *data) { /* TODO/FIXME - hardcoded for now; list should be built up dynamically later */ return "HDMI-0|HDMI-1|HDMI-2|HDMI-3|DVI-0|DVI-1|DVI-2|DVI-3|VGA-0|VGA-1|VGA-2|VGA-3|Config"; From 418f28b57a954a1ad51dbe833a87fb11adde7d33 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 25 Nov 2018 17:09:00 +0100 Subject: [PATCH 051/153] (dispserv_x11.c) Use snprintf instead of sprintf --- gfx/display_servers/dispserv_x11.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index 268a0cb79f..29a13fec55 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -55,23 +55,28 @@ static void x11_display_server_destroy(void *data) if (crt_en) { - sprintf(output, "xrandr -s %dx%d", orig_width, orig_height); + snprintf(output, sizeof(output), + "xrandr -s %dx%d", orig_width, orig_height); system(output); for (i = 0; i < 3; i++) { - sprintf(output, "xrandr --delmode %s%d %s", "VGA", i, old_mode); + snprintf(output, sizeof(output), + "xrandr --delmode %s%d %s", "VGA", i, old_mode); system(output); - sprintf(output, "xrandr --delmode %s-%d %s", "VGA", i, old_mode); + snprintf(output, sizeof(output), + "xrandr --delmode %s-%d %s", "VGA", i, old_mode); system(output); - sprintf(output, "xrandr --delmode %s%d %s", "DVI", i, old_mode); + snprintf(output, sizeof(output), + "xrandr --delmode %s%d %s", "DVI", i, old_mode); system(output); - sprintf(output, "xrandr --delmode %s-%d %s", "DVI", i, old_mode); + snprintf(output, sizeof(output), + "xrandr --delmode %s-%d %s", "DVI", i, old_mode); system(output); } - sprintf(output, "xrandr --rmmode %s", old_mode); + snprintf(output, sizeof(output), "xrandr --rmmode %s", old_mode); system(output); } From c2fc35f2cc6004840e7e4be28bf985da77050f73 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 25 Nov 2018 11:06:50 -0500 Subject: [PATCH 052/153] repurpose the old settings to the new window sizing code --- config.def.h | 4 ++-- configuration.c | 6 ++---- configuration.h | 2 -- gfx/video_driver.c | 22 +++++++--------------- intl/msg_hash_ar.h | 2 +- intl/msg_hash_chs.h | 2 +- intl/msg_hash_cht.h | 2 +- intl/msg_hash_de.h | 2 +- intl/msg_hash_el.h | 2 +- intl/msg_hash_eo.h | 2 +- intl/msg_hash_es.h | 2 +- intl/msg_hash_fr.h | 2 +- intl/msg_hash_it.h | 2 +- intl/msg_hash_ja.h | 2 +- intl/msg_hash_ko.h | 2 +- intl/msg_hash_nl.h | 2 +- intl/msg_hash_pl.h | 2 +- intl/msg_hash_pt_br.h | 2 +- intl/msg_hash_pt_pt.h | 2 +- intl/msg_hash_ru.h | 2 +- intl/msg_hash_us.h | 8 ++++++-- intl/msg_hash_vn.h | 2 +- menu/cbs/menu_cbs_sublabel.c | 4 ++++ menu/drivers/nuklear/nk_common.c | 4 ++-- menu/menu_displaylist.c | 16 ++++++++-------- menu/menu_setting.c | 8 ++++---- 26 files changed, 52 insertions(+), 56 deletions(-) diff --git a/config.def.h b/config.def.h index f0ee60d58b..618fba6174 100644 --- a/config.def.h +++ b/config.def.h @@ -117,8 +117,8 @@ static const unsigned monitor_index = 0; /* Window */ /* Window size. A value of 0 uses window scale * multiplied by the core framebuffer size. */ -static const unsigned window_x = 0; -static const unsigned window_y = 0; +static const unsigned window_width = 1280; +static const unsigned window_height = 720; /* Fullscreen resolution. A value of 0 uses the desktop * resolution. */ diff --git a/configuration.c b/configuration.c index d416670772..947011d30f 100644 --- a/configuration.c +++ b/configuration.c @@ -1590,8 +1590,6 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings, SETTING_UINT("video_monitor_index", &settings->uints.video_monitor_index, true, monitor_index, false); SETTING_UINT("video_fullscreen_x", &settings->uints.video_fullscreen_x, true, fullscreen_x, false); SETTING_UINT("video_fullscreen_y", &settings->uints.video_fullscreen_y, true, fullscreen_y, false); - SETTING_UINT("video_window_x", &settings->uints.video_window_x, true, fullscreen_x, false); - SETTING_UINT("video_window_y", &settings->uints.video_window_y, true, fullscreen_y, false); SETTING_UINT("video_window_opacity", &settings->uints.video_window_opacity, true, window_opacity, false); #ifdef HAVE_COMMAND SETTING_UINT("network_cmd_port", &settings->uints.network_cmd_port, true, network_cmd_port, false); @@ -1675,8 +1673,8 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings, SETTING_UINT("video_stream_scale_factor", &settings->uints.video_stream_scale_factor, true, 1, false); SETTING_UINT("video_windowed_position_x", &settings->uints.window_position_x, true, 0, false); SETTING_UINT("video_windowed_position_y", &settings->uints.window_position_y, true, 0, false); - SETTING_UINT("video_windowed_position_width", &settings->uints.window_position_width, true, 0, false); - SETTING_UINT("video_windowed_position_height", &settings->uints.window_position_height, true, 0, false); + SETTING_UINT("video_windowed_position_width", &settings->uints.window_position_width, true, window_width, false); + SETTING_UINT("video_windowed_position_height", &settings->uints.window_position_height, true, window_height, false); *size = count; diff --git a/configuration.h b/configuration.h index 89b65c52b6..7555118d62 100644 --- a/configuration.h +++ b/configuration.h @@ -373,8 +373,6 @@ typedef struct settings unsigned network_cmd_port; unsigned network_remote_base_port; unsigned keymapper_port; - unsigned video_window_x; - unsigned video_window_y; unsigned video_window_opacity; unsigned crt_switch_resolution; unsigned crt_switch_resolution_super; diff --git a/gfx/video_driver.c b/gfx/video_driver.c index aae7a7c4c3..c3157f8c6c 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -985,24 +985,16 @@ static bool video_driver_init_internal(bool *video_is_threaded) } else { - if (settings->uints.video_window_x || settings->uints.video_window_y) + if (settings->bools.video_force_aspect) { - width = settings->uints.video_window_x; - height = settings->uints.video_window_y; + /* Do rounding here to simplify integer scale correctness. */ + unsigned base_width = + roundf(geom->base_height * video_driver_get_aspect_ratio()); + width = roundf(base_width * settings->floats.video_scale); } else - { - if (settings->bools.video_force_aspect) - { - /* Do rounding here to simplify integer scale correctness. */ - unsigned base_width = - roundf(geom->base_height * video_driver_get_aspect_ratio()); - width = roundf(base_width * settings->floats.video_scale); - } - else - width = roundf(geom->base_width * settings->floats.video_scale); - height = roundf(geom->base_height * settings->floats.video_scale); - } + width = roundf(geom->base_width * settings->floats.video_scale); + height = roundf(geom->base_height * settings->floats.video_scale); } if (width && height) diff --git a/intl/msg_hash_ar.h b/intl/msg_hash_ar.h index 4231e13b4b..9a9163aa47 100644 --- a/intl/msg_hash_ar.h +++ b/intl/msg_hash_ar.h @@ -3723,4 +3723,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Remember Window Positions") + "Remember Window Position and Size") diff --git a/intl/msg_hash_chs.h b/intl/msg_hash_chs.h index d9cf167985..13f6fbb55a 100644 --- a/intl/msg_hash_chs.h +++ b/intl/msg_hash_chs.h @@ -4750,4 +4750,4 @@ MSG_HASH( "Warning: Missing assets, use the Online Updater if available" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Remember Window Positions") + "Remember Window Position and Size") diff --git a/intl/msg_hash_cht.h b/intl/msg_hash_cht.h index 6718972493..f619da864f 100644 --- a/intl/msg_hash_cht.h +++ b/intl/msg_hash_cht.h @@ -3501,4 +3501,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Remember Window Positions") + "Remember Window Position and Size") diff --git a/intl/msg_hash_de.h b/intl/msg_hash_de.h index 0ba3a04029..3a6c051535 100644 --- a/intl/msg_hash_de.h +++ b/intl/msg_hash_de.h @@ -3637,4 +3637,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Remember Window Positions") + "Remember Window Position and Size") diff --git a/intl/msg_hash_el.h b/intl/msg_hash_el.h index 6e080a7c78..4a1a64116c 100644 --- a/intl/msg_hash_el.h +++ b/intl/msg_hash_el.h @@ -7731,4 +7731,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Remember Window Positions") + "Remember Window Position and Size") diff --git a/intl/msg_hash_eo.h b/intl/msg_hash_eo.h index 80e3e3c412..4069f0cb2f 100644 --- a/intl/msg_hash_eo.h +++ b/intl/msg_hash_eo.h @@ -3376,4 +3376,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Remember Window Positions") + "Remember Window Position and Size") diff --git a/intl/msg_hash_es.h b/intl/msg_hash_es.h index e4c0f02968..d60e909750 100644 --- a/intl/msg_hash_es.h +++ b/intl/msg_hash_es.h @@ -7749,4 +7749,4 @@ MSG_HASH( "ADVERTENCIA: Faltan recursos, use el Actualizador si está disponible" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Remember Window Positions") + "Remember Window Position and Size") diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index a6d00bcdc7..0d2de27a1b 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -3535,4 +3535,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Remember Window Positions") + "Remember Window Position and Size") diff --git a/intl/msg_hash_it.h b/intl/msg_hash_it.h index a9584919b0..053e67d894 100644 --- a/intl/msg_hash_it.h +++ b/intl/msg_hash_it.h @@ -3595,4 +3595,4 @@ MSG_HASH( "Nessun preferito disponibile." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Remember Window Positions") + "Remember Window Position and Size") diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index f71fddf035..e0619ed04d 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -4044,4 +4044,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Remember Window Positions") + "Remember Window Position and Size") diff --git a/intl/msg_hash_ko.h b/intl/msg_hash_ko.h index 76127c76fd..1a16c5793d 100644 --- a/intl/msg_hash_ko.h +++ b/intl/msg_hash_ko.h @@ -3496,4 +3496,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Remember Window Positions") + "Remember Window Position and Size") diff --git a/intl/msg_hash_nl.h b/intl/msg_hash_nl.h index c843570f03..3f169052d4 100644 --- a/intl/msg_hash_nl.h +++ b/intl/msg_hash_nl.h @@ -3382,4 +3382,4 @@ MSG_HASH( "Geen favorieten beschikbaar." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Remember Window Positions") + "Remember Window Position and Size") diff --git a/intl/msg_hash_pl.h b/intl/msg_hash_pl.h index 924afd0a8e..e510a17a18 100644 --- a/intl/msg_hash_pl.h +++ b/intl/msg_hash_pl.h @@ -3798,4 +3798,4 @@ MSG_HASH( "Brak ulubionych." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Remember Window Positions") + "Remember Window Position and Size") diff --git a/intl/msg_hash_pt_br.h b/intl/msg_hash_pt_br.h index b1c799e9cf..c63c4404f9 100644 --- a/intl/msg_hash_pt_br.h +++ b/intl/msg_hash_pt_br.h @@ -7781,4 +7781,4 @@ MSG_HASH( "Aviso: Recursos ausentes, use o Atualizador Online se disponível" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Remember Window Positions") + "Remember Window Position and Size") diff --git a/intl/msg_hash_pt_pt.h b/intl/msg_hash_pt_pt.h index 24f37afc9b..6aa36f56d5 100644 --- a/intl/msg_hash_pt_pt.h +++ b/intl/msg_hash_pt_pt.h @@ -3462,4 +3462,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Remember Window Positions") + "Remember Window Position and Size") diff --git a/intl/msg_hash_ru.h b/intl/msg_hash_ru.h index df76bbb7f1..51d2ef1e6f 100644 --- a/intl/msg_hash_ru.h +++ b/intl/msg_hash_ru.h @@ -3665,4 +3665,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Remember Window Positions") + "Remember Window Position and Size") diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index fc3ec43e66..c7ac4fc74f 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -4886,11 +4886,15 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_WINDOW_WIDTH, - "Set the custom width size for the display window. Leaving it at 0 will attempt to scale the window as large as possible." + "Set the custom width for the display window." ) MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_WINDOW_HEIGHT, - "Set the custom height size for the display window. Leaving it at 0 will attempt to scale the window as large as possible." + "Set the custom height for the display window." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_WINDOW_SAVE_POSITION, + "Remember window size and position, enabling this has precedence over Windowed Scale" ) MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN_X, diff --git a/intl/msg_hash_vn.h b/intl/msg_hash_vn.h index fcc90e9f8e..79a6cdb8d7 100644 --- a/intl/msg_hash_vn.h +++ b/intl/msg_hash_vn.h @@ -3535,4 +3535,4 @@ MSG_HASH( "No favorites available." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Remember Window Positions") + "Remember Window Position and Size") diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index c4ff5f6cf5..34c9259106 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -194,6 +194,7 @@ default_sublabel_macro(action_bind_sublabel_video_window_width, MENU_ default_sublabel_macro(action_bind_sublabel_video_window_height, MENU_ENUM_SUBLABEL_VIDEO_WINDOW_HEIGHT) default_sublabel_macro(action_bind_sublabel_video_fullscreen_x, MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN_X) default_sublabel_macro(action_bind_sublabel_video_fullscreen_y, MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN_Y) +default_sublabel_macro(action_bind_sublabel_video_save_window_position, MENU_ENUM_SUBLABEL_VIDEO_WINDOW_SAVE_POSITION) default_sublabel_macro(action_bind_sublabel_video_message_pos_x, MENU_ENUM_SUBLABEL_VIDEO_MESSAGE_POS_X) default_sublabel_macro(action_bind_sublabel_video_message_pos_y, MENU_ENUM_SUBLABEL_VIDEO_MESSAGE_POS_Y) default_sublabel_macro(action_bind_sublabel_video_font_size, MENU_ENUM_SUBLABEL_VIDEO_FONT_SIZE) @@ -1624,6 +1625,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_VIDEO_FULLSCREEN_Y: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_fullscreen_y); break; + case MENU_ENUM_LABEL_VIDEO_WINDOW_SAVE_POSITION: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_save_window_position); + break; case MENU_ENUM_LABEL_QUIT_RETROARCH: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_quit_retroarch); break; diff --git a/menu/drivers/nuklear/nk_common.c b/menu/drivers/nuklear/nk_common.c index 67323c0cf1..61800585fd 100644 --- a/menu/drivers/nuklear/nk_common.c +++ b/menu/drivers/nuklear/nk_common.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * Copyright (C) 2014-2017 - Jean-Andr� Santoni - * Copyright (C) 2016-2017 - Andr�s Su�rez + * Copyright (C) 2014-2017 - Jean-André Santoni + * Copyright (C) 2016-2017 - Andrés Suárez * * 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/menu/menu_displaylist.c b/menu/menu_displaylist.c index 865980f621..73e3f6e744 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * Copyright (C) 2014-2017 - Jean-Andr Santoni - * Copyright (C) 2015-2017 - Andrs Surez + * Copyright (C) 2014-2017 - Jean-André Santoni + * Copyright (C) 2015-2017 - Andrés Suárez * Copyright (C) 2016-2017 - Brad Parker * * RetroArch is free software: you can redistribute it and/or modify it under the terms @@ -6609,12 +6609,6 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_VIDEO_SCALE, PARSE_ONLY_FLOAT, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_VIDEO_WINDOW_WIDTH, - PARSE_ONLY_UINT, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_VIDEO_WINDOW_HEIGHT, - PARSE_ONLY_UINT, false); menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_VIDEO_WINDOW_OPACITY, PARSE_ONLY_UINT, false); @@ -6624,6 +6618,12 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_VIDEO_WINDOW_SAVE_POSITION, PARSE_ONLY_BOOL, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_VIDEO_WINDOW_WIDTH, + PARSE_ONLY_UINT, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_VIDEO_WINDOW_HEIGHT, + PARSE_ONLY_UINT, false); menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_VIDEO_SCALE_INTEGER, PARSE_ONLY_BOOL, false); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index b55e28a2c5..1d76dedf57 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -5457,10 +5457,10 @@ static bool setting_append_list( settings_data_list_current_add_flags(list, list_info, SD_FLAG_LAKKA_ADVANCED); CONFIG_UINT( list, list_info, - &settings->uints.video_window_x, + &settings->uints.window_position_width, MENU_ENUM_LABEL_VIDEO_WINDOW_WIDTH, MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_WIDTH, - 0, + window_width, &group_info, &subgroup_info, parent_group, @@ -5471,10 +5471,10 @@ static bool setting_append_list( settings_data_list_current_add_flags(list, list_info, SD_FLAG_LAKKA_ADVANCED); CONFIG_UINT( list, list_info, - &settings->uints.video_window_y, + &settings->uints.window_position_height, MENU_ENUM_LABEL_VIDEO_WINDOW_HEIGHT, MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_HEIGHT, - 0, + window_height, &group_info, &subgroup_info, parent_group, From a4479e67385400738bf997608804387916d2c113 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 25 Nov 2018 11:39:05 -0500 Subject: [PATCH 053/153] pack the fullscreen settings together --- intl/msg_hash_ar.h | 4 ++-- intl/msg_hash_cht.h | 4 ++-- intl/msg_hash_el.h | 4 ++-- intl/msg_hash_eo.h | 4 ++-- intl/msg_hash_nl.h | 4 ++-- intl/msg_hash_us.h | 4 ++-- intl/msg_hash_vn.h | 4 ++-- menu/menu_displaylist.c | 6 +++--- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/intl/msg_hash_ar.h b/intl/msg_hash_ar.h index 9a9163aa47..865fd63e2b 100644 --- a/intl/msg_hash_ar.h +++ b/intl/msg_hash_ar.h @@ -2669,9 +2669,9 @@ MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_WINDOW_WIDTH, MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_WINDOW_HEIGHT, "Set the custom height size for the display window. Leaving it at 0 will attempt to scale the window as large as possible.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN_X, - "Set the custom width size for the non-windowed fullscreen mode. Leaving it at 0 will use the desktop resolution.") + "Set the custom width size for the non-windowed fullscreen mode. Leaving it unset will use the desktop resolution.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN_Y, - "Set the custom height size for the non-windowed fullscreen mode. Leaving it at 0 will use the desktop resolution") + "Set the custom height size for the non-windowed fullscreen mode. Leaving it unset will use the desktop resolution.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_MESSAGE_POS_X, "Specify custom X axis position for onscreen text.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_MESSAGE_POS_Y, diff --git a/intl/msg_hash_cht.h b/intl/msg_hash_cht.h index f619da864f..ad767dcb25 100644 --- a/intl/msg_hash_cht.h +++ b/intl/msg_hash_cht.h @@ -2499,9 +2499,9 @@ MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_WINDOW_WIDTH, MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_WINDOW_HEIGHT, "Set the custom height size for the display window. Leaving it at 0 will attempt to scale the window as large as possible.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN_X, - "Set the custom width size for the non-windowed fullscreen mode. Leaving it at 0 will use the desktop resolution.") + "Set the custom width size for the non-windowed fullscreen mode. Leaving it unset will use the desktop resolution.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN_Y, - "Set the custom height size for the non-windowed fullscreen mode. Leaving it at 0 will use the desktop resolution") + "Set the custom height size for the non-windowed fullscreen mode. Leaving it unset will use the desktop resolution.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_MESSAGE_POS_X, "Specify custom X axis position for onscreen text.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_MESSAGE_POS_Y, diff --git a/intl/msg_hash_el.h b/intl/msg_hash_el.h index 4a1a64116c..3954649d49 100644 --- a/intl/msg_hash_el.h +++ b/intl/msg_hash_el.h @@ -4862,11 +4862,11 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN_X, - "Set the custom width size for the non-windowed fullscreen mode. Leaving it at 0 will use the desktop resolution." + "Set the custom width size for the non-windowed fullscreen mode. Leaving it unset will use the desktop resolution." ) MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN_Y, - "Set the custom height size for the non-windowed fullscreen mode. Leaving it at 0 will use the desktop resolution" + "Set the custom height size for the non-windowed fullscreen mode. Leaving it unset will use the desktop resolution." ) MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_MESSAGE_POS_X, diff --git a/intl/msg_hash_eo.h b/intl/msg_hash_eo.h index 4069f0cb2f..b4eda865a4 100644 --- a/intl/msg_hash_eo.h +++ b/intl/msg_hash_eo.h @@ -2372,9 +2372,9 @@ MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_WINDOW_WIDTH, MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_WINDOW_HEIGHT, "Set the custom height size for the display window. Leaving it at 0 will attempt to scale the window as large as possible.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN_X, - "Set the custom width size for the non-windowed fullscreen mode. Leaving it at 0 will use the desktop resolution.") + "Set the custom width size for the non-windowed fullscreen mode. Leaving it unset will use the desktop resolution.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN_Y, - "Set the custom height size for the non-windowed fullscreen mode. Leaving it at 0 will use the desktop resolution") + "Set the custom height size for the non-windowed fullscreen mode. Leaving it unset will use the desktop resolution.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_MESSAGE_POS_X, "Specify custom X axis position for onscreen text.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_MESSAGE_POS_Y, diff --git a/intl/msg_hash_nl.h b/intl/msg_hash_nl.h index 3f169052d4..e1ffd5b701 100644 --- a/intl/msg_hash_nl.h +++ b/intl/msg_hash_nl.h @@ -2388,9 +2388,9 @@ MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_WINDOW_WIDTH, MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_WINDOW_HEIGHT, "Set the custom height size for the display window. Leaving it at 0 will attempt to scale the window as large as possible.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN_X, - "Set the custom width size for the non-windowed fullscreen mode. Leaving it at 0 will use the desktop resolution.") + "Set the custom width size for the non-windowed fullscreen mode. Leaving it unset will use the desktop resolution.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN_Y, - "Set the custom height size for the non-windowed fullscreen mode. Leaving it at 0 will use the desktop resolution") + "Set the custom height size for the non-windowed fullscreen mode. Leaving it unset will use the desktop resolution.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_MESSAGE_POS_X, "Specify custom X axis position for onscreen text.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_MESSAGE_POS_Y, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index c7ac4fc74f..f400919e98 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -4898,11 +4898,11 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN_X, - "Set the custom width size for the non-windowed fullscreen mode. Leaving it at 0 will use the desktop resolution." + "Set the custom width size for the non-windowed fullscreen mode. Leaving it unset will use the desktop resolution." ) MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN_Y, - "Set the custom height size for the non-windowed fullscreen mode. Leaving it at 0 will use the desktop resolution" + "Set the custom height size for the non-windowed fullscreen mode. Leaving it unset will use the desktop resolution." ) MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_MESSAGE_POS_X, diff --git a/intl/msg_hash_vn.h b/intl/msg_hash_vn.h index 79a6cdb8d7..e1c45a5d7e 100644 --- a/intl/msg_hash_vn.h +++ b/intl/msg_hash_vn.h @@ -2537,9 +2537,9 @@ MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_WINDOW_WIDTH, MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_WINDOW_HEIGHT, "Set the custom height size for the display window. Leaving it at 0 will attempt to scale the window as large as possible.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN_X, - "Set the custom width size for the non-windowed fullscreen mode. Leaving it at 0 will use the desktop resolution.") + "Set the custom width size for the non-windowed fullscreen mode. Leaving it unset will use the desktop resolution.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN_Y, - "Set the custom height size for the non-windowed fullscreen mode. Leaving it at 0 will use the desktop resolution") + "Set the custom height size for the non-windowed fullscreen mode. Leaving it unset will use the desktop resolution.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_MESSAGE_POS_X, "Specify custom X axis position for onscreen text.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_MESSAGE_POS_Y, diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 73e3f6e744..5cfdbcdd8c 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -6546,9 +6546,6 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_SUSPEND_SCREENSAVER_ENABLE, PARSE_ONLY_BOOL, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_SCREEN_RESOLUTION, - PARSE_ACTION, false); menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_PAL60_ENABLE, PARSE_ONLY_BOOL, false); @@ -6570,6 +6567,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_VIDEO_WINDOWED_FULLSCREEN, PARSE_ONLY_BOOL, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_SCREEN_RESOLUTION, + PARSE_ACTION, false); menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_VIDEO_FULLSCREEN_X, PARSE_ONLY_UINT, false); From 77ae2dc0cda374dba569d2e70e83e02dc9d986bd Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 25 Nov 2018 11:42:32 -0500 Subject: [PATCH 054/153] don't change window position on fullscreen changes --- gfx/common/win32_common.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 7f7aa3861e..f9314ada30 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -651,10 +651,13 @@ static void win32_save_position(void) } if (settings && settings->bools.video_window_save_positions) { - settings->uints.window_position_x = g_win32_pos_x; - settings->uints.window_position_y = g_win32_pos_y; - settings->uints.window_position_width = g_win32_pos_width; - settings->uints.window_position_height= g_win32_pos_height; + if (!settings->bools.video_fullscreen && !retroarch_is_forced_fullscreen()) + { + settings->uints.window_position_x = g_win32_pos_x; + settings->uints.window_position_y = g_win32_pos_y; + settings->uints.window_position_width = g_win32_pos_width; + settings->uints.window_position_height = g_win32_pos_height; + } } } @@ -1324,6 +1327,7 @@ bool win32_set_video_mode(void *data, &mon_rect, width, height, fullscreen)) return false; + win32_set_window(&width, &height, fullscreen, windowed_full, &rect); From b14ff4d50400c8f281bc1fdd42f01656ee71ef93 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 25 Nov 2018 18:43:08 +0100 Subject: [PATCH 055/153] - Try to fix Screen Resolution hang on platforms other than PC by hiding the setting if display server is NULL - Fix some warnings that had to do with certain strings being too small --- menu/menu_displaylist.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 5cfdbcdd8c..36a9713301 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -373,7 +373,7 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) gfx_ctx_ident_t ident_info; #endif - char tmp[PATH_MAX_LENGTH]; + char tmp[8192]; char feat_str[255]; #ifdef ANDROID bool perms = false; @@ -432,7 +432,7 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) } { - char cpu_str[255]; + char cpu_str[8192]; char cpu_arch_str[PATH_MAX_LENGTH]; char cpu_text_str[PATH_MAX_LENGTH]; enum frontend_architecture arch = frontend_driver_get_cpu_architecture(); @@ -1445,7 +1445,7 @@ static int menu_displaylist_parse_shader_options(menu_displaylist_info_t *info) for (i = 0; i < pass_count; i++) { char buf_tmp[64]; - char buf[64]; + char buf[128]; buf[0] = buf_tmp[0] = '\0'; @@ -3381,8 +3381,8 @@ static int menu_displaylist_parse_options_remappings( { for (retro_id = 0; retro_id < RARCH_FIRST_CUSTOM_BIND + 8; retro_id++) { - char desc_label[64]; - char descriptor[255]; + char desc_label[400]; + char descriptor[300]; const struct retro_keybind *auto_bind = NULL; const struct retro_keybind *keybind = NULL; @@ -6546,6 +6546,16 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_SUSPEND_SCREENSAVER_ENABLE, PARSE_ONLY_BOOL, false); +#if defined(GEKKO) || defined(__CELLOS_LV2__) + if (true) +#else + if (!string_is_equal(video_display_server_get_ident(), "null")) +#endif + { + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_SCREEN_RESOLUTION, + PARSE_ACTION, false); + } menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_PAL60_ENABLE, PARSE_ONLY_BOOL, false); From ff4fa3be7ae3fadd60574f2db7920373c5e6845e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 25 Nov 2018 18:49:04 +0100 Subject: [PATCH 056/153] Fix more string is too small warnings --- network/netplay/netplay_frontend.c | 2 +- network/netplay/netplay_io.c | 2 +- tasks/task_decompress.c | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/network/netplay/netplay_frontend.c b/network/netplay/netplay_frontend.c index 6da9b1dee9..2fcc934247 100644 --- a/network/netplay/netplay_frontend.c +++ b/network/netplay/netplay_frontend.c @@ -851,7 +851,7 @@ void netplay_get_architecture(char *frontend_architecture, size_t size) static void netplay_announce(void) { - char buf [2048]; + char buf [4600]; char frontend_architecture[PATH_MAX_LENGTH]; char url [2048] = "http://lobby.libretro.com/add/"; char *username = NULL; diff --git a/network/netplay/netplay_io.c b/network/netplay/netplay_io.c index 4028515719..33506e1430 100644 --- a/network/netplay/netplay_io.c +++ b/network/netplay/netplay_io.c @@ -1990,7 +1990,7 @@ void netplay_handle_slaves(netplay_t *netplay) void netplay_announce_nat_traversal(netplay_t *netplay) { #ifndef HAVE_SOCKET_LEGACY - char msg[512], host[PATH_MAX_LENGTH], port[6]; + char msg[4200], host[PATH_MAX_LENGTH], port[6]; if (netplay->nat_traversal_state.have_inet4) { diff --git a/tasks/task_decompress.c b/tasks/task_decompress.c index 80b5ddf9db..d83cc1d1c7 100644 --- a/tasks/task_decompress.c +++ b/tasks/task_decompress.c @@ -28,6 +28,8 @@ #include "../verbosity.h" #include "../msg_hash.h" +#define CALLBACK_ERROR_SIZE 4200 + static int file_decompressed_target_file(const char *name, const char *valid_exts, const uint8_t *cdata, @@ -80,9 +82,9 @@ next_file: return 1; error: - userdata->dec->callback_error = (char*)malloc(PATH_MAX_LENGTH); + userdata->dec->callback_error = (char*)malloc(CALLBACK_ERROR_SIZE); snprintf(userdata->dec->callback_error, - PATH_MAX_LENGTH, "Failed to deflate %s.\n", path); + CALLBACK_ERROR_SIZE, "Failed to deflate %s.\n", path); return 0; } @@ -122,8 +124,8 @@ next_file: return 1; error: - dec->callback_error = (char*)malloc(PATH_MAX_LENGTH); - snprintf(dec->callback_error, PATH_MAX_LENGTH, + dec->callback_error = (char*)malloc(CALLBACK_ERROR_SIZE); + snprintf(dec->callback_error, CALLBACK_ERROR_SIZE, "Failed to deflate %s.\n", path); return 0; From fb957f29a84606036c11d7fc29b22a37502d580a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 25 Nov 2018 19:12:21 +0100 Subject: [PATCH 057/153] Set current_display_server by default to dispserv_null --- gfx/video_display_server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/video_display_server.c b/gfx/video_display_server.c index 0f77f6697a..e4824a0a46 100644 --- a/gfx/video_display_server.c +++ b/gfx/video_display_server.c @@ -20,7 +20,7 @@ #include "video_driver.h" #include "../verbosity.h" -static const video_display_server_t *current_display_server = NULL; +static const video_display_server_t *current_display_server = &dispserv_null; static void *current_display_server_data = NULL; const char *video_display_server_get_ident(void) From 3ca4ac2a21ec4045597ee27a6467a43c07d492c9 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sun, 25 Nov 2018 19:22:55 +0100 Subject: [PATCH 058/153] (Ozone) Fix redefinition of typedef --- menu/drivers/ozone/ozone.h | 6 +++--- menu/drivers/ozone/ozone_theme.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/menu/drivers/ozone/ozone.h b/menu/drivers/ozone/ozone.h index 5438714485..76912544b9 100644 --- a/menu/drivers/ozone/ozone.h +++ b/menu/drivers/ozone/ozone.h @@ -42,7 +42,7 @@ typedef struct ozone_handle ozone_handle_t; #define INTERVAL_BATTERY_LEVEL_CHECK (30 * 1000000) #define INTERVAL_OSK_CURSOR (0.5f * 1000000) -typedef struct ozone_handle +struct ozone_handle { uint64_t frame_count; @@ -152,7 +152,7 @@ typedef struct ozone_handle unsigned old_list_offset_y; file_list_t *horizontal_list; /* console tabs */ -} ozone_handle_t; +}; /* If you change this struct, also change ozone_alloc_node and @@ -207,4 +207,4 @@ void ozone_free_list_nodes(file_list_t *list, bool actiondata); bool ozone_is_playlist(ozone_handle_t *ozone); -#endif \ No newline at end of file +#endif diff --git a/menu/drivers/ozone/ozone_theme.c b/menu/drivers/ozone/ozone_theme.c index fa9478fa82..5a32bd4943 100644 --- a/menu/drivers/ozone/ozone_theme.c +++ b/menu/drivers/ozone/ozone_theme.c @@ -118,10 +118,10 @@ void ozone_set_color_theme(ozone_handle_t *ozone, unsigned color_theme) last_color_theme = color_theme; } -unsigned ozone_get_system_theme() +unsigned ozone_get_system_theme(void) { - unsigned ret = 0; #ifdef HAVE_LIBNX + unsigned ret = 0; if (R_SUCCEEDED(setsysInitialize())) { ColorSetId theme; @@ -133,4 +133,4 @@ unsigned ozone_get_system_theme() return ret; #endif return 0; -} \ No newline at end of file +} From de903c650dc1d7f3304886e025640ae7fc078be5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 25 Nov 2018 20:34:50 +0100 Subject: [PATCH 059/153] Reinitialize context in a different way --- menu/drivers/xmb.c | 1496 ++++++++++++++++++++++---------------------- 1 file changed, 758 insertions(+), 738 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 0d85039a14..4bb2b29ab8 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1,8 +1,8 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * Copyright (C) 2014-2017 - Jean-André Santoni + * Copyright (C) 2014-2017 - Jean-Andr Santoni * Copyright (C) 2016-2017 - Brad Parker - * Copyright (C) 2018 - Alfredo Monclús + * Copyright (C) 2018 - Alfredo Moncls * * 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- @@ -233,6 +233,7 @@ typedef struct xmb_handle { bool mouse_show; bool use_ps3_layout; + bool context_just_reset; uint8_t system_tab_end; uint8_t tabs[XMB_SYSTEM_TAB_MAX_LENGTH]; @@ -2111,6 +2112,7 @@ static void xmb_context_reset_horizontal_list( } } + xmb_toggle_horizontal_list(xmb); } static void xmb_refresh_horizontal_list(xmb_handle_t *xmb) @@ -2132,7 +2134,6 @@ static void xmb_refresh_horizontal_list(xmb_handle_t *xmb) xmb_init_horizontal_list(xmb); xmb_context_reset_horizontal_list(xmb); - xmb_toggle_horizontal_list(xmb); } static int xmb_environ(enum menu_environ_cb type, void *data, void *userdata) @@ -3319,710 +3320,8 @@ static void xmb_draw_dark_layer( menu_display_blend_end(video_info); } -static const char *xmb_texture_path(unsigned id) -{ - char *iconpath = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); - char *icon_name = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); - char *icon_fullpath = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); - - iconpath[0] = icon_name[0] = icon_fullpath[0] = '\0'; - - switch (id) - { - case XMB_TEXTURE_MAIN_MENU: -#if defined(HAVE_LAKKA) - icon_name = "lakka.png"; - break; -#else - icon_name = "retroarch.png"; - break; -#endif - case XMB_TEXTURE_SETTINGS: - icon_name = "settings.png"; - break; - case XMB_TEXTURE_HISTORY: - icon_name = "history.png"; - break; - case XMB_TEXTURE_FAVORITES: - icon_name = "favorites.png"; - break; - case XMB_TEXTURE_ADD_FAVORITE: - icon_name = "add-favorite.png"; - break; - case XMB_TEXTURE_MUSICS: - icon_name = "musics.png"; - break; -#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) - case XMB_TEXTURE_MOVIES: - icon_name = "movies.png"; - break; -#endif -#ifdef HAVE_IMAGEVIEWER - case XMB_TEXTURE_IMAGES: - icon_name = "images.png"; - break; -#endif - case XMB_TEXTURE_SETTING: - icon_name = "setting.png"; - break; - case XMB_TEXTURE_SUBSETTING: - icon_name = "subsetting.png"; - break; - case XMB_TEXTURE_ARROW: - icon_name = "arrow.png"; - break; - case XMB_TEXTURE_RUN: - icon_name = "run.png"; - break; - case XMB_TEXTURE_CLOSE: - icon_name = "close.png"; - break; - case XMB_TEXTURE_RESUME: - icon_name = "resume.png"; - break; - case XMB_TEXTURE_CLOCK: - icon_name = "clock.png"; - break; - case XMB_TEXTURE_BATTERY_FULL: - icon_name = "battery-full.png"; - break; - case XMB_TEXTURE_BATTERY_CHARGING: - icon_name = "battery-charging.png"; - break; - case XMB_TEXTURE_POINTER: - icon_name = "pointer.png"; - break; - case XMB_TEXTURE_SAVESTATE: - icon_name = "savestate.png"; - break; - case XMB_TEXTURE_LOADSTATE: - icon_name = "loadstate.png"; - break; - case XMB_TEXTURE_UNDO: - icon_name = "undo.png"; - break; - case XMB_TEXTURE_CORE_INFO: - icon_name = "core-infos.png"; - break; - case XMB_TEXTURE_WIFI: - icon_name = "wifi.png"; - break; - case XMB_TEXTURE_CORE_OPTIONS: - icon_name = "core-options.png"; - break; - case XMB_TEXTURE_INPUT_REMAPPING_OPTIONS: - icon_name = "core-input-remapping-options.png"; - break; - case XMB_TEXTURE_CHEAT_OPTIONS: - icon_name = "core-cheat-options.png"; - break; - case XMB_TEXTURE_DISK_OPTIONS: - icon_name = "core-disk-options.png"; - break; - case XMB_TEXTURE_SHADER_OPTIONS: - icon_name = "core-shader-options.png"; - break; - case XMB_TEXTURE_ACHIEVEMENT_LIST: - icon_name = "achievement-list.png"; - break; - case XMB_TEXTURE_SCREENSHOT: - icon_name = "screenshot.png"; - break; - case XMB_TEXTURE_RELOAD: - icon_name = "reload.png"; - break; - case XMB_TEXTURE_RENAME: - icon_name = "rename.png"; - break; - case XMB_TEXTURE_FILE: - icon_name = "file.png"; - break; - case XMB_TEXTURE_FOLDER: - icon_name = "folder.png"; - break; - case XMB_TEXTURE_ZIP: - icon_name = "zip.png"; - break; - case XMB_TEXTURE_MUSIC: - icon_name = "music.png"; - break; - case XMB_TEXTURE_FAVORITE: - icon_name = "favorites-content.png"; - break; - case XMB_TEXTURE_IMAGE: - icon_name = "image.png"; - break; - case XMB_TEXTURE_MOVIE: - icon_name = "movie.png"; - break; - case XMB_TEXTURE_CORE: - icon_name = "core.png"; - break; - case XMB_TEXTURE_RDB: - icon_name = "database.png"; - break; - case XMB_TEXTURE_CURSOR: - icon_name = "cursor.png"; - break; - case XMB_TEXTURE_SWITCH_ON: - icon_name = "on.png"; - break; - case XMB_TEXTURE_SWITCH_OFF: - icon_name = "off.png"; - break; - case XMB_TEXTURE_ADD: - icon_name = "add.png"; - break; -#ifdef HAVE_NETWORKING - case XMB_TEXTURE_NETPLAY: - icon_name = "netplay.png"; - break; - case XMB_TEXTURE_ROOM: - icon_name = "menu_room.png"; - break; - case XMB_TEXTURE_ROOM_LAN: - icon_name = "menu_room_lan.png"; - break; - case XMB_TEXTURE_ROOM_RELAY: - icon_name = "menu_room_relay.png"; - break; -#endif - case XMB_TEXTURE_KEY: - icon_name = "key.png"; - break; - case XMB_TEXTURE_KEY_HOVER: - icon_name = "key-hover.png"; - break; - case XMB_TEXTURE_DIALOG_SLICE: - icon_name = "dialog-slice.png"; - break; - case XMB_TEXTURE_ACHIEVEMENTS: - icon_name = "menu_achievements.png"; - break; - case XMB_TEXTURE_AUDIO: - icon_name = "menu_audio.png"; - break; - case XMB_TEXTURE_DRIVERS: - icon_name = "menu_drivers.png"; - break; - case XMB_TEXTURE_EXIT: - icon_name = "menu_exit.png"; - break; - case XMB_TEXTURE_FRAMESKIP: - icon_name = "menu_frameskip.png"; - break; - case XMB_TEXTURE_HELP: - icon_name = "menu_help.png"; - break; - case XMB_TEXTURE_INFO: - icon_name = "menu_info.png"; - break; - case XMB_TEXTURE_INPUT_SETTINGS: - icon_name = "Libretro - Pad.png"; - break; - case XMB_TEXTURE_LATENCY: - icon_name = "menu_latency.png"; - break; - case XMB_TEXTURE_NETWORK: - icon_name = "menu_network.png"; - break; - case XMB_TEXTURE_POWER: - icon_name = "menu_power.png"; - break; - case XMB_TEXTURE_RECORD: - icon_name = "menu_record.png"; - break; - case XMB_TEXTURE_SAVING: - icon_name = "menu_saving.png"; - break; - case XMB_TEXTURE_UPDATER: - icon_name = "menu_updater.png"; - break; - case XMB_TEXTURE_VIDEO: - icon_name = "menu_video.png"; - break; - case XMB_TEXTURE_MIXER: - icon_name = "menu_mixer.png"; - break; - case XMB_TEXTURE_LOG: - icon_name = "menu_log.png"; - break; - case XMB_TEXTURE_OSD: - icon_name = "menu_osd.png"; - break; - case XMB_TEXTURE_UI: - icon_name = "menu_ui.png"; - break; - case XMB_TEXTURE_USER: - icon_name = "menu_user.png"; - break; - case XMB_TEXTURE_PRIVACY: - icon_name = "menu_privacy.png"; - break; - case XMB_TEXTURE_PLAYLIST: - icon_name = "menu_playlist.png"; - break; - case XMB_TEXTURE_QUICKMENU: - icon_name = "menu_quickmenu.png"; - break; - case XMB_TEXTURE_REWIND: - icon_name = "menu_rewind.png"; - break; - case XMB_TEXTURE_OVERLAY: - icon_name = "menu_overlay.png"; - break; - case XMB_TEXTURE_OVERRIDE: - icon_name = "menu_override.png"; - break; - case XMB_TEXTURE_NOTIFICATIONS: - icon_name = "menu_notifications.png"; - break; - case XMB_TEXTURE_STREAM: - icon_name = "menu_stream.png"; - break; - case XMB_TEXTURE_SHUTDOWN: - icon_name = "menu_shutdown.png"; - break; - case XMB_TEXTURE_INPUT_DPAD_U: - icon_name = "input_DPAD-U.png"; - break; - case XMB_TEXTURE_INPUT_DPAD_D: - icon_name = "input_DPAD-D.png"; - break; - case XMB_TEXTURE_INPUT_DPAD_L: - icon_name = "input_DPAD-L.png"; - break; - case XMB_TEXTURE_INPUT_DPAD_R: - icon_name = "input_DPAD-R.png"; - break; - case XMB_TEXTURE_INPUT_STCK_U: - icon_name = "input_STCK-U.png"; - break; - case XMB_TEXTURE_INPUT_STCK_D: - icon_name = "input_STCK-D.png"; - break; - case XMB_TEXTURE_INPUT_STCK_L: - icon_name = "input_STCK-L.png"; - break; - case XMB_TEXTURE_INPUT_STCK_R: - icon_name = "input_STCK-R.png"; - break; - case XMB_TEXTURE_INPUT_STCK_P: - icon_name = "input_STCK-P.png"; - break; - case XMB_TEXTURE_INPUT_BTN_U: - icon_name = "input_BTN-U.png"; - break; - case XMB_TEXTURE_INPUT_BTN_D: - icon_name = "input_BTN-D.png"; - break; - case XMB_TEXTURE_INPUT_BTN_L: - icon_name = "input_BTN-L.png"; - break; - case XMB_TEXTURE_INPUT_BTN_R: - icon_name = "input_BTN-R.png"; - break; - case XMB_TEXTURE_INPUT_LB: - icon_name = "input_LB.png"; - break; - case XMB_TEXTURE_INPUT_RB: - icon_name = "input_RB.png"; - break; - case XMB_TEXTURE_INPUT_LT: - icon_name = "input_LT.png"; - break; - case XMB_TEXTURE_INPUT_RT: - icon_name = "input_RT.png"; - break; - case XMB_TEXTURE_INPUT_SELECT: - icon_name = "input_SELECT.png"; - break; - case XMB_TEXTURE_INPUT_START: - icon_name = "input_START.png"; - break; - case XMB_TEXTURE_CHECKMARK: - icon_name = "menu_check.png"; - break; - case XMB_TEXTURE_MENU_ADD: - icon_name = "menu_add.png"; - break; - case XMB_TEXTURE_BRIGHTNESS: - icon_name = "menu_brightness.png"; - break; - case XMB_TEXTURE_PAUSE: - icon_name = "menu_pause.png"; - break; - } - - fill_pathname_application_special(iconpath, - PATH_MAX_LENGTH * sizeof(char), - APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); - - icon_fullpath = iconpath; - strlcat(icon_fullpath, icon_name, PATH_MAX_LENGTH * sizeof(char)); - - if (!filestream_exists(icon_fullpath)) - { - RARCH_WARN("[XMB] Asset missing: %s\n", icon_fullpath); - return NULL; - } - else - return icon_name; - -} - -static void xmb_context_reset_textures_nodes(xmb_handle_t *xmb) -{ - xmb->main_menu_node.icon = xmb->textures.list[XMB_TEXTURE_MAIN_MENU]; - xmb->main_menu_node.alpha = xmb->categories_active_alpha; - xmb->main_menu_node.zoom = xmb->categories_active_zoom; - - xmb->settings_tab_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS]; - xmb->settings_tab_node.alpha = xmb->categories_active_alpha; - xmb->settings_tab_node.zoom = xmb->categories_active_zoom; - - xmb->history_tab_node.icon = xmb->textures.list[XMB_TEXTURE_HISTORY]; - xmb->history_tab_node.alpha = xmb->categories_active_alpha; - xmb->history_tab_node.zoom = xmb->categories_active_zoom; - - xmb->favorites_tab_node.icon = xmb->textures.list[XMB_TEXTURE_FAVORITES]; - xmb->favorites_tab_node.alpha = xmb->categories_active_alpha; - xmb->favorites_tab_node.zoom = xmb->categories_active_zoom; - - xmb->music_tab_node.icon = xmb->textures.list[XMB_TEXTURE_MUSICS]; - xmb->music_tab_node.alpha = xmb->categories_active_alpha; - xmb->music_tab_node.zoom = xmb->categories_active_zoom; - -#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) - xmb->video_tab_node.icon = xmb->textures.list[XMB_TEXTURE_MOVIES]; - xmb->video_tab_node.alpha = xmb->categories_active_alpha; - xmb->video_tab_node.zoom = xmb->categories_active_zoom; -#endif - -#ifdef HAVE_IMAGEVIEWER - xmb->images_tab_node.icon = xmb->textures.list[XMB_TEXTURE_IMAGES]; - xmb->images_tab_node.alpha = xmb->categories_active_alpha; - xmb->images_tab_node.zoom = xmb->categories_active_zoom; -#endif - - xmb->add_tab_node.icon = xmb->textures.list[XMB_TEXTURE_ADD]; - xmb->add_tab_node.alpha = xmb->categories_active_alpha; - xmb->add_tab_node.zoom = xmb->categories_active_zoom; - -#ifdef HAVE_NETWORKING - xmb->netplay_tab_node.icon = xmb->textures.list[XMB_TEXTURE_NETPLAY]; - xmb->netplay_tab_node.alpha = xmb->categories_active_alpha; - xmb->netplay_tab_node.zoom = xmb->categories_active_zoom; -#endif -} - -static void xmb_context_reset_textures( - xmb_handle_t *xmb, const char *iconpath) -{ - unsigned i; - settings_t *settings = config_get_ptr(); - - for (i = 0; i < XMB_TEXTURE_LAST; i++) - { - if (xmb_texture_path(i) == NULL) - { - /* If the icon doesn't exist at least try to return the subsetting icon*/ - if (!(i == XMB_TEXTURE_DIALOG_SLICE || i == XMB_TEXTURE_KEY_HOVER || i == XMB_TEXTURE_KEY_HOVER)) - menu_display_reset_textures_list(xmb_texture_path(XMB_TEXTURE_SUBSETTING), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); - continue; - } - menu_display_reset_textures_list(xmb_texture_path(i), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); - } - - /* Warn only if critical assets are missing, some themes are incomplete */ - if ( - ((xmb_texture_path(XMB_TEXTURE_SUBSETTING) == NULL)) && !(settings->uints.menu_xmb_theme == XMB_ICON_THEME_CUSTOM) - ) - runloop_msg_queue_push(msg_hash_to_str(MSG_MISSING_ASSETS), 1, 256, false); - - menu_display_allocate_white_texture(); - - -} - -static void xmb_context_reset_background(const char *iconpath) -{ - char *path = NULL; - settings_t *settings = config_get_ptr(); - const char *path_menu_wp = settings->paths.path_menu_wallpaper; - - if (!string_is_empty(path_menu_wp)) - path = strdup(path_menu_wp); - else if (!string_is_empty(iconpath)) - { - path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - path[0] = '\0'; - - fill_pathname_join(path, iconpath, "bg.png", - PATH_MAX_LENGTH * sizeof(char)); - } - - if (filestream_exists(path)) - task_push_image_load(path, - menu_display_handle_wallpaper_upload, NULL); - - if (path) - free(path); -} - -static void xmb_context_reset(void *data, bool is_threaded) -{ - xmb_handle_t *xmb = (xmb_handle_t*)data; - char *iconpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - - char bg_file_path[PATH_MAX_LENGTH] = {0}; - iconpath[0] = '\0'; - fill_pathname_application_special(iconpath, - PATH_MAX_LENGTH * sizeof(char), - APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); - fill_pathname_application_special(bg_file_path, - sizeof(bg_file_path), APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_BG); - - if (!string_is_empty(bg_file_path)) - { - if (!string_is_empty(xmb->bg_file_path)) - free(xmb->bg_file_path); - xmb->bg_file_path = strdup(bg_file_path); - } - - xmb_context_reset_textures(xmb, iconpath); - xmb_context_reset_background(iconpath); - xmb_context_reset_horizontal_list(xmb); - - xmb->previous_scale_factor = 0.0; - - free(iconpath); -} - -static void xmb_layout_ps3(xmb_handle_t *xmb, int width) -{ - unsigned new_font_size, new_header_height; - settings_t *settings = config_get_ptr(); - - float scale_factor = - (settings->uints.menu_xmb_scale_factor * width) / (1920.0 * 100); - - xmb->above_subitem_offset = 1.5; - xmb->above_item_offset = -1.0; - xmb->active_item_factor = 3.0; - xmb->under_item_offset = 5.0; - - xmb->categories_active_zoom = 1.0; - xmb->categories_passive_zoom = 0.5; - xmb->items_active_zoom = 1.0; - xmb->items_passive_zoom = 0.5; - - xmb->categories_active_alpha = 1.0; - xmb->categories_passive_alpha = 0.85; - xmb->items_active_alpha = 1.0; - xmb->items_passive_alpha = 0.85; - - xmb->shadow_offset = 2.0; - - new_font_size = 32.0 * scale_factor; - xmb->font2_size = 24.0 * scale_factor; - new_header_height = 128.0 * scale_factor; - - - xmb->thumbnail_width = 1024.0 * scale_factor; - xmb->left_thumbnail_width = 1024.0 * scale_factor; - xmb->savestate_thumbnail_width= 460.0 * scale_factor; - xmb->cursor_size = 64.0 * scale_factor; - - xmb->icon_spacing_horizontal = 200.0 * scale_factor; - xmb->icon_spacing_vertical = 64.0 * scale_factor; - - xmb->margins_screen_top = (256+32) * scale_factor; - xmb->margins_screen_left = 336.0 * scale_factor; - - xmb->margins_title_left = 60 * scale_factor; - xmb->margins_title_top = 60 * scale_factor + new_font_size / 3; - xmb->margins_title_bottom = 60 * scale_factor - new_font_size / 3; - - xmb->margins_label_left = 85.0 * scale_factor; - xmb->margins_label_top = new_font_size / 3.0; - - xmb->margins_setting_left = 600.0 * scale_factor * scale_mod[6]; - xmb->margins_dialog = 48 * scale_factor; - - xmb->margins_slice = 16; - - xmb->icon_size = 128.0 * scale_factor; - xmb->font_size = new_font_size; - - menu_display_set_header_height(new_header_height); -} - -static void xmb_layout_psp(xmb_handle_t *xmb, int width) -{ - unsigned new_font_size, new_header_height; - settings_t *settings = config_get_ptr(); - float scale_factor = - ((settings->uints.menu_xmb_scale_factor * width) / (1920.0 * 100)) * 1.5; -#ifdef _3DS - scale_factor = - settings->uints.menu_xmb_scale_factor / 400.0; -#endif - - xmb->above_subitem_offset = 1.5; - xmb->above_item_offset = -1.0; - xmb->active_item_factor = 2.0; - xmb->under_item_offset = 3.0; - - xmb->categories_active_zoom = 1.0; - xmb->categories_passive_zoom = 1.0; - xmb->items_active_zoom = 1.0; - xmb->items_passive_zoom = 1.0; - - xmb->categories_active_alpha = 1.0; - xmb->categories_passive_alpha = 0.85; - xmb->items_active_alpha = 1.0; - xmb->items_passive_alpha = 0.85; - - xmb->shadow_offset = 1.0; - - new_font_size = 32.0 * scale_factor; - xmb->font2_size = 24.0 * scale_factor; - new_header_height = 128.0 * scale_factor; - xmb->margins_screen_top = (256+32) * scale_factor; - - xmb->thumbnail_width = 460.0 * scale_factor; - xmb->left_thumbnail_width = 400.0 * scale_factor; - xmb->savestate_thumbnail_width= 460.0 * scale_factor; - xmb->cursor_size = 64.0; - - xmb->icon_spacing_horizontal = 250.0 * scale_factor; - xmb->icon_spacing_vertical = 108.0 * scale_factor; - - xmb->margins_screen_left = 136.0 * scale_factor; - xmb->margins_title_left = 60 * scale_factor; - xmb->margins_title_top = 60 * scale_factor + new_font_size / 3; - xmb->margins_title_bottom = 60 * scale_factor - new_font_size / 3; - xmb->margins_label_left = 85.0 * scale_factor; - xmb->margins_label_top = new_font_size / 3.0; - xmb->margins_setting_left = 600.0 * scale_factor; - xmb->margins_dialog = 48 * scale_factor; - xmb->margins_slice = 16; - xmb->icon_size = 128.0 * scale_factor; - xmb->font_size = new_font_size; - - menu_display_set_header_height(new_header_height); -} - -static void xmb_layout(xmb_handle_t *xmb) -{ - unsigned width, height, i, current, end; - settings_t *settings = config_get_ptr(); - file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); - size_t selection = menu_navigation_get_selection(); - - video_driver_get_size(&width, &height); - - switch (settings->uints.menu_xmb_layout) - { - /* Automatic */ - case 0: - { - xmb->use_ps3_layout = false; - xmb->use_ps3_layout = width > 320 && height > 240; - - /* Mimic the layout of the PSP instead of the PS3 on tiny screens */ - if (xmb->use_ps3_layout) - xmb_layout_ps3(xmb, width); - else - xmb_layout_psp(xmb, width); - } - break; - /* PS3 */ - case 1: - { - xmb->use_ps3_layout = true; - xmb_layout_ps3(xmb, width); - } - break; - /* PSP */ - case 2: - { - xmb->use_ps3_layout = false; - xmb_layout_psp(xmb, width); - } - break; - } - -#ifdef XMB_DEBUG - RARCH_LOG("[XMB] margin screen left: %.2f\n", xmb->margins_screen_left); - RARCH_LOG("[XMB] margin screen top: %.2f\n", xmb->margins_screen_top); - RARCH_LOG("[XMB] margin title left: %.2f\n", xmb->margins_title_left); - RARCH_LOG("[XMB] margin title top: %.2f\n", xmb->margins_title_top); - RARCH_LOG("[XMB] margin title bott: %.2f\n", xmb->margins_title_bottom); - RARCH_LOG("[XMB] margin label left: %.2f\n", xmb->margins_label_left); - RARCH_LOG("[XMB] margin label top: %.2f\n", xmb->margins_label_top); - RARCH_LOG("[XMB] margin sett left: %.2f\n", xmb->margins_setting_left); - RARCH_LOG("[XMB] icon spacing hor: %.2f\n", xmb->icon_spacing_horizontal); - RARCH_LOG("[XMB] icon spacing ver: %.2f\n", xmb->icon_spacing_vertical); - RARCH_LOG("[XMB] icon size: %.2f\n", xmb->icon_size); -#endif - - current = (unsigned)selection; - end = (unsigned)menu_entries_get_size(); - - for (i = 0; i < end; i++) - { - float ia = xmb->items_passive_alpha; - float iz = xmb->items_passive_zoom; - xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset( - selection_buf, i); - - if (!node) - continue; - - if (i == current) - { - ia = xmb->items_active_alpha; - iz = xmb->items_active_alpha; - } - - node->alpha = ia; - node->label_alpha = ia; - node->zoom = iz; - node->y = xmb_item_y(xmb, i, current); - } - - if (xmb->depth <= 1) - return; - - current = (unsigned)xmb->selection_ptr_old; - end = (unsigned)file_list_get_size(xmb->selection_buf_old); - - for (i = 0; i < end; i++) - { - float ia = 0; - float iz = xmb->items_passive_zoom; - xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset( - xmb->selection_buf_old, i); - - if (!node) - continue; - - if (i == current) - { - ia = xmb->items_active_alpha; - iz = xmb->items_active_alpha; - } - - node->alpha = ia; - node->label_alpha = 0; - node->zoom = iz; - node->y = xmb_item_y(xmb, i, current); - node->x = xmb->icon_size * 1 * -2; - } -} - +static void xmb_context_reset_internal(xmb_handle_t *xmb, + bool is_threaded, bool reinit_textures); static void xmb_frame(void *data, video_frame_info_t *video_info) { @@ -4053,37 +3352,14 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) scale_factor = (settings->uints.menu_xmb_scale_factor * (float)width) / (1920.0 * 100); pseudo_font_length = xmb->icon_spacing_horizontal * 4 - xmb->icon_size / 4; - if (scale_factor != xmb->previous_scale_factor) - { - bool video_is_threaded = video_driver_is_threaded(); - menu_display_font_free(xmb->font); - menu_display_font_free(xmb->font2); - xmb_layout(xmb); - xmb->font = menu_display_font( - APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, - xmb->font_size, - video_is_threaded); - xmb->font2 = menu_display_font( - APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, - xmb->font2_size, - video_is_threaded); - xmb_context_reset_textures_nodes(xmb); - xmb_toggle_horizontal_list(xmb); + if (scale_factor != xmb->previous_scale_factor && !xmb->context_just_reset) + xmb_context_reset_internal(xmb, video_driver_is_threaded(), + false); - if (!string_is_equal(xmb_thumbnails_ident('R'), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) - { - xmb_update_thumbnail_path(xmb, 0, 'R'); - xmb_update_thumbnail_image(xmb); - } - if (!string_is_equal(xmb_thumbnails_ident('L'), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) - { - xmb_update_thumbnail_path(xmb, 0, 'L'); - xmb_update_thumbnail_image(xmb); - } - xmb_update_savestate_thumbnail_image(xmb); - } + if (xmb->context_just_reset) + xmb->context_just_reset = false; + + xmb->previous_scale_factor = scale_factor; xmb->frame_count++; @@ -4834,8 +4110,230 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) } menu_display_unset_viewport(video_info->width, video_info->height); +} - xmb->previous_scale_factor = scale_factor; +static void xmb_layout_ps3(xmb_handle_t *xmb, int width) +{ + unsigned new_font_size, new_header_height; + settings_t *settings = config_get_ptr(); + + float scale_factor = + (settings->uints.menu_xmb_scale_factor * width) / (1920.0 * 100); + + xmb->above_subitem_offset = 1.5; + xmb->above_item_offset = -1.0; + xmb->active_item_factor = 3.0; + xmb->under_item_offset = 5.0; + + xmb->categories_active_zoom = 1.0; + xmb->categories_passive_zoom = 0.5; + xmb->items_active_zoom = 1.0; + xmb->items_passive_zoom = 0.5; + + xmb->categories_active_alpha = 1.0; + xmb->categories_passive_alpha = 0.85; + xmb->items_active_alpha = 1.0; + xmb->items_passive_alpha = 0.85; + + xmb->shadow_offset = 2.0; + + new_font_size = 32.0 * scale_factor; + xmb->font2_size = 24.0 * scale_factor; + new_header_height = 128.0 * scale_factor; + + + xmb->thumbnail_width = 1024.0 * scale_factor; + xmb->left_thumbnail_width = 1024.0 * scale_factor; + xmb->savestate_thumbnail_width= 460.0 * scale_factor; + xmb->cursor_size = 64.0 * scale_factor; + + xmb->icon_spacing_horizontal = 200.0 * scale_factor; + xmb->icon_spacing_vertical = 64.0 * scale_factor; + + xmb->margins_screen_top = (256+32) * scale_factor; + xmb->margins_screen_left = 336.0 * scale_factor; + + xmb->margins_title_left = 60 * scale_factor; + xmb->margins_title_top = 60 * scale_factor + new_font_size / 3; + xmb->margins_title_bottom = 60 * scale_factor - new_font_size / 3; + + xmb->margins_label_left = 85.0 * scale_factor; + xmb->margins_label_top = new_font_size / 3.0; + + xmb->margins_setting_left = 600.0 * scale_factor * scale_mod[6]; + xmb->margins_dialog = 48 * scale_factor; + + xmb->margins_slice = 16; + + xmb->icon_size = 128.0 * scale_factor; + xmb->font_size = new_font_size; + + menu_display_set_header_height(new_header_height); +} + +static void xmb_layout_psp(xmb_handle_t *xmb, int width) +{ + unsigned new_font_size, new_header_height; + settings_t *settings = config_get_ptr(); + float scale_factor = + ((settings->uints.menu_xmb_scale_factor * width) / (1920.0 * 100)) * 1.5; +#ifdef _3DS + scale_factor = + settings->uints.menu_xmb_scale_factor / 400.0; +#endif + + xmb->above_subitem_offset = 1.5; + xmb->above_item_offset = -1.0; + xmb->active_item_factor = 2.0; + xmb->under_item_offset = 3.0; + + xmb->categories_active_zoom = 1.0; + xmb->categories_passive_zoom = 1.0; + xmb->items_active_zoom = 1.0; + xmb->items_passive_zoom = 1.0; + + xmb->categories_active_alpha = 1.0; + xmb->categories_passive_alpha = 0.85; + xmb->items_active_alpha = 1.0; + xmb->items_passive_alpha = 0.85; + + xmb->shadow_offset = 1.0; + + new_font_size = 32.0 * scale_factor; + xmb->font2_size = 24.0 * scale_factor; + new_header_height = 128.0 * scale_factor; + xmb->margins_screen_top = (256+32) * scale_factor; + + xmb->thumbnail_width = 460.0 * scale_factor; + xmb->left_thumbnail_width = 400.0 * scale_factor; + xmb->savestate_thumbnail_width= 460.0 * scale_factor; + xmb->cursor_size = 64.0; + + xmb->icon_spacing_horizontal = 250.0 * scale_factor; + xmb->icon_spacing_vertical = 108.0 * scale_factor; + + xmb->margins_screen_left = 136.0 * scale_factor; + xmb->margins_title_left = 60 * scale_factor; + xmb->margins_title_top = 60 * scale_factor + new_font_size / 3; + xmb->margins_title_bottom = 60 * scale_factor - new_font_size / 3; + xmb->margins_label_left = 85.0 * scale_factor; + xmb->margins_label_top = new_font_size / 3.0; + xmb->margins_setting_left = 600.0 * scale_factor; + xmb->margins_dialog = 48 * scale_factor; + xmb->margins_slice = 16; + xmb->icon_size = 128.0 * scale_factor; + xmb->font_size = new_font_size; + + menu_display_set_header_height(new_header_height); +} + +static void xmb_layout(xmb_handle_t *xmb) +{ + unsigned width, height, i, current, end; + settings_t *settings = config_get_ptr(); + file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); + size_t selection = menu_navigation_get_selection(); + + video_driver_get_size(&width, &height); + + switch (settings->uints.menu_xmb_layout) + { + /* Automatic */ + case 0: + { + xmb->use_ps3_layout = false; + xmb->use_ps3_layout = width > 320 && height > 240; + + /* Mimic the layout of the PSP instead of the PS3 on tiny screens */ + if (xmb->use_ps3_layout) + xmb_layout_ps3(xmb, width); + else + xmb_layout_psp(xmb, width); + } + break; + /* PS3 */ + case 1: + { + xmb->use_ps3_layout = true; + xmb_layout_ps3(xmb, width); + } + break; + /* PSP */ + case 2: + { + xmb->use_ps3_layout = false; + xmb_layout_psp(xmb, width); + } + break; + } + +#ifdef XMB_DEBUG + RARCH_LOG("[XMB] margin screen left: %.2f\n", xmb->margins_screen_left); + RARCH_LOG("[XMB] margin screen top: %.2f\n", xmb->margins_screen_top); + RARCH_LOG("[XMB] margin title left: %.2f\n", xmb->margins_title_left); + RARCH_LOG("[XMB] margin title top: %.2f\n", xmb->margins_title_top); + RARCH_LOG("[XMB] margin title bott: %.2f\n", xmb->margins_title_bottom); + RARCH_LOG("[XMB] margin label left: %.2f\n", xmb->margins_label_left); + RARCH_LOG("[XMB] margin label top: %.2f\n", xmb->margins_label_top); + RARCH_LOG("[XMB] margin sett left: %.2f\n", xmb->margins_setting_left); + RARCH_LOG("[XMB] icon spacing hor: %.2f\n", xmb->icon_spacing_horizontal); + RARCH_LOG("[XMB] icon spacing ver: %.2f\n", xmb->icon_spacing_vertical); + RARCH_LOG("[XMB] icon size: %.2f\n", xmb->icon_size); +#endif + + current = (unsigned)selection; + end = (unsigned)menu_entries_get_size(); + + for (i = 0; i < end; i++) + { + float ia = xmb->items_passive_alpha; + float iz = xmb->items_passive_zoom; + xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset( + selection_buf, i); + + if (!node) + continue; + + if (i == current) + { + ia = xmb->items_active_alpha; + iz = xmb->items_active_alpha; + } + + node->alpha = ia; + node->label_alpha = ia; + node->zoom = iz; + node->y = xmb_item_y(xmb, i, current); + } + + if (xmb->depth <= 1) + return; + + current = (unsigned)xmb->selection_ptr_old; + end = (unsigned)file_list_get_size(xmb->selection_buf_old); + + for (i = 0; i < end; i++) + { + float ia = 0; + float iz = xmb->items_passive_zoom; + xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset( + xmb->selection_buf_old, i); + + if (!node) + continue; + + if (i == current) + { + ia = xmb->items_active_alpha; + iz = xmb->items_active_alpha; + } + + node->alpha = ia; + node->label_alpha = 0; + node->zoom = iz; + node->y = xmb_item_y(xmb, i, current); + node->x = xmb->icon_size * 1 * -2; + } } static void xmb_ribbon_set_vertex(float *ribbon_verts, @@ -5116,6 +4614,528 @@ static bool xmb_load_image(void *userdata, void *data, enum menu_image_type type return true; } +static const char *xmb_texture_path(unsigned id) +{ + char *iconpath = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); + char *icon_name = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); + char *icon_fullpath = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); + + iconpath[0] = icon_name[0] = icon_fullpath[0] = '\0'; + + switch (id) + { + case XMB_TEXTURE_MAIN_MENU: +#if defined(HAVE_LAKKA) + icon_name = "lakka.png"; + break; +#else + icon_name = "retroarch.png"; + break; +#endif + case XMB_TEXTURE_SETTINGS: + icon_name = "settings.png"; + break; + case XMB_TEXTURE_HISTORY: + icon_name = "history.png"; + break; + case XMB_TEXTURE_FAVORITES: + icon_name = "favorites.png"; + break; + case XMB_TEXTURE_ADD_FAVORITE: + icon_name = "add-favorite.png"; + break; + case XMB_TEXTURE_MUSICS: + icon_name = "musics.png"; + break; +#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) + case XMB_TEXTURE_MOVIES: + icon_name = "movies.png"; + break; +#endif +#ifdef HAVE_IMAGEVIEWER + case XMB_TEXTURE_IMAGES: + icon_name = "images.png"; + break; +#endif + case XMB_TEXTURE_SETTING: + icon_name = "setting.png"; + break; + case XMB_TEXTURE_SUBSETTING: + icon_name = "subsetting.png"; + break; + case XMB_TEXTURE_ARROW: + icon_name = "arrow.png"; + break; + case XMB_TEXTURE_RUN: + icon_name = "run.png"; + break; + case XMB_TEXTURE_CLOSE: + icon_name = "close.png"; + break; + case XMB_TEXTURE_RESUME: + icon_name = "resume.png"; + break; + case XMB_TEXTURE_CLOCK: + icon_name = "clock.png"; + break; + case XMB_TEXTURE_BATTERY_FULL: + icon_name = "battery-full.png"; + break; + case XMB_TEXTURE_BATTERY_CHARGING: + icon_name = "battery-charging.png"; + break; + case XMB_TEXTURE_POINTER: + icon_name = "pointer.png"; + break; + case XMB_TEXTURE_SAVESTATE: + icon_name = "savestate.png"; + break; + case XMB_TEXTURE_LOADSTATE: + icon_name = "loadstate.png"; + break; + case XMB_TEXTURE_UNDO: + icon_name = "undo.png"; + break; + case XMB_TEXTURE_CORE_INFO: + icon_name = "core-infos.png"; + break; + case XMB_TEXTURE_WIFI: + icon_name = "wifi.png"; + break; + case XMB_TEXTURE_CORE_OPTIONS: + icon_name = "core-options.png"; + break; + case XMB_TEXTURE_INPUT_REMAPPING_OPTIONS: + icon_name = "core-input-remapping-options.png"; + break; + case XMB_TEXTURE_CHEAT_OPTIONS: + icon_name = "core-cheat-options.png"; + break; + case XMB_TEXTURE_DISK_OPTIONS: + icon_name = "core-disk-options.png"; + break; + case XMB_TEXTURE_SHADER_OPTIONS: + icon_name = "core-shader-options.png"; + break; + case XMB_TEXTURE_ACHIEVEMENT_LIST: + icon_name = "achievement-list.png"; + break; + case XMB_TEXTURE_SCREENSHOT: + icon_name = "screenshot.png"; + break; + case XMB_TEXTURE_RELOAD: + icon_name = "reload.png"; + break; + case XMB_TEXTURE_RENAME: + icon_name = "rename.png"; + break; + case XMB_TEXTURE_FILE: + icon_name = "file.png"; + break; + case XMB_TEXTURE_FOLDER: + icon_name = "folder.png"; + break; + case XMB_TEXTURE_ZIP: + icon_name = "zip.png"; + break; + case XMB_TEXTURE_MUSIC: + icon_name = "music.png"; + break; + case XMB_TEXTURE_FAVORITE: + icon_name = "favorites-content.png"; + break; + case XMB_TEXTURE_IMAGE: + icon_name = "image.png"; + break; + case XMB_TEXTURE_MOVIE: + icon_name = "movie.png"; + break; + case XMB_TEXTURE_CORE: + icon_name = "core.png"; + break; + case XMB_TEXTURE_RDB: + icon_name = "database.png"; + break; + case XMB_TEXTURE_CURSOR: + icon_name = "cursor.png"; + break; + case XMB_TEXTURE_SWITCH_ON: + icon_name = "on.png"; + break; + case XMB_TEXTURE_SWITCH_OFF: + icon_name = "off.png"; + break; + case XMB_TEXTURE_ADD: + icon_name = "add.png"; + break; +#ifdef HAVE_NETWORKING + case XMB_TEXTURE_NETPLAY: + icon_name = "netplay.png"; + break; + case XMB_TEXTURE_ROOM: + icon_name = "menu_room.png"; + break; + case XMB_TEXTURE_ROOM_LAN: + icon_name = "menu_room_lan.png"; + break; + case XMB_TEXTURE_ROOM_RELAY: + icon_name = "menu_room_relay.png"; + break; +#endif + case XMB_TEXTURE_KEY: + icon_name = "key.png"; + break; + case XMB_TEXTURE_KEY_HOVER: + icon_name = "key-hover.png"; + break; + case XMB_TEXTURE_DIALOG_SLICE: + icon_name = "dialog-slice.png"; + break; + case XMB_TEXTURE_ACHIEVEMENTS: + icon_name = "menu_achievements.png"; + break; + case XMB_TEXTURE_AUDIO: + icon_name = "menu_audio.png"; + break; + case XMB_TEXTURE_DRIVERS: + icon_name = "menu_drivers.png"; + break; + case XMB_TEXTURE_EXIT: + icon_name = "menu_exit.png"; + break; + case XMB_TEXTURE_FRAMESKIP: + icon_name = "menu_frameskip.png"; + break; + case XMB_TEXTURE_HELP: + icon_name = "menu_help.png"; + break; + case XMB_TEXTURE_INFO: + icon_name = "menu_info.png"; + break; + case XMB_TEXTURE_INPUT_SETTINGS: + icon_name = "Libretro - Pad.png"; + break; + case XMB_TEXTURE_LATENCY: + icon_name = "menu_latency.png"; + break; + case XMB_TEXTURE_NETWORK: + icon_name = "menu_network.png"; + break; + case XMB_TEXTURE_POWER: + icon_name = "menu_power.png"; + break; + case XMB_TEXTURE_RECORD: + icon_name = "menu_record.png"; + break; + case XMB_TEXTURE_SAVING: + icon_name = "menu_saving.png"; + break; + case XMB_TEXTURE_UPDATER: + icon_name = "menu_updater.png"; + break; + case XMB_TEXTURE_VIDEO: + icon_name = "menu_video.png"; + break; + case XMB_TEXTURE_MIXER: + icon_name = "menu_mixer.png"; + break; + case XMB_TEXTURE_LOG: + icon_name = "menu_log.png"; + break; + case XMB_TEXTURE_OSD: + icon_name = "menu_osd.png"; + break; + case XMB_TEXTURE_UI: + icon_name = "menu_ui.png"; + break; + case XMB_TEXTURE_USER: + icon_name = "menu_user.png"; + break; + case XMB_TEXTURE_PRIVACY: + icon_name = "menu_privacy.png"; + break; + case XMB_TEXTURE_PLAYLIST: + icon_name = "menu_playlist.png"; + break; + case XMB_TEXTURE_QUICKMENU: + icon_name = "menu_quickmenu.png"; + break; + case XMB_TEXTURE_REWIND: + icon_name = "menu_rewind.png"; + break; + case XMB_TEXTURE_OVERLAY: + icon_name = "menu_overlay.png"; + break; + case XMB_TEXTURE_OVERRIDE: + icon_name = "menu_override.png"; + break; + case XMB_TEXTURE_NOTIFICATIONS: + icon_name = "menu_notifications.png"; + break; + case XMB_TEXTURE_STREAM: + icon_name = "menu_stream.png"; + break; + case XMB_TEXTURE_SHUTDOWN: + icon_name = "menu_shutdown.png"; + break; + case XMB_TEXTURE_INPUT_DPAD_U: + icon_name = "input_DPAD-U.png"; + break; + case XMB_TEXTURE_INPUT_DPAD_D: + icon_name = "input_DPAD-D.png"; + break; + case XMB_TEXTURE_INPUT_DPAD_L: + icon_name = "input_DPAD-L.png"; + break; + case XMB_TEXTURE_INPUT_DPAD_R: + icon_name = "input_DPAD-R.png"; + break; + case XMB_TEXTURE_INPUT_STCK_U: + icon_name = "input_STCK-U.png"; + break; + case XMB_TEXTURE_INPUT_STCK_D: + icon_name = "input_STCK-D.png"; + break; + case XMB_TEXTURE_INPUT_STCK_L: + icon_name = "input_STCK-L.png"; + break; + case XMB_TEXTURE_INPUT_STCK_R: + icon_name = "input_STCK-R.png"; + break; + case XMB_TEXTURE_INPUT_STCK_P: + icon_name = "input_STCK-P.png"; + break; + case XMB_TEXTURE_INPUT_BTN_U: + icon_name = "input_BTN-U.png"; + break; + case XMB_TEXTURE_INPUT_BTN_D: + icon_name = "input_BTN-D.png"; + break; + case XMB_TEXTURE_INPUT_BTN_L: + icon_name = "input_BTN-L.png"; + break; + case XMB_TEXTURE_INPUT_BTN_R: + icon_name = "input_BTN-R.png"; + break; + case XMB_TEXTURE_INPUT_LB: + icon_name = "input_LB.png"; + break; + case XMB_TEXTURE_INPUT_RB: + icon_name = "input_RB.png"; + break; + case XMB_TEXTURE_INPUT_LT: + icon_name = "input_LT.png"; + break; + case XMB_TEXTURE_INPUT_RT: + icon_name = "input_RT.png"; + break; + case XMB_TEXTURE_INPUT_SELECT: + icon_name = "input_SELECT.png"; + break; + case XMB_TEXTURE_INPUT_START: + icon_name = "input_START.png"; + break; + case XMB_TEXTURE_CHECKMARK: + icon_name = "menu_check.png"; + break; + case XMB_TEXTURE_MENU_ADD: + icon_name = "menu_add.png"; + break; + case XMB_TEXTURE_BRIGHTNESS: + icon_name = "menu_brightness.png"; + break; + case XMB_TEXTURE_PAUSE: + icon_name = "menu_pause.png"; + break; + } + + fill_pathname_application_special(iconpath, + PATH_MAX_LENGTH * sizeof(char), + APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); + + icon_fullpath = iconpath; + strlcat(icon_fullpath, icon_name, PATH_MAX_LENGTH * sizeof(char)); + + if (!filestream_exists(icon_fullpath)) + { + RARCH_WARN("[XMB] Asset missing: %s\n", icon_fullpath); + return NULL; + } + else + return icon_name; + +} + +static void xmb_context_reset_textures( + xmb_handle_t *xmb, const char *iconpath) +{ + unsigned i; + settings_t *settings = config_get_ptr(); + + for (i = 0; i < XMB_TEXTURE_LAST; i++) + { + if (xmb_texture_path(i) == NULL) + { + /* If the icon doesn't exist at least try to return the subsetting icon*/ + if (!(i == XMB_TEXTURE_DIALOG_SLICE || i == XMB_TEXTURE_KEY_HOVER || i == XMB_TEXTURE_KEY_HOVER)) + menu_display_reset_textures_list(xmb_texture_path(XMB_TEXTURE_SUBSETTING), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); + continue; + } + menu_display_reset_textures_list(xmb_texture_path(i), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); + } + + /* Warn only if critical assets are missing, some themes are incomplete */ + if ( + ((xmb_texture_path(XMB_TEXTURE_SUBSETTING) == NULL)) && !(settings->uints.menu_xmb_theme == XMB_ICON_THEME_CUSTOM) + ) + runloop_msg_queue_push(msg_hash_to_str(MSG_MISSING_ASSETS), 1, 256, false); + + menu_display_allocate_white_texture(); + + xmb->main_menu_node.icon = xmb->textures.list[XMB_TEXTURE_MAIN_MENU]; + xmb->main_menu_node.alpha = xmb->categories_active_alpha; + xmb->main_menu_node.zoom = xmb->categories_active_zoom; + + xmb->settings_tab_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS]; + xmb->settings_tab_node.alpha = xmb->categories_active_alpha; + xmb->settings_tab_node.zoom = xmb->categories_active_zoom; + + xmb->history_tab_node.icon = xmb->textures.list[XMB_TEXTURE_HISTORY]; + xmb->history_tab_node.alpha = xmb->categories_active_alpha; + xmb->history_tab_node.zoom = xmb->categories_active_zoom; + + xmb->favorites_tab_node.icon = xmb->textures.list[XMB_TEXTURE_FAVORITES]; + xmb->favorites_tab_node.alpha = xmb->categories_active_alpha; + xmb->favorites_tab_node.zoom = xmb->categories_active_zoom; + + xmb->music_tab_node.icon = xmb->textures.list[XMB_TEXTURE_MUSICS]; + xmb->music_tab_node.alpha = xmb->categories_active_alpha; + xmb->music_tab_node.zoom = xmb->categories_active_zoom; + +#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) + xmb->video_tab_node.icon = xmb->textures.list[XMB_TEXTURE_MOVIES]; + xmb->video_tab_node.alpha = xmb->categories_active_alpha; + xmb->video_tab_node.zoom = xmb->categories_active_zoom; +#endif + +#ifdef HAVE_IMAGEVIEWER + xmb->images_tab_node.icon = xmb->textures.list[XMB_TEXTURE_IMAGES]; + xmb->images_tab_node.alpha = xmb->categories_active_alpha; + xmb->images_tab_node.zoom = xmb->categories_active_zoom; +#endif + + xmb->add_tab_node.icon = xmb->textures.list[XMB_TEXTURE_ADD]; + xmb->add_tab_node.alpha = xmb->categories_active_alpha; + xmb->add_tab_node.zoom = xmb->categories_active_zoom; + +#ifdef HAVE_NETWORKING + xmb->netplay_tab_node.icon = xmb->textures.list[XMB_TEXTURE_NETPLAY]; + xmb->netplay_tab_node.alpha = xmb->categories_active_alpha; + xmb->netplay_tab_node.zoom = xmb->categories_active_zoom; +#endif + +} + +static void xmb_context_reset_background(const char *iconpath) +{ + char *path = NULL; + settings_t *settings = config_get_ptr(); + const char *path_menu_wp = settings->paths.path_menu_wallpaper; + + if (!string_is_empty(path_menu_wp)) + path = strdup(path_menu_wp); + else if (!string_is_empty(iconpath)) + { + path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + path[0] = '\0'; + + fill_pathname_join(path, iconpath, "bg.png", + PATH_MAX_LENGTH * sizeof(char)); + } + + if (filestream_exists(path)) + task_push_image_load(path, + menu_display_handle_wallpaper_upload, NULL); + + if (path) + free(path); +} + +static void xmb_context_reset_internal(xmb_handle_t *xmb, + bool is_threaded, bool reinit_textures) +{ + char bg_file_path[PATH_MAX_LENGTH] = {0}; + char *iconpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + iconpath[0] = '\0'; + + fill_pathname_application_special(bg_file_path, + sizeof(bg_file_path), APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_BG); + + if (!string_is_empty(bg_file_path)) + { + if (!string_is_empty(xmb->bg_file_path)) + free(xmb->bg_file_path); + xmb->bg_file_path = strdup(bg_file_path); + } + + fill_pathname_application_special(iconpath, + PATH_MAX_LENGTH * sizeof(char), + APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); + + xmb_layout(xmb); + if (xmb->font) + { + menu_display_font_free(xmb->font); + xmb->font = NULL; + } + if (xmb->font2) + { + menu_display_font_free(xmb->font2); + xmb->font2 = NULL; + } + xmb->font = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, + xmb->font_size, + is_threaded); + xmb->font2 = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, + xmb->font2_size, + is_threaded); + + if (reinit_textures) + { + xmb_context_reset_textures(xmb, iconpath); + xmb_context_reset_background(iconpath); + } + + xmb_context_reset_horizontal_list(xmb); + + if (!string_is_equal(xmb_thumbnails_ident('R'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + xmb_update_thumbnail_path(xmb, 0, 'R'); + xmb_update_thumbnail_image(xmb); + } + if (!string_is_equal(xmb_thumbnails_ident('L'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + xmb_update_thumbnail_path(xmb, 0, 'L'); + xmb_update_thumbnail_image(xmb); + } + xmb_update_savestate_thumbnail_image(xmb); + + free(iconpath); +} + +static void xmb_context_reset(void *data, bool is_threaded) +{ + xmb_handle_t *xmb = (xmb_handle_t*)data; + + if (xmb) + { + xmb_context_reset_internal(xmb, is_threaded, true); + xmb->context_just_reset = true; + } +} + static void xmb_navigation_clear(void *data, bool pending_push) { xmb_handle_t *xmb = (xmb_handle_t*)data; From f9c12866bfaadb6803abbf49b3fc3bb0d22f82f0 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 25 Nov 2018 15:20:11 -0500 Subject: [PATCH 060/153] [record] add more recording options --- menu/menu_setting.c | 11 ++++- record/drivers/record_ffmpeg.c | 81 +++++++++++++++++++++++++++++++--- record/record_driver.c | 22 +++++++-- record/record_driver.h | 4 ++ 4 files changed, 106 insertions(+), 12 deletions(-) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 1d76dedf57..56c444f7c7 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -375,6 +375,15 @@ static void setting_get_string_representation_video_record_quality(rarch_setting case 4: strlcpy(s, "Lossless", len); break; + case 5: + strlcpy(s, "WebM Fast", len); + break; + case 6: + strlcpy(s, "WebM High Quality", len); + break; + case 7: + strlcpy(s, "GIF", len); + break; } } @@ -6689,7 +6698,7 @@ static bool setting_append_list( (*list)[list_info->index - 1].action_ok = &setting_action_ok_uint; (*list)[list_info->index - 1].get_string_representation = &setting_get_string_representation_video_record_quality; - menu_settings_list_current_add_range(list, list_info, RECORD_CONFIG_TYPE_RECORDING_CUSTOM, RECORD_CONFIG_TYPE_RECORDING_LOSSLESS_QUALITY, 1, true, true); + menu_settings_list_current_add_range(list, list_info, RECORD_CONFIG_TYPE_RECORDING_CUSTOM, RECORD_CONFIG_TYPE_RECORDING_GIF, 1, true, true); CONFIG_PATH( list, list_info, diff --git a/record/drivers/record_ffmpeg.c b/record/drivers/record_ffmpeg.c index b181492bde..e12ccfc28f 100644 --- a/record/drivers/record_ffmpeg.c +++ b/record/drivers/record_ffmpeg.c @@ -97,6 +97,14 @@ extern "C" { #define PIX_FMT_BGR24 AV_PIX_FMT_BGR24 #endif +#ifndef PIX_FMT_RGB24 +#define PIX_FMT_RGB24 AV_PIX_FMT_RGB24 +#endif + +#ifndef PIX_FMT_RGB8 +#define PIX_FMT_RGB8 AV_PIX_FMT_RGB8 +#endif + #ifndef PIX_FMT_RGB565 #define PIX_FMT_RGB565 AV_PIX_FMT_RGB565 #endif @@ -556,7 +564,7 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p { case RECORD_CONFIG_TYPE_RECORDING_LOW_QUALITY: case RECORD_CONFIG_TYPE_STREAMING_LOW_QUALITY: - params->threads = 1; + params->threads = 2; params->frame_drop_ratio = 1; params->audio_enable = true; params->audio_global_quality = 75; @@ -572,7 +580,7 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p break; case RECORD_CONFIG_TYPE_RECORDING_MED_QUALITY: case RECORD_CONFIG_TYPE_STREAMING_MED_QUALITY: - params->threads = 1; + params->threads = 2; params->frame_drop_ratio = 1; params->audio_enable = true; params->audio_global_quality = 75; @@ -588,7 +596,7 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p break; case RECORD_CONFIG_TYPE_RECORDING_HIGH_QUALITY: case RECORD_CONFIG_TYPE_STREAMING_HIGH_QUALITY: - params->threads = 1; + params->threads = 2; params->frame_drop_ratio = 1; params->audio_enable = true; params->audio_global_quality = 100; @@ -603,10 +611,10 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p av_dict_set(¶ms->audio_opts, "audio_global_quality", "100", 0); break; case RECORD_CONFIG_TYPE_RECORDING_LOSSLESS_QUALITY: - params->threads = 1; + params->threads = 2; params->frame_drop_ratio = 1; params->audio_enable = true; - params->audio_global_quality = 100; + params->audio_global_quality = 80; params->out_pix_fmt = PIX_FMT_BGR24; strlcpy(params->vcodec, "libx264rgb", sizeof(params->vcodec)); @@ -615,10 +623,51 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p av_dict_set(¶ms->video_opts, "preset", "medium", 0); av_dict_set(¶ms->video_opts, "tune", "animation", 0); av_dict_set(¶ms->video_opts, "crf", "0", 0); - av_dict_set(¶ms->audio_opts, "audio_global_quality", "100", 0); + av_dict_set(¶ms->audio_opts, "audio_global_quality", "80", 0); + break; + case RECORD_CONFIG_TYPE_RECORDING_WEBM_FAST: + params->threads = 2; + params->frame_drop_ratio = 1; + params->audio_enable = true; + params->audio_global_quality = 50; + params->out_pix_fmt = PIX_FMT_YUV420P; + + strlcpy(params->vcodec, "libvpx", sizeof(params->vcodec)); + strlcpy(params->acodec, "libopus", sizeof(params->acodec)); + + av_dict_set(¶ms->video_opts, "deadline", "realtime", 0); + av_dict_set(¶ms->video_opts, "crf", "14", 0); + av_dict_set(¶ms->audio_opts, "audio_global_quality", "50", 0); + break; + case RECORD_CONFIG_TYPE_RECORDING_WEBM_HIGH_QUALITY: + params->threads = 2; + params->frame_drop_ratio = 1; + params->audio_enable = true; + params->audio_global_quality = 75; + params->out_pix_fmt = PIX_FMT_YUV420P; + + strlcpy(params->vcodec, "libvpx", sizeof(params->vcodec)); + strlcpy(params->acodec, "libopus", sizeof(params->acodec)); + + av_dict_set(¶ms->video_opts, "deadline", "realtime", 0); + av_dict_set(¶ms->video_opts, "crf", "4", 0); + av_dict_set(¶ms->audio_opts, "audio_global_quality", "75", 0); + break; + case RECORD_CONFIG_TYPE_RECORDING_GIF: + params->threads = 2; + params->frame_drop_ratio = 1; + params->audio_enable = false; + params->audio_global_quality = 0; + params->out_pix_fmt = PIX_FMT_RGB8; + + strlcpy(params->vcodec, "gif", sizeof(params->vcodec)); + strlcpy(params->acodec, "", sizeof(params->acodec)); + + av_dict_set(¶ms->video_opts, "framerate", "50", 0); + av_dict_set(¶ms->audio_opts, "audio_global_quality", "0", 0); break; case RECORD_CONFIG_TYPE_STREAMING_NETPLAY: - params->threads = 1; + params->threads = 2; params->frame_drop_ratio = 1; params->audio_enable = true; params->audio_global_quality = 50; @@ -645,6 +694,24 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p params->scale_factor = 1; strlcpy(params->format, "matroska", sizeof(params->format)); } + else if (preset >= RECORD_CONFIG_TYPE_RECORDING_WEBM_FAST && settings->uints.video_record_quality < RECORD_CONFIG_TYPE_RECORDING_GIF) + { + if (!settings->bools.video_gpu_record) + params->scale_factor = settings->uints.video_record_scale_factor > 0 ? + settings->uints.video_record_scale_factor : 1; + else + params->scale_factor = 1; + strlcpy(params->format, "webm", sizeof(params->format)); + } + else if (preset <= RECORD_CONFIG_TYPE_STREAMING_LOW_QUALITY) + { + if (!settings->bools.video_gpu_record) + params->scale_factor = settings->uints.video_record_scale_factor > 0 ? + settings->uints.video_record_scale_factor : 1; + else + params->scale_factor = 1; + strlcpy(params->format, "gif", sizeof(params->format)); + } else if (preset <= RECORD_CONFIG_TYPE_STREAMING_HIGH_QUALITY) { if (!settings->bools.video_gpu_record) diff --git a/record/record_driver.c b/record/record_driver.c index 9426b58e2f..e92f0d8724 100644 --- a/record/record_driver.c +++ b/record/record_driver.c @@ -366,10 +366,24 @@ bool recording_init(void) else { const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME)); - fill_str_dated_filename(buf, game_name, - "mkv", sizeof(buf)); - fill_pathname_join(output, global->record.output_dir, buf, sizeof(output)); - + if (settings->uints.video_record_quality < RECORD_CONFIG_TYPE_RECORDING_WEBM_FAST) + { + fill_str_dated_filename(buf, game_name, + "mkv", sizeof(buf)); + fill_pathname_join(output, global->record.output_dir, buf, sizeof(output)); + } + else if (settings->uints.video_record_quality >= RECORD_CONFIG_TYPE_RECORDING_WEBM_FAST && settings->uints.video_record_quality < RECORD_CONFIG_TYPE_RECORDING_GIF) + { + fill_str_dated_filename(buf, game_name, + "webm", sizeof(buf)); + fill_pathname_join(output, global->record.output_dir, buf, sizeof(output)); + } + else + { + fill_str_dated_filename(buf, game_name, + "gif", sizeof(buf)); + fill_pathname_join(output, global->record.output_dir, buf, sizeof(output)); + } } } diff --git a/record/record_driver.h b/record/record_driver.h index 6f29831549..8d034f8939 100644 --- a/record/record_driver.h +++ b/record/record_driver.h @@ -46,11 +46,15 @@ enum record_config_type RECORD_CONFIG_TYPE_RECORDING_MED_QUALITY, RECORD_CONFIG_TYPE_RECORDING_HIGH_QUALITY, RECORD_CONFIG_TYPE_RECORDING_LOSSLESS_QUALITY, + RECORD_CONFIG_TYPE_RECORDING_WEBM_FAST, + RECORD_CONFIG_TYPE_RECORDING_WEBM_HIGH_QUALITY, + RECORD_CONFIG_TYPE_RECORDING_GIF, RECORD_CONFIG_TYPE_STREAMING_CUSTOM, RECORD_CONFIG_TYPE_STREAMING_LOW_QUALITY, RECORD_CONFIG_TYPE_STREAMING_MED_QUALITY, RECORD_CONFIG_TYPE_STREAMING_HIGH_QUALITY, RECORD_CONFIG_TYPE_STREAMING_NETPLAY + }; /* Parameters passed to ffemu_new() */ From 0bf0e355ec51ce84584f262aa14d05bea9fa1f1f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 25 Nov 2018 21:51:09 +0100 Subject: [PATCH 061/153] This stops the crashes with video_get_output_size/next/prev --- gfx/video_thread_wrapper.c | 40 ++++++++------------------------------ 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index 147ec5782b..7f3b2a2c0e 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -48,9 +48,6 @@ enum thread_cmd CMD_POKE_SET_VIDEO_MODE, CMD_POKE_SET_FILTERING, - CMD_POKE_GET_VIDEO_OUTPUT_SIZE, - CMD_POKE_GET_VIDEO_OUTPUT_PREV, - CMD_POKE_GET_VIDEO_OUTPUT_NEXT, CMD_POKE_SET_FBO_STATE, CMD_POKE_GET_FBO_STATE, @@ -499,26 +496,6 @@ static bool video_thread_handle_packet( video_thread_reply(thr, &pkt); break; - case CMD_POKE_GET_VIDEO_OUTPUT_SIZE: - if (thr->poke && thr->poke->get_video_output_size) - thr->poke->get_video_output_size(thr->driver_data, - &pkt.data.output.width, - &pkt.data.output.height); - video_thread_reply(thr, &pkt); - break; - - case CMD_POKE_GET_VIDEO_OUTPUT_PREV: - if (thr->poke && thr->poke->get_video_output_prev) - thr->poke->get_video_output_prev(thr->driver_data); - video_thread_reply(thr, &pkt); - break; - - case CMD_POKE_GET_VIDEO_OUTPUT_NEXT: - if (thr->poke && thr->poke->get_video_output_next) - thr->poke->get_video_output_next(thr->driver_data); - video_thread_reply(thr, &pkt); - break; - case CMD_POKE_SET_ASPECT_RATIO: if (thr->poke && thr->poke->set_aspect_ratio) thr->poke->set_aspect_ratio(thr->driver_data, @@ -1107,37 +1084,36 @@ static void thread_get_video_output_size(void *data, unsigned *width, unsigned *height) { thread_video_t *thr = (thread_video_t*)data; - thread_packet_t pkt = { CMD_POKE_GET_VIDEO_OUTPUT_SIZE }; if (!thr) return; - video_thread_send_and_wait_user_to_thread(thr, &pkt); - - *width = pkt.data.output.width; - *height = pkt.data.output.height; + if (thr->poke && thr->poke->get_video_output_size) + thr->poke->get_video_output_size(thr->driver_data, + width, + height); } static void thread_get_video_output_prev(void *data) { thread_video_t *thr = (thread_video_t*)data; - thread_packet_t pkt = { CMD_POKE_GET_VIDEO_OUTPUT_PREV }; if (!thr) return; - video_thread_send_and_wait_user_to_thread(thr, &pkt); + if (thr->poke && thr->poke->get_video_output_prev) + thr->poke->get_video_output_prev(thr->driver_data); } static void thread_get_video_output_next(void *data) { thread_video_t *thr = (thread_video_t*)data; - thread_packet_t pkt = { CMD_POKE_GET_VIDEO_OUTPUT_NEXT }; if (!thr) return; - video_thread_send_and_wait_user_to_thread(thr, &pkt); + if (thr->poke && thr->poke->get_video_output_next) + thr->poke->get_video_output_next(thr->driver_data); } static void thread_set_aspect_ratio(void *data, unsigned aspectratio_idx) From 665be01b6b065b79d5a0e0a683de2548f21559df Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 25 Nov 2018 15:41:26 -0500 Subject: [PATCH 062/153] [record] add recording threads setting --- config.def.h | 4 ++++ configuration.c | 2 ++ configuration.h | 2 ++ intl/msg_hash_us.h | 4 ++++ menu/menu_displaylist.c | 4 ++++ menu/menu_setting.c | 27 +++++++++++++++++++++------ msg_hash.h | 1 + record/drivers/record_ffmpeg.c | 16 ++++++++-------- 8 files changed, 46 insertions(+), 14 deletions(-) diff --git a/config.def.h b/config.def.h index 618fba6174..85a7104506 100644 --- a/config.def.h +++ b/config.def.h @@ -125,6 +125,10 @@ static const unsigned window_height = 720; static const unsigned fullscreen_x = 0; static const unsigned fullscreen_y = 0; +/* Number of threads to use for video recording */ + +static const unsigned video_record_threads = 2; + /* Amount of transparency to use for the main window. * 1 is the most transparent while 100 is opaque. */ diff --git a/configuration.c b/configuration.c index 947011d30f..0d209a5940 100644 --- a/configuration.c +++ b/configuration.c @@ -1676,6 +1676,8 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings, SETTING_UINT("video_windowed_position_width", &settings->uints.window_position_width, true, window_width, false); SETTING_UINT("video_windowed_position_height", &settings->uints.window_position_height, true, window_height, false); + SETTING_UINT("video_record_threads", &settings->uints.video_record_threads, true, video_record_threads, false); + *size = count; return tmp; diff --git a/configuration.h b/configuration.h index 7555118d62..dee5497cb8 100644 --- a/configuration.h +++ b/configuration.h @@ -443,6 +443,8 @@ typedef struct settings unsigned window_position_y; unsigned window_position_width; unsigned window_position_height; + + unsigned video_record_threads; } uints; struct diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index f400919e98..15bd1b26c3 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -3206,6 +3206,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SCALE, "Windowed Scale" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_VIDEO_RECORD_THREADS, + "Recording Threads" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SCALE_INTEGER, "Integer Scale" diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 36a9713301..11150ebf71 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -7316,6 +7316,10 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist MENU_ENUM_LABEL_STREAMING_MODE, PARSE_ONLY_UINT, false) == 0) count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_VIDEO_RECORD_THREADS, + PARSE_ONLY_UINT, true) == 0) + count++; if (menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_STREAMING_TITLE, PARSE_ONLY_STRING, false) == 0) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 56c444f7c7..edf7979b35 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -336,16 +336,16 @@ static void setting_get_string_representation_video_stream_quality( /* TODO/FIXME - localize this */ switch (*setting->value.target.unsigned_integer) { - case 5: + case 8: strlcpy(s, "Custom", len); break; - case 6: + case 9: strlcpy(s, "Low", len); break; - case 7: + case 10: strlcpy(s, "Medium", len); break; - case 8: + case 11: strlcpy(s, "High", len); break; } @@ -6759,7 +6759,7 @@ static bool setting_append_list( (*list)[list_info->index - 1].offset_by = 1; menu_settings_list_current_add_range(list, list_info, 1, 65536, 1, true, true); - CONFIG_UINT( + CONFIG_UINT( list, list_info, &settings->uints.video_stream_quality, MENU_ENUM_LABEL_VIDEO_STREAM_QUALITY, @@ -6773,7 +6773,6 @@ static bool setting_append_list( (*list)[list_info->index - 1].action_ok = &setting_action_ok_uint; (*list)[list_info->index - 1].get_string_representation = &setting_get_string_representation_video_stream_quality; - (*list)[list_info->index - 1].offset_by = 5; menu_settings_list_current_add_range(list, list_info, RECORD_CONFIG_TYPE_STREAMING_CUSTOM, RECORD_CONFIG_TYPE_STREAMING_HIGH_QUALITY, 1, true, true); CONFIG_PATH( @@ -6804,6 +6803,22 @@ static bool setting_append_list( general_read_handler); settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); + + CONFIG_UINT( + list, list_info, + &settings->uints.video_record_threads, + MENU_ENUM_LABEL_VIDEO_RECORD_THREADS, + MENU_ENUM_LABEL_VALUE_VIDEO_RECORD_THREADS, + video_record_threads, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); + (*list)[list_info->index - 1].action_ok = &setting_action_ok_uint_special; + menu_settings_list_current_add_range(list, list_info, 1, 8, 1, true, true); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_LAKKA_ADVANCED); + CONFIG_DIR( list, list_info, global->record.output_dir, diff --git a/msg_hash.h b/msg_hash.h index e457eb3c30..3c16be4e89 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -758,6 +758,7 @@ enum msg_hash_enums MENU_LABEL(VIDEO_FORCE_SRGB_DISABLE), MENU_LABEL(VIDEO_ROTATION), MENU_LABEL(VIDEO_SCALE), + MENU_LABEL(VIDEO_RECORD_THREADS), MENU_LABEL(VIDEO_SMOOTH), MENU_LABEL(VIDEO_CROP_OVERSCAN), diff --git a/record/drivers/record_ffmpeg.c b/record/drivers/record_ffmpeg.c index e12ccfc28f..f085a66a7e 100644 --- a/record/drivers/record_ffmpeg.c +++ b/record/drivers/record_ffmpeg.c @@ -564,7 +564,7 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p { case RECORD_CONFIG_TYPE_RECORDING_LOW_QUALITY: case RECORD_CONFIG_TYPE_STREAMING_LOW_QUALITY: - params->threads = 2; + params->threads = settings->uints.video_record_threads; params->frame_drop_ratio = 1; params->audio_enable = true; params->audio_global_quality = 75; @@ -580,7 +580,7 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p break; case RECORD_CONFIG_TYPE_RECORDING_MED_QUALITY: case RECORD_CONFIG_TYPE_STREAMING_MED_QUALITY: - params->threads = 2; + params->threads = settings->uints.video_record_threads; params->frame_drop_ratio = 1; params->audio_enable = true; params->audio_global_quality = 75; @@ -596,7 +596,7 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p break; case RECORD_CONFIG_TYPE_RECORDING_HIGH_QUALITY: case RECORD_CONFIG_TYPE_STREAMING_HIGH_QUALITY: - params->threads = 2; + params->threads = settings->uints.video_record_threads; params->frame_drop_ratio = 1; params->audio_enable = true; params->audio_global_quality = 100; @@ -611,7 +611,7 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p av_dict_set(¶ms->audio_opts, "audio_global_quality", "100", 0); break; case RECORD_CONFIG_TYPE_RECORDING_LOSSLESS_QUALITY: - params->threads = 2; + params->threads = settings->uints.video_record_threads; params->frame_drop_ratio = 1; params->audio_enable = true; params->audio_global_quality = 80; @@ -626,7 +626,7 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p av_dict_set(¶ms->audio_opts, "audio_global_quality", "80", 0); break; case RECORD_CONFIG_TYPE_RECORDING_WEBM_FAST: - params->threads = 2; + params->threads = settings->uints.video_record_threads; params->frame_drop_ratio = 1; params->audio_enable = true; params->audio_global_quality = 50; @@ -640,7 +640,7 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p av_dict_set(¶ms->audio_opts, "audio_global_quality", "50", 0); break; case RECORD_CONFIG_TYPE_RECORDING_WEBM_HIGH_QUALITY: - params->threads = 2; + params->threads = settings->uints.video_record_threads; params->frame_drop_ratio = 1; params->audio_enable = true; params->audio_global_quality = 75; @@ -654,7 +654,7 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p av_dict_set(¶ms->audio_opts, "audio_global_quality", "75", 0); break; case RECORD_CONFIG_TYPE_RECORDING_GIF: - params->threads = 2; + params->threads = settings->uints.video_record_threads; params->frame_drop_ratio = 1; params->audio_enable = false; params->audio_global_quality = 0; @@ -667,7 +667,7 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p av_dict_set(¶ms->audio_opts, "audio_global_quality", "0", 0); break; case RECORD_CONFIG_TYPE_STREAMING_NETPLAY: - params->threads = 2; + params->threads = settings->uints.video_record_threads; params->frame_drop_ratio = 1; params->audio_enable = true; params->audio_global_quality = 50; From 1187df922a95b6e1f553a571d529e46176eac9bb Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 25 Nov 2018 17:24:54 -0500 Subject: [PATCH 063/153] restore old functionality till the change is done in other platforms --- gfx/video_driver.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index c3157f8c6c..e544ab2762 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -985,16 +985,25 @@ static bool video_driver_init_internal(bool *video_is_threaded) } else { - if (settings->bools.video_force_aspect) + /* To-Do: remove when the new window resizing core is hooked */ + if (settings->uints.window_position_width || settings->uints.window_position_height) { - /* Do rounding here to simplify integer scale correctness. */ - unsigned base_width = - roundf(geom->base_height * video_driver_get_aspect_ratio()); - width = roundf(base_width * settings->floats.video_scale); + width = settings->uints.window_position_width; + height = settings->uints.window_position_height; } else - width = roundf(geom->base_width * settings->floats.video_scale); - height = roundf(geom->base_height * settings->floats.video_scale); + { + if (settings->bools.video_force_aspect) + { + /* Do rounding here to simplify integer scale correctness. */ + unsigned base_width = + roundf(geom->base_height * video_driver_get_aspect_ratio()); + width = roundf(base_width * settings->floats.video_scale); + } + else + width = roundf(geom->base_width * settings->floats.video_scale); + height = roundf(geom->base_height * settings->floats.video_scale); +} } if (width && height) From 94211bf833e8ec19c7f6a86c92de07813b259b77 Mon Sep 17 00:00:00 2001 From: natinusala Date: Mon, 26 Nov 2018 00:13:11 +0100 Subject: [PATCH 064/153] xmb: fix hang when resizing with threaded video driver --- menu/drivers/xmb.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 4bb2b29ab8..34ce6f6e1f 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1,8 +1,8 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * Copyright (C) 2014-2017 - Jean-Andr Santoni + * Copyright (C) 2014-2017 - Jean-André Santoni * Copyright (C) 2016-2017 - Brad Parker - * Copyright (C) 2018 - Alfredo Moncls + * Copyright (C) 2018 - Alfredo Monclús * * 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- @@ -3103,6 +3103,9 @@ static void xmb_draw_items( menu_display_blend_end(video_info); } +static void xmb_context_reset_internal(xmb_handle_t *xmb, + bool is_threaded, bool reinit_textures); + static void xmb_render(void *data, bool is_idle) { size_t i; @@ -3113,9 +3116,25 @@ static void xmb_render(void *data, bool is_idle) bool mouse_enable = settings->bools.menu_mouse_enable; bool pointer_enable = settings->bools.menu_pointer_enable; - if (!xmb) + unsigned width, height; + float scale_factor; + + if (!xmb) return; + video_driver_get_size(&width, &height); + + scale_factor = (settings->uints.menu_xmb_scale_factor * (float)width) / (1920.0 * 100); + + if (scale_factor != xmb->previous_scale_factor && !xmb->context_just_reset) + xmb_context_reset_internal(xmb, video_driver_is_threaded(), + false); + + if (xmb->context_just_reset) + xmb->context_just_reset = false; + + xmb->previous_scale_factor = scale_factor; + delta.current = menu_animation_get_delta_time(); if (menu_animation_get_ideal_delta_time(&delta)) @@ -3320,9 +3339,6 @@ static void xmb_draw_dark_layer( menu_display_blend_end(video_info); } -static void xmb_context_reset_internal(xmb_handle_t *xmb, - bool is_threaded, bool reinit_textures); - static void xmb_frame(void *data, video_frame_info_t *video_info) { math_matrix_4x4 mymat; @@ -3352,15 +3368,6 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) scale_factor = (settings->uints.menu_xmb_scale_factor * (float)width) / (1920.0 * 100); pseudo_font_length = xmb->icon_spacing_horizontal * 4 - xmb->icon_size / 4; - if (scale_factor != xmb->previous_scale_factor && !xmb->context_just_reset) - xmb_context_reset_internal(xmb, video_driver_is_threaded(), - false); - - if (xmb->context_just_reset) - xmb->context_just_reset = false; - - xmb->previous_scale_factor = scale_factor; - xmb->frame_count++; msg[0] = '\0'; From 48dcd9640e3cae4f338c7799893ccab0db7dea11 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 26 Nov 2018 01:48:26 +0100 Subject: [PATCH 065/153] Remove this --- menu/drivers/xmb.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 34ce6f6e1f..ca036873f2 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -233,7 +233,6 @@ typedef struct xmb_handle { bool mouse_show; bool use_ps3_layout; - bool context_just_reset; uint8_t system_tab_end; uint8_t tabs[XMB_SYSTEM_TAB_MAX_LENGTH]; @@ -3126,13 +3125,10 @@ static void xmb_render(void *data, bool is_idle) scale_factor = (settings->uints.menu_xmb_scale_factor * (float)width) / (1920.0 * 100); - if (scale_factor != xmb->previous_scale_factor && !xmb->context_just_reset) + if (scale_factor != xmb->previous_scale_factor) xmb_context_reset_internal(xmb, video_driver_is_threaded(), false); - if (xmb->context_just_reset) - xmb->context_just_reset = false; - xmb->previous_scale_factor = scale_factor; delta.current = menu_animation_get_delta_time(); @@ -5139,7 +5135,6 @@ static void xmb_context_reset(void *data, bool is_threaded) if (xmb) { xmb_context_reset_internal(xmb, is_threaded, true); - xmb->context_just_reset = true; } } From 83bf27ac9bb0a1739081f1b108578a1a7381c579 Mon Sep 17 00:00:00 2001 From: DEX357 Date: Mon, 26 Nov 2018 12:10:50 +0100 Subject: [PATCH 066/153] Update msg_hash_pl.h --- intl/msg_hash_pl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intl/msg_hash_pl.h b/intl/msg_hash_pl.h index e510a17a18..bc78042eb3 100644 --- a/intl/msg_hash_pl.h +++ b/intl/msg_hash_pl.h @@ -3798,4 +3798,4 @@ MSG_HASH( "Brak ulubionych." ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Remember Window Position and Size") + "Zapamiętaj położenie i rozmiar okna") From 136a9db13f8c67309288e3229b4faf612a12744e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 26 Nov 2018 12:14:13 +0100 Subject: [PATCH 067/153] Silence warning - variable too small --- cheevos/cheevos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index c4f637255f..18535b4232 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -1666,7 +1666,7 @@ static void cheevos_test_cheevo_set(const cheevoset_t *set) if (settings && settings->bools.cheevos_auto_screenshot) { - char shotname[256]; + char shotname[4200]; snprintf(shotname, sizeof(shotname), "%s/%s-cheevo-%u", settings->paths.directory_screenshot, From 098e62067e50a29f4fef9a09a1fbce818e01d9e0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 26 Nov 2018 13:37:35 +0100 Subject: [PATCH 068/153] Small cleanups --- gfx/common/x11_common.c | 9 +++++---- gfx/drivers_context/x_ctx.c | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index d8d3a353dd..d5cca29249 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -134,7 +134,8 @@ void x11_move_window(Display *dpy, Window win, int x, int y, { XEvent xev = {0}; - XA_NET_MOVERESIZE_WINDOW = XInternAtom(dpy, "_NET_MOVERESIZE_WINDOW", False); + XA_NET_MOVERESIZE_WINDOW = XInternAtom(dpy, + "_NET_MOVERESIZE_WINDOW", False); xev.xclient.type = ClientMessage; xev.xclient.send_event = True; @@ -170,12 +171,12 @@ static void x11_set_window_pid(Display *dpy, Window win) XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&pid, 1); errno = 0; - if((scret = sysconf(_SC_HOST_NAME_MAX)) == -1 && errno) + if ((scret = sysconf(_SC_HOST_NAME_MAX)) == -1 && errno) return; - if((hostname = (char*)malloc(scret + 1)) == NULL) + if ((hostname = (char*)malloc(scret + 1)) == NULL) return; - if(gethostname(hostname, scret + 1) == -1) + if (gethostname(hostname, scret + 1) == -1) RARCH_WARN("Failed to get hostname.\n"); else { diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index 4cd0388200..0f6296b820 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -1078,7 +1078,7 @@ static bool gfx_ctx_x_bind_api(void *data, enum gfx_ctx_api api, case GFX_CTX_OPENGL_ES_API: #ifdef HAVE_OPENGLES2 { - Display *dpy = XOpenDisplay(NULL); + Display *dpy = XOpenDisplay(NULL); const char *exts = glXQueryExtensionsString(dpy, DefaultScreen(dpy)); bool ret = exts && strstr(exts, "GLX_EXT_create_context_es2_profile"); From 6bf35ab6e84de5be4a0189c226ace16171d63802 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 26 Nov 2018 13:54:51 +0100 Subject: [PATCH 069/153] (x11_common.c) Cleanups --- gfx/common/x11_common.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index d5cca29249..6007a9b794 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -753,22 +753,21 @@ bool x11_has_net_wm_fullscreen(Display *dpy) char *x11_get_wm_name(Display *dpy) { + Atom type; + int format; + Window window; Atom XA_NET_SUPPORTING_WM_CHECK = XInternAtom(g_x11_dpy, "_NET_SUPPORTING_WM_CHECK", False); Atom XA_NET_WM_NAME = XInternAtom(g_x11_dpy, "_NET_WM_NAME", False); Atom XA_UTF8_STRING = XInternAtom(g_x11_dpy, "UTF8_STRING", False); - int status; - Atom type; - int format; - unsigned long nitems; - unsigned long bytes_after; - unsigned char *propdata; - char *title; - Window window; + unsigned long nitems = 0; + unsigned long bytes_after = 0; + char *title = NULL; + unsigned char *propdata = NULL; if (!XA_NET_SUPPORTING_WM_CHECK || !XA_NET_WM_NAME) return NULL; - status = XGetWindowProperty(dpy, + if (!(XGetWindowProperty(dpy, DefaultRootWindow(dpy), XA_NET_SUPPORTING_WM_CHECK, 0, @@ -779,16 +778,15 @@ char *x11_get_wm_name(Display *dpy) &format, &nitems, &bytes_after, - &propdata); + &propdata) == Success && + propdata)) + return NULL; - if (status == Success && propdata) - window = ((Window *) propdata)[0]; - else - return NULL; + window = ((Window *) propdata)[0]; XFree(propdata); - status = XGetWindowProperty(dpy, + if (!(XGetWindowProperty(dpy, window, XA_NET_WM_NAME, 0, @@ -799,13 +797,11 @@ char *x11_get_wm_name(Display *dpy) &format, &nitems, &bytes_after, - &propdata); - - if (status == Success && propdata) - title = strdup((char *) propdata); - else - return NULL; + &propdata) == Success + && propdata)) + return NULL; + title = strdup((char *) propdata); XFree(propdata); return title; From 04797d940667cdb5a100782458adbb23bed865a7 Mon Sep 17 00:00:00 2001 From: natinusala Date: Mon, 26 Nov 2018 14:01:56 +0100 Subject: [PATCH 070/153] ozone: fix flickering sidebar cursor --- menu/drivers/ozone/ozone.c | 1 - 1 file changed, 1 deletion(-) diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 556b59fe20..a35feded9e 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -812,7 +812,6 @@ static void ozone_update_scroll(ozone_handle_t *ozone, bool allow_animation, ozo else { ozone->selection_old = ozone->selection; - ozone->animations.cursor_alpha = 1.0f; ozone->animations.scroll_y = new_scroll; } } From e13efbd40046aac507d27e58a7767dd1f6805530 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 26 Nov 2018 17:39:04 +0100 Subject: [PATCH 071/153] Change custom_command_method_t returntype to int64_t --- gfx/drivers/d3d9.c | 4 ++-- gfx/drivers/gl.c | 8 ++++---- gfx/video_thread_wrapper.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gfx/drivers/d3d9.c b/gfx/drivers/d3d9.c index a383190b48..407f9731f1 100644 --- a/gfx/drivers/d3d9.c +++ b/gfx/drivers/d3d9.c @@ -1990,14 +1990,14 @@ static void d3d9_video_texture_load_d3d( *id = (uintptr_t)tex; } -static int d3d9_video_texture_load_wrap_d3d(void *data) +static int64_t d3d9_video_texture_load_wrap_d3d(void *data) { uintptr_t id = 0; struct d3d9_texture_info *info = (struct d3d9_texture_info*)data; if (!info) return 0; d3d9_video_texture_load_d3d(info, &id); - return id; + return (int64_t)(uintptr_t)id; } static uintptr_t d3d9_load_texture(void *video_data, void *data, diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index f9b93604fd..1c523db69d 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -2509,7 +2509,7 @@ static void video_texture_load_gl( } #ifdef HAVE_THREADS -static int video_texture_load_wrap_gl_mipmap(void *data) +static int64_t video_texture_load_wrap_gl_mipmap(void *data) { uintptr_t id = 0; @@ -2517,10 +2517,10 @@ static int video_texture_load_wrap_gl_mipmap(void *data) return 0; video_texture_load_gl((struct texture_image*)data, TEXTURE_FILTER_MIPMAP_LINEAR, &id); - return (int)id; + return (int64_t)(uintptr_t)id; } -static int video_texture_load_wrap_gl(void *data) +static int64_t video_texture_load_wrap_gl(void *data) { uintptr_t id = 0; @@ -2528,7 +2528,7 @@ static int video_texture_load_wrap_gl(void *data) return 0; video_texture_load_gl((struct texture_image*)data, TEXTURE_FILTER_LINEAR, &id); - return (int)id; + return (int64_t)(uintptr_t)id; } #endif diff --git a/gfx/video_thread_wrapper.h b/gfx/video_thread_wrapper.h index 3fd306590a..300517659c 100644 --- a/gfx/video_thread_wrapper.h +++ b/gfx/video_thread_wrapper.h @@ -27,7 +27,7 @@ RETRO_BEGIN_DECLS -typedef int (*custom_command_method_t)(void*); +typedef int64_t (*custom_command_method_t)(void*); typedef bool (*custom_font_command_method_t)(const void **font_driver, void **font_handle, void *video_data, const char *font_path, From b538786b00a1a820e156646a87baa96929335399 Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Mon, 26 Nov 2018 21:54:39 +0400 Subject: [PATCH 072/153] Implement zwp_idle_inhibit_v1 protocol --- Makefile.common | 3 +- gfx/common/wayland/generate_wayland_protos.sh | 4 ++ gfx/drivers_context/wayland_ctx.c | 56 ++++++++++++------- 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/Makefile.common b/Makefile.common index 72f88223ea..6218fa317a 100644 --- a/Makefile.common +++ b/Makefile.common @@ -865,7 +865,8 @@ endif ifeq ($(HAVE_WAYLAND), 1) OBJ += gfx/drivers_context/wayland_ctx.o \ input/drivers/wayland_input.o \ - gfx/common/wayland/xdg-shell.o + gfx/common/wayland/xdg-shell.o \ + gfx/common/wayland/idle-inhibit-unstable-v1.o ifeq ($(HAVE_EGL), 1) LIBS += $(EGL_LIBS) endif diff --git a/gfx/common/wayland/generate_wayland_protos.sh b/gfx/common/wayland/generate_wayland_protos.sh index 8abc2ed1a0..c3b4c9f220 100755 --- a/gfx/common/wayland/generate_wayland_protos.sh +++ b/gfx/common/wayland/generate_wayland_protos.sh @@ -10,3 +10,7 @@ fi #Generate xdg-shell header and .c files $WAYSCAN client-header $WAYLAND_PROTOS/stable/xdg-shell/xdg-shell.xml $OUTPUT/xdg-shell.h $WAYSCAN private-code $WAYLAND_PROTOS/stable/xdg-shell/xdg-shell.xml $OUTPUT/xdg-shell.c + +#Generate idle-inhibit header and .c files +$WAYSCAN client-header $WAYLAND_PROTOS/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml $OUTPUT/idle-inhibit-unstable-v1.h +$WAYSCAN private-code $WAYLAND_PROTOS/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml $OUTPUT/idle-inhibit-unstable-v1.c diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index aaaf22e36c..ac083651a1 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -42,15 +42,14 @@ #include "../common/gl_common.h" #endif -#ifdef HAVE_DBUS -#include "../common/dbus_common.h" -#endif - #include "../common/wayland_common.h" #include "../../frontend/frontend_driver.h" #include "../../input/input_driver.h" #include "../../input/input_keymaps.h" +/* Generated from idle-inhibit-unstable-v1.xml */ +#include "../common/wayland/idle-inhibit-unstable-v1.h" + /* Generated from xdg-shell.xml */ #include "../common/wayland/xdg-shell.h" @@ -93,6 +92,8 @@ typedef struct gfx_ctx_wayland_data struct wl_touch *wl_touch; struct wl_seat *seat; struct wl_shm *shm; + struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager; + struct zwp_idle_inhibitor_v1 *idle_inhibitor; int swap_interval; bool core_hw_context_enable; @@ -684,6 +685,9 @@ static void registry_handle_global(void *data, struct wl_registry *reg, wl->seat = (struct wl_seat*)wl_registry_bind(reg, id, &wl_seat_interface, 2); wl_seat_add_listener(wl->seat, &seat_listener, wl); } + else if (string_is_equal(interface, "zwp_idle_inhibit_manager_v1")) + wl->idle_inhibit_manager = (struct zwp_idle_inhibit_manager_v1*)wl_registry_bind( + reg, id, &zwp_idle_inhibit_manager_v1_interface, 1); } static void registry_handle_global_remove(void *data, @@ -766,6 +770,10 @@ static void gfx_ctx_wl_destroy_resources(gfx_ctx_wayland_data_t *wl) xdg_surface_destroy(wl->xdg_surface); if (wl->surface) wl_surface_destroy(wl->surface); + if (wl->idle_inhibit_manager) + zwp_idle_inhibit_manager_v1_destroy(wl->idle_inhibit_manager); + if (wl->idle_inhibitor) + zwp_idle_inhibitor_v1_destroy(wl->idle_inhibitor); if (wl->input.dpy) { @@ -786,10 +794,6 @@ static void gfx_ctx_wl_destroy_resources(gfx_ctx_wayland_data_t *wl) wl->width = 0; wl->height = 0; -#ifdef HAVE_DBUS - dbus_screensaver_uninhibit(); - dbus_close_connection(); -#endif } void flush_wayland_fd(void *data) @@ -1072,6 +1076,11 @@ static void *gfx_ctx_wl_init(video_frame_info_t *video_info, void *video_driver) RARCH_ERR("[Wayland]: Failed to create shell.\n"); goto error; } + + if (!wl->idle_inhibit_manager) + { + RARCH_WARN("[Wayland]: Compositor doesn't support zwp_idle_inhibit_manager_v1 protocol!\n"); + } wl->input.fd = wl_display_get_fd(wl->input.dpy); @@ -1124,10 +1133,6 @@ static void *gfx_ctx_wl_init(video_frame_info_t *video_info, void *video_driver) flush_wayland_fd(&wl->input); -#ifdef HAVE_DBUS - dbus_ensure_connection(); -#endif - return wl; error: @@ -1406,16 +1411,25 @@ static bool gfx_ctx_wl_has_focus(void *data) return wl->input.keyboard_focus; } -static bool gfx_ctx_wl_suppress_screensaver(void *data, bool enable) +static bool gfx_ctx_wl_suppress_screensaver(void *data, bool state) { - (void)data; - (void)enable; - -#ifdef HAVE_DBUS - return dbus_suspend_screensaver(enable); -#endif - - return true; + (void)data; + gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; + + if (!wl->idle_inhibit_manager) + return false; + if (state == (!!wl->idle_inhibitor)) + return true; + if (state) { + RARCH_LOG("[Wayland]: Enabling idle inhibitor\n"); + struct zwp_idle_inhibit_manager_v1 *mgr = wl->idle_inhibit_manager; + wl->idle_inhibitor = zwp_idle_inhibit_manager_v1_create_inhibitor(mgr, wl->surface); + } else { + RARCH_LOG("[Wayland]: Disabling the idle inhibitor\n"); + zwp_idle_inhibitor_v1_destroy(wl->idle_inhibitor); + wl->idle_inhibitor = NULL; + } + return true; } static bool gfx_ctx_wl_has_windowed(void *data) From ea180a17758eeb68f36c586ce445256a435924fb Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Mon, 26 Nov 2018 21:58:43 +0400 Subject: [PATCH 073/153] Relax wayland and wayland-protocols version's --- gfx/common/wayland/generate_wayland_protos.sh | 4 ++-- qb/config.libs.sh | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gfx/common/wayland/generate_wayland_protos.sh b/gfx/common/wayland/generate_wayland_protos.sh index c3b4c9f220..e64ea58914 100755 --- a/gfx/common/wayland/generate_wayland_protos.sh +++ b/gfx/common/wayland/generate_wayland_protos.sh @@ -9,8 +9,8 @@ fi #Generate xdg-shell header and .c files $WAYSCAN client-header $WAYLAND_PROTOS/stable/xdg-shell/xdg-shell.xml $OUTPUT/xdg-shell.h -$WAYSCAN private-code $WAYLAND_PROTOS/stable/xdg-shell/xdg-shell.xml $OUTPUT/xdg-shell.c +$WAYSCAN code $WAYLAND_PROTOS/stable/xdg-shell/xdg-shell.xml $OUTPUT/xdg-shell.c #Generate idle-inhibit header and .c files $WAYSCAN client-header $WAYLAND_PROTOS/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml $OUTPUT/idle-inhibit-unstable-v1.h -$WAYSCAN private-code $WAYLAND_PROTOS/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml $OUTPUT/idle-inhibit-unstable-v1.c +$WAYSCAN code $WAYLAND_PROTOS/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml $OUTPUT/idle-inhibit-unstable-v1.c diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 0fd0fe4aa3..233fd9760a 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -455,9 +455,9 @@ check_pkgconf V4L2 libv4l2 check_pkgconf FREETYPE freetype2 check_pkgconf X11 x11 check_pkgconf XCB xcb -check_pkgconf WAYLAND wayland-egl 1.15 -check_pkgconf WAYLAND_CURSOR wayland-cursor 1.15 -check_pkgconf WAYLAND_PROTOS wayland-protocols 1.15 +check_pkgconf WAYLAND wayland-egl 1.14 +check_pkgconf WAYLAND_CURSOR wayland-cursor 1.14 +check_pkgconf WAYLAND_PROTOS wayland-protocols 1.13 check_pkgconf XKBCOMMON xkbcommon 0.3.2 check_pkgconf DBUS dbus-1 check_pkgconf XEXT xext @@ -474,7 +474,7 @@ check_val '' XEXT -lXext check_val '' XF86VM -lXxf86vm if [ "$HAVE_WAYLAND_PROTOS" = yes ] && [ "$HAVE_WAYLAND" = yes ]; then - check_pkgconf WAYLAND_SCANNER wayland-scanner 1.15 + check_pkgconf WAYLAND_SCANNER wayland-scanner 1.13 ./gfx/common/wayland/generate_wayland_protos.sh else die : 'Notice: wayland-egl or wayland-protocols not present. Skiping Wayland code paths.' From c16a3a6b88b0ec4fb8538db7d967c828c240a9e5 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 26 Nov 2018 19:26:32 +0100 Subject: [PATCH 074/153] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 2621139e06..2bbfd5534d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,7 @@ - SWITCH: Proper button labels. - VULKAN: Fix RGUI crashing at startup. - VULKAN: Fix secondary screens in overlays not working. +- WAYLAND: Implement idle-inhibit support (needed for screensaver suspend). - WINDOWS/WSA: Network Information info is blank until first network operation. - WIIU: Initial netplay peer-to-peer support. Network information working. From bc0dbffc0197f9e23fd6ff4cea3445847908f058 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 26 Nov 2018 18:09:57 +0100 Subject: [PATCH 075/153] Revert "Change custom_command_method_t returntype to int64_t" This reverts commit e13efbd40046aac507d27e58a7767dd1f6805530. --- gfx/drivers/d3d9.c | 4 ++-- gfx/drivers/gl.c | 8 ++++---- gfx/video_thread_wrapper.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gfx/drivers/d3d9.c b/gfx/drivers/d3d9.c index 407f9731f1..a383190b48 100644 --- a/gfx/drivers/d3d9.c +++ b/gfx/drivers/d3d9.c @@ -1990,14 +1990,14 @@ static void d3d9_video_texture_load_d3d( *id = (uintptr_t)tex; } -static int64_t d3d9_video_texture_load_wrap_d3d(void *data) +static int d3d9_video_texture_load_wrap_d3d(void *data) { uintptr_t id = 0; struct d3d9_texture_info *info = (struct d3d9_texture_info*)data; if (!info) return 0; d3d9_video_texture_load_d3d(info, &id); - return (int64_t)(uintptr_t)id; + return id; } static uintptr_t d3d9_load_texture(void *video_data, void *data, diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 1c523db69d..f9b93604fd 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -2509,7 +2509,7 @@ static void video_texture_load_gl( } #ifdef HAVE_THREADS -static int64_t video_texture_load_wrap_gl_mipmap(void *data) +static int video_texture_load_wrap_gl_mipmap(void *data) { uintptr_t id = 0; @@ -2517,10 +2517,10 @@ static int64_t video_texture_load_wrap_gl_mipmap(void *data) return 0; video_texture_load_gl((struct texture_image*)data, TEXTURE_FILTER_MIPMAP_LINEAR, &id); - return (int64_t)(uintptr_t)id; + return (int)id; } -static int64_t video_texture_load_wrap_gl(void *data) +static int video_texture_load_wrap_gl(void *data) { uintptr_t id = 0; @@ -2528,7 +2528,7 @@ static int64_t video_texture_load_wrap_gl(void *data) return 0; video_texture_load_gl((struct texture_image*)data, TEXTURE_FILTER_LINEAR, &id); - return (int64_t)(uintptr_t)id; + return (int)id; } #endif diff --git a/gfx/video_thread_wrapper.h b/gfx/video_thread_wrapper.h index 300517659c..3fd306590a 100644 --- a/gfx/video_thread_wrapper.h +++ b/gfx/video_thread_wrapper.h @@ -27,7 +27,7 @@ RETRO_BEGIN_DECLS -typedef int64_t (*custom_command_method_t)(void*); +typedef int (*custom_command_method_t)(void*); typedef bool (*custom_font_command_method_t)(const void **font_driver, void **font_handle, void *video_data, const char *font_path, From 9d76a6bb0002ad1607c9dcfbe67ef86e918c8674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Mon, 26 Nov 2018 18:59:50 -0500 Subject: [PATCH 076/153] Update config.def.h --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 85a7104506..38882709db 100644 --- a/config.def.h +++ b/config.def.h @@ -240,7 +240,7 @@ static const float aspect_ratio = DEFAULT_ASPECT_RATIO; /* 1:1 PAR */ static const bool aspect_ratio_auto = false; -#if defined(__CELLOS_LV2) || defined(_XBOX360) || defined(ANDROID_AARCH64) +#if defined(__CELLOS_LV2) || defined(_XBOX360) static unsigned aspect_ratio_idx = ASPECT_RATIO_16_9; #elif defined(PSP) static unsigned aspect_ratio_idx = ASPECT_RATIO_CORE; From aab6a86633c7d06b58010ce54ba6377afb3ee3f1 Mon Sep 17 00:00:00 2001 From: radius Date: Mon, 26 Nov 2018 21:15:03 -0500 Subject: [PATCH 077/153] only apply fixed window size when the setting is enabled --- gfx/video_driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index e544ab2762..e82e19d022 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -986,7 +986,8 @@ static bool video_driver_init_internal(bool *video_is_threaded) else { /* To-Do: remove when the new window resizing core is hooked */ - if (settings->uints.window_position_width || settings->uints.window_position_height) + if (settings->bools.video_window_save_positions && + (settings->uints.window_position_width || settings->uints.window_position_height)) { width = settings->uints.window_position_width; height = settings->uints.window_position_height; From 4ca7ebc9dabf068c1dd24ec425da1933d36a9d52 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 27 Nov 2018 11:28:24 +0100 Subject: [PATCH 078/153] Add xrandr implementation for get_output_options --- Makefile.common | 2 +- gfx/display_servers/dispserv_x11.c | 38 ++++++++++++++++++++++++++++++ qb/config.libs.sh | 3 ++- qb/config.params.sh | 1 + 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/Makefile.common b/Makefile.common index 6218fa317a..4ed626d02a 100644 --- a/Makefile.common +++ b/Makefile.common @@ -903,7 +903,7 @@ ifeq ($(HAVE_X11), 1) gfx/common/xinerama_common.o \ gfx/display_servers/dispserv_x11.o - LIBS += $(X11_LIBS) $(XEXT_LIBS) $(XF86VM_LIBS) $(XINERAMA_LIBS) + LIBS += $(X11_LIBS) $(XEXT_LIBS) $(XF86VM_LIBS) $(XINERAMA_LIBS) $(XRANDR_LIBS) DEFINES += -DHAVE_X11 $(X11_CFLAGS) $(XEXT_CFLAGS) $(XF86VM_CFLAGS) $(XINERAMA_CFLAGS) ifeq ($(HAVE_XCB),1) LIBS += -lX11-xcb diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index 29a13fec55..a4d727ddc1 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -14,9 +14,18 @@ * You should have received a copy of the GNU General Public License along with RetroArch. * If not, see . */ + +#include + #include #include +#include "../../config.h" + +#ifdef HAVE_XRANDR +#include +#endif + #include "../video_display_server.h" #include "../common/x11_common.h" #include "../../configuration.h" @@ -284,8 +293,37 @@ static bool x11_display_server_set_resolution(void *data, const char *x11_display_server_get_output_options(void *data) { +#ifdef HAVE_XRANDR + Display *dpy; + XRRScreenResources *res; + XRROutputInfo *info; + Window root; + int i; + static char s[PATH_MAX_LENGTH]; + + if (!(dpy = XOpenDisplay(0))) + return NULL; + + root = RootWindow(dpy, DefaultScreen(dpy)); + + if (!(res = XRRGetScreenResources(dpy, root))) + return NULL; + + for (i = 0; i < res->noutput; i++) + { + if (!(info = XRRGetOutputInfo(dpy, res, res->outputs[i]))) + return NULL; + + strlcat(s, info->name, sizeof(s)); + if ((i+1) < res->noutput) + strlcat(s, "|", sizeof(s)); + } + + return s; +#else /* TODO/FIXME - hardcoded for now; list should be built up dynamically later */ return "HDMI-0|HDMI-1|HDMI-2|HDMI-3|DVI-0|DVI-1|DVI-2|DVI-3|VGA-0|VGA-1|VGA-2|VGA-3|Config"; +#endif } const video_display_server_t dispserv_x11 = { diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 233fd9760a..4e911b3826 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -482,9 +482,10 @@ else fi if [ "$HAVE_X11" = 'no' ]; then - HAVE_XEXT=no; HAVE_XF86VM=no; HAVE_XINERAMA=no; HAVE_XSHM=no + HAVE_XEXT=no; HAVE_XF86VM=no; HAVE_XINERAMA=no; HAVE_XSHM=no; HAVE_XRANDR=no fi +check_lib '' XRANDR -lXrandr check_pkgconf XINERAMA xinerama check_val '' XINERAMA -lXinerama diff --git a/qb/config.params.sh b/qb/config.params.sh index daf9206eaf..9c1f3d7ef3 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -59,6 +59,7 @@ HAVE_OPENDINGUX_FBDEV=no # Opendingux fbdev context support HAVE_OPENGLES=no # Use GLESv2 instead of desktop GL HAVE_OPENGLES3=no # OpenGLES3 support HAVE_X11=auto # everything X11. +HAVE_XRANDR=auto # Xrandr support. HAVE_OMAP=no # OMAP video support HAVE_XINERAMA=auto # Xinerama support. HAVE_KMS=auto # KMS context support From 803af8a89098c6dd1c6dd56fad1bfae2eec93f5d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 27 Nov 2018 11:55:03 +0100 Subject: [PATCH 079/153] Add brackets around this --- menu/menu_setting.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index edf7979b35..a009d79c31 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -5390,13 +5390,20 @@ static bool setting_append_list( CMD_EVENT_VIDEO_APPLY_STATE_CHANGES); settings_data_list_current_add_flags(list, list_info, SD_FLAG_LAKKA_ADVANCED); - CONFIG_ACTION( - list, list_info, - MENU_ENUM_LABEL_SCREEN_RESOLUTION, - MENU_ENUM_LABEL_VALUE_SCREEN_RESOLUTION, - &group_info, - &subgroup_info, - parent_group); +#if defined(GEKKO) || defined(__CELLOS_LV2__) + if (true) +#else + if (!string_is_equal(video_display_server_get_ident(), "null")) +#endif + { + CONFIG_ACTION( + list, list_info, + MENU_ENUM_LABEL_SCREEN_RESOLUTION, + MENU_ENUM_LABEL_VALUE_SCREEN_RESOLUTION, + &group_info, + &subgroup_info, + parent_group); + } CONFIG_UINT( list, list_info, From ffaafbc77cd6739321b73dd63b4e0e9a8fc9edea Mon Sep 17 00:00:00 2001 From: natinusala Date: Tue, 27 Nov 2018 15:32:43 +0100 Subject: [PATCH 080/153] ozone: fix scroll when rebinding inputs --- menu/drivers/ozone/ozone.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index a35feded9e..b5d4a177d9 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -774,9 +774,8 @@ static void ozone_update_scroll(ozone_handle_t *ozone, bool allow_animation, ozo bottom_boundary = video_info_height - 87 - 78; entries_middle = video_info_height/2; - if (current_selection_middle_onscreen != entries_middle) - new_scroll = ozone->animations.scroll_y - (current_selection_middle_onscreen - entries_middle); - + new_scroll = ozone->animations.scroll_y - (current_selection_middle_onscreen - entries_middle); + if (new_scroll + ozone->entries_height < bottom_boundary) new_scroll = -(78 + ozone->entries_height - bottom_boundary); From a7b93ff501280f95c914e126df7ae3b9e440d5a8 Mon Sep 17 00:00:00 2001 From: natinusala Date: Tue, 27 Nov 2018 15:44:08 +0100 Subject: [PATCH 081/153] Add generated Wayland protos to .gitignore --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 28188376c9..1094b5599e 100644 --- a/.gitignore +++ b/.gitignore @@ -163,3 +163,9 @@ retroarch_switch.lst retroarch_switch.nacp retroarch_switch.nro retroarch_switch.nso + +# Wayland +gfx/common/wayland/idle-inhibit-unstable-v1.c +gfx/common/wayland/idle-inhibit-unstable-v1.h +gfx/common/wayland/xdg-shell.c +gfx/common/wayland/xdg-shell.h From e15dd10237a328fe511080c71b5aa047387733ec Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Tue, 27 Nov 2018 13:19:50 -0500 Subject: [PATCH 082/153] ozone: Fix subsystem_data being undefined subsystem_data was not defined, seemed like a declaration of subsystem was in the wrong place. --- menu/drivers/ozone/ozone.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 6f5a285ffa..eac8d269e3 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -587,12 +587,9 @@ static int ozone_list_push(void *data, void *userdata, entry.enum_idx = MENU_ENUM_LABEL_LOAD_CONTENT_LIST; menu_displaylist_setting(&entry); - subsystem = system->subsystem.data; - if (subsystem_size > 0) { - const struct retro_subsystem_info* subsystem = NULL; - subsystem = subsystem_data; + const struct retro_subsystem_info* subsystem = system->subsystem.data; for (i = 0; i < subsystem_size; i++, subsystem++) { char s[PATH_MAX_LENGTH]; From 09698d33a26c95e7d837569d0deb90857ffead92 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 27 Nov 2018 19:52:30 +0100 Subject: [PATCH 083/153] Buildfix --- menu/drivers/ozone/ozone.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 6f5a285ffa..2c484d03f5 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -587,8 +587,6 @@ static int ozone_list_push(void *data, void *userdata, entry.enum_idx = MENU_ENUM_LABEL_LOAD_CONTENT_LIST; menu_displaylist_setting(&entry); - subsystem = system->subsystem.data; - if (subsystem_size > 0) { const struct retro_subsystem_info* subsystem = NULL; From 83c11994039b0f989f08cd3784e122de2e8549c3 Mon Sep 17 00:00:00 2001 From: Yoshi Sugawara Date: Tue, 27 Nov 2018 09:29:30 -1000 Subject: [PATCH 084/153] iOS: Hide home screen indicator and make the user swipe twice to go home/app switching for iPhone X/2018 iPad Pro --- ui/drivers/cocoa/cocoa_common.m | 42 +++++++++++++++++++++++++++ ui/drivers/cocoa/cocoa_common_metal.m | 13 +++++++++ 2 files changed, 55 insertions(+) diff --git a/ui/drivers/cocoa/cocoa_common.m b/ui/drivers/cocoa/cocoa_common.m index b356ffed58..428e467835 100644 --- a/ui/drivers/cocoa/cocoa_common.m +++ b/ui/drivers/cocoa/cocoa_common.m @@ -153,12 +153,53 @@ void *glkitview_init(void); } #elif defined(HAVE_COCOATOUCH) +- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures +{ + return UIRectEdgeBottom; +} + +-(BOOL)prefersHomeIndicatorAutoHidden +{ + return NO; +} + - (void)viewDidAppear:(BOOL)animated { /* Pause Menus. */ [self showPauseIndicator]; + if (@available(iOS 11.0, *)) { + [self setNeedsUpdateOfHomeIndicatorAutoHidden]; + } } +-(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { + [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; + if (@available(iOS 11, *)) { + [coordinator animateAlongsideTransition:^(id _Nonnull context) { + [self adjustViewFrameForSafeArea]; + } completion:^(id _Nonnull context) { + }]; + } +} + +-(void)adjustViewFrameForSafeArea { + // This is for adjusting the view frame to account for the notch in iPhone X phones + if (@available(iOS 11, *)) { + RAScreen *screen = (__bridge RAScreen*)get_chosen_screen(); + CGRect screenSize = [screen bounds]; + UIEdgeInsets inset = [[UIApplication sharedApplication] delegate].window.safeAreaInsets; + UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; + CGRect newFrame = screenSize; + if ( orientation == UIInterfaceOrientationPortrait ) { + newFrame = CGRectMake(screenSize.origin.x, screenSize.origin.y + inset.top, screenSize.size.width, screenSize.size.height - inset.top); + } else if ( orientation == UIInterfaceOrientationLandscapeLeft ) { + newFrame = CGRectMake(screenSize.origin.x, screenSize.origin.y, screenSize.size.width - inset.right, screenSize.size.height); + } else if ( orientation == UIInterfaceOrientationLandscapeRight ) { + newFrame = CGRectMake(screenSize.origin.x + inset.left, screenSize.origin.y, screenSize.size.width - inset.left, screenSize.size.height); + } + self.view.frame = newFrame; + } +} - (void)showPauseIndicator { g_pause_indicator_view.alpha = 1.0f; @@ -191,6 +232,7 @@ void *glkitview_init(void); g_pause_indicator_view.frame = CGRectMake(tenpctw * 4.0f, 0.0f, tenpctw * 2.0f, tenpcth); [g_pause_indicator_view viewWithTag:1].frame = CGRectMake(0, 0, tenpctw * 2.0f, tenpcth); + [self adjustViewFrameForSafeArea]; } #define ALMOST_INVISIBLE (.021f) diff --git a/ui/drivers/cocoa/cocoa_common_metal.m b/ui/drivers/cocoa/cocoa_common_metal.m index f5ddaceb08..9f4d9d7e57 100644 --- a/ui/drivers/cocoa/cocoa_common_metal.m +++ b/ui/drivers/cocoa/cocoa_common_metal.m @@ -172,10 +172,23 @@ void *glkitview_init(void); } #elif defined(HAVE_COCOATOUCH) +- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures +{ + return UIRectEdgeBottom; +} + +-(BOOL)prefersHomeIndicatorAutoHidden +{ + return NO; +} + - (void)viewDidAppear:(BOOL)animated { /* Pause Menus. */ [self showPauseIndicator]; + if (@available(iOS 11.0, *)) { + [self setNeedsUpdateOfHomeIndicatorAutoHidden]; + } } - (void)showPauseIndicator From 1d14512cb05591a540a161307df148a8ec889275 Mon Sep 17 00:00:00 2001 From: dukemiller Date: Tue, 27 Nov 2018 18:59:22 -0700 Subject: [PATCH 085/153] Allow framecount to be displayed independently without fps counter --- gfx/video_driver.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index e82e19d022..2d9d2baa74 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2449,10 +2449,13 @@ void video_driver_frame(const void *data, unsigned width, char frames_text[64]; last_fps = TIME_TO_FPS(curr_time, new_time, FPS_UPDATE_INTERVAL); - if (video_info.fps_show) + if (video_info.fps_show || video_info.framecount_show) { - snprintf(video_info.fps_text, sizeof(video_info.fps_text), - "|| FPS: %6.1f ", last_fps); + if (video_info.fps_show) + { + snprintf(video_info.fps_text, sizeof(video_info.fps_text), + "|| FPS: %6.1f ", last_fps); + } if (video_info.framecount_show) { snprintf(frames_text, @@ -2462,6 +2465,7 @@ void video_driver_frame(const void *data, unsigned width, } snprintf(video_driver_window_title, sizeof(video_driver_window_title), "%s%s%s", title, video_info.fps_text, + video_info.fps_show ? video_info.fps_text : "", video_info.framecount_show ? frames_text : ""); } else @@ -2491,6 +2495,28 @@ void video_driver_frame(const void *data, unsigned width, "FPS: %6.1f", last_fps); } + + if (video_info.fps_show && video_info.framecount_show) + snprintf( + video_info.fps_text, + sizeof(video_info.fps_text), + "FPS: %6.1f || %s: %" PRIu64, + last_fps, + msg_hash_to_str(MSG_FRAMES), + (uint64_t)video_driver_frame_count); + else if (video_info.framecount_show) + snprintf( + video_info.fps_text, + sizeof(video_info.fps_text), + "%s: %" PRIu64, + msg_hash_to_str(MSG_FRAMES), + (uint64_t)video_driver_frame_count); + else if (video_info.fps_show) + snprintf( + video_info.fps_text, + sizeof(video_info.fps_text), + "FPS: %6.1f", + last_fps); } else { @@ -2620,7 +2646,7 @@ void video_driver_frame(const void *data, unsigned width, video_driver_frame_count++; /* Display the FPS, with a higher priority. */ - if (video_info.fps_show) + if (video_info.fps_show || video_info.framecount_show) runloop_msg_queue_push(video_info.fps_text, 2, 1, true); /* trigger set resolution*/ From f3c682186c826fe6985eab81efec289aecd82be2 Mon Sep 17 00:00:00 2001 From: dukemiller Date: Tue, 27 Nov 2018 19:00:26 -0700 Subject: [PATCH 086/153] Add submenu label for framecount and change wording --- config.def.h | 2 +- intl/msg_hash_ar.h | 2 +- intl/msg_hash_el.h | 2 +- intl/msg_hash_us.h | 6 +++++- menu/cbs/menu_cbs_sublabel.c | 4 ++++ 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/config.def.h b/config.def.h index 38882709db..ed75f79bbe 100644 --- a/config.def.h +++ b/config.def.h @@ -549,7 +549,7 @@ static const int wasapi_sh_buffer_length = -16; /* auto */ /* Enables displaying the current frames per second. */ static const bool fps_show = false; -/* Show frame count on FPS display */ +/* Enables displaying the current frame count. */ static const bool framecount_show = true; /* Enables use of rewind. This will incur some memory footprint diff --git a/intl/msg_hash_ar.h b/intl/msg_hash_ar.h index 865fd63e2b..b4ba128781 100644 --- a/intl/msg_hash_ar.h +++ b/intl/msg_hash_ar.h @@ -3432,7 +3432,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_COLOR_GREEN, MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_COLOR_BLUE, "Notification Blue Color") MSG_HASH(MENU_ENUM_LABEL_VALUE_FRAMECOUNT_SHOW, - "Show frame count on FPS display") + "Display Frame Count") MSG_HASH(MSG_CONFIG_OVERRIDE_LOADED, "Configuration override loaded.") MSG_HASH(MSG_GAME_REMAP_FILE_LOADED, diff --git a/intl/msg_hash_el.h b/intl/msg_hash_el.h index 3954649d49..c614822049 100644 --- a/intl/msg_hash_el.h +++ b/intl/msg_hash_el.h @@ -6224,7 +6224,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_FRAMECOUNT_SHOW, - "Show frame count on FPS display" + "Display Frame Count" ) MSG_HASH( MSG_CONFIG_OVERRIDE_LOADED, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 15bd1b26c3..a2f4bd8d41 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -3630,6 +3630,10 @@ MSG_HASH( MENU_ENUM_SUBLABEL_FPS_SHOW, "Displays the current framerate per second onscreen." ) +MSG_HASH( + MENU_ENUM_SUBLABEL_FRAMECOUNT_SHOW, + "Displays the current frame count onscreen." + ) MSG_HASH( MENU_ENUM_SUBLABEL_INPUT_HOTKEY_BINDS, "Configure hotkey settings." @@ -6265,7 +6269,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_FRAMECOUNT_SHOW, - "Show frame count on FPS display" + "Display Frame Count" ) MSG_HASH( MSG_CONFIG_OVERRIDE_LOADED, diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index ca9b61fcb6..92c2fc8f9c 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -124,6 +124,7 @@ default_sublabel_macro(action_bind_sublabel_user_language, MENU_ default_sublabel_macro(action_bind_sublabel_max_swapchain_images, MENU_ENUM_SUBLABEL_VIDEO_MAX_SWAPCHAIN_IMAGES ) default_sublabel_macro(action_bind_sublabel_online_updater, MENU_ENUM_SUBLABEL_ONLINE_UPDATER) default_sublabel_macro(action_bind_sublabel_fps_show, MENU_ENUM_SUBLABEL_FPS_SHOW) +default_sublabel_macro(action_bind_sublabel_framecount_show, MENU_ENUM_SUBLABEL_FRAMECOUNT_SHOW) default_sublabel_macro(action_bind_sublabel_statistics_show, MENU_ENUM_SUBLABEL_STATISTICS_SHOW) default_sublabel_macro(action_bind_sublabel_netplay_settings, MENU_ENUM_SUBLABEL_NETPLAY) default_sublabel_macro(action_bind_sublabel_user_bind_settings, MENU_ENUM_SUBLABEL_INPUT_USER_BINDS) @@ -1873,6 +1874,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_FPS_SHOW: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_fps_show); break; + case MENU_ENUM_LABEL_FRAMECOUNT_SHOW: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_framecount_show); + break; case MENU_ENUM_LABEL_MENU_VIEWS_SETTINGS: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_views_settings_list); break; From be9d4c63ec70d758479120e025f6429cbd22b287 Mon Sep 17 00:00:00 2001 From: dukemiller Date: Tue, 27 Nov 2018 19:01:35 -0700 Subject: [PATCH 087/153] Re-arrange menu options to put related settings closer together --- 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 5249e21a91..1d0f6687b3 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -5601,10 +5601,10 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist MENU_ENUM_LABEL_FPS_SHOW, PARSE_ONLY_BOOL, false); menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_STATISTICS_SHOW, + MENU_ENUM_LABEL_FRAMECOUNT_SHOW, PARSE_ONLY_BOOL, false); menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_FRAMECOUNT_SHOW, + MENU_ENUM_LABEL_STATISTICS_SHOW, PARSE_ONLY_BOOL, false); menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_VIDEO_FONT_PATH, From 4d55c74f29ba01be3b6f9c13dedb791d6adf300f Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Wed, 28 Nov 2018 06:08:44 +0100 Subject: [PATCH 088/153] Revert "ozone: Fix subsystem_data being undefined" --- menu/drivers/ozone/ozone.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index eac8d269e3..2c484d03f5 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -589,7 +589,8 @@ static int ozone_list_push(void *data, void *userdata, if (subsystem_size > 0) { - const struct retro_subsystem_info* subsystem = system->subsystem.data; + const struct retro_subsystem_info* subsystem = NULL; + subsystem = subsystem_data; for (i = 0; i < subsystem_size; i++, subsystem++) { char s[PATH_MAX_LENGTH]; From 34fe9205dbf342798efb01a25b3fb628666a5365 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Wed, 28 Nov 2018 06:11:08 +0100 Subject: [PATCH 089/153] Revert "Revert "ozone: Fix subsystem_data being undefined"" --- menu/drivers/ozone/ozone.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 2c484d03f5..eac8d269e3 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -589,8 +589,7 @@ static int ozone_list_push(void *data, void *userdata, if (subsystem_size > 0) { - const struct retro_subsystem_info* subsystem = NULL; - subsystem = subsystem_data; + const struct retro_subsystem_info* subsystem = system->subsystem.data; for (i = 0; i < subsystem_size; i++, subsystem++) { char s[PATH_MAX_LENGTH]; From 8294bf86dfeee77103237ba371384b63821d9c0b Mon Sep 17 00:00:00 2001 From: dukemiller Date: Thu, 22 Nov 2018 16:27:55 -0700 Subject: [PATCH 090/153] Create option for dx video drivers to toggle displaying memory use --- config.def.h | 3 +++ configuration.c | 1 + configuration.h | 1 + gfx/common/dxgi_common.c | 5 +++-- intl/msg_hash_lbl.h | 2 ++ intl/msg_hash_us.c | 5 +++++ intl/msg_hash_us.h | 8 ++++++++ menu/cbs/menu_cbs_sublabel.c | 4 ++++ menu/menu_displaylist.c | 3 +++ menu/menu_setting.c | 15 +++++++++++++++ msg_hash.h | 1 + retroarch.cfg | 3 +++ 12 files changed, 49 insertions(+), 2 deletions(-) diff --git a/config.def.h b/config.def.h index ed75f79bbe..6bf045ab21 100644 --- a/config.def.h +++ b/config.def.h @@ -552,6 +552,9 @@ static const bool fps_show = false; /* Enables displaying the current frame count. */ static const bool framecount_show = true; +/* Includes displaying the current memory usage/total with FPS/Frames. */ +static const bool memory_show = false; + /* Enables use of rewind. This will incur some memory footprint * depending on the save state buffer. */ static const bool rewind_enable = false; diff --git a/configuration.c b/configuration.c index 0d209a5940..db570b0d95 100644 --- a/configuration.c +++ b/configuration.c @@ -1318,6 +1318,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, SETTING_BOOL("fps_show", &settings->bools.video_fps_show, true, false, false); SETTING_BOOL("statistics_show", &settings->bools.video_statistics_show, true, false, false); SETTING_BOOL("framecount_show", &settings->bools.video_framecount_show, true, true, false); + SETTING_BOOL("memory_show", &settings->bools.video_memory_show, true, false, false); SETTING_BOOL("ui_menubar_enable", &settings->bools.ui_menubar_enable, true, true, false); SETTING_BOOL("suspend_screensaver_enable", &settings->bools.ui_suspend_screensaver_enable, true, true, false); SETTING_BOOL("rewind_enable", &settings->bools.rewind_enable, true, rewind_enable, false); diff --git a/configuration.h b/configuration.h index dee5497cb8..f2c71cb15c 100644 --- a/configuration.h +++ b/configuration.h @@ -103,6 +103,7 @@ typedef struct settings bool video_fps_show; bool video_statistics_show; bool video_framecount_show; + bool video_memory_show; bool video_msg_bgcolor_enable; bool video_3ds_lcd_bottom; diff --git a/gfx/common/dxgi_common.c b/gfx/common/dxgi_common.c index e7065979fc..3d935f41d2 100644 --- a/gfx/common/dxgi_common.c +++ b/gfx/common/dxgi_common.c @@ -305,8 +305,9 @@ void dxgi_copy( void dxgi_update_title(video_frame_info_t* video_info) { const ui_window_t* window = ui_companion_driver_get_window_ptr(); + const settings_t *settings = config_get_ptr(); - if (video_info->fps_show) + if (settings->bools.video_memory_show) { MEMORYSTATUS stat; char mem[128]; @@ -315,7 +316,7 @@ void dxgi_update_title(video_frame_info_t* video_info) GlobalMemoryStatus(&stat); snprintf( - mem, sizeof(mem), "|| MEM: %.2f/%.2fMB", stat.dwAvailPhys / (1024.0f * 1024.0f), + mem, sizeof(mem), " || MEM: %.2f/%.2fMB", stat.dwAvailPhys / (1024.0f * 1024.0f), stat.dwTotalPhys / (1024.0f * 1024.0f)); strlcat(video_info->fps_text, mem, sizeof(video_info->fps_text)); } diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index 1571d7e991..c9cb27d08f 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -1551,6 +1551,8 @@ MSG_HASH(MENU_ENUM_LABEL_VIDEO_MESSAGE_COLOR_BLUE, "video_msg_color_blue") MSG_HASH(MENU_ENUM_LABEL_FRAMECOUNT_SHOW, "framecount_show") +MSG_HASH(MENU_ENUM_LABEL_MEMORY_SHOW, + "memory_show") MSG_HASH(MENU_ENUM_LABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "automatically_add_content_to_playlist") MSG_HASH(MENU_ENUM_LABEL_VIDEO_WINDOW_OPACITY, diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c index 83db0a6a8e..e2d5c9c970 100644 --- a/intl/msg_hash_us.c +++ b/intl/msg_hash_us.c @@ -567,6 +567,11 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len) "Enables displaying the current frames \n" "per second."); break; + case MENU_ENUM_LABEL_MEMORY_SHOW: + snprintf(s, len, + "Includes displaying the current memory \n" + "usage/total with FPS/Frames."); + break; case MENU_ENUM_LABEL_VIDEO_FONT_ENABLE: snprintf(s, len, "Show and/or hide onscreen messages."); diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index a2f4bd8d41..bc5a90f3be 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -843,6 +843,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_FPS_SHOW, "Display Framerate" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_MEMORY_SHOW, + "Include Memory Details" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_FRAME_THROTTLE_ENABLE, "Limit Maximum Run Speed" @@ -3634,6 +3638,10 @@ MSG_HASH( MENU_ENUM_SUBLABEL_FRAMECOUNT_SHOW, "Displays the current frame count onscreen." ) +MSG_HASH( + MENU_ENUM_SUBLABEL_MEMORY_SHOW, + "Includes the current memory usage/total onscreen with FPS/Frames." + ) MSG_HASH( MENU_ENUM_SUBLABEL_INPUT_HOTKEY_BINDS, "Configure hotkey settings." diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 92c2fc8f9c..81347b8267 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -125,6 +125,7 @@ default_sublabel_macro(action_bind_sublabel_max_swapchain_images, MENU_ default_sublabel_macro(action_bind_sublabel_online_updater, MENU_ENUM_SUBLABEL_ONLINE_UPDATER) default_sublabel_macro(action_bind_sublabel_fps_show, MENU_ENUM_SUBLABEL_FPS_SHOW) default_sublabel_macro(action_bind_sublabel_framecount_show, MENU_ENUM_SUBLABEL_FRAMECOUNT_SHOW) +default_sublabel_macro(action_bind_sublabel_memory_show, MENU_ENUM_SUBLABEL_MEMORY_SHOW) default_sublabel_macro(action_bind_sublabel_statistics_show, MENU_ENUM_SUBLABEL_STATISTICS_SHOW) default_sublabel_macro(action_bind_sublabel_netplay_settings, MENU_ENUM_SUBLABEL_NETPLAY) default_sublabel_macro(action_bind_sublabel_user_bind_settings, MENU_ENUM_SUBLABEL_INPUT_USER_BINDS) @@ -1877,6 +1878,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_FRAMECOUNT_SHOW: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_framecount_show); break; + case MENU_ENUM_LABEL_MEMORY_SHOW: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_memory_show); + break; case MENU_ENUM_LABEL_MENU_VIEWS_SETTINGS: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_views_settings_list); break; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 1d0f6687b3..d28adcf9b3 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -5606,6 +5606,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_STATISTICS_SHOW, PARSE_ONLY_BOOL, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_MEMORY_SHOW, + PARSE_ONLY_BOOL, false); menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_VIDEO_FONT_PATH, PARSE_ONLY_PATH, false); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index a009d79c31..c14112d8ee 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -5102,6 +5102,21 @@ static bool setting_append_list( general_read_handler, SD_FLAG_NONE); + CONFIG_BOOL( + list, list_info, + &settings->bools.video_memory_show, + MENU_ENUM_LABEL_MEMORY_SHOW, + MENU_ENUM_LABEL_VALUE_MEMORY_SHOW, + memory_show, + MENU_ENUM_LABEL_VALUE_OFF, + MENU_ENUM_LABEL_VALUE_ON, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler, + SD_FLAG_NONE); + CONFIG_BOOL( list, list_info, &settings->bools.video_statistics_show, diff --git a/msg_hash.h b/msg_hash.h index 3c16be4e89..5c4e151916 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1231,6 +1231,7 @@ enum msg_hash_enums MENU_LABEL(SHADER_PREV), MENU_LABEL(FRAME_ADVANCE), MENU_LABEL(FPS_SHOW), + MENU_LABEL(MEMORY_SHOW), MENU_LABEL(STATISTICS_SHOW), MENU_LABEL(FRAMECOUNT_SHOW), MENU_LABEL(BSV_RECORD_TOGGLE), diff --git a/retroarch.cfg b/retroarch.cfg index 671fa4a73c..da36413bda 100644 --- a/retroarch.cfg +++ b/retroarch.cfg @@ -124,6 +124,9 @@ # Display framerate. # fps_show = false +# Display memory. +# memory_show = false + # Display total number of frames rendered. (only displays if fps_show is enabled) # framecount_show = From b89410043a701770c26a2cfebfad8579f642bff7 Mon Sep 17 00:00:00 2001 From: grant2258 Date: Wed, 28 Nov 2018 08:22:33 +0000 Subject: [PATCH 091/153] add missing %s --- gfx/video_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 2d9d2baa74..de50911b15 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2464,7 +2464,7 @@ void video_driver_frame(const void *data, unsigned width, (uint64_t)video_driver_frame_count); } snprintf(video_driver_window_title, sizeof(video_driver_window_title), - "%s%s%s", title, video_info.fps_text, + "%s%s%s%s", title, video_info.fps_text, video_info.fps_show ? video_info.fps_text : "", video_info.framecount_show ? frames_text : ""); } From 2777ee2fa4ec15d3545cb664653f497b0a02a9b9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 28 Nov 2018 09:49:28 +0100 Subject: [PATCH 092/153] Fix memory leak --- menu/drivers/xmb.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 106da86156..f97b7cf352 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -4620,9 +4620,9 @@ static bool xmb_load_image(void *userdata, void *data, enum menu_image_type type static const char *xmb_texture_path(unsigned id) { - char *iconpath = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); - char *icon_name = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); - char *icon_fullpath = (char*) malloc(PATH_MAX_LENGTH * sizeof(char)); + char *iconpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + char *icon_name = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + char *icon_fullpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); iconpath[0] = icon_name[0] = icon_fullpath[0] = '\0'; @@ -4963,11 +4963,12 @@ static const char *xmb_texture_path(unsigned id) if (!filestream_exists(icon_fullpath)) { RARCH_WARN("[XMB] Asset missing: %s\n", icon_fullpath); + free(icon_fullpath); return NULL; } - else - return icon_name; + free(icon_fullpath); + return icon_name; } static void xmb_context_reset_textures( From af469698da2d669c1c6a5d0a36dc65563b815ef6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 28 Nov 2018 09:56:12 +0100 Subject: [PATCH 093/153] Silence threading error --- verbosity.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/verbosity.c b/verbosity.c index 823607b583..42a79f4977 100644 --- a/verbosity.c +++ b/verbosity.c @@ -126,9 +126,12 @@ void retro_main_log_file_init(const char *path) void retro_main_log_file_deinit(void) { if (log_file_fp && log_file_fp != stderr) + { fclose(log_file_fp); - if (log_file_buf) free(log_file_buf); - log_file_fp = NULL; + log_file_fp = NULL; + } + if (log_file_buf) + free(log_file_buf); log_file_buf = NULL; } From 1e097b0e1d4288d16f518d69712671fdab10499e Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Wed, 28 Nov 2018 13:58:14 +0400 Subject: [PATCH 094/153] Implement xdg_toplevel_close event --- gfx/drivers_context/wayland_ctx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index ac083651a1..d243a615ba 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -580,9 +580,15 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, wl->configured = false; } -/* TODO: implement xdg_toplevel close */ +static void handle_toplevel_close(void *data, struct xdg_toplevel *xdg_toplevel) +{ + gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; + BIT_SET(wl->input.key_state, KEY_ESC); +} + static const struct xdg_toplevel_listener xdg_toplevel_listener = { handle_toplevel_config, + handle_toplevel_close, }; static void display_handle_geometry(void *data, From 1c6602e35d8dffaaea46bd7be04cda4f8c0154f6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 28 Nov 2018 11:02:36 +0100 Subject: [PATCH 095/153] Add thread safety note --- tasks/task_autodetect.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tasks/task_autodetect.c b/tasks/task_autodetect.c index 4f8ac88943..00bb990b85 100644 --- a/tasks/task_autodetect.c +++ b/tasks/task_autodetect.c @@ -114,6 +114,11 @@ static bool input_autoconfigured[MAX_USERS]; static unsigned input_device_name_index[MAX_INPUT_DEVICES]; static bool input_autoconfigure_swap_override; +/* TODO/FIXME - Not thread safe to access this + * on main thread as well in its current state - + * menu_input.c - menu_event calls this function + * right now, while the underlying variable can + * be modified by a task thread. */ bool input_autoconfigure_get_swap_override(void) { return input_autoconfigure_swap_override; From ca0bd95c0ada5d451d06949ceecceba0137a0078 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 28 Nov 2018 11:03:52 +0100 Subject: [PATCH 096/153] FIx MSVC builds --- command.c | 3 ++- dynamic.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/command.c b/command.c index a378a97de9..5eaccec478 100644 --- a/command.c +++ b/command.c @@ -1899,9 +1899,10 @@ bool command_event(enum event_command cmd, void *data) break; case CMD_EVENT_LOAD_CORE: { + bool success = false; subsystem_size = 0; content_clear_subsystem(); - bool success = command_event(CMD_EVENT_LOAD_CORE_PERSIST, NULL); + success = command_event(CMD_EVENT_LOAD_CORE_PERSIST, NULL); (void)success; #ifndef HAVE_DYNAMIC diff --git a/dynamic.c b/dynamic.c index bacbefde07..fda8622334 100644 --- a/dynamic.c +++ b/dynamic.c @@ -185,6 +185,7 @@ static bool environ_cb_get_system_info(unsigned cmd, void *data) case RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO: { unsigned i, j; + unsigned size = i; const struct retro_subsystem_info *info = (const struct retro_subsystem_info*)data; subsystem_size = 0; @@ -206,7 +207,6 @@ static bool environ_cb_get_system_info(unsigned cmd, void *data) } RARCH_LOG("Subsystems: %d\n", i); - unsigned size = i; if (system) { From 1fa89d67c581edf161958cb6327127eb13eb75c6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 28 Nov 2018 11:14:21 +0100 Subject: [PATCH 097/153] (GX audio) Backport https://github.com/netux79/myra1002/commit/eefc216b0d6739f5b73f85bdc1286d32d53dc072 --- audio/drivers/gx_audio.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/audio/drivers/gx_audio.c b/audio/drivers/gx_audio.c index f28cd06bdc..e41f15f916 100644 --- a/audio/drivers/gx_audio.c +++ b/audio/drivers/gx_audio.c @@ -39,7 +39,6 @@ typedef struct volatile unsigned dma_write; size_t write_ptr; - OSCond cond; bool nonblock; bool is_paused; } gx_audio_t; @@ -63,8 +62,6 @@ static void dma_callback(void) DCFlushRange(wa->data[wa->dma_next], CHUNK_SIZE); AIInitDMA((uint32_t)wa->data[wa->dma_next], CHUNK_SIZE); - - OSSignalCond(wa->cond); } static void *gx_audio_init(const char *device, @@ -95,8 +92,6 @@ static void *gx_audio_init(const char *device, *new_rate = 48000; } - OSInitThreadQueue(&wa->cond); - wa->dma_write = BLOCKS - 1; DCFlushRange(wa->data, sizeof(wa->data)); stop_audio = false; @@ -133,8 +128,7 @@ static ssize_t gx_audio_write(void *data, const void *buf_, size_t size) /* FIXME: Nonblocking audio should break out of loop * when it has nothing to write. */ while ((wa->dma_write == wa->dma_next || - wa->dma_write == wa->dma_busy) && !wa->nonblock) - OSSleepThread(wa->cond); + wa->dma_write == wa->dma_busy) && !wa->nonblock); copy_swapped(wa->data[wa->dma_write] + wa->write_ptr, buf, to_write); @@ -205,10 +199,6 @@ static void gx_audio_free(void *data) AIStopDMA(); AIRegisterDMACallback(NULL); - if (wa->cond) - OSCloseThreadQueue(wa->cond); - wa->cond = 0; - free(data); } From 9cad7135a987a5fa99026d72386195baac1fd547 Mon Sep 17 00:00:00 2001 From: natinusala Date: Wed, 7 Nov 2018 19:25:26 +0100 Subject: [PATCH 098/153] libnx: implement focus gain and loss callbacks --- frontend/drivers/platform_switch.c | 12 ++++++++++++ gfx/drivers/gl.c | 6 ------ gfx/drivers_context/switch_ctx.c | 4 +++- retroarch.c | 6 ++++++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/frontend/drivers/platform_switch.c b/frontend/drivers/platform_switch.c index 756c9b8151..c90226cc79 100644 --- a/frontend/drivers/platform_switch.c +++ b/frontend/drivers/platform_switch.c @@ -55,6 +55,8 @@ static const char *elf_path_cst = "/switch/retroarch_switch.nro"; static uint64_t frontend_switch_get_mem_used(void); +bool platform_switch_has_focus = true; + #ifdef HAVE_LIBNX /* Splash */ @@ -69,10 +71,18 @@ extern bool nxlink_connected; #endif static void on_applet_hook(AppletHookType hook, void* param) { + /* Exit request */ if(hook == AppletHookType_OnExitRequest) { RARCH_LOG("Got AppletHook OnExitRequest, exiting.\n"); retroarch_main_quit(); } + /* Focus state*/ + else if (hook == AppletHookType_OnFocusState) { + AppletFocusState focus_state = appletGetFocusState(); + RARCH_LOG("Got AppletHook OnFocusState - new focus state is %d\n", focus_state); + + platform_switch_has_focus = focus_state == AppletFocusState_Focused; + } } #endif /* HAVE_LIBNX */ @@ -621,6 +631,8 @@ static void frontend_switch_init(void *data) nifmInitialize(); appletLockExit(); appletHook(&applet_hook_cookie, on_applet_hook, NULL); + + appletSetFocusHandlingMode(AppletFocusHandlingMode_NoSuspend); #ifndef HAVE_OPENGL /* Init Resolution before initDefault */ gfxInitResolution(1280, 720); diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index f9b93604fd..d62bd67cf4 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -957,12 +957,6 @@ static bool gl_frame(void *data, const void *frame, if (!gl) return false; -#ifdef HAVE_LIBNX - // Should be called once per frame - if(!appletMainLoop()) - return false; -#endif - gl_context_bind_hw_render(gl, false); if (gl->core_context_in_use && gl->renderchain_driver->bind_vao) diff --git a/gfx/drivers_context/switch_ctx.c b/gfx/drivers_context/switch_ctx.c index ccf3c40d02..47ab760b47 100644 --- a/gfx/drivers_context/switch_ctx.c +++ b/gfx/drivers_context/switch_ctx.c @@ -27,6 +27,8 @@ static enum gfx_ctx_api ctx_nx_api = GFX_CTX_OPENGL_API; switch_ctx_data_t *nx_ctx_ptr = NULL; +extern bool platform_switch_has_focus; + void switch_ctx_destroy(void *data) { switch_ctx_data_t *ctx_nx = (switch_ctx_data_t *)data; @@ -190,7 +192,7 @@ static bool switch_ctx_bind_api(void *data, static bool switch_ctx_has_focus(void *data) { (void)data; - return true; + return platform_switch_has_focus; } static bool switch_ctx_suppress_screensaver(void *data, bool enable) diff --git a/retroarch.c b/retroarch.c index eb14ada97e..7671fe20a8 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2522,6 +2522,12 @@ static enum runloop_state runloop_check_state( bool menu_is_alive = menu_driver_is_alive(); #endif +#ifdef HAVE_LIBNX + // Should be called once per frame + if(!appletMainLoop()) + return RUNLOOP_STATE_QUIT; +#endif + BIT256_CLEAR_ALL_PTR(¤t_input); #ifdef HAVE_MENU From d81e9a08b20e794ce1b2561890d44bc8c2d655f5 Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Wed, 28 Nov 2018 17:59:06 +0400 Subject: [PATCH 099/153] Add toplevel width and height --- gfx/drivers_context/wayland_ctx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index d243a615ba..80919d8e1d 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -576,6 +576,10 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; /* TODO: implement resizing */ + (void)toplevel; + + wl->width = wl->buffer_scale * width; + wl->height = wl->buffer_scale * height; wl->configured = false; } From 9989cc38d71c0de62afabf2924747c4d699bdd01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Wed, 28 Nov 2018 10:59:42 -0500 Subject: [PATCH 100/153] Update msg_hash_us.h --- intl/msg_hash_us.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 15bd1b26c3..bcb8740185 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -7789,4 +7789,4 @@ MSG_HASH( "Warning: Missing assets, use the Online Updater if available" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, - "Remember Window Positions") + "Remember Window Position and Size") From 0e93fade3e088d6069ab18c7ea9f20947e75a2ef Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 28 Nov 2018 19:57:19 +0100 Subject: [PATCH 101/153] Fix load content not showing up --- dynamic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dynamic.c b/dynamic.c index fda8622334..a3092dd8cd 100644 --- a/dynamic.c +++ b/dynamic.c @@ -207,6 +207,7 @@ static bool environ_cb_get_system_info(unsigned cmd, void *data) } RARCH_LOG("Subsystems: %d\n", i); + size = i; if (system) { From a24a788e5284e634ce8431ff2c64b13258babb62 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 29 Nov 2018 12:12:00 +0100 Subject: [PATCH 102/153] Fix subsystem for ozone --- menu/drivers/ozone/ozone.c | 2 +- menu/drivers/xmb.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index eac8d269e3..210799e229 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -589,7 +589,7 @@ static int ozone_list_push(void *data, void *userdata, if (subsystem_size > 0) { - const struct retro_subsystem_info* subsystem = system->subsystem.data; + const struct retro_subsystem_info* subsystem = subsystem_data; for (i = 0; i < subsystem_size; i++, subsystem++) { char s[PATH_MAX_LENGTH]; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index f97b7cf352..d6d83e79f7 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -5630,8 +5630,7 @@ static int xmb_list_push(void *data, void *userdata, menu_displaylist_setting(&entry); if (subsystem_size > 0) { - const struct retro_subsystem_info* subsystem = NULL; - subsystem = subsystem_data; + const struct retro_subsystem_info* subsystem = subsystem_data; for (i = 0; i < subsystem_size; i++, subsystem++) { char s[PATH_MAX_LENGTH]; From d52b38eadc3fd3cbba1d67e1727dd1d6803b4ebe Mon Sep 17 00:00:00 2001 From: Tatsuya79 Date: Thu, 29 Nov 2018 13:12:11 +0100 Subject: [PATCH 103/153] Add FPS counter hotkey. --- command.c | 7 +++++++ command.h | 2 ++ config.def.keybinds.h | 2 ++ input/input_defines.h | 1 + input/input_driver.c | 1 + intl/msg_hash_us.c | 4 ++++ msg_hash.h | 1 + retroarch.c | 12 ++++++++++++ 8 files changed, 30 insertions(+) diff --git a/command.c b/command.c index 5eaccec478..983bd8aae2 100644 --- a/command.c +++ b/command.c @@ -220,6 +220,7 @@ static const struct cmd_map map[] = { { "SCREENSHOT", RARCH_SCREENSHOT }, { "MUTE", RARCH_MUTE }, { "OSK", RARCH_OSK }, + { "FPS_TOGGLE", RARCH_FPS_TOGGLE }, { "NETPLAY_GAME_WATCH", RARCH_NETPLAY_GAME_WATCH }, { "VOLUME_UP", RARCH_VOLUME_UP }, { "VOLUME_DOWN", RARCH_VOLUME_DOWN }, @@ -2187,6 +2188,12 @@ TODO: Add a setting for these tweaks */ RARCH_LOG("%s\n", msg); } break; + case CMD_EVENT_FPS_TOGGLE: + { + settings_t *settings = config_get_ptr(); + settings->bools.video_fps_show = !(settings->bools.video_fps_show); + } + break; case CMD_EVENT_OVERLAY_DEINIT: #ifdef HAVE_OVERLAY input_overlay_free(overlay_ptr); diff --git a/command.h b/command.h index 134504cadb..7659ea605a 100644 --- a/command.h +++ b/command.h @@ -85,6 +85,8 @@ enum event_command CMD_EVENT_AUDIO_START, /* Mutes audio. */ CMD_EVENT_AUDIO_MUTE_TOGGLE, + /* Toggles FPS counter. */ + CMD_EVENT_FPS_TOGGLE, /* Initializes overlay. */ CMD_EVENT_OVERLAY_INIT, /* Deinitializes overlay. */ diff --git a/config.def.keybinds.h b/config.def.keybinds.h index 169cc7b5fc..c2994122a3 100644 --- a/config.def.keybinds.h +++ b/config.def.keybinds.h @@ -87,6 +87,7 @@ static const struct retro_keybind retro_keybinds_1[] = { { true, RARCH_SCREENSHOT, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_MUTE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_FPS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, @@ -165,6 +166,7 @@ static const struct retro_keybind retro_keybinds_1[] = { { true, RARCH_SCREENSHOT, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT, RETROK_F8, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_MUTE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE, RETROK_F9, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK, RETROK_F12, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_FPS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE, RETROK_F3, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH, RETROK_i, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP, RETROK_KP_PLUS, NO_BTN, NO_BTN, 0, AXIS_NONE }, diff --git a/input/input_defines.h b/input/input_defines.h index ea52a3c890..891d850bdd 100644 --- a/input/input_defines.h +++ b/input/input_defines.h @@ -97,6 +97,7 @@ enum RARCH_SCREENSHOT, RARCH_MUTE, RARCH_OSK, + RARCH_FPS_TOGGLE, RARCH_NETPLAY_GAME_WATCH, RARCH_ENABLE_HOTKEY, RARCH_VOLUME_UP, diff --git a/input/input_driver.c b/input/input_driver.c index 7261a4ca27..2e0c055fb9 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -343,6 +343,7 @@ const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = { DECLARE_META_BIND(2, screenshot, RARCH_SCREENSHOT, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT), DECLARE_META_BIND(2, audio_mute, RARCH_MUTE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE), DECLARE_META_BIND(2, osk_toggle, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK), + DECLARE_META_BIND(2, fps_toggle, RARCH_FPS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE), DECLARE_META_BIND(2, netplay_game_watch, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH), DECLARE_META_BIND(2, enable_hotkey, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY), DECLARE_META_BIND(2, volume_up, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP), diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c index e2d5c9c970..6f46d28063 100644 --- a/intl/msg_hash_us.c +++ b/intl/msg_hash_us.c @@ -104,6 +104,10 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len) snprintf(s, len, "Toggles onscreen keyboard."); break; + case RARCH_FPS_TOGGLE: + snprintf(s, len, + "Toggles frames per second counter."); + break; case RARCH_NETPLAY_GAME_WATCH: snprintf(s, len, "Netplay toggle play/spectate mode."); diff --git a/msg_hash.h b/msg_hash.h index 5c4e151916..b1565e79a0 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -671,6 +671,7 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK, + MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP, diff --git a/retroarch.c b/retroarch.c index 7671fe20a8..ba30250af1 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2930,6 +2930,18 @@ static enum runloop_state runloop_check_state( old_pressed = pressed; } + /* Check FPS toggle */ + { + static bool old_pressed = false; + bool pressed = BIT256_GET( + current_input, RARCH_FPS_TOGGLE); + + if (pressed && !old_pressed) + command_event(CMD_EVENT_FPS_TOGGLE, NULL); + + old_pressed = pressed; + } + /* Check recording toggle */ { static bool old_pressed = false; From e37c1c330daddb10909f372280088582bd871f51 Mon Sep 17 00:00:00 2001 From: Tatsuya79 Date: Thu, 29 Nov 2018 13:45:06 +0100 Subject: [PATCH 104/153] Fix missing label. --- intl/msg_hash_us.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index a3482164c3..fa0017737a 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -1251,6 +1251,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_INPUT_META_FRAMEADVANCE, "Frameadvance" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE, + "FPS toggle" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY, "Fullscreen toggle" From 8764d7be2840fa9266c0ea9ba5c2ea06c9421069 Mon Sep 17 00:00:00 2001 From: M4xw Date: Thu, 29 Nov 2018 18:42:44 +0100 Subject: [PATCH 105/153] [LIBNX] Implement Over-/Downclocking and minor fixes --- configuration.c | 10 +++ configuration.h | 2 + frontend/drivers/platform_switch.c | 62 +++++++++++--- intl/msg_hash_chs.h | 2 + intl/msg_hash_de.h | 2 + intl/msg_hash_es.h | 2 + intl/msg_hash_lbl.h | 2 + intl/msg_hash_pt_br.h | 2 + intl/msg_hash_us.h | 2 + lakka.h | 63 +-------------- menu/cbs/menu_cbs_deferred_push.c | 7 +- menu/cbs/menu_cbs_ok.c | 21 ++++- menu/cbs/menu_cbs_sublabel.c | 9 ++- menu/cbs/menu_cbs_title.c | 21 +++-- menu/drivers/ozone/ozone.c | 4 +- menu/drivers/ozone/ozone_texture.c | 3 + menu/drivers/xmb.c | 7 +- menu/menu_displaylist.c | 30 ++++--- menu/menu_displaylist.h | 2 + menu/menu_driver.h | 2 + menu/menu_setting.c | 6 +- msg_hash.h | 3 +- switch_performance_profiles.h | 125 +++++++++++++++++++++++++++++ 23 files changed, 289 insertions(+), 100 deletions(-) create mode 100644 switch_performance_profiles.h diff --git a/configuration.c b/configuration.c index db570b0d95..981ba24638 100644 --- a/configuration.c +++ b/configuration.c @@ -1679,6 +1679,10 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings, SETTING_UINT("video_record_threads", &settings->uints.video_record_threads, true, video_record_threads, false); +#ifdef HAVE_LIBNX + SETTING_UINT("libnx_overclock", &settings->uints.libnx_overclock, true, SWITCH_DEFAULT_CPU_PROFILE, false); +#endif + *size = count; return tmp; @@ -3133,6 +3137,12 @@ static bool config_load_file(const char *path, bool set_defaults, strlcpy(settings->arrays.menu_driver, "rgui", sizeof(settings->arrays.menu_driver)); #endif +#ifdef HAVE_LIBNX + // Apply initial clocks + extern void libnx_apply_overclock(); + libnx_apply_overclock(); +#endif + frontend_driver_set_sustained_performance_mode(settings->bools.sustained_performance_mode); recording_driver_update_streaming_url(); diff --git a/configuration.h b/configuration.h index f2c71cb15c..456fe8b953 100644 --- a/configuration.h +++ b/configuration.h @@ -446,6 +446,8 @@ typedef struct settings unsigned window_position_height; unsigned video_record_threads; + + unsigned libnx_overclock; } uints; struct diff --git a/frontend/drivers/platform_switch.c b/frontend/drivers/platform_switch.c index c90226cc79..59e38b6d44 100644 --- a/frontend/drivers/platform_switch.c +++ b/frontend/drivers/platform_switch.c @@ -13,6 +13,9 @@ #ifdef HAVE_LIBNX #include +#include "../../switch_performance_profiles.h" +#include "../../configuration.h" +#include #else #include #include @@ -70,18 +73,46 @@ static AppletHookCookie applet_hook_cookie; extern bool nxlink_connected; #endif -static void on_applet_hook(AppletHookType hook, void* param) { +void libnx_apply_overclock() { + const size_t profiles_count = sizeof(SWITCH_CPU_PROFILES) / sizeof(SWITCH_CPU_PROFILES[1]); + if (config_get_ptr()->uints.libnx_overclock >= 0 && config_get_ptr()->uints.libnx_overclock <= profiles_count) + pcvSetClockRate(PcvModule_Cpu, SWITCH_CPU_SPEEDS_VALUES[config_get_ptr()->uints.libnx_overclock]); +} + +static void on_applet_hook(AppletHookType hook, void *param) { + u32 performance_mode; + AppletFocusState focus_state; + /* Exit request */ - if(hook == AppletHookType_OnExitRequest) { + switch (hook) + { + case AppletHookType_OnExitRequest: RARCH_LOG("Got AppletHook OnExitRequest, exiting.\n"); retroarch_main_quit(); - } - /* Focus state*/ - else if (hook == AppletHookType_OnFocusState) { - AppletFocusState focus_state = appletGetFocusState(); - RARCH_LOG("Got AppletHook OnFocusState - new focus state is %d\n", focus_state); + break; + /* Focus state*/ + case AppletHookType_OnFocusState: + focus_state = appletGetFocusState(); + RARCH_LOG("Got AppletHook OnFocusState - new focus state is %d\n", focus_state); platform_switch_has_focus = focus_state == AppletFocusState_Focused; + if(!platform_switch_has_focus) { + pcvSetClockRate(PcvModule_Cpu, 1020000000); + } else { + libnx_apply_overclock(); + } + break; + + /* Performance mode */ + case AppletHookType_OnPerformanceMode: + // 0 == Handheld, 1 == Docked + // Since CPU doesn't change we just re-apply + performance_mode = appletGetPerformanceMode(); + libnx_apply_overclock(); + break; + + default: + break; } } @@ -211,6 +242,8 @@ static void frontend_switch_deinit(void *data) #ifdef HAVE_LIBNX nifmExit(); + pcvSetClockRate(PcvModule_Cpu, 1020000000); // Always 1020 MHz, unless SDEV + pcvExit(); #if defined(SWITCH) && defined(NXLINK) socketExit(); #endif @@ -235,7 +268,7 @@ static void frontend_switch_deinit(void *data) #ifdef HAVE_LIBNX static void frontend_switch_exec(const char *path, bool should_load_game) { - char game_path[PATH_MAX]; + char game_path[PATH_MAX-4]; const char *arg_data[3]; char error_string[200 + PATH_MAX]; int args = 0; @@ -623,16 +656,20 @@ static void frontend_switch_shutdown(bool unused) /* runloop_get_system_info isnt initialized that early.. */ extern void retro_get_system_info(struct retro_system_info *info); + static void frontend_switch_init(void *data) { + (void)data; #ifdef HAVE_LIBNX nifmInitialize(); + pcvInitialize(); + appletLockExit(); appletHook(&applet_hook_cookie, on_applet_hook, NULL); - appletSetFocusHandlingMode(AppletFocusHandlingMode_NoSuspend); + #ifndef HAVE_OPENGL /* Init Resolution before initDefault */ gfxInitResolution(1280, 720); @@ -643,7 +680,10 @@ static void frontend_switch_init(void *data) gfxConfigureTransform(0); #endif /* HAVE_OPENGL */ - appletInitializeGamePlayRecording(); + bool recording_supported = false; + appletIsGamePlayRecordingSupported(&recording_supported); + if(recording_supported) + appletInitializeGamePlayRecording(); #ifdef NXLINK socketInitializeDefault(); @@ -788,6 +828,8 @@ static enum frontend_powerstate frontend_switch_get_powerstate(int *seconds, int case ChargerType_Charger: case ChargerType_Usb: return FRONTEND_POWERSTATE_CHARGING; + default: + break; } return FRONTEND_POWERSTATE_NO_SOURCE; diff --git a/intl/msg_hash_chs.h b/intl/msg_hash_chs.h index 13f6fbb55a..328c18d273 100644 --- a/intl/msg_hash_chs.h +++ b/intl/msg_hash_chs.h @@ -15,6 +15,8 @@ MSG_HASH( MENU_ENUM_SUBLABEL_SWITCH_BACKLIGHT_CONTROL, "调整 Switch 的屏幕亮度" ) +#endif +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) MSG_HASH( MENU_ENUM_LABEL_VALUE_SWITCH_CPU_PROFILE, "CPU 超频" diff --git a/intl/msg_hash_de.h b/intl/msg_hash_de.h index 3a6c051535..48ab449e73 100644 --- a/intl/msg_hash_de.h +++ b/intl/msg_hash_de.h @@ -15,6 +15,8 @@ MSG_HASH( MENU_ENUM_SUBLABEL_SWITCH_BACKLIGHT_CONTROL, "Anpassen der Switch Bildschirmhelligkeit" ) +#endif +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) MSG_HASH( MENU_ENUM_LABEL_VALUE_SWITCH_CPU_PROFILE, "CPU Übertakten" diff --git a/intl/msg_hash_es.h b/intl/msg_hash_es.h index d60e909750..f3e9d8b2d3 100644 --- a/intl/msg_hash_es.h +++ b/intl/msg_hash_es.h @@ -15,6 +15,8 @@ MSG_HASH( MENU_ENUM_SUBLABEL_SWITCH_BACKLIGHT_CONTROL, "Ajusta el brillo de la pantalla" ) +#endif +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) MSG_HASH( MENU_ENUM_LABEL_VALUE_SWITCH_CPU_PROFILE, "CPU Overclock" diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index c9cb27d08f..d3d3be35a9 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -3,6 +3,8 @@ MSG_HASH(MENU_ENUM_LABEL_SWITCH_GPU_PROFILE, "switch_gpu_profile") MSG_HASH(MENU_ENUM_LABEL_SWITCH_BACKLIGHT_CONTROL, "switch_backlight_control") +#endif +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) MSG_HASH(MENU_ENUM_LABEL_SWITCH_CPU_PROFILE, "switch_cpu_profile") #endif diff --git a/intl/msg_hash_pt_br.h b/intl/msg_hash_pt_br.h index c63c4404f9..0dd39c521a 100644 --- a/intl/msg_hash_pt_br.h +++ b/intl/msg_hash_pt_br.h @@ -15,6 +15,8 @@ MSG_HASH( MENU_ENUM_SUBLABEL_SWITCH_BACKLIGHT_CONTROL, "Aumentar ou diminuir o brilho da tela do Switch" ) +#endif +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) MSG_HASH( MENU_ENUM_LABEL_VALUE_SWITCH_CPU_PROFILE, "Overclock da CPU" diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index fa0017737a..6fa546fe67 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -15,6 +15,8 @@ MSG_HASH( MENU_ENUM_SUBLABEL_SWITCH_BACKLIGHT_CONTROL, "Increase or decrease the Switch screen brightness" ) +#endif +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) MSG_HASH( MENU_ENUM_LABEL_VALUE_SWITCH_CPU_PROFILE, "CPU Overclock" diff --git a/lakka.h b/lakka.h index 0447aa6ed5..2b6073ead4 100644 --- a/lakka.h +++ b/lakka.h @@ -24,67 +24,6 @@ #define LAKKA_UPDATE_DIR "/storage/.update/" #define LAKKA_CONNMAN_DIR "/storage/.cache/connman/" -#ifdef HAVE_LAKKA_SWITCH -static char* SWITCH_GPU_PROFILES[] = { - "docked-overclock-3", - "docked-overclock-2", - "docked-overclock-1", - "docked", - "non-docked-overclock-5", - "non-docked-overclock-4", - "non-docked-overclock-3", - "non-docked-overclock-2", - "non-docked-overclock-1", - "non-docked", - "non-docked-underclock-1", - "non-docked-underclock-2", - "non-docked-underclock-3", -}; - -static char* SWITCH_GPU_SPEEDS[] = { - "998 Mhz", - "921 Mhz", - "844 Mhz", - "768 Mhz", - "691 Mhz", - "614 Mhz", - "537 Mhz", - "460 Mhz", - "384 Mhz", - "307 Mhz", - "230 Mhz", - "153 Mhz", - "76 Mhz" -}; - -static int SWITCH_BRIGHTNESS[] = { - 10, - 20, - 30, - 40, - 50, - 60, - 70, - 80, - 90, - 100 -}; - -static char* SWITCH_CPU_PROFILES[] = { - "overclock-4", - "overclock-3", - "overclock-2", - "overclock-1", - "default", -}; - -static char* SWITCH_CPU_SPEEDS[] = { - "1912 MHz", - "1734 MHz", - "1530 MHz", - "1224 MHz", - "1020 MHz" -}; -#endif +#include "switch_performance_profiles.h" #endif diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 7f8d37d4cc..79e1aee9b2 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -187,10 +187,13 @@ generic_deferred_push(deferred_push_core_content_dirs_subdir_list, DISPLAYLIST_ generic_deferred_push(deferred_push_lakka_list, DISPLAYLIST_LAKKA) #endif +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) +generic_deferred_push(deferred_push_switch_cpu_profile, DISPLAYLIST_SWITCH_CPU_PROFILE) +#endif + #ifdef HAVE_LAKKA_SWITCH generic_deferred_push(deferred_push_switch_gpu_profile, DISPLAYLIST_SWITCH_GPU_PROFILE) generic_deferred_push(deferred_push_switch_backlight_control, DISPLAYLIST_SWITCH_BACKLIGHT_CONTROL) -generic_deferred_push(deferred_push_switch_cpu_profile, DISPLAYLIST_SWITCH_CPU_PROFILE) #endif static int deferred_push_cursor_manager_list_deferred( @@ -906,6 +909,8 @@ static int menu_cbs_init_bind_deferred_push_compare_label( { BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_switch_backlight_control); } +#endif +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) else if (strstr(label, msg_hash_to_str(MENU_ENUM_LABEL_SWITCH_CPU_PROFILE))) { diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index a4d9230bce..0218028835 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -2524,25 +2524,34 @@ static int action_ok_deferred_list_stub(const char *path, return 0; } -#ifdef HAVE_LAKKA_SWITCH +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) static int action_ok_set_switch_cpu_profile(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { char* profile_name = SWITCH_CPU_PROFILES[entry_idx]; - char command[PATH_MAX_LENGTH] = {0}; +#ifdef HAVE_LAKKA_SWITCH snprintf(command, sizeof(command), "cpu-profile set %s", profile_name); system(command); - snprintf(command, sizeof(command), "Current profile set to %s", profile_name); - +#else + config_get_ptr()->uints.libnx_overclock = entry_idx; + + unsigned profile_clock = SWITCH_CPU_SPEEDS_VALUES[entry_idx]; + pcvSetClockRate(PcvModule_Cpu, (u32)profile_clock); + snprintf(command, sizeof(command), "Current Clock set to %i", profile_clock); +#endif + runloop_msg_queue_push(command, 1, 90, true); return menu_cbs_exit(); } +#endif + +#ifdef HAVE_LAKKA_SWITCH static int action_ok_set_switch_gpu_profile(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) @@ -5187,6 +5196,8 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, #ifdef HAVE_LAKKA_SWITCH case MENU_ENUM_LABEL_SWITCH_GPU_PROFILE: case MENU_ENUM_LABEL_SWITCH_BACKLIGHT_CONTROL: +#endif +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) case MENU_ENUM_LABEL_SWITCH_CPU_PROFILE: #endif BIND_ACTION_OK(cbs, action_ok_push_default); @@ -5640,6 +5651,8 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs, case MENU_SET_SWITCH_BRIGHTNESS: BIND_ACTION_OK(cbs, action_ok_set_switch_backlight); break; +#endif +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) case MENU_SET_SWITCH_CPU_PROFILE: BIND_ACTION_OK(cbs, action_ok_set_switch_cpu_profile); break; diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 81347b8267..2a95e163d8 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -485,9 +485,12 @@ default_sublabel_macro(action_bind_sublabel_show_wimp, #endif default_sublabel_macro(action_bind_sublabel_discord_allow, MENU_ENUM_SUBLABEL_DISCORD_ALLOW) +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) +default_sublabel_macro(action_bind_sublabel_switch_cpu_profile, MENU_ENUM_SUBLABEL_SWITCH_CPU_PROFILE) +#endif + #ifdef HAVE_LAKKA_SWITCH default_sublabel_macro(action_bind_sublabel_switch_gpu_profile, MENU_ENUM_SUBLABEL_SWITCH_GPU_PROFILE) -default_sublabel_macro(action_bind_sublabel_switch_cpu_profile, MENU_ENUM_SUBLABEL_SWITCH_CPU_PROFILE) default_sublabel_macro(action_bind_sublabel_switch_backlight_control, MENU_ENUM_SUBLABEL_SWITCH_BACKLIGHT_CONTROL) #endif @@ -2036,10 +2039,12 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_show_wimp); break; #endif -#ifdef HAVE_LAKKA_SWITCH +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) case MENU_ENUM_LABEL_SWITCH_CPU_PROFILE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_switch_cpu_profile); break; +#endif +#ifdef HAVE_LAKKA_SWITCH case MENU_ENUM_LABEL_SWITCH_GPU_PROFILE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_switch_gpu_profile); break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index b3dc2440b8..9b3e3be0b7 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -210,9 +210,12 @@ default_title_copy_macro(action_get_title_cheevos_list, MENU_ENUM_LABE default_title_copy_macro(action_get_title_video_shader_parameters,MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS) default_title_copy_macro(action_get_title_video_shader_preset_parameters,MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_PARAMETERS) +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) +default_title_macro(action_get_title_switch_cpu_profile, MENU_ENUM_LABEL_VALUE_SWITCH_CPU_PROFILE) +#endif + #ifdef HAVE_LAKKA_SWITCH default_title_macro(action_get_title_switch_gpu_profile, MENU_ENUM_LABEL_VALUE_SWITCH_GPU_PROFILE) -default_title_macro(action_get_title_switch_cpu_profile, MENU_ENUM_LABEL_VALUE_SWITCH_CPU_PROFILE) default_title_macro(action_get_title_switch_backlight_control, MENU_ENUM_LABEL_VALUE_SWITCH_BACKLIGHT_CONTROL) #endif @@ -879,13 +882,15 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_LIBRETRO_INFO_PATH: BIND_ACTION_GET_TITLE(cbs, action_get_title_core_info_directory); break; +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) + case MENU_ENUM_LABEL_SWITCH_CPU_PROFILE: + BIND_ACTION_GET_TITLE(cbs, action_get_title_switch_cpu_profile); + break; +#endif #ifdef HAVE_LAKKA_SWITCH case MENU_ENUM_LABEL_SWITCH_GPU_PROFILE: BIND_ACTION_GET_TITLE(cbs, action_get_title_switch_gpu_profile); break; - case MENU_ENUM_LABEL_SWITCH_CPU_PROFILE: - BIND_ACTION_GET_TITLE(cbs, action_get_title_switch_cpu_profile); - break; case MENU_ENUM_LABEL_SWITCH_BACKLIGHT_CONTROL: BIND_ACTION_GET_TITLE(cbs, action_get_title_switch_backlight_control); break; @@ -1176,13 +1181,15 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_LIBRETRO_INFO_PATH: BIND_ACTION_GET_TITLE(cbs, action_get_title_core_info_directory); break; +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) + case MENU_ENUM_LABEL_SWITCH_CPU_PROFILE: + BIND_ACTION_GET_TITLE(cbs, action_get_title_switch_cpu_profile); + break; +#endif #ifdef HAVE_LAKKA_SWITCH case MENU_ENUM_LABEL_SWITCH_GPU_PROFILE: BIND_ACTION_GET_TITLE(cbs, action_get_title_switch_gpu_profile); break; - case MENU_ENUM_LABEL_SWITCH_CPU_PROFILE: - BIND_ACTION_GET_TITLE(cbs, action_get_title_switch_cpu_profile); - break; case MENU_ENUM_LABEL_SWITCH_BACKLIGHT_CONTROL: BIND_ACTION_GET_TITLE(cbs, action_get_title_switch_backlight_control); break; diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 210799e229..bcd5773854 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -673,10 +673,12 @@ static int ozone_list_push(void *data, void *userdata, menu_displaylist_setting(&entry); } -#ifdef HAVE_LAKKA_SWITCH +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) entry.enum_idx = MENU_ENUM_LABEL_SWITCH_CPU_PROFILE; menu_displaylist_setting(&entry); +#endif +#ifdef HAVE_LAKKA_SWITCH entry.enum_idx = MENU_ENUM_LABEL_SWITCH_GPU_PROFILE; menu_displaylist_setting(&entry); diff --git a/menu/drivers/ozone/ozone_texture.c b/menu/drivers/ozone/ozone_texture.c index 7af3843ee1..846682d2ed 100644 --- a/menu/drivers/ozone/ozone_texture.c +++ b/menu/drivers/ozone/ozone_texture.c @@ -211,7 +211,10 @@ menu_texture_item ozone_entries_icon_get_texture(ozone_handle_t *ozone, return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_UI]; #ifdef HAVE_LAKKA_SWITCH case MENU_ENUM_LABEL_SWITCH_GPU_PROFILE: +#endif +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) case MENU_ENUM_LABEL_SWITCH_CPU_PROFILE: + return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_POWER]; #endif case MENU_ENUM_LABEL_POWER_MANAGEMENT_SETTINGS: return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_POWER]; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index d6d83e79f7..23561e1651 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2450,7 +2450,10 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, return xmb->textures.list[XMB_TEXTURE_UI]; #ifdef HAVE_LAKKA_SWITCH case MENU_ENUM_LABEL_SWITCH_GPU_PROFILE: +#endif +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) case MENU_ENUM_LABEL_SWITCH_CPU_PROFILE: + return xmb->textures.list[XMB_TEXTURE_POWER]; #endif case MENU_ENUM_LABEL_POWER_MANAGEMENT_SETTINGS: return xmb->textures.list[XMB_TEXTURE_POWER]; @@ -5714,10 +5717,12 @@ static int xmb_list_push(void *data, void *userdata, menu_displaylist_setting(&entry); } -#ifdef HAVE_LAKKA_SWITCH +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) entry.enum_idx = MENU_ENUM_LABEL_SWITCH_CPU_PROFILE; menu_displaylist_setting(&entry); +#endif +#ifdef HAVE_LAKKA_SWITCH entry.enum_idx = MENU_ENUM_LABEL_SWITCH_GPU_PROFILE; menu_displaylist_setting(&entry); diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index d28adcf9b3..e314c8ac54 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -51,6 +51,11 @@ #include "../../lakka.h" #endif +#ifdef HAVE_LIBNX +#include +#include "../../switch_performance_profiles.h" +#endif + #if defined(__linux__) || (defined(BSD) && !defined(__MACH__)) #include "../frontend/drivers/platform_unix.h" #endif @@ -4265,7 +4270,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist switch (type) { -#ifdef HAVE_LAKKA_SWITCH +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) case DISPLAYLIST_SWITCH_CPU_PROFILE: { unsigned i; @@ -4274,17 +4279,22 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist FILE *profile = NULL; const size_t profiles_count = sizeof(SWITCH_CPU_PROFILES)/sizeof(SWITCH_CPU_PROFILES[1]); - runloop_msg_queue_push("Warning : extented overclocking can damage the Switch", 1, 90, true); + runloop_msg_queue_push("Warning : extended overclocking can damage the Switch", 1, 90, true); + menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); + +#ifdef HAVE_LAKKA_SWITCH profile = popen("cpu-profile get", "r"); fgets(current_profile, PATH_MAX_LENGTH, profile); pclose(profile); + - menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); - - snprintf(text, sizeof(text), - "Current profile : %s", current_profile); - + snprintf(text, sizeof(text), "Current profile : %s", current_profile); +#else + u32 currentClock = 0; + pcvGetClockRate(PcvModule_Cpu, ¤tClock); + snprintf(text, sizeof(text), "Current Clock : %i", currentClock); +#endif menu_entries_append_enum(info->list, text, "", @@ -4313,6 +4323,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist break; } +#if defined(HAVE_LAKKA_SWITCH) case DISPLAYLIST_SWITCH_GPU_PROFILE: { unsigned i; @@ -4330,7 +4341,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); snprintf(text, sizeof(text), "Current profile : %s", current_profile); - + menu_entries_append_enum(info->list, text, "", @@ -4383,7 +4394,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist break; } -#endif +#endif // HAVE_LAKKA_SWITCH +#endif // HAVE_LAKKA_SWITCH || HAVE_LIBNX case DISPLAYLIST_MUSIC_LIST: { char combined_path[PATH_MAX_LENGTH]; diff --git a/menu/menu_displaylist.h b/menu/menu_displaylist.h index a2a71f2af2..4d8f165351 100644 --- a/menu/menu_displaylist.h +++ b/menu/menu_displaylist.h @@ -183,6 +183,8 @@ enum menu_displaylist_ctl_state #ifdef HAVE_LAKKA_SWITCH DISPLAYLIST_SWITCH_GPU_PROFILE, DISPLAYLIST_SWITCH_BACKLIGHT_CONTROL, +#endif +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) DISPLAYLIST_SWITCH_CPU_PROFILE, #endif DISPLAYLIST_PENDING_CLEAR diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 0e97b73a3f..6487d37248 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -245,6 +245,8 @@ enum menu_settings_type #ifdef HAVE_LAKKA_SWITCH MENU_SET_SWITCH_GPU_PROFILE, MENU_SET_SWITCH_BRIGHTNESS, +#endif +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) MENU_SET_SWITCH_CPU_PROFILE, #endif diff --git a/menu/menu_setting.c b/menu/menu_setting.c index c14112d8ee..daf67f6100 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -3750,8 +3750,7 @@ static bool setting_append_list( menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_QUIT); #endif -#if defined(HAVE_LAKKA) -#ifdef HAVE_LAKKA_SWITCH +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) CONFIG_ACTION( list, list_info, MENU_ENUM_LABEL_SWITCH_CPU_PROFILE, @@ -3759,7 +3758,10 @@ static bool setting_append_list( &group_info, &subgroup_info, parent_group); +#endif +#if defined(HAVE_LAKKA) +#ifdef HAVE_LAKKA_SWITCH CONFIG_ACTION( list, list_info, MENU_ENUM_LABEL_SWITCH_GPU_PROFILE, diff --git a/msg_hash.h b/msg_hash.h index b1565e79a0..326c32c92e 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -2172,7 +2172,8 @@ enum msg_hash_enums MENU_ENUM_LABEL_SWITCH_BACKLIGHT_CONTROL, MENU_ENUM_LABEL_VALUE_SWITCH_BACKLIGHT_CONTROL, MENU_ENUM_SUBLABEL_SWITCH_BACKLIGHT_CONTROL, - +#endif +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) MENU_ENUM_LABEL_SWITCH_CPU_PROFILE, MENU_ENUM_LABEL_VALUE_SWITCH_CPU_PROFILE, MENU_ENUM_SUBLABEL_SWITCH_CPU_PROFILE, diff --git a/switch_performance_profiles.h b/switch_performance_profiles.h new file mode 100644 index 0000000000..316e0bc122 --- /dev/null +++ b/switch_performance_profiles.h @@ -0,0 +1,125 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2018-2018 - Natinusala + * Copyright (C) 2018-2018 - M4xw + * + * 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 __SWITCH_PERFORMANCE_PROFILES_H +#define __SWITCH_PERFORMANCE_PROFILES_H + +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) +#ifdef HAVE_LAKKA_SWITCH +static char *SWITCH_GPU_PROFILES[] = { + "docked-overclock-3", + "docked-overclock-2", + "docked-overclock-1", + "docked", + "non-docked-overclock-5", + "non-docked-overclock-4", + "non-docked-overclock-3", + "non-docked-overclock-2", + "non-docked-overclock-1", + "non-docked", + "non-docked-underclock-1", + "non-docked-underclock-2", + "non-docked-underclock-3", +}; + +static char *SWITCH_GPU_SPEEDS[] = { + "998 Mhz", + "921 Mhz", + "844 Mhz", + "768 Mhz", + "691 Mhz", + "614 Mhz", + "537 Mhz", + "460 Mhz", + "384 Mhz", + "307 Mhz", + "230 Mhz", + "153 Mhz", + "76 Mhz"}; + +static int SWITCH_BRIGHTNESS[] = { + 10, + 20, + 30, + 40, + 50, + 60, + 70, + 80, + 90, + 100}; +#endif + +static char *SWITCH_CPU_PROFILES[] = { +#ifndef HAVE_LIBNX + "overclock-4", + "overclock-3", + "overclock-2", + "overclock-1", + "default", +#else + "Maximum Performance", + "High Performance", + "Boost Performance", + "Stock Performance", + "Powersaving Mode 1", + "Powersaving Mode 2", + "Powersaving Mode 3", +#endif +}; + +#define SWITCH_DEFAULT_CPU_PROFILE 3 /* Stock Performance */ +#define LIBNX_MAX_CPU_PROFILE 0 /* Max Performance */ + +static char *SWITCH_CPU_SPEEDS[] = { +#ifndef HAVE_LIBNX + "1912 MHz", + "1734 MHz", + "1530 MHz", + "1224 MHz", + "1020 MHz" +#else + "1785 MHz", + "1581 MHz", + "1224 MHz", + "1020 MHz", + "918 MHz", + "816 MHz", + "714 MHz" +#endif +}; + +static unsigned SWITCH_CPU_SPEEDS_VALUES[] = { +#ifndef HAVE_LIBNX + 1912000000, + 1734000000, + 1530000000, + 1224000000, + 1020000000 +#else + 1785000000, + 1581000000, + 1224000000, + 1020000000, + 918000000, + 816000000, + 714000000 +#endif +}; + +#endif + +#endif \ No newline at end of file From ab34b21f8dbb4044e1d1f69bd9f2a1fc1e183602 Mon Sep 17 00:00:00 2001 From: alfrix Date: Thu, 29 Nov 2018 14:47:46 -0300 Subject: [PATCH 106/153] XMB asset handling refactors also do not show black boxes --- menu/drivers/xmb.c | 529 +++++++++++++++++++-------------------------- 1 file changed, 218 insertions(+), 311 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index d6d83e79f7..78dbf1614a 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -205,6 +205,8 @@ enum XMB_TEXTURE_MENU_ADD, XMB_TEXTURE_BRIGHTNESS, XMB_TEXTURE_PAUSE, + XMB_TEXTURE_DEFAULT, + XMB_TEXTURE_DEFAULT_CONTENT, XMB_TEXTURE_LAST }; @@ -234,6 +236,7 @@ typedef struct xmb_handle { bool mouse_show; bool use_ps3_layout; + bool assets_missing; uint8_t system_tab_end; uint8_t tabs[XMB_SYSTEM_TAB_MAX_LENGTH]; @@ -2571,6 +2574,7 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, return xmb->textures.list[XMB_TEXTURE_CURSOR]; case FILE_TYPE_PLAYLIST_ENTRY: case MENU_SETTING_ACTION_RUN: + return xmb->textures.list[XMB_TEXTURE_RUN]; case MENU_SETTING_ACTION_RESUME_ACHIEVEMENTS: return xmb->textures.list[XMB_TEXTURE_RESUME]; case MENU_SETTING_ACTION_CLOSE: @@ -2954,7 +2958,14 @@ static int xmb_draw_item( menu_display_set_alpha(color, MIN(node->alpha, xmb->alpha)); - if (color[3] != 0) + if ( + (!xmb->assets_missing) && + (color[3] != 0) && + ( + (entry->checked) || + !((entry_type >= MENU_SETTING_DROPDOWN_ITEM) && (entry_type <= MENU_SETTING_DROPDOWN_SETTING_UINT_ITEM_SPECIAL)) + ) + ) { math_matrix_4x4 mymat_tmp; menu_display_ctx_rotate_draw_t rotate_draw; @@ -2975,31 +2986,24 @@ static int xmb_draw_item( menu_display_rotate_z(&rotate_draw, video_info); - if ( - (entry->checked) || - !((entry_type >= MENU_SETTING_DROPDOWN_ITEM) && - (entry_type <= MENU_SETTING_DROPDOWN_SETTING_UINT_ITEM_SPECIAL)) - ) - { - xmb_draw_icon(video_info, - xmb->icon_size, - &mymat_tmp, - texture, - x, - y, - width, - height, - 1.0, - rotation, - scale_factor, - &color[0], - xmb->shadow_offset); - } + xmb_draw_icon(video_info, + xmb->icon_size, + &mymat_tmp, + texture, + x, + y, + width, + height, + 1.0, + rotation, + scale_factor, + &color[0], + xmb->shadow_offset); } menu_display_set_alpha(color, MIN(node->alpha, xmb->alpha)); - if (texture_switch != 0 && color[3] != 0) + if (texture_switch != 0 && color[3] != 0 && !xmb->assets_missing) xmb_draw_icon(video_info, xmb->icon_size, mymat, @@ -3752,7 +3756,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) size_t x_pos = xmb->icon_size / 6; size_t x_pos_icon = xmb->margins_title_left; - if (coord_white[3] != 0) + if (coord_white[3] != 0 && !xmb->assets_missing) xmb_draw_icon(video_info, xmb->icon_size, &mymat, @@ -3781,7 +3785,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) } } - if (video_info->timedate_enable) + if (video_info->timedate_enable && !xmb->assets_missing) { menu_display_ctx_datetime_t datetime; char timedate[255]; @@ -3830,7 +3834,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) menu_display_set_alpha(coord_white, MIN(xmb->textures_arrow_alpha, xmb->alpha)); - if (coord_white[3] != 0) + if (coord_white[3] != 0 && !xmb->assets_missing) xmb_draw_icon(video_info, xmb->icon_size, &mymat, @@ -3852,52 +3856,55 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) menu_display_blend_begin(video_info); /* Horizontal tab icons */ - for (i = 0; i <= xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL) - + xmb->system_tab_end; i++) + if (!xmb->assets_missing) { - xmb_node_t *node = xmb_get_node(xmb, i); - - if (!node) - continue; - - menu_display_set_alpha(item_color, MIN(node->alpha, xmb->alpha)); - - if (item_color[3] != 0) + for (i = 0; i <= xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL) + + xmb->system_tab_end; i++) { - menu_display_ctx_rotate_draw_t rotate_draw; - math_matrix_4x4 mymat; - uintptr_t texture = node->icon; - float x = xmb->x + xmb->categories_x_pos + - xmb->margins_screen_left + - xmb->icon_spacing_horizontal - * (i + 1) - xmb->icon_size / 2.0; - float y = xmb->margins_screen_top - + xmb->icon_size / 2.0; - float rotation = 0; - float scale_factor = node->zoom; + xmb_node_t *node = xmb_get_node(xmb, i); - rotate_draw.matrix = &mymat; - rotate_draw.rotation = rotation; - rotate_draw.scale_x = scale_factor; - rotate_draw.scale_y = scale_factor; - rotate_draw.scale_z = 1; - rotate_draw.scale_enable = true; + if (!node) + continue; - menu_display_rotate_z(&rotate_draw, video_info); + menu_display_set_alpha(item_color, MIN(node->alpha, xmb->alpha)); - xmb_draw_icon(video_info, - xmb->icon_size, - &mymat, - texture, - x, - y, - width, - height, - 1.0, - rotation, - scale_factor, - &item_color[0], - xmb->shadow_offset); + if (item_color[3] != 0) + { + menu_display_ctx_rotate_draw_t rotate_draw; + math_matrix_4x4 mymat; + uintptr_t texture = node->icon; + float x = xmb->x + xmb->categories_x_pos + + xmb->margins_screen_left + + xmb->icon_spacing_horizontal + * (i + 1) - xmb->icon_size / 2.0; + float y = xmb->margins_screen_top + + xmb->icon_size / 2.0; + float rotation = 0; + float scale_factor = node->zoom; + + rotate_draw.matrix = &mymat; + rotate_draw.rotation = rotation; + rotate_draw.scale_x = scale_factor; + rotate_draw.scale_y = scale_factor; + rotate_draw.scale_z = 1; + rotate_draw.scale_enable = true; + + menu_display_rotate_z(&rotate_draw, video_info); + + xmb_draw_icon(video_info, + xmb->icon_size, + &mymat, + texture, + x, + y, + width, + height, + 1.0, + rotation, + scale_factor, + &item_color[0], + xmb->shadow_offset); + } } } @@ -4620,355 +4627,232 @@ static bool xmb_load_image(void *userdata, void *data, enum menu_image_type type static const char *xmb_texture_path(unsigned id) { - char *iconpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - char *icon_name = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - char *icon_fullpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - - iconpath[0] = icon_name[0] = icon_fullpath[0] = '\0'; - switch (id) { case XMB_TEXTURE_MAIN_MENU: #if defined(HAVE_LAKKA) - icon_name = "lakka.png"; - break; + return "lakka.png"; #else - icon_name = "retroarch.png"; - break; + return "retroarch.png"; #endif case XMB_TEXTURE_SETTINGS: - icon_name = "settings.png"; - break; + return "settings.png"; case XMB_TEXTURE_HISTORY: - icon_name = "history.png"; - break; + return "history.png"; case XMB_TEXTURE_FAVORITES: - icon_name = "favorites.png"; - break; + return "favorites.png"; case XMB_TEXTURE_ADD_FAVORITE: - icon_name = "add-favorite.png"; - break; + return "add-favorite.png"; case XMB_TEXTURE_MUSICS: - icon_name = "musics.png"; - break; + return "musics.png"; #if defined(HAVE_FFMPEG) || defined(HAVE_MPV) case XMB_TEXTURE_MOVIES: - icon_name = "movies.png"; - break; + return "movies.png"; #endif #ifdef HAVE_IMAGEVIEWER case XMB_TEXTURE_IMAGES: - icon_name = "images.png"; - break; + return "images.png"; #endif case XMB_TEXTURE_SETTING: - icon_name = "setting.png"; - break; + return "setting.png"; case XMB_TEXTURE_SUBSETTING: - icon_name = "subsetting.png"; - break; + return "subsetting.png"; case XMB_TEXTURE_ARROW: - icon_name = "arrow.png"; - break; + return "arrow.png"; case XMB_TEXTURE_RUN: - icon_name = "run.png"; - break; + return "run.png"; case XMB_TEXTURE_CLOSE: - icon_name = "close.png"; - break; + return "close.png"; case XMB_TEXTURE_RESUME: - icon_name = "resume.png"; - break; + return "resume.png"; case XMB_TEXTURE_CLOCK: - icon_name = "clock.png"; - break; + return "clock.png"; case XMB_TEXTURE_BATTERY_FULL: - icon_name = "battery-full.png"; - break; + return "battery-full.png"; case XMB_TEXTURE_BATTERY_CHARGING: - icon_name = "battery-charging.png"; - break; + return "battery-charging.png"; case XMB_TEXTURE_POINTER: - icon_name = "pointer.png"; - break; + return "pointer.png"; case XMB_TEXTURE_SAVESTATE: - icon_name = "savestate.png"; - break; + return "savestate.png"; case XMB_TEXTURE_LOADSTATE: - icon_name = "loadstate.png"; - break; + return "loadstate.png"; case XMB_TEXTURE_UNDO: - icon_name = "undo.png"; - break; + return "undo.png"; case XMB_TEXTURE_CORE_INFO: - icon_name = "core-infos.png"; - break; + return "core-infos.png"; case XMB_TEXTURE_WIFI: - icon_name = "wifi.png"; - break; + return "wifi.png"; case XMB_TEXTURE_CORE_OPTIONS: - icon_name = "core-options.png"; - break; + return "core-options.png"; case XMB_TEXTURE_INPUT_REMAPPING_OPTIONS: - icon_name = "core-input-remapping-options.png"; - break; + return "core-input-remapping-options.png"; case XMB_TEXTURE_CHEAT_OPTIONS: - icon_name = "core-cheat-options.png"; - break; + return "core-cheat-options.png"; case XMB_TEXTURE_DISK_OPTIONS: - icon_name = "core-disk-options.png"; - break; + return "core-disk-options.png"; case XMB_TEXTURE_SHADER_OPTIONS: - icon_name = "core-shader-options.png"; - break; + return "core-shader-options.png"; case XMB_TEXTURE_ACHIEVEMENT_LIST: - icon_name = "achievement-list.png"; - break; + return "achievement-list.png"; case XMB_TEXTURE_SCREENSHOT: - icon_name = "screenshot.png"; - break; + return "screenshot.png"; case XMB_TEXTURE_RELOAD: - icon_name = "reload.png"; - break; + return "reload.png"; case XMB_TEXTURE_RENAME: - icon_name = "rename.png"; - break; + return "rename.png"; case XMB_TEXTURE_FILE: - icon_name = "file.png"; - break; + return "file.png"; case XMB_TEXTURE_FOLDER: - icon_name = "folder.png"; - break; + return "folder.png"; case XMB_TEXTURE_ZIP: - icon_name = "zip.png"; - break; + return "zip.png"; case XMB_TEXTURE_MUSIC: - icon_name = "music.png"; - break; + return "music.png"; case XMB_TEXTURE_FAVORITE: - icon_name = "favorites-content.png"; - break; + return "favorites-content.png"; case XMB_TEXTURE_IMAGE: - icon_name = "image.png"; - break; + return "image.png"; case XMB_TEXTURE_MOVIE: - icon_name = "movie.png"; - break; + return "movie.png"; case XMB_TEXTURE_CORE: - icon_name = "core.png"; - break; + return "core.png"; case XMB_TEXTURE_RDB: - icon_name = "database.png"; - break; + return "database.png"; case XMB_TEXTURE_CURSOR: - icon_name = "cursor.png"; - break; + return "cursor.png"; case XMB_TEXTURE_SWITCH_ON: - icon_name = "on.png"; - break; + return "on.png"; case XMB_TEXTURE_SWITCH_OFF: - icon_name = "off.png"; - break; + return "off.png"; case XMB_TEXTURE_ADD: - icon_name = "add.png"; - break; + return "add.png"; #ifdef HAVE_NETWORKING case XMB_TEXTURE_NETPLAY: - icon_name = "netplay.png"; - break; + return "netplay.png"; case XMB_TEXTURE_ROOM: - icon_name = "menu_room.png"; - break; + return "menu_room.png"; case XMB_TEXTURE_ROOM_LAN: - icon_name = "menu_room_lan.png"; - break; + return "menu_room_lan.png"; case XMB_TEXTURE_ROOM_RELAY: - icon_name = "menu_room_relay.png"; - break; + return "menu_room_relay.png"; #endif case XMB_TEXTURE_KEY: - icon_name = "key.png"; - break; + return "key.png"; case XMB_TEXTURE_KEY_HOVER: - icon_name = "key-hover.png"; - break; + return "key-hover.png"; case XMB_TEXTURE_DIALOG_SLICE: - icon_name = "dialog-slice.png"; - break; + return "dialog-slice.png"; case XMB_TEXTURE_ACHIEVEMENTS: - icon_name = "menu_achievements.png"; - break; + return "menu_achievements.png"; case XMB_TEXTURE_AUDIO: - icon_name = "menu_audio.png"; - break; + return "menu_audio.png"; case XMB_TEXTURE_DRIVERS: - icon_name = "menu_drivers.png"; - break; + return "menu_drivers.png"; case XMB_TEXTURE_EXIT: - icon_name = "menu_exit.png"; - break; + return "menu_exit.png"; case XMB_TEXTURE_FRAMESKIP: - icon_name = "menu_frameskip.png"; - break; + return "menu_frameskip.png"; case XMB_TEXTURE_HELP: - icon_name = "menu_help.png"; - break; + return "menu_help.png"; case XMB_TEXTURE_INFO: - icon_name = "menu_info.png"; - break; + return "menu_info.png"; case XMB_TEXTURE_INPUT_SETTINGS: - icon_name = "Libretro - Pad.png"; - break; + return "Libretro - Pad.png"; case XMB_TEXTURE_LATENCY: - icon_name = "menu_latency.png"; - break; + return "menu_latency.png"; case XMB_TEXTURE_NETWORK: - icon_name = "menu_network.png"; - break; + return "menu_network.png"; case XMB_TEXTURE_POWER: - icon_name = "menu_power.png"; - break; + return "menu_power.png"; case XMB_TEXTURE_RECORD: - icon_name = "menu_record.png"; - break; + return "menu_record.png"; case XMB_TEXTURE_SAVING: - icon_name = "menu_saving.png"; - break; + return "menu_saving.png"; case XMB_TEXTURE_UPDATER: - icon_name = "menu_updater.png"; - break; + return "menu_updater.png"; case XMB_TEXTURE_VIDEO: - icon_name = "menu_video.png"; - break; + return "menu_video.png"; case XMB_TEXTURE_MIXER: - icon_name = "menu_mixer.png"; - break; + return "menu_mixer.png"; case XMB_TEXTURE_LOG: - icon_name = "menu_log.png"; - break; + return "menu_log.png"; case XMB_TEXTURE_OSD: - icon_name = "menu_osd.png"; - break; + return "menu_osd.png"; case XMB_TEXTURE_UI: - icon_name = "menu_ui.png"; - break; + return "menu_ui.png"; case XMB_TEXTURE_USER: - icon_name = "menu_user.png"; - break; + return "menu_user.png"; case XMB_TEXTURE_PRIVACY: - icon_name = "menu_privacy.png"; - break; + return "menu_privacy.png"; case XMB_TEXTURE_PLAYLIST: - icon_name = "menu_playlist.png"; - break; + return "menu_playlist.png"; case XMB_TEXTURE_QUICKMENU: - icon_name = "menu_quickmenu.png"; - break; + return "menu_quickmenu.png"; case XMB_TEXTURE_REWIND: - icon_name = "menu_rewind.png"; - break; + return "menu_rewind.png"; case XMB_TEXTURE_OVERLAY: - icon_name = "menu_overlay.png"; - break; + return "menu_overlay.png"; case XMB_TEXTURE_OVERRIDE: - icon_name = "menu_override.png"; - break; + return "menu_override.png"; case XMB_TEXTURE_NOTIFICATIONS: - icon_name = "menu_notifications.png"; - break; + return "menu_notifications.png"; case XMB_TEXTURE_STREAM: - icon_name = "menu_stream.png"; - break; + return "menu_stream.png"; case XMB_TEXTURE_SHUTDOWN: - icon_name = "menu_shutdown.png"; - break; + return "menu_shutdown.png"; case XMB_TEXTURE_INPUT_DPAD_U: - icon_name = "input_DPAD-U.png"; - break; + return "input_DPAD-U.png"; case XMB_TEXTURE_INPUT_DPAD_D: - icon_name = "input_DPAD-D.png"; - break; + return "input_DPAD-D.png"; case XMB_TEXTURE_INPUT_DPAD_L: - icon_name = "input_DPAD-L.png"; - break; + return "input_DPAD-L.png"; case XMB_TEXTURE_INPUT_DPAD_R: - icon_name = "input_DPAD-R.png"; - break; + return "input_DPAD-R.png"; case XMB_TEXTURE_INPUT_STCK_U: - icon_name = "input_STCK-U.png"; - break; + return "input_STCK-U.png"; case XMB_TEXTURE_INPUT_STCK_D: - icon_name = "input_STCK-D.png"; - break; + return "input_STCK-D.png"; case XMB_TEXTURE_INPUT_STCK_L: - icon_name = "input_STCK-L.png"; - break; + return "input_STCK-L.png"; case XMB_TEXTURE_INPUT_STCK_R: - icon_name = "input_STCK-R.png"; - break; + return "input_STCK-R.png"; case XMB_TEXTURE_INPUT_STCK_P: - icon_name = "input_STCK-P.png"; - break; + return "input_STCK-P.png"; case XMB_TEXTURE_INPUT_BTN_U: - icon_name = "input_BTN-U.png"; - break; + return "input_BTN-U.png"; case XMB_TEXTURE_INPUT_BTN_D: - icon_name = "input_BTN-D.png"; - break; + return "input_BTN-D.png"; case XMB_TEXTURE_INPUT_BTN_L: - icon_name = "input_BTN-L.png"; - break; + return "input_BTN-L.png"; case XMB_TEXTURE_INPUT_BTN_R: - icon_name = "input_BTN-R.png"; - break; + return "input_BTN-R.png"; case XMB_TEXTURE_INPUT_LB: - icon_name = "input_LB.png"; - break; + return "input_LB.png"; case XMB_TEXTURE_INPUT_RB: - icon_name = "input_RB.png"; - break; + return "input_RB.png"; case XMB_TEXTURE_INPUT_LT: - icon_name = "input_LT.png"; - break; + return "input_LT.png"; case XMB_TEXTURE_INPUT_RT: - icon_name = "input_RT.png"; - break; + return "input_RT.png"; case XMB_TEXTURE_INPUT_SELECT: - icon_name = "input_SELECT.png"; - break; + return "input_SELECT.png"; case XMB_TEXTURE_INPUT_START: - icon_name = "input_START.png"; - break; + return "input_START.png"; case XMB_TEXTURE_CHECKMARK: - icon_name = "menu_check.png"; - break; + return "menu_check.png"; case XMB_TEXTURE_MENU_ADD: - icon_name = "menu_add.png"; - break; + return "menu_add.png"; case XMB_TEXTURE_BRIGHTNESS: - icon_name = "menu_brightness.png"; - break; + return "menu_brightness.png"; case XMB_TEXTURE_PAUSE: - icon_name = "menu_pause.png"; - break; + return "menu_pause.png"; + case XMB_TEXTURE_DEFAULT: + return "default.png"; + case XMB_TEXTURE_DEFAULT_CONTENT: + return "default-content.png"; } - - fill_pathname_application_special(iconpath, - PATH_MAX_LENGTH * sizeof(char), - APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); - - icon_fullpath = iconpath; - strlcat(icon_fullpath, icon_name, PATH_MAX_LENGTH * sizeof(char)); - - if (!filestream_exists(icon_fullpath)) - { - RARCH_WARN("[XMB] Asset missing: %s\n", icon_fullpath); - free(icon_fullpath); - return NULL; - } - - free(icon_fullpath); - return icon_name; + return NULL; } static void xmb_context_reset_textures( @@ -4976,25 +4860,42 @@ static void xmb_context_reset_textures( { unsigned i; settings_t *settings = config_get_ptr(); + xmb->assets_missing = false; for (i = 0; i < XMB_TEXTURE_LAST; i++) { - if (xmb_texture_path(i) == NULL) + if (!menu_display_reset_textures_list(xmb_texture_path(i), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR)) { - /* If the icon doesn't exist at least try to return the subsetting icon*/ - if (!(i == XMB_TEXTURE_DIALOG_SLICE || i == XMB_TEXTURE_KEY_HOVER || i == XMB_TEXTURE_KEY_HOVER)) - menu_display_reset_textures_list(xmb_texture_path(XMB_TEXTURE_SUBSETTING), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); - continue; + RARCH_WARN("[XMB] Asset missing: %s%s\n", iconpath, xmb_texture_path(i)); + /* If the icon is missing return the subsetting (because some themes are incomplete) */ + if (!(i == XMB_TEXTURE_DIALOG_SLICE || i == XMB_TEXTURE_KEY_HOVER || i == XMB_TEXTURE_KEY)) + { + /* OSD Warning only if subsetting icon is missing */ + if ( + !menu_display_reset_textures_list(xmb_texture_path(XMB_TEXTURE_SUBSETTING), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR) + && !(settings->uints.menu_xmb_theme == XMB_ICON_THEME_CUSTOM) + ) + { + runloop_msg_queue_push(msg_hash_to_str(MSG_MISSING_ASSETS), 1, 256, false); + /* Do not draw icons if subsetting is missing */ + goto error; + } + /* Do not draw icons if this ones are is missing */ + switch (i) + { + case XMB_TEXTURE_POINTER: + case XMB_TEXTURE_ARROW: + case XMB_TEXTURE_CLOCK: + case XMB_TEXTURE_BATTERY_CHARGING: + case XMB_TEXTURE_BATTERY_FULL: + case XMB_TEXTURE_DEFAULT: + case XMB_TEXTURE_DEFAULT_CONTENT: + goto error; + } + } } - menu_display_reset_textures_list(xmb_texture_path(i), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); } - /* Warn only if critical assets are missing, some themes are incomplete */ - if ( - ((xmb_texture_path(XMB_TEXTURE_SUBSETTING) == NULL)) && !(settings->uints.menu_xmb_theme == XMB_ICON_THEME_CUSTOM) - ) - runloop_msg_queue_push(msg_hash_to_str(MSG_MISSING_ASSETS), 1, 256, false); - menu_display_allocate_white_texture(); xmb->main_menu_node.icon = xmb->textures.list[XMB_TEXTURE_MAIN_MENU]; @@ -5039,6 +4940,12 @@ static void xmb_context_reset_textures( xmb->netplay_tab_node.zoom = xmb->categories_active_zoom; #endif +return; + +error: + xmb->assets_missing = true ; + RARCH_WARN("[XMB] Critical asset missing, no icons will be drawn\n"); + return; } static void xmb_context_reset_background(const char *iconpath) From 982b39a8bf6c9c9de5c15ac04dc7953967e52cc6 Mon Sep 17 00:00:00 2001 From: alfrix Date: Thu, 29 Nov 2018 14:49:27 -0300 Subject: [PATCH 107/153] Simplify and cleanup path handling, log the specific assets missing --- menu/drivers/ozone/ozone.c | 43 ++-- menu/drivers/ozone/ozone_texture.c | 338 ++++++++++------------------- menu/drivers/ozone/ozone_texture.h | 2 +- 3 files changed, 136 insertions(+), 247 deletions(-) diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 210799e229..5f8c65af9f 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -109,7 +109,7 @@ void ozone_free_list_nodes(file_list_t *list, bool actiondata) } } -static void *ozone_init(void **userdata, bool video_is_threaded) +static void *ozone_init(void **userdata, bool video_is_threaded) { bool fallback_color_theme = false; unsigned width, height, color_theme = 0; @@ -184,7 +184,7 @@ static void *ozone_init(void **userdata, bool video_is_threaded) if (settings->bools.menu_use_preferred_system_color_theme) { #ifdef HAVE_LIBNX - if (R_SUCCEEDED(setsysInitialize())) + if (R_SUCCEEDED(setsysInitialize())) { ColorSetId theme; setsysGetColorSetId(&theme); @@ -206,7 +206,7 @@ static void *ozone_init(void **userdata, bool video_is_threaded) color_theme = settings->uints.menu_ozone_color_theme; ozone_set_color_theme(ozone, color_theme); } - + ozone->need_compute = false; ozone->animations.scroll_y = 0.0f; ozone->animations.scroll_y_sidebar = 0.0f; @@ -352,7 +352,10 @@ static void ozone_context_reset(void *data, bool is_threaded) strlcat(filename, ".png", sizeof(filename)); if (!menu_display_reset_textures_list(filename, ozone->png_path, &ozone->textures[i], TEXTURE_FILTER_MIPMAP_LINEAR)) + { ozone->has_all_assets = false; + RARCH_WARN("[OZONE] Asset missing: %s%s%s\n", ozone->png_path, path_default_slash(), filename); + } } /* Sidebar textures */ @@ -363,7 +366,10 @@ static void ozone_context_reset(void *data, bool is_threaded) strlcat(filename, ".png", sizeof(filename)); if (!menu_display_reset_textures_list(filename, ozone->tab_path, &ozone->tab_textures[i], TEXTURE_FILTER_MIPMAP_LINEAR)) + { ozone->has_all_assets = false; + RARCH_WARN("[OZONE] Asset missing: %s%s%s\n", ozone->tab_path, path_default_slash(), filename); + } } /* Theme textures */ @@ -372,8 +378,11 @@ static void ozone_context_reset(void *data, bool is_threaded) /* Icons textures init */ for (i = 0; i < OZONE_ENTRIES_ICONS_TEXTURE_LAST; i++) - if (!menu_display_reset_textures_list(ozone_entries_icon_texture_path(ozone, i), ozone->icons_path, &ozone->icons_textures[i], TEXTURE_FILTER_MIPMAP_LINEAR)) + if (!menu_display_reset_textures_list(ozone_entries_icon_texture_path(i), ozone->icons_path, &ozone->icons_textures[i], TEXTURE_FILTER_MIPMAP_LINEAR)) + { ozone->has_all_assets = false; + RARCH_WARN("[OZONE] Asset missing: %s%s%s\n", ozone->icons_path, path_default_slash(), ozone_entries_icon_texture_path(i)); + } menu_display_allocate_white_texture(); @@ -428,7 +437,7 @@ static void ozone_context_destroy(void *data) /* Textures */ for (i = 0; i < OZONE_TEXTURE_LAST; i++) video_driver_texture_unload(&ozone->textures[i]); - + /* Icons */ for (i = 0; i < OZONE_TAB_TEXTURE_LAST; i++) video_driver_texture_unload(&ozone->tab_textures[i]); @@ -779,7 +788,7 @@ static void ozone_update_scroll(ozone_handle_t *ozone, bool allow_animation, ozo if (new_scroll > 0) new_scroll = 0; - + if (allow_animation) { /* Cursor animation */ @@ -845,7 +854,7 @@ static void ozone_compute_entries_position(ozone_handle_t *ozone) /* Entry */ menu_entry_t entry; ozone_node_t *node = NULL; - + menu_entry_init(&entry); menu_entry_get(&entry, 0, (unsigned)i, NULL, true); @@ -908,7 +917,7 @@ static void ozone_render(void *data, bool is_idle) ozone_handle_t *ozone = (ozone_handle_t*)data; if (!data) return; - + if (ozone->need_compute) { ozone_compute_entries_position(ozone); @@ -1063,12 +1072,12 @@ static void ozone_draw_footer(ozone_handle_t *ozone, video_frame_info_t *video_i menu_display_blend_end(video_info); ozone_draw_text(video_info, ozone, - do_swap ? + do_swap ? msg_hash_to_str(MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_OK) : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_BACK), video_info->width - back_width, video_info->height - back_height + FONT_SIZE_FOOTER, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.footer, ozone->theme->text_rgba, false); ozone_draw_text(video_info, ozone, - do_swap ? + do_swap ? msg_hash_to_str(MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_BACK) : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_OK), video_info->width - ok_width, video_info->height - ok_height + FONT_SIZE_FOOTER, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.footer, ozone->theme->text_rgba, false); @@ -1197,9 +1206,9 @@ static void ozone_frame(void *data, video_frame_info_t *video_info) ozone->raster_blocks.sidebar.carr.coords.vertices = 0; /* Background */ - menu_display_draw_quad(video_info, - 0, 0, video_info->width, video_info->height, - video_info->width, video_info->height, + menu_display_draw_quad(video_info, + 0, 0, video_info->width, video_info->height, + video_info->width, video_info->height, !video_info->libretro_running ? ozone->theme->background : ozone->theme->background_libretro_running ); @@ -1223,7 +1232,7 @@ static void ozone_frame(void *data, video_frame_info_t *video_info) ozone->animations.scroll_y, ozone->is_playlist ); - + /* Old list */ if (ozone->draw_old_list) ozone_draw_entries(ozone, @@ -1433,7 +1442,7 @@ static int ozone_menu_iterate(menu_handle_t *menu, void *userdata, enum menu_act if (!ozone) return generic_menu_iterate(menu, userdata, action); - + selection_buf = menu_entries_get_selection_buf_ptr(0); tag = (uintptr_t)selection_buf; new_action = action; @@ -1463,7 +1472,7 @@ static int ozone_menu_iterate(menu_handle_t *menu, void *userdata, enum menu_act tag = (uintptr_t)ozone; new_selection = ozone->categories_selection_ptr - 1; - + if (new_selection < 0) new_selection = horizontal_list_size + ozone->system_tab_end; @@ -1703,7 +1712,7 @@ static void ozone_list_cache(void *data, bottom_boundary = video_info_height - 87 - 78; for (i = 0; i < entries_end; i++) - { + { ozone_node_t *node = (ozone_node_t*) file_list_get_userdata_at_offset(selection_buf, i); if (!node) diff --git a/menu/drivers/ozone/ozone_texture.c b/menu/drivers/ozone/ozone_texture.c index 7af3843ee1..8249bd6d0d 100644 --- a/menu/drivers/ozone/ozone_texture.c +++ b/menu/drivers/ozone/ozone_texture.c @@ -307,6 +307,7 @@ menu_texture_item ozone_entries_icon_get_texture(ozone_handle_t *ozone, return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_CURSOR]; case FILE_TYPE_PLAYLIST_ENTRY: case MENU_SETTING_ACTION_RUN: + return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_RUN]; case MENU_SETTING_ACTION_RESUME_ACHIEVEMENTS: return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_RESUME]; case MENU_SETTING_ACTION_CLOSE: @@ -448,351 +449,230 @@ menu_texture_item ozone_entries_icon_get_texture(ozone_handle_t *ozone, return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_SUBSETTING]; } -const char *ozone_entries_icon_texture_path(ozone_handle_t *ozone, unsigned id) +const char *ozone_entries_icon_texture_path(unsigned id) { - char icon_fullpath[255]; - char *icon_name = NULL; - switch (id) { case OZONE_ENTRIES_ICONS_TEXTURE_MAIN_MENU: #if defined(HAVE_LAKKA) - icon_name = "lakka.png"; - break; + return "lakka.png"; #else - icon_name = "retroarch.png"; - break; + return "retroarch.png"; #endif case OZONE_ENTRIES_ICONS_TEXTURE_SETTINGS: - icon_name = "settings.png"; - break; + return "settings.png"; case OZONE_ENTRIES_ICONS_TEXTURE_HISTORY: - icon_name = "history.png"; - break; + return "history.png"; case OZONE_ENTRIES_ICONS_TEXTURE_FAVORITES: - icon_name = "favorites.png"; - break; + return "favorites.png"; case OZONE_ENTRIES_ICONS_TEXTURE_ADD_FAVORITE: - icon_name = "add-favorite.png"; - break; + return "add-favorite.png"; case OZONE_ENTRIES_ICONS_TEXTURE_MUSICS: - icon_name = "musics.png"; - break; + return "musics.png"; #if defined(HAVE_FFMPEG) || defined(HAVE_MPV) case OZONE_ENTRIES_ICONS_TEXTURE_MOVIES: - icon_name = "movies.png"; - break; + return "movies.png"; #endif #ifdef HAVE_IMAGEVIEWER case OZONE_ENTRIES_ICONS_TEXTURE_IMAGES: - icon_name = "images.png"; - break; + return "images.png"; #endif case OZONE_ENTRIES_ICONS_TEXTURE_SETTING: - icon_name = "setting.png"; - break; + return "setting.png"; case OZONE_ENTRIES_ICONS_TEXTURE_SUBSETTING: - icon_name = "subsetting.png"; - break; + return "subsetting.png"; case OZONE_ENTRIES_ICONS_TEXTURE_ARROW: - icon_name = "arrow.png"; - break; + return "arrow.png"; case OZONE_ENTRIES_ICONS_TEXTURE_RUN: - icon_name = "run.png"; - break; + return "run.png"; case OZONE_ENTRIES_ICONS_TEXTURE_CLOSE: - icon_name = "close.png"; - break; + return "close.png"; case OZONE_ENTRIES_ICONS_TEXTURE_RESUME: - icon_name = "resume.png"; - break; + return "resume.png"; case OZONE_ENTRIES_ICONS_TEXTURE_CLOCK: - icon_name = "clock.png"; - break; + return "clock.png"; case OZONE_ENTRIES_ICONS_TEXTURE_BATTERY_FULL: - icon_name = "battery-full.png"; - break; + return "battery-full.png"; case OZONE_ENTRIES_ICONS_TEXTURE_BATTERY_CHARGING: - icon_name = "battery-charging.png"; - break; + return "battery-charging.png"; case OZONE_ENTRIES_ICONS_TEXTURE_POINTER: - icon_name = "pointer.png"; - break; + return "pointer.png"; case OZONE_ENTRIES_ICONS_TEXTURE_SAVESTATE: - icon_name = "savestate.png"; - break; + return "savestate.png"; case OZONE_ENTRIES_ICONS_TEXTURE_LOADSTATE: - icon_name = "loadstate.png"; - break; + return "loadstate.png"; case OZONE_ENTRIES_ICONS_TEXTURE_UNDO: - icon_name = "undo.png"; - break; + return "undo.png"; case OZONE_ENTRIES_ICONS_TEXTURE_CORE_INFO: - icon_name = "core-infos.png"; - break; + return "core-infos.png"; case OZONE_ENTRIES_ICONS_TEXTURE_WIFI: - icon_name = "wifi.png"; - break; + return "wifi.png"; case OZONE_ENTRIES_ICONS_TEXTURE_CORE_OPTIONS: - icon_name = "core-options.png"; - break; + return "core-options.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_REMAPPING_OPTIONS: - icon_name = "core-input-remapping-options.png"; - break; + return "core-input-remapping-options.png"; case OZONE_ENTRIES_ICONS_TEXTURE_CHEAT_OPTIONS: - icon_name = "core-cheat-options.png"; - break; + return "core-cheat-options.png"; case OZONE_ENTRIES_ICONS_TEXTURE_DISK_OPTIONS: - icon_name = "core-disk-options.png"; - break; + return "core-disk-options.png"; case OZONE_ENTRIES_ICONS_TEXTURE_SHADER_OPTIONS: - icon_name = "core-shader-options.png"; - break; + return "core-shader-options.png"; case OZONE_ENTRIES_ICONS_TEXTURE_ACHIEVEMENT_LIST: - icon_name = "achievement-list.png"; - break; + return "achievement-list.png"; case OZONE_ENTRIES_ICONS_TEXTURE_SCREENSHOT: - icon_name = "screenshot.png"; - break; + return "screenshot.png"; case OZONE_ENTRIES_ICONS_TEXTURE_RELOAD: - icon_name = "reload.png"; - break; + return "reload.png"; case OZONE_ENTRIES_ICONS_TEXTURE_RENAME: - icon_name = "rename.png"; - break; + return "rename.png"; case OZONE_ENTRIES_ICONS_TEXTURE_FILE: - icon_name = "file.png"; - break; + return "file.png"; case OZONE_ENTRIES_ICONS_TEXTURE_FOLDER: - icon_name = "folder.png"; - break; + return "folder.png"; case OZONE_ENTRIES_ICONS_TEXTURE_ZIP: - icon_name = "zip.png"; - break; + return "zip.png"; case OZONE_ENTRIES_ICONS_TEXTURE_MUSIC: - icon_name = "music.png"; - break; + return "music.png"; case OZONE_ENTRIES_ICONS_TEXTURE_FAVORITE: - icon_name = "favorites-content.png"; - break; + return "favorites-content.png"; case OZONE_ENTRIES_ICONS_TEXTURE_IMAGE: - icon_name = "image.png"; - break; + return "image.png"; case OZONE_ENTRIES_ICONS_TEXTURE_MOVIE: - icon_name = "movie.png"; - break; + return "movie.png"; case OZONE_ENTRIES_ICONS_TEXTURE_CORE: - icon_name = "core.png"; - break; + return "core.png"; case OZONE_ENTRIES_ICONS_TEXTURE_RDB: - icon_name = "database.png"; - break; + return "database.png"; case OZONE_ENTRIES_ICONS_TEXTURE_CURSOR: - icon_name = "cursor.png"; - break; + return "cursor.png"; case OZONE_ENTRIES_ICONS_TEXTURE_SWITCH_ON: - icon_name = "on.png"; - break; + return "on.png"; case OZONE_ENTRIES_ICONS_TEXTURE_SWITCH_OFF: - icon_name = "off.png"; - break; + return "off.png"; case OZONE_ENTRIES_ICONS_TEXTURE_ADD: - icon_name = "add.png"; - break; + return "add.png"; #ifdef HAVE_NETWORKING case OZONE_ENTRIES_ICONS_TEXTURE_NETPLAY: - icon_name = "netplay.png"; - break; + return "netplay.png"; case OZONE_ENTRIES_ICONS_TEXTURE_ROOM: - icon_name = "menu_room.png"; - break; + return "menu_room.png"; case OZONE_ENTRIES_ICONS_TEXTURE_ROOM_LAN: - icon_name = "menu_room_lan.png"; - break; + return "menu_room_lan.png"; case OZONE_ENTRIES_ICONS_TEXTURE_ROOM_RELAY: - icon_name = "menu_room_relay.png"; - break; + return "menu_room_relay.png"; #endif case OZONE_ENTRIES_ICONS_TEXTURE_KEY: - icon_name = "key.png"; - break; + return "key.png"; case OZONE_ENTRIES_ICONS_TEXTURE_KEY_HOVER: - icon_name = "key-hover.png"; - break; + return "key-hover.png"; case OZONE_ENTRIES_ICONS_TEXTURE_DIALOG_SLICE: - icon_name = "dialog-slice.png"; - break; + return "dialog-slice.png"; case OZONE_ENTRIES_ICONS_TEXTURE_ACHIEVEMENTS: - icon_name = "menu_achievements.png"; - break; + return "menu_achievements.png"; case OZONE_ENTRIES_ICONS_TEXTURE_AUDIO: - icon_name = "menu_audio.png"; - break; + return "menu_audio.png"; case OZONE_ENTRIES_ICONS_TEXTURE_DRIVERS: - icon_name = "menu_drivers.png"; - break; + return "menu_drivers.png"; case OZONE_ENTRIES_ICONS_TEXTURE_EXIT: - icon_name = "menu_exit.png"; - break; + return "menu_exit.png"; case OZONE_ENTRIES_ICONS_TEXTURE_FRAMESKIP: - icon_name = "menu_frameskip.png"; - break; + return "menu_frameskip.png"; case OZONE_ENTRIES_ICONS_TEXTURE_HELP: - icon_name = "menu_help.png"; - break; + return "menu_help.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INFO: - icon_name = "menu_info.png"; - break; + return "menu_info.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_SETTINGS: - icon_name = "Libretro - Pad.png"; - break; + return "Libretro - Pad.png"; case OZONE_ENTRIES_ICONS_TEXTURE_LATENCY: - icon_name = "menu_latency.png"; - break; + return "menu_latency.png"; case OZONE_ENTRIES_ICONS_TEXTURE_NETWORK: - icon_name = "menu_network.png"; - break; + return "menu_network.png"; case OZONE_ENTRIES_ICONS_TEXTURE_POWER: - icon_name = "menu_power.png"; - break; + return "menu_power.png"; case OZONE_ENTRIES_ICONS_TEXTURE_RECORD: - icon_name = "menu_record.png"; - break; + return "menu_record.png"; case OZONE_ENTRIES_ICONS_TEXTURE_SAVING: - icon_name = "menu_saving.png"; - break; + return "menu_saving.png"; case OZONE_ENTRIES_ICONS_TEXTURE_UPDATER: - icon_name = "menu_updater.png"; - break; + return "menu_updater.png"; case OZONE_ENTRIES_ICONS_TEXTURE_VIDEO: - icon_name = "menu_video.png"; - break; + return "menu_video.png"; case OZONE_ENTRIES_ICONS_TEXTURE_MIXER: - icon_name = "menu_mixer.png"; - break; + return "menu_mixer.png"; case OZONE_ENTRIES_ICONS_TEXTURE_LOG: - icon_name = "menu_log.png"; - break; + return "menu_log.png"; case OZONE_ENTRIES_ICONS_TEXTURE_OSD: - icon_name = "menu_osd.png"; - break; + return "menu_osd.png"; case OZONE_ENTRIES_ICONS_TEXTURE_UI: - icon_name = "menu_ui.png"; - break; + return "menu_ui.png"; case OZONE_ENTRIES_ICONS_TEXTURE_USER: - icon_name = "menu_user.png"; - break; + return "menu_user.png"; case OZONE_ENTRIES_ICONS_TEXTURE_PRIVACY: - icon_name = "menu_privacy.png"; - break; + return "menu_privacy.png"; case OZONE_ENTRIES_ICONS_TEXTURE_PLAYLIST: - icon_name = "menu_playlist.png"; - break; + return "menu_playlist.png"; case OZONE_ENTRIES_ICONS_TEXTURE_QUICKMENU: - icon_name = "menu_quickmenu.png"; - break; + return "menu_quickmenu.png"; case OZONE_ENTRIES_ICONS_TEXTURE_REWIND: - icon_name = "menu_rewind.png"; - break; + return "menu_rewind.png"; case OZONE_ENTRIES_ICONS_TEXTURE_OVERLAY: - icon_name = "menu_overlay.png"; - break; + return "menu_overlay.png"; case OZONE_ENTRIES_ICONS_TEXTURE_OVERRIDE: - icon_name = "menu_override.png"; - break; + return "menu_override.png"; case OZONE_ENTRIES_ICONS_TEXTURE_NOTIFICATIONS: - icon_name = "menu_notifications.png"; - break; + return "menu_notifications.png"; case OZONE_ENTRIES_ICONS_TEXTURE_STREAM: - icon_name = "menu_stream.png"; - break; + return "menu_stream.png"; case OZONE_ENTRIES_ICONS_TEXTURE_SHUTDOWN: - icon_name = "menu_shutdown.png"; - break; + return "menu_shutdown.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_DPAD_U: - icon_name = "input_DPAD-U.png"; - break; + return "input_DPAD-U.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_DPAD_D: - icon_name = "input_DPAD-D.png"; - break; + return "input_DPAD-D.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_DPAD_L: - icon_name = "input_DPAD-L.png"; - break; + return "input_DPAD-L.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_DPAD_R: - icon_name = "input_DPAD-R.png"; - break; + return "input_DPAD-R.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_STCK_U: - icon_name = "input_STCK-U.png"; - break; + return "input_STCK-U.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_STCK_D: - icon_name = "input_STCK-D.png"; - break; + return "input_STCK-D.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_STCK_L: - icon_name = "input_STCK-L.png"; - break; + return "input_STCK-L.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_STCK_R: - icon_name = "input_STCK-R.png"; - break; + return "input_STCK-R.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_STCK_P: - icon_name = "input_STCK-P.png"; - break; + return "input_STCK-P.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_U: - icon_name = "input_BTN-U.png"; - break; + return "input_BTN-U.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_D: - icon_name = "input_BTN-D.png"; - break; + return "input_BTN-D.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_L: - icon_name = "input_BTN-L.png"; - break; + return "input_BTN-L.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_R: - icon_name = "input_BTN-R.png"; - break; + return "input_BTN-R.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_LB: - icon_name = "input_LB.png"; - break; + return "input_LB.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_RB: - icon_name = "input_RB.png"; - break; + return "input_RB.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_LT: - icon_name = "input_LT.png"; - break; + return "input_LT.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_RT: - icon_name = "input_RT.png"; - break; + return "input_RT.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_SELECT: - icon_name = "input_SELECT.png"; - break; + return "input_SELECT.png"; case OZONE_ENTRIES_ICONS_TEXTURE_INPUT_START: - icon_name = "input_START.png"; - break; + return "input_START.png"; case OZONE_ENTRIES_ICONS_TEXTURE_CHECKMARK: - icon_name = "menu_check.png"; - break; + return "menu_check.png"; case OZONE_ENTRIES_ICONS_TEXTURE_MENU_ADD: - icon_name = "menu_add.png"; - break; + return "menu_add.png"; case OZONE_ENTRIES_ICONS_TEXTURE_BRIGHTNESS: - icon_name = "menu_brightnes.png"; - break; + return "menu_brightness.png"; case OZONE_ENTRIES_ICONS_TEXTURE_PAUSE: - icon_name = "menu_pause.png"; - break; + return "menu_pause.png"; } - - fill_pathname_join( - icon_fullpath, - ozone->icons_path, - icon_name, - sizeof(icon_fullpath) - ); - - if (!filestream_exists(icon_fullpath)) - { - return "subsetting.png"; - } - else - return icon_name; + return NULL; } void ozone_unload_theme_textures(ozone_handle_t *ozone) @@ -838,4 +718,4 @@ bool ozone_reset_theme_textures(ozone_handle_t *ozone) } return result; -} \ No newline at end of file +} diff --git a/menu/drivers/ozone/ozone_texture.h b/menu/drivers/ozone/ozone_texture.h index e06bea008f..374a798c65 100644 --- a/menu/drivers/ozone/ozone_texture.h +++ b/menu/drivers/ozone/ozone_texture.h @@ -199,7 +199,7 @@ enum OZONE_ENTRIES_ICONS_TEXTURE_LAST }; -const char *ozone_entries_icon_texture_path(ozone_handle_t *ozone, unsigned id); +const char *ozone_entries_icon_texture_path(unsigned id); menu_texture_item ozone_entries_icon_get_texture(ozone_handle_t *ozone, enum msg_hash_enums enum_idx, unsigned type, bool active); From 3934cec5973f1929260162c06c1bb1fcc495daf7 Mon Sep 17 00:00:00 2001 From: Tatsuya79 Date: Thu, 29 Nov 2018 22:40:23 +0100 Subject: [PATCH 108/153] Default framecount_show to off. --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 6bf045ab21..385550499a 100644 --- a/config.def.h +++ b/config.def.h @@ -550,7 +550,7 @@ static const int wasapi_sh_buffer_length = -16; /* auto */ static const bool fps_show = false; /* Enables displaying the current frame count. */ -static const bool framecount_show = true; +static const bool framecount_show = false; /* Includes displaying the current memory usage/total with FPS/Frames. */ static const bool memory_show = false; From c0cada4b55bf550311c85653ca2a2637f19b7f48 Mon Sep 17 00:00:00 2001 From: Tatsuya79 Date: Fri, 30 Nov 2018 00:30:12 +0100 Subject: [PATCH 109/153] Fix title window fps counter. --- gfx/video_driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index de50911b15..88ef1862ef 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2454,7 +2454,7 @@ void video_driver_frame(const void *data, unsigned width, if (video_info.fps_show) { snprintf(video_info.fps_text, sizeof(video_info.fps_text), - "|| FPS: %6.1f ", last_fps); + " || FPS: %6.1f ", last_fps); } if (video_info.framecount_show) { @@ -2464,7 +2464,7 @@ void video_driver_frame(const void *data, unsigned width, (uint64_t)video_driver_frame_count); } snprintf(video_driver_window_title, sizeof(video_driver_window_title), - "%s%s%s%s", title, video_info.fps_text, + "%s%s%s", title, video_info.fps_show ? video_info.fps_text : "", video_info.framecount_show ? frames_text : ""); } From 0e295716b9908c8a9ac1e89e30b735e008e6f55c Mon Sep 17 00:00:00 2001 From: Stuart Carnie Date: Thu, 29 Nov 2018 22:04:43 -0700 Subject: [PATCH 110/153] feat(metal): Add native rotation support for Metal driver * fix crash when frame or frame size is 0 --- gfx/common/metal/Context.h | 1 + gfx/common/metal/Context.m | 34 +++++++++++++- gfx/common/metal/RendererCommon.h | 1 + gfx/common/metal/RendererCommon.m | 14 ++++++ gfx/common/metal_common.h | 2 + gfx/common/metal_common.m | 44 +++++++++++-------- gfx/drivers/metal.m | 18 +++++--- .../RetroArch_Metal.xcodeproj/project.pbxproj | 32 +++++++++++++- 8 files changed, 118 insertions(+), 28 deletions(-) diff --git a/gfx/common/metal/Context.h b/gfx/common/metal/Context.h index 5068df92a2..2897367664 100644 --- a/gfx/common/metal/Context.h +++ b/gfx/common/metal/Context.h @@ -76,6 +76,7 @@ typedef struct /*! @brief end commits the command buffer */ - (void)end; +- (void)setRotation:(unsigned)rotation; - (bool)readBackBuffer:(uint8_t *)buffer; @end diff --git a/gfx/common/metal/Context.m b/gfx/common/metal/Context.m index 69d1c059f6..34fc099afc 100644 --- a/gfx/common/metal/Context.m +++ b/gfx/common/metal/Context.m @@ -53,10 +53,16 @@ id _states[GFX_MAX_SHADERS][2]; id _clearState; - Uniforms _uniforms; bool _captureEnabled; id _backBuffer; + + unsigned _rotation; + matrix_float4x4 _mvp_no_rot; + matrix_float4x4 _mvp; + + Uniforms _uniforms; + Uniforms _uniformsNoRotate; } - (instancetype)initWithDevice:(id)d @@ -75,6 +81,11 @@ _commandQueue = [_device newCommandQueue]; _clearColor = MTLClearColorMake(0, 0, 0, 1); _uniforms.projectionMatrix = matrix_proj_ortho(0, 1, 0, 1); + + _rotation = 0; + [self setRotation:0]; + _mvp_no_rot = matrix_proj_ortho(0, 1, 0, 1); + _mvp = matrix_proj_ortho(0, 1, 0, 1); { MTLSamplerDescriptor *sd = [MTLSamplerDescriptor new]; @@ -130,6 +141,27 @@ return &_uniforms; } +- (void)setRotation:(unsigned)rotation +{ + _rotation = 270 * rotation; + + /* Calculate projection. */ + _mvp_no_rot = matrix_proj_ortho(0, 1, 0, 1); + + bool allow_rotate = true; + if (!allow_rotate) + { + _mvp = _mvp_no_rot; + return; + } + + matrix_float4x4 rot = matrix_rotate_z((float)(M_PI * _rotation / 180.0f)); + _mvp = simd_mul(rot, _mvp_no_rot); + + _uniforms.projectionMatrix = _mvp; + _uniformsNoRotate.projectionMatrix = _mvp_no_rot; +} + - (void)setDisplaySyncEnabled:(bool)displaySyncEnabled { #if TARGET_OS_OSX diff --git a/gfx/common/metal/RendererCommon.h b/gfx/common/metal/RendererCommon.h index 977cf7b607..f0835f271e 100644 --- a/gfx/common/metal/RendererCommon.h +++ b/gfx/common/metal/RendererCommon.h @@ -55,6 +55,7 @@ typedef NS_ENUM(NSUInteger, RTextureFilter) }; extern matrix_float4x4 matrix_proj_ortho(float left, float right, float top, float bottom); +extern matrix_float4x4 matrix_rotate_z(float rot); extern matrix_float4x4 make_matrix_float4x4(const float *v); #endif /* RendererCommon_h */ diff --git a/gfx/common/metal/RendererCommon.m b/gfx/common/metal/RendererCommon.m index c3be58dc86..95ff5c889c 100644 --- a/gfx/common/metal/RendererCommon.m +++ b/gfx/common/metal/RendererCommon.m @@ -86,3 +86,17 @@ matrix_float4x4 matrix_proj_ortho(float left, float right, float top, float bott matrix_float4x4 mat = {P, Q, R, S}; return mat; } + +matrix_float4x4 matrix_rotate_z(float rot) +{ + float cz, sz; + __sincosf(rot, &sz, &cz); + + simd_float4 P = simd_make_float4(cz, -sz, 0, 0); + simd_float4 Q = simd_make_float4(sz, cz, 0, 0); + simd_float4 R = simd_make_float4( 0, 0, 1, 0); + simd_float4 S = simd_make_float4( 0, 0, 0, 1); + + matrix_float4x4 mat = {P, Q, R, S}; + return mat; +} diff --git a/gfx/common/metal_common.h b/gfx/common/metal_common.h index 66b7f08b92..4fbefa25ac 100644 --- a/gfx/common/metal_common.h +++ b/gfx/common/metal_common.h @@ -96,6 +96,8 @@ extern MTLPixelFormat SelectOptimalPixelFormat(MTLPixelFormat fmt); /*! @brief setNeedsResize triggers a display resize */ - (void)setNeedsResize; +- (void)setViewportWidth:(unsigned)width height:(unsigned)height forceFull:(BOOL)forceFull allowRotate:(BOOL)allowRotate; +- (void)setRotation:(unsigned)rotation; @end diff --git a/gfx/common/metal_common.m b/gfx/common/metal_common.m index 2c2129d911..d2afec6184 100644 --- a/gfx/common/metal_common.m +++ b/gfx/common/metal_common.m @@ -216,21 +216,19 @@ return YES; } -- (void)_updateUniforms +- (void)setViewportWidth:(unsigned)width height:(unsigned)height forceFull:(BOOL)forceFull allowRotate:(BOOL)allowRotate { - _uniforms.projectionMatrix = matrix_proj_ortho(0, 1, 0, 1); -} - -- (void)_updateViewport:(CGSize)size -{ - RARCH_LOG("[Metal]: _updateViewport size %.0fx%.0f\n", size.width, size.height); +#if 0 + RARCH_LOG("[Metal]: setViewportWidth size %dx%d\n", width, height); +#endif - _viewport->full_width = (unsigned int)size.width; - _viewport->full_height = (unsigned int)size.height; + _viewport->full_width = width; + _viewport->full_height = height; video_driver_set_size(&_viewport->full_width, &_viewport->full_height); - _layer.drawableSize = size; - video_driver_update_viewport(_viewport, NO, _keepAspect); + _layer.drawableSize = CGSizeMake(width, height); + video_driver_update_viewport(_viewport, forceFull, _keepAspect); + // update matrix _context.viewport = _viewport; _viewportMVP.outputSize = simd_make_float2(_viewport->full_width, _viewport->full_height); @@ -256,8 +254,10 @@ [self _beginFrame]; _frameView.frameCount = frameCount; - _frameView.size = CGSizeMake(width, height); - [_frameView updateFrame:data pitch:pitch]; + if (data && width && height) { + _frameView.size = CGSizeMake(width, height); + [_frameView updateFrame:data pitch:pitch]; + } [self _drawViews:video_info]; @@ -277,7 +277,7 @@ id rce = _context.rce; [rce pushDebugGroup:@"overlay"]; [rce setRenderPipelineState:[_context getStockShader:VIDEO_SHADER_STOCK_BLEND blend:YES]]; - [rce setVertexBytes:&_uniforms length:sizeof(_uniforms) atIndex:BufferIndexUniforms]; + [rce setVertexBytes:_context.uniforms length:sizeof(*_context.uniforms) atIndex:BufferIndexUniforms]; [rce setFragmentSamplerState:_samplerStateLinear atIndex:SamplerIndexDraw]; [_overlay drawWithEncoder:rce]; [rce popDebugGroup]; @@ -338,7 +338,6 @@ _context.viewport = _viewport; } [_context begin]; - [self _updateUniforms]; } - (void)_drawViews:(video_frame_info_t *)video_info @@ -351,7 +350,7 @@ if ((_frameView.drawState & ViewDrawStateEncoder) != 0) { - [rce setVertexBytes:&_uniforms length:sizeof(_uniforms) atIndex:BufferIndexUniforms]; + [rce setVertexBytes:_context.uniforms length:sizeof(*_context.uniforms) atIndex:BufferIndexUniforms]; [rce setRenderPipelineState:_t_pipelineStateNoAlpha]; if (_frameView.filter == RTextureFilterNearest) { @@ -410,6 +409,11 @@ // TODO(sgc): resize all drawables } +- (void)setRotation:(unsigned)rotation +{ + [_context setRotation:rotation]; +} + - (Uniforms *)viewportMVP { return &_viewportMVP; @@ -419,7 +423,7 @@ - (void)mtkView:(MTKView *)view drawableSizeWillChange:(CGSize)size { - [self _updateViewport:size]; + [self setViewportWidth:(unsigned int)size.width height:(unsigned int)size.height forceFull:NO allowRotate:YES]; } - (void)drawInMTKView:(MTKView *)view @@ -897,7 +901,7 @@ typedef struct MTLALIGN(16) rce = [cb renderCommandEncoderWithDescriptor:rpd]; } -#if METAL_DEBUG +#if DEBUG && METAL_DEBUG rce.label = [NSString stringWithFormat:@"pass %d", i]; #endif @@ -1126,6 +1130,8 @@ typedef struct MTLALIGN(16) texture_t *source = &_engine.frame.texture[0]; for (unsigned i = 0; i < shader->passes; source = &_engine.pass[i++].rt) { + matrix_float4x4 *mvp = (i == shader->passes-1) ? &_context.uniforms->projectionMatrix : &_engine.mvp; + /* clang-format off */ semantics_map_t semantics_map = { { @@ -1154,7 +1160,7 @@ typedef struct MTLALIGN(16) &_engine.luts[0].size_data, sizeof(*_engine.luts)}, }, { - &_engine.mvp, /* MVP */ + mvp, /* MVP */ &_engine.pass[i].rt.size_data, /* OutputSize */ &_engine.frame.output_size, /* FinalViewportSize */ &_engine.pass[i].frame_count, /* FrameCount */ diff --git a/gfx/drivers/metal.m b/gfx/drivers/metal.m index 3496d035bf..29c792c9ab 100644 --- a/gfx/drivers/metal.m +++ b/gfx/drivers/metal.m @@ -151,16 +151,22 @@ static void metal_free(void *data) static void metal_set_viewport(void *data, unsigned viewport_width, unsigned viewport_height, bool force_full, bool allow_rotate) { -#if 0 - RARCH_LOG("[Metal]: set_viewport size: %dx%d full: %s rotate: %s\n", - viewport_width, viewport_height, - force_full ? "YES" : "NO", - allow_rotate ? "YES" : "NO"); -#endif + MetalDriver *md = (__bridge MetalDriver *)data; + if (md == nil) { + return; + } + + [md setViewportWidth:viewport_width height:viewport_height forceFull:force_full allowRotate:allow_rotate]; } static void metal_set_rotation(void *data, unsigned rotation) { + MetalDriver *md = (__bridge MetalDriver *)data; + if (md == nil) { + return; + } + + [md setRotation:rotation]; } static void metal_viewport_info(void *data, struct video_viewport *vp) diff --git a/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj index a97c52c3f8..5ca7fea33a 100644 --- a/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj @@ -88,6 +88,17 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 05132C6621A74D7A00379846 /* ozone_texture.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = ozone_texture.c; sourceTree = ""; }; + 05132C6721A74D7B00379846 /* ozone_theme.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ozone_theme.h; sourceTree = ""; }; + 05132C6821A74D7B00379846 /* ozone.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ozone.h; sourceTree = ""; }; + 05132C6921A74D7B00379846 /* ozone_entries.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = ozone_entries.c; sourceTree = ""; }; + 05132C6A21A74D7B00379846 /* ozone.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = ozone.c; sourceTree = ""; }; + 05132C6B21A74D7B00379846 /* ozone_theme.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = ozone_theme.c; sourceTree = ""; }; + 05132C6C21A74D7B00379846 /* ozone_sidebar.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = ozone_sidebar.c; sourceTree = ""; }; + 05132C6D21A74D7B00379846 /* ozone_sidebar.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ozone_sidebar.h; sourceTree = ""; }; + 05132C6E21A74D7B00379846 /* ozone_display.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = ozone_display.c; sourceTree = ""; }; + 05132C6F21A74D7B00379846 /* ozone_texture.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ozone_texture.h; sourceTree = ""; }; + 05132C7021A74D7B00379846 /* ozone_display.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ozone_display.h; sourceTree = ""; }; 05269A6120ABF20500C29F1E /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; }; 05366512213F8BE5007E7EA0 /* thumbnailpackdownload.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = thumbnailpackdownload.cpp; sourceTree = ""; }; 05366513213F8BE5007E7EA0 /* ui_qt_application.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ui_qt_application.cpp; sourceTree = ""; }; @@ -514,7 +525,6 @@ 05D7753320A5678300646447 /* griffin_cpp.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = griffin_cpp.cpp; path = ../../griffin/griffin_cpp.cpp; sourceTree = ""; }; 05D7753420A5678400646447 /* griffin_glslang.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = griffin_glslang.cpp; path = ../../griffin/griffin_glslang.cpp; sourceTree = ""; }; 05EFAFC22191D64200D27059 /* stripes.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = stripes.c; sourceTree = ""; }; - 05EFAFC32191D64200D27059 /* ozone.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = ozone.c; sourceTree = ""; }; 05F2872F20F2BEEA00632D47 /* task_autodetect.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = task_autodetect.c; sourceTree = ""; }; 05F2873020F2BEEA00632D47 /* task_netplay_find_content.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = task_netplay_find_content.c; sourceTree = ""; }; 05F2873120F2BEEA00632D47 /* task_netplay_nat_traversal.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = task_netplay_nat_traversal.c; sourceTree = ""; }; @@ -610,6 +620,24 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 05132C6521A74D5100379846 /* ozone */ = { + isa = PBXGroup; + children = ( + 05132C6E21A74D7B00379846 /* ozone_display.c */, + 05132C7021A74D7B00379846 /* ozone_display.h */, + 05132C6921A74D7B00379846 /* ozone_entries.c */, + 05132C6C21A74D7B00379846 /* ozone_sidebar.c */, + 05132C6D21A74D7B00379846 /* ozone_sidebar.h */, + 05132C6621A74D7A00379846 /* ozone_texture.c */, + 05132C6F21A74D7B00379846 /* ozone_texture.h */, + 05132C6B21A74D7B00379846 /* ozone_theme.c */, + 05132C6721A74D7B00379846 /* ozone_theme.h */, + 05132C6A21A74D7B00379846 /* ozone.c */, + 05132C6821A74D7B00379846 /* ozone.h */, + ); + path = ozone; + sourceTree = ""; + }; 05366511213F8BE5007E7EA0 /* qt */ = { isa = PBXGroup; children = ( @@ -801,12 +829,12 @@ isa = PBXGroup; children = ( 05A8C53520DB72F000FF7857 /* nuklear */, + 05132C6521A74D5100379846 /* ozone */, 05A8C54020DB72F000FF7857 /* materialui.c */, 05A8C53420DB72F000FF7857 /* menu_generic.c */, 05A8C53320DB72F000FF7857 /* menu_generic.h */, 05A8C53D20DB72F000FF7857 /* nuklear.c */, 05A8C53E20DB72F000FF7857 /* null.c */, - 05EFAFC32191D64200D27059 /* ozone.c */, 05A8C53C20DB72F000FF7857 /* rgui.c */, 05EFAFC22191D64200D27059 /* stripes.c */, 05A8C53220DB72F000FF7857 /* xmb.c */, From 0f5729354e65174635e66baf2ef765dd3fe32423 Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Fri, 30 Nov 2018 21:36:42 +0400 Subject: [PATCH 111/153] Initial support for toplevel resizing --- gfx/drivers_context/wayland_ctx.c | 63 +++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 11 deletions(-) diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 80919d8e1d..f3803a96f7 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -76,6 +76,9 @@ typedef struct gfx_ctx_wayland_data bool maximized; bool resize; bool configured; + bool activated; + int prev_width; + int prev_height; unsigned width; unsigned height; unsigned physical_width; @@ -571,17 +574,55 @@ static const struct xdg_surface_listener xdg_surface_listener = { }; static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, - int width, int height, struct wl_array *states) + int32_t width, int32_t height, struct wl_array *states) { gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; - /* TODO: implement resizing */ - (void)toplevel; - - wl->width = wl->buffer_scale * width; - wl->height = wl->buffer_scale * height; - - wl->configured = false; + printf("Configure event got, width: %d, height: %d\n", width, height); + wl->fullscreen = false; + wl->maximized = false; + enum xdg_toplevel_state *state; + wl_array_for_each(state, states) { + switch (*state) { + case XDG_TOPLEVEL_STATE_FULLSCREEN: + printf("Surface state: XDG_SURFACE_STATE_FULLSCREEN\n"); + wl->fullscreen = true; + break; + case XDG_TOPLEVEL_STATE_MAXIMIZED: + printf("Surface state: XDG_SURFACE_STATE_MAXIMIZED\n"); + wl->maximized = true; + break; + case XDG_TOPLEVEL_STATE_RESIZING: + printf("Surface state: XDG_SURFACE_STATE_RESIZING\n"); + wl->resize = true; + break; + case XDG_TOPLEVEL_STATE_ACTIVATED: + printf("Surface state: XDG_SURFACE_STATE_ACTIVATED\n"); + wl->activated = true; + break; + case XDG_TOPLEVEL_STATE_TILED_TOP: + printf("Surface state: XDG_SURFACE_STATE_TILED_TOP\n"); + case XDG_TOPLEVEL_STATE_TILED_LEFT: + printf("Surface state: XDG_SURFACE_STATE_TILED_LEFT\n"); + case XDG_TOPLEVEL_STATE_TILED_RIGHT: + printf("Surface state: XDG_SURFACE_STATE_TILED_RIGHT\n"); + case XDG_TOPLEVEL_STATE_TILED_BOTTOM: + printf("Surface state: XDG_SURFACE_STATE_TILED_BOTTOM\n"); + break; + } + } + if (width > 0 && height >0) { + wl->prev_width = width; + wl->prev_height = height; + wl->width = width; + wl->height = height; + } + else { + wl->width = wl->prev_width; + wl->height = wl->prev_height; + } + + wl->configured = false; } static void handle_toplevel_close(void *data, struct xdg_toplevel *xdg_toplevel) @@ -1423,9 +1464,9 @@ static bool gfx_ctx_wl_has_focus(void *data) static bool gfx_ctx_wl_suppress_screensaver(void *data, bool state) { - (void)data; - gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; - + (void)data; + gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; + if (!wl->idle_inhibit_manager) return false; if (state == (!!wl->idle_inhibitor)) From cd2d2f88079c74da631ce40e4b0ecee6c2b9af00 Mon Sep 17 00:00:00 2001 From: alfrix Date: Fri, 30 Nov 2018 18:10:28 -0300 Subject: [PATCH 112/153] Add icons for apply on toggle and autoapply --- menu/drivers/ozone/ozone_texture.c | 10 +++++++++- menu/drivers/ozone/ozone_texture.h | 4 +++- menu/drivers/xmb.c | 12 +++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/menu/drivers/ozone/ozone_texture.c b/menu/drivers/ozone/ozone_texture.c index 8e3455593a..b1a34532a8 100644 --- a/menu/drivers/ozone/ozone_texture.c +++ b/menu/drivers/ozone/ozone_texture.c @@ -212,7 +212,7 @@ menu_texture_item ozone_entries_icon_get_texture(ozone_handle_t *ozone, #ifdef HAVE_LAKKA_SWITCH case MENU_ENUM_LABEL_SWITCH_GPU_PROFILE: #endif -#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) case MENU_ENUM_LABEL_SWITCH_CPU_PROFILE: return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_POWER]; #endif @@ -277,6 +277,10 @@ menu_texture_item ozone_entries_icon_get_texture(ozone_handle_t *ozone, case MENU_ENUM_LABEL_CHEAT_ADD_NEW_TOP: case MENU_ENUM_LABEL_CHEAT_ADD_NEW_BOTTOM: return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_MENU_ADD]; + case MENU_ENUM_LABEL_CHEAT_APPLY_AFTER_TOGGLE: + return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_MENU_APPLY_TOGGLE]; + case MENU_ENUM_LABEL_CHEAT_APPLY_AFTER_LOAD: + return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_MENU_APPLY_COG]; default: break; } @@ -674,6 +678,10 @@ switch (id) return "menu_brightness.png"; case OZONE_ENTRIES_ICONS_TEXTURE_PAUSE: return "menu_pause.png"; + case OZONE_ENTRIES_ICONS_TEXTURE_MENU_APPLY_TOGGLE: + return "menu_apply_toggle.png"; + case OZONE_ENTRIES_ICONS_TEXTURE_MENU_APPLY_COG: + return "menu_apply_cog.png"; } return NULL; } diff --git a/menu/drivers/ozone/ozone_texture.h b/menu/drivers/ozone/ozone_texture.h index 374a798c65..5441732378 100644 --- a/menu/drivers/ozone/ozone_texture.h +++ b/menu/drivers/ozone/ozone_texture.h @@ -196,6 +196,8 @@ enum OZONE_ENTRIES_ICONS_TEXTURE_MENU_ADD, OZONE_ENTRIES_ICONS_TEXTURE_BRIGHTNESS, OZONE_ENTRIES_ICONS_TEXTURE_PAUSE, + OZONE_ENTRIES_ICONS_TEXTURE_MENU_APPLY_TOGGLE, + OZONE_ENTRIES_ICONS_TEXTURE_MENU_APPLY_COG, OZONE_ENTRIES_ICONS_TEXTURE_LAST }; @@ -207,4 +209,4 @@ menu_texture_item ozone_entries_icon_get_texture(ozone_handle_t *ozone, bool ozone_reset_theme_textures(ozone_handle_t *ozone); void ozone_unload_theme_textures(ozone_handle_t *ozone); -#endif \ No newline at end of file +#endif diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index d0e3419a13..ea131d5342 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -207,6 +207,8 @@ enum XMB_TEXTURE_PAUSE, XMB_TEXTURE_DEFAULT, XMB_TEXTURE_DEFAULT_CONTENT, + XMB_TEXTURE_MENU_APPLY_TOGGLE, + XMB_TEXTURE_MENU_APPLY_COG, XMB_TEXTURE_LAST }; @@ -2454,7 +2456,7 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, #ifdef HAVE_LAKKA_SWITCH case MENU_ENUM_LABEL_SWITCH_GPU_PROFILE: #endif -#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) +#if defined(HAVE_LAKKA_SWITCH) || defined(HAVE_LIBNX) case MENU_ENUM_LABEL_SWITCH_CPU_PROFILE: return xmb->textures.list[XMB_TEXTURE_POWER]; #endif @@ -2518,6 +2520,10 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, case MENU_ENUM_LABEL_CHEAT_ADD_NEW_TOP: case MENU_ENUM_LABEL_CHEAT_ADD_NEW_BOTTOM: return xmb->textures.list[XMB_TEXTURE_MENU_ADD]; + case MENU_ENUM_LABEL_CHEAT_APPLY_AFTER_TOGGLE: + return xmb->textures.list[XMB_TEXTURE_MENU_APPLY_TOGGLE]; + case MENU_ENUM_LABEL_CHEAT_APPLY_AFTER_LOAD: + return xmb->textures.list[XMB_TEXTURE_MENU_APPLY_COG]; default: break; } @@ -4854,6 +4860,10 @@ static const char *xmb_texture_path(unsigned id) return "default.png"; case XMB_TEXTURE_DEFAULT_CONTENT: return "default-content.png"; + case XMB_TEXTURE_MENU_APPLY_TOGGLE: + return "menu_apply_toggle.png"; + case XMB_TEXTURE_MENU_APPLY_COG: + return "menu_apply_cog.png"; } return NULL; } From a617f0d43691e75d3ffd67e0049eee622f870486 Mon Sep 17 00:00:00 2001 From: Tatsuya79 Date: Sat, 1 Dec 2018 11:27:39 +0100 Subject: [PATCH 113/153] Frame count should be OFF by default. --- configuration.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration.c b/configuration.c index 981ba24638..4264d236a5 100644 --- a/configuration.c +++ b/configuration.c @@ -1317,7 +1317,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, SETTING_BOOL("builtin_imageviewer_enable", &settings->bools.multimedia_builtin_imageviewer_enable, true, true, false); SETTING_BOOL("fps_show", &settings->bools.video_fps_show, true, false, false); SETTING_BOOL("statistics_show", &settings->bools.video_statistics_show, true, false, false); - SETTING_BOOL("framecount_show", &settings->bools.video_framecount_show, true, true, false); + SETTING_BOOL("framecount_show", &settings->bools.video_framecount_show, true, false, false); SETTING_BOOL("memory_show", &settings->bools.video_memory_show, true, false, false); SETTING_BOOL("ui_menubar_enable", &settings->bools.ui_menubar_enable, true, true, false); SETTING_BOOL("suspend_screensaver_enable", &settings->bools.ui_suspend_screensaver_enable, true, true, false); From 3d159d424e35813199e013de481ab8461c7731ed Mon Sep 17 00:00:00 2001 From: Aleksey Samoilov Date: Sun, 2 Dec 2018 17:53:03 +0400 Subject: [PATCH 114/153] Cleanup --- gfx/drivers_context/wayland_ctx.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index f3803a96f7..b4d9c6e564 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -585,33 +585,25 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, wl_array_for_each(state, states) { switch (*state) { case XDG_TOPLEVEL_STATE_FULLSCREEN: - printf("Surface state: XDG_SURFACE_STATE_FULLSCREEN\n"); wl->fullscreen = true; break; case XDG_TOPLEVEL_STATE_MAXIMIZED: - printf("Surface state: XDG_SURFACE_STATE_MAXIMIZED\n"); wl->maximized = true; break; case XDG_TOPLEVEL_STATE_RESIZING: - printf("Surface state: XDG_SURFACE_STATE_RESIZING\n"); wl->resize = true; break; case XDG_TOPLEVEL_STATE_ACTIVATED: - printf("Surface state: XDG_SURFACE_STATE_ACTIVATED\n"); wl->activated = true; break; case XDG_TOPLEVEL_STATE_TILED_TOP: - printf("Surface state: XDG_SURFACE_STATE_TILED_TOP\n"); case XDG_TOPLEVEL_STATE_TILED_LEFT: - printf("Surface state: XDG_SURFACE_STATE_TILED_LEFT\n"); case XDG_TOPLEVEL_STATE_TILED_RIGHT: - printf("Surface state: XDG_SURFACE_STATE_TILED_RIGHT\n"); case XDG_TOPLEVEL_STATE_TILED_BOTTOM: - printf("Surface state: XDG_SURFACE_STATE_TILED_BOTTOM\n"); - break; + break; } } - if (width > 0 && height >0) { + if (width > 0 && height > 0) { wl->prev_width = width; wl->prev_height = height; wl->width = width; From eda342262b9cc6c8b2265476cfa26ca9d613ca37 Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Sun, 2 Dec 2018 21:15:57 +0400 Subject: [PATCH 115/153] Fix --- gfx/drivers_context/wayland_ctx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index b4d9c6e564..bd6cbba2da 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -578,7 +578,6 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, { gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; - printf("Configure event got, width: %d, height: %d\n", width, height); wl->fullscreen = false; wl->maximized = false; enum xdg_toplevel_state *state; @@ -1456,8 +1455,9 @@ static bool gfx_ctx_wl_has_focus(void *data) static bool gfx_ctx_wl_suppress_screensaver(void *data, bool state) { - (void)data; - gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; + (void)data; + + gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; if (!wl->idle_inhibit_manager) return false; From b0273953410ec63605374afd1dfa07c0e7bae4dc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 3 Dec 2018 00:40:50 +0100 Subject: [PATCH 116/153] (Android/Vulkan) Enable 'emulate mailbox' for Android --- gfx/common/vulkan_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/common/vulkan_common.c b/gfx/common/vulkan_common.c index 24402cddba..9958f7526b 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.c @@ -42,7 +42,7 @@ #define VENDOR_ID_NV 0x10DE #define VENDOR_ID_INTEL 0x8086 -#ifdef _WIN32 +#if defined(_WIN32) || defined(ANDROID) #define VULKAN_EMULATE_MAILBOX #endif From be285b6acae8c17505ff945319ab0ba10ea8a81b Mon Sep 17 00:00:00 2001 From: hunterk Date: Sun, 2 Dec 2018 20:23:36 -0600 Subject: [PATCH 117/153] set a default SRAM autosave interval on modern platforms --- config.def.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config.def.h b/config.def.h index 546e7bebfd..50126da58c 100644 --- a/config.def.h +++ b/config.def.h @@ -536,7 +536,13 @@ static const bool pause_nonactive = true; /* Saves non-volatile SRAM at a regular interval. * It is measured in seconds. A value of 0 disables autosave. */ +#if defined(__i386__) || defined(__i486__) || defined(__i686__) || defined(_WIN32) || defined(OSX) || defined(ANDROID) || defined(IOS) +/* Flush to file every 10 seconds on modern platforms by default */ +static const unsigned autosave_interval = 10; +#else +/* Default to disabled on I/O-constrained platforms */ static const unsigned autosave_interval = 0; +#endif /* Publicly announce netplay */ static const bool netplay_public_announce = true; From 9b0bad5d9f1e20816e92e682e68418a4d1b4f03f Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Mon, 3 Dec 2018 14:32:31 +0400 Subject: [PATCH 118/153] Add zxdg_shell_v6 and wl_shell ad fallback interfaces --- Makefile.common | 1 + gfx/common/wayland/generate_wayland_protos.sh | 4 + gfx/drivers_context/wayland_ctx.c | 269 +++++++++++++++--- 3 files changed, 235 insertions(+), 39 deletions(-) diff --git a/Makefile.common b/Makefile.common index 6218fa317a..47a567c99f 100644 --- a/Makefile.common +++ b/Makefile.common @@ -866,6 +866,7 @@ ifeq ($(HAVE_WAYLAND), 1) OBJ += gfx/drivers_context/wayland_ctx.o \ input/drivers/wayland_input.o \ gfx/common/wayland/xdg-shell.o \ + gfx/common/wayland/xdg-shell-unstable-v6.o \ gfx/common/wayland/idle-inhibit-unstable-v1.o ifeq ($(HAVE_EGL), 1) LIBS += $(EGL_LIBS) diff --git a/gfx/common/wayland/generate_wayland_protos.sh b/gfx/common/wayland/generate_wayland_protos.sh index e64ea58914..22e19281cf 100755 --- a/gfx/common/wayland/generate_wayland_protos.sh +++ b/gfx/common/wayland/generate_wayland_protos.sh @@ -7,6 +7,10 @@ if [ ! -d $OUTPUT ]; then mkdir $OUTPUT fi +#Generate xdg-shell_v6 header and .c files +$WAYSCAN client-header $WAYLAND_PROTOS/unstable/xdg-shell/xdg-shell-unstable-v6.xml $OUTPUT/xdg-shell-unstable-v6.h +$WAYSCAN code $WAYLAND_PROTOS/unstable/xdg-shell/xdg-shell-unstable-v6.xml $OUTPUT/xdg-shell-unstable-v6.c + #Generate xdg-shell header and .c files $WAYSCAN client-header $WAYLAND_PROTOS/stable/xdg-shell/xdg-shell.xml $OUTPUT/xdg-shell.h $WAYSCAN code $WAYLAND_PROTOS/stable/xdg-shell/xdg-shell.xml $OUTPUT/xdg-shell.c diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index bd6cbba2da..03d109305c 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -50,6 +50,9 @@ /* Generated from idle-inhibit-unstable-v1.xml */ #include "../common/wayland/idle-inhibit-unstable-v1.h" +/* Generated from xdg-shell-unstable-v6.xml */ +#include "../common/wayland/xdg-shell-unstable-v6.h" + /* Generated from xdg-shell.xml */ #include "../common/wayland/xdg-shell.h" @@ -87,8 +90,13 @@ typedef struct gfx_ctx_wayland_data struct wl_registry *registry; struct wl_compositor *compositor; struct wl_surface *surface; + struct wl_shell_surface *shell_surf; + struct wl_shell *shell; + struct zxdg_surface_v6 *zxdg_surface; + struct zxdg_shell_v6 *zxdg_shell; + struct zxdg_toplevel_v6 *zxdg_toplevel; struct xdg_surface *xdg_surface; - struct xdg_wm_base *shell; + struct xdg_wm_base *xdg_shell; struct xdg_toplevel *xdg_toplevel; struct wl_keyboard *wl_keyboard; struct wl_pointer *wl_pointer; @@ -314,8 +322,14 @@ static void pointer_handle_button(void *data, { wl->input.mouse.left = true; - if (BIT_GET(wl->input.key_state, KEY_LEFTALT) && wl->xdg_toplevel) - xdg_toplevel_move(wl->xdg_toplevel, wl->seat, serial); + if (BIT_GET(wl->input.key_state, KEY_LEFTALT) && wl->xdg_toplevel) { + if (wl->xdg_toplevel) + xdg_toplevel_move(wl->xdg_toplevel, wl->seat, serial); + else if (wl->zxdg_toplevel) + zxdg_toplevel_v6_move(wl->zxdg_toplevel, wl->seat, serial); + else if (wl->shell) + wl_shell_surface_move(wl->shell_surf, wl->seat, serial); + } } else if (button == BTN_RIGHT) wl->input.mouse.right = true; @@ -580,7 +594,7 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, wl->fullscreen = false; wl->maximized = false; - enum xdg_toplevel_state *state; + const uint32_t *state; wl_array_for_each(state, states) { switch (*state) { case XDG_TOPLEVEL_STATE_FULLSCREEN: @@ -594,12 +608,7 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, break; case XDG_TOPLEVEL_STATE_ACTIVATED: wl->activated = true; - break; - case XDG_TOPLEVEL_STATE_TILED_TOP: - case XDG_TOPLEVEL_STATE_TILED_LEFT: - case XDG_TOPLEVEL_STATE_TILED_RIGHT: - case XDG_TOPLEVEL_STATE_TILED_BOTTOM: - break; + break; } } if (width > 0 && height > 0) { @@ -627,6 +636,111 @@ static const struct xdg_toplevel_listener xdg_toplevel_listener = { handle_toplevel_close, }; +static void zxdg_shell_ping(void *data, struct zxdg_shell_v6 *shell, uint32_t serial) +{ + zxdg_shell_v6_pong(shell, serial); +} + +static const struct zxdg_shell_v6_listener zxdg_shell_v6_listener = { + zxdg_shell_ping, +}; + +static void handle_zxdg_surface_config(void *data, struct zxdg_surface_v6 *surface, + uint32_t serial) +{ + zxdg_surface_v6_ack_configure(surface, serial); +} + +static const struct zxdg_surface_v6_listener zxdg_surface_v6_listener = { + handle_zxdg_surface_config, +}; + +static void handle_zxdg_toplevel_config(void *data, struct zxdg_toplevel_v6 *toplevel, + int32_t width, int32_t height, struct wl_array *states) +{ + gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; + + wl->fullscreen = false; + wl->maximized = false; + const uint32_t *state; + wl_array_for_each(state, states) { + switch (*state) { + case XDG_TOPLEVEL_STATE_FULLSCREEN: + wl->fullscreen = true; + break; + case XDG_TOPLEVEL_STATE_MAXIMIZED: + wl->maximized = true; + break; + case XDG_TOPLEVEL_STATE_RESIZING: + wl->resize = true; + break; + case XDG_TOPLEVEL_STATE_ACTIVATED: + wl->activated = true; + break; + } + } + if (width > 0 && height > 0) { + wl->prev_width = width; + wl->prev_height = height; + wl->width = width; + wl->height = height; + } + else { + wl->width = wl->prev_width; + wl->height = wl->prev_height; + } + + wl->configured = false; +} + +static void handle_zxdg_toplevel_close(void *data, struct zxdg_toplevel_v6 *zxdg_toplevel) +{ + gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; + BIT_SET(wl->input.key_state, KEY_ESC); +} + +static const struct zxdg_toplevel_v6_listener zxdg_toplevel_v6_listener = { + handle_zxdg_toplevel_config, + handle_zxdg_toplevel_close, +}; + +static void shell_surface_handle_ping(void *data, + struct wl_shell_surface *shell_surface, + uint32_t serial) +{ + (void)data; + wl_shell_surface_pong(shell_surface, serial); +} + +static void shell_surface_handle_configure(void *data, + struct wl_shell_surface *shell_surface, + uint32_t edges, int32_t width, int32_t height) +{ + gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; + + (void)shell_surface; + (void)edges; + + wl->width = wl->buffer_scale * width; + wl->height = wl->buffer_scale * height; + + RARCH_LOG("[Wayland]: Surface configure: %u x %u.\n", + wl->width, wl->height); +} + +static void shell_surface_handle_popup_done(void *data, + struct wl_shell_surface *shell_surface) +{ + (void)data; + (void)shell_surface; +} + +static const struct wl_shell_surface_listener shell_surface_listener = { + shell_surface_handle_ping, + shell_surface_handle_configure, + shell_surface_handle_popup_done, +}; + static void display_handle_geometry(void *data, struct wl_output *output, int x, int y, @@ -718,8 +832,14 @@ static void registry_handle_global(void *data, struct wl_registry *reg, wl_display_roundtrip(wl->input.dpy); } else if (string_is_equal(interface, "xdg_wm_base")) - wl->shell = (struct xdg_wm_base*) + wl->xdg_shell = (struct xdg_wm_base*) wl_registry_bind(reg, id, &xdg_wm_base_interface, 1); + else if (string_is_equal(interface, "zxdg_shell_v6")) + wl->zxdg_shell = (struct zxdg_shell_v6*) + wl_registry_bind(reg, id, &zxdg_shell_v6_interface, 1); + else if (string_is_equal(interface, "wl_shell")) + wl->shell = (struct wl_shell*) + wl_registry_bind(reg, id, &wl_shell_interface, 1); else if (string_is_equal(interface, "wl_shm")) wl->shm = (struct wl_shm*)wl_registry_bind(reg, id, &wl_shm_interface, 1); else if (string_is_equal(interface, "wl_seat")) @@ -802,16 +922,28 @@ static void gfx_ctx_wl_destroy_resources(gfx_ctx_wayland_data_t *wl) if (wl->seat) wl_seat_destroy(wl->seat); + if (wl->xdg_shell) + xdg_wm_base_destroy(wl->xdg_shell); + if (wl->zxdg_shell) + zxdg_shell_v6_destroy(wl->zxdg_shell); if (wl->shell) - xdg_wm_base_destroy(wl->shell); + wl_shell_destroy(wl->shell); if (wl->compositor) wl_compositor_destroy(wl->compositor); if (wl->registry) wl_registry_destroy(wl->registry); if (wl->xdg_surface) xdg_surface_destroy(wl->xdg_surface); + if (wl->zxdg_surface) + zxdg_surface_v6_destroy(wl->zxdg_surface); if (wl->surface) wl_surface_destroy(wl->surface); + if (wl->xdg_toplevel) + xdg_toplevel_destroy(wl->xdg_toplevel); + if (wl->zxdg_toplevel) + zxdg_toplevel_v6_destroy(wl->zxdg_toplevel); + if (wl->shell_surf) + wl_shell_surface_destroy(wl->shell_surf); if (wl->idle_inhibit_manager) zwp_idle_inhibit_manager_v1_destroy(wl->idle_inhibit_manager); if (wl->idle_inhibitor) @@ -826,12 +958,17 @@ static void gfx_ctx_wl_destroy_resources(gfx_ctx_wayland_data_t *wl) #ifdef HAVE_EGL wl->win = NULL; #endif - wl->shell = NULL; + wl->xdg_shell = NULL; + wl->zxdg_shell = NULL; + wl->shell = NULL; wl->compositor = NULL; wl->registry = NULL; wl->input.dpy = NULL; wl->xdg_surface = NULL; wl->surface = NULL; + wl->xdg_toplevel = NULL; + wl->zxdg_toplevel = NULL; + wl->shell_surf = NULL; wl->width = 0; wl->height = 0; @@ -952,8 +1089,14 @@ static void gfx_ctx_wl_update_title(void *data, void *data2) video_driver_get_window_title(title, sizeof(title)); - if (wl && title[0]) - xdg_toplevel_set_title (wl->xdg_toplevel, title); + if (wl && title[0]) { + if (wl->xdg_toplevel) + xdg_toplevel_set_title(wl->xdg_toplevel, title); + else if (wl->zxdg_toplevel) + zxdg_toplevel_v6_set_title(wl->zxdg_toplevel, title); + else if (wl->shell_surf) + wl_shell_surface_set_title(wl->shell_surf, title); + } } @@ -1113,10 +1256,20 @@ static void *gfx_ctx_wl_init(video_frame_info_t *video_info, void *video_driver) goto error; } - if (!wl->shell) + if (!wl->xdg_shell) { - RARCH_ERR("[Wayland]: Failed to create shell.\n"); - goto error; + RARCH_LOG("[Wayland]: Using zxdg_shell_v6 interface.\n"); + } + + if (!wl->xdg_shell && !wl->zxdg_shell) + { + RARCH_WARN("[Wayland]: Fallback to deprecated wl_shell interface!.\n"); + } + + if (!wl->xdg_shell && !wl->zxdg_shell && !wl->shell) + { + RARCH_ERR("[Wayland]: Failed to create shell.\n"); + goto error; } if (!wl->idle_inhibit_manager) @@ -1346,25 +1499,55 @@ static bool gfx_ctx_wl_set_video_mode(void *data, break; } - wl->xdg_surface = xdg_wm_base_get_xdg_surface(wl->shell, wl->surface); - xdg_surface_add_listener(wl->xdg_surface, &xdg_surface_listener, wl); - - wl->xdg_toplevel = xdg_surface_get_toplevel(wl->xdg_surface); - xdg_toplevel_add_listener(wl->xdg_toplevel, &xdg_toplevel_listener, wl); - - xdg_toplevel_set_app_id (wl->xdg_toplevel, "RetroArch"); - xdg_toplevel_set_title (wl->xdg_toplevel, "RetroArch"); - - /* Waiting for xdg_toplevel to be configured before starting to draw */ - wl_surface_commit(wl->surface); - wl->configured = true; - - while (wl->configured) - wl_display_dispatch(wl->input.dpy); - - /* Waiting for the "initial" set of globals to appear */ - wl_display_roundtrip(wl->input.dpy); - xdg_wm_base_add_listener(wl->shell, &xdg_shell_listener, NULL); + if (wl->xdg_shell) { + wl->xdg_surface = xdg_wm_base_get_xdg_surface(wl->xdg_shell, wl->surface); + xdg_surface_add_listener(wl->xdg_surface, &xdg_surface_listener, wl); + + wl->xdg_toplevel = xdg_surface_get_toplevel(wl->xdg_surface); + xdg_toplevel_add_listener(wl->xdg_toplevel, &xdg_toplevel_listener, wl); + + xdg_toplevel_set_app_id(wl->xdg_toplevel, "RetroArch"); + xdg_toplevel_set_title(wl->xdg_toplevel, "RetroArch"); + + /* Waiting for xdg_toplevel to be configured before starting to draw */ + wl_surface_commit(wl->surface); + wl->configured = true; + + while (wl->configured) { + wl_display_dispatch(wl->input.dpy); + } + /* Waiting for the "initial" set of globals to appear */ + wl_display_roundtrip(wl->input.dpy); + xdg_wm_base_add_listener(wl->xdg_shell, &xdg_shell_listener, NULL); + } else if (wl->zxdg_shell) { + wl->zxdg_surface = zxdg_shell_v6_get_xdg_surface(wl->zxdg_shell, wl->surface); + zxdg_surface_v6_add_listener(wl->zxdg_surface, &zxdg_surface_v6_listener, wl); + + wl->zxdg_toplevel = zxdg_surface_v6_get_toplevel(wl->zxdg_surface); + zxdg_toplevel_v6_add_listener(wl->zxdg_toplevel, &zxdg_toplevel_v6_listener, wl); + + zxdg_toplevel_v6_set_app_id(wl->zxdg_toplevel, "RetroArch"); + zxdg_toplevel_v6_set_title(wl->zxdg_toplevel, "RetroArch"); + + /* Waiting for xdg_toplevel to be configured before starting to draw */ + wl_surface_commit(wl->surface); + wl->configured = true; + + while (wl->configured) { + wl_display_dispatch(wl->input.dpy); + } + /* Waiting for the "initial" set of globals to appear */ + wl_display_roundtrip(wl->input.dpy); + zxdg_shell_v6_add_listener(wl->zxdg_shell, &zxdg_shell_v6_listener, NULL); + } else if (wl->shell) { + wl->shell_surf = wl_shell_get_shell_surface(wl->shell, wl->surface); + + wl_shell_surface_add_listener(wl->shell_surf, &shell_surface_listener, wl); + wl_shell_surface_set_toplevel(wl->shell_surf); + wl_shell_surface_set_class(wl->shell_surf, "RetroArch"); + wl_shell_surface_set_title(wl->shell_surf, "RetroArch"); + } + switch (wl_api) { @@ -1389,8 +1572,16 @@ static bool gfx_ctx_wl_set_video_mode(void *data, break; } - if (fullscreen) - xdg_toplevel_set_fullscreen(wl->xdg_toplevel, NULL); + if (fullscreen) { + if (wl->xdg_toplevel) { + xdg_toplevel_set_fullscreen(wl->xdg_toplevel, NULL); + } else if (wl->zxdg_toplevel) { + zxdg_toplevel_v6_set_fullscreen(wl->zxdg_toplevel, NULL); + } else if (wl->shell) { + wl_shell_surface_set_fullscreen(wl->shell_surf, + WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, NULL); + } + } flush_wayland_fd(&wl->input); From 2b6fbbdfe09d087cec84575647225e9c5a8cf035 Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Mon, 3 Dec 2018 14:46:57 +0400 Subject: [PATCH 119/153] Temp fix resizing --- gfx/drivers_context/wayland_ctx.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 03d109305c..138f485935 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -617,10 +617,6 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, wl->width = width; wl->height = height; } - else { - wl->width = wl->prev_width; - wl->height = wl->prev_height; - } wl->configured = false; } @@ -685,10 +681,6 @@ static void handle_zxdg_toplevel_config(void *data, struct zxdg_toplevel_v6 *top wl->width = width; wl->height = height; } - else { - wl->width = wl->prev_width; - wl->height = wl->prev_height; - } wl->configured = false; } From 72eb7c4f5950f881a3db3e6ce14d60f04f3e2a1c Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Mon, 3 Dec 2018 14:48:13 +0400 Subject: [PATCH 120/153] Temp fix resizing --- gfx/drivers_context/wayland_ctx.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index bd6cbba2da..b48b6ff801 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -608,10 +608,6 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, wl->width = width; wl->height = height; } - else { - wl->width = wl->prev_width; - wl->height = wl->prev_height; - } wl->configured = false; } From 687fe77cd741aa1d5eb7ffeb2a81e42acd5b8945 Mon Sep 17 00:00:00 2001 From: hunterk Date: Tue, 4 Dec 2018 23:30:57 -0600 Subject: [PATCH 121/153] add a couple more qualifiers for the autosave interval --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 50126da58c..91d0ec6eec 100644 --- a/config.def.h +++ b/config.def.h @@ -536,7 +536,7 @@ static const bool pause_nonactive = true; /* Saves non-volatile SRAM at a regular interval. * It is measured in seconds. A value of 0 disables autosave. */ -#if defined(__i386__) || defined(__i486__) || defined(__i686__) || defined(_WIN32) || defined(OSX) || defined(ANDROID) || defined(IOS) +#if defined(__i386__) || defined(__i486__) || defined(__i686__) || defined(__x86_64__) || defined((_M_X64) || defined(_WIN32) || defined(OSX) || defined(ANDROID) || defined(IOS) /* Flush to file every 10 seconds on modern platforms by default */ static const unsigned autosave_interval = 10; #else From a42cacaaf6e43ec1a7eea749086609730288833e Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Wed, 5 Dec 2018 01:55:22 -0500 Subject: [PATCH 122/153] autosave_interval: Fix syntax error --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 91d0ec6eec..380e04440e 100644 --- a/config.def.h +++ b/config.def.h @@ -536,7 +536,7 @@ static const bool pause_nonactive = true; /* Saves non-volatile SRAM at a regular interval. * It is measured in seconds. A value of 0 disables autosave. */ -#if defined(__i386__) || defined(__i486__) || defined(__i686__) || defined(__x86_64__) || defined((_M_X64) || defined(_WIN32) || defined(OSX) || defined(ANDROID) || defined(IOS) +#if defined(__i386__) || defined(__i486__) || defined(__i686__) || defined(__x86_64__) || defined(_M_X64) || defined(_WIN32) || defined(OSX) || defined(ANDROID) || defined(IOS) /* Flush to file every 10 seconds on modern platforms by default */ static const unsigned autosave_interval = 10; #else From dcec570d05d0c30c5394340df59f1e598f8658b8 Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Wed, 5 Dec 2018 21:20:15 +0400 Subject: [PATCH 123/153] Style fix --- gfx/drivers_context/wayland_ctx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index b48b6ff801..c66cbec88b 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -603,11 +603,11 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, } } if (width > 0 && height > 0) { - wl->prev_width = width; - wl->prev_height = height; - wl->width = width; - wl->height = height; - } + wl->prev_width = width; + wl->prev_height = height; + wl->width = width; + wl->height = height; + } wl->configured = false; } From e12caa94d469f230cfd7f7bf721401f2e7d6e49d Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Wed, 5 Dec 2018 22:36:37 +0400 Subject: [PATCH 124/153] Style fixes --- gfx/drivers_context/wayland_ctx.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 138f485935..a7dbdc949f 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -612,11 +612,11 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, } } if (width > 0 && height > 0) { - wl->prev_width = width; - wl->prev_height = height; - wl->width = width; - wl->height = height; - } + wl->prev_width = width; + wl->prev_height = height; + wl->width = width; + wl->height = height; + } wl->configured = false; } @@ -676,11 +676,11 @@ static void handle_zxdg_toplevel_config(void *data, struct zxdg_toplevel_v6 *top } } if (width > 0 && height > 0) { - wl->prev_width = width; - wl->prev_height = height; - wl->width = width; - wl->height = height; - } + wl->prev_width = width; + wl->prev_height = height; + wl->width = width; + wl->height = height; + } wl->configured = false; } @@ -1500,15 +1500,13 @@ static bool gfx_ctx_wl_set_video_mode(void *data, xdg_toplevel_set_app_id(wl->xdg_toplevel, "RetroArch"); xdg_toplevel_set_title(wl->xdg_toplevel, "RetroArch"); - - /* Waiting for xdg_toplevel to be configured before starting to draw */ + wl_surface_commit(wl->surface); wl->configured = true; while (wl->configured) { wl_display_dispatch(wl->input.dpy); } - /* Waiting for the "initial" set of globals to appear */ wl_display_roundtrip(wl->input.dpy); xdg_wm_base_add_listener(wl->xdg_shell, &xdg_shell_listener, NULL); } else if (wl->zxdg_shell) { @@ -1520,20 +1518,17 @@ static bool gfx_ctx_wl_set_video_mode(void *data, zxdg_toplevel_v6_set_app_id(wl->zxdg_toplevel, "RetroArch"); zxdg_toplevel_v6_set_title(wl->zxdg_toplevel, "RetroArch"); - - /* Waiting for xdg_toplevel to be configured before starting to draw */ + wl_surface_commit(wl->surface); wl->configured = true; while (wl->configured) { wl_display_dispatch(wl->input.dpy); } - /* Waiting for the "initial" set of globals to appear */ wl_display_roundtrip(wl->input.dpy); zxdg_shell_v6_add_listener(wl->zxdg_shell, &zxdg_shell_v6_listener, NULL); } else if (wl->shell) { wl->shell_surf = wl_shell_get_shell_surface(wl->shell, wl->surface); - wl_shell_surface_add_listener(wl->shell_surf, &shell_surface_listener, wl); wl_shell_surface_set_toplevel(wl->shell_surf); wl_shell_surface_set_class(wl->shell_surf, "RetroArch"); From dc948866643c03639a405fb20272e026205b609a Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Wed, 5 Dec 2018 22:51:07 +0400 Subject: [PATCH 125/153] Initial support for xdg-decoration-unstable-v1 --- Makefile.common | 3 ++- gfx/common/wayland/generate_wayland_protos.sh | 10 +++++++--- gfx/drivers_context/wayland_ctx.c | 12 ++++++++++++ qb/config.libs.sh | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Makefile.common b/Makefile.common index 47a567c99f..d400a480fa 100644 --- a/Makefile.common +++ b/Makefile.common @@ -867,7 +867,8 @@ ifeq ($(HAVE_WAYLAND), 1) input/drivers/wayland_input.o \ gfx/common/wayland/xdg-shell.o \ gfx/common/wayland/xdg-shell-unstable-v6.o \ - gfx/common/wayland/idle-inhibit-unstable-v1.o + gfx/common/wayland/idle-inhibit-unstable-v1.o \ + gfx/common/wayland/xdg-decoration-unstable-v1.o ifeq ($(HAVE_EGL), 1) LIBS += $(EGL_LIBS) endif diff --git a/gfx/common/wayland/generate_wayland_protos.sh b/gfx/common/wayland/generate_wayland_protos.sh index 22e19281cf..8c0cc7f155 100755 --- a/gfx/common/wayland/generate_wayland_protos.sh +++ b/gfx/common/wayland/generate_wayland_protos.sh @@ -9,12 +9,16 @@ fi #Generate xdg-shell_v6 header and .c files $WAYSCAN client-header $WAYLAND_PROTOS/unstable/xdg-shell/xdg-shell-unstable-v6.xml $OUTPUT/xdg-shell-unstable-v6.h -$WAYSCAN code $WAYLAND_PROTOS/unstable/xdg-shell/xdg-shell-unstable-v6.xml $OUTPUT/xdg-shell-unstable-v6.c +$WAYSCAN private-code $WAYLAND_PROTOS/unstable/xdg-shell/xdg-shell-unstable-v6.xml $OUTPUT/xdg-shell-unstable-v6.c #Generate xdg-shell header and .c files $WAYSCAN client-header $WAYLAND_PROTOS/stable/xdg-shell/xdg-shell.xml $OUTPUT/xdg-shell.h -$WAYSCAN code $WAYLAND_PROTOS/stable/xdg-shell/xdg-shell.xml $OUTPUT/xdg-shell.c +$WAYSCAN private-code $WAYLAND_PROTOS/stable/xdg-shell/xdg-shell.xml $OUTPUT/xdg-shell.c #Generate idle-inhibit header and .c files $WAYSCAN client-header $WAYLAND_PROTOS/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml $OUTPUT/idle-inhibit-unstable-v1.h -$WAYSCAN code $WAYLAND_PROTOS/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml $OUTPUT/idle-inhibit-unstable-v1.c +$WAYSCAN private-code $WAYLAND_PROTOS/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml $OUTPUT/idle-inhibit-unstable-v1.c + +#Generate xdg-decoration header and .c files +$WAYSCAN client-header $WAYLAND_PROTOS/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml $OUTPUT/xdg-decoration-unstable-v1.h +$WAYSCAN private-code $WAYLAND_PROTOS/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml $OUTPUT/xdg-decoration-unstable-v1.c diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 138f485935..d05c65d321 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -56,6 +56,9 @@ /* Generated from xdg-shell.xml */ #include "../common/wayland/xdg-shell.h" +/* Generated from xdg-decoration-unstable-v1.h */ +#include "../common/wayland/xdg-decoration-unstable-v1.h" + typedef struct touch_pos { @@ -103,6 +106,8 @@ typedef struct gfx_ctx_wayland_data struct wl_touch *wl_touch; struct wl_seat *seat; struct wl_shm *shm; + struct zxdg_decoration_manager_v1 *deco_manager; + struct zxdg_toplevel_decoration_v1 *deco; struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager; struct zwp_idle_inhibitor_v1 *idle_inhibitor; int swap_interval; @@ -842,6 +847,9 @@ static void registry_handle_global(void *data, struct wl_registry *reg, else if (string_is_equal(interface, "zwp_idle_inhibit_manager_v1")) wl->idle_inhibit_manager = (struct zwp_idle_inhibit_manager_v1*)wl_registry_bind( reg, id, &zwp_idle_inhibit_manager_v1_interface, 1); + else if (string_is_equal(interface, "zxdg_decoration_manager_v1")) + wl->deco_manager = (struct zxdg_decoration_manager_v1*)wl_registry_bind( + reg, id, &zxdg_decoration_manager_v1_interface, 1); } static void registry_handle_global_remove(void *data, @@ -938,6 +946,10 @@ static void gfx_ctx_wl_destroy_resources(gfx_ctx_wayland_data_t *wl) wl_shell_surface_destroy(wl->shell_surf); if (wl->idle_inhibit_manager) zwp_idle_inhibit_manager_v1_destroy(wl->idle_inhibit_manager); + if (wl->deco) + zxdg_toplevel_decoration_v1_destroy(wl->deco); + if (wl->deco_manager) + zxdg_decoration_manager_v1_destroy(wl->deco_manager); if (wl->idle_inhibitor) zwp_idle_inhibitor_v1_destroy(wl->idle_inhibitor); diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 233fd9760a..d31c45c589 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -457,7 +457,7 @@ check_pkgconf X11 x11 check_pkgconf XCB xcb check_pkgconf WAYLAND wayland-egl 1.14 check_pkgconf WAYLAND_CURSOR wayland-cursor 1.14 -check_pkgconf WAYLAND_PROTOS wayland-protocols 1.13 +check_pkgconf WAYLAND_PROTOS wayland-protocols 1.15 check_pkgconf XKBCOMMON xkbcommon 0.3.2 check_pkgconf DBUS dbus-1 check_pkgconf XEXT xext From f953962d0852b8ac5fb9ab8914094349ccc7ddb5 Mon Sep 17 00:00:00 2001 From: rsn8887 Date: Wed, 5 Dec 2018 18:12:55 -0600 Subject: [PATCH 126/153] [LIBNX] Fix Split Joycon mode for horizontal holding --- input/drivers_joypad/switch_joypad.c | 1 + 1 file changed, 1 insertion(+) diff --git a/input/drivers_joypad/switch_joypad.c b/input/drivers_joypad/switch_joypad.c index 67a4556196..f04402b7e2 100644 --- a/input/drivers_joypad/switch_joypad.c +++ b/input/drivers_joypad/switch_joypad.c @@ -170,6 +170,7 @@ static void switch_joypad_poll(void) { hidSetNpadJoyAssignmentModeSingleByDefault(i); hidSetNpadJoyAssignmentModeSingleByDefault(i + 1); + hidSetNpadJoyHoldType(HidJoyHoldType_Horizontal); } } lastMode = 1; From 44cd32912535b58b3cda9a32ae9ba5f03448ccab Mon Sep 17 00:00:00 2001 From: rsn8887 Date: Wed, 5 Dec 2018 18:29:28 -0600 Subject: [PATCH 127/153] [LIBNX] Fix switching from Split Joycon mode to Dual Joycon mode --- input/drivers_joypad/switch_joypad.c | 1 + 1 file changed, 1 insertion(+) diff --git a/input/drivers_joypad/switch_joypad.c b/input/drivers_joypad/switch_joypad.c index f04402b7e2..b92397779b 100644 --- a/input/drivers_joypad/switch_joypad.c +++ b/input/drivers_joypad/switch_joypad.c @@ -186,6 +186,7 @@ static void switch_joypad_poll(void) { hidSetNpadJoyAssignmentModeDual(i); hidSetNpadJoyAssignmentModeDual(i + 1); + hidMergeSingleJoyAsDualJoy(i, i + 1); } } lastMode = 0; From 124d9b57d663d8379f1477ae02a8f47da7c8cbe6 Mon Sep 17 00:00:00 2001 From: Themaister Date: Thu, 6 Dec 2018 11:38:30 +0100 Subject: [PATCH 128/153] Vulkan: Fix blue/red flip when using HW rendered cores with history. Was using frontend format of BGRA8 when core was RGBA8, with blind vkCmdCopyImage. Fix is to use the same format as core is pushing to history buffer. --- gfx/drivers/vulkan.c | 4 ++++ gfx/drivers_shader/shader_vulkan.cpp | 16 ++++++++++------ gfx/drivers_shader/shader_vulkan.h | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 140dbff7b7..09769b1b0a 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -1742,6 +1742,9 @@ static bool vulkan_frame(void *data, const void *frame, input.view = vk->hw.image->image_view; input.layout = vk->hw.image->image_layout; + /* The format can change on a whim. */ + input.format = vk->hw.image->create_info.format; + if (frame) { input.width = frame_width; @@ -1769,6 +1772,7 @@ static bool vulkan_frame(void *data, const void *frame, input.layout = tex->layout; input.width = tex->width; input.height = tex->height; + input.format = VK_FORMAT_UNDEFINED; /* It's already configured. */ } vulkan_filter_chain_set_input_texture((vulkan_filter_chain_t*)vk->filter_chain, &input); diff --git a/gfx/drivers_shader/shader_vulkan.cpp b/gfx/drivers_shader/shader_vulkan.cpp index 57559d3258..cc587083d4 100644 --- a/gfx/drivers_shader/shader_vulkan.cpp +++ b/gfx/drivers_shader/shader_vulkan.cpp @@ -210,9 +210,10 @@ class Framebuffer Framebuffer(Framebuffer&&) = delete; void operator=(Framebuffer&&) = delete; - void set_size(DeferredDisposer &disposer, const Size2D &size); + void set_size(DeferredDisposer &disposer, const Size2D &size, VkFormat format = VK_FORMAT_UNDEFINED); const Size2D &get_size() const { return size; } + VkFormat get_format() const { return format; } VkImage get_image() const { return image; } VkImageView get_view() const { return view; } VkFramebuffer get_framebuffer() const { return framebuffer; } @@ -1009,9 +1010,10 @@ void vulkan_filter_chain::update_history(DeferredDisposer &disposer, VkCommandBu swap(back, tmp); if (input_texture.width != tmp->get_size().width || - input_texture.height != tmp->get_size().height) + input_texture.height != tmp->get_size().height || + (input_texture.format != VK_FORMAT_UNDEFINED && input_texture.format != tmp->get_format())) { - tmp->set_size(disposer, { input_texture.width, input_texture.height }); + tmp->set_size(disposer, { input_texture.width, input_texture.height }, input_texture.format); } tmp->copy(cmd, input_texture.image, src_layout); @@ -2422,12 +2424,14 @@ void Framebuffer::init_framebuffer() vkCreateFramebuffer(device, &info, nullptr, &framebuffer); } -void Framebuffer::set_size(DeferredDisposer &disposer, const Size2D &size) +void Framebuffer::set_size(DeferredDisposer &disposer, const Size2D &size, VkFormat format) { this->size = size; + if (format != VK_FORMAT_UNDEFINED) + this->format = format; - RARCH_LOG("[Vulkan filter chain]: Updating framebuffer size %u x %u.\n", - size.width, size.height); + RARCH_LOG("[Vulkan filter chain]: Updating framebuffer size %u x %u (format: %u).\n", + size.width, size.height, (unsigned)this->format); { // The current framebuffers, etc, might still be in use diff --git a/gfx/drivers_shader/shader_vulkan.h b/gfx/drivers_shader/shader_vulkan.h index 79ac7f2d8f..7c7e07ad91 100644 --- a/gfx/drivers_shader/shader_vulkan.h +++ b/gfx/drivers_shader/shader_vulkan.h @@ -53,6 +53,7 @@ struct vulkan_filter_chain_texture VkImageLayout layout; unsigned width; unsigned height; + VkFormat format; }; enum vulkan_filter_chain_scale From e050ca89c7c9c06eded2cacb3c50a301883f8435 Mon Sep 17 00:00:00 2001 From: radius Date: Thu, 6 Dec 2018 10:03:48 -0500 Subject: [PATCH 129/153] make windowed size take into account window border and title height --- gfx/common/win32_common.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index f9314ada30..25552ed318 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -622,18 +622,22 @@ static LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, static void win32_set_position_from_config(void) { settings_t *settings = config_get_ptr(); + int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); + int title_bar_height = GetSystemMetrics(SM_CYCAPTION); if (!settings->bools.video_window_save_positions) return; g_win32_pos_x = settings->uints.window_position_x; g_win32_pos_y = settings->uints.window_position_y; - g_win32_pos_width = settings->uints.window_position_width; - g_win32_pos_height= settings->uints.window_position_height; + g_win32_pos_width = settings->uints.window_position_width + border_thickness * 2; + g_win32_pos_height= settings->uints.window_position_height + border_thickness * 2 + title_bar_height; } static void win32_save_position(void) { RECT rect; + int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); + int title_bar_height = GetSystemMetrics(SM_CYCAPTION); WINDOWPLACEMENT placement; settings_t *settings = config_get_ptr(); memset(&placement, 0, sizeof(placement)); @@ -655,8 +659,8 @@ static void win32_save_position(void) { settings->uints.window_position_x = g_win32_pos_x; settings->uints.window_position_y = g_win32_pos_y; - settings->uints.window_position_width = g_win32_pos_width; - settings->uints.window_position_height = g_win32_pos_height; + settings->uints.window_position_width = g_win32_pos_width - border_thickness * 2; + settings->uints.window_position_height = g_win32_pos_height - border_thickness * 2 - title_bar_height; } } } From 0735fbcd57ec8b6d683ec797358c19188e51ce19 Mon Sep 17 00:00:00 2001 From: orbea Date: Thu, 6 Dec 2018 07:09:03 -0800 Subject: [PATCH 130/153] Fix build with '--enable-sixel'. (#7704) First bad commit 2edd03361c35ef2648d30ff421bfcee44158bb4f --- gfx/drivers/sixel_gfx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gfx/drivers/sixel_gfx.c b/gfx/drivers/sixel_gfx.c index 8daecdaa32..d49c3dd74f 100644 --- a/gfx/drivers/sixel_gfx.c +++ b/gfx/drivers/sixel_gfx.c @@ -30,6 +30,7 @@ #include "../../driver.h" #include "../../configuration.h" +#include "../../retroarch.h" #include "../../verbosity.h" #include "../../frontend/frontend_driver.h" #include "../common/sixel_common.h" From defe82c9ceb3357c8b4f3f75b27a6d89193d1e45 Mon Sep 17 00:00:00 2001 From: radius Date: Thu, 6 Dec 2018 10:15:50 -0500 Subject: [PATCH 131/153] fix the menubar height growing issue too --- gfx/common/win32_common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 25552ed318..a9d96062e0 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -624,6 +624,7 @@ static void win32_set_position_from_config(void) settings_t *settings = config_get_ptr(); int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); int title_bar_height = GetSystemMetrics(SM_CYCAPTION); + int menu_bar_height = GetSystemMetrics(SM_CYMENU); if (!settings->bools.video_window_save_positions) return; @@ -638,6 +639,7 @@ static void win32_save_position(void) RECT rect; int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); int title_bar_height = GetSystemMetrics(SM_CYCAPTION); + int menu_bar_height = GetSystemMetrics(SM_CYMENU); WINDOWPLACEMENT placement; settings_t *settings = config_get_ptr(); memset(&placement, 0, sizeof(placement)); @@ -660,7 +662,7 @@ static void win32_save_position(void) settings->uints.window_position_x = g_win32_pos_x; settings->uints.window_position_y = g_win32_pos_y; settings->uints.window_position_width = g_win32_pos_width - border_thickness * 2; - settings->uints.window_position_height = g_win32_pos_height - border_thickness * 2 - title_bar_height; + settings->uints.window_position_height = g_win32_pos_height - border_thickness * 2 - title_bar_height - (settings->bools.ui_menubar_enable ? menu_bar_height : 0); } } } From 5898f3e5d22b930a1050a59b61e98ecd07dd6977 Mon Sep 17 00:00:00 2001 From: orbea Date: Thu, 6 Dec 2018 08:31:01 -0800 Subject: [PATCH 132/153] Fix KMS with OpenGL. All credit for this patch goes to dtsarr. Fixes https://github.com/libretro/RetroArch/issues/7119 --- gfx/common/egl_common.c | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/gfx/common/egl_common.c b/gfx/common/egl_common.c index f3c579af21..ee7bca84b6 100644 --- a/gfx/common/egl_common.c +++ b/gfx/common/egl_common.c @@ -329,8 +329,47 @@ bool egl_init_context(egl_ctx_data_t *egl, RARCH_LOG("[EGL]: EGL version: %d.%d\n", *major, *minor); - if (!eglChooseConfig(egl->dpy, attrib_ptr, &egl->config, 1, n) || *n != 1) + EGLint count = 0; + EGLint matched = 0; + EGLConfig *configs; + int config_index = -1; + + if (!eglGetConfigs(egl->dpy, NULL, 0, &count) || count < 1) + { + RARCH_ERR("[EGL]: No cofigs to choose from.\n"); return false; + } + + configs = malloc(count * sizeof *configs); + if (!configs) return false; + + if (!eglChooseConfig(egl->dpy, attrib_ptr, configs, count, &matched) || !matched) + { + RARCH_ERR("[EGL]: No EGL configs with appropriate attributes.\n"); + return false; + } + + int i; + EGLint id; + + for (i = 0; i < count; ++i) + { + if (!eglGetConfigAttrib(egl->dpy, configs[i], EGL_NATIVE_VISUAL_ID, &id)) + continue; + + if (id == GBM_FORMAT_XRGB8888) break; + } + + if (id != GBM_FORMAT_XRGB8888) + { + RARCH_ERR("[EGL]: No EGL configs with format XRGB8888\n"); + return false; + } + + config_index = i; + if (config_index != -1) egl->config = configs[config_index]; + + free(configs); egl->major = g_egl_major; egl->minor = g_egl_minor; From 763863751855ca733c1ccadb78b9e8e61302e773 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 7 Dec 2018 00:51:56 +0100 Subject: [PATCH 133/153] Cleanups --- gfx/common/egl_common.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/gfx/common/egl_common.c b/gfx/common/egl_common.c index ee7bca84b6..8ae8fee90c 100644 --- a/gfx/common/egl_common.c +++ b/gfx/common/egl_common.c @@ -315,7 +315,12 @@ bool egl_init_context(egl_ctx_data_t *egl, EGLint *major, EGLint *minor, EGLint *n, const EGLint *attrib_ptr) { - EGLDisplay dpy = get_egl_display(platform, display_data); + EGLConfig *configs = NULL; + EGLint count = 0; + EGLint matched = 0; + int config_index = -1; + EGLDisplay dpy = get_egl_display(platform, display_data); + if (dpy == EGL_NO_DISPLAY) { RARCH_ERR("[EGL]: Couldn't get EGL display.\n"); @@ -329,11 +334,6 @@ bool egl_init_context(egl_ctx_data_t *egl, RARCH_LOG("[EGL]: EGL version: %d.%d\n", *major, *minor); - EGLint count = 0; - EGLint matched = 0; - EGLConfig *configs; - int config_index = -1; - if (!eglGetConfigs(egl->dpy, NULL, 0, &count) || count < 1) { RARCH_ERR("[EGL]: No cofigs to choose from.\n"); @@ -343,7 +343,8 @@ bool egl_init_context(egl_ctx_data_t *egl, configs = malloc(count * sizeof *configs); if (!configs) return false; - if (!eglChooseConfig(egl->dpy, attrib_ptr, configs, count, &matched) || !matched) + if (!eglChooseConfig(egl->dpy, attrib_ptr, + configs, count, &matched) || !matched) { RARCH_ERR("[EGL]: No EGL configs with appropriate attributes.\n"); return false; @@ -354,10 +355,12 @@ bool egl_init_context(egl_ctx_data_t *egl, for (i = 0; i < count; ++i) { - if (!eglGetConfigAttrib(egl->dpy, configs[i], EGL_NATIVE_VISUAL_ID, &id)) + if (!eglGetConfigAttrib(egl->dpy, + configs[i], EGL_NATIVE_VISUAL_ID, &id)) continue; - if (id == GBM_FORMAT_XRGB8888) break; + if (id == GBM_FORMAT_XRGB8888) + break; } if (id != GBM_FORMAT_XRGB8888) @@ -367,7 +370,8 @@ bool egl_init_context(egl_ctx_data_t *egl, } config_index = i; - if (config_index != -1) egl->config = configs[config_index]; + if (config_index != -1) + egl->config = configs[config_index]; free(configs); From e27e1114c77088c594c3368c970db941c2f83c03 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Fri, 7 Dec 2018 14:18:43 +0000 Subject: [PATCH 134/153] (3DS) Improve default configuration --- config.def.h | 5 +++++ configuration.c | 7 +++++-- frontend/drivers/platform_ctr.c | 27 ++++++++++++++++++++------- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/config.def.h b/config.def.h index 02fe8569cc..362672ca6b 100644 --- a/config.def.h +++ b/config.def.h @@ -244,6 +244,11 @@ static const bool aspect_ratio_auto = false; static unsigned aspect_ratio_idx = ASPECT_RATIO_16_9; #elif defined(PSP) static unsigned aspect_ratio_idx = ASPECT_RATIO_CORE; +#elif defined(_3DS) +/* Previously defaulted to ASPECT_RATIO_4_3. + * Non-4:3 content looks dreadful when stretched + * to 4:3 on the 3DS screen... */ +static unsigned aspect_ratio_idx = ASPECT_RATIO_CORE; #elif defined(RARCH_CONSOLE) static unsigned aspect_ratio_idx = ASPECT_RATIO_4_3; #else diff --git a/configuration.c b/configuration.c index 4264d236a5..e778f43a09 100644 --- a/configuration.c +++ b/configuration.c @@ -543,6 +543,9 @@ static enum location_driver_enum LOCATION_DEFAULT_DRIVER = LOCATION_CORELOCATION static enum location_driver_enum LOCATION_DEFAULT_DRIVER = LOCATION_NULL; #endif +#if defined(_3DS) && defined(HAVE_RGUI) +static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_RGUI; +#else #if defined(HAVE_XUI) static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_XUI; #elif defined(HAVE_MATERIALUI) && defined(RARCH_MOBILE) @@ -556,7 +559,7 @@ static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_RGUI; #else static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_NULL; #endif - +#endif #define GENERAL_SETTING(key, configval, default_enable, default_setting, type, handle_setting) \ { \ @@ -678,7 +681,7 @@ const char *config_get_default_audio(void) case AUDIO_PS2: return "ps2"; case AUDIO_CTR: - return "csnd"; + return "dsp"; case AUDIO_SWITCH: return "switch"; case AUDIO_RWEBAUDIO: diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index 68110a0f28..58fb331736 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -240,13 +240,15 @@ static void frontend_ctr_exec(const char* path, bool should_load_game) } else { - RARCH_LOG("\n"); - RARCH_LOG("\n"); - RARCH_LOG("Warning:\n"); - RARCH_LOG("First core launch may take 20 seconds!\n"); - RARCH_LOG("Do not force quit before then or your memory card may be corrupted!\n"); - RARCH_LOG("\n"); - RARCH_LOG("\n"); + RARCH_WARN("\n"); + RARCH_WARN("\n"); + RARCH_WARN("Warning:\n"); + RARCH_WARN("First core launch may take 20\n"); + RARCH_WARN("seconds! Do not force quit\n"); + RARCH_WARN("before then or your memory\n"); + RARCH_WARN("card may be corrupted!\n"); + RARCH_WARN("\n"); + RARCH_WARN("\n"); exec_cia(path, arg_data); } @@ -356,6 +358,17 @@ static void ctr_check_dspfirm(void) } fclose(code_fp); } + else + { + RARCH_WARN("\n"); + RARCH_WARN("\n"); + RARCH_WARN("Warning:\n"); + RARCH_WARN("3DS DSP dump is missing.\n"); + RARCH_WARN("A working DSP dump is required\n"); + RARCH_WARN("for correct operation.\n"); + RARCH_WARN("\n"); + RARCH_WARN("\n"); + } } } From 96840572ef116f1f7018901c129de3bb8a7018bb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 7 Dec 2018 20:18:01 +0100 Subject: [PATCH 135/153] Add HAVE_GBM ifdefs --- gfx/common/egl_common.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gfx/common/egl_common.c b/gfx/common/egl_common.c index 8ae8fee90c..16616a566e 100644 --- a/gfx/common/egl_common.c +++ b/gfx/common/egl_common.c @@ -315,6 +315,8 @@ bool egl_init_context(egl_ctx_data_t *egl, EGLint *major, EGLint *minor, EGLint *n, const EGLint *attrib_ptr) { + int i; + EGLint id; EGLConfig *configs = NULL; EGLint count = 0; EGLint matched = 0; @@ -350,24 +352,25 @@ bool egl_init_context(egl_ctx_data_t *egl, return false; } - int i; - EGLint id; - for (i = 0; i < count; ++i) { if (!eglGetConfigAttrib(egl->dpy, configs[i], EGL_NATIVE_VISUAL_ID, &id)) continue; +#ifdef HAVE_GBM if (id == GBM_FORMAT_XRGB8888) break; +#endif } +#ifdef HAVE_GBM if (id != GBM_FORMAT_XRGB8888) { RARCH_ERR("[EGL]: No EGL configs with format XRGB8888\n"); return false; } +#endif config_index = i; if (config_index != -1) From bfd914157718083bfa511e54ccdb894d2d41ee05 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 7 Dec 2018 21:15:38 +0100 Subject: [PATCH 136/153] Play it safe for non-GBM targets --- gfx/common/egl_common.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gfx/common/egl_common.c b/gfx/common/egl_common.c index 16616a566e..b9416d2f13 100644 --- a/gfx/common/egl_common.c +++ b/gfx/common/egl_common.c @@ -336,14 +336,16 @@ bool egl_init_context(egl_ctx_data_t *egl, RARCH_LOG("[EGL]: EGL version: %d.%d\n", *major, *minor); +#ifdef HAVE_GBM if (!eglGetConfigs(egl->dpy, NULL, 0, &count) || count < 1) { - RARCH_ERR("[EGL]: No cofigs to choose from.\n"); + RARCH_ERR("[EGL]: No configs to choose from.\n"); return false; } configs = malloc(count * sizeof *configs); - if (!configs) return false; + if (!configs) + return false; if (!eglChooseConfig(egl->dpy, attrib_ptr, configs, count, &matched) || !matched) @@ -358,25 +360,25 @@ bool egl_init_context(egl_ctx_data_t *egl, configs[i], EGL_NATIVE_VISUAL_ID, &id)) continue; -#ifdef HAVE_GBM if (id == GBM_FORMAT_XRGB8888) break; -#endif } -#ifdef HAVE_GBM if (id != GBM_FORMAT_XRGB8888) { RARCH_ERR("[EGL]: No EGL configs with format XRGB8888\n"); return false; } -#endif config_index = i; if (config_index != -1) egl->config = configs[config_index]; free(configs); +#else + if (!eglChooseConfig(egl->dpy, attrib_ptr, &egl->config, 1, n) || *n != 1) + return false; +#endif egl->major = g_egl_major; egl->minor = g_egl_minor; From 7ed7b7b4362211dec57b7bd0efaaa052e359f21e Mon Sep 17 00:00:00 2001 From: natinusala Date: Sat, 8 Dec 2018 13:27:57 +0100 Subject: [PATCH 137/153] Add more generated Wayland files to gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 1094b5599e..2ca4c1f0f6 100644 --- a/.gitignore +++ b/.gitignore @@ -167,5 +167,7 @@ retroarch_switch.nso # Wayland gfx/common/wayland/idle-inhibit-unstable-v1.c gfx/common/wayland/idle-inhibit-unstable-v1.h +gfx/common/wayland/idle-inhibit-unstable-v6.c +gfx/common/wayland/idle-inhibit-unstable-v6.h gfx/common/wayland/xdg-shell.c gfx/common/wayland/xdg-shell.h From f45154f15c29429693f29dad8b0104803eb7c607 Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Sun, 9 Dec 2018 14:56:36 +0400 Subject: [PATCH 138/153] Add support for zxdg_decoration_manager_v1 --- gfx/drivers_context/wayland_ctx.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index d05c65d321..ca1626330c 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -1094,10 +1094,18 @@ static void gfx_ctx_wl_update_title(void *data, void *data2) video_driver_get_window_title(title, sizeof(title)); if (wl && title[0]) { - if (wl->xdg_toplevel) - xdg_toplevel_set_title(wl->xdg_toplevel, title); - else if (wl->zxdg_toplevel) - zxdg_toplevel_v6_set_title(wl->zxdg_toplevel, title); + if (wl->xdg_toplevel) { + if (wl->deco) { + zxdg_toplevel_decoration_v1_set_mode(wl->deco, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); + } + xdg_toplevel_set_title(wl->xdg_toplevel, title); + } + else if (wl->zxdg_toplevel) { + if (wl->deco) { + zxdg_toplevel_decoration_v1_set_mode(wl->deco, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); + } + zxdg_toplevel_v6_set_title(wl->zxdg_toplevel, title); + } else if (wl->shell_surf) wl_shell_surface_set_title(wl->shell_surf, title); } @@ -1280,6 +1288,11 @@ static void *gfx_ctx_wl_init(video_frame_info_t *video_info, void *video_driver) { RARCH_WARN("[Wayland]: Compositor doesn't support zwp_idle_inhibit_manager_v1 protocol!\n"); } + + if (!wl->deco_manager) + { + RARCH_WARN("[Wayland]: Compositor doesn't support zxdg_decoration_manager_v1 protocol!\n"); + } wl->input.fd = wl_display_get_fd(wl->input.dpy); @@ -1513,6 +1526,11 @@ static bool gfx_ctx_wl_set_video_mode(void *data, xdg_toplevel_set_app_id(wl->xdg_toplevel, "RetroArch"); xdg_toplevel_set_title(wl->xdg_toplevel, "RetroArch"); + if (wl->deco_manager) { + wl->deco = zxdg_decoration_manager_v1_get_toplevel_decoration( + wl->deco_manager, wl->xdg_toplevel); + } + /* Waiting for xdg_toplevel to be configured before starting to draw */ wl_surface_commit(wl->surface); wl->configured = true; @@ -1533,6 +1551,11 @@ static bool gfx_ctx_wl_set_video_mode(void *data, zxdg_toplevel_v6_set_app_id(wl->zxdg_toplevel, "RetroArch"); zxdg_toplevel_v6_set_title(wl->zxdg_toplevel, "RetroArch"); + if (wl->deco_manager) { + wl->deco = zxdg_decoration_manager_v1_get_toplevel_decoration( + wl->deco_manager, wl->xdg_toplevel); + } + /* Waiting for xdg_toplevel to be configured before starting to draw */ wl_surface_commit(wl->surface); wl->configured = true; From 058a880a8b1cffecb5be9b53b4846563e57e4b14 Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Sun, 9 Dec 2018 18:42:45 +0400 Subject: [PATCH 139/153] Add KDE's server-decoration protocol as fallback (for KDE) --- Makefile.common | 3 ++- gfx/common/wayland/generate_wayland_protos.sh | 4 +++ gfx/drivers_context/wayland_ctx.c | 25 ++++++++++++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Makefile.common b/Makefile.common index d400a480fa..c6fbe390f9 100644 --- a/Makefile.common +++ b/Makefile.common @@ -868,7 +868,8 @@ ifeq ($(HAVE_WAYLAND), 1) gfx/common/wayland/xdg-shell.o \ gfx/common/wayland/xdg-shell-unstable-v6.o \ gfx/common/wayland/idle-inhibit-unstable-v1.o \ - gfx/common/wayland/xdg-decoration-unstable-v1.o + gfx/common/wayland/xdg-decoration-unstable-v1.o \ + gfx/common/wayland/server-decorations.o ifeq ($(HAVE_EGL), 1) LIBS += $(EGL_LIBS) endif diff --git a/gfx/common/wayland/generate_wayland_protos.sh b/gfx/common/wayland/generate_wayland_protos.sh index 8c0cc7f155..973b76bc49 100755 --- a/gfx/common/wayland/generate_wayland_protos.sh +++ b/gfx/common/wayland/generate_wayland_protos.sh @@ -22,3 +22,7 @@ $WAYSCAN private-code $WAYLAND_PROTOS/unstable/idle-inhibit/idle-inhibit-unstabl #Generate xdg-decoration header and .c files $WAYSCAN client-header $WAYLAND_PROTOS/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml $OUTPUT/xdg-decoration-unstable-v1.h $WAYSCAN private-code $WAYLAND_PROTOS/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml $OUTPUT/xdg-decoration-unstable-v1.c + +#Generate server-decorations header and .c files +$WAYSCAN client-header gfx/common/wayland/server-decoration.xml $OUTPUT/server-decorations.h +$WAYSCAN private-code gfx/common/wayland/server-decoration.xml $OUTPUT/server-decorations.c diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index ca1626330c..23378e913a 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -59,6 +59,9 @@ /* Generated from xdg-decoration-unstable-v1.h */ #include "../common/wayland/xdg-decoration-unstable-v1.h" +/* Generated from server-decoration.xml */ +#include "../common/wayland/server-decorations.h" + typedef struct touch_pos { @@ -106,6 +109,8 @@ typedef struct gfx_ctx_wayland_data struct wl_touch *wl_touch; struct wl_seat *seat; struct wl_shm *shm; + struct org_kde_kwin_server_decoration *server_deco; + struct org_kde_kwin_server_decoration_manager *server_deco_manager; struct zxdg_decoration_manager_v1 *deco_manager; struct zxdg_toplevel_decoration_v1 *deco; struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager; @@ -850,6 +855,9 @@ static void registry_handle_global(void *data, struct wl_registry *reg, else if (string_is_equal(interface, "zxdg_decoration_manager_v1")) wl->deco_manager = (struct zxdg_decoration_manager_v1*)wl_registry_bind( reg, id, &zxdg_decoration_manager_v1_interface, 1); + else if (string_is_equal(interface, "org_kde_kwin_server_decoration_manager")) + wl->server_deco_manager = (struct org_kde_kwin_server_decoration_manager*)wl_registry_bind( + reg, id, &org_kde_kwin_server_decoration_interface, 1); } static void registry_handle_global_remove(void *data, @@ -950,6 +958,8 @@ static void gfx_ctx_wl_destroy_resources(gfx_ctx_wayland_data_t *wl) zxdg_toplevel_decoration_v1_destroy(wl->deco); if (wl->deco_manager) zxdg_decoration_manager_v1_destroy(wl->deco_manager); + if (wl->server_deco) + org_kde_kwin_server_decoration_destroy(wl->server_deco); if (wl->idle_inhibitor) zwp_idle_inhibitor_v1_destroy(wl->idle_inhibitor); @@ -1097,13 +1107,17 @@ static void gfx_ctx_wl_update_title(void *data, void *data2) if (wl->xdg_toplevel) { if (wl->deco) { zxdg_toplevel_decoration_v1_set_mode(wl->deco, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); + } else if (wl->server_deco) { + org_kde_kwin_server_decoration_request_mode(wl->server_deco, ORG_KDE_KWIN_SERVER_DECORATION_MODE_SERVER); } xdg_toplevel_set_title(wl->xdg_toplevel, title); } else if (wl->zxdg_toplevel) { if (wl->deco) { zxdg_toplevel_decoration_v1_set_mode(wl->deco, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); - } + } else if (wl->server_deco) { + org_kde_kwin_server_decoration_request_mode(wl->server_deco, ORG_KDE_KWIN_SERVER_DECORATION_MODE_SERVER); + } zxdg_toplevel_v6_set_title(wl->zxdg_toplevel, title); } else if (wl->shell_surf) @@ -1293,6 +1307,11 @@ static void *gfx_ctx_wl_init(video_frame_info_t *video_info, void *video_driver) { RARCH_WARN("[Wayland]: Compositor doesn't support zxdg_decoration_manager_v1 protocol!\n"); } + + if (!wl->server_deco_manager) + { + RARCH_WARN("[Wayland]: Compositor doesn't support org_kde_kwin_server_decoration_manager protocol!\n"); + } wl->input.fd = wl_display_get_fd(wl->input.dpy); @@ -1529,6 +1548,8 @@ static bool gfx_ctx_wl_set_video_mode(void *data, if (wl->deco_manager) { wl->deco = zxdg_decoration_manager_v1_get_toplevel_decoration( wl->deco_manager, wl->xdg_toplevel); + } else if (wl->server_deco_manager) { + wl->server_deco = org_kde_kwin_server_decoration_manager_create(wl->server_deco_manager, wl->surface); } /* Waiting for xdg_toplevel to be configured before starting to draw */ @@ -1554,6 +1575,8 @@ static bool gfx_ctx_wl_set_video_mode(void *data, if (wl->deco_manager) { wl->deco = zxdg_decoration_manager_v1_get_toplevel_decoration( wl->deco_manager, wl->xdg_toplevel); + } else if (wl->server_deco_manager) { + wl->server_deco = org_kde_kwin_server_decoration_manager_create(wl->server_deco_manager, wl->surface); } /* Waiting for xdg_toplevel to be configured before starting to draw */ From d1c15efc2486ff102e360b8fd729cec64ee90cef Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Sun, 9 Dec 2018 18:47:47 +0400 Subject: [PATCH 140/153] Revert "Add KDE's server-decoration protocol as fallback (for KDE)" This reverts commit 058a880a8b1cffecb5be9b53b4846563e57e4b14. --- Makefile.common | 3 +-- gfx/common/wayland/generate_wayland_protos.sh | 4 --- gfx/drivers_context/wayland_ctx.c | 25 +------------------ 3 files changed, 2 insertions(+), 30 deletions(-) diff --git a/Makefile.common b/Makefile.common index c6fbe390f9..d400a480fa 100644 --- a/Makefile.common +++ b/Makefile.common @@ -868,8 +868,7 @@ ifeq ($(HAVE_WAYLAND), 1) gfx/common/wayland/xdg-shell.o \ gfx/common/wayland/xdg-shell-unstable-v6.o \ gfx/common/wayland/idle-inhibit-unstable-v1.o \ - gfx/common/wayland/xdg-decoration-unstable-v1.o \ - gfx/common/wayland/server-decorations.o + gfx/common/wayland/xdg-decoration-unstable-v1.o ifeq ($(HAVE_EGL), 1) LIBS += $(EGL_LIBS) endif diff --git a/gfx/common/wayland/generate_wayland_protos.sh b/gfx/common/wayland/generate_wayland_protos.sh index 973b76bc49..8c0cc7f155 100755 --- a/gfx/common/wayland/generate_wayland_protos.sh +++ b/gfx/common/wayland/generate_wayland_protos.sh @@ -22,7 +22,3 @@ $WAYSCAN private-code $WAYLAND_PROTOS/unstable/idle-inhibit/idle-inhibit-unstabl #Generate xdg-decoration header and .c files $WAYSCAN client-header $WAYLAND_PROTOS/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml $OUTPUT/xdg-decoration-unstable-v1.h $WAYSCAN private-code $WAYLAND_PROTOS/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml $OUTPUT/xdg-decoration-unstable-v1.c - -#Generate server-decorations header and .c files -$WAYSCAN client-header gfx/common/wayland/server-decoration.xml $OUTPUT/server-decorations.h -$WAYSCAN private-code gfx/common/wayland/server-decoration.xml $OUTPUT/server-decorations.c diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 23378e913a..ca1626330c 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -59,9 +59,6 @@ /* Generated from xdg-decoration-unstable-v1.h */ #include "../common/wayland/xdg-decoration-unstable-v1.h" -/* Generated from server-decoration.xml */ -#include "../common/wayland/server-decorations.h" - typedef struct touch_pos { @@ -109,8 +106,6 @@ typedef struct gfx_ctx_wayland_data struct wl_touch *wl_touch; struct wl_seat *seat; struct wl_shm *shm; - struct org_kde_kwin_server_decoration *server_deco; - struct org_kde_kwin_server_decoration_manager *server_deco_manager; struct zxdg_decoration_manager_v1 *deco_manager; struct zxdg_toplevel_decoration_v1 *deco; struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager; @@ -855,9 +850,6 @@ static void registry_handle_global(void *data, struct wl_registry *reg, else if (string_is_equal(interface, "zxdg_decoration_manager_v1")) wl->deco_manager = (struct zxdg_decoration_manager_v1*)wl_registry_bind( reg, id, &zxdg_decoration_manager_v1_interface, 1); - else if (string_is_equal(interface, "org_kde_kwin_server_decoration_manager")) - wl->server_deco_manager = (struct org_kde_kwin_server_decoration_manager*)wl_registry_bind( - reg, id, &org_kde_kwin_server_decoration_interface, 1); } static void registry_handle_global_remove(void *data, @@ -958,8 +950,6 @@ static void gfx_ctx_wl_destroy_resources(gfx_ctx_wayland_data_t *wl) zxdg_toplevel_decoration_v1_destroy(wl->deco); if (wl->deco_manager) zxdg_decoration_manager_v1_destroy(wl->deco_manager); - if (wl->server_deco) - org_kde_kwin_server_decoration_destroy(wl->server_deco); if (wl->idle_inhibitor) zwp_idle_inhibitor_v1_destroy(wl->idle_inhibitor); @@ -1107,17 +1097,13 @@ static void gfx_ctx_wl_update_title(void *data, void *data2) if (wl->xdg_toplevel) { if (wl->deco) { zxdg_toplevel_decoration_v1_set_mode(wl->deco, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); - } else if (wl->server_deco) { - org_kde_kwin_server_decoration_request_mode(wl->server_deco, ORG_KDE_KWIN_SERVER_DECORATION_MODE_SERVER); } xdg_toplevel_set_title(wl->xdg_toplevel, title); } else if (wl->zxdg_toplevel) { if (wl->deco) { zxdg_toplevel_decoration_v1_set_mode(wl->deco, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); - } else if (wl->server_deco) { - org_kde_kwin_server_decoration_request_mode(wl->server_deco, ORG_KDE_KWIN_SERVER_DECORATION_MODE_SERVER); - } + } zxdg_toplevel_v6_set_title(wl->zxdg_toplevel, title); } else if (wl->shell_surf) @@ -1307,11 +1293,6 @@ static void *gfx_ctx_wl_init(video_frame_info_t *video_info, void *video_driver) { RARCH_WARN("[Wayland]: Compositor doesn't support zxdg_decoration_manager_v1 protocol!\n"); } - - if (!wl->server_deco_manager) - { - RARCH_WARN("[Wayland]: Compositor doesn't support org_kde_kwin_server_decoration_manager protocol!\n"); - } wl->input.fd = wl_display_get_fd(wl->input.dpy); @@ -1548,8 +1529,6 @@ static bool gfx_ctx_wl_set_video_mode(void *data, if (wl->deco_manager) { wl->deco = zxdg_decoration_manager_v1_get_toplevel_decoration( wl->deco_manager, wl->xdg_toplevel); - } else if (wl->server_deco_manager) { - wl->server_deco = org_kde_kwin_server_decoration_manager_create(wl->server_deco_manager, wl->surface); } /* Waiting for xdg_toplevel to be configured before starting to draw */ @@ -1575,8 +1554,6 @@ static bool gfx_ctx_wl_set_video_mode(void *data, if (wl->deco_manager) { wl->deco = zxdg_decoration_manager_v1_get_toplevel_decoration( wl->deco_manager, wl->xdg_toplevel); - } else if (wl->server_deco_manager) { - wl->server_deco = org_kde_kwin_server_decoration_manager_create(wl->server_deco_manager, wl->surface); } /* Waiting for xdg_toplevel to be configured before starting to draw */ From 613e3f265549772089873c83f7ac3037deb5f7ba Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Sun, 9 Dec 2018 18:55:30 +0400 Subject: [PATCH 141/153] Add generated wayland-protocols to .gitignore --- .gitignore | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.gitignore b/.gitignore index 28188376c9..369bb4d452 100644 --- a/.gitignore +++ b/.gitignore @@ -163,3 +163,13 @@ retroarch_switch.lst retroarch_switch.nacp retroarch_switch.nro retroarch_switch.nso + +# Wayland +gfx/common/wayland/idle-inhibit-unstable-v1.c +gfx/common/wayland/idle-inhibit-unstable-v1.h +gfx/common/wayland/xdg-shell-unstable-v6.c +gfx/common/wayland/xdg-shell-unstable-v6.h +gfx/common/wayland/xdg-decoration-unstable-v1.h +gfx/common/wayland/xdg-decoration-unstable-v1.c +gfx/common/wayland/xdg-shell.c +gfx/common/wayland/xdg-shell.h From 27f2cc0bff80b08cd65564cbe018152eabc3c0f8 Mon Sep 17 00:00:00 2001 From: Sunderland93 Date: Sun, 9 Dec 2018 19:28:45 +0400 Subject: [PATCH 142/153] Increase minimal Wayland version to 1.15 --- qb/config.libs.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qb/config.libs.sh b/qb/config.libs.sh index ba8c62dad5..9542d643ab 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -455,8 +455,8 @@ check_pkgconf V4L2 libv4l2 check_pkgconf FREETYPE freetype2 check_pkgconf X11 x11 check_pkgconf XCB xcb -check_pkgconf WAYLAND wayland-egl 1.14 -check_pkgconf WAYLAND_CURSOR wayland-cursor 1.14 +check_pkgconf WAYLAND wayland-egl 1.15 +check_pkgconf WAYLAND_CURSOR wayland-cursor 1.15 check_pkgconf WAYLAND_PROTOS wayland-protocols 1.15 check_pkgconf XKBCOMMON xkbcommon 0.3.2 check_pkgconf DBUS dbus-1 @@ -474,7 +474,7 @@ check_val '' XEXT -lXext check_val '' XF86VM -lXxf86vm if [ "$HAVE_WAYLAND_PROTOS" = yes ] && [ "$HAVE_WAYLAND" = yes ]; then - check_pkgconf WAYLAND_SCANNER wayland-scanner 1.13 + check_pkgconf WAYLAND_SCANNER wayland-scanner 1.15 ./gfx/common/wayland/generate_wayland_protos.sh else die : 'Notice: wayland-egl or wayland-protocols not present. Skiping Wayland code paths.' From 23bbcdf8cef049979ed117755b02012f1872c7eb Mon Sep 17 00:00:00 2001 From: orbea Date: Sun, 9 Dec 2018 17:42:15 -0800 Subject: [PATCH 143/153] menu: Add "Show Reset Core Association". This can be found at: Settings -> User Interface -> Views -> Quick Menu -> Show Reset Core Association This could be helpful for child friendly devices where someone may accidentally reset the core and then not now which core they were using before or how to set it again. Also fixes an issue where "Show Add To Favorites" hides "Reset Core Association" when that is not desired or expected. Fixes https://github.com/libretro/RetroArch/issues/7714 --- config.def.h | 1 + configuration.c | 1 + configuration.h | 1 + intl/msg_hash_ar.h | 4 ++++ intl/msg_hash_chs.h | 4 ++++ intl/msg_hash_cht.h | 4 ++++ intl/msg_hash_de.h | 4 ++++ intl/msg_hash_el.h | 8 ++++++++ intl/msg_hash_eo.h | 4 ++++ intl/msg_hash_es.h | 8 ++++++++ intl/msg_hash_fr.h | 4 ++++ intl/msg_hash_it.h | 4 ++++ intl/msg_hash_ja.h | 4 ++++ intl/msg_hash_ko.h | 4 ++++ intl/msg_hash_lbl.h | 2 ++ intl/msg_hash_nl.h | 4 ++++ intl/msg_hash_pl.h | 4 ++++ intl/msg_hash_pt_br.h | 8 ++++++++ intl/msg_hash_pt_pt.h | 4 ++++ intl/msg_hash_ru.h | 4 ++++ intl/msg_hash_us.h | 8 ++++++++ intl/msg_hash_vn.h | 4 ++++ menu/cbs/menu_cbs_sublabel.c | 4 ++++ menu/menu_displaylist.c | 6 +++++- menu/menu_setting.c | 15 +++++++++++++++ msg_hash.h | 1 + 26 files changed, 118 insertions(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 362672ca6b..f3dcfa0078 100644 --- a/config.def.h +++ b/config.def.h @@ -285,6 +285,7 @@ static bool quick_menu_show_take_screenshot = true; static bool quick_menu_show_save_load_state = true; static bool quick_menu_show_undo_save_load_state = true; static bool quick_menu_show_add_to_favorites = true; +static bool quick_menu_show_reset_core_association = true; static bool quick_menu_show_options = true; static bool quick_menu_show_controls = true; static bool quick_menu_show_cheats = true; diff --git a/configuration.c b/configuration.c index e778f43a09..b8d3896d3f 100644 --- a/configuration.c +++ b/configuration.c @@ -1402,6 +1402,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, SETTING_BOOL("quick_menu_show_save_load_state", &settings->bools.quick_menu_show_save_load_state, true, quick_menu_show_save_load_state, false); SETTING_BOOL("quick_menu_show_undo_save_load_state", &settings->bools.quick_menu_show_undo_save_load_state, true, quick_menu_show_undo_save_load_state, false); SETTING_BOOL("quick_menu_show_add_to_favorites", &settings->bools.quick_menu_show_add_to_favorites, true, quick_menu_show_add_to_favorites, false); + SETTING_BOOL("quick_menu_show_reset_core_association", &settings->bools.quick_menu_show_reset_core_association, true, quick_menu_show_reset_core_association, false); SETTING_BOOL("quick_menu_show_options", &settings->bools.quick_menu_show_options, true, quick_menu_show_options, false); SETTING_BOOL("quick_menu_show_controls", &settings->bools.quick_menu_show_controls, true, quick_menu_show_controls, false); SETTING_BOOL("quick_menu_show_cheats", &settings->bools.quick_menu_show_cheats, true, quick_menu_show_cheats, false); diff --git a/configuration.h b/configuration.h index 456fe8b953..16930cf1a1 100644 --- a/configuration.h +++ b/configuration.h @@ -184,6 +184,7 @@ typedef struct settings bool quick_menu_show_save_load_state; bool quick_menu_show_undo_save_load_state; bool quick_menu_show_add_to_favorites; + bool quick_menu_show_reset_core_association; bool quick_menu_show_options; bool quick_menu_show_controls; bool quick_menu_show_cheats; diff --git a/intl/msg_hash_ar.h b/intl/msg_hash_ar.h index b4ba128781..d16d7dbe7b 100644 --- a/intl/msg_hash_ar.h +++ b/intl/msg_hash_ar.h @@ -3369,6 +3369,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Show Add to Favorites") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Show/hide the 'Add to Favorites' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show Reset Core Association") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show/hide the 'Reset Core Association' option.") MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_OPTIONS, "Show Options") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_OPTIONS, diff --git a/intl/msg_hash_chs.h b/intl/msg_hash_chs.h index 328c18d273..c1a67fc089 100644 --- a/intl/msg_hash_chs.h +++ b/intl/msg_hash_chs.h @@ -3646,6 +3646,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "显示「添加到收藏夹」") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "显示或隐藏「添加到收藏夹」选项。") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show Reset Core Association") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show/hide the 'Reset Core Association' option.") MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_OPTIONS, "显示「核心选项」") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_OPTIONS, diff --git a/intl/msg_hash_cht.h b/intl/msg_hash_cht.h index ad767dcb25..2a70764f89 100644 --- a/intl/msg_hash_cht.h +++ b/intl/msg_hash_cht.h @@ -3177,6 +3177,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "顯示 Add to Favorites") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "顯示/隱藏 the 'Add to Favorites' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show Reset Core Association") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show/hide the 'Reset Core Association' option.") MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_OPTIONS, "顯示 Options") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_OPTIONS, diff --git a/intl/msg_hash_de.h b/intl/msg_hash_de.h index 48ab449e73..0c7e2d15a8 100644 --- a/intl/msg_hash_de.h +++ b/intl/msg_hash_de.h @@ -3297,6 +3297,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Zeige 'Zu Favoriten hinzufügen'") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Zeige/verstecke die Option 'Zu Favoriten hinzufügen'.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show Reset Core Association") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show/hide the 'Reset Core Association' option.") MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_OPTIONS, "Zeige 'Optionen'") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_OPTIONS, diff --git a/intl/msg_hash_el.h b/intl/msg_hash_el.h index c614822049..f7a4cf468e 100644 --- a/intl/msg_hash_el.h +++ b/intl/msg_hash_el.h @@ -6098,6 +6098,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Show/hide the 'Add to Favorites' option." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show Reset Core Association" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show/hide the 'Reset Core Association' option." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_OPTIONS, "Show Options" diff --git a/intl/msg_hash_eo.h b/intl/msg_hash_eo.h index b4eda865a4..06ac75250e 100644 --- a/intl/msg_hash_eo.h +++ b/intl/msg_hash_eo.h @@ -3052,6 +3052,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Show Add to Favorites") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Show/hide the 'Add to Favorites' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show Reset Core Association") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show/hide the 'Reset Core Association' option.") MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_OPTIONS, "Show Options") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_OPTIONS, diff --git a/intl/msg_hash_es.h b/intl/msg_hash_es.h index f3e9d8b2d3..aca567dfcb 100644 --- a/intl/msg_hash_es.h +++ b/intl/msg_hash_es.h @@ -6101,6 +6101,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Mostrar/ocultar la opción de 'Agregar a favoritos'" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show Reset Core Association" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show/hide the 'Reset Core Association' option." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_OPTIONS, "Mostrar opciones" diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index 0d2de27a1b..d73c584f7e 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -3211,6 +3211,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Show Add to Favorites") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Show/hide the 'Add to Favorites' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show Reset Core Association") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show/hide the 'Reset Core Association' option.") MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_OPTIONS, "Show Options") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_OPTIONS, diff --git a/intl/msg_hash_it.h b/intl/msg_hash_it.h index 053e67d894..ad0cafed43 100644 --- a/intl/msg_hash_it.h +++ b/intl/msg_hash_it.h @@ -3271,6 +3271,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Visualizza Aggiungi a Preferiti") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Mostra/nasconde l'opzione Aggiungi a Preferiti.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show Reset Core Association") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show/hide the 'Reset Core Association' option.") MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_OPTIONS, "Visualizza Opzioni") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_OPTIONS, diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index e0619ed04d..2fa257e0d4 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -3397,6 +3397,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "「お気に入りに追加」を表示") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "「お気に入りに追加」オプションを表示/非表示にする。") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show Reset Core Association") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show/hide the 'Reset Core Association' option.") MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_OPTIONS, "「オプション」を表示") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_OPTIONS, diff --git a/intl/msg_hash_ko.h b/intl/msg_hash_ko.h index 1a16c5793d..9442c78d3b 100644 --- a/intl/msg_hash_ko.h +++ b/intl/msg_hash_ko.h @@ -3172,6 +3172,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Show Add to Favorites") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Show/hide the 'Add to Favorites' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show Reset Core Association") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show/hide the 'Reset Core Association' option.") MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_OPTIONS, "Show Options") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_OPTIONS, diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index d3d3be35a9..55bada0865 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -1515,6 +1515,8 @@ MSG_HASH(MENU_ENUM_LABEL_QUICK_MENU_SHOW_UNDO_SAVE_LOAD_STATE, "quick_menu_show_undo_save_load_state") MSG_HASH(MENU_ENUM_LABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "quick_menu_show_add_to_favorites") +MSG_HASH(MENU_ENUM_LABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "quick_menu_show_reset_core_association") MSG_HASH(MENU_ENUM_LABEL_QUICK_MENU_SHOW_OPTIONS, "quick_menu_show_options") MSG_HASH(MENU_ENUM_LABEL_QUICK_MENU_SHOW_CONTROLS, diff --git a/intl/msg_hash_nl.h b/intl/msg_hash_nl.h index e1ffd5b701..5b84c6c849 100644 --- a/intl/msg_hash_nl.h +++ b/intl/msg_hash_nl.h @@ -3066,6 +3066,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Show Add to Favorites") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Show/hide the 'Add to Favorites' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show Reset Core Association") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show/hide the 'Reset Core Association' option.") MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_OPTIONS, "Toon Opties") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_OPTIONS, diff --git a/intl/msg_hash_pl.h b/intl/msg_hash_pl.h index bc78042eb3..0de82669c5 100644 --- a/intl/msg_hash_pl.h +++ b/intl/msg_hash_pl.h @@ -3438,6 +3438,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Pokaż dodaj do ulubionych") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Pokaż/ukryj opcję 'Dodaj do ulubionych'.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show Reset Core Association") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show/hide the 'Reset Core Association' option.") MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_OPTIONS, "Pokaż opcje") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_OPTIONS, diff --git a/intl/msg_hash_pt_br.h b/intl/msg_hash_pt_br.h index 0dd39c521a..a9c4bc8d89 100644 --- a/intl/msg_hash_pt_br.h +++ b/intl/msg_hash_pt_br.h @@ -6133,6 +6133,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Exibir/ocultar a opção 'Adicionar aos Favoritos'." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show Reset Core Association" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show/hide the 'Reset Core Association' option." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_OPTIONS, "Exibir Opções" diff --git a/intl/msg_hash_pt_pt.h b/intl/msg_hash_pt_pt.h index 6aa36f56d5..6b05ed4ea2 100644 --- a/intl/msg_hash_pt_pt.h +++ b/intl/msg_hash_pt_pt.h @@ -3146,6 +3146,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Mostrar 'Adicionar aos favoritos'") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Mostrar/esconder a opção 'Adicionar aos favoritos'.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show Reset Core Association") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show/hide the 'Reset Core Association' option.") MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_OPTIONS, "Mostrar 'Opções'") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_OPTIONS, diff --git a/intl/msg_hash_ru.h b/intl/msg_hash_ru.h index 51d2ef1e6f..ba735cba78 100644 --- a/intl/msg_hash_ru.h +++ b/intl/msg_hash_ru.h @@ -3220,6 +3220,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Показать Добавить в избранное") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Показать/скрыть настройку 'Добавить в избранное'.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show Reset Core Association") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show/hide the 'Reset Core Association' option.") MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_OPTIONS, "Показать Настройки") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_OPTIONS, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 6fa546fe67..4af01c43d0 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -6157,6 +6157,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Show/hide the 'Add to Favorites' option." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show Reset Core Association" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show/hide the 'Reset Core Association' option." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_OPTIONS, "Show Options" diff --git a/intl/msg_hash_vn.h b/intl/msg_hash_vn.h index e1c45a5d7e..b0ec9bed99 100644 --- a/intl/msg_hash_vn.h +++ b/intl/msg_hash_vn.h @@ -3209,6 +3209,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Show Add to Favorites") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, "Show/hide the 'Add to Favorites' option.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show Reset Core Association") +MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + "Show/hide the 'Reset Core Association' option.") MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_OPTIONS, "Show Options") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_OPTIONS, diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 2a95e163d8..1079c997cf 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -388,6 +388,7 @@ default_sublabel_macro(action_bind_sublabel_quick_menu_show_take_screenshot, default_sublabel_macro(action_bind_sublabel_quick_menu_show_save_load_state, MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_SAVE_LOAD_STATE) default_sublabel_macro(action_bind_sublabel_quick_menu_show_undo_save_load_state, MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_UNDO_SAVE_LOAD_STATE) default_sublabel_macro(action_bind_sublabel_quick_menu_show_add_to_favorites, MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES) +default_sublabel_macro(action_bind_sublabel_quick_menu_show_reset_core_association, MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION) default_sublabel_macro(action_bind_sublabel_quick_menu_show_options, MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_OPTIONS) default_sublabel_macro(action_bind_sublabel_quick_menu_show_controls, MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_CONTROLS) default_sublabel_macro(action_bind_sublabel_quick_menu_show_cheats, MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_CHEATS) @@ -988,6 +989,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_quick_menu_show_add_to_favorites); break; + case MENU_ENUM_LABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_quick_menu_show_reset_core_association); + break; case MENU_ENUM_LABEL_QUICK_MENU_SHOW_OPTIONS: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_quick_menu_show_options); break; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index e314c8ac54..ec709d8b97 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2887,7 +2887,7 @@ static int menu_displaylist_parse_horizontal_content_actions( MENU_ENUM_LABEL_ADD_TO_FAVORITES_PLAYLIST, FILE_TYPE_PLAYLIST_ENTRY, 0, 0); } - if (settings->bools.quick_menu_show_add_to_favorites) + if (settings->bools.quick_menu_show_reset_core_association) { menu_entries_append_enum(info->list, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RESET_CORE_ASSOCIATION), @@ -5834,6 +5834,10 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist MENU_ENUM_LABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES, PARSE_ONLY_BOOL, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + PARSE_ONLY_BOOL, false); + menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_QUICK_MENU_SHOW_OPTIONS, PARSE_ONLY_BOOL, false); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index daf67f6100..1889ea6291 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -8867,6 +8867,21 @@ static bool setting_append_list( general_read_handler, SD_FLAG_NONE); + CONFIG_BOOL( + list, list_info, + &settings->bools.quick_menu_show_reset_core_association, + MENU_ENUM_LABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, + quick_menu_show_reset_core_association, + MENU_ENUM_LABEL_VALUE_OFF, + MENU_ENUM_LABEL_VALUE_ON, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler, + SD_FLAG_NONE); + #if 0 CONFIG_BOOL( list, list_info, diff --git a/msg_hash.h b/msg_hash.h index 326c32c92e..46573e29ca 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -859,6 +859,7 @@ enum msg_hash_enums MENU_LABEL(QUICK_MENU_SHOW_SAVE_LOAD_STATE), MENU_LABEL(QUICK_MENU_SHOW_UNDO_SAVE_LOAD_STATE), MENU_LABEL(QUICK_MENU_SHOW_ADD_TO_FAVORITES), + MENU_LABEL(QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION), MENU_LABEL(QUICK_MENU_SHOW_OPTIONS), MENU_LABEL(QUICK_MENU_SHOW_CONTROLS), MENU_LABEL(QUICK_MENU_SHOW_CHEATS), From 51c9914cbb19dfb76fda9e25a117eaa8407c6cee Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Sun, 9 Dec 2018 22:15:45 -0500 Subject: [PATCH 144/153] add montreal MITM server for radius --- network/netplay/netplay.h | 1 + 1 file changed, 1 insertion(+) diff --git a/network/netplay/netplay.h b/network/netplay/netplay.h index 06428696e8..23536bdbbc 100644 --- a/network/netplay/netplay.h +++ b/network/netplay/netplay.h @@ -37,6 +37,7 @@ typedef struct mitm_server { static const mitm_server_t netplay_mitm_server_list[] = { { "nyc", "New York City, USA" }, { "madrid", "Madrid, Spain" }, + { "montreal", "Montreal, Canada" }, }; enum rarch_netplay_ctl_state From 11391d601c848a2479dfa77a602aeb8db79310e4 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Mon, 10 Dec 2018 17:01:13 +0000 Subject: [PATCH 145/153] Hide 'scan content' entries from Collections menu when 'Show Import content Tab' is disabled (RGUI, GLUI) --- menu/menu_displaylist.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index ec709d8b97..b97034d1f0 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -3458,16 +3458,19 @@ static int menu_displaylist_parse_playlists( if (!horizontal) { #ifdef HAVE_LIBRETRODB - menu_entries_append_enum(info->list, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SCAN_DIRECTORY), - msg_hash_to_str(MENU_ENUM_LABEL_SCAN_DIRECTORY), - MENU_ENUM_LABEL_SCAN_DIRECTORY, - MENU_SETTING_ACTION, 0, 0); - menu_entries_append_enum(info->list, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SCAN_FILE), - msg_hash_to_str(MENU_ENUM_LABEL_SCAN_FILE), - MENU_ENUM_LABEL_SCAN_FILE, - MENU_SETTING_ACTION, 0, 0); + if (settings->bools.menu_content_show_add) + { + menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SCAN_DIRECTORY), + msg_hash_to_str(MENU_ENUM_LABEL_SCAN_DIRECTORY), + MENU_ENUM_LABEL_SCAN_DIRECTORY, + MENU_SETTING_ACTION, 0, 0); + menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SCAN_FILE), + msg_hash_to_str(MENU_ENUM_LABEL_SCAN_FILE), + MENU_ENUM_LABEL_SCAN_FILE, + MENU_SETTING_ACTION, 0, 0); + } #endif if (settings->bools.menu_content_show_favorites) menu_entries_append_enum(info->list, From cad5ae287f8e5368cc1194ddbf96b85303634fd5 Mon Sep 17 00:00:00 2001 From: radius Date: Mon, 10 Dec 2018 21:38:30 -0500 Subject: [PATCH 146/153] fix https://github.com/libretro/fbalpha/issues/24#issuecomment-445803876 --- command.c | 4 ++-- dynamic.c | 29 ++++++++++++++++++----------- dynamic.h | 11 ++++++++--- menu/cbs/menu_cbs_sublabel.c | 7 ++++--- menu/drivers/ozone/ozone.c | 4 ++-- menu/drivers/xmb.c | 4 ++-- menu/widgets/menu_filebrowser.c | 4 ++-- tasks/task_content.c | 6 +++--- 8 files changed, 41 insertions(+), 28 deletions(-) diff --git a/command.c b/command.c index 983bd8aae2..dcc37f7575 100644 --- a/command.c +++ b/command.c @@ -1901,7 +1901,7 @@ bool command_event(enum event_command cmd, void *data) case CMD_EVENT_LOAD_CORE: { bool success = false; - subsystem_size = 0; + subsystem_current_count = 0; content_clear_subsystem(); success = command_event(CMD_EVENT_LOAD_CORE_PERSIST, NULL); (void)success; @@ -2045,7 +2045,7 @@ bool command_event(enum event_command cmd, void *data) #endif if (is_inited) { - subsystem_size = 0; + subsystem_current_count = 0; content_clear_subsystem(); } } diff --git a/dynamic.c b/dynamic.c index a3092dd8cd..274d5c61a5 100644 --- a/dynamic.c +++ b/dynamic.c @@ -188,7 +188,7 @@ static bool environ_cb_get_system_info(unsigned cmd, void *data) unsigned size = i; const struct retro_subsystem_info *info = (const struct retro_subsystem_info*)data; - subsystem_size = 0; + subsystem_current_count = 0; RARCH_LOG("Environ SET_SUBSYSTEM_INFO.\n"); for (i = 0; info[i].ident; i++) @@ -207,18 +207,24 @@ static bool environ_cb_get_system_info(unsigned cmd, void *data) } RARCH_LOG("Subsystems: %d\n", i); - size = i; + size = i; + + if (size > SUBSYSTEM_MAX_SUBSYSTEMS) + RARCH_WARN("Subsystems exceed subsystem max, clamping to %d\n", SUBSYSTEM_MAX_SUBSYSTEMS); if (system) { - for (i = 0; i < size; i++) + for (i = 0; i < size && i < SUBSYSTEM_MAX_SUBSYSTEMS; i++) { subsystem_data[i].desc = strdup(info[i].desc); subsystem_data[i].ident = strdup(info[i].ident); subsystem_data[i].id = info[i].id; subsystem_data[i].num_roms = info[i].num_roms; - for (j = 0; j < subsystem_data[i].num_roms; j++) + if (subsystem_data[i].num_roms > SUBSYSTEM_MAX_SUBSYSTEM_ROMS) + RARCH_WARN("Subsystems exceed subsystem max roms, clamping to %d\n", SUBSYSTEM_MAX_SUBSYSTEM_ROMS); + + for (j = 0; j < subsystem_data[i].num_roms && j < SUBSYSTEM_MAX_SUBSYSTEM_ROMS; j++) { subsystem_data_roms[i][j].desc = strdup(info[i].roms[j].desc); subsystem_data_roms[i][j].valid_extensions = strdup(info[i].roms[j].valid_extensions); @@ -229,15 +235,19 @@ static bool environ_cb_get_system_info(unsigned cmd, void *data) subsystem_data[i].roms = subsystem_data_roms[i]; } - for (i = 0; i < size; i++) + + subsystem_current_count = size <= SUBSYSTEM_MAX_SUBSYSTEMS ? size : SUBSYSTEM_MAX_SUBSYSTEMS; +#if 0 + RARCH_LOG("Subsystems: %d\n", subsystem_current_count); + + for (i = 0; i < subsystem_current_count; i++) { -#if 1 RARCH_LOG("Subsystem ID: %d\n", i); RARCH_LOG("Special game type: %s\n", subsystem_data[i].desc); RARCH_LOG(" Ident: %s\n", subsystem_data[i].ident); RARCH_LOG(" ID: %u\n", subsystem_data[i].id); RARCH_LOG(" Content:\n"); -#endif + for (j = 0; j < subsystem_data[i].num_roms; j++) { RARCH_LOG(" %s (%s)\n", @@ -245,9 +255,7 @@ static bool environ_cb_get_system_info(unsigned cmd, void *data) "required" : "optional"); } } - RARCH_LOG("Subsystems: %d\n", subsystem_size); - subsystem_size = size; - RARCH_LOG("Subsystems: %d\n", subsystem_size); +#endif } break; } @@ -1461,7 +1469,6 @@ bool rarch_environment_cb(unsigned cmd, void *data) cb, offsetof(struct retro_hw_render_callback, stencil)); memset(hwr + offsetof(struct retro_hw_render_callback, stencil), 0, sizeof(*cb) - offsetof(struct retro_hw_render_callback, stencil)); - } else memcpy(hwr, cb, sizeof(*cb)); diff --git a/dynamic.h b/dynamic.h index 505082bc97..79b7d50fff 100644 --- a/dynamic.h +++ b/dynamic.h @@ -146,9 +146,14 @@ bool init_libretro_sym_custom(enum rarch_core_type type, struct retro_core_t *cu **/ void uninit_libretro_sym(struct retro_core_t *core); -struct retro_subsystem_info subsystem_data[20]; -struct retro_subsystem_rom_info subsystem_data_roms[10][10]; -unsigned subsystem_size; +/* Arbitrary twenty subsystems limite */ +#define SUBSYSTEM_MAX_SUBSYSTEMS 20 +/* Arbitrary 10 roms for each subsystem limit */ +#define SUBSYSTEM_MAX_SUBSYSTEM_ROMS 10 + +struct retro_subsystem_info subsystem_data[SUBSYSTEM_MAX_SUBSYSTEMS]; +struct retro_subsystem_rom_info subsystem_data_roms[SUBSYSTEM_MAX_SUBSYSTEMS][SUBSYSTEM_MAX_SUBSYSTEM_ROMS]; +unsigned subsystem_current_count; RETRO_END_DECLS diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 1079c997cf..31410d59e0 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -521,10 +521,11 @@ static int action_bind_sublabel_subsystem_add( char *s, size_t len) { rarch_system_info_t *system = runloop_get_system_info(); - const struct retro_subsystem_info *subsystem = (system && subsystem_size > 0) ? - subsystem_data + (type - MENU_SETTINGS_SUBSYSTEM_ADD) : NULL; + const struct retro_subsystem_info *subsystem = (system && subsystem_current_count > 0) ? + subsystem_data + (type - MENU_SETTINGS_SUBSYSTEM_ADD) : NULL; - if (subsystem_size > 0 && content_get_subsystem_rom_id() < subsystem->num_roms) + /* To-Do: localization & sublabels for pre-init case */ + if (subsystem_current_count > 0 && content_get_subsystem_rom_id() < subsystem->num_roms) snprintf(s, len, " Current Content: %s", content_get_subsystem() == type - MENU_SETTINGS_SUBSYSTEM_ADD ? subsystem->roms[content_get_subsystem_rom_id()].desc diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 909d293a67..4ca662b7fe 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -596,10 +596,10 @@ static int ozone_list_push(void *data, void *userdata, entry.enum_idx = MENU_ENUM_LABEL_LOAD_CONTENT_LIST; menu_displaylist_setting(&entry); - if (subsystem_size > 0) + if (subsystem_current_count > 0) { const struct retro_subsystem_info* subsystem = subsystem_data; - for (i = 0; i < subsystem_size; i++, subsystem++) + for (i = 0; i < subsystem_current_count; i++, subsystem++) { char s[PATH_MAX_LENGTH]; if (content_get_subsystem() == i) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index ea131d5342..cace669d2e 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -5548,10 +5548,10 @@ static int xmb_list_push(void *data, void *userdata, entry.enum_idx = MENU_ENUM_LABEL_LOAD_CONTENT_LIST; menu_displaylist_setting(&entry); - if (subsystem_size > 0) + if (subsystem_current_count > 0) { const struct retro_subsystem_info* subsystem = subsystem_data; - for (i = 0; i < subsystem_size; i++, subsystem++) + for (i = 0; i < subsystem_current_count; i++, subsystem++) { char s[PATH_MAX_LENGTH]; if (content_get_subsystem() == i) diff --git a/menu/widgets/menu_filebrowser.c b/menu/widgets/menu_filebrowser.c index ee19acefbe..fbde810143 100644 --- a/menu/widgets/menu_filebrowser.c +++ b/menu/widgets/menu_filebrowser.c @@ -86,7 +86,7 @@ void filebrowser_parse(menu_displaylist_info_t *info, unsigned type_data) { const struct retro_subsystem_info *subsystem = &subsystem_data[content_get_subsystem()]; - if (subsystem_size > 0) + if (subsystem_current_count > 0) str_list = file_archive_get_file_list(path, subsystem->roms[content_get_subsystem_rom_id()].valid_extensions); } } @@ -96,7 +96,7 @@ void filebrowser_parse(menu_displaylist_info_t *info, unsigned type_data) { const struct retro_subsystem_info *subsystem = &subsystem_data[content_get_subsystem()]; - if (subsystem_size > 0 && content_get_subsystem_rom_id() < subsystem->num_roms) + if (subsystem_current_count > 0 && content_get_subsystem_rom_id() < subsystem->num_roms) str_list = dir_list_new(path, (filter_ext && info) ? subsystem->roms[content_get_subsystem_rom_id()].valid_extensions : NULL, true, settings->bools.show_hidden_files, true, false); diff --git a/tasks/task_content.c b/tasks/task_content.c index 3db8f943b0..ceb4bbf173 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -663,7 +663,7 @@ error: static const struct retro_subsystem_info *content_file_init_subsystem( const struct retro_subsystem_info *subsystem_data, - size_t subsystem_size, + size_t subsystem_current_count, char **error_string, bool *ret) { @@ -671,7 +671,7 @@ retro_subsystem_info *content_file_init_subsystem( char *msg = (char*)malloc(path_size); struct string_list *subsystem = path_get_subsystem_list(); const struct retro_subsystem_info *special = libretro_find_subsystem_info( - subsystem_data, subsystem_size, + subsystem_data, subsystem_current_count, path_get(RARCH_PATH_SUBSYSTEM)); msg[0] = '\0'; @@ -1786,7 +1786,7 @@ void content_set_subsystem(unsigned idx) pending_subsystem_id = idx; - if (subsystem_size > 0) + if (subsystem_current_count > 0) { strlcpy(pending_subsystem_ident, subsystem->ident, sizeof(pending_subsystem_ident)); From 45228d030718deed3ecc0eef72f7bef09221cf1f Mon Sep 17 00:00:00 2001 From: radius Date: Mon, 10 Dec 2018 23:01:21 -0500 Subject: [PATCH 147/153] massive subsystem cleanup & use the proper data in each instance --- menu/cbs/menu_cbs_sublabel.c | 24 ++++++++++----- menu/drivers/ozone/ozone.c | 59 ++++++------------------------------ menu/drivers/xmb.c | 59 ++++++------------------------------ menu/menu_driver.c | 54 +++++++++++++++++++++++++++++++++ menu/menu_driver.h | 2 ++ 5 files changed, 90 insertions(+), 108 deletions(-) diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 31410d59e0..defe0e2dd6 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -521,15 +521,23 @@ static int action_bind_sublabel_subsystem_add( char *s, size_t len) { rarch_system_info_t *system = runloop_get_system_info(); - const struct retro_subsystem_info *subsystem = (system && subsystem_current_count > 0) ? - subsystem_data + (type - MENU_SETTINGS_SUBSYSTEM_ADD) : NULL; + const struct retro_subsystem_info *subsystem; - /* To-Do: localization & sublabels for pre-init case */ - if (subsystem_current_count > 0 && content_get_subsystem_rom_id() < subsystem->num_roms) - snprintf(s, len, " Current Content: %s", - content_get_subsystem() == type - MENU_SETTINGS_SUBSYSTEM_ADD - ? subsystem->roms[content_get_subsystem_rom_id()].desc - : subsystem->roms[0].desc); + /* Core fully loaded, use the subsystem data */ + if (system->subsystem.data) + subsystem = system->subsystem.data + (type - MENU_SETTINGS_SUBSYSTEM_ADD); + /* Core not loaded completely, use the data we peeked on load core */ + else + subsystem = subsystem_data + (type - MENU_SETTINGS_SUBSYSTEM_ADD); + + if (subsystem && subsystem_current_count > 0) + { + if (content_get_subsystem_rom_id() < subsystem->num_roms) + snprintf(s, len, " Current Content: %s", + content_get_subsystem() == type - MENU_SETTINGS_SUBSYSTEM_ADD + ? subsystem->roms[content_get_subsystem_rom_id()].desc + : subsystem->roms[0].desc); + } return 0; } diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 4ca662b7fe..c3a8324c55 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -502,6 +502,7 @@ static int ozone_list_push(void *data, void *userdata, unsigned i = 0; core_info_list_t *list = NULL; menu_handle_t *menu = (menu_handle_t*)data; + const struct retro_subsystem_info* subsystem; switch (type) { @@ -596,56 +597,14 @@ static int ozone_list_push(void *data, void *userdata, entry.enum_idx = MENU_ENUM_LABEL_LOAD_CONTENT_LIST; menu_displaylist_setting(&entry); - if (subsystem_current_count > 0) - { - const struct retro_subsystem_info* subsystem = subsystem_data; - for (i = 0; i < subsystem_current_count; i++, subsystem++) - { - char s[PATH_MAX_LENGTH]; - if (content_get_subsystem() == i) - { - if (content_get_subsystem_rom_id() < subsystem->num_roms) - { - snprintf(s, sizeof(s), - "Load %s %s", - subsystem->desc, - i == content_get_subsystem() - ? "\u2605" : " "); - menu_entries_append_enum(info->list, - s, - msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_ADD), - MENU_ENUM_LABEL_SUBSYSTEM_ADD, - MENU_SETTINGS_SUBSYSTEM_ADD + i, 0, 0); - } - else - { - snprintf(s, sizeof(s), - "Start %s %s", - subsystem->desc, - i == content_get_subsystem() - ? "\u2605" : " "); - menu_entries_append_enum(info->list, - s, - msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_LOAD), - MENU_ENUM_LABEL_SUBSYSTEM_LOAD, - MENU_SETTINGS_SUBSYSTEM_LOAD, 0, 0); - } - } - else - { - snprintf(s, sizeof(s), - "Load %s %s", - subsystem->desc, - i == content_get_subsystem() - ? "\u2605" : " "); - menu_entries_append_enum(info->list, - s, - msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_ADD), - MENU_ENUM_LABEL_SUBSYSTEM_ADD, - MENU_SETTINGS_SUBSYSTEM_ADD + i, 0, 0); - } - } - } + /* Core fully loaded, use the subsystem data */ + if (system->subsystem.data) + subsystem = system->subsystem.data; + /* Core not loaded completely, use the data we peeked on load core */ + else + subsystem = subsystem_data; + + menu_subsystem_populate(subsystem, info); } entry.enum_idx = MENU_ENUM_LABEL_ADD_CONTENT_LIST; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index cace669d2e..4b0fd88e60 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -5453,6 +5453,7 @@ static int xmb_list_push(void *data, void *userdata, unsigned i = 0; core_info_list_t *list = NULL; menu_handle_t *menu = (menu_handle_t*)data; + const struct retro_subsystem_info* subsystem; switch (type) { @@ -5548,56 +5549,14 @@ static int xmb_list_push(void *data, void *userdata, entry.enum_idx = MENU_ENUM_LABEL_LOAD_CONTENT_LIST; menu_displaylist_setting(&entry); - if (subsystem_current_count > 0) - { - const struct retro_subsystem_info* subsystem = subsystem_data; - for (i = 0; i < subsystem_current_count; i++, subsystem++) - { - char s[PATH_MAX_LENGTH]; - if (content_get_subsystem() == i) - { - if (content_get_subsystem_rom_id() < subsystem->num_roms) - { - snprintf(s, sizeof(s), - "Load %s %s", - subsystem->desc, - i == content_get_subsystem() - ? "\u2605" : " "); - menu_entries_append_enum(info->list, - s, - msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_ADD), - MENU_ENUM_LABEL_SUBSYSTEM_ADD, - MENU_SETTINGS_SUBSYSTEM_ADD + i, 0, 0); - } - else - { - snprintf(s, sizeof(s), - "Start %s %s", - subsystem->desc, - i == content_get_subsystem() - ? "\u2605" : " "); - menu_entries_append_enum(info->list, - s, - msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_LOAD), - MENU_ENUM_LABEL_SUBSYSTEM_LOAD, - MENU_SETTINGS_SUBSYSTEM_LOAD, 0, 0); - } - } - else - { - snprintf(s, sizeof(s), - "Load %s %s", - subsystem->desc, - i == content_get_subsystem() - ? "\u2605" : " "); - menu_entries_append_enum(info->list, - s, - msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_ADD), - MENU_ENUM_LABEL_SUBSYSTEM_ADD, - MENU_SETTINGS_SUBSYSTEM_ADD + i, 0, 0); - } - } - } + /* Core fully loaded, use the subsystem data */ + if (system->subsystem.data) + subsystem = system->subsystem.data; + /* Core not loaded completely, use the data we peeked on load core */ + else + subsystem = subsystem_data; + + menu_subsystem_populate(subsystem, info); } entry.enum_idx = MENU_ENUM_LABEL_ADD_CONTENT_LIST; diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 8ca72c132e..fbbfe10227 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -2654,3 +2654,57 @@ void hex32_to_rgba_normalized(uint32_t hex, float* rgba, float alpha) rgba[2] = rgba[6] = rgba[10] = rgba[14] = ((hex >> 0 ) & 0xFF) * (1.0f / 255.0f); /* b */ rgba[3] = rgba[7] = rgba[11] = rgba[15] = alpha; } + +void menu_subsystem_populate(const struct retro_subsystem_info* subsystem, menu_displaylist_info_t *info) +{ + int i = 0; + if (subsystem && subsystem_current_count > 0) + { + for (i = 0; i < subsystem_current_count; i++, subsystem++) + { + char s[PATH_MAX_LENGTH]; + if (content_get_subsystem() == i) + { + if (content_get_subsystem_rom_id() < subsystem->num_roms) + { + snprintf(s, sizeof(s), + "Load %s %s", + subsystem->desc, + i == content_get_subsystem() + ? "\u2605" : " "); + menu_entries_append_enum(info->list, + s, + msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_ADD), + MENU_ENUM_LABEL_SUBSYSTEM_ADD, + MENU_SETTINGS_SUBSYSTEM_ADD + i, 0, 0); + } + else + { + snprintf(s, sizeof(s), + "Start %s %s", + subsystem->desc, + i == content_get_subsystem() + ? "\u2605" : " "); + menu_entries_append_enum(info->list, + s, + msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_LOAD), + MENU_ENUM_LABEL_SUBSYSTEM_LOAD, + MENU_SETTINGS_SUBSYSTEM_LOAD, 0, 0); + } + } + else + { + snprintf(s, sizeof(s), + "Load %s %s", + subsystem->desc, + i == content_get_subsystem() + ? "\u2605" : " "); + menu_entries_append_enum(info->list, + s, + msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_ADD), + MENU_ENUM_LABEL_SUBSYSTEM_ADD, + MENU_SETTINGS_SUBSYSTEM_ADD + i, 0, 0); + } + } + } +} \ No newline at end of file diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 6487d37248..33f111a8ca 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -844,6 +844,8 @@ void menu_driver_destroy(void); void hex32_to_rgba_normalized(uint32_t hex, float* rgba, float alpha); +void menu_subsystem_populate(const struct retro_subsystem_info* subsystem, menu_displaylist_info_t *info); + extern uintptr_t menu_display_white_texture; extern menu_display_ctx_driver_t menu_display_ctx_gl; From 7a36190a0e61d9a4ba4175ed2c92d27b47a9e0ef Mon Sep 17 00:00:00 2001 From: radius Date: Mon, 10 Dec 2018 23:19:57 -0500 Subject: [PATCH 148/153] cleanup filebrowser too --- menu/widgets/menu_filebrowser.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/menu/widgets/menu_filebrowser.c b/menu/widgets/menu_filebrowser.c index fbde810143..4999bcca5e 100644 --- a/menu/widgets/menu_filebrowser.c +++ b/menu/widgets/menu_filebrowser.c @@ -74,6 +74,16 @@ void filebrowser_parse(menu_displaylist_info_t *info, unsigned type_data) bool filter_ext = settings->bools.menu_navigation_browser_filter_supported_extensions_enable; + rarch_system_info_t *system = runloop_get_system_info(); + const struct retro_subsystem_info *subsystem; + + /* Core fully loaded, use the subsystem data */ + if (system->subsystem.data) + subsystem = system->subsystem.data + content_get_subsystem(); + /* Core not loaded completely, use the data we peeked on load core */ + else + subsystem = subsystem_data + content_get_subsystem(); + if (info && string_is_equal(info->label, msg_hash_to_str(MENU_ENUM_LABEL_SCAN_FILE))) filter_ext = false; @@ -82,21 +92,14 @@ void filebrowser_parse(menu_displaylist_info_t *info, unsigned type_data) { if (filebrowser_types != FILEBROWSER_SELECT_FILE_SUBSYSTEM) str_list = file_archive_get_file_list(path, info->exts); - else - { - const struct retro_subsystem_info *subsystem = &subsystem_data[content_get_subsystem()]; - - if (subsystem_current_count > 0) - str_list = file_archive_get_file_list(path, subsystem->roms[content_get_subsystem_rom_id()].valid_extensions); - } + else if (subsystem && subsystem_current_count > 0) + str_list = file_archive_get_file_list(path, subsystem->roms[content_get_subsystem_rom_id()].valid_extensions); } else if (!string_is_empty(path)) { if (filebrowser_types == FILEBROWSER_SELECT_FILE_SUBSYSTEM) { - const struct retro_subsystem_info *subsystem = &subsystem_data[content_get_subsystem()]; - - if (subsystem_current_count > 0 && content_get_subsystem_rom_id() < subsystem->num_roms) + if (subsystem && subsystem_current_count > 0 && content_get_subsystem_rom_id() < subsystem->num_roms) str_list = dir_list_new(path, (filter_ext && info) ? subsystem->roms[content_get_subsystem_rom_id()].valid_extensions : NULL, true, settings->bools.show_hidden_files, true, false); From 479104ee05d63a8053168aaf800c0478149978bf Mon Sep 17 00:00:00 2001 From: radius Date: Mon, 10 Dec 2018 23:27:04 -0500 Subject: [PATCH 149/153] cleanup task_content.c too --- tasks/task_content.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tasks/task_content.c b/tasks/task_content.c index ceb4bbf173..36883c1adb 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -1781,12 +1781,18 @@ int content_get_subsystem() void content_set_subsystem(unsigned idx) { rarch_system_info_t *system = runloop_get_system_info(); - const struct retro_subsystem_info *subsystem = system ? - subsystem_data + idx : NULL; + const struct retro_subsystem_info *subsystem; - pending_subsystem_id = idx; + /* Core fully loaded, use the subsystem data */ + if (system->subsystem.data) + subsystem = system->subsystem.data + idx; + /* Core not loaded completely, use the data we peeked on load core */ + else + subsystem = subsystem_data + idx; - if (subsystem_current_count > 0) + pending_subsystem_id = idx; + + if (subsystem && subsystem_current_count > 0) { strlcpy(pending_subsystem_ident, subsystem->ident, sizeof(pending_subsystem_ident)); From ced0f09f0e696fc33763000fcaf401500b668aab Mon Sep 17 00:00:00 2001 From: radius Date: Mon, 10 Dec 2018 23:51:41 -0500 Subject: [PATCH 150/153] start at the current loaded content dir for subsystem and disk image append --- menu/cbs/menu_cbs_ok.c | 44 +++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 0218028835..fa24a25936 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -521,24 +521,36 @@ int generic_action_ok_displaylist_push(const char *path, } break; case ACTION_OK_DL_DISK_IMAGE_APPEND_LIST: - filebrowser_clear_type(); - info.type = type; - info.directory_ptr = idx; - info_path = settings->paths.directory_menu_content; - info_label = label; - dl_type = DISPLAYLIST_FILE_BROWSER_SELECT_FILE; + { + char game_dir[PATH_MAX_LENGTH]; + filebrowser_clear_type(); + strlcpy(game_dir, path_get(RARCH_PATH_CONTENT), sizeof(game_dir)); + path_basedir(game_dir); + + info.type = type; + info.directory_ptr = idx; + info_path = !string_is_empty(game_dir) ? game_dir : settings->paths.directory_menu_content; + info_label = label; + dl_type = DISPLAYLIST_FILE_BROWSER_SELECT_FILE; + } break; case ACTION_OK_DL_SUBSYSTEM_ADD_LIST: - filebrowser_clear_type(); - if (content_get_subsystem() != type - MENU_SETTINGS_SUBSYSTEM_ADD) - content_clear_subsystem(); - content_set_subsystem(type - MENU_SETTINGS_SUBSYSTEM_ADD); - filebrowser_set_type(FILEBROWSER_SELECT_FILE_SUBSYSTEM); - info.type = type; - info.directory_ptr = idx; - info_path = settings->paths.directory_menu_content; - info_label = label; - dl_type = DISPLAYLIST_FILE_BROWSER_SELECT_FILE; + { + char game_dir[PATH_MAX_LENGTH]; + filebrowser_clear_type(); + strlcpy(game_dir, path_get(RARCH_PATH_CONTENT), sizeof(game_dir)); + path_basedir(game_dir); + + if (content_get_subsystem() != type - MENU_SETTINGS_SUBSYSTEM_ADD) + content_clear_subsystem(); + content_set_subsystem(type - MENU_SETTINGS_SUBSYSTEM_ADD); + filebrowser_set_type(FILEBROWSER_SELECT_FILE_SUBSYSTEM); + info.type = type; + info.directory_ptr = idx; + info_path = !string_is_empty(game_dir) ? game_dir : settings->paths.directory_menu_content; + info_label = label; + dl_type = DISPLAYLIST_FILE_BROWSER_SELECT_FILE; + } break; case ACTION_OK_DL_SUBSYSTEM_LOAD: { From 868465ad01dba03b5f86f185dfe357c2eb94dc6a Mon Sep 17 00:00:00 2001 From: Themaister Date: Tue, 11 Dec 2018 20:12:25 +0100 Subject: [PATCH 151/153] EGL: Add callback to select EGLConfig. A more robust fix for DRM/GBM shenanigans. --- gfx/common/egl_common.c | 55 ++++++++++++---------- gfx/common/egl_common.h | 6 ++- gfx/drivers_context/android_ctx.c | 2 +- gfx/drivers_context/drm_ctx.c | 24 +++++++++- gfx/drivers_context/emscriptenegl_ctx.c | 2 +- gfx/drivers_context/mali_fbdev_ctx.c | 2 +- gfx/drivers_context/opendingux_fbdev_ctx.c | 2 +- gfx/drivers_context/qnx_ctx.c | 2 +- gfx/drivers_context/switch_ctx.c | 2 +- gfx/drivers_context/vc_egl_ctx.c | 2 +- gfx/drivers_context/vivante_fbdev_ctx.c | 2 +- gfx/drivers_context/wayland_ctx.c | 3 +- gfx/drivers_context/xegl_ctx.c | 2 +- 13 files changed, 70 insertions(+), 36 deletions(-) diff --git a/gfx/common/egl_common.c b/gfx/common/egl_common.c index b9416d2f13..348d1bafe4 100644 --- a/gfx/common/egl_common.c +++ b/gfx/common/egl_common.c @@ -309,14 +309,31 @@ static EGLDisplay get_egl_display(EGLenum platform, void *native) return eglGetDisplay((EGLNativeDisplayType) native); } +bool egl_default_accept_config_cb(void *display_data, EGLDisplay dpy, EGLConfig config) +{ + /* Makes sure we have 8 bit color. */ + EGLint r, g, b; + if (!eglGetConfigAttrib(dpy, config, EGL_RED_SIZE, &r)) + return false; + if (!eglGetConfigAttrib(dpy, config, EGL_GREEN_SIZE, &g)) + return false; + if (!eglGetConfigAttrib(dpy, config, EGL_BLUE_SIZE, &b)) + return false; + + if (r != 8 || g != 8 || b != 8) + return false; + + return true; +} + bool egl_init_context(egl_ctx_data_t *egl, EGLenum platform, void *display_data, EGLint *major, EGLint *minor, - EGLint *n, const EGLint *attrib_ptr) + EGLint *n, const EGLint *attrib_ptr, + egl_accept_config_cb_t cb) { - int i; - EGLint id; + EGLint i; EGLConfig *configs = NULL; EGLint count = 0; EGLint matched = 0; @@ -336,14 +353,13 @@ bool egl_init_context(egl_ctx_data_t *egl, RARCH_LOG("[EGL]: EGL version: %d.%d\n", *major, *minor); -#ifdef HAVE_GBM if (!eglGetConfigs(egl->dpy, NULL, 0, &count) || count < 1) { RARCH_ERR("[EGL]: No configs to choose from.\n"); return false; } - configs = malloc(count * sizeof *configs); + configs = malloc(count * sizeof(*configs)); if (!configs) return false; @@ -354,31 +370,22 @@ bool egl_init_context(egl_ctx_data_t *egl, return false; } - for (i = 0; i < count; ++i) + for (i = 0; i < count; i++) { - if (!eglGetConfigAttrib(egl->dpy, - configs[i], EGL_NATIVE_VISUAL_ID, &id)) - continue; - - if (id == GBM_FORMAT_XRGB8888) + if (!cb || cb(display_data, egl->dpy, configs[i])) + { + egl->config = configs[i]; break; + } } - if (id != GBM_FORMAT_XRGB8888) - { - RARCH_ERR("[EGL]: No EGL configs with format XRGB8888\n"); - return false; - } - - config_index = i; - if (config_index != -1) - egl->config = configs[config_index]; - free(configs); -#else - if (!eglChooseConfig(egl->dpy, attrib_ptr, &egl->config, 1, n) || *n != 1) + + if (i == count) + { + RARCH_ERR("[EGL]: No EGL config found which satifies requirements.\n"); return false; -#endif + } egl->major = g_egl_major; egl->minor = g_egl_minor; diff --git a/gfx/common/egl_common.h b/gfx/common/egl_common.h index 5481efc937..5fe4bec6e8 100644 --- a/gfx/common/egl_common.h +++ b/gfx/common/egl_common.h @@ -88,13 +88,17 @@ void egl_set_swap_interval(egl_ctx_data_t *egl, int interval); void egl_get_video_size(egl_ctx_data_t *egl, unsigned *width, unsigned *height); +typedef bool (*egl_accept_config_cb_t)(void *display_data, EGLDisplay dpy, EGLConfig config); +bool egl_default_accept_config_cb(void *display_data, EGLDisplay dpy, EGLConfig config); + bool egl_init_context(egl_ctx_data_t *egl, EGLenum platform, void *display_data, EGLint *major, EGLint *minor, EGLint *n, - const EGLint *attrib_ptr); + const EGLint *attrib_ptr, + egl_accept_config_cb_t cb); bool egl_create_context(egl_ctx_data_t *egl, const EGLint *egl_attribs); diff --git a/gfx/drivers_context/android_ctx.c b/gfx/drivers_context/android_ctx.c index 69b9c2a389..116a6a9fdf 100644 --- a/gfx/drivers_context/android_ctx.c +++ b/gfx/drivers_context/android_ctx.c @@ -137,7 +137,7 @@ static void *android_gfx_ctx_init(video_frame_info_t *video_info, void *video_dr RARCH_LOG("Android EGL: GLES version = %d.\n", g_es3 ? 3 : 2); if (!egl_init_context(&and->egl, EGL_NONE, EGL_DEFAULT_DISPLAY, - &major, &minor, &n, attribs)) + &major, &minor, &n, attribs, NULL)) { egl_report_error(); goto error; diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index bd81479792..d362bb745a 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -497,6 +497,28 @@ static EGLint *gfx_ctx_drm_egl_fill_attribs( } #ifdef HAVE_EGL +static bool gbm_choose_xrgb8888_cb(void *display_data, EGLDisplay dpy, EGLConfig config) +{ + EGLint r, g, b, id; + (void)display_data; + + /* Makes sure we have 8 bit color. */ + if (!eglGetConfigAttrib(dpy, config, EGL_RED_SIZE, &r)) + return false; + if (!eglGetConfigAttrib(dpy, config, EGL_GREEN_SIZE, &g)) + return false; + if (!eglGetConfigAttrib(dpy, config, EGL_BLUE_SIZE, &b)) + return false; + + if (r != 8 || g != 8 || b != 8) + return false; + + if (!eglGetConfigAttrib(dpy, config, EGL_NATIVE_VISUAL_ID, &id)) + return false; + + return id == GBM_FORMAT_XRGB8888; +} + #define DRM_EGL_ATTRIBS_BASE \ EGL_SURFACE_TYPE, EGL_WINDOW_BIT, \ EGL_RED_SIZE, 1, \ @@ -575,7 +597,7 @@ static bool gfx_ctx_drm_egl_set_video_mode(gfx_ctx_drm_data_t *drm) #ifdef HAVE_EGL if (!egl_init_context(&drm->egl, EGL_PLATFORM_GBM_KHR, (EGLNativeDisplayType)g_gbm_dev, &major, - &minor, &n, attrib_ptr)) + &minor, &n, attrib_ptr, gbm_choose_xrgb8888_cb)) goto error; attr = gfx_ctx_drm_egl_fill_attribs(drm, egl_attribs); diff --git a/gfx/drivers_context/emscriptenegl_ctx.c b/gfx/drivers_context/emscriptenegl_ctx.c index b2eb2b7100..46410ba68d 100644 --- a/gfx/drivers_context/emscriptenegl_ctx.c +++ b/gfx/drivers_context/emscriptenegl_ctx.c @@ -212,7 +212,7 @@ static void *gfx_ctx_emscripten_init(video_frame_info_t *video_info, } if (!egl_init_context(&emscripten->egl, EGL_NONE, - (void *)EGL_DEFAULT_DISPLAY, &major, &minor, &n, attribute_list)) + (void *)EGL_DEFAULT_DISPLAY, &major, &minor, &n, attribute_list, NULL)) { egl_report_error(); goto error; diff --git a/gfx/drivers_context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c index cb86849d95..363e3c0182 100644 --- a/gfx/drivers_context/mali_fbdev_ctx.c +++ b/gfx/drivers_context/mali_fbdev_ctx.c @@ -116,7 +116,7 @@ static void *gfx_ctx_mali_fbdev_init(video_frame_info_t *video_info, void *video #ifdef HAVE_EGL if (!egl_init_context(&mali->egl, EGL_NONE, EGL_DEFAULT_DISPLAY, - &major, &minor, &n, attribs)) + &major, &minor, &n, attribs, NULL)) { egl_report_error(); goto error; diff --git a/gfx/drivers_context/opendingux_fbdev_ctx.c b/gfx/drivers_context/opendingux_fbdev_ctx.c index 41d6e34aae..f774c9c34b 100644 --- a/gfx/drivers_context/opendingux_fbdev_ctx.c +++ b/gfx/drivers_context/opendingux_fbdev_ctx.c @@ -87,7 +87,7 @@ static void *gfx_ctx_opendingux_init(video_frame_info_t *video_info, void *video if (!egl_init_context(&viv->egl, EGL_NONE, EGL_DEFAULT_DISPLAY, &major, &minor, - &n, attribs)) + &n, attribs, NULL)) { egl_report_error(); goto error; diff --git a/gfx/drivers_context/qnx_ctx.c b/gfx/drivers_context/qnx_ctx.c index 7ce06b5f28..f71c2f50b3 100644 --- a/gfx/drivers_context/qnx_ctx.c +++ b/gfx/drivers_context/qnx_ctx.c @@ -134,7 +134,7 @@ static void *gfx_ctx_qnx_init(video_frame_info_t *video_info, void *video_driver #ifdef HAVE_EGL if (!egl_init_context(&qnx->egl, EGL_NONE, EGL_DEFAULT_DISPLAY, &major, &minor, - &n, attribs)) + &n, attribs, NULL)) { egl_report_error(); goto error; diff --git a/gfx/drivers_context/switch_ctx.c b/gfx/drivers_context/switch_ctx.c index 47ab760b47..6a8e075cd6 100644 --- a/gfx/drivers_context/switch_ctx.c +++ b/gfx/drivers_context/switch_ctx.c @@ -88,7 +88,7 @@ static void *switch_ctx_init(video_frame_info_t *video_info, void *video_driver) #ifdef HAVE_EGL if (!egl_init_context(&ctx_nx->egl, EGL_NONE, EGL_DEFAULT_DISPLAY, - &major, &minor, &n, attribs)) + &major, &minor, &n, attribs, NULL)) { egl_report_error(); goto error; diff --git a/gfx/drivers_context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index 04aaf3ee1f..183ab77557 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -210,7 +210,7 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver) #ifdef HAVE_EGL if (!egl_init_context(&vc->egl, EGL_NONE, EGL_DEFAULT_DISPLAY, - &major, &minor, &n, attribute_list)) + &major, &minor, &n, attribute_list, NULL)) { egl_report_error(); goto error; diff --git a/gfx/drivers_context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c index 2270ee003c..4eff7b8835 100644 --- a/gfx/drivers_context/vivante_fbdev_ctx.c +++ b/gfx/drivers_context/vivante_fbdev_ctx.c @@ -93,7 +93,7 @@ static void *gfx_ctx_vivante_init(video_frame_info_t *video_info, void *video_dr #ifdef HAVE_EGL if (!egl_init_context(&viv->egl, EGL_NONE, EGL_DEFAULT_DISPLAY, &major, &minor, - &n, attribs)) + &n, attribs, NULL)) { egl_report_error(); goto error; diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 929e441978..01a5e52133 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -1305,7 +1305,8 @@ static void *gfx_ctx_wl_init(video_frame_info_t *video_info, void *video_driver) if (!egl_init_context(&wl->egl, EGL_PLATFORM_WAYLAND_KHR, (EGLNativeDisplayType)wl->input.dpy, - &major, &minor, &n, attrib_ptr)) + &major, &minor, &n, attrib_ptr, + egl_default_accept_config_cb)) { egl_report_error(); goto error; diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index ad21ce4644..24d2546c53 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -172,7 +172,7 @@ static void *gfx_ctx_xegl_init(video_frame_info_t *video_info, void *video_drive #ifdef HAVE_EGL if (!egl_init_context(&xegl->egl, EGL_PLATFORM_X11_KHR, - (EGLNativeDisplayType)g_x11_dpy, &major, &minor, &n, attrib_ptr)) + (EGLNativeDisplayType)g_x11_dpy, &major, &minor, &n, attrib_ptr, egl_default_accept_config_cb)) { egl_report_error(); goto error; From a7e4d8359b9584e6ab8c3617cb4f4e87c34a9565 Mon Sep 17 00:00:00 2001 From: radius Date: Tue, 11 Dec 2018 19:34:12 -0500 Subject: [PATCH 152/153] fix fullscreen=>windowed when remember window positions is on --- command.c | 5 +++++ gfx/common/win32_common.c | 7 ++----- retroarch.c | 16 ++++++++++++++++ retroarch.h | 6 ++++++ 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/command.c b/command.c index dcc37f7575..0f0ad1969d 100644 --- a/command.c +++ b/command.c @@ -2745,9 +2745,12 @@ TODO: Add a setting for these tweaks */ settings_t *settings = config_get_ptr(); bool new_fullscreen_state = !settings->bools.video_fullscreen && !retroarch_is_forced_fullscreen(); + if (!video_driver_has_windowed()) return false; + retroarch_set_switching_display_mode(); + /* we toggled manually, write the new value to settings */ configuration_set_bool(settings, settings->bools.video_fullscreen, new_fullscreen_state); @@ -2763,6 +2766,8 @@ TODO: Add a setting for these tweaks */ video_driver_hide_mouse(); else video_driver_show_mouse(); + + retroarch_unset_switching_display_mode(); } break; case CMD_EVENT_COMMAND_DEINIT: diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index a9d96062e0..79f3dd6b9e 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -657,7 +657,7 @@ static void win32_save_position(void) } if (settings && settings->bools.video_window_save_positions) { - if (!settings->bools.video_fullscreen && !retroarch_is_forced_fullscreen()) + if (!settings->bools.video_fullscreen && !retroarch_is_forced_fullscreen() && !retroarch_is_switching_display_mode()) { settings->uints.window_position_x = g_win32_pos_x; settings->uints.window_position_y = g_win32_pos_y; @@ -684,7 +684,6 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message, *quit = true; break; } - win32_save_position(); break; case WM_DROPFILES: { @@ -724,10 +723,9 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message, g_win32_resized = true; } } - win32_save_position(); *quit = true; break; - case WM_COMMAND: + case WM_COMMAND: { settings_t *settings = config_get_ptr(); if (settings && settings->bools.ui_menubar_enable) @@ -970,7 +968,6 @@ bool win32_window_create(void *data, unsigned style, #ifndef _XBOX unsigned user_width = width; unsigned user_height = height; - win32_set_position_from_config(); if (settings->bools.video_window_save_positions && !fullscreen) diff --git a/retroarch.c b/retroarch.c index ba30250af1..49d35b45bb 100644 --- a/retroarch.c +++ b/retroarch.c @@ -210,6 +210,7 @@ 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 rarch_is_switching_display_mode = false; static bool has_set_verbosity = false; static bool has_set_libretro = false; static bool has_set_libretro_directory = false; @@ -2025,6 +2026,21 @@ void retroarch_unset_forced_fullscreen(void) rarch_force_fullscreen = false; } +bool retroarch_is_switching_display_mode(void) +{ + return rarch_is_switching_display_mode; +} + +void retroarch_set_switching_display_mode(void) +{ + rarch_is_switching_display_mode = true; +} + +void retroarch_unset_switching_display_mode(void) +{ + rarch_is_switching_display_mode = false; +} + /* set a runtime shader preset without overwriting the settings value */ void retroarch_set_shader_preset(const char* preset) { diff --git a/retroarch.h b/retroarch.h index a3667fde88..50f481ea6c 100644 --- a/retroarch.h +++ b/retroarch.h @@ -330,6 +330,12 @@ void retroarch_unset_shader_preset(void); char* retroarch_get_shader_preset(void); +bool retroarch_is_switching_display_mode(void); + +void retroarch_set_switching_display_mode(void); + +void retroarch_unset_switching_display_mode(void); + /** * retroarch_fail: * @error_code : Error code. From 077b108aa116bae93d30dc0d11109e0fa7c2d4ba Mon Sep 17 00:00:00 2001 From: Themaister Date: Wed, 12 Dec 2018 13:22:24 +0100 Subject: [PATCH 153/153] Vulkan: Fix potential crash when toggling fullscreen. If we have HW rendering, and we toggle fullscreen while in the menu, we don't have a ready HW image, so fall back to black dummy texture. --- gfx/common/vulkan_common.h | 1 + gfx/drivers/vulkan.c | 53 +++++++++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/gfx/common/vulkan_common.h b/gfx/common/vulkan_common.h index a66544af6a..69c9758819 100644 --- a/gfx/common/vulkan_common.h +++ b/gfx/common/vulkan_common.h @@ -342,6 +342,7 @@ typedef struct vk struct video_viewport vp; struct vk_per_frame *chain; struct vk_per_frame swapchain[VULKAN_MAX_SWAPCHAIN_IMAGES]; + struct vk_texture default_texture; /* Currently active command buffer. */ VkCommandBuffer cmd; diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 09769b1b0a..9ca988f1a1 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -645,6 +645,7 @@ static void vulkan_deinit_descriptor_pool(vk_t *vk) static void vulkan_init_textures(vk_t *vk) { unsigned i; + const uint32_t zero = 0; vulkan_init_samplers(vk); if (!vk->hw.enable) @@ -665,6 +666,10 @@ static void vulkan_init_textures(vk_t *vk) NULL, NULL, VULKAN_TEXTURE_DYNAMIC); } } + + vk->default_texture = vulkan_create_texture(vk, NULL, + 1, 1, VK_FORMAT_B8G8R8A8_UNORM, + &zero, NULL, VULKAN_TEXTURE_STATIC); } static void vulkan_deinit_textures(vk_t *vk) @@ -683,6 +688,9 @@ static void vulkan_deinit_textures(vk_t *vk) vulkan_destroy_texture( vk->context->device, &vk->swapchain[i].texture_optimal); } + + if (vk->default_texture.memory != VK_NULL_HANDLE) + vulkan_destroy_texture(vk->context->device, &vk->default_texture); } static void vulkan_deinit_command_buffers(vk_t *vk) @@ -1732,28 +1740,43 @@ static bool vulkan_frame(void *data, const void *frame, if (vk->hw.enable) { /* Does this make that this can happen at all? */ - if (!vk->hw.image) + if (vk->hw.image) { - RARCH_ERR("[Vulkan]: HW image is not set. Buggy core?\n"); - return false; - } + input.image = vk->hw.image->create_info.image; + input.view = vk->hw.image->image_view; + input.layout = vk->hw.image->image_layout; - input.image = vk->hw.image->create_info.image; - input.view = vk->hw.image->image_view; - input.layout = vk->hw.image->image_layout; + /* The format can change on a whim. */ + input.format = vk->hw.image->create_info.format; - /* The format can change on a whim. */ - input.format = vk->hw.image->create_info.format; + if (frame) + { + input.width = frame_width; + input.height = frame_height; + } + else + { + input.width = vk->hw.last_width; + input.height = vk->hw.last_height; + } - if (frame) - { - input.width = frame_width; - input.height = frame_height; + input.image = vk->hw.image->create_info.image; + input.view = vk->hw.image->image_view; + input.layout = vk->hw.image->image_layout; + + /* The format can change on a whim. */ + input.format = vk->hw.image->create_info.format; } else { - input.width = vk->hw.last_width; - input.height = vk->hw.last_height; + /* Fall back to the default, black texture. + * This can happen if we restart the video driver while in the menu. */ + input.image = vk->default_texture.image; + input.view = vk->default_texture.view; + input.layout = vk->default_texture.layout; + input.format = vk->default_texture.format; + input.width = vk->default_texture.width; + input.height = vk->default_texture.height; } vk->hw.last_width = input.width;