From 3c3611af6f336c5f7a896415ceed9af086a87e27 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Mon, 13 Jan 2025 15:37:59 +0100 Subject: [PATCH 01/49] Resync libretro-common --- libretro-common/include/retro_timers.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libretro-common/include/retro_timers.h b/libretro-common/include/retro_timers.h index 96041255a3f1..c0d2db4db534 100644 --- a/libretro-common/include/retro_timers.h +++ b/libretro-common/include/retro_timers.h @@ -39,7 +39,7 @@ #include #elif defined(_3DS) #include <3ds.h> -#elif defined(EMSCRIPTEN) +#elif defined(EMSCRIPTEN_FIXME) #include #else #include @@ -100,7 +100,7 @@ static int nanosleepDOS(const struct timespec *rqtp, struct timespec *rmtp) #define retro_sleep(msec) (usleep(1000 * (msec))) #elif defined(WIIU) #define retro_sleep(msec) (OSSleepTicks(ms_to_ticks((msec)))) -#elif defined(EMSCRIPTEN) +#elif defined(EMSCRIPTEN_FIXME) #define retro_sleep(msec) (emscripten_sleep(msec)) #else static INLINE void retro_sleep(unsigned msec) From bd413de842bdf7770b2445618c187c64b1d2e43b Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Mon, 13 Jan 2025 16:01:16 +0100 Subject: [PATCH 02/49] Log messages are too small to hold entire path --- tasks/task_content.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/task_content.c b/tasks/task_content.c index 603e0f3fd3b4..448cb165f1df 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -789,7 +789,7 @@ static bool content_file_extract_from_archive( NULL : content_ctx->directory_cache, tmp_path, sizeof(tmp_path))) { - char msg[128]; + char msg[PATH_MAX_LENGTH]; snprintf(msg, sizeof(msg), "%s: \"%s\".\n", msg_hash_to_str(MSG_FAILED_TO_EXTRACT_CONTENT_FROM_COMPRESSED_FILE), *content_path); @@ -993,7 +993,7 @@ static bool content_file_load( content_compressed, i, first_content_type, &content_data, &content_size)) { - char msg[128]; + char msg[PATH_MAX_LENGTH]; snprintf(msg, sizeof(msg), "%s \"%s\"\n", msg_hash_to_str(MSG_COULD_NOT_READ_CONTENT_FILE), content_path); @@ -1073,7 +1073,7 @@ static bool content_file_load( * (This disclaimer is out dated but I don't want to remove it)*/ if (!CopyFileFromAppW(wcontent_path, wnew_path, false)) { - char msg[128]; + char msg[PATH_MAX_LENGTH]; /* TODO/FIXME - localize */ snprintf(msg, sizeof(msg), "%s \"%s\". (during copy read or write)\n", msg_hash_to_str(MSG_COULD_NOT_READ_CONTENT_FILE), From e081bde06494762300a52b907792fe32352d02b0 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Mon, 13 Jan 2025 21:14:30 +0100 Subject: [PATCH 03/49] (core_info.c) Use fill_pathname where we can --- core_info.c | 50 ++++++++++++++------------------------------------ 1 file changed, 14 insertions(+), 36 deletions(-) diff --git a/core_info.c b/core_info.c index edb68971f6ac..5bca38a3d8d5 100644 --- a/core_info.c +++ b/core_info.c @@ -1497,18 +1497,15 @@ static bool core_info_path_is_locked( core_aux_file_path_list_t *lock_list, const char *core_file_name) { - size_t i, len; + size_t i; uint32_t hash; char lock_filename[NAME_MAX_LENGTH]; if (lock_list->size < 1) return false; - len = strlcpy(lock_filename, core_file_name, - sizeof(lock_filename)); - strlcpy(lock_filename + len, - ".lck", - sizeof(lock_filename) - len); + fill_pathname(lock_filename, core_file_name, + ".lck", sizeof(lock_filename)); hash = core_info_hash_string(lock_filename); @@ -1528,18 +1525,15 @@ static bool core_info_path_is_standalone_exempt( core_aux_file_path_list_t *exempt_list, const char *core_file_name) { - size_t i, len; + size_t i; uint32_t hash; char exempt_filename[NAME_MAX_LENGTH]; if (exempt_list->size < 1) return false; - len = strlcpy(exempt_filename, core_file_name, - sizeof(exempt_filename)); - strlcpy(exempt_filename + len, - ".lsae", - sizeof(exempt_filename) - len); + fill_pathname(exempt_filename, core_file_name, + ".lsae", sizeof(exempt_filename)); hash = core_info_hash_string(exempt_filename); @@ -2912,7 +2906,6 @@ static bool core_info_update_core_aux_file(const char *path, bool create) * core info list this is *not* thread safe */ bool core_info_set_core_lock(const char *core_path, bool lock) { - size_t _len; core_info_t *core_info = NULL; char lock_file_path[PATH_MAX_LENGTH]; @@ -2931,11 +2924,8 @@ bool core_info_set_core_lock(const char *core_path, bool lock) return false; /* Get lock file path */ - _len = strlcpy(lock_file_path, core_info->path, - sizeof(lock_file_path)); - strlcpy(lock_file_path + _len, - ".lck", - sizeof(lock_file_path) - _len); + fill_pathname(lock_file_path, core_info->path, + ".lck", sizeof(lock_file_path)); /* Create or delete lock file, as required */ if (!core_info_update_core_aux_file(lock_file_path, lock)) @@ -2959,7 +2949,6 @@ bool core_info_set_core_lock(const char *core_path, bool lock) * must be checked externally */ bool core_info_get_core_lock(const char *core_path, bool validate_path) { - size_t _len; core_info_t *core_info = NULL; const char *core_file_path = NULL; bool is_locked = false; @@ -2990,11 +2979,8 @@ bool core_info_get_core_lock(const char *core_path, bool validate_path) return false; /* Get lock file path */ - _len = strlcpy(lock_file_path, core_file_path, - sizeof(lock_file_path)); - strlcpy(lock_file_path + _len, - ".lck", - sizeof(lock_file_path) - _len); + fill_pathname(lock_file_path, core_file_path, + ".lck", sizeof(lock_file_path)); /* Check whether lock file exists */ is_locked = path_is_valid(lock_file_path); @@ -3022,7 +3008,6 @@ bool core_info_set_core_standalone_exempt(const char *core_path, bool exempt) /* Static platforms do not support the contentless * cores menu */ #if defined(HAVE_DYNAMIC) - size_t _len; core_info_t *core_info = NULL; char exempt_file_path[PATH_MAX_LENGTH]; @@ -3034,11 +3019,8 @@ bool core_info_set_core_standalone_exempt(const char *core_path, bool exempt) return false; /* Get 'standalone exempt' file path */ - _len = strlcpy(exempt_file_path, core_info->path, - sizeof(exempt_file_path)); - strlcpy(exempt_file_path + _len, - ".lsae", - sizeof(exempt_file_path) - _len); + fill_pathname(exempt_file_path, core_info->path, + ".lsae", sizeof(exempt_file_path)); /* Create or delete 'standalone exempt' file, as required */ if (core_info_update_core_aux_file(exempt_file_path, exempt)) @@ -3062,7 +3044,6 @@ bool core_info_get_core_standalone_exempt(const char *core_path) /* Static platforms do not support the contentless * cores menu */ #if defined(HAVE_DYNAMIC) - size_t _len; core_info_t *core_info = NULL; char exempt_file_path[PATH_MAX_LENGTH]; @@ -3074,11 +3055,8 @@ bool core_info_get_core_standalone_exempt(const char *core_path) return false; /* Get 'standalone exempt' file path */ - _len = strlcpy(exempt_file_path, core_info->path, - sizeof(exempt_file_path)); - strlcpy(exempt_file_path + _len, - ".lsae", - sizeof(exempt_file_path) - _len); + fill_pathname(exempt_file_path, core_info->path, + ".lsae", sizeof(exempt_file_path)); /* Check whether 'standalone exempt' file exists */ if (path_is_valid(exempt_file_path)) From 47d888364df1d6b8d38d004fa4e6fe23f3d1d8ca Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Mon, 13 Jan 2025 21:53:49 +0100 Subject: [PATCH 04/49] Standardize len variables - argument should always be named 'len', while local len variables should have '_' prefix --- audio/drivers/pulse.c | 2 +- core_info.c | 10 +-- .../libretro-net-retropad/net_retropad_core.c | 22 +++--- disk_index_file.c | 12 ++-- input/common/wayland_common.c | 7 +- input/drivers/test_input.c | 12 ++-- input/drivers_joypad/test_joypad.c | 12 ++-- input/drivers_joypad/udev_joypad.c | 9 +-- input/include/hid_driver.h | 4 +- libretro-common/file/archive_file.c | 10 +-- libretro-common/file/archive_file_7z.c | 4 +- libretro-common/file/archive_file_zlib.c | 4 +- libretro-common/file/nbio/nbio_unixmmap.c | 12 ++-- libretro-common/formats/json/rjson.c | 8 +-- libretro-common/hash/lrc_hash.c | 10 +-- libretro-common/memmap/memmap.c | 2 +- libretro-common/samples/net/net_http_test.c | 4 +- menu/menu_driver.c | 3 +- runloop.c | 65 +++++++++-------- tasks/task_database_cue.c | 72 +++++++++---------- 20 files changed, 139 insertions(+), 145 deletions(-) diff --git a/audio/drivers/pulse.c b/audio/drivers/pulse.c index b680f05a1dd6..548584950406 100644 --- a/audio/drivers/pulse.c +++ b/audio/drivers/pulse.c @@ -142,7 +142,7 @@ static void stream_state_cb(pa_stream *s, void *data) } } -static void stream_request_cb(pa_stream *s, size_t length, void *data) +static void stream_request_cb(pa_stream *s, size_t len, void *data) { pa_t *pa = (pa_t*)data; pa_threaded_mainloop_signal(pa->mainloop, 0); diff --git a/core_info.c b/core_info.c index 5bca38a3d8d5..1a8b6b2e46d7 100644 --- a/core_info.c +++ b/core_info.c @@ -100,11 +100,11 @@ static core_info_state_t core_info_st = { /* JSON Handlers START */ static bool CCJSONObjectMemberHandler(void *context, - const char *pValue, size_t length) + const char *pValue, size_t len) { CCJSONContext *pCtx = (CCJSONContext *)context; - if (length) + if (len) { switch (pCtx->array_depth) { @@ -262,12 +262,12 @@ static bool CCJSONObjectMemberHandler(void *context, } static bool CCJSONStringHandler(void *context, - const char *pValue, size_t length) + const char *pValue, size_t len) { CCJSONContext *pCtx = (CCJSONContext*)context; if ( pCtx->current_string_val - && length + && len && !string_is_empty(pValue)) { if (*pCtx->current_string_val) @@ -290,7 +290,7 @@ static bool CCJSONStringHandler(void *context, } static bool CCJSONNumberHandler(void *context, - const char *pValue, size_t length) + const char *pValue, size_t len) { CCJSONContext *pCtx = (CCJSONContext*)context; diff --git a/cores/libretro-net-retropad/net_retropad_core.c b/cores/libretro-net-retropad/net_retropad_core.c index 4584cf0a2807..1b81991eb315 100644 --- a/cores/libretro-net-retropad/net_retropad_core.c +++ b/cores/libretro-net-retropad/net_retropad_core.c @@ -278,7 +278,7 @@ static bool ITifJSONObjectEndHandler(void* context) return true; } -static bool ITifJSONObjectMemberHandler(void* context, const char *pValue, size_t length) +static bool ITifJSONObjectMemberHandler(void* context, const char *pValue, size_t len) { ITifJSONContext *pCtx = (ITifJSONContext*)context; @@ -286,7 +286,7 @@ static bool ITifJSONObjectMemberHandler(void* context, const char *pValue, size_ if (pCtx->current_entry_str_val) return false; - if (length) + if (len) { if (string_is_equal(pValue, "expected_button")) pCtx->current_entry_uint_val = &pCtx->expected_button; @@ -298,11 +298,11 @@ static bool ITifJSONObjectMemberHandler(void* context, const char *pValue, size_ return true; } -static bool ITifJSONNumberHandler(void* context, const char *pValue, size_t length) +static bool ITifJSONNumberHandler(void* context, const char *pValue, size_t len) { ITifJSONContext *pCtx = (ITifJSONContext*)context; - if (pCtx->current_entry_uint_val && length && !string_is_empty(pValue)) + if (pCtx->current_entry_uint_val && len && !string_is_empty(pValue)) *pCtx->current_entry_uint_val = string_to_unsigned(pValue); /* ignore unknown members */ @@ -311,11 +311,11 @@ static bool ITifJSONNumberHandler(void* context, const char *pValue, size_t leng return true; } -static bool ITifJSONStringHandler(void* context, const char *pValue, size_t length) +static bool ITifJSONStringHandler(void* context, const char *pValue, size_t len) { ITifJSONContext *pCtx = (ITifJSONContext*)context; - if (pCtx->current_entry_str_val && length && !string_is_empty(pValue)) + if (pCtx->current_entry_str_val && len && !string_is_empty(pValue)) { if (*pCtx->current_entry_str_val) free(*pCtx->current_entry_str_val); @@ -728,7 +728,7 @@ static void retropad_update_input(void) pointer_y = (int16_t)state; } } - + /* Do not send extra descriptor state - RA side is not prepared to receive it */ if (i>1) continue; @@ -1035,7 +1035,7 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void) sensor_item_colors[median_index] = (uint16_t)(fabsf(32*4*value)) << 11; } } - + /* Button values for sensor test screen, since they do not follow any pattern, it is * * provided as a direct list. */ if (mouse_type == NETRETROPAD_MOUSE) @@ -1062,7 +1062,7 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void) offset = DESC_OFFSET(&mouse, 0, 0, RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP); sensor_item_colors[86] = mouse.value[offset] ? 0xA000 : 0x0000; - + offset = DESC_OFFSET(&mouse, 0, 0, RETRO_DEVICE_ID_MOUSE_BUTTON_4); sensor_item_colors[88] = mouse.value[offset] ? 0xA000 : 0x0000; @@ -1094,7 +1094,7 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void) offset = DESC_OFFSET(&lightgun, 0, 0, RETRO_DEVICE_ID_LIGHTGUN_SELECT); sensor_item_colors[76] = lightgun.value[offset] ? 0xA000 : 0x0000; - + offset = DESC_OFFSET(&lightgun, 0, 0, RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN); sensor_item_colors[77] = lightgun.value[offset] ? 0xA000 : 0x0000; @@ -1390,7 +1390,7 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void) pointer_prev_y = pointer_y_coord; } } - + NETRETROPAD_CORE_PREFIX(video_cb)(frame_buf, 320, 240, 640); retro_sleep(4); } diff --git a/disk_index_file.c b/disk_index_file.c index 00ec7570ef81..c35c8739bc29 100644 --- a/disk_index_file.c +++ b/disk_index_file.c @@ -43,7 +43,7 @@ typedef struct char *image_path; } DCifJSONContext; -static bool DCifJSONObjectMemberHandler(void* context, const char *pValue, size_t length) +static bool DCifJSONObjectMemberHandler(void* context, const char *pValue, size_t len) { DCifJSONContext *pCtx = (DCifJSONContext*)context; @@ -51,7 +51,7 @@ static bool DCifJSONObjectMemberHandler(void* context, const char *pValue, size_ if (pCtx->current_entry_str_val) return false; - if (length) + if (len) { if (string_is_equal(pValue, "image_index")) pCtx->current_entry_uint_val = &pCtx->image_index; @@ -63,11 +63,11 @@ static bool DCifJSONObjectMemberHandler(void* context, const char *pValue, size_ return true; } -static bool DCifJSONNumberHandler(void* context, const char *pValue, size_t length) +static bool DCifJSONNumberHandler(void* context, const char *pValue, size_t len) { DCifJSONContext *pCtx = (DCifJSONContext*)context; - if (pCtx->current_entry_uint_val && length && !string_is_empty(pValue)) + if (pCtx->current_entry_uint_val && len && !string_is_empty(pValue)) *pCtx->current_entry_uint_val = string_to_unsigned(pValue); /* ignore unknown members */ @@ -76,11 +76,11 @@ static bool DCifJSONNumberHandler(void* context, const char *pValue, size_t leng return true; } -static bool DCifJSONStringHandler(void* context, const char *pValue, size_t length) +static bool DCifJSONStringHandler(void* context, const char *pValue, size_t len) { DCifJSONContext *pCtx = (DCifJSONContext*)context; - if (pCtx->current_entry_str_val && length && !string_is_empty(pValue)) + if (pCtx->current_entry_str_val && len && !string_is_empty(pValue)) { free(*pCtx->current_entry_str_val); diff --git a/input/common/wayland_common.c b/input/common/wayland_common.c index 0be0406c32a3..f17d2fe2ca88 100644 --- a/input/common/wayland_common.c +++ b/input/common/wayland_common.c @@ -996,8 +996,7 @@ static void wl_data_device_handle_drop(void *data, FILE *stream; int pipefd[2]; void *buffer; - size_t length; - size_t _len = 0; + size_t __len, _len = 0; ssize_t read = 0; char *line = NULL; char file_list[512][512] = { 0 }; @@ -1012,7 +1011,7 @@ static void wl_data_device_handle_drop(void *data, pipe(pipefd); - buffer = wayland_data_offer_receive(wl->input.dpy, offer_data->offer, &length, FILE_MIME, false); + buffer = wayland_data_offer_receive(wl->input.dpy, offer_data->offer, &__len, FILE_MIME, false); close(pipefd[1]); close(pipefd[0]); @@ -1023,7 +1022,7 @@ static void wl_data_device_handle_drop(void *data, wl_data_offer_destroy(offer_data->offer); free(offer_data); - if (!(stream = fmemopen(buffer, length, "r"))) + if (!(stream = fmemopen(buffer, __len, "r"))) { RARCH_WARN("[Wayland]: Failed to open DnD buffer\n"); return; diff --git a/input/drivers/test_input.c b/input/drivers/test_input.c index 7a0ae52b44b5..c20a20291906 100644 --- a/input/drivers/test_input.c +++ b/input/drivers/test_input.c @@ -125,7 +125,7 @@ static bool KTifJSONObjectEndHandler(void* context) return true; } -static bool KTifJSONObjectMemberHandler(void* context, const char *pValue, size_t length) +static bool KTifJSONObjectMemberHandler(void* context, const char *pValue, size_t len) { KTifJSONContext *pCtx = (KTifJSONContext*)context; @@ -133,7 +133,7 @@ static bool KTifJSONObjectMemberHandler(void* context, const char *pValue, size_ if (pCtx->current_entry_str_val) return false; - if (length) + if (len) { if (string_is_equal(pValue, "frame")) pCtx->current_entry_uint_val = &pCtx->frame; @@ -149,11 +149,11 @@ static bool KTifJSONObjectMemberHandler(void* context, const char *pValue, size_ return true; } -static bool KTifJSONNumberHandler(void* context, const char *pValue, size_t length) +static bool KTifJSONNumberHandler(void* context, const char *pValue, size_t len) { KTifJSONContext *pCtx = (KTifJSONContext*)context; - if (pCtx->current_entry_uint_val && length && !string_is_empty(pValue)) + if (pCtx->current_entry_uint_val && len && !string_is_empty(pValue)) *pCtx->current_entry_uint_val = string_to_unsigned(pValue); /* ignore unknown members */ @@ -162,11 +162,11 @@ static bool KTifJSONNumberHandler(void* context, const char *pValue, size_t leng return true; } -static bool KTifJSONStringHandler(void* context, const char *pValue, size_t length) +static bool KTifJSONStringHandler(void* context, const char *pValue, size_t len) { KTifJSONContext *pCtx = (KTifJSONContext*)context; - if (pCtx->current_entry_str_val && length && !string_is_empty(pValue)) + if (pCtx->current_entry_str_val && len && !string_is_empty(pValue)) { if (*pCtx->current_entry_str_val) free(*pCtx->current_entry_str_val); diff --git a/input/drivers_joypad/test_joypad.c b/input/drivers_joypad/test_joypad.c index 28b475fa81c5..d5a72b8822ca 100644 --- a/input/drivers_joypad/test_joypad.c +++ b/input/drivers_joypad/test_joypad.c @@ -125,7 +125,7 @@ static bool JTifJSONObjectEndHandler(void* context) return true; } -static bool JTifJSONObjectMemberHandler(void* context, const char *pValue, size_t length) +static bool JTifJSONObjectMemberHandler(void* context, const char *pValue, size_t len) { JTifJSONContext *pCtx = (JTifJSONContext*)context; @@ -133,7 +133,7 @@ static bool JTifJSONObjectMemberHandler(void* context, const char *pValue, size_ if (pCtx->current_entry_str_val) return false; - if (length) + if (len) { if (string_is_equal(pValue, "frame")) pCtx->current_entry_uint_val = &pCtx->frame; @@ -149,11 +149,11 @@ static bool JTifJSONObjectMemberHandler(void* context, const char *pValue, size_ return true; } -static bool JTifJSONNumberHandler(void* context, const char *pValue, size_t length) +static bool JTifJSONNumberHandler(void* context, const char *pValue, size_t len) { JTifJSONContext *pCtx = (JTifJSONContext*)context; - if (pCtx->current_entry_uint_val && length && !string_is_empty(pValue)) + if (pCtx->current_entry_uint_val && len && !string_is_empty(pValue)) *pCtx->current_entry_uint_val = string_to_unsigned(pValue); /* ignore unknown members */ @@ -162,11 +162,11 @@ static bool JTifJSONNumberHandler(void* context, const char *pValue, size_t leng return true; } -static bool JTifJSONStringHandler(void* context, const char *pValue, size_t length) +static bool JTifJSONStringHandler(void* context, const char *pValue, size_t len) { JTifJSONContext *pCtx = (JTifJSONContext*)context; - if (pCtx->current_entry_str_val && length && !string_is_empty(pValue)) + if (pCtx->current_entry_str_val && len && !string_is_empty(pValue)) { if (*pCtx->current_entry_str_val) free(*pCtx->current_entry_str_val); diff --git a/input/drivers_joypad/udev_joypad.c b/input/drivers_joypad/udev_joypad.c index d06bb00b8e4e..4e7fd4049c46 100644 --- a/input/drivers_joypad/udev_joypad.c +++ b/input/drivers_joypad/udev_joypad.c @@ -520,17 +520,18 @@ static void udev_joypad_poll(void) for (p = 0; p < MAX_USERS; p++) { - int i, len; + int i; + ssize_t _len; struct input_event events[32]; struct udev_joypad *pad = &udev_pads[p]; if (pad->fd < 0) continue; - while ((len = read(pad->fd, events, sizeof(events))) > 0) + while ((_len = read(pad->fd, events, sizeof(events))) > 0) { - len /= sizeof(*events); - for (i = 0; i < len; i++) + _len /= sizeof(*events); + for (i = 0; i < _len; i++) { uint16_t type = events[i].type; uint16_t code = events[i].code; diff --git a/input/include/hid_driver.h b/input/include/hid_driver.h index b6e63dcfc149..8d7143c4d4fa 100644 --- a/input/include/hid_driver.h +++ b/input/include/hid_driver.h @@ -50,8 +50,8 @@ struct hid_driver const char *(*name)(void *handle, unsigned pad); const char *ident; void (*send_control)(void *handle, uint8_t *buf, size_t size); - int32_t (*set_report)(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *data, size_t length); - int32_t (*get_report)(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *data, size_t length); + int32_t (*set_report)(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *data, size_t len); + int32_t (*get_report)(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *data, size_t len); int32_t (*set_idle)(void *handle, uint8_t amount); int32_t (*set_protocol)(void *handle, uint8_t protocol); int32_t (*read)(void *handle, void *buf, size_t size); diff --git a/libretro-common/file/archive_file.c b/libretro-common/file/archive_file.c index 0b3a6bf1c149..ad90ee68628f 100644 --- a/libretro-common/file/archive_file.c +++ b/libretro-common/file/archive_file.c @@ -526,7 +526,7 @@ static struct string_list *file_archive_filename_split(const char *path) */ int file_archive_compressed_read( const char * path, void **buf, - const char* optional_filename, int64_t *length) + const char* optional_filename, int64_t *len) { const struct file_archive_file_backend *backend = NULL; @@ -540,7 +540,7 @@ int file_archive_compressed_read( */ if (optional_filename && path_is_valid(optional_filename)) { - *length = 0; + *len = 0; return 1; } @@ -555,17 +555,17 @@ int file_archive_compressed_read( { /* could not extract string and substring. */ string_list_free(str_list); - *length = 0; + *len = 0; return 0; } backend = file_archive_get_file_backend(str_list->elems[0].data); - *length = backend->compressed_file_read(str_list->elems[0].data, + *len = backend->compressed_file_read(str_list->elems[0].data, str_list->elems[1].data, buf, optional_filename); string_list_free(str_list); - if (*length != -1) + if (*len != -1) return 1; return 0; diff --git a/libretro-common/file/archive_file_7z.c b/libretro-common/file/archive_file_7z.c index adcb15a3bb2c..289ec25f1c00 100644 --- a/libretro-common/file/archive_file_7z.c +++ b/libretro-common/file/archive_file_7z.c @@ -515,9 +515,9 @@ static int sevenzip_parse_file_iterate_step(void *context, } static uint32_t sevenzip_stream_crc32_calculate(uint32_t crc, - const uint8_t *data, size_t length) + const uint8_t *data, size_t len) { - return encoding_crc32(crc, data, length); + return encoding_crc32(crc, data, len); } const struct file_archive_file_backend sevenzip_backend = { diff --git a/libretro-common/file/archive_file_zlib.c b/libretro-common/file/archive_file_zlib.c index d82af9aea4f5..352650dd21fe 100644 --- a/libretro-common/file/archive_file_zlib.c +++ b/libretro-common/file/archive_file_zlib.c @@ -256,9 +256,9 @@ static int zlib_stream_decompress_data_to_file_iterate( } static uint32_t zlib_stream_crc32_calculate(uint32_t crc, - const uint8_t *data, size_t length) + const uint8_t *data, size_t len) { - return encoding_crc32(crc, data, length); + return encoding_crc32(crc, data, len); } static bool zip_file_decompressed_handle( diff --git a/libretro-common/file/nbio/nbio_unixmmap.c b/libretro-common/file/nbio/nbio_unixmmap.c index 1a94238beb7e..7a9856e72c5a 100644 --- a/libretro-common/file/nbio/nbio_unixmmap.c +++ b/libretro-common/file/nbio/nbio_unixmmap.c @@ -66,16 +66,16 @@ static void *nbio_mmap_unix_open(const char * filename, unsigned mode) static const int o_flags[] = { O_RDONLY, O_RDWR|O_CREAT|O_TRUNC, O_RDWR, O_RDONLY, O_RDWR|O_CREAT|O_TRUNC }; static const int map_flags[] = { PROT_READ, PROT_WRITE|PROT_READ, PROT_WRITE|PROT_READ, PROT_READ, PROT_WRITE|PROT_READ }; - size_t len; + size_t _len; void* ptr = NULL; struct nbio_mmap_unix_t* handle = NULL; int fd = open(filename, o_flags[mode]|O_CLOEXEC, 0644); if (fd < 0) return NULL; - len = lseek(fd, 0, SEEK_END); - if (len != 0) - ptr = mmap(NULL, len, map_flags[mode], MAP_SHARED, fd, 0); + _len = lseek(fd, 0, SEEK_END); + if (_len != 0) + ptr = mmap(NULL, _len, map_flags[mode], MAP_SHARED, fd, 0); if (ptr == MAP_FAILED) { @@ -86,7 +86,7 @@ static void *nbio_mmap_unix_open(const char * filename, unsigned mode) handle = malloc(sizeof(struct nbio_mmap_unix_t)); handle->fd = fd; handle->map_flags = map_flags[mode]; - handle->len = len; + handle->len = _len; handle->ptr = ptr; return handle; } @@ -132,7 +132,7 @@ static void nbio_mmap_unix_resize(void *data, size_t len) abort(); } -static void *nbio_mmap_unix_get_ptr(void *data, size_t* len) +static void *nbio_mmap_unix_get_ptr(void *data, size_t *len) { struct nbio_mmap_unix_t* handle = (struct nbio_mmap_unix_t*)data; if (!handle) diff --git a/libretro-common/formats/json/rjson.c b/libretro-common/formats/json/rjson.c index bb3eaf346c39..9c79569bf4dd 100644 --- a/libretro-common/formats/json/rjson.c +++ b/libretro-common/formats/json/rjson.c @@ -987,12 +987,12 @@ void rjson_set_max_depth(rjson_t *json, unsigned int max_depth) json->stack_max = max_depth; } -const char *rjson_get_string(rjson_t *json, size_t *length) +const char *rjson_get_string(rjson_t *json, size_t *len) { char* str = (json->string_pass_through ? json->string_pass_through : json->string); - if (length) - *length = json->string_len; + if (len) + *len = json->string_len; str[json->string_len] = '\0'; return str; } @@ -1112,7 +1112,7 @@ void rjson_free(rjson_t *json) } static bool _rjson_nop_default(void *context) { return true; } -static bool _rjson_nop_string(void *context, const char *value, size_t length) { return true; } +static bool _rjson_nop_string(void *context, const char *value, size_t len) { return true; } static bool _rjson_nop_bool(void *context, bool value) { return true; } enum rjson_type rjson_parse(rjson_t *json, void* context, diff --git a/libretro-common/hash/lrc_hash.c b/libretro-common/hash/lrc_hash.c index 98ce13282366..cf2979f35f1b 100644 --- a/libretro-common/hash/lrc_hash.c +++ b/libretro-common/hash/lrc_hash.c @@ -252,11 +252,11 @@ uint32_t crc32_adjust(uint32_t checksum, uint8_t input) return ((checksum >> 8) & 0x00ffffff) ^ crc32_hash_table[(checksum ^ input) & 0xff]; } -uint32_t crc32_calculate(const uint8_t *data, size_t length) +uint32_t crc32_calculate(const uint8_t *data, size_t len) { size_t i; uint32_t checksum = ~0; - for (i = 0; i < length; i++) + for (i = 0; i < len; i++) checksum = crc32_adjust(checksum, data[i]); return ~checksum; } @@ -486,9 +486,9 @@ static int SHA1Result(struct sha1_context *context) static void SHA1Input(struct sha1_context *context, const unsigned char *message_array, - unsigned length) + unsigned len) { - if (!length) + if (!len) return; if (context->Computed || context->Corrupted) @@ -497,7 +497,7 @@ static void SHA1Input(struct sha1_context *context, return; } - while (length-- && !context->Corrupted) + while (len-- && !context->Corrupted) { context->Message_Block[context->Message_Block_Index++] = (*message_array & 0xFF); diff --git a/libretro-common/memmap/memmap.c b/libretro-common/memmap/memmap.c index 5062abaae28c..229ed170fd68 100644 --- a/libretro-common/memmap/memmap.c +++ b/libretro-common/memmap/memmap.c @@ -92,7 +92,7 @@ void* mmap(void *addr, size_t len, int prot, int flags, return((void*) ((int8_t*)map + offset)); } -int munmap(void *addr, size_t length) +int munmap(void *addr, size_t len) { if (!UnmapViewOfFile(addr)) return -1; diff --git a/libretro-common/samples/net/net_http_test.c b/libretro-common/samples/net/net_http_test.c index ebd0167e4200..57a29fb6c4f9 100644 --- a/libretro-common/samples/net/net_http_test.c +++ b/libretro-common/samples/net/net_http_test.c @@ -32,7 +32,7 @@ int main(void) { char *data; struct http_t *http1, *http3; - size_t len, pos = 0, tot = 0; + size_t _len, pos = 0, tot = 0; if (!network_init()) return -1; @@ -45,7 +45,7 @@ int main(void) http3 = net_http_new("http://www.wikipedia.org/"); while (!net_http_update(http3, NULL, NULL)) {} - data = (char*)net_http_data(http3, &len, false); + data = (char*)net_http_data(http3, &_len, false); printf("%.*s\n", (int)256, data); diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 6a94a4f3d81d..437564107255 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -4069,8 +4069,7 @@ static size_t menu_driver_get_current_menu_label(struct menu_state *menu_st, #endif static size_t menu_driver_get_current_menu_sublabel( - struct menu_state *menu_st, - char *s, size_t len) + struct menu_state *menu_st, char *s, size_t len) { menu_entry_t entry; MENU_ENTRY_INITIALIZE(entry); diff --git a/runloop.c b/runloop.c index 99c5a3304aad..a8079f9fe3be 100644 --- a/runloop.c +++ b/runloop.c @@ -1141,8 +1141,7 @@ static bool validate_game_specific_options(char *s, size_t len) return true; } -static bool validate_folder_options( - char *s, size_t len, bool mkdir) +static bool validate_folder_options(char *s, size_t len, bool mkdir) { const char *game_path = path_get(RARCH_PATH_BASENAME); @@ -4852,42 +4851,42 @@ void runloop_path_fill_names(void) if (string_is_empty(runloop_st->name.ups)) { - size_t len = strlcpy(runloop_st->name.ups, + size_t _len = strlcpy(runloop_st->name.ups, runloop_st->runtime_content_path_basename, sizeof(runloop_st->name.ups)); - strlcpy(runloop_st->name.ups + len, + strlcpy(runloop_st->name.ups + _len, ".ups", - sizeof(runloop_st->name.ups) - len); + sizeof(runloop_st->name.ups) - _len); } if (string_is_empty(runloop_st->name.bps)) { - size_t len = strlcpy(runloop_st->name.bps, + size_t _len = strlcpy(runloop_st->name.bps, runloop_st->runtime_content_path_basename, sizeof(runloop_st->name.bps)); - strlcpy(runloop_st->name.bps + len, + strlcpy(runloop_st->name.bps + _len, ".bps", - sizeof(runloop_st->name.bps) - len); + sizeof(runloop_st->name.bps) - _len); } if (string_is_empty(runloop_st->name.ips)) { - size_t len = strlcpy(runloop_st->name.ips, + size_t _len = strlcpy(runloop_st->name.ips, runloop_st->runtime_content_path_basename, sizeof(runloop_st->name.ips)); - strlcpy(runloop_st->name.ips + len, + strlcpy(runloop_st->name.ips + _len, ".ips", - sizeof(runloop_st->name.ips) - len); + sizeof(runloop_st->name.ips) - _len); } if (string_is_empty(runloop_st->name.xdelta)) { - size_t len = strlcpy(runloop_st->name.xdelta, + size_t _len = strlcpy(runloop_st->name.xdelta, runloop_st->runtime_content_path_basename, sizeof(runloop_st->name.xdelta)); - strlcpy(runloop_st->name.xdelta + len, + strlcpy(runloop_st->name.xdelta + _len, ".xdelta", - sizeof(runloop_st->name.xdelta) - len); + sizeof(runloop_st->name.xdelta) - _len); } } @@ -7345,19 +7344,19 @@ void runloop_task_msg_queue_push( } -bool runloop_get_current_savestate_path(char *path, size_t len) +bool runloop_get_current_savestate_path(char *s, size_t len) { settings_t *settings = config_get_ptr(); int state_slot = settings ? settings->ints.state_slot : 0; - return runloop_get_savestate_path(path, len, state_slot); + return runloop_get_savestate_path(s, len, state_slot); } -bool runloop_get_savestate_path(char *path, size_t len, int state_slot) +bool runloop_get_savestate_path(char *s, size_t len, int state_slot) { runloop_state_t *runloop_st = &runloop_state; const char *name_savestate = NULL; - if (!path) + if (!s) return false; name_savestate = runloop_st->name.savestate; @@ -7365,61 +7364,61 @@ bool runloop_get_savestate_path(char *path, size_t len, int state_slot) return false; if (state_slot < 0) - fill_pathname_join_delim(path, name_savestate, "auto", '.', len); + fill_pathname_join_delim(s, name_savestate, "auto", '.', len); else { - size_t _len = strlcpy(path, name_savestate, len); + size_t _len = strlcpy(s, name_savestate, len); if (state_slot > 0) - snprintf(path + _len, len - _len, "%d", state_slot); + snprintf(s + _len, len - _len, "%d", state_slot); } return true; } -bool runloop_get_current_replay_path(char *path, size_t len) +bool runloop_get_current_replay_path(char *s, size_t len) { settings_t *settings = config_get_ptr(); int slot = settings ? settings->ints.replay_slot : 0; - return runloop_get_replay_path(path, len, slot); + return runloop_get_replay_path(s, len, slot); } -bool runloop_get_replay_path(char *path, size_t len, unsigned slot) +bool runloop_get_replay_path(char *s, size_t len, unsigned slot) { size_t _len; runloop_state_t *runloop_st = &runloop_state; const char *name_replay = NULL; - if (!path) + if (!s) return false; name_replay = runloop_st->name.replay; if (string_is_empty(name_replay)) return false; - _len = strlcpy(path, name_replay, len); + _len = strlcpy(s, name_replay, len); if (slot >= 0) - snprintf(path + _len, len - _len, "%d", slot); + snprintf(s + _len, len - _len, "%d", slot); return true; } -bool runloop_get_entry_state_path(char *path, size_t len, unsigned slot) +bool runloop_get_entry_state_path(char *s, size_t len, unsigned slot) { size_t _len; runloop_state_t *runloop_st = &runloop_state; const char *name_savestate = NULL; - if (!path || !slot) + if (!s || !slot) return false; name_savestate = runloop_st->name.savestate; if (string_is_empty(name_savestate)) return false; - _len = strlcpy(path, name_savestate, len); - snprintf(path + _len, len - _len, "%d.entry", slot); + _len = strlcpy(s, name_savestate, len); + snprintf(s + _len, len - _len, "%d.entry", slot); return true; } @@ -7892,8 +7891,8 @@ void runloop_path_set_names(void) } void runloop_path_set_redirect(settings_t *settings, - const char *old_savefile_dir, - const char *old_savestate_dir) + const char *old_savefile_dir, + const char *old_savestate_dir) { char content_dir_name[DIR_MAX_LENGTH]; char new_savefile_dir[DIR_MAX_LENGTH]; diff --git a/tasks/task_database_cue.c b/tasks/task_database_cue.c index 0a004ca5eb28..56478ccffff7 100644 --- a/tasks/task_database_cue.c +++ b/tasks/task_database_cue.c @@ -551,14 +551,12 @@ int detect_scd_game(intfstream_t *fd, char *s, size_t len, const char *filename) #define SCD_SERIAL_OFFSET 0x0193 #define SCD_SERIAL_LEN 11 #define SCD_REGION_OFFSET 0x0200 - size_t _len; + int index; + size_t _len, __len, ___len; char pre_game_id[SCD_SERIAL_LEN+1]; char raw_game_id[SCD_SERIAL_LEN+1]; char check_suffix_50[10]; char region_id; - size_t length; - size_t lengthref; - int index; char lgame_id[10]; /* Load raw serial or quit */ @@ -588,9 +586,9 @@ int detect_scd_game(intfstream_t *fd, char *s, size_t len, const char *filename) string_remove_all_whitespace(pre_game_id, raw_game_id); /** rule: remove all spaces from the raw serial globally **/ /** Dissect this pre serial into parts **/ - length = strlen(pre_game_id); - lengthref = length - 2; - strncpy(check_suffix_50, &pre_game_id[lengthref], length - 2 + 1); + __len = strlen(pre_game_id); + ___len = __len - 2; + strncpy(check_suffix_50, &pre_game_id[___len], __len - 2 + 1); check_suffix_50[2] = '\0'; /** redump serials are built differently for each prefix **/ @@ -666,7 +664,7 @@ int detect_sat_game(intfstream_t *fd, char *s, size_t len, const char *filename) #define SAT_SERIAL_OFFSET 0x0030 #define SAT_SERIAL_LEN 9 #define SAT_REGION_OFFSET 0x0050 - size_t _len, length; + size_t _len, __len; char raw_game_id[SAT_SERIAL_LEN+1]; char region_id; char check_suffix_5[10]; @@ -703,10 +701,10 @@ int detect_sat_game(intfstream_t *fd, char *s, size_t len, const char *filename) string_trim_whitespace_left(raw_game_id); /** Dissect this raw serial into parts **/ - length = strlen(raw_game_id); - strncpy(check_suffix_5, &raw_game_id[length - 2], 2); + __len = strlen(raw_game_id); + strncpy(check_suffix_5, &raw_game_id[__len - 2], 2); check_suffix_5[2] = '\0'; - strncpy(check_suffix_50, &raw_game_id[length - 2], 2); + strncpy(check_suffix_50, &raw_game_id[__len - 2], 2); check_suffix_50[2] = '\0'; /** redump serials are built differently for each region **/ @@ -717,8 +715,8 @@ int detect_sat_game(intfstream_t *fd, char *s, size_t len, const char *filename) && raw_game_id[1] == 'K' && raw_game_id[2] == '-') { - strncpy(s, &raw_game_id[3], length - 3); - s[length - 3] = '\0'; + strncpy(s, &raw_game_id[3], __len - 3); + s[__len - 3] = '\0'; } else strlcpy(s, raw_game_id, len); @@ -730,13 +728,13 @@ int detect_sat_game(intfstream_t *fd, char *s, size_t len, const char *filename) if ( !strcmp(check_suffix_5, "-5") || !strcmp(check_suffix_50, "50")) { - strncpy(rgame_id, &raw_game_id[2], length - 4); - rgame_id[length - 4] = '\0'; + strncpy(rgame_id, &raw_game_id[2], __len - 4); + rgame_id[__len - 4] = '\0'; } else { - strncpy(rgame_id, &raw_game_id[2], length - 1); - rgame_id[length - 1] = '\0'; + strncpy(rgame_id, &raw_game_id[2], __len - 1); + rgame_id[__len - 1] = '\0'; } _len = strlcat(s, lgame_id, len); _len += strlcpy(s + _len, rgame_id, len - _len); @@ -759,13 +757,11 @@ int detect_sat_game(intfstream_t *fd, char *s, size_t len, const char *filename) int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename) { - size_t _len; + size_t _len, __len, ___len; int total_hyphens; int total_hyphens_recalc; char pre_game_id[50]; char raw_game_id[50]; - size_t length; - size_t length_recalc; int index; size_t size_t_var; char lgame_id[20]; @@ -794,7 +790,7 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename) string_trim_whitespace_left(raw_game_id); string_replace_multi_space_with_single_space(raw_game_id); string_replace_whitespace_with_single_character(raw_game_id, '-'); - length = strlen(raw_game_id); + __len = strlen(raw_game_id); total_hyphens = string_count_occurrences_single_character(raw_game_id, '-'); /** redump serials are built differently for each prefix **/ @@ -809,14 +805,14 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename) size_t_var = (size_t)index; strncpy(lgame_id, &raw_game_id[0], size_t_var); lgame_id[index] = '\0'; - strncpy(rgame_id, &raw_game_id[index + 1], length - 1); - rgame_id[length - 1] = '\0'; + strncpy(rgame_id, &raw_game_id[index + 1], __len - 1); + rgame_id[__len - 1] = '\0'; _len = strlcat(s, lgame_id, len); s[ _len] = '-'; s[++_len] = '\0'; strlcpy(s + _len, rgame_id, len - _len); } - else if (length <= 7) + else if (__len <= 7) { strncpy(s, raw_game_id, 7); s[7] = '\0'; @@ -825,8 +821,8 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename) { strncpy(lgame_id, raw_game_id, 7); lgame_id[7] = '\0'; - strncpy(rgame_id, &raw_game_id[length - 2], length - 1); - rgame_id[length - 1] = '\0'; + strncpy(rgame_id, &raw_game_id[__len - 2], __len - 1); + rgame_id[__len - 1] = '\0'; _len = strlcat(s, lgame_id, len); s[ _len] = '-'; s[++_len] = '\0'; @@ -839,8 +835,8 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename) { strncpy(lgame_id, raw_game_id, 1); lgame_id[1] = '\0'; - strncpy(rgame_id, &raw_game_id[1], length - 1); - rgame_id[length - 1] = '\0'; + strncpy(rgame_id, &raw_game_id[1], __len - 1); + rgame_id[__len - 1] = '\0'; _len = strlcpy(pre_game_id, lgame_id, sizeof(pre_game_id)); pre_game_id[ _len] = '-'; pre_game_id[++_len] = '\0'; @@ -855,12 +851,12 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename) size_t_var = (size_t)index; strncpy(lgame_id, pre_game_id, size_t_var); lgame_id[index] = '\0'; - length_recalc = strlen(pre_game_id); + ___len = strlen(pre_game_id); } else { - length_recalc = strlen(pre_game_id) - 1; - if (length_recalc <= 8) + ___len = strlen(pre_game_id) - 1; + if (___len <= 8) { strncpy(s, pre_game_id, 8); s[8] = '\0'; @@ -870,8 +866,8 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename) strncpy(lgame_id, pre_game_id, 7); lgame_id[7] = '\0'; } - strncpy(rgame_id, &pre_game_id[length_recalc - 2], length_recalc - 1); - rgame_id[length_recalc - 1] = '\0'; + strncpy(rgame_id, &pre_game_id[___len - 2], ___len - 1); + rgame_id[___len - 1] = '\0'; _len = strlcat(s, lgame_id, len); s[ _len] = '-'; s[++_len] = '\0'; @@ -891,8 +887,8 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename) return false; strncpy(lgame_id, raw_game_id, index - 1); lgame_id[index - 1] = '\0'; - strncpy(rgame_id, &raw_game_id[length - 4], length - 3); - rgame_id[length - 3] = '\0'; + strncpy(rgame_id, &raw_game_id[__len - 4], __len - 3); + rgame_id[__len - 3] = '\0'; _len = strlcat(s, lgame_id, len); s[ _len] = '-'; s[++_len] = '\0'; @@ -907,7 +903,7 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename) && raw_game_id[1] == 'K' && raw_game_id[2] == '-') { - if (length <= 8) + if (__len <= 8) { /* For 8 chars serials in 'MK-xxxxx' format, we need to remove 'MK-' to match Redump database * Sega GT being the only exception (MK-51053), we have to check if it's not that game first */ @@ -926,8 +922,8 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename) { strncpy(lgame_id, raw_game_id, 8); lgame_id[8] = '\0'; - strncpy(rgame_id, &raw_game_id[length - 2], length - 1); - rgame_id[length - 1] = '\0'; + strncpy(rgame_id, &raw_game_id[__len - 2], __len - 1); + rgame_id[__len - 1] = '\0'; _len = strlcat(s, lgame_id, len); s[ _len] = '-'; s[++_len] = '\0'; From 0bb00773582414e4ea8db40636ec94639e4ac1ea Mon Sep 17 00:00:00 2001 From: Jesse Talavera Date: Mon, 13 Jan 2025 15:54:52 -0500 Subject: [PATCH 05/49] Fix a crash when initializing an illuminance sensor on Linux (#17408) --- input/common/linux_common.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/input/common/linux_common.c b/input/common/linux_common.c index c3705bd5da75..32f7c45dded9 100644 --- a/input/common/linux_common.c +++ b/input/common/linux_common.c @@ -201,6 +201,10 @@ linux_illuminance_sensor_t *linux_open_illuminance_sensor(unsigned rate) if (!sensor) goto error; + device = retro_opendir(IIO_DEVICES_DIR); + if (!device) + goto error; + sensor->millilux = 0; sensor->poll_rate = rate ? rate : DEFAULT_POLL_RATE; sensor->thread = NULL; /* We'll spawn a thread later, once we find a sensor */ @@ -243,7 +247,7 @@ linux_illuminance_sensor_t *linux_open_illuminance_sensor(unsigned rate) } error: - RARCH_ERR("Failed to find an illuminance sensor\n"); + RARCH_ERR("Failed to find an illuminance sensor in " IIO_DEVICES_DIR "\n"); retro_closedir(device); free(sensor); From 31534438bc39186fbf0180611f6d28a653aee7be Mon Sep 17 00:00:00 2001 From: zoltanvb <101990835+zoltanvb@users.noreply.github.com> Date: Tue, 14 Jan 2025 16:19:05 +0100 Subject: [PATCH 06/49] Enable also alternative device names (#17412) Enable input_device_device_display_name to also have alt_ variants. Tests updated. --- tasks/task_autodetect.c | 41 ++++++++++++++----- tests-other/autoconf/TestpadD_alternative.cfg | 5 ++- .../testinput_alternative_autoconfig.cfg | 2 +- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/tasks/task_autodetect.c b/tasks/task_autodetect.c index 92a97b0762af..1d5086c79faf 100644 --- a/tasks/task_autodetect.c +++ b/tasks/task_autodetect.c @@ -105,9 +105,9 @@ static void input_autoconfigure_free(retro_task_t *task) * 'affinity' between the connected input * device and the specified config file * > 0: No match - * > 2: Device name matches - * > 3: VID+PID match - * > 5: Both device name and VID+PID match */ + * > 20-29: Device name matches + * > 30-39: VID+PID match + * > 50-59: Both device name and VID+PID match */ static unsigned input_autoconfigure_get_config_file_affinity( autoconfig_handle_t *autoconfig_handle, config_file_t *config) @@ -172,7 +172,7 @@ static unsigned input_autoconfigure_get_config_file_affinity( #endif if (pid_match) - affinity += 3; + affinity += 30; /* Check for matching device name */ _len = strlcpy(config_key, "input_device", @@ -183,7 +183,11 @@ static unsigned input_autoconfigure_get_config_file_affinity( && !string_is_empty(entry->value) && string_is_equal(entry->value, autoconfig_handle->device_info.name)) - affinity += 2; + affinity += 20; + + /* Store the selected alternative as last digit of affinity. */ + if (affinity > 0) + affinity += i; if (max_affinity < affinity) max_affinity = affinity; @@ -196,9 +200,12 @@ static unsigned input_autoconfigure_get_config_file_affinity( * handle, parsing required device info metadata */ static void input_autoconfigure_set_config_file( autoconfig_handle_t *autoconfig_handle, - config_file_t *config) + config_file_t *config, unsigned alternative) { struct config_entry_list *entry = NULL; + char config_key[32] = {0}; + char config_key_postfix[7] = {0}; + size_t _len; /* Attach config file */ autoconfig_handle->autoconfig_file = config; @@ -214,7 +221,17 @@ static void input_autoconfigure_set_config_file( } /* Read device display name */ - if ( (entry = config_get_entry(config, "input_device_display_name")) + if (alternative > 0) + snprintf(config_key_postfix, sizeof(config_key_postfix), + "_alt%d",alternative); + + /* Parse config file */ + _len = strlcpy(config_key, "input_device_display_name", + sizeof(config_key)); + _len += strlcpy(config_key + _len, config_key_postfix, + sizeof(config_key) - _len); + + if ( (entry = config_get_entry(config, config_key)) && !string_is_empty(entry->value)) strlcpy(autoconfig_handle->device_info.display_name, entry->value, @@ -299,9 +316,9 @@ static bool input_autoconfigure_scan_config_files_external( config = NULL; max_affinity = affinity; - /* An affinity of 5 is a 'perfect' match, + /* An affinity of 5x is a 'perfect' match, * and means we can return immediately */ - if (affinity == 5) + if (affinity >= 50) break; } /* No match - just clean up config file */ @@ -318,7 +335,8 @@ static bool input_autoconfigure_scan_config_files_external( { if (autoconfig_handle && best_config) input_autoconfigure_set_config_file( - autoconfig_handle, best_config); + autoconfig_handle, best_config, + max_affinity % 10); match_found = true; } @@ -372,7 +390,8 @@ static bool input_autoconfigure_scan_config_files_internal( { if (autoconfig_handle && config) input_autoconfigure_set_config_file( - autoconfig_handle, config); + autoconfig_handle, config, + affinity % 10); return true; } diff --git a/tests-other/autoconf/TestpadD_alternative.cfg b/tests-other/autoconf/TestpadD_alternative.cfg index 5e978627fe30..a0290bf0cd0e 100644 --- a/tests-other/autoconf/TestpadD_alternative.cfg +++ b/tests-other/autoconf/TestpadD_alternative.cfg @@ -3,10 +3,11 @@ input_device = "Test joypad device D" input_vendor_id = 1 input_product_id = 2 input_device_alt1 = "Test joypad device E" -input_device_alt8 = "Test joypad device F" +input_device_display_name_alt1 = "Test joypad device name E" +input_device_alt8 = "Test joypad dev F" input_vendor_id_alt8 = 21 input_product_id_alt8 = 22 -input_device_display_name = "Test joypad device D/E/F" +input_device_display_name = "Test joypad device name D" input_b_btn = "0" input_y_btn = "1" input_select_btn = "2" diff --git a/tests-other/testinput_alternative_autoconfig.cfg b/tests-other/testinput_alternative_autoconfig.cfg index 091fecb3945e..c2acee9820c2 100644 --- a/tests-other/testinput_alternative_autoconfig.cfg +++ b/tests-other/testinput_alternative_autoconfig.cfg @@ -8,7 +8,7 @@ # - A device is connected with autoconfig profile # - A second device is connected which matches autoconfig profile alt1 # - A third device is connected which matches autoconfig profile alt8 (only by vid/pid) -# - VALIDATE: check that Player 1..3 have "Test joypad D/E/F" configured +# - VALIDATE: check that Player 1..3 have "Test joypad D/E/X" configured input_joypad_driver = "test" test_input_file_joypad = "tests-other/test_input_joypad_alternative_autoconfig.ratst" From 2fdd8434df456a43f6550b057753213760129d73 Mon Sep 17 00:00:00 2001 From: Eric Warmenhoven Date: Tue, 14 Jan 2025 15:31:11 -0500 Subject: [PATCH 07/49] tvOS: Fix 720p display (#17414) --- ui/drivers/ui_cocoatouch.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 18f98a0e0766..d650f3610aae 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -528,7 +528,7 @@ - (CAMetalLayer *)metalLayer { - (void)setupMetalLayer { self.metalLayer.device = MTLCreateSystemDefaultDevice(); - self.metalLayer.contentsScale = [UIScreen mainScreen].nativeScale; + self.metalLayer.contentsScale = cocoa_screen_get_native_scale(); self.metalLayer.opaque = YES; } From 13bd14747a53e69f173714b00025d0e802df8dbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Via=C4=8Das=C5=82a=C5=AD=20Chalikin?= Date: Mon, 13 Jan 2025 22:23:41 +0300 Subject: [PATCH 08/49] PipeWire improvements * Use given latency * Fix (non)blocking microphone * Mute microphone on startuo * Reset buffer when the microphone stops * Delete client-info handler * Refactor the naming conventions, styling --- audio/common/pipewire.c | 13 +-- audio/common/pipewire.h | 15 ++- audio/drivers/pipewire.c | 154 +++++++++++----------------- audio/drivers_microphone/pipewire.c | 92 ++++++++++------- 4 files changed, 128 insertions(+), 146 deletions(-) diff --git a/audio/common/pipewire.c b/audio/common/pipewire.c index 3dcf25460d8a..b4d01744063c 100644 --- a/audio/common/pipewire.c +++ b/audio/common/pipewire.c @@ -31,7 +31,6 @@ static void core_error_cb(void *data, uint32_t id, int seq, int res, const char RARCH_ERR("[PipeWire]: error id:%u seq:%d res:%d (%s): %s\n", id, seq, res, spa_strerror(res), message); - /* stop and exit the thread loop */ pw_thread_loop_stop(pw->thread_loop); } @@ -42,11 +41,9 @@ static void core_done_cb(void *data, uint32_t id, int seq) retro_assert(id == PW_ID_CORE); pw->last_seq = seq; + if (pw->pending_seq == seq) - { - /* stop and exit the thread loop */ pw_thread_loop_signal(pw->thread_loop, false); - } } static const struct pw_core_events core_events = { @@ -55,7 +52,7 @@ static const struct pw_core_events core_events = { .error = core_error_cb, }; -size_t calc_frame_size(enum spa_audio_format fmt, uint32_t nchannels) +size_t pipewire_calc_frame_size(enum spa_audio_format fmt, uint32_t nchannels) { uint32_t sample_size = 1; switch (fmt) @@ -85,7 +82,7 @@ size_t calc_frame_size(enum spa_audio_format fmt, uint32_t nchannels) return sample_size * nchannels; } -void set_position(uint32_t channels, uint32_t position[SPA_AUDIO_MAX_CHANNELS]) +void pipewire_set_position(uint32_t channels, uint32_t position[SPA_AUDIO_MAX_CHANNELS]) { memcpy(position, (uint32_t[SPA_AUDIO_MAX_CHANNELS]) { SPA_AUDIO_CHANNEL_UNKNOWN, }, sizeof(uint32_t) * SPA_AUDIO_MAX_CHANNELS); @@ -114,7 +111,7 @@ void set_position(uint32_t channels, uint32_t position[SPA_AUDIO_MAX_CHANNELS]) } } -void pipewire_wait_resync(pipewire_core_t *pw) +void pipewire_core_wait_resync(pipewire_core_t *pw) { retro_assert(pw); pw->pending_seq = pw_core_sync(pw->core, PW_ID_CORE, pw->pending_seq); @@ -127,7 +124,7 @@ void pipewire_wait_resync(pipewire_core_t *pw) } } -bool pipewire_set_active(struct pw_thread_loop *loop, struct pw_stream *stream, bool active) +bool pipewire_stream_set_active(struct pw_thread_loop *loop, struct pw_stream *stream, bool active) { enum pw_stream_state st; const char *error; diff --git a/audio/common/pipewire.h b/audio/common/pipewire.h index 7e9627128ac5..7b9a0dce4a79 100644 --- a/audio/common/pipewire.h +++ b/audio/common/pipewire.h @@ -38,27 +38,26 @@ typedef struct pipewire_core { struct pw_thread_loop *thread_loop; struct pw_context *ctx; + struct pw_core *core; struct spa_hook core_listener; int last_seq, pending_seq; struct pw_registry *registry; struct spa_hook registry_listener; - struct pw_client *client; - struct spa_hook client_listener; - bool nonblock; struct string_list *devicelist; + bool nonblock; } pipewire_core_t; -size_t calc_frame_size(enum spa_audio_format fmt, uint32_t nchannels); +size_t pipewire_calc_frame_size(enum spa_audio_format fmt, uint32_t nchannels); -void set_position(uint32_t channels, uint32_t position[SPA_AUDIO_MAX_CHANNELS]); +void pipewire_set_position(uint32_t channels, uint32_t position[SPA_AUDIO_MAX_CHANNELS]); -void pipewire_wait_resync(pipewire_core_t *pipewire); +bool pipewire_core_init(pipewire_core_t *pipewire, const char *loop_name); -bool pipewire_set_active(struct pw_thread_loop *loop, struct pw_stream *stream, bool active); +void pipewire_core_wait_resync(pipewire_core_t *pipewire); -bool pipewire_core_init(pipewire_core_t *pipewire, const char *loop_name); +bool pipewire_stream_set_active(struct pw_thread_loop *loop, struct pw_stream *stream, bool active); #endif /* _RETROARCH_PIPEWIRE */ diff --git a/audio/drivers/pipewire.c b/audio/drivers/pipewire.c index 0517a9efc94c..45142948d5e2 100644 --- a/audio/drivers/pipewire.c +++ b/audio/drivers/pipewire.c @@ -36,25 +36,21 @@ #define DEFAULT_CHANNELS 2 -#define QUANTUM 1024 /* TODO: detect */ #define RINGBUFFER_SIZE (1u << 22) #define RINGBUFFER_MASK (RINGBUFFER_SIZE - 1) typedef struct pipewire_audio { pipewire_core_t *pw; - struct pw_stream *stream; struct spa_hook stream_listener; struct spa_audio_info_raw info; uint32_t highwater_mark; uint32_t frame_size; - uint32_t req; struct spa_ringbuffer ring; uint8_t buffer[RINGBUFFER_SIZE]; } pipewire_audio_t; - static void stream_destroy_cb(void *data) { pipewire_audio_t *audio = (pipewire_audio_t*)data; @@ -68,7 +64,7 @@ static void playback_process_cb(void *data) void *p; struct pw_buffer *b; struct spa_buffer *buf; - uint32_t req, index, n_bytes; + uint32_t req, idx, n_bytes; int32_t avail; retro_assert(audio->stream); @@ -80,20 +76,15 @@ static void playback_process_cb(void *data) } buf = b->buffer; - p = buf->datas[0].data; - if (p == NULL) + if ((p = buf->datas[0].data) == NULL) goto done; /* calculate the total no of bytes to read data from buffer */ - req = b->requested * audio->frame_size; - - if (req == 0) - req = audio->req; - - n_bytes = SPA_MIN(req, buf->datas[0].maxsize); + n_bytes = buf->datas[0].maxsize; + if (b->requested) + n_bytes = SPA_MIN(b->requested * audio->frame_size, n_bytes); - /* get no of available bytes to read data from buffer */ - avail = spa_ringbuffer_get_read_index(&audio->ring, &index); + avail = spa_ringbuffer_get_read_index(&audio->ring, &idx); if (avail <= 0) /* fill rest buffer with silence */ @@ -105,10 +96,10 @@ static void playback_process_cb(void *data) spa_ringbuffer_read_data(&audio->ring, audio->buffer, RINGBUFFER_SIZE, - index & RINGBUFFER_MASK, p, n_bytes); + idx & RINGBUFFER_MASK, p, n_bytes); - index += n_bytes; - spa_ringbuffer_read_update(&audio->ring, index); + idx += n_bytes; + spa_ringbuffer_read_update(&audio->ring, idx); } buf->datas[0].chunk->offset = 0; @@ -116,7 +107,6 @@ static void playback_process_cb(void *data) buf->datas[0].chunk->size = n_bytes; done: - /* queue the buffer for playback */ pw_stream_queue_buffer(audio->stream, b); pw_thread_loop_signal(audio->pw->thread_loop, false); } @@ -158,42 +148,17 @@ static const struct pw_stream_events playback_stream_events = { .state_changed = stream_state_changed_cb, }; -static void client_info_cb(void *data, const struct pw_client_info *info) -{ - const struct spa_dict_item *item; - pipewire_core_t *pw = (pipewire_core_t*)data; - - RARCH_DBG("[PipeWire]: client: id:%u\n", info->id); - RARCH_DBG("[PipeWire]: \tprops:\n"); - spa_dict_for_each(item, info->props) - RARCH_DBG("[PipeWire]: \t\t%s: \"%s\"\n", item->key, item->value); - - pw_thread_loop_signal(pw->thread_loop, false); -} - -static const struct pw_client_events client_events = { - PW_VERSION_CLIENT_EVENTS, - .info = client_info_cb, -}; - static void registry_event_global(void *data, uint32_t id, uint32_t permissions, const char *type, uint32_t version, const struct spa_dict *props) { union string_list_elem_attr attr; + const struct spa_dict_item *item; pipewire_core_t *pw = (pipewire_core_t*)data; const char *media = NULL; const char *sink = NULL; - if (!pw->client && spa_streq(type, PW_TYPE_INTERFACE_Client)) - { - pw->client = pw_registry_bind(pw->registry, - id, type, PW_VERSION_CLIENT, 0); - pw_client_add_listener(pw->client, - &pw->client_listener, - &client_events, pw); - } - else if (spa_streq(type, PW_TYPE_INTERFACE_Node)) + if (spa_streq(type, PW_TYPE_INTERFACE_Node)) { media = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS); if (media && strcmp(media, "Audio/Sink") == 0) @@ -205,13 +170,12 @@ static void registry_event_global(void *data, uint32_t id, string_list_append(pw->devicelist, sink, attr); RARCH_LOG("[PipeWire]: Found Sink Node: %s\n", sink); } + + RARCH_DBG("[PipeWire]: Object: id:%u Type:%s/%d\n", id, type, version); + spa_dict_for_each(item, props) + RARCH_DBG("[PipeWire]: \t\t%s: \"%s\"\n", item->key, item->value); } } - - const struct spa_dict_item *item; - RARCH_DBG("[PipeWire]: Object: id:%u Type:%s/%d\n", id, type, version); - spa_dict_for_each(item, props) - RARCH_DBG("[PipeWire]: \t\t%s: \"%s\"\n", item->key, item->value); } static const struct pw_registry_events registry_events = { @@ -245,12 +209,19 @@ static void *pipewire_init(const char *device, unsigned rate, if (!pipewire_core_init(pw, "audio_driver")) goto error; + pw->registry = pw_core_get_registry(pw->core, PW_VERSION_REGISTRY, 0); + + spa_zero(pw->registry_listener); + pw_registry_add_listener(pw->registry, &pw->registry_listener, ®istry_events, pw); + + /* unlock, run the loop and wait, this will trigger the callbacks */ + pipewire_core_wait_resync(pw); + audio->info.format = is_little_endian() ? SPA_AUDIO_FORMAT_F32_LE : SPA_AUDIO_FORMAT_F32_BE; audio->info.channels = DEFAULT_CHANNELS; - set_position(DEFAULT_CHANNELS, audio->info.position); + pipewire_set_position(DEFAULT_CHANNELS, audio->info.position); audio->info.rate = rate; - audio->frame_size = calc_frame_size(audio->info.format, DEFAULT_CHANNELS); - audio->req = QUANTUM * rate * 1 / 2 / 100000 * audio->frame_size; + audio->frame_size = pipewire_calc_frame_size(audio->info.format, DEFAULT_CHANNELS); props = pw_properties_new(PW_KEY_MEDIA_TYPE, PW_RARCH_MEDIA_TYPE_AUDIO, PW_KEY_MEDIA_CATEGORY, PW_RARCH_MEDIA_CATEGORY_PLAYBACK, @@ -262,22 +233,18 @@ static void *pipewire_init(const char *device, unsigned rate, PW_KEY_APP_ICON_NAME, PW_RARCH_APPNAME, NULL); if (!props) - goto error; + goto unlock_error; if (device) pw_properties_set(props, PW_KEY_TARGET_OBJECT, device); - buf_samples = QUANTUM * rate * 3 / 4 / 100000; - - pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%" PRIu64 "/%u", - buf_samples, rate); - + buf_samples = latency * rate / 1000; + pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%" PRIu64 "/%u", buf_samples, rate); pw_properties_setf(props, PW_KEY_NODE_RATE, "1/%d", rate); - audio->stream = pw_stream_new(pw->core, PW_RARCH_APPNAME, props); if (!audio->stream) - goto error; + goto unlock_error; pw_stream_add_listener(audio->stream, &audio->stream_listener, &playback_stream_events, audio); @@ -294,23 +261,17 @@ static void *pipewire_init(const char *device, unsigned rate, params, 1); if (res < 0) - goto error; + goto unlock_error; audio->highwater_mark = MIN(RINGBUFFER_SIZE, - latency? (latency * 1000): 46440 * (uint64_t)rate / 1000000 * audio->frame_size); - RARCH_DBG("[PipeWire]: Bufer size: %u, RingBuffer size: %u\n", audio->highwater_mark, RINGBUFFER_SIZE); + latency * (uint64_t)rate / 1000 * audio->frame_size); - pw->registry = pw_core_get_registry(pw->core, PW_VERSION_REGISTRY, 0); - - spa_zero(pw->registry_listener); - pw_registry_add_listener(pw->registry, &pw->registry_listener, ®istry_events, pw); - - /* unlock, run the loop and wait, this will trigger the callbacks */ - pipewire_wait_resync(pw); pw_thread_loop_unlock(pw->thread_loop); return audio; +unlock_error: + pw_thread_loop_unlock(audio->pw->thread_loop); error: RARCH_ERR("[PipeWire]: Failed to initialize audio\n"); pipewire_free(audio); @@ -320,28 +281,33 @@ static void *pipewire_init(const char *device, unsigned rate, static ssize_t pipewire_write(void *data, const void *buf_, size_t size) { int32_t filled, avail; - uint32_t index; + uint32_t idx; pipewire_audio_t *audio = (pipewire_audio_t*)data; const char *error = NULL; if (pw_stream_get_state(audio->stream, &error) != PW_STREAM_STATE_STREAMING) return 0; /* wait for stream to become ready */ + if (size > audio->highwater_mark) + { + RARCH_ERR("[PipeWire]: Buffer too small! Please try increasing the latency.\n"); + return 0; + } + pw_thread_loop_lock(audio->pw->thread_loop); while (size) { - filled = spa_ringbuffer_get_write_index(&audio->ring, &index); + filled = spa_ringbuffer_get_write_index(&audio->ring, &idx); avail = audio->highwater_mark - filled; #if 0 /* Useful for tracing */ RARCH_DBG("[PipeWire]: Ringbuffer utilization: filled %d, avail %d, index %d, size %d\n", - filled, avail, index, size); + filled, avail, idx, size); #endif /* in non-blocking mode we play as much as we can - * in blocking mode we expect a freed buffer of at least the given size - */ + * in blocking mode we expect a freed buffer of at least the given size */ if (size > (size_t)avail) { if (audio->pw->nonblock) @@ -349,31 +315,29 @@ static ssize_t pipewire_write(void *data, const void *buf_, size_t size) size = avail; break; } - else - { - pw_thread_loop_wait(audio->pw->thread_loop); - } + + pw_thread_loop_wait(audio->pw->thread_loop); } else break; } if (filled < 0) - RARCH_ERR("[Pipewire]: %p: underrun write:%u filled:%d\n", audio, index, filled); + RARCH_ERR("[Pipewire]: %p: underrun write:%u filled:%d\n", audio, idx, filled); else { if ((uint32_t) filled + size > RINGBUFFER_SIZE) { RARCH_ERR("[PipeWire]: %p: overrun write:%u filled:%d + size:%zu > max:%u\n", - audio, index, filled, size, RINGBUFFER_SIZE); + audio, idx, filled, size, RINGBUFFER_SIZE); } } spa_ringbuffer_write_data(&audio->ring, audio->buffer, RINGBUFFER_SIZE, - index & RINGBUFFER_MASK, buf_, size); - index += size; - spa_ringbuffer_write_update(&audio->ring, index); + idx & RINGBUFFER_MASK, buf_, size); + idx += size; + spa_ringbuffer_write_update(&audio->ring, idx); pw_thread_loop_unlock(audio->pw->thread_loop); return size; @@ -383,26 +347,33 @@ static bool pipewire_stop(void *data) { pipewire_audio_t *audio = (pipewire_audio_t*)data; const char *error = NULL; + + if (!audio || !audio->pw) + return false; if (pw_stream_get_state(audio->stream, &error) == PW_STREAM_STATE_PAUSED) return true; - return pipewire_set_active(audio->pw->thread_loop, audio->stream, false); + return pipewire_stream_set_active(audio->pw->thread_loop, audio->stream, false); } static bool pipewire_start(void *data, bool is_shutdown) { pipewire_audio_t *audio = (pipewire_audio_t*)data; const char *error = NULL; + + if (!audio || !audio->pw) + return false; if (pw_stream_get_state(audio->stream, &error) == PW_STREAM_STATE_STREAMING) return true; - return pipewire_set_active(audio->pw->thread_loop, audio->stream, true); + return pipewire_stream_set_active(audio->pw->thread_loop, audio->stream, true); } static bool pipewire_alive(void *data) { pipewire_audio_t *audio = (pipewire_audio_t*)data; const char *error = NULL; + if (!audio) return false; @@ -432,9 +403,6 @@ static void pipewire_free(void *data) audio->stream = NULL; } - if (audio->pw->client) - pw_proxy_destroy((struct pw_proxy *)audio->pw->client); - if (audio->pw->registry) pw_proxy_destroy((struct pw_proxy*)audio->pw->registry); @@ -484,7 +452,7 @@ static void pipewire_device_list_free(void *data, void *array_list_data) static size_t pipewire_write_avail(void *data) { - uint32_t index, written, length; + uint32_t idx, written, length; pipewire_audio_t *audio = (pipewire_audio_t*)data; const char *error = NULL; @@ -495,7 +463,7 @@ static size_t pipewire_write_avail(void *data) return 0; /* wait for stream to become ready */ pw_thread_loop_lock(audio->pw->thread_loop); - written = spa_ringbuffer_get_write_index(&audio->ring, &index); + written = spa_ringbuffer_get_write_index(&audio->ring, &idx); length = audio->highwater_mark - written; pw_thread_loop_unlock(audio->pw->thread_loop); diff --git a/audio/drivers_microphone/pipewire.c b/audio/drivers_microphone/pipewire.c index 426c3248a2c9..2bb009555f4b 100644 --- a/audio/drivers_microphone/pipewire.c +++ b/audio/drivers_microphone/pipewire.c @@ -33,21 +33,18 @@ #define DEFAULT_CHANNELS 1 -#define QUANTUM 1024 /* TODO: detect */ #define RINGBUFFER_SIZE (1u << 22) #define RINGBUFFER_MASK (RINGBUFFER_SIZE - 1) typedef struct pipewire_microphone { pipewire_core_t *pw; - struct pw_stream *stream; struct spa_hook stream_listener; struct spa_audio_info_raw info; uint32_t frame_size; struct spa_ringbuffer ring; uint8_t buffer[RINGBUFFER_SIZE]; - bool is_ready; } pipewire_microphone_t; @@ -90,7 +87,7 @@ static void capture_process_cb(void *data) struct pw_buffer *b; struct spa_buffer *buf; int32_t filled; - uint32_t index, offs, n_bytes; + uint32_t idx, offs, n_bytes; assert(microphone->stream); @@ -108,24 +105,25 @@ static void capture_process_cb(void *data) offs = SPA_MIN(buf->datas[0].chunk->offset, buf->datas[0].maxsize); n_bytes = SPA_MIN(buf->datas[0].chunk->size, buf->datas[0].maxsize - offs); - filled = spa_ringbuffer_get_write_index(µphone->ring, &index); + filled = spa_ringbuffer_get_write_index(µphone->ring, &idx); if (filled < 0) - RARCH_ERR("[PipeWire]: %p: underrun write:%u filled:%d\n", p, index, filled); + RARCH_ERR("[PipeWire]: %p: underrun write:%u filled:%d\n", p, idx, filled); else { if ((uint32_t)filled + n_bytes > RINGBUFFER_SIZE) RARCH_ERR("[PipeWire]: %p: overrun write:%u filled:%d + size:%u > max:%u\n", - p, index, filled, n_bytes, RINGBUFFER_SIZE); + p, idx, filled, n_bytes, RINGBUFFER_SIZE); } spa_ringbuffer_write_data(µphone->ring, microphone->buffer, RINGBUFFER_SIZE, - index & RINGBUFFER_MASK, + idx & RINGBUFFER_MASK, SPA_PTROFF(p, offs, void), n_bytes); - index += n_bytes; - spa_ringbuffer_write_update(µphone->ring, index); + idx += n_bytes; + spa_ringbuffer_write_update(µphone->ring, idx); done: pw_stream_queue_buffer(microphone->stream, b); + pw_thread_loop_signal(microphone->pw->thread_loop, false); } static const struct pw_stream_events capture_stream_events = { @@ -140,6 +138,7 @@ static void registry_event_global(void *data, uint32_t id, const struct spa_dict *props) { union string_list_elem_attr attr; + const struct spa_dict_item *item; pipewire_core_t *pw = (pipewire_core_t*)data; const char *media = NULL; const char *sink = NULL; @@ -158,6 +157,10 @@ static void registry_event_global(void *data, uint32_t id, string_list_append(pw->devicelist, sink, attr); RARCH_LOG("[PipeWire]: Found Source Node: %s\n", sink); } + + RARCH_DBG("[PipeWire]: Object: id:%u Type:%s/%d\n", id, type, version); + spa_dict_for_each(item, props) + RARCH_DBG("[PipeWire]: \t\t%s: \"%s\"\n", item->key, item->value); } } } @@ -197,7 +200,7 @@ static void *pipewire_microphone_init(void) spa_zero(pw->registry_listener); pw_registry_add_listener(pw->registry, &pw->registry_listener, ®istry_events, pw); - pipewire_wait_resync(pw); + pipewire_core_wait_resync(pw); pw_thread_loop_unlock(pw->thread_loop); return pw; @@ -219,9 +222,6 @@ static void pipewire_microphone_free(void *driver_context) if (pw->thread_loop) pw_thread_loop_stop(pw->thread_loop); - if (pw->client) - pw_proxy_destroy((struct pw_proxy *)pw->client); - if (pw->registry) pw_proxy_destroy((struct pw_proxy*)pw->registry); @@ -247,26 +247,41 @@ static void pipewire_microphone_free(void *driver_context) static int pipewire_microphone_read(void *driver_context, void *microphone_context, void *buf_, size_t size_) { int32_t readable; - uint32_t index; + uint32_t idx; const char *error = NULL; pipewire_core_t *pw = (pipewire_core_t*)driver_context; pipewire_microphone_t *microphone = (pipewire_microphone_t*)microphone_context; - if (!microphone->is_ready || pw_stream_get_state(microphone->stream, &error) != PW_STREAM_STATE_STREAMING) + if ( !microphone->is_ready + || pw_stream_get_state(microphone->stream, &error) != PW_STREAM_STATE_STREAMING) return -1; pw_thread_loop_lock(pw->thread_loop); - /* get no of available bytes to read data from buffer */ - readable = spa_ringbuffer_get_read_index(µphone->ring, &index); - if (readable < (int32_t)size_) - size_ = readable; + while (size_) + { + /* get no of available bytes to read data from buffer */ + readable = spa_ringbuffer_get_read_index(µphone->ring, &idx); + + if (readable < (int32_t)size_) + { + if (pw->nonblock) + { + size_ = readable; + break; + } + + pw_thread_loop_wait(pw->thread_loop); + } + else + break; + } spa_ringbuffer_read_data(µphone->ring, microphone->buffer, RINGBUFFER_SIZE, - index & RINGBUFFER_MASK, buf_, size_); - index += size_; - spa_ringbuffer_read_update(µphone->ring, index); + idx & RINGBUFFER_MASK, buf_, size_); + idx += size_; + spa_ringbuffer_read_update(µphone->ring, idx); pw_thread_loop_unlock(pw->thread_loop); return size_; @@ -328,15 +343,16 @@ static void *pipewire_microphone_open_mic(void *driver_context, if (!microphone) goto error; + microphone->is_ready = false; microphone->pw = (pipewire_core_t*)driver_context; pw_thread_loop_lock(microphone->pw->thread_loop); microphone->info.format = is_little_endian() ? SPA_AUDIO_FORMAT_F32_LE : SPA_AUDIO_FORMAT_F32_BE; microphone->info.channels = DEFAULT_CHANNELS; - set_position(DEFAULT_CHANNELS, microphone->info.position); + pipewire_set_position(DEFAULT_CHANNELS, microphone->info.position); microphone->info.rate = rate; - microphone->frame_size = calc_frame_size(microphone->info.format, DEFAULT_CHANNELS); + microphone->frame_size = pipewire_calc_frame_size(microphone->info.format, DEFAULT_CHANNELS); props = pw_properties_new(PW_KEY_MEDIA_TYPE, PW_RARCH_MEDIA_TYPE_AUDIO, PW_KEY_MEDIA_CATEGORY, PW_RARCH_MEDIA_CATEGORY_RECORD, @@ -353,13 +369,9 @@ static void *pipewire_microphone_open_mic(void *driver_context, if (device) pw_properties_set(props, PW_KEY_TARGET_OBJECT, device); - buf_samples = QUANTUM * rate * 3 / 4 / 100000; - - pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%" PRIu64 "/%u", - buf_samples, rate); - + buf_samples = latency * rate / 1000; + pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%" PRIu64 "/%u", buf_samples, rate); pw_properties_setf(props, PW_KEY_NODE_RATE, "1/%d", rate); - microphone->stream = pw_stream_new(microphone->pw->core, PW_RARCH_APPNAME, props); if (!microphone->stream) @@ -375,6 +387,7 @@ static void *pipewire_microphone_open_mic(void *driver_context, PW_DIRECTION_INPUT, PW_ID_ANY, PW_STREAM_FLAG_AUTOCONNECT | + PW_STREAM_FLAG_INACTIVE | PW_STREAM_FLAG_MAP_BUFFERS | PW_STREAM_FLAG_RT_PROCESS, params, 1); @@ -383,11 +396,11 @@ static void *pipewire_microphone_open_mic(void *driver_context, goto unlock_error; pw_thread_loop_wait(microphone->pw->thread_loop); - pw_thread_loop_unlock(microphone->pw->thread_loop); + *new_rate = microphone->info.rate; - microphone->is_ready = true; + microphone->is_ready = true; return microphone; unlock_error: @@ -419,12 +432,12 @@ static bool pipewire_microphone_start_mic(void *driver_context, void *microphone pipewire_microphone_t *microphone = (pipewire_microphone_t*)microphone_context; const char *error = NULL; - if (!microphone->is_ready) + if (!pw || !microphone || !microphone->is_ready) return false; if (pw_stream_get_state(microphone->stream, &error) == PW_STREAM_STATE_STREAMING) return true; - return pipewire_set_active(pw->thread_loop, microphone->stream, true); + return pipewire_stream_set_active(pw->thread_loop, microphone->stream, true); } static bool pipewire_microphone_stop_mic(void *driver_context, void *microphone_context) @@ -432,13 +445,18 @@ static bool pipewire_microphone_stop_mic(void *driver_context, void *microphone_ pipewire_core_t *pw = (pipewire_core_t*)driver_context; pipewire_microphone_t *microphone = (pipewire_microphone_t*)microphone_context; const char *error = NULL; + bool res = false; - if (!microphone->is_ready) + if (!pw || !microphone || !microphone->is_ready) return false; if (pw_stream_get_state(microphone->stream, &error) == PW_STREAM_STATE_PAUSED) return true; - return pipewire_set_active(pw->thread_loop, microphone->stream, false); + res = pipewire_stream_set_active(pw->thread_loop, microphone->stream, false); + spa_ringbuffer_read_update(µphone->ring, 0); + spa_ringbuffer_write_update(µphone->ring, 0); + + return res; } static bool pipewire_microphone_mic_use_float(const void *driver_context, const void *microphone_context) From 5069b693a18d3b67a434474bbe21f5e5e0f88ee8 Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 15 Jan 2025 00:14:15 +0000 Subject: [PATCH 09/49] Fetch translations from Crowdin --- intl/msg_hash_de.h | 24 ++++++++++++++++++++++++ intl/msg_hash_ko.h | 24 ++++++++++++++++++++++++ intl/msg_hash_uk.h | 12 ++++++++++++ intl/progress.h | 6 +++--- 4 files changed, 63 insertions(+), 3 deletions(-) diff --git a/intl/msg_hash_de.h b/intl/msg_hash_de.h index 9cad72f10194..1804369efe5a 100644 --- a/intl/msg_hash_de.h +++ b/intl/msg_hash_de.h @@ -1894,6 +1894,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_BLACK_FRAME_INSERTION, "Schwarzes Bild einfügen" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_BLACK_FRAME_INSERTION, + "WARNUNG: Schnelles Flackern kann auf manchen Bildschirmen zu einem Nachleuchten des Bildes führen. Verwendung auf eigene Gefahr // Schwarze(n) Rahmen zwischen den Bildern einfügen. Kann die Bewegungsunschärfe durch Emulation der CRT-Abtastung stark reduzieren, allerdings auf Kosten der Helligkeit." + ) MSG_HASH( MENU_ENUM_LABEL_HELP_VIDEO_BLACK_FRAME_INSERTION, "Fügt Schwarzbild(er) zwischen Frames für verbesserte Bewegungsschärfe ein. Nur die Option benutzen, die für die aktuelle Aktualisierungsrate bestimmt ist. Nicht für die Verwendung bei Aktualisierungsraten mit nicht multiplen 60 Hz wie 144 Hz, 165Hz, usw. Nicht kombinieren mit Swap-Intervall > 1, Unterbilder, Bildverzögerung oder mit exakter Inhaltssignalfrequenz synchronisieren. System-VRR eingeschaltet lassen ist ok, nur nicht diese Einstellung. Wenn -irgendein- temporäres Bild-Nachleuch[...]" @@ -1974,6 +1978,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_SUBFRAMES, "Shader-Unterbilder" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_SHADER_SUBFRAMES, + "WARNUNG: Schnelles Flackern kann auf manchen Bildschirmen zu einem Nachleuchten des Bildes führen. Verwendung auf eigene Gefahr // Simuliert eine einfache rollende Scanline über mehrere Unterbilder, indem der Bildschirm vertikal aufgeteilt wird und jeder Teil des Bildschirms entsprechend der Anzahl der Unterbilder dargestellt wird." + ) MSG_HASH( MENU_ENUM_LABEL_HELP_VIDEO_SHADER_SUBFRAMES, "Fügt zusätzlich Shader-Bild(er) zwischen Frames für alle möglichen Shader-Effekte ein, die darauf ausgelegt sind, schneller als die Inhaltsrate zu laufen. Nur die Option benutzen, die für die aktuelle Aktualisierungsrate bestimmt ist. Nicht für die Verwendung bei Aktualisierungsraten mit nicht multiplen 60 Hz wie 144 Hz, 165Hz, usw. Nicht kombinieren mit Swap-Intervall > 1, Schwarzbilder, Bildverzögerung oder mit exakter Inhaltssignalfrequenz synchronisieren. System-VRR eingeschaltet lass[...]" @@ -2046,6 +2054,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SCAN_SUBFRAMES, "Rollende Scanline-Simulation" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_SCAN_SUBFRAMES, + "WARNUNG: Schnelles Flackern kann auf manchen Bildschirmen zu einem Nachleuchten des Bildes führen. Verwendung auf eigene Gefahr // Simuliert eine einfache rollende Scanline über mehrere Unterbilder, indem der Bildschirm vertikal aufgeteilt wird und jeder Teil des Bildschirms entsprechend der Anzahl der Unterbilder dargestellt wird." + ) MSG_HASH( MENU_ENUM_LABEL_HELP_VIDEO_SCAN_SUBFRAMES, "Simuliert eine einfache rollende Scanline über mehrere Unterbilder, indem der Bildschirm vertikal aufgeteilt wird und jeder Teil des Bildschirms entsprechend der Anzahl der Unterbilder vom oberen Bildschirmrand nach unten gerendert wird." @@ -4443,6 +4455,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_CORE_INFO_SAVESTATE_BYPASS, "Umgehung der Core-Info-Savestates-Funktionen" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_CORE_INFO_SAVESTATE_BYPASS, + "Legt fest, ob Savestate-Fähigkeiten der Core-Info ignoriert werden sollen, so dass mit verwandten Funktionen experimentiert werden kann (Run-Ahead, Zurückspulen usw.)." + ) #ifndef HAVE_DYNAMIC MSG_HASH( MENU_ENUM_LABEL_VALUE_ALWAYS_RELOAD_CORE_ON_RUN_CONTENT, @@ -4683,6 +4699,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_SAVESTATE_AUTO_SAVE, "Savestate automatisch erstellen" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_SAVESTATE_AUTO_SAVE, + "Beim Schließen des Inhalts automatisch einen Savestate erstellen. Dieser Savestate wird beim Start geladen, wenn \"Savestate automatisch laden\" aktiviert ist." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_SAVESTATE_AUTO_LOAD, "Savestate automatisch laden" @@ -15381,6 +15401,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_BOTTOM_FONT_ENABLE, "Schrift aktivieren" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_BOTTOM_FONT_ENABLE, + "Text am unteren Bildschirm einblenden. Aktivieren, um Schaltflächenbeschreibungen auf dem unteren Bildschirm anzuzeigen. Dies schließt das Savestate-Speicherdatum aus." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_BOTTOM_FONT_COLOR_RED, "Schriftfarbe Rot" diff --git a/intl/msg_hash_ko.h b/intl/msg_hash_ko.h index 9ef6d437fbb1..ac46ad6c4c6b 100644 --- a/intl/msg_hash_ko.h +++ b/intl/msg_hash_ko.h @@ -1982,6 +1982,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_BLACK_FRAME_INSERTION, "검은 프레임 삽입" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_BLACK_FRAME_INSERTION, + "주의: 빠른 깜빡임은 일부 디스플레이에 잔상을 남길 수 있습니다. 사용에 주의가 필요합니다 // 프레임 사이에 검은 프레임을 삽입합니다. CRT 스캔을 흉내내어 모션 블러를 크게 줄일 수 있지만, 화면 밝기가 저하됩니다." + ) MSG_HASH( MENU_ENUM_LABEL_HELP_VIDEO_BLACK_FRAME_INSERTION, "향상된 모션 선명도를 위해 프레임 사이에 검정색 프레임을 삽입합니다. 현재 디스플레이의 주사율과 일치하는 옵션만 사용하십시오. 144Hz, 165Hz 등과 같이 60Hz의 배수가 아닌 새로 고침 빈도에서는 사용하지 마십시오. 스왑 간격 > 1, 서브프레임, 프레임 지연, 정확한 프레임 동기화 설정들과 함께 사용하지 마십시오. 시스템의 VRR 설정을 켜두는 것은 괜찮습니다. 일시적인 화면 [...]" @@ -2062,6 +2066,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_SUBFRAMES, "셰이더 서브프레임" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_SHADER_SUBFRAMES, + "주의: 빠른 깜빡임은 일부 디스플레이에 잔상을 남길 수 있습니다. 사용에 주의가 필요합니다 // 화면을 여러 세로 구간으로 나누고 다수의 서브프레임으로부터 각 구간에 해당하는 서브프레임을 렌더하는 방식으로 롤링 스캔라인 효과를 흉내냅니다." + ) MSG_HASH( MENU_ENUM_LABEL_HELP_VIDEO_SHADER_SUBFRAMES, "콘텐츠의 프레임 레이트보다 더 높은 프레임 레이트로 실행되도록 설계된 셰이더를 위해 프레임 사이에 추가 셰이더 프레임을 삽입합니다. 현재 디스플레이의 주사율과 일치하는 옵션만 사용하십시오. 144Hz, 165Hz 등과 같이 60Hz의 배수가 아닌 새로 고침 빈도에서는 사용하지 마십시오. 스왑 간격 > 1, 검정색 프레임 삽입, 프레임 지연, 정확한 프레임 동기화 설정들과 함께 사용[...]" @@ -2134,6 +2142,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SCAN_SUBFRAMES, "롤링 스캔라인 시뮬레이션" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_SCAN_SUBFRAMES, + "주의: 빠른 깜빡임은 일부 디스플레이에 잔상을 남길 수 있습니다. 사용에 주의가 필요합니다 // 화면을 여러 세로 구간으로 나누고 다수의 서브프레임으로부터 각 구간에 해당하는 서브프레임을 렌더하는 방식으로 롤링 스캔라인 효과를 흉내냅니다." + ) MSG_HASH( MENU_ENUM_LABEL_HELP_VIDEO_SCAN_SUBFRAMES, "화면을 여러 세로 구간으로 나누고 다수의 서브프레임으로부터 각 구간에 해당하는 서브프레임을 위에서 아래로 렌더하는 방식으로 롤링 스캔라인 효과를 흉내냅니다." @@ -4583,6 +4595,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_CORE_INFO_SAVESTATE_BYPASS, "코어 정보 상태저장 기능 여부 무시" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_CORE_INFO_SAVESTATE_BYPASS, + "코어 정보의 상태저장 기능 제공 여부를 무시할지 설정합니다. 관련 기능(미리 실행, 되감기 등)을 시험해볼 수 있게 됩니다." + ) #ifndef HAVE_DYNAMIC MSG_HASH( MENU_ENUM_LABEL_VALUE_ALWAYS_RELOAD_CORE_ON_RUN_CONTENT, @@ -4823,6 +4839,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_SAVESTATE_AUTO_SAVE, "자동 상태저장" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_SAVESTATE_AUTO_SAVE, + "컨텐츠를 종료할 때 자동으로 상태저장을 생성합니다. '상태저장 자동으로 불러오기'가 활성화되어 있는 경우, 이 상태저장을 다음 시작 시에 자동으로 불러옵니다." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_SAVESTATE_AUTO_LOAD, "상태저장 자동으로 불러오기" @@ -15837,6 +15857,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_BOTTOM_FONT_ENABLE, "폰트 사용" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_BOTTOM_FONT_ENABLE, + "아래 화면 메뉴에 폰트를 사용합니다. 활성화하면 아래 화면에 버튼 설명이 표시됩니다. 상태저장 일자 표시는 영향을 받지 않습니다." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_BOTTOM_FONT_COLOR_RED, "폰트 색 빨강" diff --git a/intl/msg_hash_uk.h b/intl/msg_hash_uk.h index d7399efe330f..f2e91997ff09 100644 --- a/intl/msg_hash_uk.h +++ b/intl/msg_hash_uk.h @@ -1970,6 +1970,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_BLACK_FRAME_INSERTION, "Вставка чорного кадра" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_BLACK_FRAME_INSERTION, + "УВАГА: Швидке мерехтіння може призвести до збереження зображення на деяких дисплеях. Використовуйте на свій страх і ризик // вставте чорний фреймворк між кадрами. Можна значно зменшити розмиття руху шляхом емуляції сканування CRT, але це зменшило яскравість." + ) MSG_HASH( MENU_ENUM_LABEL_HELP_VIDEO_BLACK_FRAME_INSERTION, "Вставляє чорні рамки між кадрами для покращення чіткості руху. Використовуйте лише опцію, призначену для поточної частоти оновлення екрана. Не можна використовувати з частотою оновлення, не кратною 60 Гц, наприклад, 144 Гц, 165 Гц тощо. Не поєднуйте з інтервалом заміни > 1, під к[...]" @@ -2050,6 +2054,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_SUBFRAMES, "Підкадри шейдерів" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_SHADER_SUBFRAMES, + "ПОПЕРЕДЖЕННЯ: Швидке мерехтіння може призвести до збереження зображень на деяких дисплеях. Використовуйте на свій страх і ризик // Симулює базовий рухомий стовпчик протягом декількох підкадрів шляхом ділення екрану вверх і рендерингу кожної частини екрана відповідно до [...]" + ) MSG_HASH( MENU_ENUM_LABEL_HELP_VIDEO_SHADER_SUBFRAMES, "Вставляє додатковий(і) кадр(и) шейдерів між кадрами для будь-яких можливих шейдерних ефектів, які мають працювати швидше за частоту оновлення вмісту. Використовуйте лише той параметр, який призначено для поточної частоти оновлення екрана. Не використовується при частоті [...]" @@ -2122,6 +2130,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SCAN_SUBFRAMES, "Моделювання рухомої розгортки" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_SCAN_SUBFRAMES, + "ПОПЕРЕДЖЕННЯ: Швидке мерехтіння може призвести до збереження зображень на деяких дисплеях. Використовуйте на свій страх і ризик // Симулює базовий рухомий стовпчик протягом декількох підкадрів шляхом ділення екрану вверх і рендерингу кожної частини екрана відповідно до [...]" + ) MSG_HASH( MENU_ENUM_LABEL_HELP_VIDEO_SCAN_SUBFRAMES, "Імітує базовий рухомий рядок розгортки на кількох під кадрів, розділяючи екран вертикально вгору та відтворюючи кожну частину екрана відповідно до кількості під кадрів, починаючи з верхньої частини sc." diff --git a/intl/progress.h b/intl/progress.h index 3be62eb7ff95..10000ddf66f1 100644 --- a/intl/progress.h +++ b/intl/progress.h @@ -31,7 +31,7 @@ #define LANGUAGE_PROGRESS_DANISH_APPROVED 0 /* German */ -#define LANGUAGE_PROGRESS_GERMAN_TRANSLATED 99 +#define LANGUAGE_PROGRESS_GERMAN_TRANSLATED 100 #define LANGUAGE_PROGRESS_GERMAN_APPROVED 14 /* Greek */ @@ -91,7 +91,7 @@ #define LANGUAGE_PROGRESS_JAPANESE_APPROVED 0 /* Korean */ -#define LANGUAGE_PROGRESS_KOREAN_TRANSLATED 99 +#define LANGUAGE_PROGRESS_KOREAN_TRANSLATED 100 #define LANGUAGE_PROGRESS_KOREAN_APPROVED 0 /* Dutch */ @@ -143,7 +143,7 @@ #define LANGUAGE_PROGRESS_TATAR_APPROVED 0 /* Ukrainian */ -#define LANGUAGE_PROGRESS_UKRAINIAN_TRANSLATED 99 +#define LANGUAGE_PROGRESS_UKRAINIAN_TRANSLATED 100 #define LANGUAGE_PROGRESS_UKRAINIAN_APPROVED 7 /* Valencian */ From f7447d2e0de9aeb0c9a2c4ded8278335dd0a195b Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Wed, 15 Jan 2025 12:19:02 +0100 Subject: [PATCH 10/49] Add TODO/FIXME notes and cleanup argument naming --- gfx/video_shader_parse.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 84f84bc7509c..0d7dadd28159 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -110,7 +110,7 @@ static path_change_data_t *file_change_data = NULL; /** * fill_pathname_expanded_and_absolute: - * @param out_path + * @param s * String to write into. * @param in_refpath * Used to get the base path if in_path is relative. @@ -123,12 +123,10 @@ static path_change_data_t *file_change_data = NULL; * If the path was relative it will take this path and get the * absolute path using in_refpath as the path to extract a base path. * - * out_path is filled with the absolute path + * s is filled with the absolute path **/ -static void fill_pathname_expanded_and_absolute( - char *out_path, size_t out_size, - const char *in_refpath, - const char *in_path) +static void fill_pathname_expanded_and_absolute(char *s, size_t len, + const char *in_refpath, const char *in_path) { char expanded_path[PATH_MAX_LENGTH]; @@ -140,12 +138,12 @@ static void fill_pathname_expanded_and_absolute( /* Resolve the reference path relative to the config */ if (path_is_absolute(expanded_path)) - strlcpy(out_path, expanded_path, out_size); + strlcpy(s, expanded_path, len); else - fill_pathname_resolve_relative(out_path, in_refpath, - in_path, out_size); + fill_pathname_resolve_relative(s, in_refpath, + in_path, len); - pathname_conform_slashes_to_os(out_path); + pathname_conform_slashes_to_os(s); } /** @@ -230,16 +228,15 @@ static void fill_pathname_expanded_and_absolute( * after replacing the wildcards does not exist on disk, * the path returned will be uneffected. **/ -static void video_shader_replace_wildcards(char *inout_absolute_path, - const unsigned in_absolute_path_length, char *in_preset_path) +static void video_shader_replace_wildcards(char *s, size_t len, char *in_preset_path) { int i = 0; char replaced_path[PATH_MAX_LENGTH]; - if (!strstr(inout_absolute_path, RARCH_WILDCARD_DELIMITER)) + if (!strstr(s, RARCH_WILDCARD_DELIMITER)) return; - strlcpy(replaced_path, inout_absolute_path, sizeof(replaced_path)); + strlcpy(replaced_path, s, sizeof(replaced_path)); /* Step through the wildcards while we can still find the * delimiter in the replaced path @@ -453,7 +450,7 @@ static void video_shader_replace_wildcards(char *inout_absolute_path, } if (path_is_valid(replaced_path)) - strlcpy(inout_absolute_path, replaced_path, in_absolute_path_length); + strlcpy(s, replaced_path, len); else { /* If a file does not exist at the location of the replaced path @@ -461,7 +458,7 @@ static void video_shader_replace_wildcards(char *inout_absolute_path, RARCH_DBG("\n[Shaders]: Filepath after wildcard replacement can't be found:\n"); RARCH_DBG(" \"%s\" \n", replaced_path); RARCH_DBG(" Falling back to original Filepath\n"); - RARCH_DBG(" \"%s\" \n\n", inout_absolute_path); + RARCH_DBG(" \"%s\" \n\n", s); } } @@ -496,6 +493,7 @@ static void video_shader_gather_reference_path_list( /* Get the absolute path and replace wildcards in the path */ fill_pathname_expanded_and_absolute(reference_preset_path, PATH_MAX_LENGTH, conf->path, ref_tmp->path); + /* TODO/FIXME - dehardcode PATH_MAX_LENGTH */ video_shader_replace_wildcards(reference_preset_path, PATH_MAX_LENGTH, conf->path); video_shader_gather_reference_path_list(in_path_linked_list, reference_preset_path, reference_depth + 1); @@ -612,6 +610,7 @@ static bool video_shader_parse_pass(config_file_t *conf, /* Get the absolute path and replace wildcards in the path */ fill_pathname_expanded_and_absolute(pass->source.path, PATH_MAX_LENGTH, conf->path, tmp_path); + /* TODO/FIXME - dehardcode PATH_MAX_LENGTH */ video_shader_replace_wildcards(pass->source.path, PATH_MAX_LENGTH, conf->path); @@ -846,6 +845,7 @@ static bool video_shader_parse_textures(config_file_t *conf, /* Get the absolute path and replace wildcards in the path */ fill_pathname_expanded_and_absolute(shader->lut[shader->luts].path, PATH_MAX_LENGTH, conf->path, texture_path); + /* TODO/FIXME - dehardcode PATH_MAX_LENGTH */ video_shader_replace_wildcards(shader->lut[shader->luts].path, PATH_MAX_LENGTH, conf->path); strlcpy(shader->lut[shader->luts].id, id, @@ -1323,6 +1323,7 @@ static config_file_t *video_shader_get_root_preset_config(const char *path) /* Get the absolute path and replace wildcards in the path */ fill_pathname_expanded_and_absolute(nested_reference_path, PATH_MAX_LENGTH, conf->path, conf->references->path); + /* TODO/FIXME - dehardcode PATH_MAX_LENGTH */ video_shader_replace_wildcards(nested_reference_path, PATH_MAX_LENGTH, conf->path); /* Create a new config from the referenced path */ @@ -1409,6 +1410,7 @@ static bool video_shader_check_reference_chain_for_save( /* Get the absolute path and replace wildcards in the path */ fill_pathname_expanded_and_absolute(nested_ref_path, PATH_MAX_LENGTH, conf->path, conf->references->path); + /* TODO/FIXME - dehardcode PATH_MAX_LENGTH */ video_shader_replace_wildcards(nested_ref_path, PATH_MAX_LENGTH, conf->path); /* If one of the reference paths is the same as the file we want to save then this reference chain would be @@ -1550,6 +1552,7 @@ static bool video_shader_write_referenced_preset( /* Get the absolute path and replace wildcards in the path */ fill_pathname_expanded_and_absolute(abs_tmp_ref_path, PATH_MAX_LENGTH, ref_conf->path, ref_conf->references->path); + /* TODO/FIXME - dehardcode PATH_MAX_LENGTH */ video_shader_replace_wildcards(abs_tmp_ref_path, PATH_MAX_LENGTH, ref_conf->path); pathname_conform_slashes_to_os(abs_tmp_ref_path); @@ -1592,6 +1595,7 @@ static bool video_shader_write_referenced_preset( /* Get the absolute path and replace wildcards in the path */ fill_pathname_expanded_and_absolute(path_to_ref, PATH_MAX_LENGTH, ref_conf->path, ref_conf->references->path); + /* TODO/FIXME - dehardcode PATH_MAX_LENGTH */ video_shader_replace_wildcards(path_to_ref, PATH_MAX_LENGTH, ref_conf->path); @@ -1615,6 +1619,7 @@ static bool video_shader_write_referenced_preset( /* Get the absolute path and replace wildcards in the path */ fill_pathname_expanded_and_absolute(path_to_ref, PATH_MAX_LENGTH, ref_conf->path, ref_conf->references->path); + /* TODO/FIXME - dehardcode PATH_MAX_LENGTH */ video_shader_replace_wildcards(path_to_ref, PATH_MAX_LENGTH, ref_conf->path); } @@ -2089,6 +2094,7 @@ static bool video_shader_override_values(config_file_t *override_conf, /* Get the absolute path and replace wildcards in the path */ fill_pathname_expanded_and_absolute(override_tex_path, PATH_MAX_LENGTH, override_conf->path, tex_path); + /* TODO/FIXME - dehardcode PATH_MAX_LENGTH */ video_shader_replace_wildcards(override_tex_path, PATH_MAX_LENGTH, override_conf->path); strlcpy(shader->lut[i].path, override_tex_path, sizeof(shader->lut[i].path)); @@ -2306,6 +2312,7 @@ bool video_shader_load_preset_into_shader(const char *path, /* Get the absolute path and replace wildcards in the path */ fill_pathname_expanded_and_absolute(path_to_ref, PATH_MAX_LENGTH, conf->path, path_list_tmp->path); + /* TODO/FIXME - dehardcode PATH_MAX_LENGTH */ video_shader_replace_wildcards(path_to_ref, PATH_MAX_LENGTH, conf->path); if ((tmp_conf = video_shader_get_root_preset_config(path_to_ref))) From 2533bbdc0b2003555bd0846f0bfb2a1d54ea32eb Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Wed, 15 Jan 2025 12:37:35 +0100 Subject: [PATCH 11/49] Small cleanups --- gfx/gfx_widgets.c | 95 ++++++++++------------ gfx/widgets/gfx_widget_achievement_popup.c | 22 ++--- 2 files changed, 53 insertions(+), 64 deletions(-) diff --git a/gfx/gfx_widgets.c b/gfx/gfx_widgets.c index 6024d958ece4..b36f3abc0930 100644 --- a/gfx/gfx_widgets.c +++ b/gfx/gfx_widgets.c @@ -16,7 +16,6 @@ */ #include -#include #ifdef HAVE_CONFIG_H #include "../config.h" @@ -43,39 +42,11 @@ #include "../tasks/task_content.h" #include "../tasks/tasks_internal.h" -#define BASE_FONT_SIZE 32.0f - +#define BASE_FONT_SIZE 32.0f #define MSG_QUEUE_FONT_SIZE 20.0f -/* Icons */ -static const char -*gfx_widgets_icons_names[MENU_WIDGETS_ICON_LAST] = { - "menu_pause.png", - "menu_frameskip.png", - "menu_rewind.png", - "resume.png", - - "menu_hourglass.png", - "menu_check.png", - "menu_add.png", - "menu_exit.png", - - "menu_info.png", - - "menu_achievements.png" -}; - static dispgfx_widget_t dispwidget_st = {0}; /* uint64_t alignment */ -static void INLINE gfx_widgets_font_free(gfx_widget_font_data_t *font_data) -{ - if (font_data->font) - font_driver_free(font_data->font); - - font_data->font = NULL; - font_data->usage_count = 0; -} - /* Widgets list */ const static gfx_widget_t* const widgets[] = { #ifdef HAVE_NETWORKING @@ -1514,19 +1485,6 @@ static void gfx_widgets_draw_regular_msg( } } -static void INLINE gfx_widgets_font_bind(gfx_widget_font_data_t *font_data) -{ - font_driver_bind_block(font_data->font, &font_data->raster_block); - font_data->raster_block.carr.coords.vertices = 0; - font_data->usage_count = 0; -} - -static void INLINE gfx_widgets_font_unbind(gfx_widget_font_data_t *font_data) -{ - font_driver_bind_block(font_data->font, NULL); -} - - void gfx_widgets_frame(void *data) { size_t i; @@ -1568,9 +1526,19 @@ void gfx_widgets_frame(void *data) video_st->data, video_width, video_height, true, false); /* Font setup */ - gfx_widgets_font_bind(&p_dispwidget->gfx_widget_fonts.regular); - gfx_widgets_font_bind(&p_dispwidget->gfx_widget_fonts.bold); - gfx_widgets_font_bind(&p_dispwidget->gfx_widget_fonts.msg_queue); + font_driver_bind_block(p_dispwidget->gfx_widget_fonts.regular.font, + &p_dispwidget->gfx_widget_fonts.regular.raster_block); + font_driver_bind_block(p_dispwidget->gfx_widget_fonts.bold.font, + &p_dispwidget->gfx_widget_fonts.bold.raster_block); + font_driver_bind_block(p_dispwidget->gfx_widget_fonts.msg_queue.font, + &p_dispwidget->gfx_widget_fonts.msg_queue.raster_block); + + p_dispwidget->gfx_widget_fonts.regular.raster_block.carr.coords.vertices = 0; + p_dispwidget->gfx_widget_fonts.regular.usage_count = 0; + p_dispwidget->gfx_widget_fonts.bold.raster_block.carr.coords.vertices = 0; + p_dispwidget->gfx_widget_fonts.bold.usage_count = 0; + p_dispwidget->gfx_widget_fonts.msg_queue.raster_block.carr.coords.vertices = 0; + p_dispwidget->gfx_widget_fonts.msg_queue.usage_count = 0; #ifdef HAVE_TRANSLATE /* AI Service overlay */ @@ -1669,7 +1637,7 @@ void gfx_widgets_frame(void *data) } #endif - /* Status Text (fps, framecount, memory, core status message) */ + /* Status Text (FPS, framecount, memory, core status message) */ if ( fps_show || framecount_show || memory_show @@ -1835,9 +1803,9 @@ void gfx_widgets_frame(void *data) &p_dispwidget->gfx_widget_fonts.msg_queue); /* Unbind fonts */ - gfx_widgets_font_unbind(&p_dispwidget->gfx_widget_fonts.regular); - gfx_widgets_font_unbind(&p_dispwidget->gfx_widget_fonts.bold); - gfx_widgets_font_unbind(&p_dispwidget->gfx_widget_fonts.msg_queue); + font_driver_bind_block(p_dispwidget->gfx_widget_fonts.regular.font, NULL); + font_driver_bind_block(p_dispwidget->gfx_widget_fonts.bold.font, NULL); + font_driver_bind_block(p_dispwidget->gfx_widget_fonts.msg_queue.font, NULL); if (video_st->current_video && video_st->current_video->set_viewport) video_st->current_video->set_viewport( @@ -1938,6 +1906,23 @@ static void gfx_widgets_context_reset( unsigned width, unsigned height, bool fullscreen, const char *dir_assets, char *font_path) { + /* Icons */ + static const char + *gfx_widgets_icons_names[MENU_WIDGETS_ICON_LAST] = { + "menu_pause.png", + "menu_frameskip.png", + "menu_rewind.png", + "resume.png", + + "menu_hourglass.png", + "menu_check.png", + "menu_add.png", + "menu_exit.png", + + "menu_info.png", + + "menu_achievements.png" + }; size_t i; /* Load textures */ @@ -2111,6 +2096,15 @@ bool gfx_widgets_init( return false; } +static void gfx_widgets_font_free(gfx_widget_font_data_t *font_data) +{ + if (font_data->font) + font_driver_free(font_data->font); + + font_data->font = NULL; + font_data->usage_count = 0; +} + static void gfx_widgets_context_destroy(dispgfx_widget_t *p_dispwidget) { size_t i; @@ -2135,7 +2129,6 @@ static void gfx_widgets_context_destroy(dispgfx_widget_t *p_dispwidget) gfx_widgets_font_free(&p_dispwidget->gfx_widget_fonts.msg_queue); } - void gfx_widgets_deinit(bool widgets_persisting) { dispgfx_widget_t *p_dispwidget = &dispwidget_st; diff --git a/gfx/widgets/gfx_widget_achievement_popup.c b/gfx/widgets/gfx_widget_achievement_popup.c index ba583a8ab0b2..0de8cbe29c41 100644 --- a/gfx/widgets/gfx_widget_achievement_popup.c +++ b/gfx/widgets/gfx_widget_achievement_popup.c @@ -155,18 +155,14 @@ static void gfx_widget_achievement_popup_frame(void* data, void* userdata) gfx_display_ctx_driver_t* dispctx = p_disp->dispctx; dispgfx_widget_t* p_dispwidget = (dispgfx_widget_t*)userdata; - unsigned text_unfold_offset = 0; - bool is_folding = false; - unsigned screen_padding_x = 0; - unsigned screen_padding_y = 0; - int screen_pos_x = 0; - int screen_pos_y = 0; - + unsigned screen_padding_x = 0; + unsigned screen_padding_y = 0; + int screen_pos_x = 0; + int screen_pos_y = 0; /* Slight additional offset for title/subtitle while unfolding */ - text_unfold_offset = ((1.0f - state->unfold) * state->width) * 0.5; - + unsigned text_unfold_offset = ((1.0f - state->unfold) * state->width) * 0.5; /* Whether gfx scissoring should occur, partially hiding popup */ - is_folding = fabs(state->unfold - 1.0f) > 0.01; + bool is_folding = fabs(state->unfold - 1.0f) > 0.01; /* Calculate padding in screen space */ if (state->padding_auto) @@ -200,11 +196,11 @@ static void gfx_widget_achievement_popup_frame(void* data, void* userdata) switch (state->anchor_v) { case ANCHOR_TOP: - screen_pos_y = -(state->height); + screen_pos_y = -(state->height); screen_pos_y += (screen_padding_y + state->height) * state->slide_v; break; case ANCHOR_BOTTOM: - screen_pos_y = video_height; + screen_pos_y = video_height; screen_pos_y -= (screen_padding_y + state->height) * state->slide_v; break; } @@ -217,7 +213,7 @@ static void gfx_widget_achievement_popup_frame(void* data, void* userdata) state->queue[state->queue_read_index].badge_name) { const retro_time_t next_try = state->queue[state->queue_read_index].badge_retry; - const retro_time_t now = cpu_features_get_time_usec(); + const retro_time_t now = cpu_features_get_time_usec(); if (next_try == 0 || now > next_try) { /* try again in 250ms */ From 47d199297a01b75abf9cbb4a4730a3310d3fca87 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Wed, 15 Jan 2025 12:45:05 +0100 Subject: [PATCH 12/49] runtime_file.c - Move scope of menu_driver_ident call --- runtime_file.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/runtime_file.c b/runtime_file.c index 2b4c794c2794..94ddd01b27f0 100644 --- a/runtime_file.c +++ b/runtime_file.c @@ -1162,9 +1162,6 @@ void runtime_update_playlist( runtime_log_t *runtime_log = NULL; const struct playlist_entry *entry = NULL; struct playlist_entry update_entry = {0}; -#if defined(HAVE_MENU) && (defined(HAVE_OZONE) || defined(HAVE_MATERIALUI)) - const char *menu_ident = menu_driver_ident(); -#endif /* Sanity check */ if (!playlist) @@ -1232,6 +1229,7 @@ void runtime_update_playlist( * to be populated even when no runtime is recorded */ if (update_entry.runtime_status != PLAYLIST_RUNTIME_VALID) { + const char *menu_ident = menu_driver_ident(); if ( string_is_equal(menu_ident, "ozone") || string_is_equal(menu_ident, "glui")) { @@ -1270,9 +1268,6 @@ void runtime_update_contentless_core( core_info_t *core_info = NULL; runtime_log_t *runtime_log = NULL; contentless_core_runtime_info_t runtime_info = {0}; -#if (defined(HAVE_OZONE) || defined(HAVE_MATERIALUI)) - const char *menu_ident = menu_driver_ident(); -#endif /* Sanity check */ if ( string_is_empty(core_path) @@ -1325,6 +1320,7 @@ void runtime_update_contentless_core( * to be populated even when no runtime is recorded */ if (runtime_info.status != CONTENTLESS_CORE_RUNTIME_VALID) { + const char *menu_ident = menu_driver_ident(); if ( string_is_equal(menu_ident, "ozone") || string_is_equal(menu_ident, "glui")) { From 047e04ed3e4ea800459250500250fd151254555d Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Wed, 15 Jan 2025 15:00:12 +0100 Subject: [PATCH 13/49] Standardize local len variable naming conventions --- bluetooth/drivers/bluetoothctl.c | 6 +- input/input_driver.c | 14 +-- libretro-common/cdrom/cdrom.c | 23 ++-- libretro-common/compat/compat_posix_string.c | 7 +- libretro-common/compat/compat_strl.c | 39 +++---- libretro-common/file/file_path.c | 6 +- libretro-common/formats/m3u/m3u_file.c | 8 +- libretro-common/media/media_detect_cd.c | 31 +++-- libretro-common/memmap/memmap.c | 14 +-- libretro-common/vfs/vfs_implementation.c | 16 +-- .../vfs/vfs_implementation_uwp.cpp | 12 +- network/cloud_sync/webdav.c | 106 +++++++++--------- tasks/task_cloudsync.c | 16 ++- 13 files changed, 135 insertions(+), 163 deletions(-) diff --git a/bluetooth/drivers/bluetoothctl.c b/bluetooth/drivers/bluetoothctl.c index 8913aaae4571..20e3919d0e56 100644 --- a/bluetooth/drivers/bluetoothctl.c +++ b/bluetooth/drivers/bluetoothctl.c @@ -64,9 +64,9 @@ static void bluetoothctl_scan(void *data) while (fgets(line, 512, dev_file)) { - size_t len = strlen(line); - if (len > 0 && line[len-1] == '\n') - line[--len] = '\0'; + size_t _len = strlen(line); + if (_len > 0 && line[_len - 1] == '\n') + line[--_len] = '\0'; string_list_append(btctl->lines, line, attr); } diff --git a/input/input_driver.c b/input/input_driver.c index e47a935ff504..f4a16934b498 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -4088,7 +4088,6 @@ static bool input_keyboard_line_event( bool ret = false; const char *word = NULL; char c = (character >= 128) ? '?' : character; - #ifdef HAVE_LANGEXTRA static uint32_t composition = 0; /* reset composition, when edit box is opened. */ @@ -4099,12 +4098,12 @@ static bool input_keyboard_line_event( composition = 0; if (IS_COMPOSITION(character) || IS_END_COMPOSITION(character)) { - size_t len = strlen((char*)&composition); - if (composition && state->buffer && state->size >= len && state->ptr >= len) + size_t _len = strlen((char*)&composition); + if (composition && state->buffer && state->size >= _len && state->ptr >= _len) { - memmove(state->buffer + state->ptr-len, state->buffer + state->ptr, len + 1); - state->ptr -= len; - state->size -= len; + memmove(state->buffer + state->ptr - _len, state->buffer + state->ptr, _len + 1); + state->ptr -= _len; + state->size -= _len; } if (IS_COMPOSITION_KR(character) && composition) { @@ -4123,7 +4122,7 @@ static bool input_keyboard_line_event( composition = character & 0xffffff; character &= 0xffffff; } - if (len && composition == 0) + if (_len && composition == 0) word = state->buffer; if (character) input_keyboard_line_append(state, (char*)&character, strlen((char*)&character)); @@ -4134,7 +4133,6 @@ static bool input_keyboard_line_event( /* Treat extended chars as ? as we cannot support * printable characters for unicode stuff. */ - if (c == '\r' || c == '\n') { state->cb(state->userdata, state->buffer); diff --git a/libretro-common/cdrom/cdrom.c b/libretro-common/cdrom/cdrom.c index a1de1a15c8f2..c507eadc0f71 100644 --- a/libretro-common/cdrom/cdrom.c +++ b/libretro-common/cdrom/cdrom.c @@ -1000,12 +1000,11 @@ int cdrom_set_read_speed(libretro_vfs_implementation_file *stream, unsigned spee int cdrom_write_cue(libretro_vfs_implementation_file *stream, char **out_buf, size_t *out_len, char cdrom_drive, unsigned char *num_tracks, cdrom_toc_t *toc) { + int i; unsigned char buf[2352] = {0}; unsigned short data_len = 0; - size_t len = 0; - size_t pos = 0; + size_t _len = 0, pos = 0; int rv = 0; - int i; if (!out_buf || !out_len || !num_tracks || !toc) { @@ -1052,10 +1051,10 @@ int cdrom_write_cue(libretro_vfs_implementation_file *stream, char **out_buf, si return 1; } - len = CDROM_CUE_TRACK_BYTES * (*num_tracks); + _len = CDROM_CUE_TRACK_BYTES * (*num_tracks); toc->num_tracks = *num_tracks; - *out_buf = (char*)calloc(1, len); - *out_len = len; + *out_buf = (char*)calloc(1, _len); + *out_len = _len; for (i = 0; i < (data_len - 2) / 11; i++) { @@ -1104,11 +1103,11 @@ int cdrom_write_cue(libretro_vfs_implementation_file *stream, char **out_buf, si track_type = "MODE2/2352"; #if defined(_WIN32) && !defined(_XBOX) - pos += snprintf(*out_buf + pos, len - pos, "FILE \"cdrom://%c:/drive-track%02d.bin\" BINARY\n", cdrom_drive, point); + pos += snprintf(*out_buf + pos, _len - pos, "FILE \"cdrom://%c:/drive-track%02d.bin\" BINARY\n", cdrom_drive, point); #else - pos += snprintf(*out_buf + pos, len - pos, "FILE \"cdrom://drive%c-track%02d.bin\" BINARY\n", cdrom_drive, point); + pos += snprintf(*out_buf + pos, _len - pos, "FILE \"cdrom://drive%c-track%02d.bin\" BINARY\n", cdrom_drive, point); #endif - pos += snprintf(*out_buf + pos, len - pos, " TRACK %02d %s\n", point, track_type); + pos += snprintf(*out_buf + pos, _len - pos, " TRACK %02d %s\n", point, track_type); { unsigned pregap_lba_len = toc->track[point - 1].lba - toc->track[point - 1].lba_start; @@ -1121,11 +1120,11 @@ int cdrom_write_cue(libretro_vfs_implementation_file *stream, char **out_buf, si cdrom_lba_to_msf(pregap_lba_len, &min, &sec, &frame); - pos += snprintf(*out_buf + pos, len - pos, " INDEX 00 00:00:00\n"); - pos += snprintf(*out_buf + pos, len - pos, " INDEX 01 %02u:%02u:%02u\n", (unsigned)min, (unsigned)sec, (unsigned)frame); + pos += snprintf(*out_buf + pos, _len - pos, " INDEX 00 00:00:00\n"); + pos += snprintf(*out_buf + pos, _len - pos, " INDEX 01 %02u:%02u:%02u\n", (unsigned)min, (unsigned)sec, (unsigned)frame); } else - pos += snprintf(*out_buf + pos, len - pos, " INDEX 01 00:00:00\n"); + pos += snprintf(*out_buf + pos, _len - pos, " INDEX 01 00:00:00\n"); } } } diff --git a/libretro-common/compat/compat_posix_string.c b/libretro-common/compat/compat_posix_string.c index 6a2f07ee4b3e..41c8d0a2fe48 100644 --- a/libretro-common/compat/compat_posix_string.c +++ b/libretro-common/compat/compat_posix_string.c @@ -56,12 +56,11 @@ int retro_strcasecmp__(const char *a, const char *b) char *retro_strdup__(const char *orig) { - size_t len = strlen(orig) + 1; - char *ret = (char*)malloc(len); + size_t _len = strlen(orig) + 1; + char *ret = (char*)malloc(_len); if (!ret) return NULL; - - strlcpy(ret, orig, len); + strlcpy(ret, orig, _len); return ret; } diff --git a/libretro-common/compat/compat_strl.c b/libretro-common/compat/compat_strl.c index 3a6392cb127b..d11a8c6699af 100644 --- a/libretro-common/compat/compat_strl.c +++ b/libretro-common/compat/compat_strl.c @@ -28,35 +28,28 @@ /* Implementation of strlcpy()/strlcat() based on OpenBSD. */ #ifndef __MACH__ - -size_t strlcpy(char *dest, const char *source, size_t size) +size_t strlcpy(char *s, const char *source, size_t len) { - size_t src_size = 0; - size_t n = size; - - if (n) - while (--n && (*dest++ = *source++)) src_size++; - - if (!n) + size_t _len = len; + size_t __len = 0; + if (_len) + while (--_len && (*s++ = *source++)) __len++; + if (!_len) { - if (size) *dest = '\0'; - while (*source++) src_size++; + if (len) *s = '\0'; + while (*source++) __len++; } - - return src_size; + return __len; } -size_t strlcat(char *dest, const char *source, size_t size) +size_t strlcat(char *s, const char *source, size_t len) { - size_t len = strlen(dest); - - dest += len; - - if (len > size) - size = 0; + size_t _len = strlen(s); + s += _len; + if (_len > len) + len = 0; else - size -= len; - - return len + strlcpy(dest, source, size); + len -= _len; + return _len + strlcpy(s, source, len); } #endif diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index 92c880327436..5a968326be4a 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -1414,11 +1414,11 @@ size_t fill_pathname_application_path(char *s, size_t len) } #elif defined(__QNX__) char *buff = malloc(len); - size_t rv = 0; + size_t _len = 0; if (_cmdname(buff)) - rv = strlcpy(s, buff, len); + _len = strlcpy(s, buff, len); free(buff); - return rv; + return _len; #else size_t i; static const char *exts[] = { "exe", "file", "path/a.out" }; diff --git a/libretro-common/formats/m3u/m3u_file.c b/libretro-common/formats/m3u/m3u_file.c index 560162e62a7a..2eb8a8da2438 100644 --- a/libretro-common/formats/m3u/m3u_file.c +++ b/libretro-common/formats/m3u/m3u_file.c @@ -182,16 +182,16 @@ static bool m3u_file_load(m3u_file_t *m3u_file) if (token_ptr) { - size_t len = (size_t)(1 + token_ptr - line); + size_t _len = (size_t)(1 + token_ptr - line); /* Get entry_path segment */ - if (len > 0) + if (_len > 0) { memset(entry_path, 0, sizeof(entry_path)); strlcpy( entry_path, line, - ((len < PATH_MAX_LENGTH ? - len : PATH_MAX_LENGTH) * sizeof(char))); + ((_len < PATH_MAX_LENGTH ? + _len : PATH_MAX_LENGTH) * sizeof(char))); string_trim_whitespace_right(entry_path); string_trim_whitespace_left(entry_path); } diff --git a/libretro-common/media/media_detect_cd.c b/libretro-common/media/media_detect_cd.c index c8ea47f72095..68831c4b3209 100644 --- a/libretro-common/media/media_detect_cd.c +++ b/libretro-common/media/media_detect_cd.c @@ -28,34 +28,31 @@ /*#define MEDIA_CUE_PARSE_DEBUG*/ -static void media_zero_trailing_spaces(char *buf, size_t len) +static void media_zero_trailing_spaces(char *s, size_t len) { int i; - for (i = len - 1; i >= 0; i--) { - if (buf[i] == ' ') - buf[i] = '\0'; - else if (buf[i] != '\0') + if (s[i] == ' ') + s[i] = '\0'; + else if (s[i] != '\0') break; } } -static bool media_skip_spaces(const char **buf, size_t len) +static bool media_skip_spaces(const char **s, size_t len) { - if (buf && *buf && **buf) + if (s && *s && **s) { size_t i; for (i = 0; i < len; i++) { - if ((*buf)[i] == ' ' || (*buf)[i] == '\t') + if ((*s)[i] == ' ' || (*s)[i] == '\t') continue; - - *buf += i; + *s += i; return true; } } - return false; } @@ -86,7 +83,7 @@ bool media_detect_cd_info_cue(const char *path, media_detect_cd_info_t *info) while (!filestream_eof(file) && (line = filestream_getline(file))) { - size_t len = 0; + size_t _len = 0; const char *command = NULL; if (string_is_empty(line)) @@ -95,15 +92,15 @@ bool media_detect_cd_info_cue(const char *path, media_detect_cd_info_t *info) continue; } - len = strlen(line); + _len = strlen(line); command = line; - media_skip_spaces(&command, len); + media_skip_spaces(&command, _len); if (!found_file && !strncasecmp(command, "FILE", 4)) { const char *file = command + 4; - media_skip_spaces(&file, len - 4); + media_skip_spaces(&file, _len - 4); if (!string_is_empty(file)) { @@ -137,7 +134,7 @@ bool media_detect_cd_info_cue(const char *path, media_detect_cd_info_t *info) else if (found_file && !found_track && !strncasecmp(command, "TRACK", 5)) { const char *track = command + 5; - media_skip_spaces(&track, len - 5); + media_skip_spaces(&track, _len - 5); if (!string_is_empty(track)) { @@ -173,7 +170,7 @@ bool media_detect_cd_info_cue(const char *path, media_detect_cd_info_t *info) else if (found_file && found_track && first_data_track && !strncasecmp(command, "INDEX", 5)) { const char *index = command + 5; - media_skip_spaces(&index, len - 5); + media_skip_spaces(&index, _len - 5); if (!string_is_empty(index)) { diff --git a/libretro-common/memmap/memmap.c b/libretro-common/memmap/memmap.c index 229ed170fd68..89e45e0edae3 100644 --- a/libretro-common/memmap/memmap.c +++ b/libretro-common/memmap/memmap.c @@ -94,9 +94,7 @@ void* mmap(void *addr, size_t len, int prot, int flags, int munmap(void *addr, size_t len) { - if (!UnmapViewOfFile(addr)) - return -1; - return 0; + return (UnmapViewOfFile(addr)) ? 0 : -1; } int mprotect(void *addr, size_t len, int prot) @@ -137,23 +135,21 @@ int mprotect(void *addr, size_t len, int prot) int memsync(void *start, void *end) { - size_t len = (char*)end - (char*)start; + size_t _len = (char*)end - (char*)start; #if defined(__MACH__) && defined(__arm__) - sys_dcache_flush(start ,len); - sys_icache_invalidate(start, len); + sys_dcache_flush(start, _len); + sys_icache_invalidate(start, _len); return 0; #elif defined(__arm__) && !defined(__QNX__) - (void)len; __clear_cache(start, end); return 0; #elif defined(HAVE_MMAN) - return msync(start, len, MS_SYNC | MS_INVALIDATE + return msync(start, _len, MS_SYNC | MS_INVALIDATE #ifdef __QNX__ MS_CACHE_ONLY #endif ); #else - (void)len; return 0; #endif } diff --git a/libretro-common/vfs/vfs_implementation.c b/libretro-common/vfs/vfs_implementation.c index 7a55d3ac1b21..efbbf508c5f5 100644 --- a/libretro-common/vfs/vfs_implementation.c +++ b/libretro-common/vfs/vfs_implementation.c @@ -1074,7 +1074,7 @@ libretro_vfs_implementation_dir *retro_vfs_opendir_impl( { #if defined(_WIN32) char path_buf[1024]; - size_t copied = 0; + size_t _len; #if defined(LEGACY_WIN32) char *path_local = NULL; #else @@ -1095,25 +1095,21 @@ libretro_vfs_implementation_dir *retro_vfs_opendir_impl( rdir->orig_path = strdup(name); #if defined(_WIN32) - copied = strlcpy(path_buf, name, sizeof(path_buf)); - + _len = strlcpy(path_buf, name, sizeof(path_buf)); /* Non-NT platforms don't like extra slashes in the path */ - if (path_buf[copied - 1] != '\\') - path_buf [copied++] = '\\'; - - path_buf[copied ] = '*'; - path_buf[copied+1] = '\0'; + if (path_buf[_len - 1] != '\\') + path_buf [_len++] = '\\'; + path_buf[_len ] = '*'; + path_buf[_len + 1] = '\0'; #if defined(LEGACY_WIN32) path_local = utf8_to_local_string_alloc(path_buf); rdir->directory = FindFirstFile(path_local, &rdir->entry); - if (path_local) free(path_local); #else path_wide = utf8_to_utf16_string_alloc(path_buf); rdir->directory = FindFirstFileW(path_wide, &rdir->entry); - if (path_wide) free(path_wide); #endif diff --git a/libretro-common/vfs/vfs_implementation_uwp.cpp b/libretro-common/vfs/vfs_implementation_uwp.cpp index 5ffda0bbd521..b429a89a048c 100644 --- a/libretro-common/vfs/vfs_implementation_uwp.cpp +++ b/libretro-common/vfs/vfs_implementation_uwp.cpp @@ -659,8 +659,8 @@ struct libretro_vfs_implementation_dir libretro_vfs_implementation_dir* retro_vfs_opendir_impl( const char* name, bool include_hidden) { + size_t _len; char path_buf[1024]; - size_t copied = 0; wchar_t* path_wide = NULL; libretro_vfs_implementation_dir* rdir; @@ -674,14 +674,14 @@ libretro_vfs_implementation_dir* retro_vfs_opendir_impl( rdir->orig_path = strdup(name); - copied = strlcpy(path_buf, name, sizeof(path_buf)); + _len = strlcpy(path_buf, name, sizeof(path_buf)); /* Non-NT platforms don't like extra slashes in the path */ - if (path_buf[copied - 1] != '\\') - path_buf[copied++] = '\\'; + if (path_buf[_len - 1] != '\\') + path_buf[_len++] = '\\'; - path_buf[copied] = '*'; - path_buf[copied + 1] = '\0'; + path_buf[_len] = '*'; + path_buf[_len + 1] = '\0'; path_wide = utf8_to_utf16_string_alloc(path_buf); rdir->directory = FindFirstFileExFromAppW( diff --git a/network/cloud_sync/webdav.c b/network/cloud_sync/webdav.c index 7620ee7aa367..075c2fb34725 100644 --- a/network/cloud_sync/webdav.c +++ b/network/cloud_sync/webdav.c @@ -70,26 +70,24 @@ webdav_state_t *webdav_state_get_ptr(void) static char *webdav_create_basic_auth(void) { - settings_t *settings = config_get_ptr(); - size_t len = 0; - char userpass[512]; - char *base64auth; int flen; - + char *base64auth; + char userpass[512]; + settings_t *settings = config_get_ptr(); + size_t _len = 0; if (!string_is_empty(settings->arrays.webdav_username)) - len += strlcpy(userpass + len, settings->arrays.webdav_username, sizeof(userpass) - len); - userpass[len++] = ':'; + _len += strlcpy(userpass + _len, settings->arrays.webdav_username, sizeof(userpass) - _len); + userpass[_len++] = ':'; if (!string_is_empty(settings->arrays.webdav_password)) - len += strlcpy(userpass + len, settings->arrays.webdav_password, sizeof(userpass) - len); - userpass[len] = '\0'; - base64auth = base64(userpass, (int)len, &flen); - len = strlcpy(userpass, "Authorization: Basic ", sizeof(userpass)); - len += strlcpy(userpass + len, base64auth, sizeof(userpass) - len); + _len += strlcpy(userpass + _len, settings->arrays.webdav_password, sizeof(userpass) - _len); + userpass[_len] = '\0'; + base64auth = base64(userpass, (int)_len, &flen); + _len = strlcpy(userpass, "Authorization: Basic ", sizeof(userpass)); + _len += strlcpy(userpass + _len, base64auth, sizeof(userpass) - _len); free(base64auth); - userpass[len++] = '\r'; - userpass[len++] = '\n'; - userpass[len ] = '\0'; - + userpass[_len++] = '\r'; + userpass[_len++] = '\n'; + userpass[_len ] = '\0'; return strdup(userpass); } @@ -357,13 +355,13 @@ static char *webdav_create_digest_response(const char *method, const char *path) static char *webdav_create_digest_auth_header(const char *method, const char *url) { + size_t _len; + char nonceCount[10]; webdav_state_t *webdav_st = webdav_state_get_ptr(); - char *header; - char *response; - char nonceCount[10]; + char *header = NULL; + char *response = NULL; const char *path = url; int count = 0; - size_t len = 0; size_t total = 0; do @@ -376,48 +374,46 @@ static char *webdav_create_digest_auth_header(const char *method, const char *ur response = webdav_create_digest_response(method, path); snprintf(nonceCount, sizeof(nonceCount), "%08x", webdav_st->nc++); - len = STRLEN_CONST("Authorization: Digest "); - len += STRLEN_CONST("username=\"") + strlen(webdav_st->username) + STRLEN_CONST("\", "); - len += STRLEN_CONST("realm=\"") + strlen(webdav_st->realm) + STRLEN_CONST("\", "); - len += STRLEN_CONST("nonce=\"") + strlen(webdav_st->nonce) + STRLEN_CONST("\", "); - len += STRLEN_CONST("uri=\"") + strlen(path) + STRLEN_CONST("\", "); - len += STRLEN_CONST("nc=\"") + strlen(nonceCount) + STRLEN_CONST("\", "); - len += STRLEN_CONST("cnonce=\"") + strlen(webdav_st->cnonce) + STRLEN_CONST("\", "); + _len = STRLEN_CONST("Authorization: Digest "); + _len += STRLEN_CONST("username=\"") + strlen(webdav_st->username) + STRLEN_CONST("\", "); + _len += STRLEN_CONST("realm=\"") + strlen(webdav_st->realm) + STRLEN_CONST("\", "); + _len += STRLEN_CONST("nonce=\"") + strlen(webdav_st->nonce) + STRLEN_CONST("\", "); + _len += STRLEN_CONST("uri=\"") + strlen(path) + STRLEN_CONST("\", "); + _len += STRLEN_CONST("nc=\"") + strlen(nonceCount) + STRLEN_CONST("\", "); + _len += STRLEN_CONST("cnonce=\"") + strlen(webdav_st->cnonce) + STRLEN_CONST("\", "); if (webdav_st->qop_auth) - len += STRLEN_CONST("qop=\"auth\", "); + _len += STRLEN_CONST("qop=\"auth\", "); if (webdav_st->opaque) - len += STRLEN_CONST("opaque=\"") + strlen(webdav_st->opaque) + STRLEN_CONST("\", "); - len += STRLEN_CONST("response=\"") + strlen(response) + STRLEN_CONST("\"\r\n"); - len += 1; - - total = len; - len = 0; - header = malloc(total); - len = strlcpy(header, "Authorization: Digest username=\"", total - len); - len += strlcpy(header + len, webdav_st->username, total - len); - len += strlcpy(header + len, "\", realm=\"", total - len); - len += strlcpy(header + len, webdav_st->realm, total - len); - len += strlcpy(header + len, "\", nonce=\"", total - len); - len += strlcpy(header + len, webdav_st->nonce, total - len); - len += strlcpy(header + len, "\", uri=\"", total - len); - len += strlcpy(header + len, path, total - len); - len += strlcpy(header + len, "\", nc=\"", total - len); - len += strlcpy(header + len, nonceCount, total - len); - len += strlcpy(header + len, "\", cnonce=\"", total - len); - len += strlcpy(header + len, webdav_st->cnonce, total - len); + _len += STRLEN_CONST("opaque=\"") + strlen(webdav_st->opaque) + STRLEN_CONST("\", "); + _len += STRLEN_CONST("response=\"") + strlen(response) + STRLEN_CONST("\"\r\n"); + _len += 1; + + total = _len; + _len = 0; + header = (char*)malloc(total); + _len = strlcpy(header, "Authorization: Digest username=\"", total - _len); + _len += strlcpy(header + _len, webdav_st->username, total - _len); + _len += strlcpy(header + _len, "\", realm=\"", total - _len); + _len += strlcpy(header + _len, webdav_st->realm, total - _len); + _len += strlcpy(header + _len, "\", nonce=\"", total - _len); + _len += strlcpy(header + _len, webdav_st->nonce, total - _len); + _len += strlcpy(header + _len, "\", uri=\"", total - _len); + _len += strlcpy(header + _len, path, total - _len); + _len += strlcpy(header + _len, "\", nc=\"", total - _len); + _len += strlcpy(header + _len, nonceCount, total - _len); + _len += strlcpy(header + _len, "\", cnonce=\"", total - _len); + _len += strlcpy(header + _len, webdav_st->cnonce, total - _len); if (webdav_st->qop_auth) - len += strlcpy(header + len, "\", qop=\"auth", total - len); + _len += strlcpy(header + _len, "\", qop=\"auth", total - _len); if (webdav_st->opaque) { - len += strlcpy(header + len, "\", opaque=\"", total - len); - len += strlcpy(header + len, webdav_st->opaque, total - len); + _len += strlcpy(header + _len, "\", opaque=\"", total - _len); + _len += strlcpy(header + _len, webdav_st->opaque, total - _len); } - len += strlcpy(header + len, "\", response=\"", total - len); - len += strlcpy(header + len, response, total - len); - strlcpy(header + len, "\"\r\n", total - len); - + _len += strlcpy(header + _len, "\", response=\"", total - _len); + _len += strlcpy(header + _len, response, total - _len); + strlcpy(header + _len, "\"\r\n", total - _len); free(response); - return header; } diff --git a/tasks/task_cloudsync.c b/tasks/task_cloudsync.c index e6bbd3991717..a7e014f94968 100644 --- a/tasks/task_cloudsync.c +++ b/tasks/task_cloudsync.c @@ -175,13 +175,11 @@ static file_list_t *task_cloud_sync_create_manifest(RFILE *file) return list; } -static void task_cloud_sync_manifest_filename(char *path, size_t len, bool server) +static void task_cloud_sync_manifest_filename(char *s, size_t len, bool server) { settings_t *settings = config_get_ptr(); const char *path_dir_core_assets = settings->paths.directory_core_assets; - - fill_pathname_join_special(path, - path_dir_core_assets, + fill_pathname_join_special(s, path_dir_core_assets, server ? MANIFEST_FILENAME_SERVER : MANIFEST_FILENAME_LOCAL, len); } @@ -1121,15 +1119,15 @@ static void task_cloud_sync_end_handler(void *user_data, const char *path, bool if ((sync_state = (task_cloud_sync_state_t *)task->state)) { char title[128]; - size_t len = strlcpy(title, "Cloud Sync finished", sizeof(title)); + size_t _len = strlcpy(title, "Cloud Sync finished", sizeof(title)); if (sync_state->failures || sync_state->conflicts) - len += strlcpy(title + len, " with ", sizeof(title) - len); + _len += strlcpy(title + _len, " with ", sizeof(title) - _len); if (sync_state->failures) - len += strlcpy(title + len, "failures", sizeof(title) - len); + _len += strlcpy(title + _len, "failures", sizeof(title) - _len); if (sync_state->failures && sync_state->conflicts) - len += strlcpy(title + len, " and ", sizeof(title) - len); + _len += strlcpy(title + _len, " and ", sizeof(title) - _len); if (sync_state->conflicts) - strlcpy(title + len, "conflicts", sizeof(title) - len); + strlcpy(title + _len, "conflicts", sizeof(title) - _len); task_set_title(task, strdup(title)); } From 7456711eaa2bb4b6e6b839a6aef9aa26169c76ea Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Wed, 15 Jan 2025 15:08:37 +0100 Subject: [PATCH 14/49] (video_shader_parse.c) Standardize replace_len variable name and reduce char array buffers --- gfx/video_shader_parse.c | 52 ++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 0d7dadd28159..b6db6738c914 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -246,7 +246,7 @@ static void video_shader_replace_wildcards(char *s, size_t len, char *in_preset_ /* If the wildcard text is in the path then process it */ if (strstr(replaced_path, wildcard_tokens[i].token_name)) { - size_t replace_len = 0; + size_t _len = 0; char replace_text[PATH_MAX_LENGTH]; switch (wildcard_tokens[i].token_id) @@ -267,7 +267,7 @@ static void video_shader_replace_wildcards(char *s, size_t len, char *in_preset_ path_remove_extension(content_dir_name); if (string_is_not_equal_fast(content_dir_name, "", sizeof(""))) - replace_len = strlcpy(replace_text, content_dir_name, sizeof(replace_text)); + _len = strlcpy(replace_text, content_dir_name, sizeof(replace_text)); else replace_text[0] = '\0'; } @@ -281,7 +281,7 @@ static void video_shader_replace_wildcards(char *s, size_t len, char *in_preset_ if (path_basename) path_basename = path_basename_nocompression(path_basename); if (path_basename) - replace_len = strlcpy(replace_text, path_basename, sizeof(replace_text)); + _len = strlcpy(replace_text, path_basename, sizeof(replace_text)); else replace_text[0] = '\0'; } @@ -291,61 +291,61 @@ static void video_shader_replace_wildcards(char *s, size_t len, char *in_preset_ break; case RARCH_WILDCARD_CORE_REQUESTED_ROTATION: { - char rotation_replace_strings[4][64] = { + char rotation_replace_strings[4][24] = { "CORE-REQ-ROT-0", "CORE-REQ-ROT-90", "CORE-REQ-ROT-180", "CORE-REQ-ROT-270" }; - replace_len = strlcpy(replace_text, + _len = strlcpy(replace_text, rotation_replace_strings[retroarch_get_core_requested_rotation()], sizeof(replace_text)); } break; case RARCH_WILDCARD_VIDEO_ALLOW_CORE_ROTATION: - if (config_get_ptr()->bools.video_allow_rotate) - replace_len = strlcpy(replace_text, "VID-ALLOW-CORE-ROT-ON", + _len = strlcpy(replace_text, "VID-ALLOW-CORE-ROT-O", sizeof(replace_text)); + if (config_get_ptr()->bools.video_allow_rotate) + _len += strlcpy(replace_text + _len, "N", sizeof(replace_text) - _len); else - replace_len = strlcpy(replace_text, "VID-ALLOW-CORE-ROT-OFF", - sizeof(replace_text)); + _len += strlcpy(replace_text + _len, "FF", sizeof(replace_text) - _len); break; case RARCH_WILDCARD_VIDEO_USER_ROTATION: { - char rotation_replace_strings[4][64] = { + char rotation_replace_strings[4][24] = { "VID-USER-ROT-0", "VID-USER-ROT-90", "VID-USER-ROT-180", "VID-USER-ROT-270" }; settings_t *settings = config_get_ptr(); - replace_len = strlcpy(replace_text, + _len = strlcpy(replace_text, rotation_replace_strings[settings->uints.video_rotation], sizeof(replace_text)); } break; case RARCH_WILDCARD_VIDEO_FINAL_ROTATION: { - char rotation_replace_strings[4][64] = { + char rotation_replace_strings[4][24] = { "VID-FINAL-ROT-0", "VID-FINAL-ROT-90", "VID-FINAL-ROT-180", "VID-FINAL-ROT-270" }; - replace_len = strlcpy(replace_text, + _len = strlcpy(replace_text, rotation_replace_strings[retroarch_get_rotation()], sizeof(replace_text)); } break; case RARCH_WILDCARD_SCREEN_ORIENTATION: { - char rotation_replace_strings[4][64] = { + char rotation_replace_strings[4][24] = { "SCREEN-ORIENT-0", "SCREEN-ORIENT-90", "SCREEN-ORIENT-180", "SCREEN-ORIENT-270" }; - replace_len = strlcpy(replace_text, + _len = strlcpy(replace_text, rotation_replace_strings[config_get_ptr()->uints.screen_orientation], sizeof(replace_text)); } @@ -353,7 +353,7 @@ static void video_shader_replace_wildcards(char *s, size_t len, char *in_preset_ case RARCH_WILDCARD_CORE_ASPECT_ORIENTATION: { const int requested_rotation = retroarch_get_core_requested_rotation(); - replace_len = strlcpy(replace_text, + _len = strlcpy(replace_text, (video_driver_get_core_aspect() < 1 || requested_rotation == 1 || requested_rotation == 3) ? "CORE-ASPECT-ORIENT-VERT" : "CORE-ASPECT-ORIENT-HORZ", @@ -365,7 +365,7 @@ static void video_shader_replace_wildcards(char *s, size_t len, char *in_preset_ unsigned viewport_width = 0; unsigned viewport_height = 0; video_driver_get_size(&viewport_width, &viewport_height); - replace_len = strlcpy(replace_text, + _len = strlcpy(replace_text, ((float)viewport_width / viewport_height < 1) ? "VIEW-ASPECT-ORIENT-VERT" : "VIEW-ASPECT-ORIENT-HORZ", @@ -381,7 +381,7 @@ static void video_shader_replace_wildcards(char *s, size_t len, char *in_preset_ if (string_is_not_equal_fast(preset_dir_name, "", sizeof(""))) path_remove_extension(preset_dir_name); if (string_is_not_equal_fast(preset_dir_name, "", sizeof(""))) - replace_len = strlcpy(replace_text, preset_dir_name, sizeof(replace_text)); + _len = strlcpy(replace_text, preset_dir_name, sizeof(replace_text)); else replace_text[0] = '\0'; } @@ -393,7 +393,7 @@ static void video_shader_replace_wildcards(char *s, size_t len, char *in_preset_ if (string_is_not_equal_fast(preset_name, "", sizeof(""))) path_remove_extension(preset_name); if (string_is_not_equal_fast(preset_name, "", sizeof(""))) - replace_len = strlcpy(replace_text, preset_name, sizeof(replace_text)); + _len = strlcpy(replace_text, preset_name, sizeof(replace_text)); else replace_text[0] = '\0'; } @@ -405,11 +405,11 @@ static void video_shader_replace_wildcards(char *s, size_t len, char *in_preset_ video_context_driver_get_flags(&flags); if (BIT32_GET(flags.flags, GFX_CTX_FLAGS_SHADERS_CG)) - replace_len = strlcpy(replace_text, "cg", sizeof(replace_text)); + _len = strlcpy(replace_text, "cg", sizeof(replace_text)); else if (BIT32_GET(flags.flags, GFX_CTX_FLAGS_SHADERS_GLSL)) - replace_len = strlcpy(replace_text, "glsl", sizeof(replace_text)); + _len = strlcpy(replace_text, "glsl", sizeof(replace_text)); else if (BIT32_GET(flags.flags, GFX_CTX_FLAGS_SHADERS_SLANG)) - replace_len = strlcpy(replace_text, "slang", sizeof(replace_text)); + _len = strlcpy(replace_text, "slang", sizeof(replace_text)); else replace_text[0] = '\0'; } @@ -421,11 +421,11 @@ static void video_shader_replace_wildcards(char *s, size_t len, char *in_preset_ video_context_driver_get_flags(&flags); if (BIT32_GET(flags.flags, GFX_CTX_FLAGS_SHADERS_CG)) - replace_len = strlcpy(replace_text, "cgp", sizeof(replace_text)); + _len = strlcpy(replace_text, "cgp", sizeof(replace_text)); else if (BIT32_GET(flags.flags, GFX_CTX_FLAGS_SHADERS_GLSL)) - replace_len = strlcpy(replace_text, "glslp", sizeof(replace_text)); + _len = strlcpy(replace_text, "glslp", sizeof(replace_text)); else if (BIT32_GET(flags.flags, GFX_CTX_FLAGS_SHADERS_SLANG)) - replace_len = strlcpy(replace_text, "slangp", sizeof(replace_text)); + _len = strlcpy(replace_text, "slangp", sizeof(replace_text)); else replace_text[0] = '\0'; } @@ -440,7 +440,7 @@ static void video_shader_replace_wildcards(char *s, size_t len, char *in_preset_ wildcard_tokens[i].token_name, wildcard_tokens[i].token_size, replace_text, - replace_len); + _len); strlcpy(replaced_path, replace_output, sizeof(replaced_path)); From 076c2bca3b7c563a9eb5e96d3387d4542f6837a8 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Wed, 15 Jan 2025 15:25:27 +0100 Subject: [PATCH 15/49] video_shader_replace_wildcards - get rid of the 2D char arrays --- gfx/video_shader_parse.c | 69 ++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 45 deletions(-) diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index b6db6738c914..07aa57d35b22 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -290,17 +290,12 @@ static void video_shader_replace_wildcards(char *s, size_t len, char *in_preset_ strlcpy(replace_text, config_get_ptr()->arrays.video_driver, sizeof(replace_text)); break; case RARCH_WILDCARD_CORE_REQUESTED_ROTATION: - { - char rotation_replace_strings[4][24] = { - "CORE-REQ-ROT-0", - "CORE-REQ-ROT-90", - "CORE-REQ-ROT-180", - "CORE-REQ-ROT-270" - }; - _len = strlcpy(replace_text, - rotation_replace_strings[retroarch_get_core_requested_rotation()], - sizeof(replace_text)); - } + _len = strlcpy(replace_text, "CORE-REQ-ROT-", sizeof(replace_text)); + _len += snprintf( + replace_text + _len, + sizeof(replace_text) - _len, + "%d", + retroarch_get_core_requested_rotation() * 90); break; case RARCH_WILDCARD_VIDEO_ALLOW_CORE_ROTATION: _len = strlcpy(replace_text, "VID-ALLOW-CORE-ROT-O", @@ -311,44 +306,28 @@ static void video_shader_replace_wildcards(char *s, size_t len, char *in_preset_ _len += strlcpy(replace_text + _len, "FF", sizeof(replace_text) - _len); break; case RARCH_WILDCARD_VIDEO_USER_ROTATION: - { - char rotation_replace_strings[4][24] = { - "VID-USER-ROT-0", - "VID-USER-ROT-90", - "VID-USER-ROT-180", - "VID-USER-ROT-270" - }; - settings_t *settings = config_get_ptr(); - _len = strlcpy(replace_text, - rotation_replace_strings[settings->uints.video_rotation], - sizeof(replace_text)); - } + _len = strlcpy(replace_text, "VID-USER-ROT-", sizeof(replace_text)); + _len += snprintf( + replace_text + _len, + sizeof(replace_text) - _len, + "%d", + config_get_ptr()->uints.video_rotation * 90); break; case RARCH_WILDCARD_VIDEO_FINAL_ROTATION: - { - char rotation_replace_strings[4][24] = { - "VID-FINAL-ROT-0", - "VID-FINAL-ROT-90", - "VID-FINAL-ROT-180", - "VID-FINAL-ROT-270" - }; - _len = strlcpy(replace_text, - rotation_replace_strings[retroarch_get_rotation()], - sizeof(replace_text)); - } + _len = strlcpy(replace_text, "VID-FINAL-ROT-", sizeof(replace_text)); + _len += snprintf( + replace_text + _len, + sizeof(replace_text) - _len, + "%d", + retroarch_get_rotation() * 90); break; case RARCH_WILDCARD_SCREEN_ORIENTATION: - { - char rotation_replace_strings[4][24] = { - "SCREEN-ORIENT-0", - "SCREEN-ORIENT-90", - "SCREEN-ORIENT-180", - "SCREEN-ORIENT-270" - }; - _len = strlcpy(replace_text, - rotation_replace_strings[config_get_ptr()->uints.screen_orientation], - sizeof(replace_text)); - } + _len = strlcpy(replace_text, "SCREEN-ORIENT-", sizeof(replace_text)); + _len += snprintf( + replace_text + _len, + sizeof(replace_text) - _len, + "%d", + config_get_ptr()->uints.screen_orientation * 90); break; case RARCH_WILDCARD_CORE_ASPECT_ORIENTATION: { From 9da7af46c39a0b8fc2ccc11a762718c7fbe47b1c Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Wed, 15 Jan 2025 16:04:25 +0100 Subject: [PATCH 16/49] len variable/argument name standardization --- gfx/common/d3dcompiler_common.c | 10 +-- gfx/common/d3dcompiler_common.h | 2 +- input/drivers_hid/wiiu_hid.c | 28 +++---- libretro-common/formats/json/rjson.c | 4 +- libretro-common/include/formats/rjson.h | 2 +- libretro-common/streams/stdin_stream.c | 26 ++---- libretro-common/streams/trans_stream.c | 8 +- save.c | 8 +- state_manager.c | 32 ++++---- tasks/task_save.c | 105 +++++++++++------------- verbosity.c | 18 ++-- verbosity.h | 2 +- 12 files changed, 113 insertions(+), 132 deletions(-) diff --git a/gfx/common/d3dcompiler_common.c b/gfx/common/d3dcompiler_common.c index 8ea35ad30354..1adbe3a15d1b 100644 --- a/gfx/common/d3dcompiler_common.c +++ b/gfx/common/d3dcompiler_common.c @@ -115,7 +115,7 @@ HRESULT WINAPI } #endif -bool d3d_compile(const char* src, size_t size, +bool d3d_compile(const char* src, size_t len, LPCSTR src_name, LPCSTR entrypoint, LPCSTR target, D3DBlob* out) { D3DBlob error_msg; @@ -125,18 +125,18 @@ bool d3d_compile(const char* src, size_t size, UINT compileflags = 0; #endif - if (!size) - size = strlen(src); + if (!len) + len = strlen(src); if (FAILED(D3DCompile( - src, size, src_name, NULL, NULL, + src, len, src_name, NULL, NULL, entrypoint, target, compileflags, 0, out, &error_msg))) { if (error_msg) { const char* msg = (const char*)error_msg->lpVtbl->GetBufferPointer(error_msg); RARCH_ERR("D3DCompile failed :\n%s\n", msg); - /* Place a breakpoint here, if you want, + /* Place a breakpoint here, if you want, to see shader compilation issues */ Release(error_msg); } diff --git a/gfx/common/d3dcompiler_common.h b/gfx/common/d3dcompiler_common.h index 292cf13fe6ac..3c4c4ba758e4 100644 --- a/gfx/common/d3dcompiler_common.h +++ b/gfx/common/d3dcompiler_common.h @@ -24,7 +24,7 @@ typedef ID3DBlob* D3DBlob; -bool d3d_compile(const char* src, size_t size, +bool d3d_compile(const char* src, size_t len, LPCSTR src_name, LPCSTR entrypoint, LPCSTR target, D3DBlob* out); bool d3d_compile_from_file(LPCWSTR filename, LPCSTR entrypoint, LPCSTR target, D3DBlob* out); diff --git a/input/drivers_hid/wiiu_hid.c b/input/drivers_hid/wiiu_hid.c index 285bcb9e0a47..821863244170 100644 --- a/input/drivers_hid/wiiu_hid.c +++ b/input/drivers_hid/wiiu_hid.c @@ -170,11 +170,11 @@ static int16_t wiiu_hid_joypad_state( const uint32_t joyaxis = (binds[i].joyaxis != AXIS_NONE) ? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis; if ( - (uint16_t)joykey != NO_BTN + (uint16_t)joykey != NO_BTN && pad->iface->button && pad->iface->button(pad->connection, (uint16_t)joykey)) ret |= ( 1 << i); else if (joyaxis != AXIS_NONE && pad->iface->get_axis && - ((float)abs(pad->iface->get_axis(pad->connection, joyaxis)) + ((float)abs(pad->iface->get_axis(pad->connection, joyaxis)) / 0x8000) > joypad_info->axis_threshold) ret |= (1 << i); } @@ -194,12 +194,11 @@ static bool wiiu_hid_joypad_rumble(void *data, unsigned slot, return false; } -static void *wiiu_hid_alloc_zeroed(size_t alignment, size_t size) +static void *wiiu_hid_alloc_zeroed(size_t alignment, size_t len) { - void *result = memalign(alignment, size); + void *result = memalign(alignment, len); if (result) - memset(result, 0, size); - + memset(result, 0, len); return result; } @@ -663,7 +662,7 @@ static uint8_t wiiu_hid_try_init_driver(wiiu_adapter_t *adapter) adapter->device_name); adapter->pad_driver = entry->iface; - + if (entry->iface->multi_pad) return wiiu_hid_try_init_driver_multi(adapter, entry); @@ -749,7 +748,7 @@ static void wiiu_hid_poll(void *data) synchronized_process_adapters(hid); } -static void wiiu_hid_send_control(void *data, uint8_t *buf, size_t size) +static void wiiu_hid_send_control(void *data, uint8_t *buf, size_t len) { wiiu_adapter_t *adapter = (wiiu_adapter_t *)data; int32_t result; @@ -761,7 +760,7 @@ static void wiiu_hid_send_control(void *data, uint8_t *buf, size_t size) } memset(adapter->tx_buffer, 0, adapter->tx_size); - memcpy(adapter->tx_buffer, buf, size); + memcpy(adapter->tx_buffer, buf, len); /* From testing, HIDWrite returns an error that looks like it's two * int16_t's bitmasked together. For example, one error I saw when trying @@ -848,24 +847,19 @@ static int32_t wiiu_hid_set_protocol(void *data, uint8_t protocol) NULL, NULL); } -static int32_t wiiu_hid_read(void *data, void *buffer, size_t size) +static int32_t wiiu_hid_read(void *data, void *buffer, size_t len) { wiiu_adapter_t *adapter = (wiiu_adapter_t *)data; int32_t result; - if (!adapter) return -1; - - if (size > adapter->rx_size) + if (len > adapter->rx_size) return -1; - - if ((result = HIDRead(adapter->handle, buffer, size, NULL, NULL)) < 0) + if ((result = HIDRead(adapter->handle, buffer, len, NULL, NULL)) < 0) wiiu_hid_report_hid_error("read failed", adapter, result); - return result; } - static void wiiu_hid_init_cachealigned_buffer(int32_t min_size, uint8_t **out_buf_ptr, int32_t *actual_size) { *actual_size = (min_size + 0x3f) & ~0x3f; diff --git a/libretro-common/formats/json/rjson.c b/libretro-common/formats/json/rjson.c index 9c79569bf4dd..3f99178984e3 100644 --- a/libretro-common/formats/json/rjson.c +++ b/libretro-common/formats/json/rjson.c @@ -930,14 +930,14 @@ static int _rjson_buffer_io(void* buf, int len, void *user) return len; } -rjson_t *rjson_open_buffer(const void *buffer, size_t size) +rjson_t *rjson_open_buffer(const void *buffer, size_t len) { rjson_t *json = (rjson_t *)malloc(sizeof(rjson_t) + sizeof(const char *)*2); const char **ud = (const char **)(json + 1); if (!json) return NULL; ud[0] = (const char *)buffer; - ud[1] = ud[0] + size; + ud[1] = ud[0] + len; _rjson_setup(json, _rjson_buffer_io, (void*)ud, sizeof(json->input_buf)); return json; } diff --git a/libretro-common/include/formats/rjson.h b/libretro-common/include/formats/rjson.h index 53623dd17e70..3101955b2c47 100644 --- a/libretro-common/include/formats/rjson.h +++ b/libretro-common/include/formats/rjson.h @@ -67,7 +67,7 @@ struct RFILE; /* Create a new parser instance from various sources */ rjson_t *rjson_open_stream(struct intfstream_internal *stream); rjson_t *rjson_open_rfile(struct RFILE *rfile); -rjson_t *rjson_open_buffer(const void *buffer, size_t size); +rjson_t *rjson_open_buffer(const void *buffer, size_t len); rjson_t *rjson_open_string(const char *string, size_t len); rjson_t *rjson_open_user(rjson_io_t io, void *user_data, int io_block_size); diff --git a/libretro-common/streams/stdin_stream.c b/libretro-common/streams/stdin_stream.c index 80f6e9abd5ac..a0800915fc5b 100644 --- a/libretro-common/streams/stdin_stream.c +++ b/libretro-common/streams/stdin_stream.c @@ -39,13 +39,9 @@ #include #if (defined(_WIN32) && defined(_XBOX)) || defined(__WINRT__) || !defined(__PSL1GHT__) && defined(__PS3__) -size_t read_stdin(char *buf, size_t size) -{ - /* Not implemented. */ - return 0; -} +size_t read_stdin(char *buf, size_t len) { return 0; } /* not implemented */ #elif defined(_WIN32) -size_t read_stdin(char *buf, size_t size) +size_t read_stdin(char *buf, size_t len) { DWORD i; DWORD has_read = 0; @@ -90,7 +86,7 @@ size_t read_stdin(char *buf, size_t size) { has_key = true; echo = true; - avail = size; + avail = len; break; } } @@ -105,8 +101,8 @@ size_t read_stdin(char *buf, size_t size) if (!avail) return 0; - if (avail > size) - avail = size; + if (avail > len) + avail = len; if (!ReadFile(hnd, buf, avail, &has_read, NULL)) return 0; @@ -130,22 +126,18 @@ size_t read_stdin(char *buf, size_t size) return has_read; } #else -size_t read_stdin(char *buf, size_t size) +size_t read_stdin(char *buf, size_t len) { size_t has_read = 0; - - while (size) + while (len) { - ssize_t ret = read(STDIN_FILENO, buf, size); - + ssize_t ret = read(STDIN_FILENO, buf, len); if (ret <= 0) break; - buf += ret; has_read += ret; - size -= ret; + len -= ret; } - return has_read; } #endif diff --git a/libretro-common/streams/trans_stream.c b/libretro-common/streams/trans_stream.c index aecb457b66d1..41132565ce7d 100644 --- a/libretro-common/streams/trans_stream.c +++ b/libretro-common/streams/trans_stream.c @@ -28,8 +28,8 @@ * for the new stream data to be saved * @in : input data * @in_size : input size - * @out : output data - * @out_size : output size + * @s : output data + * @len : output size * @error : (optional) output for error code * * Perform a full transcoding from a source to a destination. @@ -37,7 +37,7 @@ bool trans_stream_trans_full( struct trans_stream_backend *backend, void **data, const uint8_t *in, uint32_t in_size, - uint8_t *out, uint32_t out_size, + uint8_t *s, uint32_t len, enum trans_stream_error *error) { void *rdata; @@ -57,7 +57,7 @@ bool trans_stream_trans_full( } backend->set_in(rdata, in, in_size); - backend->set_out(rdata, out, out_size); + backend->set_out(rdata, s, len); ret = backend->trans(rdata, true, &rd, &wn, error); if (data) diff --git a/save.c b/save.c index d79a494ea593..41e10084fe6c 100644 --- a/save.c +++ b/save.c @@ -152,7 +152,7 @@ static void autosave_thread(void *data) * autosave_new: * @path : path to autosave file * @data : pointer to buffer - * @size : size of @data buffer + * @len : size of @data buffer * @interval : interval at which saves should be performed. * * Create and initialize autosave object. @@ -161,7 +161,7 @@ static void autosave_thread(void *data) * NULL. **/ static autosave_t *autosave_new(const char *path, - const void *data, size_t size, + const void *data, size_t len, unsigned interval, bool compress) { void *buf = NULL; @@ -170,14 +170,14 @@ static autosave_t *autosave_new(const char *path, return NULL; handle->flags = 0; - handle->bufsize = size; + handle->bufsize = len; handle->interval = interval; if (compress) handle->flags |= AUTOSAVE_FLAG_COMPRESS_FILES; handle->retro_buffer = data; handle->path = path; - if (!(buf = malloc(size))) + if (!(buf = malloc(len))) { free(handle); return NULL; diff --git a/state_manager.c b/state_manager.c index 9fb25a9993f6..8b16fa8bc12c 100644 --- a/state_manager.c +++ b/state_manager.c @@ -205,8 +205,8 @@ static size_t state_manager_raw_maxsize(size_t uncomp) */ static void *state_manager_raw_alloc(size_t len, uint16_t uniq) { - size_t len16 = (len + sizeof(uint16_t) - 1) & -sizeof(uint16_t); - uint16_t *ret = (uint16_t*)calloc(len16 + sizeof(uint16_t) * 4 + 16, 1); + size_t _len = (len + sizeof(uint16_t) - 1) & -sizeof(uint16_t); + uint16_t *ret = (uint16_t*)calloc(_len + sizeof(uint16_t) * 4 + 16, 1); if (!ret) return NULL; @@ -222,7 +222,7 @@ static void *state_manager_raw_alloc(size_t len, uint16_t uniq) * * It doesn't make any difference to us, but sacrificing 16 bytes to get * Valgrind happy is worth it. */ - ret[len16/sizeof(uint16_t) + 3] = uniq; + ret[_len / sizeof(uint16_t) + 3] = uniq; return ret; } @@ -270,7 +270,7 @@ static size_t state_manager_raw_compress(const void *src, continue; } - changed = find_same(old16, new16); + changed = find_same(old16, new16); if (changed > UINT16_MAX) changed = UINT16_MAX; @@ -301,8 +301,7 @@ static size_t state_manager_raw_compress(const void *src, * If the given arguments do not match a previous call to * state_manager_raw_compress(), anything at all can happen. */ -static void state_manager_raw_decompress(const void *patch, - size_t patchlen, void *data, size_t datalen) +static void state_manager_raw_decompress(const void *patch, void *data) { uint16_t *out16 = (uint16_t*)data; const uint16_t *patch16 = (const uint16_t*)patch; @@ -473,8 +472,7 @@ static bool state_manager_pop(state_manager_t *state, const void **data) compressed = state->data + start + sizeof(size_t); out = state->thisblock; - state_manager_raw_decompress(compressed, - state->maxcompsize, out, state->blocksize); + state_manager_raw_decompress(compressed, out); state->entries--; return true; @@ -512,8 +510,8 @@ static void state_manager_push_do(state_manager_t *state) if (state->thisblock_valid) { - const uint8_t *oldb, *newb; uint8_t *compressed; + const uint8_t *oldb, *newb; size_t headpos, tailpos, remaining; if (state->capacity < sizeof(size_t) + state->maxcompsize) { RARCH_ERR("State capacity insufficient\n"); @@ -666,14 +664,14 @@ void state_manager_event_deinit( free(rewind_st->state); } - rewind_st->state = NULL; - rewind_st->size = 0; - rewind_st->flags &= ~( - STATE_MGR_REWIND_ST_FLAG_FRAME_IS_REVERSED - | STATE_MGR_REWIND_ST_FLAG_HOTKEY_WAS_CHECKED - | STATE_MGR_REWIND_ST_FLAG_HOTKEY_WAS_PRESSED - | STATE_MGR_REWIND_ST_FLAG_INIT_ATTEMPTED - ); + rewind_st->state = NULL; + rewind_st->size = 0; + rewind_st->flags &= ~( + STATE_MGR_REWIND_ST_FLAG_FRAME_IS_REVERSED + | STATE_MGR_REWIND_ST_FLAG_HOTKEY_WAS_CHECKED + | STATE_MGR_REWIND_ST_FLAG_HOTKEY_WAS_PRESSED + | STATE_MGR_REWIND_ST_FLAG_INIT_ATTEMPTED + ); /* Restore regular (non-rewind) core audio * callbacks if required */ diff --git a/tasks/task_save.c b/tasks/task_save.c index 72f38a901482..d078a9b261dc 100644 --- a/tasks/task_save.c +++ b/tasks/task_save.c @@ -371,19 +371,20 @@ size_t content_get_serialized_size(void) rastate_size_info_t size; return content_get_rastate_size(&size, false); } + size_t content_get_serialized_size_rewind(void) { rastate_size_info_t size; return content_get_rastate_size(&size, true); } -static void content_write_block_header(unsigned char* output, const char* header, size_t size) +static void content_write_block_header(unsigned char* output, const char* header, size_t len) { memcpy(output, header, 4); - output[4] = ((size) & 0xFF); - output[5] = ((size >> 8) & 0xFF); - output[6] = ((size >> 16) & 0xFF); - output[7] = ((size >> 24) & 0xFF); + output[4] = ((len) & 0xFF); + output[5] = ((len >> 8) & 0xFF); + output[6] = ((len >> 16) & 0xFF); + output[7] = ((len >> 24) & 0xFF); } static bool content_write_serialized_state(void* buffer, @@ -523,9 +524,9 @@ static void task_save_handler(retro_task_t *task) if (!state->data) { - size_t size = 0; - state->data = content_get_serialized_data(&size); - state->size = (ssize_t)size; + size_t _len = 0; + state->data = content_get_serialized_data(&_len); + state->size = (ssize_t)_len; } remaining = MIN(state->size - state->written, SAVE_STATE_CHUNK); @@ -608,7 +609,7 @@ static void task_save_handler(retro_task_t *task) * * Create a new task to undo the last save of the content state. **/ -static bool task_push_undo_save_state(const char *path, void *data, size_t size) +static bool task_push_undo_save_state(const char *path, void *data, size_t len) { settings_t *settings; retro_task_t *task = task_init(); @@ -623,7 +624,7 @@ static bool task_push_undo_save_state(const char *path, void *data, size_t size) strlcpy(state->path, path, sizeof(state->path)); state->data = data; - state->size = size; + state->size = len; state->flags |= SAVE_TASK_FLAG_UNDO_SAVE; state->state_slot = settings->ints.state_slot; if (video_st->frame_cache_data && (video_st->frame_cache_data == RETRO_HW_FRAME_BUFFER_VALID)) @@ -829,9 +830,9 @@ static void task_load_handler(retro_task_t *task) task_load_handler_finished(task, state); } -static bool content_load_rastate1(unsigned char* input, size_t size) +static bool content_load_rastate1(unsigned char* input, size_t len) { - unsigned char *stop = input + size; + unsigned char *stop = input + len; bool seen_core = false; #ifdef HAVE_CHEEVOS bool seen_cheevos = false; @@ -934,18 +935,16 @@ static bool content_load_rastate1(unsigned char* input, size_t size) return true; } -bool content_deserialize_state( - const void* serialized_data, size_t serialized_size) +bool content_deserialize_state(const void *s, size_t len) { - if (memcmp(serialized_data, "RASTATE", 7) != 0) + if (memcmp(s, "RASTATE", 7) != 0) { /* old format is just core data, load it directly */ retro_ctx_serialize_info_t serial_info; - serial_info.data_const = serialized_data; - serial_info.size = serialized_size; + serial_info.data_const = s; + serial_info.size = len; if (!core_unserialize(&serial_info)) return false; - #ifdef HAVE_CHEEVOS rcheevos_set_serialized_data(NULL); #endif @@ -963,18 +962,17 @@ bool content_deserialize_state( } else { - unsigned char* input = (unsigned char*)serialized_data; + unsigned char* input = (unsigned char*)s; switch (input[7]) /* version */ { case 1: - if (content_load_rastate1(input, serialized_size)) + if (content_load_rastate1(input, len)) break; /* fall-through intentional */ default: return false; } } - return true; } @@ -1158,7 +1156,7 @@ static void save_state_cb(retro_task_t *task, * * Create a new task to save the content state. **/ -static void task_push_save_state(const char *path, void *data, size_t size, bool autosave) +static void task_push_save_state(const char *path, void *data, size_t len, bool autosave) { settings_t *settings = config_get_ptr(); retro_task_t *task = task_init(); @@ -1170,11 +1168,11 @@ static void task_push_save_state(const char *path, void *data, size_t size, bool strlcpy(state->path, path, sizeof(state->path)); state->data = data; - state->size = size; + state->size = len; /* Don't show OSD messages if we are auto-saving */ if (autosave) - state->flags |= (SAVE_TASK_FLAG_AUTOSAVE | - SAVE_TASK_FLAG_MUTE); + state->flags |= ( SAVE_TASK_FLAG_AUTOSAVE + | SAVE_TASK_FLAG_MUTE); if (settings->bools.savestate_thumbnail_enable) { /* Delay OSD messages and widgets for a few frames @@ -1264,7 +1262,7 @@ static void content_load_and_save_state_cb(retro_task_t *task, * and then save the content state. **/ static void task_push_load_and_save_state(const char *path, void *data, - size_t size, bool load_to_backup_buffer, bool autosave) + size_t len, bool load_to_backup_buffer, bool autosave) { retro_task_t *task = NULL; settings_t *settings = config_get_ptr(); @@ -1285,7 +1283,7 @@ static void task_push_load_and_save_state(const char *path, void *data, strlcpy(state->path, path, sizeof(state->path)); if (load_to_backup_buffer) state->flags |= SAVE_TASK_FLAG_LOAD_TO_BACKUP_BUFF; - state->undo_size = size; + state->undo_size = len; state->undo_data = data; /* Don't show OSD messages if we are auto-saving */ if (autosave) @@ -1337,9 +1335,9 @@ static void task_push_load_and_save_state(const char *path, void *data, **/ bool content_auto_save_state(const char *path) { + size_t _len; settings_t *settings = config_get_ptr(); void *serial_data = NULL; - size_t serial_size; intfstream_t *file = NULL; if (!core_info_current_supports_savestate()) @@ -1349,12 +1347,11 @@ bool content_auto_save_state(const char *path) return false; } - serial_size = core_serialize_size(); - - if (serial_size == 0) + _len = core_serialize_size(); + if (_len == 0) return false; - serial_data = content_get_serialized_data(&serial_size); + serial_data = content_get_serialized_data(&_len); if (!serial_data) return false; @@ -1372,7 +1369,7 @@ bool content_auto_save_state(const char *path) return false; } - if (serial_size != (size_t)intfstream_write(file, serial_data, serial_size)) + if (_len != (size_t)intfstream_write(file, serial_data, _len)) { intfstream_close(file); free(serial_data); @@ -1395,7 +1392,6 @@ bool content_auto_save_state(const char *path) take_screenshot(dir_screenshot, path, true, validfb, false, false); } #endif - return true; } @@ -1410,7 +1406,7 @@ bool content_auto_save_state(const char *path) **/ bool content_save_state(const char *path, bool save_to_disk) { - size_t serial_size; + size_t _len; void *data = NULL; if (!core_info_current_supports_savestate()) @@ -1420,14 +1416,13 @@ bool content_save_state(const char *path, bool save_to_disk) return false; } - serial_size = core_serialize_size(); - - if (serial_size == 0) + _len = core_serialize_size(); + if (_len == 0) return false; if (!save_state_in_background) { - if (!(data = content_get_serialized_data(&serial_size))) + if (!(data = content_get_serialized_data(&_len))) { RARCH_ERR("[State]: %s \"%s\".\n", msg_hash_to_str(MSG_FAILED_TO_SAVE_STATE_TO), @@ -1438,7 +1433,7 @@ bool content_save_state(const char *path, bool save_to_disk) RARCH_LOG("[State]: %s \"%s\", %u %s.\n", msg_hash_to_str(MSG_SAVING_STATE), path, - (unsigned)serial_size, + (unsigned)_len, msg_hash_to_str(MSG_BYTES)); } @@ -1451,16 +1446,16 @@ bool content_save_state(const char *path, bool save_to_disk) /* TODO/FIXME - Use msg_hash_to_str here */ RARCH_LOG("[State]: %s ...\n", msg_hash_to_str(MSG_FILE_ALREADY_EXISTS_SAVING_TO_BACKUP_BUFFER)); - task_push_load_and_save_state(path, data, serial_size, true, false); + task_push_load_and_save_state(path, data, _len, true, false); } else - task_push_save_state(path, data, serial_size, false); + task_push_save_state(path, data, _len, false); } else { if (!data) { - if (!(data = content_get_serialized_data(&serial_size))) + if (!(data = content_get_serialized_data(&_len))) { RARCH_ERR("[State]: %s \"%s\".\n", msg_hash_to_str(MSG_FAILED_TO_SAVE_STATE_TO), @@ -1479,15 +1474,15 @@ bool content_save_state(const char *path, bool save_to_disk) undo_load_buf.data = NULL; } - if (!(undo_load_buf.data = malloc(serial_size))) + if (!(undo_load_buf.data = malloc(_len))) { free(data); return false; } - memcpy(undo_load_buf.data, data, serial_size); + memcpy(undo_load_buf.data, data, _len); free(data); - undo_load_buf.size = serial_size; + undo_load_buf.size = _len; strlcpy(undo_load_buf.path, path, sizeof(undo_load_buf.path)); } @@ -1735,8 +1730,8 @@ bool content_load_state_from_ram(void) **/ bool content_save_state_to_ram(void) { + size_t _len; void *data = NULL; - size_t serial_size; if (!core_info_current_supports_savestate()) { @@ -1745,14 +1740,14 @@ bool content_save_state_to_ram(void) return false; } - serial_size = core_serialize_size(); + _len = core_serialize_size(); - if (serial_size == 0) + if (_len == 0) return false; if (!save_state_in_background) { - if (!(data = content_get_serialized_data(&serial_size))) + if (!(data = content_get_serialized_data(&_len))) { RARCH_ERR("[State]: %s.\n", msg_hash_to_str(MSG_FAILED_TO_SAVE_SRAM)); @@ -1761,13 +1756,13 @@ bool content_save_state_to_ram(void) RARCH_LOG("[State]: %s, %u %s.\n", msg_hash_to_str(MSG_SAVING_STATE), - (unsigned)serial_size, + (unsigned)_len, msg_hash_to_str(MSG_BYTES)); } if (!data) { - if (!(data = content_get_serialized_data(&serial_size))) + if (!(data = content_get_serialized_data(&_len))) { RARCH_ERR("[State]: %s.\n", msg_hash_to_str(MSG_FAILED_TO_SAVE_SRAM)); @@ -1782,15 +1777,15 @@ bool content_save_state_to_ram(void) ram_buf.state_buf.data = NULL; } - if (!(ram_buf.state_buf.data = malloc(serial_size))) + if (!(ram_buf.state_buf.data = malloc(_len))) { free(data); return false; } - memcpy(ram_buf.state_buf.data, data, serial_size); + memcpy(ram_buf.state_buf.data, data, _len); free(data); - ram_buf.state_buf.size = serial_size; + ram_buf.state_buf.size = _len; ram_buf.to_write_file = true; return true; diff --git a/verbosity.c b/verbosity.c index da8a34308b11..d785e88e1529 100644 --- a/verbosity.c +++ b/verbosity.c @@ -331,15 +331,15 @@ void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap) #endif } -void RARCH_LOG_BUFFER(uint8_t *data, size_t size) +void RARCH_LOG_BUFFER(uint8_t *data, size_t len) { unsigned i, offset; - int padding = size % 16; + int padding = len % 16; uint8_t buf[16] = {0}; - RARCH_LOG("== %d-byte buffer ==================\n", (int)size); + RARCH_LOG("== %d-byte buffer ==================\n", (int)len); - for (i = 0, offset = 0; i < size; i++) + for (i = 0, offset = 0; i < len; i++) { buf[offset] = data[i]; offset++; @@ -468,7 +468,9 @@ void rarch_log_file_init( time_t cur_time = time(NULL); rtime_localtime(&cur_time, &tm_); - strftime(timestamped_log_file_name, sizeof(timestamped_log_file_name), "retroarch__%Y_%m_%d__%H_%M_%S.log", &tm_); + strftime(timestamped_log_file_name, + sizeof(timestamped_log_file_name), + "retroarch__%Y_%m_%d__%H_%M_%S.log", &tm_); } /* If nothing has changed, do nothing */ @@ -506,10 +508,10 @@ void rarch_log_file_init( if (last_slash) { char tmp_buf[PATH_MAX_LENGTH] = {0}; - size_t path_length = last_slash + 1 - override_path; + size_t _len = last_slash + 1 - override_path; - if ((path_length > 1) && (path_length < PATH_MAX_LENGTH)) - strlcpy(tmp_buf, override_path, path_length * sizeof(char)); + if ((_len > 1) && (_len < PATH_MAX_LENGTH)) + strlcpy(tmp_buf, override_path, _len * sizeof(char)); strlcpy(log_directory, tmp_buf, sizeof(log_directory)); } diff --git a/verbosity.h b/verbosity.h index 808e0fa5702b..d44748096fa3 100644 --- a/verbosity.h +++ b/verbosity.h @@ -227,7 +227,7 @@ void logger_send_v(const char *__format, va_list args); void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap); void RARCH_DBG(const char *fmt, ...); void RARCH_LOG(const char *fmt, ...); -void RARCH_LOG_BUFFER(uint8_t *buffer, size_t size); +void RARCH_LOG_BUFFER(uint8_t *buffer, size_t len); void RARCH_LOG_OUTPUT(const char *msg, ...); void RARCH_WARN(const char *fmt, ...); void RARCH_ERR(const char *fmt, ...); From b2072dd3bea580bd04450a2726361fe361e4042a Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Wed, 15 Jan 2025 16:36:49 +0100 Subject: [PATCH 17/49] Use strldup where possible, avoid strcpy_literal --- libretro-common/media/media_detect_cd.c | 40 +++++++------------------ libretro-db/query.c | 19 +++++------- runahead.c | 18 ++--------- 3 files changed, 20 insertions(+), 57 deletions(-) diff --git a/libretro-common/media/media_detect_cd.c b/libretro-common/media/media_detect_cd.c index 68831c4b3209..dd0cf1fb8c15 100644 --- a/libretro-common/media/media_detect_cd.c +++ b/libretro-common/media/media_detect_cd.c @@ -328,7 +328,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ * but I have not seen any real examples of them. */ info->system_id = MEDIA_CD_SYSTEM_MEGA_CD; - strcpy_literal(info->system, "Sega CD / Mega CD"); + strlcpy(info->system, "Sega CD / Mega CD", sizeof(info->system)); title_pos = buf + offset + 0x150; @@ -338,12 +338,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ media_zero_trailing_spaces(info->title, sizeof(info->title)); } else - { - info->title[0] = 'N'; - info->title[1] = '/'; - info->title[2] = 'A'; - info->title[3] = '\0'; - } + strlcpy(info->title, "N/A", sizeof(info->title)); serial_pos = buf + offset + 0x183; @@ -370,7 +365,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ info->system_id = MEDIA_CD_SYSTEM_SATURN; - strcpy_literal(info->system, "Sega Saturn"); + strlcpy(info->system, "Sega Saturn", sizeof(info->system)); title_pos = buf + offset + 0x60; @@ -380,12 +375,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ media_zero_trailing_spaces(info->title, sizeof(info->title)); } else - { - info->title [0] = 'N'; - info->title [1] = '/'; - info->title [2] = 'A'; - info->title [3] = '\0'; - } + strlcpy(info->title, "N/A", sizeof(info->title)); serial_pos = buf + offset + 0x20; @@ -441,7 +431,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ info->system_id = MEDIA_CD_SYSTEM_DREAMCAST; - strcpy_literal(info->system, "Sega Dreamcast"); + strlcpy(info->system, "Sega Dreamcast", sizeof(info->system)); title_pos = buf + offset + 0x80; @@ -451,12 +441,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ media_zero_trailing_spaces(info->title, sizeof(info->title)); } else - { - info->title [0] = 'N'; - info->title [1] = '/'; - info->title [2] = 'A'; - info->title [3] = '\0'; - } + strlcpy(info->title, "N/A", sizeof(info->title)); serial_pos = buf + offset + 0x40; @@ -510,7 +495,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ info->system_id = MEDIA_CD_SYSTEM_PSX; - strcpy_literal(info->system, "Sony PlayStation"); + strlcpy(info->system, "Sony PlayStation", sizeof(info->system)); title_pos = buf + offset + (16 * sector_size) + 40; @@ -520,22 +505,17 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ media_zero_trailing_spaces(info->title, sizeof(info->title)); } else - { - info->title [0] = 'N'; - info->title [1] = '/'; - info->title [2] = 'A'; - info->title [3] = '\0'; - } + strlcpy(info->title, "N/A", sizeof(info->title)); } else if (!memcmp(buf + offset, "\x01\x5a\x5a\x5a\x5a\x5a\x01\x00\x00\x00\x00\x00", 12)) { info->system_id = MEDIA_CD_SYSTEM_3DO; - strcpy_literal(info->system, "3DO"); + strlcpy(info->system, "3DO", sizeof(info->system)); } else if (!memcmp(buf + offset + 0x950, "PC Engine CD-ROM SYSTEM", 23)) { info->system_id = MEDIA_CD_SYSTEM_PC_ENGINE_CD; - strcpy_literal(info->system, "TurboGrafx-CD / PC-Engine CD"); + strlcpy(info->system, "TurboGrafx-CD / PC-Engine CD", sizeof(info->system)); } free(buf); diff --git a/libretro-db/query.c b/libretro-db/query.c index 370d2b665c87..7fcf86bdf13d 100644 --- a/libretro-db/query.c +++ b/libretro-db/query.c @@ -272,15 +272,13 @@ static void query_raise_unknown_function( ssize_t where, const char *name, ssize_t len, const char **error) { - int n = snprintf(s, _len, + int __len = snprintf(s, _len, "%" PRIu64 "::Unknown function '", (uint64_t)where ); - - if (len < ((ssize_t)_len - n - 3)) - strncpy(s + n, name, len); - - strcpy_literal(s + n + len, "'"); + if (len < ((ssize_t)_len - __len - 3)) + strncpy(s + __len, name, len); + strcpy_literal(s + __len + len, "'"); *error = s; } @@ -671,8 +669,7 @@ static struct buffer query_parse_method_call( { if (argi >= QUERY_MAX_ARGS) { - strcpy_literal(s, - "Too many arguments in function call."); + strlcpy(s, "Too many arguments in function call.", len); *error = s; goto clean; } @@ -797,8 +794,7 @@ static struct buffer query_parse_table( { if (argi >= QUERY_MAX_ARGS) { - strcpy_literal(s, - "Too many arguments in function call."); + strlcpy(s, "Too many arguments in function call.", len); *error = s; goto clean; } @@ -846,8 +842,7 @@ static struct buffer query_parse_table( if (argi >= QUERY_MAX_ARGS) { - strcpy_literal(s, - "Too many arguments in function call."); + strlcpy(s, "Too many arguments in function call.", len); *error = s; goto clean; } diff --git a/runahead.c b/runahead.c index 2714aaf69844..12147a31455e 100644 --- a/runahead.c +++ b/runahead.c @@ -150,11 +150,7 @@ static void strcat_alloc(char **dst, const char *s) { size_t __len = strlen(s); if (__len != 0) - { - char *_dst= (char*)malloc(__len + 1); - strcpy_literal(_dst, s); - src = _dst; - } + src = strldup(s, __len); else src = NULL; } @@ -243,11 +239,7 @@ static char *get_tmpdir_alloc(const char *override_dir) { size_t _len = strlen(src); if (_len != 0) - { - char *dst = (char*)malloc(_len + 1); - strcpy_literal(dst, src); - path = dst; - } + path = strldup(src, _len); } else path = (char*)calloc(1,1); @@ -272,11 +264,7 @@ static bool write_file_with_random_name(char **temp_dll_path, { size_t _len = strlen(src); if (_len != 0) - { - char *dst = (char*)malloc(_len + 1); - strcpy_literal(dst, src); - ext = dst; - } + ext = strldup(src, _len); } else ext = (char*)calloc(1,1); From de3acd90175f423233f39733df2a6f7387d627a7 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Wed, 15 Jan 2025 18:28:14 +0100 Subject: [PATCH 18/49] (video_shader_parse.c) Go lighter on char stack usage, remove unnecessary wildcard token_size --- gfx/video_shader_parse.c | 115 +++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 59 deletions(-) diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 07aa57d35b22..b61f7ebbe3c1 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -83,26 +83,25 @@ enum wildcard_type struct wildcard_token { enum wildcard_type token_id; - char token_name[64]; - size_t token_size; + char token_name[32]; }; static struct wildcard_token wildcard_tokens[SHADER_NUM_WILDCARDS] = { - {RARCH_WILDCARD_CONTENT_DIR, "$CONTENT-DIR$", STRLEN_CONST("$CONTENT-DIR$")}, - {RARCH_WILDCARD_CORE, "$CORE$", STRLEN_CONST("$CORE$")}, - {RARCH_WILDCARD_GAME, "$GAME$", STRLEN_CONST("$GAME$")}, - {RARCH_WILDCARD_VIDEO_DRIVER, "$VID-DRV$", STRLEN_CONST("$VID-DRV$")}, - {RARCH_WILDCARD_VIDEO_DRIVER_PRESET_EXT, "$VID-DRV-PRESET-EXT$", STRLEN_CONST("$VID-DRV-PRESET-EXT$")}, - {RARCH_WILDCARD_VIDEO_DRIVER_SHADER_EXT, "$VID-DRV-SHADER-EXT$", STRLEN_CONST("$VID-DRV-SHADER-EXT$")}, - {RARCH_WILDCARD_CORE_REQUESTED_ROTATION, "$CORE-REQ-ROT$", STRLEN_CONST("$CORE-REQ-ROT$")}, - {RARCH_WILDCARD_VIDEO_ALLOW_CORE_ROTATION, "$VID-ALLOW-CORE-ROT$", STRLEN_CONST("$VID-ALLOW-CORE-ROT$")}, - {RARCH_WILDCARD_VIDEO_USER_ROTATION, "$VID-USER-ROT$", STRLEN_CONST("$VID-USER-ROT$")}, - {RARCH_WILDCARD_VIDEO_FINAL_ROTATION, "$VID-FINAL-ROT$", STRLEN_CONST("$VID-FINAL-ROT$")}, - {RARCH_WILDCARD_SCREEN_ORIENTATION, "$SCREEN-ORIENT$", STRLEN_CONST("$SCREEN-ORIENT$")}, - {RARCH_WILDCARD_VIEWPORT_ASPECT_ORIENTATION, "$VIEW-ASPECT-ORIENT$", STRLEN_CONST("$VIEW-ASPECT-ORIENT$")}, - {RARCH_WILDCARD_CORE_ASPECT_ORIENTATION, "$CORE-ASPECT-ORIENT$", STRLEN_CONST("$CORE-ASPECT-ORIENT$")}, - {RARCH_WILDCARD_PRESET_DIR, "$PRESET-DIR$", STRLEN_CONST("$PRESET-DIR$")}, - {RARCH_WILDCARD_PRESET, "$PRESET$", STRLEN_CONST("$PRESET$")}, + {RARCH_WILDCARD_CONTENT_DIR, "$CONTENT-DIR$"}, + {RARCH_WILDCARD_CORE, "$CORE$"}, + {RARCH_WILDCARD_GAME, "$GAME$"}, + {RARCH_WILDCARD_VIDEO_DRIVER, "$VID-DRV$"}, + {RARCH_WILDCARD_VIDEO_DRIVER_PRESET_EXT, "$VID-DRV-PRESET-EXT$"}, + {RARCH_WILDCARD_VIDEO_DRIVER_SHADER_EXT, "$VID-DRV-SHADER-EXT$"}, + {RARCH_WILDCARD_CORE_REQUESTED_ROTATION, "$CORE-REQ-ROT$"}, + {RARCH_WILDCARD_VIDEO_ALLOW_CORE_ROTATION, "$VID-ALLOW-CORE-ROT$"}, + {RARCH_WILDCARD_VIDEO_USER_ROTATION, "$VID-USER-ROT$"}, + {RARCH_WILDCARD_VIDEO_FINAL_ROTATION, "$VID-FINAL-ROT$"}, + {RARCH_WILDCARD_SCREEN_ORIENTATION, "$SCREEN-ORIENT$"}, + {RARCH_WILDCARD_VIEWPORT_ASPECT_ORIENTATION, "$VIEW-ASPECT-ORIENT$"}, + {RARCH_WILDCARD_CORE_ASPECT_ORIENTATION, "$CORE-ASPECT-ORIENT$"}, + {RARCH_WILDCARD_PRESET_DIR, "$PRESET-DIR$"}, + {RARCH_WILDCARD_PRESET, "$PRESET$"}, }; /* TODO/FIXME - global state - perhaps move outside this file */ @@ -334,8 +333,7 @@ static void video_shader_replace_wildcards(char *s, size_t len, char *in_preset_ const int requested_rotation = retroarch_get_core_requested_rotation(); _len = strlcpy(replace_text, (video_driver_get_core_aspect() < 1 || requested_rotation == 1 || requested_rotation == 3) - ? "CORE-ASPECT-ORIENT-VERT" - : "CORE-ASPECT-ORIENT-HORZ", + ? "CORE-ASPECT-ORIENT-VERT" : "CORE-ASPECT-ORIENT-HORZ", sizeof(replace_text)); } break; @@ -354,13 +352,17 @@ static void video_shader_replace_wildcards(char *s, size_t len, char *in_preset_ case RARCH_WILDCARD_PRESET_DIR: { char preset_dir_name[DIR_MAX_LENGTH]; - fill_pathname_parent_dir_name(preset_dir_name, in_preset_path, sizeof(preset_dir_name)); + fill_pathname_parent_dir_name(preset_dir_name, + in_preset_path, sizeof(preset_dir_name)); if (string_is_not_equal_fast(preset_dir_name, "", sizeof(""))) - strlcpy(preset_dir_name, path_basename_nocompression(preset_dir_name), sizeof(preset_dir_name)); + strlcpy(preset_dir_name, + path_basename_nocompression(preset_dir_name), + sizeof(preset_dir_name)); if (string_is_not_equal_fast(preset_dir_name, "", sizeof(""))) path_remove_extension(preset_dir_name); if (string_is_not_equal_fast(preset_dir_name, "", sizeof(""))) - _len = strlcpy(replace_text, preset_dir_name, sizeof(replace_text)); + _len = strlcpy(replace_text, + preset_dir_name, sizeof(replace_text)); else replace_text[0] = '\0'; } @@ -368,11 +370,14 @@ static void video_shader_replace_wildcards(char *s, size_t len, char *in_preset_ case RARCH_WILDCARD_PRESET: { char preset_name[NAME_MAX_LENGTH]; - strlcpy(preset_name, path_basename_nocompression(in_preset_path), sizeof(preset_name)); + strlcpy(preset_name, + path_basename_nocompression(in_preset_path), + sizeof(preset_name)); if (string_is_not_equal_fast(preset_name, "", sizeof(""))) path_remove_extension(preset_name); if (string_is_not_equal_fast(preset_name, "", sizeof(""))) - _len = strlcpy(replace_text, preset_name, sizeof(replace_text)); + _len = strlcpy(replace_text, + preset_name, sizeof(replace_text)); else replace_text[0] = '\0'; } @@ -417,12 +422,10 @@ static void video_shader_replace_wildcards(char *s, size_t len, char *in_preset_ char *replace_output = string_replace_substring(replaced_path, sizeof(replaced_path), wildcard_tokens[i].token_name, - wildcard_tokens[i].token_size, + STRLEN_CONST(wildcard_tokens[i].token_name), replace_text, _len); - strlcpy(replaced_path, replace_output, sizeof(replaced_path)); - free(replace_output); } } @@ -1168,6 +1171,18 @@ static bool video_shader_write_root_preset(const struct video_shader *shader, config_set_path(conf, key, tmp_rel); + _len = strlcpy(key, "alias", sizeof(key)); + strlcpy(key + _len, formatted_num, sizeof(key) - _len); + config_set_string(conf, key, pass->alias); + + _len = strlcpy(key, "wrap_mode", sizeof(key)); + strlcpy(key + _len, formatted_num, sizeof(key) - _len); + config_set_string(conf, key, video_shader_wrap_mode_to_str(pass->wrap)); + + _len = strlcpy(key, "mipmap_input", sizeof(key)); + strlcpy(key + _len, formatted_num, sizeof(key) - _len); + config_set_string(conf, key, pass->mipmap ? "true" : "false"); + if (pass->filter != RARCH_FILTER_UNSPEC) { _len = strlcpy(key, "filter_linear", sizeof(key)); @@ -1178,10 +1193,6 @@ static bool video_shader_write_root_preset(const struct video_shader *shader, : "false"); } - _len = strlcpy(key, "wrap_mode", sizeof(key)); - strlcpy(key + _len, formatted_num, sizeof(key) - _len); - config_set_string(conf, key, video_shader_wrap_mode_to_str(pass->wrap)); - if (pass->frame_count_mod) { _len = strlcpy(key, "frame_count_mod", sizeof(key)); @@ -1189,14 +1200,6 @@ static bool video_shader_write_root_preset(const struct video_shader *shader, config_set_int(conf, key, pass->frame_count_mod); } - _len = strlcpy(key, "mipmap_input", sizeof(key)); - strlcpy(key + _len, formatted_num, sizeof(key) - _len); - config_set_string(conf, key, pass->mipmap ? "true" : "false"); - - _len = strlcpy(key, "alias", sizeof(key)); - strlcpy(key + _len, formatted_num, sizeof(key) - _len); - config_set_string(conf, key, pass->alias); - video_shader_write_fbo(conf, formatted_num, &pass->fbo); } @@ -1224,16 +1227,24 @@ static bool video_shader_write_root_preset(const struct video_shader *shader, /* Step through the textures in the shader */ for (i = 0; i < shader->luts; i++) { + size_t _len; + char k[128]; fill_pathname_abbreviated_or_relative(tmp_rel, tmp_base, shader->lut[i].path, PATH_MAX_LENGTH); pathname_make_slashes_portable(tmp_rel); config_set_string(conf, shader->lut[i].id, tmp_rel); + _len = strlcpy(k, shader->lut[i].id, sizeof(k)); + + /* Mipmap On or Off */ + strlcpy(k + _len, "_mipmap", sizeof(k) - _len); + config_set_string(conf, k, shader->lut[i].mipmap + ? "true" + : "false"); + /* Linear filter ON or OFF */ if (shader->lut[i].filter != RARCH_FILTER_UNSPEC) { - char k[128]; - size_t _len = strlcpy(k, shader->lut[i].id, sizeof(k)); strlcpy(k + _len, "_linear", sizeof(k) - _len); config_set_string(conf, k, (shader->lut[i].filter == RARCH_FILTER_LINEAR) @@ -1242,23 +1253,9 @@ static bool video_shader_write_root_preset(const struct video_shader *shader, } /* Wrap Mode */ - { - char k[128]; - size_t _len = strlcpy(k, shader->lut[i].id, sizeof(k)); - strlcpy(k + _len, "_wrap_mode", sizeof(k) - _len); - config_set_string(conf, k, - video_shader_wrap_mode_to_str(shader->lut[i].wrap)); - } - - /* Mipmap On or Off */ - { - char k[128]; - size_t _len = strlcpy(k, shader->lut[i].id, sizeof(k)); - strlcpy(k + _len, "_mipmap", sizeof(k) - _len); - config_set_string(conf, k, shader->lut[i].mipmap - ? "true" - : "false"); - } + strlcpy(k + _len, "_wrap_mode", sizeof(k) - _len); + config_set_string(conf, k, + video_shader_wrap_mode_to_str(shader->lut[i].wrap)); } } @@ -1422,7 +1419,7 @@ static bool video_shader_check_reference_chain_for_save( break; } - ref_depth += 1; + ref_depth++; } free(path_to_save_conformed); From e0f09f609fdc9c8d5be8d4ac69e068d2c5d42755 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Wed, 15 Jan 2025 18:30:11 +0100 Subject: [PATCH 19/49] (video_shader_parse.c) token_name char size can be further reduced to 24 --- gfx/video_shader_parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index b61f7ebbe3c1..2861d0e2ab64 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -83,7 +83,7 @@ enum wildcard_type struct wildcard_token { enum wildcard_type token_id; - char token_name[32]; + char token_name[24]; }; static struct wildcard_token wildcard_tokens[SHADER_NUM_WILDCARDS] = { From a5c9d9520f7e1d90e97181412119181f6369b5e6 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Wed, 15 Jan 2025 22:17:59 +0100 Subject: [PATCH 20/49] * Use fill_pathname_basedir where possible * Move static variable to only function where it's used * Change signature of file_path.c function --- disk_index_file.c | 9 ++---- gfx/video_shader_parse.c | 35 ++++++++++++------------ libretro-common/file/file_path.c | 25 ++++++++--------- libretro-common/include/file/file_path.h | 2 +- menu/cbs/menu_cbs_ok.c | 8 ++++-- menu/menu_displaylist.c | 16 ++++++++--- menu/menu_driver.c | 12 +++----- runloop.c | 15 +++++----- tasks/task_content.c | 8 +++--- tasks/task_translation.c | 4 +-- 10 files changed, 65 insertions(+), 69 deletions(-) diff --git a/disk_index_file.c b/disk_index_file.c index c35c8739bc29..67b359a34e2c 100644 --- a/disk_index_file.c +++ b/disk_index_file.c @@ -226,12 +226,9 @@ bool disk_index_file_init( /* > Get disk index file directory */ if (!string_is_empty(dir_savefile)) strlcpy(disk_index_file_dir, dir_savefile, sizeof(disk_index_file_dir)); - else - { - /* Use content directory */ - strlcpy(disk_index_file_dir, content_path, sizeof(disk_index_file_dir)); - path_basedir(disk_index_file_dir); - } + else /* Use content directory */ + fill_pathname_basedir(disk_index_file_dir, content_path, + sizeof(disk_index_file_dir)); /* > Create directory, if required */ if ( !path_is_directory(disk_index_file_dir) diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 2861d0e2ab64..043b3905a2ee 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -86,24 +86,6 @@ struct wildcard_token char token_name[24]; }; -static struct wildcard_token wildcard_tokens[SHADER_NUM_WILDCARDS] = { - {RARCH_WILDCARD_CONTENT_DIR, "$CONTENT-DIR$"}, - {RARCH_WILDCARD_CORE, "$CORE$"}, - {RARCH_WILDCARD_GAME, "$GAME$"}, - {RARCH_WILDCARD_VIDEO_DRIVER, "$VID-DRV$"}, - {RARCH_WILDCARD_VIDEO_DRIVER_PRESET_EXT, "$VID-DRV-PRESET-EXT$"}, - {RARCH_WILDCARD_VIDEO_DRIVER_SHADER_EXT, "$VID-DRV-SHADER-EXT$"}, - {RARCH_WILDCARD_CORE_REQUESTED_ROTATION, "$CORE-REQ-ROT$"}, - {RARCH_WILDCARD_VIDEO_ALLOW_CORE_ROTATION, "$VID-ALLOW-CORE-ROT$"}, - {RARCH_WILDCARD_VIDEO_USER_ROTATION, "$VID-USER-ROT$"}, - {RARCH_WILDCARD_VIDEO_FINAL_ROTATION, "$VID-FINAL-ROT$"}, - {RARCH_WILDCARD_SCREEN_ORIENTATION, "$SCREEN-ORIENT$"}, - {RARCH_WILDCARD_VIEWPORT_ASPECT_ORIENTATION, "$VIEW-ASPECT-ORIENT$"}, - {RARCH_WILDCARD_CORE_ASPECT_ORIENTATION, "$CORE-ASPECT-ORIENT$"}, - {RARCH_WILDCARD_PRESET_DIR, "$PRESET-DIR$"}, - {RARCH_WILDCARD_PRESET, "$PRESET$"}, -}; - /* TODO/FIXME - global state - perhaps move outside this file */ static path_change_data_t *file_change_data = NULL; @@ -231,6 +213,23 @@ static void video_shader_replace_wildcards(char *s, size_t len, char *in_preset_ { int i = 0; char replaced_path[PATH_MAX_LENGTH]; + static struct wildcard_token wildcard_tokens[SHADER_NUM_WILDCARDS] = { + {RARCH_WILDCARD_CONTENT_DIR, "$CONTENT-DIR$"}, + {RARCH_WILDCARD_CORE, "$CORE$"}, + {RARCH_WILDCARD_GAME, "$GAME$"}, + {RARCH_WILDCARD_VIDEO_DRIVER, "$VID-DRV$"}, + {RARCH_WILDCARD_VIDEO_DRIVER_PRESET_EXT, "$VID-DRV-PRESET-EXT$"}, + {RARCH_WILDCARD_VIDEO_DRIVER_SHADER_EXT, "$VID-DRV-SHADER-EXT$"}, + {RARCH_WILDCARD_CORE_REQUESTED_ROTATION, "$CORE-REQ-ROT$"}, + {RARCH_WILDCARD_VIDEO_ALLOW_CORE_ROTATION, "$VID-ALLOW-CORE-ROT$"}, + {RARCH_WILDCARD_VIDEO_USER_ROTATION, "$VID-USER-ROT$"}, + {RARCH_WILDCARD_VIDEO_FINAL_ROTATION, "$VID-FINAL-ROT$"}, + {RARCH_WILDCARD_SCREEN_ORIENTATION, "$SCREEN-ORIENT$"}, + {RARCH_WILDCARD_VIEWPORT_ASPECT_ORIENTATION, "$VIEW-ASPECT-ORIENT$"}, + {RARCH_WILDCARD_CORE_ASPECT_ORIENTATION, "$CORE-ASPECT-ORIENT$"}, + {RARCH_WILDCARD_PRESET_DIR, "$PRESET-DIR$"}, + {RARCH_WILDCARD_PRESET, "$PRESET$"}, + }; if (!strstr(s, RARCH_WILDCARD_DELIMITER)) return; diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index 5a968326be4a..897d97c619d3 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -597,21 +597,18 @@ size_t path_basedir(char *s) char *last_slash = NULL; if (!s || s[0] == '\0' || s[1] == '\0') return (s && s[0] != '\0') ? 1 : 0; - slash = strrchr(s, '/'); - backslash = strrchr(s, '\\'); - last_slash = (!slash || (backslash > slash)) ? (char*)backslash : (char*)slash; + slash = strrchr(s, '/'); + backslash = strrchr(s, '\\'); + last_slash = (!slash || (backslash > slash)) ? (char*)backslash : (char*)slash; if (last_slash) { - last_slash[1] = '\0'; + last_slash[1] = '\0'; return last_slash + 1 - s; } - else - { - s[0] = '.'; - s[1] = PATH_DEFAULT_SLASH_C(); - s[2] = '\0'; - return 2; - } + s[0] = '.'; + s[1] = PATH_DEFAULT_SLASH_C(); + s[2] = '\0'; + return 2; } /** @@ -1446,13 +1443,13 @@ size_t fill_pathname_application_path(char *s, size_t len) return 0; } -void fill_pathname_application_dir(char *s, size_t len) +size_t fill_pathname_application_dir(char *s, size_t len) { #ifdef __WINRT__ - strlcpy(s, uwp_dir_install, len); + return strlcpy(s, uwp_dir_install, len); #else fill_pathname_application_path(s, len); - path_basedir(s); + return path_basedir(s); #endif } diff --git a/libretro-common/include/file/file_path.h b/libretro-common/include/file/file_path.h index ba1782ecf8c4..bdaeef3f567b 100644 --- a/libretro-common/include/file/file_path.h +++ b/libretro-common/include/file/file_path.h @@ -636,7 +636,7 @@ size_t fill_pathname_slash(char *path, size_t size); #if !defined(RARCH_CONSOLE) && defined(RARCH_INTERNAL) size_t fill_pathname_application_path(char *buf, size_t size); -void fill_pathname_application_dir(char *buf, size_t size); +size_t fill_pathname_application_dir(char *buf, size_t size); size_t fill_pathname_home_dir(char *buf, size_t size); #endif diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index ab9a963b457d..512140d664d3 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1377,10 +1377,12 @@ int generic_action_ok_displaylist_push( { filebrowser_clear_type(); if (content_get_subsystem_rom_id() > 0) - strlcpy(tmp, content_get_subsystem_rom(content_get_subsystem_rom_id() - 1), sizeof(tmp)); + fill_pathname_basedir(tmp, + content_get_subsystem_rom(content_get_subsystem_rom_id() - 1), + sizeof(tmp)); else - strlcpy(tmp, path_get(RARCH_PATH_CONTENT), sizeof(tmp)); - path_basedir(tmp); + fill_pathname_basedir(tmp, + path_get(RARCH_PATH_CONTENT), sizeof(tmp)); if (content_get_subsystem() != (int)type - MENU_SETTINGS_SUBSYSTEM_ADD) content_clear_subsystem(); diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index f308eb3759eb..ccf102220ce7 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -500,9 +500,9 @@ static int filebrowser_parse( if (str_list->size <= 0) { char dir[DIR_MAX_LENGTH]; - fill_pathname_application_dir(dir, sizeof(dir)); + size_t _len = fill_pathname_application_dir(dir, sizeof(dir)); if (string_ends_with(full_path, "/") && !string_ends_with(dir, "/")) - strlcat(dir, "/", sizeof(dir)); + strlcpy(dir + _len, "/", sizeof(dir) - _len); if (string_is_equal(dir, full_path)) allow_parent_directory = false; else @@ -5139,13 +5139,21 @@ static unsigned menu_displaylist_parse_content_information( if ( !string_is_empty(content_label) && !string_is_empty(db_name)) { + char *last; char db_path[PATH_MAX_LENGTH]; fill_pathname_join_special(db_path, settings->paths.path_content_database, db_name, sizeof(db_path)); - path_remove_extension(db_path); - strlcat(db_path, ".rdb", sizeof(db_path)); + last = (char*)strrchr(path_basename(db_path), '.'); + if (*last) + { + last[0] = '.'; + last[1] = 'r'; + last[2] = 'd'; + last[3] = 'b'; + last[4] = '\0'; + } if (path_is_valid(db_path)) if (menu_entries_append(info_list, diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 437564107255..254bc73bbea2 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -2985,16 +2985,12 @@ static bool menu_shader_manager_save_preset_internal( fill_pathname_join(buffer, target_dirs[i], fullname, sizeof(buffer)); - strlcpy(basedir, buffer, sizeof(basedir)); - path_basedir(basedir); + fill_pathname_basedir(basedir, buffer, sizeof(basedir)); - if (!path_is_directory(basedir)) + if (!path_is_directory(basedir) && !(ret = path_mkdir(basedir))) { - if (!(ret = path_mkdir(basedir))) - { - RARCH_WARN("[Shaders]: Failed to create preset directory \"%s\".\n", basedir); - continue; - } + RARCH_WARN("[Shaders]: Failed to create preset directory \"%s\".\n", basedir); + continue; } preset_path = buffer; diff --git a/runloop.c b/runloop.c index a8079f9fe3be..68715735bdf6 100644 --- a/runloop.c +++ b/runloop.c @@ -7928,10 +7928,10 @@ void runloop_path_set_redirect(settings_t *settings, if ( string_is_empty(intermediate_savefile_dir) || savefiles_in_content_dir) { - strlcpy(intermediate_savefile_dir, - runloop_st->runtime_content_path_basename, - sizeof(intermediate_savefile_dir)); - path_basedir(intermediate_savefile_dir); + fill_pathname_basedir( + intermediate_savefile_dir, + runloop_st->runtime_content_path_basename, + sizeof(intermediate_savefile_dir)); if (string_is_empty(intermediate_savefile_dir)) RARCH_LOG("Cannot resolve save file path.\n"); @@ -7941,10 +7941,9 @@ void runloop_path_set_redirect(settings_t *settings, if ( string_is_empty(intermediate_savestate_dir) || savestates_in_content_dir) { - strlcpy(intermediate_savestate_dir, - runloop_st->runtime_content_path_basename, - sizeof(intermediate_savestate_dir)); - path_basedir(intermediate_savestate_dir); + fill_pathname_basedir(intermediate_savestate_dir, + runloop_st->runtime_content_path_basename, + sizeof(intermediate_savestate_dir)); if (string_is_empty(intermediate_savestate_dir)) RARCH_LOG("Cannot resolve save state file path.\n"); diff --git a/tasks/task_content.c b/tasks/task_content.c index 448cb165f1df..ef7ff7f29e84 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -556,6 +556,9 @@ static bool content_file_list_set_info( { char archive_path[PATH_MAX_LENGTH]; size_t _len = 0; + + file_info->file_in_archive = true; + /* Extract path of parent archive */ if ((_len = (size_t)(1 + archive_delim - path)) >= PATH_MAX_LENGTH) @@ -582,9 +585,6 @@ static bool content_file_list_set_info( * this is the basename of the archive file without * extension */ fill_pathname_base(name, archive_path, sizeof(name)); - path_remove_extension(name); - - file_info->file_in_archive = true; } else { @@ -596,8 +596,8 @@ static bool content_file_list_set_info( * is the basename of the content file, without * extension */ fill_pathname_base(name, path, sizeof(name)); - path_remove_extension(name); } + path_remove_extension(name); if (!string_is_empty(dir)) { diff --git a/tasks/task_translation.c b/tasks/task_translation.c index 414d52902221..94680b976373 100644 --- a/tasks/task_translation.c +++ b/tasks/task_translation.c @@ -780,7 +780,6 @@ static const char *ai_service_get_str(enum translation_lang id) bool run_translation_service(settings_t *settings, bool paused) { struct video_viewport vp; - uint8_t header[54]; size_t pitch; unsigned width, height; const void *data = NULL; @@ -947,11 +946,10 @@ bool run_translation_service(settings_t *settings, bool paused) the BMP header as bytes, and then covert that to a b64 encoded array for transport in JSON. */ - form_bmp_header(header, width, height, false); if (!(bmp_buffer = (uint8_t*)malloc(width * height * 3 + 54))) goto finish; - memcpy(bmp_buffer, header, 54 * sizeof(uint8_t)); + form_bmp_header(bmp_buffer, width, height, false); memcpy(bmp_buffer + 54, bit24_image, width * height * 3 * sizeof(uint8_t)); From beceb88cd7d722b86057898c2f47ecad64a7b233 Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 16 Jan 2025 00:14:30 +0000 Subject: [PATCH 21/49] Fetch translations from Crowdin --- intl/msg_hash_be.h | 8 ++++---- intl/msg_hash_pt_pt.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/intl/msg_hash_be.h b/intl/msg_hash_be.h index 9290b0df6be8..252b27608be9 100644 --- a/intl/msg_hash_be.h +++ b/intl/msg_hash_be.h @@ -2296,7 +2296,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_ROTATION, - "Прымушае пэўны паварот выявы. Дадаецца да паваротаў, што задае ядро." + "Прымушае ўжыць пэўны паварот выявы. Дадаецца да паваротаў, што задае ядро." ) MSG_HASH( MENU_ENUM_LABEL_VALUE_SCREEN_ORIENTATION, @@ -2304,7 +2304,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_SCREEN_ORIENTATION, - "Прымушае пэўную арыентацыю экрана паводле аперацыйнай сістэмы." + "Прымушае ўжыць пэўную арыентацыю экрана паводле аперацыйнай сістэмы." ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_GPU_INDEX, @@ -2320,7 +2320,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_WINDOW_OFFSET_X, - "Прымушае пэўнае зрушэнне выявы па гарызанталі. Ужываецца глабальна." + "Прымушае ўжыць пэўнае зрушэнне выявы па гарызанталі. Ужываецца глабальна." ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_OFFSET_Y, @@ -2328,7 +2328,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_WINDOW_OFFSET_Y, - "Прымушае пэўнае зрушэнне выявы па вертыкалі. Ужываецца глабальна." + "Прымушае ўжыць пэўнае зрушэнне выявы па вертыкалі. Ужываецца глабальна." ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_REFRESH_RATE, diff --git a/intl/msg_hash_pt_pt.h b/intl/msg_hash_pt_pt.h index fd4ff934121d..5e40948996ce 100644 --- a/intl/msg_hash_pt_pt.h +++ b/intl/msg_hash_pt_pt.h @@ -195,7 +195,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_QUIT_RETROARCH, - "Sair" + "Encerrar" ) MSG_HASH( MENU_ENUM_SUBLABEL_QUIT_RETROARCH, From 0113226936031ff1fe62c6af2cb92299aea9a06a Mon Sep 17 00:00:00 2001 From: Jamiras <32680403+Jamiras@users.noreply.github.com> Date: Thu, 16 Jan 2025 12:00:02 -0700 Subject: [PATCH 22/49] (cheevos) include achievement state in netplay states (#17416) * add achievement data to netplay save state * honor achievement state from netplay server * keep processing achievements if menu doesn't pause game * remove unused variable * only CRC coremem * force send savestate on join and hardcore change * allow hardcore enablement to be synced to clients * still calculate cheevos_size for non-server * use appropriate buffer * optimizations for when achievements are disabled * support interfacing with older protocols * formatting * c89 --- cheevos/cheevos.c | 80 +++---- cheevos/cheevos_locals.h | 1 - intl/msg_hash_us.h | 8 + msg_hash.h | 2 + network/netplay/netplay.h | 2 + network/netplay/netplay_frontend.c | 372 ++++++++++++++++++++++++++--- network/netplay/netplay_private.h | 6 +- network/netplay/netplay_protocol.h | 2 +- runloop.c | 36 ++- 9 files changed, 419 insertions(+), 90 deletions(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index a71b0ca5c77d..68acaaac56b6 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -87,7 +87,6 @@ static rcheevos_locals_t rcheevos_locals = {{0}},/* memory */ #ifdef HAVE_THREADS CMD_EVENT_NONE, /* queued_command */ - false, /* game_placard_requested */ #endif "", /* user_agent_prefix */ "", /* user_agent_core */ @@ -112,8 +111,8 @@ rcheevos_locals_t* get_rcheevos_locals(void) Supporting functions. *****************************************************************************/ -#define CMD_CHEEVOS_NON_COMMAND -1 -static void rcheevos_show_game_placard(void); +#define CMD_CHEEVOS_FINALIZE_LOAD -1 +static void rcheevos_finalize_game_load_on_ui_thread(void); #ifndef CHEEVOS_VERBOSE void rcheevos_log(const char* fmt, ...) @@ -686,7 +685,6 @@ bool rcheevos_unload(void) #ifdef HAVE_THREADS rcheevos_locals.queued_command = CMD_EVENT_NONE; - rcheevos_locals.game_placard_requested = false; #endif if (rcheevos_locals.memory.count > 0) @@ -827,6 +825,11 @@ static void rcheevos_toggle_hardcore_active(rcheevos_locals_t* locals) command_event(CMD_EVENT_REWIND_INIT, NULL); } } + +#ifdef HAVE_NETWORKING + /* force sending a savestate to clients so they'll drop out of hardcore too */ + netplay_force_send_savestate(); +#endif } void rcheevos_toggle_hardcore_paused(void) @@ -978,16 +981,12 @@ void rcheevos_test(void) #ifdef HAVE_THREADS if (rcheevos_locals.queued_command != CMD_EVENT_NONE) { - if ((int)rcheevos_locals.queued_command != CMD_CHEEVOS_NON_COMMAND) + if ((int)rcheevos_locals.queued_command == CMD_CHEEVOS_FINALIZE_LOAD) + rcheevos_finalize_game_load_on_ui_thread(); + else command_event(rcheevos_locals.queued_command, NULL); rcheevos_locals.queued_command = CMD_EVENT_NONE; - - if (rcheevos_locals.game_placard_requested) - { - rcheevos_locals.game_placard_requested = false; - rcheevos_show_game_placard(); - } } #endif @@ -1382,6 +1381,25 @@ static void rcheevos_finalize_game_load(rc_client_t* client) } } +static void rcheevos_finalize_game_load_on_ui_thread(void) +{ + rcheevos_show_game_placard(); + +#if HAVE_REWIND + if (!rcheevos_hardcore_active()) + { + const settings_t* settings = config_get_ptr(); + /* Re-enable rewind. Additional space will be allocated for the achievement state data */ + if (settings->bools.rewind_enable) + command_event(CMD_EVENT_REWIND_REINIT, NULL); + } +#endif + +#ifdef HAVE_NETWORKING + netplay_reinit_serialization(); +#endif +} + static void rcheevos_client_load_game_callback(int result, const char* error_message, rc_client_t* client, void* userdata) { @@ -1446,17 +1464,6 @@ static void rcheevos_client_load_game_callback(int result, rc_client_set_read_memory_function(client, rcheevos_client_read_memory); } -#ifdef HAVE_THREADS - if (!video_driver_is_threaded() && !task_is_on_main_thread()) - { - /* have to "schedule" this. game image should not be loaded on background thread */ - rcheevos_locals.queued_command = CMD_CHEEVOS_NON_COMMAND; - rcheevos_locals.game_placard_requested = true; - } - else -#endif - rcheevos_show_game_placard(); - rcheevos_finalize_game_load(client); if (rcheevos_hardcore_active()) @@ -1466,27 +1473,18 @@ static void rcheevos_client_load_game_callback(int result, rcheevos_validate_config_settings(); rcheevos_enforce_hardcore_settings(); } - else - { -#if HAVE_REWIND - /* Re-enable rewind. Additional space will be allocated for the achievement state data */ - if (settings->bools.rewind_enable) - { -#ifdef HAVE_THREADS - if (!task_is_on_main_thread()) - { - /* Have to "schedule" this. CMD_EVENT_REWIND_REINIT should - * only be called on the main thread */ - rcheevos_locals.queued_command = CMD_EVENT_REWIND_REINIT; - } - else -#endif - command_event(CMD_EVENT_REWIND_REINIT, NULL); - } -#endif - } rcheevos_spectating_changed(); /* synchronize spectating state */ + +#ifdef HAVE_THREADS + if (!task_is_on_main_thread()) + { + /* have to "schedule" this. game image should not be loaded into memory on background thread */ + rcheevos_locals.queued_command = CMD_CHEEVOS_FINALIZE_LOAD; + } + else +#endif + rcheevos_finalize_game_load_on_ui_thread(); } static rc_clock_t rcheevos_client_get_time_millisecs(const rc_client_t* client) diff --git a/cheevos/cheevos_locals.h b/cheevos/cheevos_locals.h index 16907a5faca5..74caf86e4620 100644 --- a/cheevos/cheevos_locals.h +++ b/cheevos/cheevos_locals.h @@ -86,7 +86,6 @@ typedef struct rcheevos_locals_t #ifdef HAVE_THREADS enum event_command queued_command; /* action queued by background thread to be run on main thread */ - bool game_placard_requested; /* request to display game placard */ #endif char user_agent_prefix[128]; /* RetroArch/OS version information */ diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 98922cc165f8..7c2788a2afac 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -15583,6 +15583,14 @@ MSG_HASH( MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT, "A cheat was activated. Achievements Hardcore Mode disabled for the current session." ) +MSG_HASH( + MSG_CHEEVOS_HARDCORE_MODE_CHANGED_BY_HOST, + "Achievements Hardcore Mode changed by host." + ) +MSG_HASH( + MSG_CHEEVOS_HARDCORE_MODE_REQUIRES_NEWER_HOST, + "Netplay host needs to be updated. Achievements Hardcore Mode disabled for current session." + ) MSG_HASH( MSG_CHEEVOS_MASTERED_GAME, "Mastered %s" diff --git a/msg_hash.h b/msg_hash.h index 4eaf9aac660e..eddaa01f258f 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -4097,6 +4097,8 @@ enum msg_hash_enums MSG_CHEEVOS_LOAD_STATE_PREVENTED_BY_HARDCORE_MODE, MSG_CHEEVOS_HARDCORE_MODE_DISABLED, MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT, + MSG_CHEEVOS_HARDCORE_MODE_CHANGED_BY_HOST, + MSG_CHEEVOS_HARDCORE_MODE_REQUIRES_NEWER_HOST, MSG_CHEEVOS_MASTERED_GAME, MSG_CHEEVOS_COMPLETED_GAME, MSG_CHEEVOS_HARDCORE_MODE_ENABLE, diff --git a/network/netplay/netplay.h b/network/netplay/netplay.h index ea027f5f8fa0..3c1b90da776f 100644 --- a/network/netplay/netplay.h +++ b/network/netplay/netplay.h @@ -195,7 +195,9 @@ void deinit_netplay(void); bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data); +bool netplay_reinit_serialization(void); bool netplay_is_spectating(void); +void netplay_force_send_savestate(void); #ifdef HAVE_NETPLAYDISCOVERY /** Initialize Netplay discovery */ diff --git a/network/netplay/netplay_frontend.c b/network/netplay/netplay_frontend.c index b12a324014e0..cd99527d52a4 100644 --- a/network/netplay/netplay_frontend.c +++ b/network/netplay/netplay_frontend.c @@ -216,6 +216,16 @@ net_driver_state_t *networking_state_get_ptr(void) return &networking_driver_st; } +static bool netplay_build_savestate(netplay_t* netplay, retro_ctx_serialize_info_t* serial_info, bool force_capture_achievements); +static bool netplay_process_savestate(netplay_t* netplay, retro_ctx_serialize_info_t* serial_info); + +/* Align to 8-byte boundary */ +#define CONTENT_ALIGN_SIZE(size) ((((size) + 7) & ~7)) +#define NETPLAYSTATE_VERSION 1 +#define NETPLAYSTATE_MEM_BLOCK "MEM " +#define NETPLAYSTATE_CHEEVOS_BLOCK "ACHV" +#define NETPLAYSTATE_END_BLOCK "END " + #ifdef HAVE_NETPLAYDISCOVERY /** Initialize Netplay discovery (client) */ bool init_netplay_discovery(void) @@ -2099,6 +2109,31 @@ bool netplay_delta_frame_ready(netplay_t *netplay, struct delta_frame *delta, return true; } +static const uint8_t* netplay_get_savestate_coremem(netplay_t* netplay, const uint8_t* input) +{ + /* If the container header is detected, find the coremem block */ + if (memcmp(input, "NETPLAY", 7) == 0) + { + const uint8_t* stop = input + netplay->state_size; + input += 8; /* NETPLAY# */ + + while (input < stop) + { + size_t block_size = (input[7] << 24 | input[6] << 16 | input[5] << 8 | input[4]); + const uint8_t* marker = input; + + input += 8; + + if (memcmp(marker, NETPLAYSTATE_MEM_BLOCK, 4) == 0) + break; + + input += CONTENT_ALIGN_SIZE(block_size); + } + } + + return input; +} + /** * netplay_delta_frame_crc * @@ -2107,9 +2142,13 @@ bool netplay_delta_frame_ready(netplay_t *netplay, struct delta_frame *delta, static uint32_t netplay_delta_frame_crc(netplay_t *netplay, struct delta_frame *delta) { + const uint8_t* input; + NETPLAY_ASSERT_MODUS(NETPLAY_MODUS_INPUT_FRAME_SYNC); - return encoding_crc32(0L, (const unsigned char*)delta->state, - netplay->state_size); + input = netplay_get_savestate_coremem(netplay, + (const uint8_t*)delta->state); + + return encoding_crc32(0L, input, netplay->coremem_size); } /* @@ -3657,11 +3696,9 @@ static bool netplay_sync_pre_frame(netplay_t *netplay) if (!(netplay->quirks & NETPLAY_QUIRK_INITIALIZATION)) { retro_ctx_serialize_info_t serial_info = {0}; - serial_info.data = netplay->buffer[netplay->run_ptr].state; - serial_info.size = netplay->state_size; - memset(serial_info.data, 0, serial_info.size); - if (core_serialize_special(&serial_info)) + + if (netplay_build_savestate(netplay, &serial_info, false)) { if (netplay->force_send_savestate && !netplay->stall && !netplay->remote_paused) @@ -3678,9 +3715,6 @@ static bool netplay_sync_pre_frame(netplay_t *netplay) } /* Send this along to the other side. */ - serial_info.data_const = - netplay->buffer[netplay->run_ptr].state; - netplay_load_savestate(netplay, &serial_info, false); netplay->force_send_savestate = false; @@ -3892,7 +3926,7 @@ static void netplay_sync_input_post_frame(netplay_t *netplay, bool stalled) serial_info.data = NULL; serial_info.data_const = netplay->buffer[netplay->replay_ptr].state; serial_info.size = netplay->state_size; - if (!core_unserialize_special(&serial_info)) + if (!netplay_process_savestate(netplay, &serial_info)) RARCH_ERR("[Netplay] Netplay savestate loading failed: Prepare for desync!\n"); while (netplay->replay_frame_count < netplay->run_frame_count) @@ -3908,7 +3942,7 @@ static void netplay_sync_input_post_frame(netplay_t *netplay, bool stalled) /* Remember the current state */ memset(serial_info.data, 0, serial_info.size); - core_serialize_special(&serial_info); + netplay_build_savestate(netplay, &serial_info, true); if (netplay->replay_frame_count < netplay->unread_frame_count) netplay_handle_frame_hash(netplay, ptr); @@ -4670,6 +4704,9 @@ static void netplay_announce_play_spectate(netplay_t *netplay, #ifdef HAVE_CHEEVOS rcheevos_spectating_changed(); + + if (!netplay->is_server && !netplay_is_spectating()) /* force sync of achievement state */ + netplay_cmd_request_savestate(netplay); #endif RARCH_LOG("[Netplay] %s\n", _msg); @@ -6041,8 +6078,7 @@ static bool netplay_get_cmd(netplay_t *netplay, state_size = ntohl(state_size); state_size_raw = cmd_size - (sizeof(frame) + sizeof(state_size)); - if (state_size != netplay->state_size || - state_size_raw > netplay->zbuffer_size) + if (state_size_raw > netplay->zbuffer_size) { RARCH_ERR("[Netplay] Netplay state load with an unexpected save state size.\n"); return netplay_cmd_nak(netplay, connection); @@ -6061,6 +6097,18 @@ static bool netplay_get_cmd(netplay_t *netplay, break; } + if (state_size > netplay->state_size) + { + /* other client state size is larger than ours, grow ours */ + netplay->state_size = state_size; + for (i = 0; i < netplay->buffer_size; i++) + { + netplay->buffer[i].state = realloc(netplay->buffer[i].state, netplay->state_size); + if (!netplay->buffer[i].state) + return false; + } + } + ctrans->decompression_backend->set_in( ctrans->decompression_stream, netplay->zbuffer, state_size_raw); @@ -6071,6 +6119,28 @@ static bool netplay_get_cmd(netplay_t *netplay, ctrans->decompression_stream, true, &rd, &wn, NULL); + if (memcmp(netplay->buffer[load_ptr].state, "NETPLAY", 7) != 0) + { + if (state_size != netplay->coremem_size) + { + RARCH_ERR("[Netplay] Netplay state load with an unexpected save state size.\n"); + return netplay_cmd_nak(netplay, connection); + } + +#ifdef HAVE_CHEEVOS + /* did not receive a protocol 7 packet. server isn't sending achievement data. disable hardcore */ + if (!netplay->is_server && rcheevos_hardcore_active() && !netplay_is_spectating()) + { + const char* msg = msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_REQUIRES_NEWER_HOST); + runloop_msg_queue_push(msg, strlen(msg), 0, 180, true, NULL, + MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + RARCH_WARN("[Netplay] Server did not send achievement information.\n", msg); + + rcheevos_pause_hardcore(); + } +#endif + } + /* Force a rewind to the relevant frame. */ netplay->force_rewind = true; @@ -6984,6 +7054,15 @@ static bool netplay_init_socket_buffers(netplay_t *netplay) return true; } +static void netplay_write_block_header(unsigned char* output, const char* header, size_t size) +{ + memcpy(output, header, 4); + output[4] = ((size) & 0xFF); + output[5] = ((size >> 8) & 0xFF); + output[6] = ((size >> 16) & 0xFF); + output[7] = ((size >> 24) & 0xFF); +} + static bool netplay_init_serialization(netplay_t *netplay) { size_t i; @@ -7001,6 +7080,31 @@ static bool netplay_init_serialization(netplay_t *netplay) size_t info_size = core_serialize_size_special(); if (!info_size) return false; + + netplay->coremem_size = info_size; + + /* 8-byte identifier, 8-byte block header, content, 8-byte terminator */ + info_size = 8 + 8 + CONTENT_ALIGN_SIZE(info_size) + 8; + +#ifdef HAVE_CHEEVOS + { + const settings_t* settings = config_get_ptr(); + if (settings->bools.cheevos_enable) + { + /* 8-byte flags + content */ + netplay->cheevos_size = 8 + rcheevos_get_serialize_size(); + } + else + { + /* just 8-byte flags */ + netplay->cheevos_size = 8; + } + + /* 8-byte block header + content */ + info_size += 8 + CONTENT_ALIGN_SIZE(netplay->cheevos_size); + } +#endif + netplay->state_size = info_size; } @@ -7042,7 +7146,7 @@ static bool netplay_try_init_serialization(netplay_t *netplay) /* Check if we can actually save. */ serial_info.data_const = NULL; serial_info.data = netplay->buffer[netplay->run_ptr].state; - serial_info.size = netplay->state_size; + serial_info.size = netplay->coremem_size; if (!core_serialize_special(&serial_info)) return false; @@ -7327,11 +7431,12 @@ static netplay_t *netplay_new(const char *server, const char *mitm, */ static void netplay_send_savestate(netplay_t *netplay, retro_ctx_serialize_info_t *serial_info, uint32_t cx, - struct compression_transcoder *z) + struct compression_transcoder *z, bool is_legacy_data) { uint32_t header[4]; uint32_t rd, wn; size_t i; + bool has_legacy_connection = false; /* Compress it */ z->compression_backend->set_in(z->compression_stream, @@ -7355,19 +7460,48 @@ static void netplay_send_savestate(netplay_t *netplay, for (i = 0; i < netplay->connections_size; i++) { - struct netplay_connection *connection = &netplay->connections[i]; - if ( (!(connection->flags & NETPLAY_CONN_FLAG_ACTIVE)) - || (connection->mode < NETPLAY_CONNECTION_CONNECTED) - || (connection->compression_supported != cx)) - continue; + struct netplay_connection* connection = &netplay->connections[i]; + bool can_send; - if ( !netplay_send(&connection->send_packet_buffer, - connection->fd, header, - sizeof(header)) - || !netplay_send(&connection->send_packet_buffer, - connection->fd, - netplay->zbuffer, wn)) - netplay_hangup(netplay, connection); + /* if is_legacy_data is false, only send to peers on protocol 7 or higher */ + REQUIRE_PROTOCOL_VERSION(connection, 7) + can_send = !is_legacy_data; + else + can_send = is_legacy_data; + + if (can_send) + { + if ( (!(connection->flags & NETPLAY_CONN_FLAG_ACTIVE)) + || (connection->mode < NETPLAY_CONNECTION_CONNECTED) + || (connection->compression_supported != cx)) + continue; + + if ( !netplay_send(&connection->send_packet_buffer, + connection->fd, header, sizeof(header)) + || !netplay_send(&connection->send_packet_buffer, + connection->fd, netplay->zbuffer, wn)) + netplay_hangup(netplay, connection); + } + else + { + has_legacy_connection = true; + } + } + + if (has_legacy_connection && !is_legacy_data) + { + /* at least one peer is not on protocol 7 or higher. extract the coremem segment + * and only send it. */ + const uint8_t* input = netplay_get_savestate_coremem(netplay, + (const uint8_t*)serial_info->data_const); + + if (input != serial_info->data_const) + { + serial_info->data_const = input; + serial_info->size = netplay->coremem_size; + + netplay_send_savestate(netplay, serial_info, cx, z, true); + } } } @@ -7507,6 +7641,143 @@ static void netplay_core_reset(netplay_t *netplay) } } +static bool netplay_process_savestate1(retro_ctx_serialize_info_t* serial_info) +{ +#ifdef HAVE_CHEEVOS + const settings_t* settings = config_get_ptr(); +#endif + const uint8_t* input = serial_info->data_const; + const uint8_t* stop = input + serial_info->size; + bool seen_core = false; + + input += 8; /* NETPLAY1 */ + + while (input < stop) + { + size_t block_size = (input[7] << 24 | input[6] << 16 | input[5] << 8 | input[4]); + const uint8_t *marker = input; + + input += 8; + + if (memcmp(marker, NETPLAYSTATE_MEM_BLOCK, 4) == 0) + { + retro_ctx_serialize_info_t serial_info; + serial_info.data_const = (void*)input; + serial_info.size = block_size; + if (!core_unserialize_special(&serial_info)) + return false; + + seen_core = true; + } +#ifdef HAVE_CHEEVOS + else if (memcmp(marker, NETPLAYSTATE_CHEEVOS_BLOCK, 4) == 0 && settings->bools.cheevos_enable) + { + const bool hardcore_state = (input[0] != 0); + if (hardcore_state != rcheevos_hardcore_active() && !netplay_is_spectating()) + { + const char *msg = msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_CHANGED_BY_HOST); + runloop_msg_queue_push(msg, strlen(msg), 0, 180, true, NULL, + MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + + if (!hardcore_state) + { + /* use pause_hardcore to ensure player can't re-enabled it on client side */ + rcheevos_pause_hardcore(); + } + else + { + /* if the player had hardcore on, this will reset it to on. otherwise, it'll + * stay off, even if the server is playing with hardcore restrictions now. we + * don't want to force hardcore unlocks for a player that doesn't want them. */ + rcheevos_hardcore_enabled_changed(); + } + } + + if (block_size > 8) + { + input += 8; + rcheevos_set_serialized_data((void*)input); + } + } +#endif + + input += CONTENT_ALIGN_SIZE(block_size); + } + + if (!seen_core) + return false; + + return true; +} + +static bool netplay_process_savestate(netplay_t* netplay, retro_ctx_serialize_info_t* serial_info) +{ + /* if no NETPLAY marker, it's just raw core data */ + if (memcmp(serial_info->data_const, "NETPLAY", 7) != 0) + { + serial_info->size = netplay->coremem_size; + return core_unserialize_special(serial_info); + } + + switch (((uint8_t*)serial_info->data_const)[7]) + { + case 1: + return netplay_process_savestate1(serial_info); + + default: + return false; + } +} + +static bool netplay_build_savestate(netplay_t* netplay, retro_ctx_serialize_info_t* serial_info, bool force_capture_achievements) +{ + uint8_t* buffer = (uint8_t*)serial_info->data; + uint8_t* output = buffer; + + memcpy(output, "NETPLAY", 7); + output[7] = NETPLAYSTATE_VERSION; + output += 8; + + /* important - write the unaligned size - some cores fail if they aren't passed the exact right size. */ + netplay_write_block_header(output, NETPLAYSTATE_MEM_BLOCK, netplay->coremem_size); + output += 8; + + /* capture the core state */ + serial_info->data = output; + serial_info->size = netplay->coremem_size; + if (!core_serialize_special(serial_info)) + return false; + + output += CONTENT_ALIGN_SIZE(netplay->coremem_size); + +#ifdef HAVE_CHEEVOS + if (netplay->is_server || (force_capture_achievements && netplay->cheevos_size > 8)) + { + const settings_t* settings = config_get_ptr(); + size_t cheevos_size = 8; + + if (settings->bools.cheevos_enable) + { + if (netplay->cheevos_size > 8 && rcheevos_get_serialized_data(output + 16)) + cheevos_size = netplay->cheevos_size; + } + + netplay_write_block_header(output, NETPLAYSTATE_CHEEVOS_BLOCK, cheevos_size); + output += 8; + memset(output, 0, 8); + output[0] = rcheevos_hardcore_active() ? 1 : 0; + output += cheevos_size; + } +#endif + + netplay_write_block_header(output, NETPLAYSTATE_END_BLOCK, 0); + output += 8; + + serial_info->data_const = serial_info->data = buffer; + serial_info->size = (output - buffer); + return true; +} + void netplay_load_savestate(netplay_t *netplay, retro_ctx_serialize_info_t *serial_info, bool save) { @@ -7528,11 +7799,9 @@ void netplay_load_savestate(netplay_t *netplay, if (!serial_info) { - tmp_serial_info.data = netplay->buffer[netplay->run_ptr].state; - tmp_serial_info.size = netplay->state_size; - if (!core_serialize_special(&tmp_serial_info)) + tmp_serial_info.data = netplay->buffer[netplay->run_ptr].state; + if (!netplay_build_savestate(netplay, &tmp_serial_info, false)) return; - tmp_serial_info.data_const = tmp_serial_info.data; serial_info = &tmp_serial_info; } else if (serial_info->size <= netplay->state_size) @@ -7546,10 +7815,10 @@ void netplay_load_savestate(netplay_t *netplay, /* Send this to every peer. */ if (netplay->compress_nil.compression_backend) netplay_send_savestate(netplay, serial_info, 0, - &netplay->compress_nil); + &netplay->compress_nil, false); if (netplay->compress_zlib.compression_backend) netplay_send_savestate(netplay, serial_info, NETPLAY_COMPRESSION_ZLIB, - &netplay->compress_zlib); + &netplay->compress_zlib, false); } } @@ -9074,6 +9343,43 @@ bool netplay_is_spectating(void) return (netplay && (netplay->self_mode == NETPLAY_CONNECTION_SPECTATING)); } +void netplay_force_send_savestate(void) +{ + net_driver_state_t* net_st = &networking_driver_st; + netplay_t* netplay = net_st->data; + + if (netplay && netplay->is_server) + netplay->force_send_savestate = true; +} + +bool netplay_reinit_serialization(void) +{ + net_driver_state_t* net_st = &networking_driver_st; + netplay_t* netplay = net_st->data; + size_t i; + + if (!netplay) + return true; + + netplay->state_size = 0; + + /* netplay_init_serialization rebuilds the delta states and zbuffer, but + * nothing else, so we have to free them directly */ + for (i = 0; i < netplay->buffer_size; i++) + { + free(netplay->buffer[i].state); + netplay->buffer[i].state = NULL; + } + + if (netplay->zbuffer) + { + free(netplay->zbuffer); + netplay->zbuffer = NULL; + } + + return netplay_init_serialization(netplay); +} + /** * netplay_driver_ctl * diff --git a/network/netplay/netplay_private.h b/network/netplay/netplay_private.h index 3ab7a517685c..187822da3a47 100644 --- a/network/netplay/netplay_private.h +++ b/network/netplay/netplay_private.h @@ -527,8 +527,12 @@ struct netplay size_t zbuffer_size; /* The size of our packet buffers */ size_t packet_buffer_size; - /* Size of savestates */ + /* Size of savestates (coremem_size + cheevos_size + headers) */ size_t state_size; + size_t coremem_size; /* core_serialize_special_size() */ +#ifdef HAVE_CHEEVOS + size_t cheevos_size; /* rcheevos_get_serialize_size() */ +#endif /* The frame we're currently inputting */ size_t self_ptr; diff --git a/network/netplay/netplay_protocol.h b/network/netplay/netplay_protocol.h index 7583a2e2561a..608fca18b774 100644 --- a/network/netplay/netplay_protocol.h +++ b/network/netplay/netplay_protocol.h @@ -19,7 +19,7 @@ #define __RARCH_NETPLAY_PROTOCOL_H #define LOW_NETPLAY_PROTOCOL_VERSION 5 -#define HIGH_NETPLAY_PROTOCOL_VERSION 6 +#define HIGH_NETPLAY_PROTOCOL_VERSION 7 #define NETPLAY_PROTOCOL_VERSION HIGH_NETPLAY_PROTOCOL_VERSION diff --git a/runloop.c b/runloop.c index 68715735bdf6..f8bc9104de89 100644 --- a/runloop.c +++ b/runloop.c @@ -5428,6 +5428,22 @@ static void runloop_pause_toggle( command_event(CMD_EVENT_PAUSE, NULL); } +static bool runloop_is_libretro_running(runloop_state_t* runloop_st, settings_t* settings) +{ + const bool runloop_is_inited = (runloop_st->flags & RUNLOOP_FLAG_IS_INITED) ? true : false; +#ifdef HAVE_NETWORKING + const bool menu_pause_libretro = settings->bools.menu_pause_libretro + && netplay_driver_ctl(RARCH_NETPLAY_CTL_ALLOW_PAUSE, NULL); +#else + const bool menu_pause_libretro = settings->bools.menu_pause_libretro; +#endif + + return runloop_is_inited + && !(runloop_st->flags & RUNLOOP_FLAG_PAUSED) + && (!menu_pause_libretro + && runloop_st->flags & RUNLOOP_FLAG_CORE_RUNNING); +} + static enum runloop_state_enum runloop_check_state( bool error_on_init, settings_t *settings, @@ -5963,18 +5979,7 @@ static enum runloop_state_enum runloop_check_state( if (focused || !(runloop_st->flags & RUNLOOP_FLAG_IDLE)) { - bool runloop_is_inited = (runloop_st->flags & RUNLOOP_FLAG_IS_INITED) ? true : false; -#ifdef HAVE_NETWORKING - bool menu_pause_libretro = settings->bools.menu_pause_libretro - && netplay_driver_ctl(RARCH_NETPLAY_CTL_ALLOW_PAUSE, NULL); -#else - bool menu_pause_libretro = settings->bools.menu_pause_libretro; -#endif - bool libretro_running = - runloop_is_inited - && !(runloop_st->flags & RUNLOOP_FLAG_PAUSED) - && ( !menu_pause_libretro - && runloop_st->flags & RUNLOOP_FLAG_CORE_RUNNING); + const bool libretro_running = runloop_is_libretro_running(runloop_st, settings); if (menu) { @@ -6967,7 +6972,12 @@ int runloop_iterate(void) #endif #ifdef HAVE_CHEEVOS if (cheevos_enable) - rcheevos_idle(); + { + if (runloop_is_libretro_running(runloop_st, settings)) + rcheevos_test(); + else + rcheevos_idle(); + } #endif #ifdef HAVE_MENU /* Rely on vsync throttling unless VRR is enabled and menu throttle is disabled. */ From 7e00668181a14c7d09ac40c97bf09df33b7b72c8 Mon Sep 17 00:00:00 2001 From: zoltanvb <101990835+zoltanvb@users.noreply.github.com> Date: Thu, 16 Jan 2025 20:00:16 +0100 Subject: [PATCH 23/49] Language update (#17418) --- .github/ISSUE_TEMPLATE/01-bug-report.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/01-bug-report.yml b/.github/ISSUE_TEMPLATE/01-bug-report.yml index d2f15672667f..9a218c4daae8 100644 --- a/.github/ISSUE_TEMPLATE/01-bug-report.yml +++ b/.github/ISSUE_TEMPLATE/01-bug-report.yml @@ -42,7 +42,7 @@ body: attributes: label: Version/Commit description: You can find this information under Information/System Information - placeholder: 1.19.1 (Git 0792144fe3) + placeholder: 1.20.0 (Git ab3b175) validations: required: true @@ -56,8 +56,8 @@ body: - type: dropdown id: nigthly attributes: - label: Check in the nightly version - description: This issue is reproducible with [nightly builds](https://buildbot.libretro.com/nightly/)? + label: Present in the nightly version + description: Is the issue reproducible with current [nightly builds](https://buildbot.libretro.com/nightly/)? options: - I don't know - Yes, this is reproduced in the nightly build From 86c9a43b08014bf75c6a53be7e4bad556d6275ff Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Thu, 16 Jan 2025 21:09:19 +0100 Subject: [PATCH 24/49] Use path_get_extension_mutable --- libretro-common/file/file_path.c | 6 +++--- menu/menu_displaylist.c | 2 +- runloop.c | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index 897d97c619d3..ad484a4b84ff 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -255,7 +255,8 @@ const char *path_get_extension(const char *path) char *path_get_extension_mutable(const char *path) { char *ext = NULL; - if (!string_is_empty(path) && ((ext = (char*)strrchr(path_basename(path), '.')))) + if ( !string_is_empty(path) + && ((ext = (char*)strrchr(path_basename(path), '.')))) return ext; return NULL; } @@ -276,8 +277,7 @@ char *path_get_extension_mutable(const char *path) **/ char *path_remove_extension(char *s) { - char *last = !string_is_empty(s) - ? (char*)strrchr(path_basename(s), '.') : NULL; + char *last = path_get_extension_mutable(s); if (!last) return NULL; if (*last) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index ccf102220ce7..9fb01dc3427b 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -5145,7 +5145,7 @@ static unsigned menu_displaylist_parse_content_information( settings->paths.path_content_database, db_name, sizeof(db_path)); - last = (char*)strrchr(path_basename(db_path), '.'); + last = path_get_extension_mutable(db_path); if (*last) { last[0] = '.'; diff --git a/runloop.c b/runloop.c index f8bc9104de89..cf7878eace0b 100644 --- a/runloop.c +++ b/runloop.c @@ -7856,7 +7856,8 @@ void runloop_path_set_basename(const char *path) */ path_basedir_wrapper(runloop_st->runtime_content_path_basename); if (!string_is_empty(runloop_st->runtime_content_path_basename)) - fill_pathname_dir(runloop_st->runtime_content_path_basename, path, "", sizeof(runloop_st->runtime_content_path_basename)); + fill_pathname_dir(runloop_st->runtime_content_path_basename, path, + "", sizeof(runloop_st->runtime_content_path_basename)); #endif if ((dst = strrchr(runloop_st->runtime_content_path_basename, '.'))) From 0b329018eea4222895d1673590daf2be512dc8ed Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Thu, 16 Jan 2025 23:59:22 +0100 Subject: [PATCH 25/49] Less string buffers and less string copies --- cheat_manager.c | 21 +++------- command.c | 84 +++++++++++++++++++--------------------- command.h | 2 +- core_info.c | 25 ++++-------- disk_control_interface.c | 8 ++-- disk_control_interface.h | 4 +- menu/menu_displaylist.c | 61 ++++++++++++++++------------- playlist.c | 24 ++++++------ runloop.c | 12 +++--- runtime_file.c | 4 +- save.c | 2 - tasks/task_autodetect.c | 24 +++++------- 12 files changed, 122 insertions(+), 149 deletions(-) diff --git a/cheat_manager.c b/cheat_manager.c index 18256e0c5e77..240b0f9632e6 100644 --- a/cheat_manager.c +++ b/cheat_manager.c @@ -704,7 +704,7 @@ bool cheat_manager_get_code_state(unsigned i) return cheat_st->cheats[i].state; } -static bool cheat_manager_get_game_specific_filename( +static size_t cheat_manager_get_game_specific_filename( char *s, size_t len, const char *path_cheat_database, bool saving) @@ -714,32 +714,23 @@ static bool cheat_manager_get_game_specific_filename( runloop_state_t *runloop_st = runloop_state_get_ptr(); const char *core_name = NULL; const char *game_name = NULL; - if (!core_get_system_info(&sysinfo)) - return false; - + return 0; core_name = sysinfo.library_name; game_name = path_basename_nocompression(runloop_st->name.cheatfile); - if ( string_is_empty(path_cheat_database) || string_is_empty(core_name) || string_is_empty(game_name)) - return false; - - fill_pathname_join_special(s1, - path_cheat_database, core_name, + return 0; + fill_pathname_join_special(s1, path_cheat_database, core_name, sizeof(s1)); - if (saving) { /* Check if directory is valid, if not, create it */ if (!path_is_valid(s1)) path_mkdir(s1); } - - fill_pathname_join_special(s, s1, game_name, len); - - return true; + return fill_pathname_join_special(s, s1, game_name, len); } void cheat_manager_load_game_specific_cheats(const char *path_cheat_database) @@ -789,7 +780,7 @@ int cheat_manager_initialize_memory(rarch_setting_t *setting, size_t idx, bool w bool is_search_initialization = (setting != NULL); rarch_system_info_t *sys_info = &runloop_state_get_ptr()->system; unsigned offset = 0; - cheat_manager_t *cheat_st = &cheat_manager_state; + cheat_manager_t *cheat_st = &cheat_manager_state; #ifdef HAVE_MENU struct menu_state *menu_st = menu_state_get_ptr(); #endif diff --git a/command.c b/command.c index d26ca11a1192..ff962d4d44dc 100644 --- a/command.c +++ b/command.c @@ -67,7 +67,7 @@ #include "version.h" #include "version_git.h" -#define CMD_BUF_SIZE 4096 +#define CMD_BUF_SIZE 4096 static void command_post_state_loaded(void) { @@ -160,8 +160,7 @@ static void command_parse_sub_msg(command_t *handle, const char *tok) RARCH_WARN(msg_hash_to_str(MSG_UNRECOGNIZED_COMMAND), tok); } -static void command_parse_msg( - command_t *handle, char *buf) +static void command_parse_msg(command_t *handle, char *buf) { char *save = NULL; const char *tok = strtok_r(buf, "\n", &save); @@ -235,8 +234,8 @@ command_t* command_network_new(uint16_t port) command_t *cmd = (command_t*)calloc(1, sizeof(*cmd)); command_network_t *netcmd = (command_network_t*)calloc( 1, sizeof(command_network_t)); - int fd = socket_init( - (void**)&res, port, NULL, SOCKET_TYPE_DATAGRAM, AF_INET); + int fd = socket_init((void**)&res, port, NULL, + SOCKET_TYPE_DATAGRAM, AF_INET); RARCH_LOG("[NetCMD]: %s %hu.\n", msg_hash_to_str(MSG_BRINGING_UP_COMMAND_INTERFACE_ON_PORT), @@ -1255,25 +1254,22 @@ bool command_event_resize_windowed_scale(settings_t *settings, return true; } -bool command_event_save_auto_state(void) +size_t command_event_save_auto_state(void) { size_t _len; runloop_state_t *runloop_st = runloop_state_get_ptr(); char savestate_name_auto[PATH_MAX_LENGTH]; - if (runloop_st->entry_state_slot) - return false; + return 0; if (!core_info_current_supports_savestate()) - return false; + return 0; if (string_is_empty(path_basename(path_get(RARCH_PATH_BASENAME)))) - return false; - + return 0; _len = strlcpy(savestate_name_auto, runloop_st->name.savestate, sizeof(savestate_name_auto)); - strlcpy(savestate_name_auto + _len, ".auto", - sizeof(savestate_name_auto) - _len); - + _len += strlcpy(savestate_name_auto + _len, ".auto", + sizeof(savestate_name_auto) - _len); if (content_auto_save_state((const char*)savestate_name_auto)) RARCH_LOG("[State]: %s \"%s\" %s.\n", msg_hash_to_str(MSG_AUTO_SAVE_STATE_TO), @@ -1282,8 +1278,7 @@ bool command_event_save_auto_state(void) RARCH_LOG("[State]: %s \"%s\" %s.\n", msg_hash_to_str(MSG_AUTO_SAVE_STATE_TO), savestate_name_auto, "failed"); - - return true; + return _len; } #ifdef HAVE_CHEATS @@ -1740,25 +1735,23 @@ void command_event_set_replay_garbage_collect( { /* TODO: debugme */ size_t i, cnt = 0; - char state_base[128]; - char state_dir[DIR_MAX_LENGTH]; + char tmp[DIR_MAX_LENGTH]; runloop_state_t *runloop_st = runloop_state_get_ptr(); - struct string_list *dir_list = NULL; unsigned min_idx = UINT_MAX; const char *oldest_save = NULL; /* Similar to command_event_set_replay_auto_index(), * this will find the lowest numbered replay */ - fill_pathname_basedir(state_dir, runloop_st->name.replay, - sizeof(state_dir)); + fill_pathname_basedir(tmp, runloop_st->name.replay, + sizeof(tmp)); - if (!(dir_list = dir_list_new_special(state_dir, + if (!(dir_list = dir_list_new_special(tmp, DIR_LIST_PLAIN, NULL, show_hidden_files))) return; - fill_pathname_base(state_base, runloop_st->name.replay, - sizeof(state_base)); + fill_pathname_base(tmp, runloop_st->name.replay, + sizeof(tmp)); for (i = 0; i < dir_list->size; i++) { @@ -1783,7 +1776,7 @@ void command_event_set_replay_garbage_collect( /* Check whether this file is associated with * the current content */ - if (!string_starts_with(elem_base, state_base)) + if (!string_starts_with(elem_base, tmp)) continue; /* This looks like a valid save */ @@ -1966,17 +1959,11 @@ void command_event_save_current_config(enum override_type type) else { if (runloop_st->flags & RUNLOOP_FLAG_OVERRIDES_ACTIVE) - { _len = strlcpy(msg, msg_hash_to_str(MSG_OVERRIDES_ACTIVE_NOT_SAVING), sizeof(msg)); - runloop_msg_queue_push(msg, _len, 1, 180, true, NULL, - MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); - } else - { _len = command_event_save_config(path_get(RARCH_PATH_CONFIG), msg, sizeof(msg)); - runloop_msg_queue_push(msg, _len, 1, 180, true, NULL, - MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); - } + runloop_msg_queue_push(msg, _len, 1, 180, true, NULL, + MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); } } break; @@ -2061,7 +2048,7 @@ void command_event_remove_current_config(enum override_type type) bool command_event_main_state(unsigned cmd) { char msg[128]; - char state_path[16384]; + char state_path[16384]; /* TODO/FIXME - reduce this */ size_t _len = 0; settings_t *settings = config_get_ptr(); bool savestates_enabled = core_info_current_supports_savestate(); @@ -2081,8 +2068,13 @@ bool command_event_main_state(unsigned cmd) /* TODO: Load state should act in one of three ways: - [X] Not during recording or playback: normally - - [-] During playback: If the state is part of this replay, go back to that state and rewind the replay (not yet implemented); otherwise halt playback and go to that state normally. - - [-] During recording: If the state is part of this replay, go back to that state and rewind the replay, clobbering the stuff in between then and now (not yet implemented); if the state is not part of the replay, do nothing and log a warning. + - [-] During playback: If the state is part of this replay, go back to + that state and rewind the replay (not yet implemented); otherwise + halt playback and go to that state normally. + - [-] During recording: If the state is part of this replay, go back to + that state and rewind the replay, clobbering the stuff in between + then and now (not yet implemented); if the state is not part of + the replay, do nothing and log a warning. */ @@ -2093,7 +2085,8 @@ bool command_event_main_state(unsigned cmd) case CMD_EVENT_SAVE_STATE: case CMD_EVENT_SAVE_STATE_TO_RAM: { - /* TODO: Saving state during recording should associate the state with the replay. */ + /* TODO: Saving state during recording should associate + * the state with the replay. */ video_driver_state_t *video_st = video_state_get_ptr(); bool savestate_auto_index = @@ -2136,7 +2129,11 @@ bool command_event_main_state(unsigned cmd) break; case CMD_EVENT_UNDO_LOAD_STATE: { - /* TODO: To support this through re-recording would take some care around moving the replay recording forward to the time when the undo happened, which would need undo support for replays. For now, forbid it during recording and halt playback. */ + /* TODO: To support this through re-recording would take some + * care around moving the replay recording forward to the time + * when the undo happened, which would need undo support for + * replays. For now, forbid it during recording and halt + * playback. */ #ifdef HAVE_BSV_MOVIE input_driver_state_t *input_st = input_state_get_ptr(); if (input_st->bsv_movie_state.flags & BSV_FLAG_MOVIE_RECORDING) @@ -2179,8 +2176,8 @@ bool command_event_disk_control_append_image( { runloop_state_t *runloop_st = runloop_state_get_ptr(); rarch_system_info_t *sys_info = runloop_st ? (rarch_system_info_t*)&runloop_st->system : NULL; - if ( !sys_info || - !disk_control_append_image(&sys_info->disk_control, path)) + if ( !sys_info + || !disk_control_append_image(&sys_info->disk_control, path)) return false; #ifdef HAVE_THREADS @@ -2230,12 +2227,11 @@ void command_event_reinit(const int flags) video_driver_reinit(flags); /* Poll input to avoid possibly stale data to corrupt things. */ - if ( joypad && joypad->poll) + if (joypad && joypad->poll) joypad->poll(); - if ( sec_joypad && sec_joypad->poll) + if (sec_joypad && sec_joypad->poll) sec_joypad->poll(); - if ( input_st->current_driver && - input_st->current_driver->poll) + if (input_st->current_driver && input_st->current_driver->poll) input_st->current_driver->poll(input_st->current_data); command_event(CMD_EVENT_GAME_FOCUS_TOGGLE, &game_focus_cmd); diff --git a/command.h b/command.h index 5beb361cc5e5..d032d5588225 100644 --- a/command.h +++ b/command.h @@ -341,7 +341,7 @@ void command_event_set_mixer_volume( bool command_event_resize_windowed_scale(settings_t *settings, unsigned window_scale); -bool command_event_save_auto_state(void); +size_t command_event_save_auto_state(void); /** * event_set_volume: diff --git a/core_info.c b/core_info.c index 1a8b6b2e46d7..b4d96d735a64 100644 --- a/core_info.c +++ b/core_info.c @@ -849,8 +849,7 @@ static bool core_info_cache_write(core_info_cache_list_t *list, const char *info sizeof(file_path)); #if defined(CORE_INFO_CACHE_COMPRESS) - file = intfstream_open_rzip_file(file_path, - RETRO_VFS_FILE_ACCESS_WRITE); + file = intfstream_open_rzip_file(file_path, RETRO_VFS_FILE_ACCESS_WRITE); #else file = intfstream_open_file(file_path, RETRO_VFS_FILE_ACCESS_WRITE, @@ -1255,10 +1254,8 @@ bool core_info_cache_force_refresh(const char *path_info) * if required */ if (!path_is_valid(file_path)) { - RFILE *refresh_file = filestream_open( - file_path, - RETRO_VFS_FILE_ACCESS_WRITE, - RETRO_VFS_FILE_ACCESS_HINT_NONE); + RFILE *refresh_file = filestream_open(file_path, + RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!refresh_file) return false; @@ -1402,8 +1399,7 @@ static core_path_list_t *core_info_path_list_new(const char *core_dir, /* Fetch core directory listing */ dir_list_ok = dir_list_append(path_list->dir_list, - core_dir, exts, false, show_hidden_files, - false, false); + core_dir, exts, false, show_hidden_files, false, false); #if defined(__WINRT__) || defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP { @@ -2196,19 +2192,15 @@ static bool core_info_does_support_file( const core_info_t *core, const char *path) { const char *basename, *ext; - if (!core || !core->supported_extensions_list) return false; if (string_is_empty(path)) return false; - basename = path_basename(path); - /* if a core has / in its list of supported extensions, the core supports loading of directories on the host file system */ if (string_is_empty(basename)) return string_list_find_elem(core->supported_extensions_list, "/"); - ext = strrchr(basename, '.'); return string_list_find_elem_prefix( core->supported_extensions_list, ".", (ext ? ext + 1 : "")); @@ -2226,12 +2218,11 @@ static int core_info_qsort_cmp(const void *a_, const void *b_) int support_b = core_info_does_support_file(b, p_coreinfo->tmp_path); #ifdef HAVE_COMPRESSION - support_a = support_a || - core_info_does_support_any_file(a, p_coreinfo->tmp_list); - support_b = support_b || - core_info_does_support_any_file(b, p_coreinfo->tmp_list); + support_a = support_a + || core_info_does_support_any_file(a, p_coreinfo->tmp_list); + support_b = support_b + || core_info_does_support_any_file(b, p_coreinfo->tmp_list); #endif - if (support_a != support_b) return support_b - support_a; return strcasecmp(a->display_name, b->display_name); diff --git a/disk_control_interface.c b/disk_control_interface.c index 19ae7c5c5b97..cec617fb9402 100644 --- a/disk_control_interface.c +++ b/disk_control_interface.c @@ -243,9 +243,9 @@ unsigned disk_control_get_image_index( **/ void disk_control_get_image_label( disk_control_interface_t *disk_control, - unsigned index, char *label, size_t len) + unsigned index, char *s, size_t len) { - if (!label || len < 1) + if (!s || len < 1) return; if (!disk_control) @@ -254,13 +254,13 @@ void disk_control_get_image_label( if (!disk_control->cb.get_image_label) goto error; - if (!disk_control->cb.get_image_label(index, label, len)) + if (!disk_control->cb.get_image_label(index, s, len)) goto error; return; error: - label[0] = '\0'; + s[0] = '\0'; } /***********/ diff --git a/disk_control_interface.h b/disk_control_interface.h index 1efb364d6573..b9bd9d0afa84 100644 --- a/disk_control_interface.h +++ b/disk_control_interface.h @@ -100,7 +100,7 @@ bool disk_control_append_enabled( * * Leaf function. * - * @return true if core supports image labels + * @return true if core supports image labels * - get_image_label **/ bool disk_control_image_label_enabled( @@ -155,7 +155,7 @@ unsigned disk_control_get_image_index( **/ void disk_control_get_image_label( disk_control_interface_t *disk_control, - unsigned index, char *label, size_t len); + unsigned index, char *s, size_t len); /***********/ /* Setters */ diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 9fb01dc3427b..a444676286d7 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2093,8 +2093,12 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list) /* RetroRating Level */ if (frontend->get_rating) { - snprintf(entry, sizeof(entry), "%s: %d", - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_RETRORATING_LEVEL), + _len = strlcpy(entry, + msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_RETRORATING_LEVEL), + sizeof(entry)); + _len += strlcpy(entry + _len, ": ", sizeof(entry) - _len); + snprintf(entry + _len, sizeof(entry) - _len, "%d", frontend->get_rating()); if (menu_entries_append(list, entry, "", MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, @@ -2170,11 +2174,15 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list) video_context_driver_get_ident(&ident_info); /* Video Context Driver */ - snprintf(entry, sizeof(entry), "%s: %s", + _len = strlcpy(entry, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_VIDEO_CONTEXT_DRIVER), + sizeof(entry)); + _len += strlcpy(entry + _len, ": ", sizeof(entry) - _len); + strlcpy(entry + _len, string_is_empty(ident_info.ident) ? msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE) - : ident_info.ident); + : ident_info.ident, + sizeof(entry) - _len); if (menu_entries_append(list, entry, "", MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0, NULL)) @@ -6560,14 +6568,16 @@ static int menu_displaylist_parse_disc_info(file_list_t *info_list, { char drive[2]; char drive_string[NAME_MAX_LENGTH] = {0}; - size_t pos = snprintf(drive_string, sizeof(drive_string), + size_t _len = snprintf(drive_string, sizeof(drive_string), msg_drive_number, i + 1); - pos += snprintf(drive_string + pos, - sizeof(drive_string) - pos, - ": %s", list->elems[i].data); + _len += strlcpy(drive_string + _len, ": ", + sizeof(drive_string) - _len); + strlcpy( drive_string + _len, + list->elems[i].data, + sizeof(drive_string) - _len); - drive[0] = list->elems[i].attr.i; - drive[1] = '\0'; + drive[0] = list->elems[i].attr.i; + drive[1] = '\0'; if (menu_entries_append(info_list, drive_string, drive, MSG_UNKNOWN, @@ -7219,6 +7229,7 @@ unsigned menu_displaylist_build_list( PARSE_ONLY_BOOL, false) == 0) count++; + /* TODO/FIXME - should we dehardcode this? */ if ( string_is_equal(current_input->ident, "android") || (string_is_equal(current_input->ident, "cocoa") && string_is_equal(os_ver, "iOS"))) @@ -13249,29 +13260,27 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, for (i = 0; i < pass_count; i++) { - size_t _len2; - char buf[128]; - snprintf(buf_tmp + _len, sizeof(buf_tmp) - _len, " #%u", i); + size_t _len3; + size_t _len2 = _len + snprintf(buf_tmp + _len, sizeof(buf_tmp) - _len, " #%u", i); if (menu_entries_append(info->list, buf_tmp, shdr_pass, MENU_ENUM_LABEL_VIDEO_SHADER_PASS, MENU_SETTINGS_SHADER_PASS_0 + i, 0, 0, NULL)) count++; - _len2 = strlcpy(buf, buf_tmp, sizeof(buf)); - buf[ _len2] = ' '; - buf[++_len2] = '\0'; - strlcpy(buf + _len2, val_filter, sizeof(buf) - _len2); - if (menu_entries_append(info->list, buf, shdr_filter_pass, + buf_tmp[ _len2] = ' '; + buf_tmp[++_len2] = '\0'; + + _len3 = _len2; + strlcpy(buf_tmp + _len3, val_filter, sizeof(buf_tmp) - _len3); + if (menu_entries_append(info->list, buf_tmp, shdr_filter_pass, MENU_ENUM_LABEL_VIDEO_SHADER_FILTER_PASS, MENU_SETTINGS_SHADER_PASS_FILTER_0 + i, 0, 0, NULL)) count++; - _len2 = strlcpy(buf, buf_tmp, sizeof(buf)); - buf[ _len2] = ' '; - buf[++_len2] = '\0'; - strlcpy(buf + _len2, val_scale, sizeof(buf) - _len2); - if (menu_entries_append(info->list, buf, shdr_scale_pass, + _len3 = _len2; + strlcpy(buf_tmp + _len3, val_scale, sizeof(buf_tmp) - _len3); + if (menu_entries_append(info->list, buf_tmp, shdr_scale_pass, MENU_ENUM_LABEL_VIDEO_SHADER_SCALE_PASS, MENU_SETTINGS_SHADER_PASS_SCALE_0 + i, 0, 0, NULL)) count++; @@ -15164,13 +15173,11 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, case DISPLAYLIST_USER_BINDS_LIST: menu_entries_clear(info->list); { - char lbl[NAME_MAX_LENGTH]; unsigned val = atoi(info->path); const char *temp_val = msg_hash_to_str( (enum msg_hash_enums)(MENU_ENUM_LABEL_INPUT_USER_1_BINDS + (val-1))); - strlcpy(lbl, temp_val, sizeof(lbl)); ret = MENU_DISPLAYLIST_PARSE_SETTINGS(info->list, - lbl, PARSE_NONE, true, MENU_SETTINGS_INPUT_BEGIN); + temp_val, PARSE_NONE, true, MENU_SETTINGS_INPUT_BEGIN); info->flags |= MD_FLAG_NEED_REFRESH | MD_FLAG_NEED_PUSH; } @@ -15284,7 +15291,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, } if (!string_is_empty(info->exts)) free(info->exts); - info->exts = strdup(new_exts); + info->exts = strdup(new_exts); use_filebrowser = true; } #endif diff --git a/playlist.c b/playlist.c index ab5e582ce3d6..7b029219ae22 100644 --- a/playlist.c +++ b/playlist.c @@ -194,43 +194,40 @@ playlist_config_t *playlist_get_config(playlist_t *playlist) { if (!playlist) return NULL; - return &playlist->config; } static void path_replace_base_path_and_convert_to_local_file_system( - char *out_path, + char *s, const char *in_path, - const char *in_oldrefpath, - const char *in_refpath, - size_t size) + const char *in_oldrefpath, const char *in_refpath, + size_t len) { size_t in_oldrefpath_length = strlen(in_oldrefpath); - /* If entry path is inside playlist base path, * replace it with new base content directory */ if (string_starts_with_size(in_path, in_oldrefpath, in_oldrefpath_length)) { size_t in_refpath_length = strlen(in_refpath); - memcpy(out_path, in_refpath, in_refpath_length); + memcpy(s, in_refpath, in_refpath_length); memcpy( - out_path + in_refpath_length, - in_path + in_oldrefpath_length, + s + in_refpath_length, + in_path + in_oldrefpath_length, strlen(in_path) - in_oldrefpath_length + 1); #ifdef _WIN32 /* If we are running under a Windows filesystem, * '/' characters are not allowed anywhere. * We replace with '\' and hope for the best... */ - string_replace_all_chars(out_path, + string_replace_all_chars(s, POSIX_PATH_DELIMITER, WINDOWS_PATH_DELIMITER); #else /* Under POSIX filesystem, we replace '\' characters with '/' */ - string_replace_all_chars(out_path, + string_replace_all_chars(s, WINDOWS_PATH_DELIMITER, POSIX_PATH_DELIMITER); #endif } else - strlcpy(out_path, in_path, size); + strlcpy(s, in_path, len); } /* Generates a case insensitive hash for the @@ -2980,7 +2977,8 @@ playlist_t *playlist_init(const playlist_config_t *config) tmp_entry_path[0] = '\0'; path_replace_base_path_and_convert_to_local_file_system( tmp_entry_path, entry->path, - playlist->base_content_directory, playlist->config.base_content_directory, + playlist->base_content_directory, + playlist->config.base_content_directory, sizeof(tmp_entry_path)); free(entry->path); diff --git a/runloop.c b/runloop.c index cf7878eace0b..9a6dc93aecf6 100644 --- a/runloop.c +++ b/runloop.c @@ -1192,8 +1192,8 @@ static bool validate_folder_specific_options(char *s, size_t len) **/ static void runloop_init_core_options_path( settings_t *settings, - char *s, size_t len, - char *src_path, size_t src_len) + char *s, size_t len, + char *s2, size_t len2) { runloop_state_t *runloop_st = &runloop_state; bool game_specific_options = settings->bools.game_specific_options; @@ -1250,11 +1250,9 @@ static void runloop_init_core_options_path( if ( !per_core_options || !per_core_options_exist) { - const char *options_path = path_core_options; - - if (!string_is_empty(options_path)) + if (!string_is_empty(path_core_options)) strlcpy(global_options_path, - options_path, sizeof(global_options_path)); + path_core_options, sizeof(global_options_path)); else if (!path_is_empty(RARCH_PATH_CONFIG)) fill_pathname_resolve_relative( global_options_path, path_get(RARCH_PATH_CONFIG), @@ -1266,7 +1264,7 @@ static void runloop_init_core_options_path( { strlcpy(s, per_core_options_path, len); if (!per_core_options_exist) - strlcpy(src_path, global_options_path, src_len); + strlcpy(s2, global_options_path, len2); } else strlcpy(s, global_options_path, len); diff --git a/runtime_file.c b/runtime_file.c index 94ddd01b27f0..6a202a931690 100644 --- a/runtime_file.c +++ b/runtime_file.c @@ -324,9 +324,7 @@ runtime_log_t *runtime_log_init( * content has the same name... */ else if (string_is_equal(core_name, "TyrQuake")) { - const char *slash = strrchr(content_path, '/'); - const char *backslash = strrchr(content_path, '\\'); - const char *last_slash = (!slash || (backslash > slash)) ? (char*)backslash : (char*)slash; + char *last_slash = find_last_slash(content_path); if (last_slash) { size_t path_length = last_slash + 1 - content_path; diff --git a/save.c b/save.c index 41e10084fe6c..f282369985e9 100644 --- a/save.c +++ b/save.c @@ -522,9 +522,7 @@ bool event_save_files(bool is_sram_used) return false; for (i = 0; i < task_save_files->size; i++) - { content_save_ram_file(i, compress_files); - } return true; } diff --git a/tasks/task_autodetect.c b/tasks/task_autodetect.c index 1d5086c79faf..daaee066ce4b 100644 --- a/tasks/task_autodetect.c +++ b/tasks/task_autodetect.c @@ -202,10 +202,9 @@ static void input_autoconfigure_set_config_file( autoconfig_handle_t *autoconfig_handle, config_file_t *config, unsigned alternative) { - struct config_entry_list *entry = NULL; - char config_key[32] = {0}; - char config_key_postfix[7] = {0}; size_t _len; + char config_key[32]; + struct config_entry_list *entry = NULL; /* Attach config file */ autoconfig_handle->autoconfig_file = config; @@ -220,16 +219,13 @@ static void input_autoconfigure_set_config_file( sizeof(autoconfig_handle->device_info.config_name)); } - /* Read device display name */ - if (alternative > 0) - snprintf(config_key_postfix, sizeof(config_key_postfix), - "_alt%d",alternative); - /* Parse config file */ _len = strlcpy(config_key, "input_device_display_name", sizeof(config_key)); - _len += strlcpy(config_key + _len, config_key_postfix, - sizeof(config_key) - _len); + /* Read device display name */ + if (alternative > 0) + _len += snprintf(config_key + _len, sizeof(config_key) - _len, + "_alt%d",alternative); if ( (entry = config_get_entry(config, config_key)) && !string_is_empty(entry->value)) @@ -483,12 +479,12 @@ static void reallocate_port_if_needed(unsigned detected_port, int vendor_id, strlcpy(settings_value_device_name, settings_value, sizeof(settings_value_device_name)); device_has_reserved_slot = - string_is_equal(device_name, settings_value_device_name) || - string_is_equal(device_display_name, settings_value_device_name); + string_is_equal(device_name, settings_value_device_name) + || string_is_equal(device_display_name, settings_value_device_name); } else - device_has_reserved_slot = (vendor_id == settings_value_vendor_id && - product_id == settings_value_product_id); + device_has_reserved_slot = ( vendor_id == settings_value_vendor_id + && product_id == settings_value_product_id); if (device_has_reserved_slot) { From e982905eb4f705f73599a5a700f01e7d039a5215 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Fri, 17 Jan 2025 00:55:30 +0100 Subject: [PATCH 26/49] content_get_subsystem_friendly_name - change function signature return to size_t --- content.h | 2 +- tasks/task_content.c | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/content.h b/content.h index 776126cf5150..612bc4e185e7 100644 --- a/content.h +++ b/content.h @@ -135,7 +135,7 @@ char* content_get_subsystem_rom(unsigned index); bool content_set_subsystem_by_name(const char* subsystem_name); /* Get the current subsystem "friendly name" */ -void content_get_subsystem_friendly_name(const char* subsystem_name, char* subsystem_friendly_name, size_t len); +size_t content_get_subsystem_friendly_name(const char* subsystem_name, char *s, size_t len); /* Sets overrides which modify frontend handling of * specific content file types */ diff --git a/tasks/task_content.c b/tasks/task_content.c index ef7ff7f29e84..5c93ed43be71 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -2865,26 +2865,22 @@ bool content_set_subsystem_by_name(const char* subsystem_name) return false; } -void content_get_subsystem_friendly_name(const char* subsystem_name, char *s, size_t len) +size_t content_get_subsystem_friendly_name(const char* subsystem_name, char *s, size_t len) { - unsigned i = 0; + unsigned i; runloop_state_t *runloop_st = runloop_state_get_ptr(); rarch_system_info_t *sys_info = &runloop_st->system; /* Core not loaded completely, use the data we peeked on load core */ const struct retro_subsystem_info *subsystem = runloop_st->subsystem_data; - /* Core fully loaded, use the subsystem data */ if (sys_info->subsystem.data) subsystem = sys_info->subsystem.data; - for (i = 0; i < runloop_st->subsystem_current_count; i++, subsystem++) { if (string_is_equal(subsystem_name, subsystem->ident)) - { - strlcpy(s, subsystem->desc, len); - break; - } + return strlcpy(s, subsystem->desc, len); } + return 0; } /* Add a rom to the subsystem ROM buffer */ From e4d76842468e584d97bf73d24f5e427d32ae3f67 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Fri, 17 Jan 2025 01:01:43 +0100 Subject: [PATCH 27/49] Less string copies in fill_pathname_expanded_and_absolute --- gfx/video_shader_parse.c | 66 +++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 38 deletions(-) diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 043b3905a2ee..a4cbff748468 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -109,21 +109,12 @@ static path_change_data_t *file_change_data = NULL; static void fill_pathname_expanded_and_absolute(char *s, size_t len, const char *in_refpath, const char *in_path) { - char expanded_path[PATH_MAX_LENGTH]; - - expanded_path[0] = '\0'; - /* Expand paths which start with :\ to an absolute path */ - fill_pathname_expand_special(expanded_path, - in_path, sizeof(expanded_path)); - + fill_pathname_expand_special(s, in_path, len); /* Resolve the reference path relative to the config */ - if (path_is_absolute(expanded_path)) - strlcpy(s, expanded_path, len); - else + if (!path_is_absolute(s)) fill_pathname_resolve_relative(s, in_refpath, in_path, len); - pathname_conform_slashes_to_os(s); } @@ -471,14 +462,11 @@ static void video_shader_gather_reference_path_list( while (ref_tmp) { char* reference_preset_path = (char*)malloc(PATH_MAX_LENGTH); - /* Get the absolute path and replace wildcards in the path */ fill_pathname_expanded_and_absolute(reference_preset_path, PATH_MAX_LENGTH, conf->path, ref_tmp->path); /* TODO/FIXME - dehardcode PATH_MAX_LENGTH */ video_shader_replace_wildcards(reference_preset_path, PATH_MAX_LENGTH, conf->path); - video_shader_gather_reference_path_list(in_path_linked_list, reference_preset_path, reference_depth + 1); - free(reference_preset_path); ref_tmp = ref_tmp->next; } @@ -825,9 +813,11 @@ static bool video_shader_parse_textures(config_file_t *conf, config_get_path(conf, id, texture_path, sizeof(texture_path)); /* Get the absolute path and replace wildcards in the path */ - fill_pathname_expanded_and_absolute(shader->lut[shader->luts].path, PATH_MAX_LENGTH, conf->path, texture_path); + fill_pathname_expanded_and_absolute(shader->lut[shader->luts].path, + PATH_MAX_LENGTH, conf->path, texture_path); /* TODO/FIXME - dehardcode PATH_MAX_LENGTH */ - video_shader_replace_wildcards(shader->lut[shader->luts].path, PATH_MAX_LENGTH, conf->path); + video_shader_replace_wildcards(shader->lut[shader->luts].path, + PATH_MAX_LENGTH, conf->path); strlcpy(shader->lut[shader->luts].id, id, sizeof(shader->lut[shader->luts].id)); @@ -1297,9 +1287,11 @@ static config_file_t *video_shader_get_root_preset_config(const char *path) } /* Get the absolute path and replace wildcards in the path */ - fill_pathname_expanded_and_absolute(nested_reference_path, PATH_MAX_LENGTH, conf->path, conf->references->path); + fill_pathname_expanded_and_absolute(nested_reference_path, + PATH_MAX_LENGTH, conf->path, conf->references->path); /* TODO/FIXME - dehardcode PATH_MAX_LENGTH */ - video_shader_replace_wildcards(nested_reference_path, PATH_MAX_LENGTH, conf->path); + video_shader_replace_wildcards(nested_reference_path, + PATH_MAX_LENGTH, conf->path); /* Create a new config from the referenced path */ config_file_free(conf); @@ -1384,12 +1376,15 @@ static bool video_shader_check_reference_chain_for_save( } /* Get the absolute path and replace wildcards in the path */ - fill_pathname_expanded_and_absolute(nested_ref_path, PATH_MAX_LENGTH, conf->path, conf->references->path); + fill_pathname_expanded_and_absolute(nested_ref_path, + PATH_MAX_LENGTH, conf->path, conf->references->path); /* TODO/FIXME - dehardcode PATH_MAX_LENGTH */ - video_shader_replace_wildcards(nested_ref_path, PATH_MAX_LENGTH, conf->path); + video_shader_replace_wildcards(nested_ref_path, + PATH_MAX_LENGTH, conf->path); - /* If one of the reference paths is the same as the file we want to save then this reference chain would be - * self-referential / cyclical and we can't save this as a simple preset*/ + /* If one of the reference paths is the same as the file we want to save, + * then this reference chain would be self-referential / cyclical and + * we can't save this as a simple preset */ if (string_is_equal(nested_ref_path, path_to_save_conformed)) { RARCH_WARN("[Shaders]: Saving preset:\n" @@ -2063,23 +2058,22 @@ static bool video_shader_override_values(config_file_t *override_conf, if (config_get_entry(override_conf, shader->lut[i].id)) { char *tex_path = (char*)malloc(PATH_MAX_LENGTH); - /* Texture path from the config */ - config_get_path(override_conf, shader->lut[i].id, tex_path, PATH_MAX_LENGTH); - + config_get_path(override_conf, shader->lut[i].id, tex_path, + PATH_MAX_LENGTH); /* Get the absolute path and replace wildcards in the path */ - fill_pathname_expanded_and_absolute(override_tex_path, PATH_MAX_LENGTH, override_conf->path, tex_path); + fill_pathname_expanded_and_absolute(override_tex_path, + PATH_MAX_LENGTH, override_conf->path, tex_path); /* TODO/FIXME - dehardcode PATH_MAX_LENGTH */ - video_shader_replace_wildcards(override_tex_path, PATH_MAX_LENGTH, override_conf->path); - - strlcpy(shader->lut[i].path, override_tex_path, sizeof(shader->lut[i].path)); - + video_shader_replace_wildcards(override_tex_path, + PATH_MAX_LENGTH, override_conf->path); + strlcpy(shader->lut[i].path, override_tex_path, + sizeof(shader->lut[i].path)); #ifdef DEBUG RARCH_DBG("[Shaders]: Texture: \"%s\" = %s.\n", shader->lut[i].id, shader->lut[i].path); #endif - free(tex_path); return_val = true; } @@ -2283,7 +2277,6 @@ bool video_shader_load_preset_into_shader(const char *path, { config_file_t *tmp_conf = NULL; char *path_to_ref = (char*)malloc(PATH_MAX_LENGTH); - /* Get the absolute path and replace wildcards in the path */ fill_pathname_expanded_and_absolute(path_to_ref, PATH_MAX_LENGTH, conf->path, path_list_tmp->path); @@ -2295,8 +2288,7 @@ bool video_shader_load_preset_into_shader(const char *path, /* Check if the config is a valid shader chain config If the config has a shaders entry then it is considered a shader chain config, vs a config which may only have - parameter values and texture overrides - */ + parameter values and texture overrides */ if (config_get_entry(tmp_conf, "shaders")) { RARCH_WARN("\n[Shaders]: Additional #reference entries pointing at shader chain presets are not supported: \"%s\".\n", path_to_ref); @@ -2329,10 +2321,8 @@ bool video_shader_load_preset_into_shader(const char *path, override_paths_list = path_linked_list_new(); video_shader_gather_reference_path_list(override_paths_list, conf->path, 0); - /* - * Step through the references and apply overrides for each one - * Start on the second item since the first is empty - */ + /* Step through the references and apply overrides for each one + * Start on the second item since the first is empty */ path_list_tmp = (struct path_linked_list*)override_paths_list; while (path_list_tmp) { From 1975235fd7ef40b536c8bf02fd00e3340d80ec4c Mon Sep 17 00:00:00 2001 From: github-actions Date: Fri, 17 Jan 2025 00:14:25 +0000 Subject: [PATCH 28/49] Fetch translations from Crowdin --- intl/msg_hash_be.h | 30 +++++++++++++++++++----------- intl/msg_hash_es.h | 18 +++++++++++++----- intl/msg_hash_ru.h | 8 ++++++++ intl/msg_hash_tr.h | 8 ++++++++ intl/progress.h | 16 ++++++++-------- 5 files changed, 56 insertions(+), 24 deletions(-) diff --git a/intl/msg_hash_be.h b/intl/msg_hash_be.h index 252b27608be9..d970a09c8f2f 100644 --- a/intl/msg_hash_be.h +++ b/intl/msg_hash_be.h @@ -3836,7 +3836,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_INPUT_META_REWIND_HOTKEY, - "Зваротная перамотка кантэнту пры ўтрыманні кнопкі. Павінна быць уключана 'Падтрымка перамоткі'." + "Перамотка назад бягучага змесціва пры ўтрыманні кнопкі. Мае быць уключана 'Падтрымка перамоткі назад'." ) MSG_HASH( MENU_ENUM_LABEL_VALUE_INPUT_META_PAUSE_TOGGLE, @@ -5058,7 +5058,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_SLOWMOTION_RATIO, - "Хуткасць кантэнту пры выкарыстанні функцыі запавольвання." + "Хуткасць змесціва пры выкарыстанні функцыі запаволенага руху." ) MSG_HASH( MENU_ENUM_LABEL_VALUE_MENU_ENUM_THROTTLE_FRAMERATE, @@ -5085,7 +5085,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_REWIND_GRANULARITY, - "Колькасць кадраў перамоткі за адзін крок. Больш высокія значэнні павялічваюць хуткасць перамоткі." + "Колькасць кадраў перамоткі назад на крок. Больш высокія значэнні павялічваюць хуткасць перамоткі назад." ) MSG_HASH( MENU_ENUM_LABEL_VALUE_REWIND_BUFFER_SIZE, @@ -7194,7 +7194,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_CHEEVOS_HARDCORE_MODE_ENABLE, - "Адключае чыты, перамотку, запаволенне і загрузку захаванняў стану. Дасягненні ў рэжыме хардкора маюць спецыяльную пазнаку, каб паказаць іншым гульцам вашыя навыкі без магчымасцяў эмулятара. Пераключэнне наладкі падчас гульні прывядзе да яе перазапуску." + "Адключае чыты, перамотку, запаволены рух ды загрузку захаванняў стану. Дасягненні ў рэжыме хардкора маюць спецыяльную пазнаку, каб паказаць іншым гульцам вашыя навыкі без магчымасцяў эмулятара. Пераключэнне наладкі падчас гульні прывядзе да яе перазапуску." ) MSG_HASH( MENU_ENUM_LABEL_VALUE_CHEEVOS_LEADERBOARDS_ENABLE, @@ -10160,7 +10160,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_ACHIEVEMENT_PAUSE, - "Прыпыняе рэжым хардкора для дасягненняў у бягучым сеансе. Дадзенае дзеянне актывуе чыт-коды, перамотку, запавольванне і загрузку захаванняў." + "Прыпыняе хардкор рэжым дасягненняў у бягучым сеансе. Гэтае дзеянне актывуе чыт-коды, перамотку, запавольваны рух ды загрузку станаў." ) MSG_HASH( MENU_ENUM_LABEL_VALUE_ACHIEVEMENT_RESUME, @@ -10168,7 +10168,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_ACHIEVEMENT_RESUME, - "Аднаўляе дасягненні ў рэжыме хардкора для бягучага сеансу. Дадзенае дзеянне адключыць чыт-коды, перамотку, запавольванне, загрузку захаванняў і перазапусціць гульню." + "Аднаўляе дасягненні ў хардкор рэжыме на бягучы сеанс. Гэтае дзеянне адключае чыт-коды, перамотку назад, запавольванне, загрузку захаванняў стану і перазапускае гульню." ) MSG_HASH( MENU_ENUM_LABEL_VALUE_ACHIEVEMENT_SERVER_UNREACHABLE, @@ -14329,7 +14329,7 @@ MSG_HASH( ) MSG_HASH( MSG_REWIND_UNSUPPORTED, - "Зваротная перамотка недаступная праз адсутнасць у ядры серыялізаванай падтрымкі захавання стану." + "Перамотка назад недаступная праз адсутнасць у ядры серыялізаванай падтрымкі захавання стану." ) MSG_HASH( MSG_REWIND_INIT, @@ -14865,15 +14865,23 @@ MSG_HASH( ) MSG_HASH( MSG_CHEEVOS_LOAD_STATE_PREVENTED_BY_HARDCORE_MODE, - "Для загрузкі захаванняў патрабуецца адключыць ці прыпыніць Рэжым хардкора для дасягненняў." + "Загрузка станаў патрабуе адключэння ці прыпынення хардкор рэжыму дасягненняў." ) MSG_HASH( MSG_CHEEVOS_HARDCORE_MODE_DISABLED, - "Загружана захаванне стану. Для бягучага сеанса дасягненняў рэжым хардкору адключаны." + "Загружана захаванне стану. Хардкор рэжым дасягненняў у бягучым сеансе адключаны." ) MSG_HASH( MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT, - "Актываваны чыт-код. Рэжым харкдора для дасягненняў у бягучым сеансе адключаны." + "Актываваны чыт-код. Хардкор рэжым дасягненняў у бягучым сеансе адключаны." + ) +MSG_HASH( + MSG_CHEEVOS_HARDCORE_MODE_CHANGED_BY_HOST, + "Хардкор рэжым дасягненняў зменены хастом." + ) +MSG_HASH( + MSG_CHEEVOS_HARDCORE_MODE_REQUIRES_NEWER_HOST, + "Трэба абнавіць хост сеткавай гульні. Хардкор рэжым дасягненняў у бягучым сеансе адключаны." ) MSG_HASH( MSG_CHEEVOS_MASTERED_GAME, @@ -14885,7 +14893,7 @@ MSG_HASH( ) MSG_HASH( MSG_CHEEVOS_HARDCORE_MODE_ENABLE, - "Уключаны рэжым хардкору, захаванне стану ды перамотка назад адключаныя." + "Уключаны хардкор рэжым, захаванне стану ды перамотка назад адключаныя." ) MSG_HASH( MSG_CHEEVOS_GAME_HAS_NO_ACHIEVEMENTS, diff --git a/intl/msg_hash_es.h b/intl/msg_hash_es.h index 010ac03ab122..8bce37041e4f 100644 --- a/intl/msg_hash_es.h +++ b/intl/msg_hash_es.h @@ -14795,6 +14795,14 @@ MSG_HASH( MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT, "Se ha activado un truco. Los logros Hardcore han sido desactivados para esta sesión." ) +MSG_HASH( + MSG_CHEEVOS_HARDCORE_MODE_CHANGED_BY_HOST, + "Logros Hardcore cambiados por el servidor." + ) +MSG_HASH( + MSG_CHEEVOS_HARDCORE_MODE_REQUIRES_NEWER_HOST, + "El servidor de juego en red necesita una actualización. Los logros Hardcore han sido desactivados para esta sesión." + ) MSG_HASH( MSG_CHEEVOS_MASTERED_GAME, "Has dominado %s" @@ -14833,23 +14841,23 @@ MSG_HASH( ) MSG_HASH( MSG_CHEEVOS_HARDCORE_PAUSED_MANUAL_FRAME_DELAY, - "Modo «hardcore» pausado. No se permite ajustar manualmente el retraso en los fotogramas de vídeo." + "Modo Hardcore pausado. No se permite ajustar manualmente el retraso en los fotogramas de vídeo." ) MSG_HASH( MSG_CHEEVOS_HARDCORE_PAUSED_VSYNC_SWAP_INTERVAL, - "Modo «hardcore» pausado. No se permite un valor de intercambio de sincronía vertical superior a 1." + "Modo Hardcore pausado. No se permite un valor de intercambio de sincronía vertical superior a 1." ) MSG_HASH( MSG_CHEEVOS_HARDCORE_PAUSED_BLACK_FRAME_INSERTION, - "Modo «hardcore» pausado. No se permite insertar fotogramas negros." + "Modo Hardcore pausado. No se permite insertar fotogramas negros." ) MSG_HASH( MSG_CHEEVOS_HARDCORE_PAUSED_SETTING_NOT_ALLOWED, - "Modo «hardcore» pausado. Ajuste no permitido: %s=%s" + "Modo Hardcore pausado. Ajuste no permitido: %s=%s" ) MSG_HASH( MSG_CHEEVOS_HARDCORE_PAUSED_SYSTEM_NOT_FOR_CORE, - "Modo «hardcore» pausado. No puedes desbloquear logros «hardcore» de %s con %s" + "Modo Hardcore pausado. No puedes desbloquear logros Hardcore de %s con %s" ) MSG_HASH( MSG_CHEEVOS_GAME_NOT_IDENTIFIED, diff --git a/intl/msg_hash_ru.h b/intl/msg_hash_ru.h index 33ac5391e7bb..2df7fac37949 100644 --- a/intl/msg_hash_ru.h +++ b/intl/msg_hash_ru.h @@ -14839,6 +14839,14 @@ MSG_HASH( MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT, "Активирован чит-код. Режим харкдора для достижений в текущем сеансе отключен." ) +MSG_HASH( + MSG_CHEEVOS_HARDCORE_MODE_CHANGED_BY_HOST, + "Режим хардкора для достижений изменён хостом." + ) +MSG_HASH( + MSG_CHEEVOS_HARDCORE_MODE_REQUIRES_NEWER_HOST, + "Требуется обновить хост сетевой игры. Режим хардкора для достижений отключен в текущем сеансе." + ) MSG_HASH( MSG_CHEEVOS_MASTERED_GAME, "Завершено %s" diff --git a/intl/msg_hash_tr.h b/intl/msg_hash_tr.h index 6e77dde53f6f..b7b185fcf4c0 100644 --- a/intl/msg_hash_tr.h +++ b/intl/msg_hash_tr.h @@ -14887,6 +14887,14 @@ MSG_HASH( MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT, "Bir hile etkinleştirildi. Başarılar mevcut oturum için Zorlu Kip devre dışı bırakıldı." ) +MSG_HASH( + MSG_CHEEVOS_HARDCORE_MODE_CHANGED_BY_HOST, + "Başarımlar Zorlu Mod, sunucu tarafından değiştirildi." + ) +MSG_HASH( + MSG_CHEEVOS_HARDCORE_MODE_REQUIRES_NEWER_HOST, + "Netplay ana bilgisayarının güncellenmesi gerekiyor. Başarımlar Zorlu Mod mevcut oturum için devre dışı bırakıldı." + ) MSG_HASH( MSG_CHEEVOS_MASTERED_GAME, "Ustalıkla %s" diff --git a/intl/progress.h b/intl/progress.h index 10000ddf66f1..69c5f5fc454a 100644 --- a/intl/progress.h +++ b/intl/progress.h @@ -31,7 +31,7 @@ #define LANGUAGE_PROGRESS_DANISH_APPROVED 0 /* German */ -#define LANGUAGE_PROGRESS_GERMAN_TRANSLATED 100 +#define LANGUAGE_PROGRESS_GERMAN_TRANSLATED 99 #define LANGUAGE_PROGRESS_GERMAN_APPROVED 14 /* Greek */ @@ -59,11 +59,11 @@ #define LANGUAGE_PROGRESS_FINNISH_APPROVED 46 /* French */ -#define LANGUAGE_PROGRESS_FRENCH_TRANSLATED 100 -#define LANGUAGE_PROGRESS_FRENCH_APPROVED 100 +#define LANGUAGE_PROGRESS_FRENCH_TRANSLATED 99 +#define LANGUAGE_PROGRESS_FRENCH_APPROVED 99 /* Galician */ -#define LANGUAGE_PROGRESS_GALICIAN_TRANSLATED 99 +#define LANGUAGE_PROGRESS_GALICIAN_TRANSLATED 98 #define LANGUAGE_PROGRESS_GALICIAN_APPROVED 0 /* Hebrew */ @@ -75,7 +75,7 @@ #define LANGUAGE_PROGRESS_CROATIAN_APPROVED 0 /* Hungarian */ -#define LANGUAGE_PROGRESS_HUNGARIAN_TRANSLATED 100 +#define LANGUAGE_PROGRESS_HUNGARIAN_TRANSLATED 99 #define LANGUAGE_PROGRESS_HUNGARIAN_APPROVED 0 /* Indonesian */ @@ -83,7 +83,7 @@ #define LANGUAGE_PROGRESS_INDONESIAN_APPROVED 0 /* Italian */ -#define LANGUAGE_PROGRESS_ITALIAN_TRANSLATED 100 +#define LANGUAGE_PROGRESS_ITALIAN_TRANSLATED 99 #define LANGUAGE_PROGRESS_ITALIAN_APPROVED 0 /* Japanese */ @@ -91,7 +91,7 @@ #define LANGUAGE_PROGRESS_JAPANESE_APPROVED 0 /* Korean */ -#define LANGUAGE_PROGRESS_KOREAN_TRANSLATED 100 +#define LANGUAGE_PROGRESS_KOREAN_TRANSLATED 99 #define LANGUAGE_PROGRESS_KOREAN_APPROVED 0 /* Dutch */ @@ -143,7 +143,7 @@ #define LANGUAGE_PROGRESS_TATAR_APPROVED 0 /* Ukrainian */ -#define LANGUAGE_PROGRESS_UKRAINIAN_TRANSLATED 100 +#define LANGUAGE_PROGRESS_UKRAINIAN_TRANSLATED 99 #define LANGUAGE_PROGRESS_UKRAINIAN_APPROVED 7 /* Valencian */ From a9b0e45013e42d8fd0c03a5779a4b3594cf63ae7 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Fri, 17 Jan 2025 03:01:33 +0100 Subject: [PATCH 29/49] (glslang_utill.c) One less string copy per iteration --- file_path_special.c | 2 +- gfx/drivers_shader/glslang_util.c | 18 ++++++------------ libretro-common/encodings/encoding_utf.c | 2 +- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/file_path_special.c b/file_path_special.c index b8167068ff73..78007d073835 100644 --- a/file_path_special.c +++ b/file_path_special.c @@ -146,7 +146,7 @@ bool fill_pathname_application_data(char *s, size_t len) if (appdata) { fill_pathname_join(s, appdata, - "Library/Application Support/RetroArch", len); + "Library/Application Support/RetroArch", len); return true; } #endif diff --git a/gfx/drivers_shader/glslang_util.c b/gfx/drivers_shader/glslang_util.c index 4bb3a8e49617..d5281d331332 100644 --- a/gfx/drivers_shader/glslang_util.c +++ b/gfx/drivers_shader/glslang_util.c @@ -28,17 +28,17 @@ #include "glslang_util.h" #include "../../verbosity.h" -static void get_include_file(const char *line, char *s, size_t len) +static char *slang_get_include_file(const char *line) { char *end = NULL; char *start = (char*)strchr(line, '\"'); if (!start) - return; + return NULL; start++; if (!(end = (char*)strchr(start, '\"'))) - return; + return NULL; *end = '\0'; - strlcpy(s, start, len); + return start; } bool slang_texture_semantic_is_array(enum slang_texture_semantic sem) @@ -193,15 +193,8 @@ bool glslang_read_shader_file(const char *path, bool include_optional = !strncmp("#pragma include_optional ", line, STRLEN_CONST("#pragma include_optional ")); if ( !strncmp("#include ", line, STRLEN_CONST("#include ")) || include_optional ) { - - char include_file[PATH_MAX_LENGTH]; char include_path[PATH_MAX_LENGTH]; - - include_file[0] = '\0'; - include_path[0] = '\0'; - - /* Build include file path */ - get_include_file(line, include_file, sizeof(include_file)); + char *include_file = slang_get_include_file(line); if (string_is_empty(include_file)) { @@ -209,6 +202,7 @@ bool glslang_read_shader_file(const char *path, goto error; } + include_path[0] = '\0'; fill_pathname_resolve_relative( include_path, path, include_file, sizeof(include_path)); diff --git a/libretro-common/encodings/encoding_utf.c b/libretro-common/encodings/encoding_utf.c index f204e57b5248..fd04c1c290e6 100644 --- a/libretro-common/encodings/encoding_utf.c +++ b/libretro-common/encodings/encoding_utf.c @@ -185,7 +185,7 @@ size_t utf8cpy(char *d, size_t d_len, const char *s, size_t chars) sb++; } - if ((size_t)(sb - sb_org) > d_len-1 /* NUL */) + if ((size_t)(sb - sb_org) > d_len-1) { sb = sb_org + d_len-1; while ((*sb & 0xC0) == 0x80) From 9b5007aefdd26948904a27a74e3e6b1b3400dbf5 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Fri, 17 Jan 2025 03:39:30 +0100 Subject: [PATCH 30/49] (manual_content_scan) USe fill_pathname --- manual_content_scan.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/manual_content_scan.c b/manual_content_scan.c index 43c3f96e6105..e3813445335a 100644 --- a/manual_content_scan.c +++ b/manual_content_scan.c @@ -923,7 +923,6 @@ bool manual_content_scan_get_task_config( manual_content_scan_task_config_t *task_config, const char *path_dir_playlist) { - size_t _len; if (!task_config) return false; @@ -983,13 +982,11 @@ bool manual_content_scan_get_task_config( /* Now we have a valid system name, can generate * a 'database' name... */ - _len = strlcpy( + fill_pathname( task_config->database_name, task_config->system_name, - sizeof(task_config->database_name)); - strlcpy(task_config->database_name + _len, ".lpl", - sizeof(task_config->database_name) - _len); + sizeof(task_config->database_name)); /* ...which can in turn be used to generate the * playlist path */ From 31b78127209aaf8c8f8d0a724d53d1911b8d3ff8 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Fri, 17 Jan 2025 04:16:12 +0100 Subject: [PATCH 31/49] Function argument name standardization --- cheevos/cheevos_client.c | 14 +++---- gfx/common/vulkan_common.c | 31 +++++++-------- gfx/drivers_shader/shader_vulkan.cpp | 8 ++-- gfx/video_driver.c | 9 ++--- input/connect/connect_retrode.c | 8 ++-- input/connect/connect_wiiugca.c | 11 +++--- input/input_keymaps.c | 10 ++--- input/input_keymaps.h | 4 +- libretro-common/file/archive_file_7z.c | 12 +++--- libretro-common/file/config_file.c | 10 ++--- libretro-common/file/file_path.c | 4 +- libretro-common/formats/png/rpng_encode.c | 33 ++++++++-------- libretro-common/memmap/memalign.c | 14 +++---- libretro-common/net/net_socket.c | 48 +++++++++++------------ libretro-common/queues/fifo_queue.c | 34 ++++++++-------- libretro-common/queues/message_queue.c | 12 +++--- libretro-common/streams/network_stream.c | 16 ++++---- libretro-db/query.c | 7 ++-- menu/menu_driver.c | 4 +- menu/menu_explore.c | 24 ++++++------ network/netplay/netplay_frontend.c | 44 ++++++++++----------- runahead.c | 9 ++--- runloop.c | 4 +- save.c | 4 +- tasks/task_content.c | 10 ++--- tasks/task_overlay.c | 13 +++--- 26 files changed, 187 insertions(+), 210 deletions(-) diff --git a/cheevos/cheevos_client.c b/cheevos/cheevos_client.c index 1f8e480d1fea..77206c92c0f3 100644 --- a/cheevos/cheevos_client.c +++ b/cheevos/cheevos_client.c @@ -289,20 +289,20 @@ static void rcheevos_client_http_task_save_callback(retro_task_t* task, void rcheevos_client_http_load_response(const rc_api_request_t* request, rc_client_server_callback_t callback, void* callback_data) { - size_t size = 0; char* contents; - FILE* file = fopen(CHEEVOS_JSON_OVERRIDE, "rb"); + size_t _len = 0; + FILE* file = fopen(CHEEVOS_JSON_OVERRIDE, "rb"); fseek(file, 0, SEEK_END); - size = ftell(file); + _len = ftell(file); fseek(file, 0, SEEK_SET); - contents = (char*)malloc(size + 1); - fread((void*)contents, 1, size, file); + contents = (char*)malloc(_len + 1); + fread((void*)contents, 1, _len, file); fclose(file); - contents[size] = 0; - CHEEVOS_LOG(RCHEEVOS_TAG "Loaded game info. Read %u bytes to %s\n", size, CHEEVOS_JSON_OVERRIDE); + contents[_len] = 0; + CHEEVOS_LOG(RCHEEVOS_TAG "Loaded game info. Read %u bytes to %s\n", _len, CHEEVOS_JSON_OVERRIDE); callback(contents, 200, callback_data); } diff --git a/gfx/common/vulkan_common.c b/gfx/common/vulkan_common.c index 4b02ceb29804..5e1a8d8d19f3 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.c @@ -277,9 +277,9 @@ static void vulkan_debug_mark_object(VkDevice device, } static bool vulkan_buffer_chain_suballoc(struct vk_buffer_chain *chain, - size_t size, struct vk_buffer_range *range) + size_t len, struct vk_buffer_range *range) { - VkDeviceSize next_offset = chain->offset + size; + VkDeviceSize next_offset = chain->offset + len; if (next_offset <= chain->current->buffer.size) { range->data = (uint8_t*)chain->current->buffer.mapped + chain->offset; @@ -287,24 +287,21 @@ static bool vulkan_buffer_chain_suballoc(struct vk_buffer_chain *chain, range->offset = chain->offset; chain->offset = (next_offset + chain->alignment - 1) & ~(chain->alignment - 1); - return true; } - return false; } static struct vk_buffer_node *vulkan_buffer_chain_alloc_node( const struct vulkan_context *context, - size_t size, VkBufferUsageFlags usage) + size_t len, VkBufferUsageFlags usage) { struct vk_buffer_node *node = (struct vk_buffer_node*) malloc(sizeof(*node)); if (!node) return NULL; - node->buffer = vulkan_create_buffer( - context, size, usage); + context, len, usage); node->next = NULL; return node; } @@ -1355,7 +1352,7 @@ static void vulkan_create_wait_fences(gfx_ctx_vulkan_data_t *vk) bool vulkan_buffer_chain_alloc(const struct vulkan_context *context, struct vk_buffer_chain *chain, - size_t size, struct vk_buffer_range *range) + size_t len, struct vk_buffer_range *range) { if (!chain->head) { @@ -1367,7 +1364,7 @@ bool vulkan_buffer_chain_alloc(const struct vulkan_context *context, chain->offset = 0; } - if (!vulkan_buffer_chain_suballoc(chain, size, range)) + if (!vulkan_buffer_chain_suballoc(chain, len, range)) { /* We've exhausted the current chain, traverse list until we * can find a block we can use. Usually, we just step once. */ @@ -1375,24 +1372,24 @@ bool vulkan_buffer_chain_alloc(const struct vulkan_context *context, { chain->current = chain->current->next; chain->offset = 0; - if (vulkan_buffer_chain_suballoc(chain, size, range)) + if (vulkan_buffer_chain_suballoc(chain, len, range)) return true; } /* We have to allocate a new node, might allocate larger * buffer here than block_size in case we have * a very large allocation. */ - if (size < chain->block_size) - size = chain->block_size; + if (len < chain->block_size) + len = chain->block_size; if (!(chain->current->next = vulkan_buffer_chain_alloc_node( - context, size, chain->usage))) + context, len, chain->usage))) return false; chain->current = chain->current->next; chain->offset = 0; /* This cannot possibly fail. */ - retro_assert(vulkan_buffer_chain_suballoc(chain, size, range)); + retro_assert(vulkan_buffer_chain_suballoc(chain, len, range)); } return true; } @@ -1418,7 +1415,7 @@ void vulkan_debug_mark_memory(VkDevice device, VkDeviceMemory memory) struct vk_buffer vulkan_create_buffer( const struct vulkan_context *context, - size_t size, VkBufferUsageFlags usage) + size_t len, VkBufferUsageFlags usage) { struct vk_buffer buffer; VkMemoryRequirements mem_reqs; @@ -1428,7 +1425,7 @@ struct vk_buffer vulkan_create_buffer( info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; info.pNext = NULL; info.flags = 0; - info.size = size; + info.size = len; info.usage = usage; info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; info.queueFamilyIndexCount = 0; @@ -1450,7 +1447,7 @@ struct vk_buffer vulkan_create_buffer( vulkan_debug_mark_memory(context->device, buffer.memory); vkBindBufferMemory(context->device, buffer.buffer, buffer.memory, 0); - buffer.size = size; + buffer.size = len; vkMapMemory(context->device, buffer.memory, 0, buffer.size, 0, &buffer.mapped); diff --git a/gfx/drivers_shader/shader_vulkan.cpp b/gfx/drivers_shader/shader_vulkan.cpp index b1ef070d00eb..c09f57521344 100644 --- a/gfx/drivers_shader/shader_vulkan.cpp +++ b/gfx/drivers_shader/shader_vulkan.cpp @@ -73,7 +73,7 @@ class Buffer public: Buffer(VkDevice device, const VkPhysicalDeviceMemoryProperties &mem_props, - size_t size, VkBufferUsageFlags usage); + size_t len, VkBufferUsageFlags usage); ~Buffer(); size_t get_size() const { return size; } @@ -1532,8 +1532,8 @@ StaticTexture::~StaticTexture() Buffer::Buffer(VkDevice device, const VkPhysicalDeviceMemoryProperties &mem_props, - size_t size, VkBufferUsageFlags usage) : - device(device), size(size) + size_t len, VkBufferUsageFlags usage) : + device(device), size(len) { VkBufferCreateInfo info; VkMemoryRequirements mem_reqs; @@ -1542,7 +1542,7 @@ Buffer::Buffer(VkDevice device, info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; info.pNext = NULL; info.flags = 0; - info.size = size; + info.size = len; info.usage = usage; info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; info.queueFamilyIndexCount = 0; diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 339341a7e716..7451f103c40a 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -198,18 +198,15 @@ struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = { { 4.0f / 3.0f , "" } /* full - initialized in video_driver_init_internal */ }; -static INLINE bool realloc_checked(void **ptr, size_t size) +static INLINE bool realloc_checked(void **ptr, size_t len) { void *nptr = NULL; - if (*ptr) - nptr = realloc(*ptr, size); + nptr = realloc(*ptr, len); else - nptr = malloc(size); - + nptr = malloc(len); if (nptr) *ptr = nptr; - return *ptr == nptr; } diff --git a/input/connect/connect_retrode.c b/input/connect/connect_retrode.c index b4322e66d420..b54191bae151 100644 --- a/input/connect/connect_retrode.c +++ b/input/connect/connect_retrode.c @@ -164,20 +164,20 @@ static void retrode_update_button_state(retrode_pad_data_t *pad) pad->buttons |= (pressed_keys & (1 << i)) ? (1 << button_mapping[i]) : 0; } -static void hidpad_retrode_pad_packet_handler(retrode_pad_data_t *pad, uint8_t *packet, size_t size) +static void hidpad_retrode_pad_packet_handler(retrode_pad_data_t *pad, uint8_t *packet, size_t len) { - memcpy(pad->data, packet, size); + memcpy(pad->data, packet, len); retrode_update_button_state(pad); } -static void hidpad_retrode_packet_handler(void *device_data, uint8_t *packet, uint16_t size) +static void hidpad_retrode_packet_handler(void *device_data, uint8_t *packet, uint16_t len) { retrode_device_data_t *device = (retrode_device_data_t *)device_data; if (!device) return; - memcpy(device->data, packet, size); + memcpy(device->data, packet, len); /* * packet[0] contains Retrode port number diff --git a/input/connect/connect_wiiugca.c b/input/connect/connect_wiiugca.c index c06ecfb37ba5..8e3422ec4a6c 100644 --- a/input/connect/connect_wiiugca.c +++ b/input/connect/connect_wiiugca.c @@ -191,17 +191,16 @@ static void update_analog_state(gca_pad_data_t *pad) } } -static void hidpad_wiiugca_pad_packet_handler(gca_pad_data_t *pad, uint8_t *packet, size_t size) +static void hidpad_wiiugca_pad_packet_handler(gca_pad_data_t *pad, uint8_t *packet, size_t len) { - if (size > 9) + if (len > 9) return; - - memcpy(pad->data, packet, size); + memcpy(pad->data, packet, len); update_button_state(pad); update_analog_state(pad); } -static void hidpad_wiiugca_packet_handler(void *device_data, uint8_t *packet, uint16_t size) +static void hidpad_wiiugca_packet_handler(void *device_data, uint8_t *packet, uint16_t len) { uint32_t i; gca_device_data_t *device = (gca_device_data_t *)device_data; @@ -209,7 +208,7 @@ static void hidpad_wiiugca_packet_handler(void *device_data, uint8_t *packet, ui if (!device) return; - memcpy(device->data, packet, size); + memcpy(device->data, packet, len); for (i = 1; i < 37; i += 9) { diff --git a/input/input_keymaps.c b/input/input_keymaps.c index 1a71d2edf050..83e77136d8e3 100644 --- a/input/input_keymaps.c +++ b/input/input_keymaps.c @@ -221,7 +221,7 @@ const struct input_key_map input_config_key_map[] = { { "media", RETROK_LAUNCH_MEDIA }, { "app1", RETROK_LAUNCH_APP1 }, { "app2", RETROK_LAUNCH_APP2 }, - + { "nul", RETROK_UNKNOWN }, { NULL, RETROK_UNKNOWN }, }; @@ -1189,7 +1189,7 @@ const struct rarch_key_map rarch_key_map_x11[] = { { XFVK_KP0, RETROK_KP0 }, { XFVK_KPDL, RETROK_KP_PERIOD }, { XFVK_KPEQ, RETROK_KP_EQUALS }, - + { XFVK_MUTE, RETROK_VOLUME_MUTE }, { XFVK_VOUP, RETROK_VOLUME_UP }, { XFVK_VODN, RETROK_VOLUME_DOWN }, @@ -1914,7 +1914,7 @@ const struct rarch_key_map rarch_key_map_ps3[] = { { KB_RAWKEY_SCROLL_LOCK, RETROK_SCROLLOCK }, { KB_RAWKEY_PAUSE, RETROK_BREAK }, - /* + /* { KB_RAWKEY_HASHTILDE, RETROK_HASH }, { KB_RAWKEY_KPLEFTPAREN, RETROK_LEFTPAREN }, { KB_RAWKEY_KPRIGHTPAREN, RETROK_RIGHTPAREN }, @@ -2162,7 +2162,7 @@ enum retro_key input_keymaps_translate_keysym_to_rk(unsigned sym) * Translates a retro key identifier to a human-readable * identifier string. **/ -void input_keymaps_translate_rk_to_str(enum retro_key key, char *buf, size_t size) +void input_keymaps_translate_rk_to_str(enum retro_key key, char *buf, size_t len) { unsigned i; @@ -2180,7 +2180,7 @@ void input_keymaps_translate_rk_to_str(enum retro_key key, char *buf, size_t siz if (input_config_key_map[i].key != key) continue; - strlcpy(buf, input_config_key_map[i].str, size); + strlcpy(buf, input_config_key_map[i].str, len); break; } } diff --git a/input/input_keymaps.h b/input/input_keymaps.h index 2ffee2b67ffc..473a708d3a58 100644 --- a/input/input_keymaps.h +++ b/input/input_keymaps.h @@ -224,12 +224,12 @@ enum retro_key input_keymaps_translate_keysym_to_rk(unsigned sym); * input_keymaps_translate_rk_to_str: * @key : Retro key identifier. * @buf : Buffer. - * @size : Size of @buf. + * @len : Size of @buf. * * Translates a retro key identifier to a human-readable * identifier string. **/ -void input_keymaps_translate_rk_to_str(enum retro_key key, char *buf, size_t size); +void input_keymaps_translate_rk_to_str(enum retro_key key, char *buf, size_t len); /** * input_translate_rk_to_ascii: diff --git a/libretro-common/file/archive_file_7z.c b/libretro-common/file/archive_file_7z.c index 289ec25f1c00..ef9f96b9de9b 100644 --- a/libretro-common/file/archive_file_7z.c +++ b/libretro-common/file/archive_file_7z.c @@ -62,11 +62,11 @@ struct sevenzip_context_t uint32_t block_index; }; -static void *sevenzip_stream_alloc_impl(ISzAllocPtr p, size_t size) +static void *sevenzip_stream_alloc_impl(ISzAllocPtr p, size_t len) { - if (size == 0) + if (len == 0) return 0; - return malloc(size); + return malloc(len); } static void sevenzip_stream_free_impl(ISzAllocPtr p, void *address) @@ -77,12 +77,12 @@ static void sevenzip_stream_free_impl(ISzAllocPtr p, void *address) free(address); } -static void *sevenzip_stream_alloc_tmp_impl(ISzAllocPtr p, size_t size) +static void *sevenzip_stream_alloc_tmp_impl(ISzAllocPtr p, size_t len) { (void)p; - if (size == 0) + if (len == 0) return 0; - return malloc(size); + return malloc(len); } static void* sevenzip_stream_new(void) diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index f2edb10408a3..8f1ab2523848 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -1168,24 +1168,24 @@ size_t config_get_config_path(config_file_t *conf, char *s, size_t len) } bool config_get_array(config_file_t *conf, const char *key, - char *buf, size_t size) + char *buf, size_t len) { const struct config_entry_list *entry = config_get_entry(conf, key); if (entry) - return strlcpy(buf, entry->value, size) < size; + return strlcpy(buf, entry->value, len) < len; return false; } bool config_get_path(config_file_t *conf, const char *key, - char *buf, size_t size) + char *buf, size_t len) { #if defined(RARCH_CONSOLE) || !defined(RARCH_INTERNAL) - return config_get_array(conf, key, buf, size); + return config_get_array(conf, key, buf, len); #else const struct config_entry_list *entry = config_get_entry(conf, key); if (entry) { - fill_pathname_expand_special(buf, entry->value, size); + fill_pathname_expand_special(buf, entry->value, len); return true; } return false; diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index ad484a4b84ff..a9a36b84c80f 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -1170,7 +1170,7 @@ size_t fill_pathname_abbreviate_special(char *s, * * @returns new string that has been sanitized **/ -const char *sanitize_path_part(const char *path_part, size_t size) +const char *sanitize_path_part(const char *path_part, size_t len) { int i; int j = 0; @@ -1180,7 +1180,7 @@ const char *sanitize_path_part(const char *path_part, size_t size) if (string_is_empty(path_part)) return NULL; - tmp = (char *)malloc((size + 1) * sizeof(char)); + tmp = (char *)malloc((len + 1) * sizeof(char)); for (i = 0; path_part[i] != '\0'; i++) { diff --git a/libretro-common/formats/png/rpng_encode.c b/libretro-common/formats/png/rpng_encode.c index ced535cd23f0..97d5febd1a2b 100644 --- a/libretro-common/formats/png/rpng_encode.c +++ b/libretro-common/formats/png/rpng_encode.c @@ -49,10 +49,10 @@ static void dword_write_be(uint8_t *buf, uint32_t val) *buf++ = (uint8_t)(val >> 0); } -static bool png_write_crc_string(intfstream_t *intf_s, const uint8_t *data, size_t size) +static bool png_write_crc_string(intfstream_t *intf_s, const uint8_t *data, size_t len) { uint8_t crc_raw[4] = {0}; - uint32_t crc = encoding_crc32(0, data, size); + uint32_t crc = encoding_crc32(0, data, len); dword_write_be(crc_raw, crc); return intfstream_write(intf_s, crc_raw, sizeof(crc_raw)) == sizeof(crc_raw); @@ -94,12 +94,11 @@ static bool png_write_ihdr_string(intfstream_t *intf_s, const struct png_ihdr *i sizeof(ihdr_raw) - sizeof(uint32_t)); } -static bool png_write_idat_string(intfstream_t* intf_s, const uint8_t *data, size_t size) +static bool png_write_idat_string(intfstream_t* intf_s, const uint8_t *data, size_t len) { - if (intfstream_write(intf_s, data, size) != (ssize_t)size) + if (intfstream_write(intf_s, data, len) != (ssize_t)len) return false; - - return png_write_crc_string(intf_s, data + sizeof(uint32_t), size - sizeof(uint32_t)); + return png_write_crc_string(intf_s, data + sizeof(uint32_t), len - sizeof(uint32_t)); } static bool png_write_iend_string(intfstream_t* intf_s) @@ -140,11 +139,11 @@ static void copy_bgr24_line(uint8_t *dst, const uint8_t *src, unsigned width) } } -static unsigned count_sad(const uint8_t *data, size_t size) +static unsigned count_sad(const uint8_t *data, size_t len) { size_t i; unsigned cnt = 0; - for (i = 0; i < size; i++) + for (i = 0; i < len; i++) { if (data[i]) cnt += abs((int8_t)data[i]); @@ -223,7 +222,7 @@ bool rpng_save_image_stream(const uint8_t *data, intfstream_t* intf_s, void *stream = NULL; uint32_t total_in = 0; uint32_t total_out = 0; - + if (!intf_s) GOTO_END_ERROR(); @@ -370,8 +369,8 @@ bool rpng_save_image_argb(const char *path, const uint32_t *data, { bool ret = false; intfstream_t* intf_s = NULL; - - intf_s = intfstream_open_file(path, + + intf_s = intfstream_open_file(path, RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE); @@ -388,11 +387,11 @@ bool rpng_save_image_bgr24(const char *path, const uint8_t *data, { bool ret = false; intfstream_t* intf_s = NULL; - - intf_s = intfstream_open_file(path, + + intf_s = intfstream_open_file(path, RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE); - ret = rpng_save_image_stream(data, intf_s, width, height, + ret = rpng_save_image_stream(data, intf_s, width, height, (signed) pitch, 3); intfstream_close(intf_s); free(intf_s); @@ -412,14 +411,14 @@ uint8_t* rpng_save_image_bgr24_string(const uint8_t *data, buf_length = (int)(width*height*3*DEFLATE_PADDING)+PNG_ROUGH_HEADER; buf = (uint8_t*)malloc(buf_length*sizeof(uint8_t)); if (!buf) - GOTO_END_ERROR(); + GOTO_END_ERROR(); - intf_s = intfstream_open_writable_memory(buf, + intf_s = intfstream_open_writable_memory(buf, RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE, buf_length); - ret = rpng_save_image_stream((const uint8_t*)data, + ret = rpng_save_image_stream((const uint8_t*)data, intf_s, width, height, pitch, 3); *bytes = intfstream_get_ptr(intf_s); diff --git a/libretro-common/memmap/memalign.c b/libretro-common/memmap/memalign.c index 14eaeffdbd5a..d798d371b2e6 100644 --- a/libretro-common/memmap/memalign.c +++ b/libretro-common/memmap/memalign.c @@ -25,19 +25,17 @@ #include -void *memalign_alloc(size_t boundary, size_t size) +void *memalign_alloc(size_t boundary, size_t len) { void **place = NULL; uintptr_t addr = 0; - void *ptr = (void*)malloc(boundary + size + sizeof(uintptr_t)); + void *ptr = (void*)malloc(boundary + len + sizeof(uintptr_t)); if (!ptr) return NULL; - addr = ((uintptr_t)ptr + sizeof(uintptr_t) + boundary) & ~(boundary - 1); place = (void**)addr; place[-1] = ptr; - return (void*)addr; } @@ -51,13 +49,13 @@ void memalign_free(void *ptr) free(p[-1]); } -void *memalign_alloc_aligned(size_t size) +void *memalign_alloc_aligned(size_t len) { #if defined(__x86_64__) || defined(__LP64) || defined(__IA64__) || defined(_M_X64) || defined(_M_X64) || defined(_WIN64) - return memalign_alloc(64, size); + return memalign_alloc(64, len); #elif defined(__i386__) || defined(__i486__) || defined(__i686__) || defined(GEKKO) || defined(_M_IX86) - return memalign_alloc(32, size); + return memalign_alloc(32, len); #else - return memalign_alloc(32, size); + return memalign_alloc(32, len); #endif } diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index 039a0b670ed5..ea5c936a9e16 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -92,27 +92,24 @@ int socket_next(void **address) } ssize_t socket_receive_all_nonblocking(int fd, bool *error, - void *data_, size_t size) + void *data_, size_t len) { - ssize_t ret = recv(fd, (char*)data_, size, 0); - + ssize_t ret = recv(fd, (char*)data_, len, 0); if (ret > 0) return ret; - if (ret < 0 && isagain((int)ret)) return 0; - *error = true; return -1; } -bool socket_receive_all_blocking(int fd, void *data_, size_t size) +bool socket_receive_all_blocking(int fd, void *data_, size_t len) { const uint8_t *data = (const uint8_t*)data_; - while (size) + while (len) { - ssize_t ret = recv(fd, (char*)data, size, 0); + ssize_t ret = recv(fd, (char*)data, len, 0); if (!ret) return false; @@ -125,7 +122,7 @@ bool socket_receive_all_blocking(int fd, void *data_, size_t size) else { data += ret; - size -= ret; + len -= ret; } } @@ -133,8 +130,7 @@ bool socket_receive_all_blocking(int fd, void *data_, size_t size) } bool socket_receive_all_blocking_with_timeout(int fd, - void *data_, size_t size, - int timeout) + void *data_, size_t len, int timeout) { const uint8_t *data = (const uint8_t*)data_; retro_time_t deadline = cpu_features_get_time_usec(); @@ -144,9 +140,9 @@ bool socket_receive_all_blocking_with_timeout(int fd, else deadline += 5000000; - while (size) + while (len) { - ssize_t ret = recv(fd, (char*)data, size, 0); + ssize_t ret = recv(fd, (char*)data, len, 0); if (!ret) return false; @@ -169,7 +165,7 @@ bool socket_receive_all_blocking_with_timeout(int fd, else { data += ret; - size -= ret; + len -= ret; } } @@ -570,15 +566,15 @@ bool socket_wait(int fd, bool *rd, bool *wr, int timeout) #endif } -bool socket_send_all_blocking(int fd, const void *data_, size_t size, +bool socket_send_all_blocking(int fd, const void *data_, size_t len, bool no_signal) { const uint8_t *data = (const uint8_t*)data_; int flags = no_signal ? MSG_NOSIGNAL : 0; - while (size) + while (len) { - ssize_t ret = send(fd, (const char*)data, size, flags); + ssize_t ret = send(fd, (const char*)data, len, flags); if (!ret) continue; @@ -591,7 +587,7 @@ bool socket_send_all_blocking(int fd, const void *data_, size_t size, else { data += ret; - size -= ret; + len -= ret; } } @@ -599,7 +595,7 @@ bool socket_send_all_blocking(int fd, const void *data_, size_t size, } bool socket_send_all_blocking_with_timeout(int fd, - const void *data_, size_t size, + const void *data_, size_t len, int timeout, bool no_signal) { const uint8_t *data = (const uint8_t*)data_; @@ -611,9 +607,9 @@ bool socket_send_all_blocking_with_timeout(int fd, else deadline += 5000000; - while (size) + while (len) { - ssize_t ret = send(fd, (const char*)data, size, flags); + ssize_t ret = send(fd, (const char*)data, len, flags); if (!ret) continue; @@ -636,22 +632,22 @@ bool socket_send_all_blocking_with_timeout(int fd, else { data += ret; - size -= ret; + len -= ret; } } return true; } -ssize_t socket_send_all_nonblocking(int fd, const void *data_, size_t size, +ssize_t socket_send_all_nonblocking(int fd, const void *data_, size_t len, bool no_signal) { const uint8_t *data = (const uint8_t*)data_; int flags = no_signal ? MSG_NOSIGNAL : 0; - while (size) + while (len) { - ssize_t ret = send(fd, (const char*)data, size, flags); + ssize_t ret = send(fd, (const char*)data, len, flags); if (!ret) break; @@ -666,7 +662,7 @@ ssize_t socket_send_all_nonblocking(int fd, const void *data_, size_t size, else { data += ret; - size -= ret; + len -= ret; } } diff --git a/libretro-common/queues/fifo_queue.c b/libretro-common/queues/fifo_queue.c index 05deb1878593..19543a81b964 100644 --- a/libretro-common/queues/fifo_queue.c +++ b/libretro-common/queues/fifo_queue.c @@ -29,24 +29,24 @@ #include -static bool fifo_initialize_internal(fifo_buffer_t *buf, size_t size) +static bool fifo_initialize_internal(fifo_buffer_t *buf, size_t len) { - uint8_t *buffer = (uint8_t*)calloc(1, size + 1); + uint8_t *buffer = (uint8_t*)calloc(1, len + 1); if (!buffer) return false; buf->buffer = buffer; - buf->size = size + 1; + buf->size = len + 1; buf->first = 0; buf->end = 0; return true; } -bool fifo_initialize(fifo_buffer_t *buf, size_t size) +bool fifo_initialize(fifo_buffer_t *buf, size_t len) { - return (buf && fifo_initialize_internal(buf, size)); + return (buf && fifo_initialize_internal(buf, len)); } void fifo_free(fifo_buffer_t *buffer) @@ -73,14 +73,14 @@ bool fifo_deinitialize(fifo_buffer_t *buffer) return true; } -fifo_buffer_t *fifo_new(size_t size) +fifo_buffer_t *fifo_new(size_t len) { fifo_buffer_t *buf = (fifo_buffer_t*)malloc(sizeof(*buf)); if (!buf) return NULL; - if (!fifo_initialize_internal(buf, size)) + if (!fifo_initialize_internal(buf, len)) { free(buf); return NULL; @@ -89,36 +89,36 @@ fifo_buffer_t *fifo_new(size_t size) return buf; } -void fifo_write(fifo_buffer_t *buffer, const void *in_buf, size_t size) +void fifo_write(fifo_buffer_t *buffer, const void *in_buf, size_t len) { - size_t first_write = size; + size_t first_write = len; size_t rest_write = 0; - if (buffer->end + size > buffer->size) + if (buffer->end + len > buffer->size) { first_write = buffer->size - buffer->end; - rest_write = size - first_write; + rest_write = len - first_write; } memcpy(buffer->buffer + buffer->end, in_buf, first_write); memcpy(buffer->buffer, (const uint8_t*)in_buf + first_write, rest_write); - buffer->end = (buffer->end + size) % buffer->size; + buffer->end = (buffer->end + len) % buffer->size; } -void fifo_read(fifo_buffer_t *buffer, void *in_buf, size_t size) +void fifo_read(fifo_buffer_t *buffer, void *in_buf, size_t len) { - size_t first_read = size; + size_t first_read = len; size_t rest_read = 0; - if (buffer->first + size > buffer->size) + if (buffer->first + len > buffer->size) { first_read = buffer->size - buffer->first; - rest_read = size - first_read; + rest_read = len - first_read; } memcpy(in_buf, (const uint8_t*)buffer->buffer + buffer->first, first_read); memcpy((uint8_t*)in_buf + first_read, buffer->buffer, rest_read); - buffer->first = (buffer->first + size) % buffer->size; + buffer->first = (buffer->first + len) % buffer->size; } diff --git a/libretro-common/queues/message_queue.c b/libretro-common/queues/message_queue.c index 4e7dea061c2d..d4b5c8609882 100644 --- a/libretro-common/queues/message_queue.c +++ b/libretro-common/queues/message_queue.c @@ -28,7 +28,7 @@ #include #include -bool msg_queue_initialize(msg_queue_t *queue, size_t size) +bool msg_queue_initialize(msg_queue_t *queue, size_t len) { struct queue_elem **elems = NULL; @@ -36,31 +36,31 @@ bool msg_queue_initialize(msg_queue_t *queue, size_t size) return false; if (!(elems = (struct queue_elem**) - calloc(size + 1, sizeof(struct queue_elem*)))) + calloc(len + 1, sizeof(struct queue_elem*)))) return false; queue->tmp_msg = NULL; queue->elems = elems; queue->ptr = 1; - queue->size = size + 1; + queue->size = len + 1; return true; } /** * msg_queue_new: - * @size : maximum size of message + * @len : maximum size of message * * Creates a message queue with maximum size different messages. * * Returns: NULL if allocation error, pointer to a message queue * if successful. Has to be freed manually. **/ -msg_queue_t *msg_queue_new(size_t size) +msg_queue_t *msg_queue_new(size_t len) { msg_queue_t *queue = (msg_queue_t*)malloc(sizeof(*queue)); - if (!msg_queue_initialize(queue, size)) + if (!msg_queue_initialize(queue, len)) { if (queue) free(queue); diff --git a/libretro-common/streams/network_stream.c b/libretro-common/streams/network_stream.c index 47f426b9427f..48af03a10b23 100644 --- a/libretro-common/streams/network_stream.c +++ b/libretro-common/streams/network_stream.c @@ -27,19 +27,19 @@ #include -bool netstream_open(netstream_t *stream, void *buf, size_t size, size_t used) +bool netstream_open(netstream_t *stream, void *buf, size_t len, size_t used) { if (buf) { /* Pre-allocated buffer must have a non-zero size. */ - if (!size || used > size) + if (!len || used > len) return false; } else { - if (size) + if (len) { - buf = malloc(size); + buf = malloc(len); if (!buf) return false; } @@ -48,7 +48,7 @@ bool netstream_open(netstream_t *stream, void *buf, size_t size, size_t used) } stream->buf = buf; - stream->size = size; + stream->size = len; stream->used = used; stream->pos = 0; @@ -252,14 +252,14 @@ bool netstream_write(netstream_t *stream, const void *data, size_t len) } else { - size_t size = stream->size + (len - remaining); - void *buf = realloc(stream->buf, size); + size_t _len = stream->size + (len - remaining); + void *buf = realloc(stream->buf, _len); if (!buf) return false; stream->buf = buf; - stream->size = size; + stream->size = _len; } } diff --git a/libretro-db/query.c b/libretro-db/query.c index 7fcf86bdf13d..f8b861d46349 100644 --- a/libretro-db/query.c +++ b/libretro-db/query.c @@ -347,13 +347,12 @@ static struct buffer query_expect_eof(char *s, size_t len, } static int query_peek(struct buffer buff, const char * data, - size_t size_data) + size_t len) { size_t remain = buff.len - buff.offset; - if (remain < size_data) + if (remain < len) return 0; - return (strncmp(buff.data + buff.offset, - data, size_data) == 0); + return (strncmp(buff.data + buff.offset, data, len) == 0); } static struct buffer query_get_char( diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 254bc73bbea2..e05cba034d23 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -458,9 +458,9 @@ void menu_entry_get(menu_entry_t *entry, size_t stack_idx, if (entry->enum_idx == MENU_ENUM_LABEL_CHEEVOS_PASSWORD) { size_t j; - size_t size = strlcpy(entry->password_value, entry->value, + size_t _len = strlcpy(entry->password_value, entry->value, sizeof(entry->password_value)); - for (j = 0; j < size; j++) + for (j = 0; j < _len; j++) entry->password_value[j] = '*'; } } diff --git a/menu/menu_explore.c b/menu/menu_explore.c index a10f6c51fa27..90c10851de8f 100644 --- a/menu/menu_explore.c +++ b/menu/menu_explore.c @@ -183,23 +183,21 @@ static explore_state_t* explore_state; static void ex_arena_grow(ex_arena *arena, size_t min_size) { - size_t size = EX_ARENA_ALIGN_UP( + size_t _len = EX_ARENA_ALIGN_UP( MAX(min_size, EX_ARENA_BLOCK_SIZE), EX_ARENA_ALIGNMENT); - arena->ptr = (char *)malloc(size); - arena->end = arena->ptr + size; + arena->ptr = (char *)malloc(_len); + arena->end = arena->ptr + _len; RBUF_PUSH(arena->blocks, arena->ptr); } -static void *ex_arena_alloc(ex_arena *arena, size_t size) +static void *ex_arena_alloc(ex_arena *arena, size_t len) { void *ptr = NULL; - - if (size > (size_t)(arena->end - arena->ptr)) - ex_arena_grow(arena, size); - + if (len > (size_t)(arena->end - arena->ptr)) + ex_arena_grow(arena, len); ptr = arena->ptr; arena->ptr = (char *) - EX_ARENA_ALIGN_UP((uintptr_t)(arena->ptr + size), EX_ARENA_ALIGNMENT); + EX_ARENA_ALIGN_UP((uintptr_t)(arena->ptr + len), EX_ARENA_ALIGNMENT); return ptr; } @@ -996,14 +994,14 @@ static const char* explore_get_view_path(struct menu_state *menu_st, menu_list_t const menu_ctx_driver_t *driver_ctx = menu_st->driver_ctx; if (driver_ctx->list_get_entry) { - size_t selection = driver_ctx->list_get_selection ? driver_ctx->list_get_selection(menu_st->userdata) : 0; - size_t size = driver_ctx->list_get_size ? driver_ctx->list_get_size(menu_st->userdata, MENU_LIST_TABS) : 0; - if (selection > 0 && size > 0) + size_t selection = driver_ctx->list_get_selection ? driver_ctx->list_get_selection(menu_st->userdata) : 0; + size_t _len = driver_ctx->list_get_size ? driver_ctx->list_get_size(menu_st->userdata, MENU_LIST_TABS) : 0; + if (selection > 0 && _len > 0) { struct item_file *item = NULL; /* Label contains the path and path contains the label */ if ((item = (struct item_file*)driver_ctx->list_get_entry(menu_st->userdata, MENU_LIST_HORIZONTAL, - (unsigned)(selection - (size +1))))) + (unsigned)(selection - (_len +1))))) return item->label; } } diff --git a/network/netplay/netplay_frontend.c b/network/netplay/netplay_frontend.c index cd99527d52a4..d44526f88504 100644 --- a/network/netplay/netplay_frontend.c +++ b/network/netplay/netplay_frontend.c @@ -735,12 +735,12 @@ static void RETRO_CALLCONV netplay_netpacket_poll_receive_cb(void); * * Initialize a new socket buffer. */ -static bool netplay_init_socket_buffer(struct socket_buffer *sbuf, size_t size) +static bool netplay_init_socket_buffer(struct socket_buffer *sbuf, size_t len) { - sbuf->data = (unsigned char*)malloc(size); + sbuf->data = (unsigned char*)malloc(len); if (!sbuf->data) return false; - sbuf->bufsz = size; + sbuf->bufsz = len; sbuf->start = sbuf->read = sbuf->end = 0; return true; @@ -2197,7 +2197,7 @@ static void netplay_delta_frame_free(struct delta_frame *delta) */ static netplay_input_state_t netplay_input_state_for( netplay_input_state_t *list, - uint32_t client_num, size_t size, + uint32_t client_num, size_t len, bool must_create, bool must_not_create) { netplay_input_state_t ret; @@ -2206,16 +2206,16 @@ static netplay_input_state_t netplay_input_state_for( while (*list) { ret = *list; - if (!ret->used && !must_not_create && ret->size == size) + if (!ret->used && !must_not_create && ret->size == len) { ret->client_num = client_num; ret->used = true; - memset(ret->data, 0, size*sizeof(uint32_t)); + memset(ret->data, 0, len * sizeof(uint32_t)); return ret; } else if (ret->used && ret->client_num == client_num) { - if (!must_create && ret->size == size) + if (!must_create && ret->size == len) return ret; return NULL; } @@ -2226,8 +2226,8 @@ static netplay_input_state_t netplay_input_state_for( return NULL; /* Couldn't find a slot, allocate a fresh one */ - if (size > 1) - ret = (netplay_input_state_t)calloc(1, sizeof(struct netplay_input_state) + (size-1) * sizeof(uint32_t)); + if (len > 1) + ret = (netplay_input_state_t)calloc(1, sizeof(struct netplay_input_state) + (len - 1) * sizeof(uint32_t)); else ret = (netplay_input_state_t)calloc(1, sizeof(struct netplay_input_state)); if (!ret) @@ -2235,7 +2235,7 @@ static netplay_input_state_t netplay_input_state_for( *list = ret; ret->client_num = client_num; ret->used = true; - ret->size = (uint32_t)size; + ret->size = (uint32_t)len; return ret; } @@ -4477,21 +4477,19 @@ bool netplay_send_cur_input(netplay_t *netplay, */ bool netplay_send_raw_cmd(netplay_t *netplay, struct netplay_connection *connection, uint32_t cmd, const void *data, - size_t size) + size_t len) { uint32_t cmdbuf[2]; cmdbuf[0] = htonl(cmd); - cmdbuf[1] = htonl(size); + cmdbuf[1] = htonl(len); if (!netplay_send(&connection->send_packet_buffer, connection->fd, cmdbuf, sizeof(cmdbuf))) return false; - - if (size > 0) - if (!netplay_send(&connection->send_packet_buffer, connection->fd, data, size)) + if (len > 0) + if (!netplay_send(&connection->send_packet_buffer, connection->fd, data, len)) return false; - return true; } @@ -4503,7 +4501,7 @@ bool netplay_send_raw_cmd(netplay_t *netplay, */ void netplay_send_raw_cmd_all(netplay_t *netplay, struct netplay_connection *except, uint32_t cmd, const void *data, - size_t size) + size_t len) { size_t i; for (i = 0; i < netplay->connections_size; i++) @@ -4514,7 +4512,7 @@ void netplay_send_raw_cmd_all(netplay_t *netplay, if ( (connection->flags & NETPLAY_CONN_FLAG_ACTIVE) && (connection->mode >= NETPLAY_CONNECTION_CONNECTED)) { - if (!netplay_send_raw_cmd(netplay, connection, cmd, data, size)) + if (!netplay_send_raw_cmd(netplay, connection, cmd, data, len)) netplay_hangup(netplay, connection); } } @@ -7054,13 +7052,13 @@ static bool netplay_init_socket_buffers(netplay_t *netplay) return true; } -static void netplay_write_block_header(unsigned char* output, const char* header, size_t size) +static void netplay_write_block_header(unsigned char* output, const char* header, size_t len) { memcpy(output, header, 4); - output[4] = ((size) & 0xFF); - output[5] = ((size >> 8) & 0xFF); - output[6] = ((size >> 16) & 0xFF); - output[7] = ((size >> 24) & 0xFF); + output[4] = ((len) & 0xFF); + output[5] = ((len >> 8) & 0xFF); + output[6] = ((len >> 16) & 0xFF); + output[7] = ((len >> 24) & 0xFF); } static bool netplay_init_serialization(netplay_t *netplay) diff --git a/runahead.c b/runahead.c index 12147a31455e..0f26be66321f 100644 --- a/runahead.c +++ b/runahead.c @@ -533,15 +533,14 @@ bool secondary_core_ensure_exists(void *data, settings_t *settings) #if defined(HAVE_DYNAMIC) static bool secondary_core_deserialize(runloop_state_t *runloop_st, - settings_t *settings, - const void *data, size_t size) + settings_t *settings, const void *data, size_t len) { bool ret = false; if (secondary_core_ensure_exists(runloop_st, settings)) { runloop_st->flags |= RUNLOOP_FLAG_REQUEST_SPECIAL_SAVESTATE; - ret = runloop_st->secondary_core.retro_unserialize(data, size); + ret = runloop_st->secondary_core.retro_unserialize(data, len); runloop_st->flags &= ~RUNLOOP_FLAG_REQUEST_SPECIAL_SAVESTATE; } else @@ -828,12 +827,12 @@ static void runahead_reset_hook(void) runloop_st->retro_reset_callback_original(); } -static bool runahead_unserialize_hook(const void *buf, size_t size) +static bool runahead_unserialize_hook(const void *buf, size_t len) { runloop_state_t *runloop_st = runloop_state_get_ptr(); runloop_st->flags |= RUNLOOP_FLAG_INPUT_IS_DIRTY; if (runloop_st->retro_unserialize_callback_original) - return runloop_st->retro_unserialize_callback_original(buf, size); + return runloop_st->retro_unserialize_callback_original(buf, len); return false; } diff --git a/runloop.c b/runloop.c index 9a6dc93aecf6..1d5339c34e79 100644 --- a/runloop.c +++ b/runloop.c @@ -558,7 +558,7 @@ void libretro_get_environment_info( } static dylib_t load_dynamic_core(const char *path, char *buf, - size_t size) + size_t len) { #if defined(ANDROID) /* Can't resolve symlinks when dealing with cores @@ -589,7 +589,7 @@ static dylib_t load_dynamic_core(const char *path, char *buf, /* Need to use absolute path for this setting. It can be * saved to content history, and a relative path would * break in that scenario. */ - path_resolve_realpath(buf, size, resolve_symlinks); + path_resolve_realpath(buf, len, resolve_symlinks); return dylib_load(path); } diff --git a/save.c b/save.c index f282369985e9..e3aef59effb6 100644 --- a/save.c +++ b/save.c @@ -407,7 +407,7 @@ static bool content_load_ram_file(unsigned slot) * Attempt to save valuable RAM data somewhere. **/ static bool dump_to_file_desperate(const void *data, - size_t size, unsigned type) + size_t len, unsigned type) { char path[PATH_MAX_LENGTH + 256 + 32]; path [0] = '\0'; @@ -434,7 +434,7 @@ static bool dump_to_file_desperate(const void *data, * > In this case, we don't want to further * complicate matters by introducing zlib * compression overheads */ - if (filestream_write_file(path, data, size)) + if (filestream_write_file(path, data, len)) { RARCH_WARN("[SRAM]: Succeeded in saving RAM data to \"%s\".\n", path); return true; diff --git a/tasks/task_content.c b/tasks/task_content.c index 5c93ed43be71..1d4512c627f4 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -407,7 +407,7 @@ static void content_file_list_free( free(file_list); } -static content_file_list_t *content_file_list_init(size_t size) +static content_file_list_t *content_file_list_init(size_t len) { content_file_list_t *file_list = NULL; @@ -424,17 +424,17 @@ static content_file_list_t *content_file_list_init(size_t size) { /* Create entries list */ if ((file_list->entries = (content_file_info_t *) - calloc(size, sizeof(content_file_info_t)))) + calloc(len, sizeof(content_file_info_t)))) { - file_list->size = size; + file_list->size = len; /* Create retro_game_info object */ if ((file_list->game_info = (struct retro_game_info *) - calloc(size, sizeof(struct retro_game_info)))) + calloc(len, sizeof(struct retro_game_info)))) { /* Create retro_game_info_ext object */ if ((file_list->game_info_ext = (struct retro_game_info_ext *) - calloc(size, sizeof(struct retro_game_info_ext)))) + calloc(len, sizeof(struct retro_game_info_ext)))) return file_list; } } diff --git a/tasks/task_overlay.c b/tasks/task_overlay.c index b369c1546e68..321b9aea5b29 100644 --- a/tasks/task_overlay.c +++ b/tasks/task_overlay.c @@ -517,24 +517,21 @@ static bool task_overlay_load_desc( } static ssize_t task_overlay_find_index(const struct overlay *ol, - const char *name, size_t size) + const char *name, size_t len) { size_t i; - if (!ol) return -1; - - for (i = 0; i < size; i++) + for (i = 0; i < len; i++) { if (string_is_equal(ol[i].name, name)) return i; } - return -1; } static bool task_overlay_resolve_targets(struct overlay *ol, - size_t idx, size_t size) + size_t idx, size_t len) { unsigned i; struct overlay *current = (struct overlay*)&ol[idx]; @@ -543,11 +540,11 @@ static bool task_overlay_resolve_targets(struct overlay *ol, { struct overlay_desc *desc = (struct overlay_desc*)¤t->descs[i]; const char *next = desc->next_index_name; - ssize_t next_idx = (idx + 1) % size; + ssize_t next_idx = (idx + 1) % len; if (!string_is_empty(next)) { - next_idx = task_overlay_find_index(ol, next, size); + next_idx = task_overlay_find_index(ol, next, len); if (next_idx < 0) { From e2c8e98be0026a3a6a009b58645b21bacbb81437 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Fri, 17 Jan 2025 12:03:30 +0100 Subject: [PATCH 32/49] Buildfixes and warning fixes --- core_updater_list.c | 16 ++++++++-------- input/connect/connect_retrode.c | 2 +- menu/cbs/menu_cbs_deferred_push.c | 18 +++++++++--------- menu/cbs/menu_cbs_ok.c | 16 ++++++++-------- menu/cbs/menu_cbs_title.c | 4 ++-- menu/drivers/ozone.c | 2 +- menu/drivers/rgui.c | 2 +- menu/menu_displaylist.c | 6 +++--- playlist.c | 2 +- tasks/task_content.c | 2 +- tasks/task_overlay.c | 6 +++--- 11 files changed, 38 insertions(+), 38 deletions(-) diff --git a/core_updater_list.c b/core_updater_list.c index 08af5e02e23f..baec5f39892f 100644 --- a/core_updater_list.c +++ b/core_updater_list.c @@ -330,7 +330,7 @@ bool core_updater_list_get_core( static bool core_updater_list_set_date( core_updater_list_entry_t *entry, const char *date_str) { - char *tok, *save; + char *tok, *save = NULL; char *elem0 = NULL; char *elem1 = NULL; char *elem2 = NULL; @@ -784,7 +784,7 @@ bool core_updater_list_parse_network_data( const char *network_buildbot_url, const char *data, size_t len) { - char *tok, *save; + char *tok, *save = NULL; unsigned list_size = 0; char *data_buf = NULL; @@ -817,12 +817,12 @@ bool core_updater_list_parse_network_data( for (tok = strtok_r(data_buf, "\n", &save); tok; tok = strtok_r(NULL, "\n", &save)) { - char *tok2, *save2; - char *elem0 = NULL; - char *elem1 = NULL; - char *elem2 = NULL; - char *line_cpy = NULL; - const char *line = tok; + char *tok2, *save2 = NULL; + char *elem0 = NULL; + char *elem1 = NULL; + char *elem2 = NULL; + char *line_cpy = NULL; + const char *line = tok; if (string_is_empty(line)) continue; diff --git a/input/connect/connect_retrode.c b/input/connect/connect_retrode.c index b54191bae151..01aa8e2f3c05 100644 --- a/input/connect/connect_retrode.c +++ b/input/connect/connect_retrode.c @@ -187,7 +187,7 @@ static void hidpad_retrode_packet_handler(void *device_data, uint8_t *packet, ui * 4 = right Genesis/MD */ - hidpad_retrode_pad_packet_handler(&device->pad_data[packet[0] - 1], &device->data[0], size); + hidpad_retrode_pad_packet_handler(&device->pad_data[packet[0] - 1], &device->data[0], len); } static void hidpad_retrode_set_rumble(void *data, diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index a486e98186a1..a18fbeb19754 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -353,11 +353,11 @@ static int deferred_push_cursor_manager_list_generic( menu_displaylist_info_t *info, enum database_query_type type) { char query[256]; - char *tok, *save; - char *elem0 = NULL; - char *elem1 = NULL; - char *path_cpy = NULL; - const char *path = info->path; + char *tok, *save = NULL; + char *elem0 = NULL; + char *elem1 = NULL; + char *path_cpy = NULL; + const char *path = info->path; if (!path) return -1; @@ -526,8 +526,8 @@ static int general_push(menu_displaylist_info_t *info, core_info_get_list(&list); if (list && !string_is_empty(list->all_ext)) { - char *tok, *save; - char *all_ext_cpy = strdup(list->all_ext); + char *tok, *save = NULL; + char *all_ext_cpy = strdup(list->all_ext); /* If the current core already supports * this extension, skip adding it */ @@ -538,8 +538,8 @@ static int general_push(menu_displaylist_info_t *info, if (!string_is_empty(newstr2)) { - char *tok2, *save2; - char *newstr2_cpy = strdup(newstr2); + char *tok2, *save2 = NULL; + char *newstr2_cpy = strdup(newstr2); for ( tok2 = strtok_r(newstr2_cpy, "|", &save2); tok2; tok2 = strtok_r(NULL, "|", &save2)) { diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 512140d664d3..aa97852ba8ce 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -5376,8 +5376,8 @@ static int action_ok_download_generic(const char *path, break; case MENU_ENUM_LABEL_CB_CORE_CONTENT_DOWNLOAD: { - char *tok, *save; - char *menu_label_cpy = strdup(menu_label); + char *tok, *save = NULL; + char *menu_label_cpy = strdup(menu_label); if ((tok = strtok_r(menu_label_cpy, ";", &save))) strlcpy(s, tok, sizeof(s)); free(menu_label_cpy); @@ -6243,17 +6243,17 @@ static int action_ok_delete_entry(const char *path, static int action_ok_rdb_entry_submenu(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - char *tok, *save; char new_str[PATH_MAX_LENGTH]; char new_label[PATH_MAX_LENGTH]; - size_t _len = 0; - char *label_cpy = NULL; + char *tok, *save = NULL; + size_t _len = 0; + char *label_cpy = NULL; if (!label) return -1; - new_label[0] = '\0'; - label_cpy = strdup(label); + new_label[0] = '\0'; + label_cpy = strdup(label); /* element 0: label */ if ((tok = strtok_r(label_cpy, "|", &save))) @@ -6939,7 +6939,7 @@ static int generic_action_ok_dropdown_setting(const char *path, const char *labe case ST_STRING_OPTIONS: if (setting->get_string_representation) { - char *tok, *save; + char *tok, *save = NULL; unsigned tok_idx = 0; char *setting_values_cpy = strdup(setting->values); diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index c8a22062b7a8..75ce5d941acd 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -812,8 +812,8 @@ static int action_get_title_generic(char *s, size_t len, { if (!string_is_empty(path)) { - char *tok, *save; - char *path_cpy = strdup(path); + char *tok, *save = NULL; + char *path_cpy = strdup(path); if ((tok = strtok_r(path_cpy, "|", &save))) { diff --git a/menu/drivers/ozone.c b/menu/drivers/ozone.c index 4afe3a1605cc..c14868f0cfc7 100644 --- a/menu/drivers/ozone.c +++ b/menu/drivers/ozone.c @@ -6751,7 +6751,7 @@ static void ozone_draw_osk( 0.00, 0.00, 0.00, 0.15, 0.00, 0.00, 0.00, 0.15, }; - char *tok, *save; + char *tok, *save = NULL; unsigned i = 0; static retro_time_t last_time = 0; unsigned list_size = 0; diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 2ca60b46d537..4174676d1dec 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -7166,7 +7166,7 @@ static void rgui_update_menu_sublabel(rgui_t *rgui, size_t selection) if (!string_is_empty(entry.sublabel)) { - char *tok, *save; + char *tok, *save = NULL; static const char* const sublabel_spacer = RGUI_TICKER_SPACER; bool prev_line_empty = true; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index a444676286d7..232ced8a7f4d 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -13073,7 +13073,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, #endif if (!string_is_empty(info->label)) { - char *tok, *save; + char *tok, *save = NULL; char *info_label_cpy = strdup(info->label); if ((tok = strtok_r(info_label_cpy, "|", &save))) @@ -15594,7 +15594,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, case ST_STRING_OPTIONS: { char val_d[16]; - char *tok, *save; + char *tok, *save = NULL; unsigned i = 0; bool checked_found = false; unsigned checked = 0; @@ -15943,7 +15943,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, case ST_STRING_OPTIONS: { char val_d[16]; - char *tok, *save; + char *tok, *save = NULL; unsigned i = 0; bool checked_found = false; unsigned checked = 0; diff --git a/playlist.c b/playlist.c index 7b029219ae22..8242d954bdd6 100644 --- a/playlist.c +++ b/playlist.c @@ -2823,7 +2823,7 @@ static bool playlist_read_file(playlist_t *playlist) line_buf[3], thumbnail_mode_str, sizeof(thumbnail_mode_str)) > 0) { - char *tok, *save; + char *tok, *save = NULL; char *thumbnail_mode_str_cpy = strdup(thumbnail_mode_str); if ((tok = strtok_r(thumbnail_mode_str_cpy, "|", &save))) diff --git a/tasks/task_content.c b/tasks/task_content.c index 1d4512c627f4..10de01f9a115 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -222,7 +222,7 @@ bool content_file_override_set( for (i = 0; overrides[i].extensions; i++) { - char *tok, *save; + char *tok, *save = NULL; char *overrides_ext_cpy = strdup(overrides[i].extensions); /* Get list of extensions affected by overrides */ diff --git a/tasks/task_overlay.c b/tasks/task_overlay.c index 321b9aea5b29..afd15e05841b 100644 --- a/tasks/task_overlay.c +++ b/tasks/task_overlay.c @@ -102,8 +102,8 @@ static void task_overlay_load_desc_image( static void task_overlay_redefine_eightway_direction( char *str, input_bits_t *data) { - char *tok, *save; unsigned bit; + char *tok, *save = NULL; BIT256_CLEAR_ALL(*data); @@ -230,7 +230,7 @@ static bool task_overlay_load_desc( char overlay_desc_key[32]; char overlay_key[64]; char overlay[256]; - char *tok, *save; + char *tok, *save = NULL; unsigned list_size = 0; char *elem0 = NULL; char *elem1 = NULL; @@ -835,7 +835,7 @@ static void task_overlay_deferred_load(retro_task_t *task) if (config_get_array(conf, overlay->config.rect.key, overlay->config.rect.array, sizeof(overlay->config.rect.array))) { - char *tok, *save; + char *tok, *save = NULL; char *elem0 = NULL; char *elem1 = NULL; char *elem2 = NULL; From 16209a0936ede85266e9ff7a6a46a904608d87e0 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Fri, 17 Jan 2025 12:32:54 +0100 Subject: [PATCH 33/49] (configuration.c) Cleanups/remove some redundant char buffers (rcheevos) Fix warning --- configuration.c | 53 ++++++++++------------------ deps/rcheevos/src/rcheevos/runtime.c | 4 +-- 2 files changed, 20 insertions(+), 37 deletions(-) diff --git a/configuration.c b/configuration.c index 6771ca4979bf..2631bc01fec6 100644 --- a/configuration.c +++ b/configuration.c @@ -4489,29 +4489,15 @@ bool config_load_override(void *data) bool config_load_override_file(const char *config_path) { - char config_directory[DIR_MAX_LENGTH]; - bool should_append = false; - bool show_notification = true; - settings_t *settings = config_st; - - config_directory[0] = '\0'; + settings_t *settings = config_st; path_clear(RARCH_PATH_CONFIG_OVERRIDE); - /* Get base config directory */ - fill_pathname_application_special(config_directory, - sizeof(config_directory), - APPLICATION_SPECIAL_DIRECTORY_CONFIG); - - if (path_is_valid(config_path)) - { - path_set(RARCH_PATH_CONFIG_OVERRIDE, config_path); - should_append = true; - } - - if (!should_append) + if (!path_is_valid(config_path)) return false; + path_set(RARCH_PATH_CONFIG_OVERRIDE, config_path); + /* Re-load the configuration with any overrides * that might have been found */ @@ -4523,8 +4509,7 @@ bool config_load_override_file(const char *config_path) path_get(RARCH_PATH_CONFIG), settings)) return false; - if (settings->bools.notification_show_config_override_load - && show_notification) + if (settings->bools.notification_show_config_override_load) { char msg[128]; size_t _len = strlcpy(msg, msg_hash_to_str(MSG_CONFIG_OVERRIDE_LOADED), sizeof(msg)); @@ -6205,12 +6190,10 @@ static bool config_file_salamander_get_path(char *s, size_t len) void config_load_file_salamander(void) { - config_file_t *config = NULL; char config_path[PATH_MAX_LENGTH]; - char libretro_path[PATH_MAX_LENGTH]; + config_file_t *config = NULL; config_path[0] = '\0'; - libretro_path[0] = '\0'; /* Get config file path */ if (!config_file_salamander_get_path( @@ -6227,10 +6210,10 @@ void config_load_file_salamander(void) config_path); if (config_get_path(config, "libretro_path", - libretro_path, sizeof(libretro_path)) - && !string_is_empty(libretro_path) - && !string_is_equal(libretro_path, "builtin")) - path_set(RARCH_PATH_CORE, libretro_path); + config_path, sizeof(config_path)) + && !string_is_empty(config_path) + && !string_is_equal(config_path, "builtin")) + path_set(RARCH_PATH_CORE, config_path); config_file_free(config); } @@ -6452,7 +6435,6 @@ void input_config_parse_joy_axis( { char tmp[64]; char key[64]; - char key_label[64]; config_file_t *conf = (config_file_t*)conf_data; struct retro_keybind *bind = (struct retro_keybind*)bind_data; struct config_entry_list *tmp_a = NULL; @@ -6461,8 +6443,6 @@ void input_config_parse_joy_axis( fill_pathname_join_delim(key, s, "axis", '_', sizeof(key)); - fill_pathname_join_delim(key_label, s, - "axis_label", '_', sizeof(key_label)); if (config_get_array(conf, key, tmp, sizeof(tmp))) { @@ -6489,7 +6469,10 @@ void input_config_parse_joy_axis( bind->orig_joyaxis = bind->joyaxis; } - tmp_a = config_get_entry(conf, key_label); + fill_pathname_join_delim(key, s, + "axis_label", '_', sizeof(key)); + + tmp_a = config_get_entry(conf, key); if (tmp_a && (!string_is_empty(tmp_a->value))) { @@ -6543,7 +6526,6 @@ void input_config_parse_joy_button( { char tmp[64]; char key[64]; - char key_label[64]; config_file_t *conf = (config_file_t*)data; struct retro_keybind *bind = (struct retro_keybind*)bind_data; struct config_entry_list *tmp_a = NULL; @@ -6552,8 +6534,6 @@ void input_config_parse_joy_button( fill_pathname_join_delim(key, s, "btn", '_', sizeof(key)); - fill_pathname_join_delim(key_label, s, - "btn_label", '_', sizeof(key_label)); if (config_get_array(conf, key, tmp, sizeof(tmp))) { @@ -6584,7 +6564,10 @@ void input_config_parse_joy_button( } } - tmp_a = config_get_entry(conf, key_label); + fill_pathname_join_delim(key, s, + "btn_label", '_', sizeof(key)); + + tmp_a = config_get_entry(conf, key); if (tmp_a && !string_is_empty(tmp_a->value)) { diff --git a/deps/rcheevos/src/rcheevos/runtime.c b/deps/rcheevos/src/rcheevos/runtime.c index 25e9885dcf93..292b21b5d932 100644 --- a/deps/rcheevos/src/rcheevos/runtime.c +++ b/deps/rcheevos/src/rcheevos/runtime.c @@ -316,7 +316,7 @@ int rc_runtime_activate_lboard(rc_runtime_t* self, uint32_t id, const char* mema rc_lboard_t* lboard; rc_parse_state_t parse; rc_runtime_lboard_t* runtime_lboard; - int size; + int32_t size; uint32_t i; if (memaddr == 0) @@ -834,7 +834,7 @@ void rc_runtime_invalidate_address(rc_runtime_t* self, uint32_t address) { } } -void rc_runtime_validate_addresses(rc_runtime_t* self, rc_runtime_event_handler_t event_handler, +void rc_runtime_validate_addresses(rc_runtime_t* self, rc_runtime_event_handler_t event_handler, rc_runtime_validate_address_t validate_handler) { rc_memref_t** last_memref = &self->memrefs; rc_memref_t* memref = self->memrefs; From 1e83bfb97159e522e6689aa70d2435ca5ddeffe2 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Fri, 17 Jan 2025 12:55:45 +0100 Subject: [PATCH 34/49] Reduce char arrays --- libretro-common/file/config_file_userdata.c | 81 +++++++++------------ 1 file changed, 36 insertions(+), 45 deletions(-) diff --git a/libretro-common/file/config_file_userdata.c b/libretro-common/file/config_file_userdata.c index 799ce5f2a4ff..e0459f3df747 100644 --- a/libretro-common/file/config_file_userdata.c +++ b/libretro-common/file/config_file_userdata.c @@ -28,55 +28,46 @@ int config_userdata_get_float(void *userdata, const char *key_str, float *value, float default_value) { - bool got; - char key[2][256]; + char key[256]; struct config_file_userdata *usr = (struct config_file_userdata*)userdata; - - fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0])); - fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1])); - - got = config_get_float (usr->conf, key[0], value); - got = got || config_get_float(usr->conf, key[1], value); - - if (!got) - *value = default_value; - return got; + fill_pathname_join_delim(key, usr->prefix[0], key_str, '_', sizeof(key)); + if (config_get_float(usr->conf, key, value)) + return true; + *value = default_value; + fill_pathname_join_delim(key, usr->prefix[1], key_str, '_', sizeof(key)); + if (config_get_float(usr->conf, key, value)) + return true; + return false; } int config_userdata_get_int(void *userdata, const char *key_str, int *value, int default_value) { - bool got; - char key[2][256]; + char key[256]; struct config_file_userdata *usr = (struct config_file_userdata*)userdata; - - fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0])); - fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1])); - - got = config_get_int (usr->conf, key[0], value); - got = got || config_get_int(usr->conf, key[1], value); - - if (!got) - *value = default_value; - return got; + fill_pathname_join_delim(key, usr->prefix[0], key_str, '_', sizeof(key)); + if (config_get_int(usr->conf, key, value)) + return true; + *value = default_value; + fill_pathname_join_delim(key, usr->prefix[1], key_str, '_', sizeof(key)); + if (config_get_int(usr->conf, key, value)) + return true; + return false; } int config_userdata_get_hex(void *userdata, const char *key_str, unsigned *value, unsigned default_value) { - bool got; - char key[2][256]; + char key[256]; struct config_file_userdata *usr = (struct config_file_userdata*)userdata; - - fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0])); - fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1])); - - got = config_get_hex(usr->conf, key[0], value); - got = got || config_get_hex(usr->conf, key[1], value); - - if (!got) - *value = default_value; - return got; + fill_pathname_join_delim(key, usr->prefix[0], key_str, '_', sizeof(key)); + if (config_get_hex(usr->conf, key, value)) + return true; + *value = default_value; + fill_pathname_join_delim(key, usr->prefix[1], key_str, '_', sizeof(key)); + if (config_get_hex(usr->conf, key, value)) + return true; + return false; } int config_userdata_get_float_array(void *userdata, const char *key_str, @@ -84,14 +75,14 @@ int config_userdata_get_float_array(void *userdata, const char *key_str, const float *default_values, unsigned num_default_values) { char key[2][256]; - struct config_file_userdata *usr = (struct config_file_userdata*)userdata; char *str = NULL; + struct config_file_userdata *usr = (struct config_file_userdata*)userdata; fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0])); fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1])); - if ( config_get_string(usr->conf, key[0], &str) || - config_get_string(usr->conf, key[1], &str)) + if ( config_get_string(usr->conf, key[0], &str) + || config_get_string(usr->conf, key[1], &str)) { unsigned i; struct string_list list = {0}; @@ -117,13 +108,13 @@ int config_userdata_get_int_array(void *userdata, const char *key_str, const int *default_values, unsigned num_default_values) { char key[2][256]; - struct config_file_userdata *usr = (struct config_file_userdata*)userdata; char *str = NULL; + struct config_file_userdata *usr = (struct config_file_userdata*)userdata; fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0])); fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1])); - if ( config_get_string(usr->conf, key[0], &str) || - config_get_string(usr->conf, key[1], &str)) + if ( config_get_string(usr->conf, key[0], &str) + || config_get_string(usr->conf, key[1], &str)) { unsigned i; struct string_list list = {0}; @@ -148,13 +139,13 @@ int config_userdata_get_string(void *userdata, const char *key_str, char **output, const char *default_output) { char key[2][256]; - struct config_file_userdata *usr = (struct config_file_userdata*)userdata; char *str = NULL; + struct config_file_userdata *usr = (struct config_file_userdata*)userdata; fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0])); fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1])); - if ( config_get_string(usr->conf, key[0], &str) || - config_get_string(usr->conf, key[1], &str)) + if ( config_get_string(usr->conf, key[0], &str) + || config_get_string(usr->conf, key[1], &str)) { *output = str; return true; From b47e09534cda70681326f16eb7fb0e012f1b5d7f Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Fri, 17 Jan 2025 13:10:17 +0100 Subject: [PATCH 35/49] Less string copies --- libretro-common/file/archive_file_7z.c | 38 ++++++++------------- libretro-common/file/archive_file_zlib.c | 43 ++++++++++-------------- 2 files changed, 32 insertions(+), 49 deletions(-) diff --git a/libretro-common/file/archive_file_7z.c b/libretro-common/file/archive_file_7z.c index ef9f96b9de9b..89486d668e2b 100644 --- a/libretro-common/file/archive_file_7z.c +++ b/libretro-common/file/archive_file_7z.c @@ -59,7 +59,7 @@ struct sevenzip_context_t uint32_t parse_index; uint32_t decompress_index; uint32_t packIndex; - uint32_t block_index; + uint32_t block_index; }; static void *sevenzip_stream_alloc_impl(ISzAllocPtr p, size_t len) @@ -71,15 +71,12 @@ static void *sevenzip_stream_alloc_impl(ISzAllocPtr p, size_t len) static void sevenzip_stream_free_impl(ISzAllocPtr p, void *address) { - (void)p; - if (address) free(address); } static void *sevenzip_stream_alloc_tmp_impl(ISzAllocPtr p, size_t len) { - (void)p; if (len == 0) return 0; return malloc(len); @@ -140,11 +137,11 @@ static int64_t sevenzip_file_read( const char *needle, void **buf, const char *optional_outfile) { + CSzArEx db; CFileInStream archiveStream; CLookToRead2 lookStream; ISzAlloc allocImp; ISzAlloc allocTempImp; - CSzArEx db; uint8_t *output = 0; int64_t outsize = -1; @@ -164,18 +161,16 @@ static int64_t sevenzip_file_read( #if defined(_WIN32) && defined(USE_WINDOWS_FILE) && !defined(LEGACY_WIN32) if (!string_is_empty(path)) { - wchar_t *pathW = utf8_to_utf16_string_alloc(path); - - if (pathW) + wchar_t *path_w = utf8_to_utf16_string_alloc(path); + if (path_w) { /* Could not open 7zip archive? */ - if (InFile_OpenW(&archiveStream.file, pathW)) + if (InFile_OpenW(&archiveStream.file, path_w)) { - free(pathW); + free(path_w); return -1; } - - free(pathW); + free(path_w); } } #else @@ -276,7 +271,7 @@ static int64_t sevenzip_file_read( * copy and free the old one. */ *buf = malloc((size_t)(outsize + 1)); ((char*)(*buf))[outsize] = '\0'; - memcpy(*buf,output + offset,outsize); + memcpy(*buf, output + offset, outsize); } break; } @@ -369,18 +364,18 @@ static int sevenzip_parse_file_init(file_archive_transfer_t *state, #if defined(_WIN32) && defined(USE_WINDOWS_FILE) && !defined(LEGACY_WIN32) if (!string_is_empty(file)) { - wchar_t *fileW = utf8_to_utf16_string_alloc(file); + wchar_t *file_w = utf8_to_utf16_string_alloc(file); - if (fileW) + if (file_w) { /* could not open 7zip archive? */ - if (InFile_OpenW(&sevenzip_context->archiveStream.file, fileW)) + if (InFile_OpenW(&sevenzip_context->archiveStream.file, file_w)) { - free(fileW); + free(file_w); goto error; } - free(fileW); + free(file_w); } } #else @@ -439,21 +434,18 @@ static int sevenzip_parse_file_iterate_step_internal( if ( (_len < PATH_MAX_LENGTH) && !SzArEx_IsDir(&sevenzip_context->db, sevenzip_context->parse_index)) { - char infile[PATH_MAX_LENGTH]; SRes res = SZ_ERROR_FAIL; uint16_t *temp = (uint16_t*)malloc(_len * sizeof(uint16_t)); if (!temp) return -1; - infile[0] = '\0'; - SzArEx_GetFileNameUtf16(&sevenzip_context->db, sevenzip_context->parse_index, temp); if (temp) { - res = utf16_to_char_string(temp, infile, sizeof(infile)) + res = utf16_to_char_string(temp, s, PATH_MAX_LENGTH) ? SZ_OK : SZ_ERROR_FAIL; free(temp); } @@ -461,8 +453,6 @@ static int sevenzip_parse_file_iterate_step_internal( if (res != SZ_OK) return -1; - strlcpy(s, infile, PATH_MAX_LENGTH); - *cmode = 0; /* unused for 7zip */ *checksum = sevenzip_context->db.CRCs.Vals[sevenzip_context->parse_index]; *size = (uint32_t)SzArEx_GetFileSize(&sevenzip_context->db, sevenzip_context->parse_index); diff --git a/libretro-common/file/archive_file_zlib.c b/libretro-common/file/archive_file_zlib.c index 352650dd21fe..29f6f3880fcb 100644 --- a/libretro-common/file/archive_file_zlib.c +++ b/libretro-common/file/archive_file_zlib.c @@ -61,15 +61,13 @@ typedef struct uint8_t *decompressed_data; } zip_context_t; -static INLINE uint32_t read_le(const uint8_t *data, unsigned size) +static INLINE uint32_t read_le(const uint8_t *data, size_t len) { unsigned i; uint32_t val = 0; - - size *= 8; - for (i = 0; i < size; i += 8) + len *= 8; + for (i = 0; i < len; i += 8) val |= (uint32_t)*data++ << i; - return val; } @@ -114,9 +112,7 @@ static bool zlib_stream_decompress_data_to_file_init( /* seek past most of the local directory header */ #ifdef HAVE_MMAP if (state->archive_mmap_data) - { local_header = state->archive_mmap_data + (size_t)cdata + 26; - } else #endif { @@ -181,13 +177,11 @@ static int zlib_stream_decompress_data_to_file_iterate( if (zip_context->cmode == ZIP_MODE_STORED) { #ifdef HAVE_MMAP + /* Simply copy the data to the output buffer */ if (zip_context->state->archive_mmap_data) - { - /* Simply copy the data to the output buffer */ memcpy(zip_context->decompressed_data, zip_context->state->archive_mmap_data + (size_t)zip_context->fdoffset, zip_context->usize); - } else #endif { @@ -204,27 +198,26 @@ static int zlib_stream_decompress_data_to_file_iterate( } else if (zip_context->cmode == ZIP_MODE_DEFLATED) { - int to_read = MIN(zip_context->csize - zip_context->boffset, _READ_CHUNK_SIZE); uint8_t *dptr; + int to_read = MIN(zip_context->csize - zip_context->boffset, _READ_CHUNK_SIZE); + /* File was uncompressed or decompression finished before */ if (!zip_context->zstream) - { - /* file was uncompressed or decompression finished before */ return 1; - } #ifdef HAVE_MMAP if (state->archive_mmap_data) { /* Decompress from the mapped file */ dptr = state->archive_mmap_data + (size_t)zip_context->fdoffset + zip_context->boffset; - rd = to_read; + rd = to_read; } else #endif { /* Read some compressed data from file to the temp buffer */ - filestream_seek(state->archive_file, zip_context->fdoffset + zip_context->boffset, - RETRO_VFS_SEEK_POSITION_START); + filestream_seek(state->archive_file, + zip_context->fdoffset + zip_context->boffset, + RETRO_VFS_SEEK_POSITION_START); rd = filestream_read(state->archive_file, zip_context->tmpbuf, to_read); if (rd < 0) return -1; @@ -365,7 +358,6 @@ static int64_t zip_file_read( file_archive_transfer_t state = {0}; decomp_state_t decomp = {0}; struct archive_extract_userdata userdata = {0}; - bool returnerr = true; int ret = 0; if (needle) @@ -380,6 +372,7 @@ static int64_t zip_file_read( do { + bool returnerr = true; ret = file_archive_parse_file_iterate(&state, &returnerr, path, "", zip_file_decompressed, &userdata); if (!returnerr) @@ -522,13 +515,13 @@ static int zip_parse_file_iterate_step(void *context, file_archive_file_cb file_cb) { zip_context_t *zip_context = (zip_context_t *)context; - const uint8_t *cdata = NULL; - uint32_t checksum = 0; - uint32_t size = 0; - uint32_t csize = 0; - unsigned cmode = 0; - unsigned payload = 0; - int ret = zip_parse_file_iterate_step_internal(zip_context, + const uint8_t *cdata = NULL; + uint32_t checksum = 0; + uint32_t size = 0; + uint32_t csize = 0; + unsigned cmode = 0; + unsigned payload = 0; + int ret = zip_parse_file_iterate_step_internal(zip_context, userdata->current_file_path, &cdata, &cmode, &size, &csize, &checksum, &payload); if (ret != 1) From dda78a4fc80394da38c8c3c95a26ee4eccff5230 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Fri, 17 Jan 2025 13:26:17 +0100 Subject: [PATCH 36/49] Use find_last_slash where possible --- retroarch.c | 4 +--- tasks/task_content.c | 4 +--- tasks/task_database.c | 14 +++----------- verbosity.c | 4 +--- 4 files changed, 6 insertions(+), 20 deletions(-) diff --git a/retroarch.c b/retroarch.c index e4f4b94bebe8..27aa4d2a0f2a 100644 --- a/retroarch.c +++ b/retroarch.c @@ -6611,12 +6611,10 @@ static void retroarch_parse_input_libretro_path( else { size_t _len; - const char *slash = strrchr(path, '/'); - const char *backslash = strrchr(path, '\\'); /* If path has no extension and contains no path * delimiters, check if it is a core 'name', matching * an existing file in the cores directory */ - if (((!slash || (backslash > slash)) ? (char*)backslash : (char*)slash)) + if (find_last_slash(path)) goto end; /* First check for built-in cores */ diff --git a/tasks/task_content.c b/tasks/task_content.c index 10de01f9a115..eaa20b73151d 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -602,9 +602,7 @@ static bool content_file_list_set_info( if (!string_is_empty(dir)) { /* Remove any trailing slash */ - const char *slash = strrchr(dir, '/'); - const char *backslash = strrchr(dir, '\\'); - char *last_slash = (!slash || (backslash > slash)) ? (char*)backslash : (char*)slash; + char *last_slash = find_last_slash(dir); if (last_slash && (last_slash[1] == '\0')) *last_slash = '\0'; diff --git a/tasks/task_database.c b/tasks/task_database.c index 310e9d3b72c0..da6bfa1f27a5 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -1287,9 +1287,7 @@ static void task_database_handler(retro_task_t *task) if (!string_is_empty(db->fullpath)) { - const char *slash = strrchr(db->fullpath, '/'); - const char *backslash = strrchr(db->fullpath, '\\'); - char *last_slash = (!slash || (backslash > slash)) ? (char*)backslash : (char*)slash; + char *last_slash = find_last_slash(db->fullpath); dirname = last_slash + 1; } @@ -1298,20 +1296,14 @@ static void task_database_handler(retro_task_t *task) for (i = 0; i < dbstate->list->size; i++) { char *last_slash; - const char *slash; - const char *backslash; const char *data = dbstate->list->elems[i].data; - char *dbname = NULL; bool strmatch = false; char *dbpath = strdup(data); path_remove_extension(dbpath); - slash = strrchr(dbpath, '/'); - backslash = strrchr(dbpath, '\\'); - last_slash = (!slash || (backslash > slash)) ? (char*)backslash : (char*)slash; - dbname = last_slash + 1; - strmatch = strcasecmp(dbname, dirname) == 0; + last_slash = find_last_slash(dbpath); + strmatch = strcasecmp(last_slash + 1, dirname) == 0; free(dbpath); diff --git a/verbosity.c b/verbosity.c index d785e88e1529..5f46967846da 100644 --- a/verbosity.c +++ b/verbosity.c @@ -501,9 +501,7 @@ void rarch_log_file_init( { /* Get log directory */ const char *override_path = g_verbosity->override_path; - const char *slash = strrchr(override_path, '/'); - const char *backslash = strrchr(override_path, '\\'); - const char *last_slash = (!slash || (backslash > slash)) ? (char*)backslash : (char*)slash; + const char *last_slash = find_last_slash(override_path); if (last_slash) { From 2471082ced2e13b2d1772ec8778088d453a7b222 Mon Sep 17 00:00:00 2001 From: Eric Warmenhoven Date: Fri, 17 Jan 2025 13:54:54 -0500 Subject: [PATCH 37/49] macos: fix some sandbox handling for app store (#17424) * minor safety check * macos: fix some sandbox handling for app store --- frontend/drivers/platform_darwin.m | 4 ++-- menu/cbs/menu_cbs_ok.c | 5 ++++- menu/menu_displaylist.c | 4 ++-- ui/drivers/cocoa/apple_platform.h | 5 +++++ ui/drivers/cocoa/cocoa_common.m | 7 +++++++ ui/drivers/ui_cocoa.m | 25 ++++++++++++++++--------- 6 files changed, 36 insertions(+), 14 deletions(-) diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index e27c38fccccc..970dd376e6a7 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -704,7 +704,7 @@ static enum frontend_architecture frontend_darwin_get_arch(void) static int frontend_darwin_parse_drive_list(void *data, bool load_content) { int ret = -1; -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || defined(HAVE_APPLE_STORE) #ifdef HAVE_MENU struct string_list *str_list = NULL; file_list_t *list = (file_list_t*)data; @@ -733,7 +733,7 @@ static int frontend_darwin_parse_drive_list(void *data, bool load_content) FILE_TYPE_DIRECTORY, 0, 0, NULL); string_list_free(str_list); -#if TARGET_OS_IOS +#if !TARGET_OS_TV if ( filebrowser_get_type() == FILEBROWSER_NONE || filebrowser_get_type() == FILEBROWSER_SCAN_FILE || filebrowser_get_type() == FILEBROWSER_SELECT_FILE) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index aa97852ba8ce..be032c88c2c9 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -6467,9 +6467,12 @@ static int action_ok_open_uwp_permission_settings(const char *path, static int action_ok_open_picker(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { -#if TARGET_OS_IOS +#ifdef IOS ios_show_file_sheet(); return 0; +#elif defined(OSX) && defined(HAVE_APPLE_STORE) + osx_show_file_sheet(); + return 0; #else char *new_path = NULL; int ret = generic_action_ok_displaylist_push( diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 232ced8a7f4d..b386968eaaae 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -492,7 +492,7 @@ static int filebrowser_parse( MENU_ENUM_LABEL_NO_ITEMS, MENU_SETTING_NO_ITEM, 0, 0, NULL); -#ifdef IOS +#if defined(IOS) || (defined(OSX) && defined(HAVE_APPLE_STORE)) { /* Check if we're allowed to escape our sandbox */ struct string_list *str_list = string_list_new(); @@ -5154,7 +5154,7 @@ static unsigned menu_displaylist_parse_content_information( db_name, sizeof(db_path)); last = path_get_extension_mutable(db_path); - if (*last) + if (last && *last) { last[0] = '.'; last[1] = 'r'; diff --git a/ui/drivers/cocoa/apple_platform.h b/ui/drivers/cocoa/apple_platform.h index 86bb97ee19a0..4128b396586f 100644 --- a/ui/drivers/cocoa/apple_platform.h +++ b/ui/drivers/cocoa/apple_platform.h @@ -15,6 +15,10 @@ extern void ios_show_file_sheet(void); extern bool ios_running_on_ipad(void); #endif +#if TARGET_OS_OSX +extern void osx_show_file_sheet(void); +#endif + #ifdef __OBJC__ #import @@ -56,6 +60,7 @@ typedef enum apple_view_type * the displays should not sleep. */ - (bool)setDisableDisplaySleep:(bool)disable; +- (void)openDocument:(id)sender; @end #endif diff --git a/ui/drivers/cocoa/cocoa_common.m b/ui/drivers/cocoa/cocoa_common.m index 20569fa70930..7656c90ea069 100644 --- a/ui/drivers/cocoa/cocoa_common.m +++ b/ui/drivers/cocoa/cocoa_common.m @@ -802,6 +802,13 @@ void ios_show_file_sheet(void) } #endif +#if TARGET_OS_OSX && defined(HAVE_APPLE_STORE) +void osx_show_file_sheet(void) +{ + [apple_platform openDocument:nil]; +} +#endif + void *cocoa_screen_get_chosen(void) { unsigned monitor_index; diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index c40c45885711..8da4b6624571 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -918,16 +918,23 @@ static void open_document_handler( if (!result) return; - path_set(RARCH_PATH_CONTENT, state->result); - - if (core_name) + if (filebrowser_get_type() == FILEBROWSER_SCAN_FILE) + action_scan_file(state->result, NULL, 0, 0); + else { - content_ctx_info_t content_info = {0}; - task_push_load_content_with_current_core_from_companion_ui( - NULL, - &content_info, - CORE_TYPE_PLAIN, - NULL, NULL); + path_set(RARCH_PATH_CONTENT, state->result); + + if (!string_is_empty(core_name)) + { + content_ctx_info_t content_info = {0}; + task_push_load_content_with_current_core_from_companion_ui( + NULL, + &content_info, + CORE_TYPE_PLAIN, + NULL, NULL); + } + else + cocoa_file_load_with_detect_core(state->result); } } From ec54cdfcf01f36e91ef4253a7bbd158090be2064 Mon Sep 17 00:00:00 2001 From: Ethan O'Brien <77750390+ethanaobrien@users.noreply.github.com> Date: Fri, 17 Jan 2025 12:55:02 -0600 Subject: [PATCH 38/49] Add HAVE_CHD flag for emscripten makefile (#17423) --- Makefile.emscripten | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.emscripten b/Makefile.emscripten index 475cbcc3e396..55a435b563b8 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -48,6 +48,7 @@ HAVE_CORE_INFO_CACHE = 1 HAVE_7ZIP = 1 HAVE_BSV_MOVIE = 1 HAVE_AL = 1 +HAVE_CHD ?= 0 # WARNING -- READ BEFORE ENABLING # The rwebaudio driver is known to have several audio bugs, such as @@ -150,8 +151,7 @@ LDFLAGS += -s STACK_SIZE=131072 LDFLAGS += --extern-pre-js emscripten/pre.js -CFLAGS += -Wall -I. -Ilibretro-common/include -std=gnu99 #\ -# -s EXPORTED_FUNCTIONS="['_main', '_malloc', '_cmd_savefiles', '_cmd_save_state', '_cmd_take_screenshot']" +CFLAGS += -Wall -I. -Ilibretro-common/include -Ideps/7zip -std=gnu99 RARCH_OBJ := $(addprefix $(OBJDIR)/,$(OBJ)) From b211adaaca5f47f0916283551e4f8b4ea4156063 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Fri, 17 Jan 2025 19:55:08 +0100 Subject: [PATCH 39/49] Function argument name standardization --- audio/audio_driver.h | 2 +- cores/dynamic_dummy.c | 84 +--- cores/internal_cores.h | 24 +- cores/libretro-ffmpeg/ffmpeg_core.c | 49 +- .../video_processor_v4l2.c | 425 ++++++++++-------- frontend/drivers/platform_darwin.m | 29 +- frontend/drivers/platform_wii.c | 6 +- frontend/frontend_driver.c | 3 +- frontend/frontend_driver.h | 3 +- gfx/common/vulkan_common.h | 4 +- gfx/drivers/gl3.c | 4 +- gfx/drivers/omap_gfx.c | 15 +- gfx/drivers_shader/shader_gl3.cpp | 4 +- input/drivers_hid/btstack_hid.c | 4 +- input/drivers_hid/iohidmanager_hid.c | 22 +- input/drivers_hid/libusb_hid.c | 8 +- input/drivers_hid/wiiusb_hid.c | 6 +- input/drivers_keyboard/keyboard_event_xkb.c | 8 +- input/include/hid_driver.h | 4 +- libretro-common/formats/png/rpng.c | 20 +- libretro-common/hash/lrc_hash.c | 4 +- libretro-common/include/compat/msvc.h | 4 +- libretro-common/include/compat/strl.h | 4 +- libretro-common/include/fastcpy.h | 36 +- libretro-common/include/file/file_path.h | 153 ++++--- libretro-common/include/memalign.h | 4 +- libretro-common/include/net/net_http.h | 4 +- libretro-common/include/net/net_socket.h | 14 +- libretro-common/include/net/net_socket_ssl.h | 8 +- libretro-common/include/queues/fifo_queue.h | 8 +- .../include/queues/message_queue.h | 6 +- .../include/streams/network_stream.h | 2 +- .../include/streams/stdin_stream.h | 2 +- libretro-common/include/string/stdstring.h | 8 +- libretro-common/net/net_socket_ssl_bear.c | 122 +++-- libretro-common/net/net_socket_ssl_mbed.c | 34 +- libretro-db/rmsgpack.c | 12 +- menu/cbs/menu_cbs_left.c | 4 +- menu/cbs/menu_cbs_right.c | 4 +- menu/drivers/materialui.c | 4 +- menu/menu_displaylist.c | 4 +- network/netplay/netplay_private.h | 4 +- tasks/task_database.c | 22 +- tasks/task_menu_explore.c | 8 +- tasks/task_save.c | 14 +- ui/drivers/qt/qt_options.h | 12 +- ui/drivers/ui_qt.cpp | 14 +- 47 files changed, 593 insertions(+), 646 deletions(-) diff --git a/audio/audio_driver.h b/audio/audio_driver.h index 4dcb6a659348..1a0275863e31 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -110,7 +110,7 @@ typedef struct audio_driver * Unless said otherwise with set_nonblock_state(), all writes * are blocking, and it should block till it has written all frames. */ - ssize_t (*write)(void *data, const void *buf, size_t size); + ssize_t (*write)(void *data, const void *buf, size_t len); /** * Temporarily pauses the audio driver. diff --git a/cores/dynamic_dummy.c b/cores/dynamic_dummy.c index fc23656bfd4f..e1c2fbdb482e 100644 --- a/cores/dynamic_dummy.c +++ b/cores/dynamic_dummy.c @@ -54,8 +54,8 @@ void retro_unload_game(void) { libretro_dummy_retro_unload_game(); } unsigned retro_get_region(void) { return libretro_dummy_retro_get_region(); } bool retro_load_game_special(unsigned type, const struct retro_game_info *info, size_t num) { return libretro_dummy_retro_load_game_special(type, info, num); } size_t retro_serialize_size(void) { return libretro_dummy_retro_serialize_size(); } -bool retro_serialize(void *data, size_t size) { return libretro_dummy_retro_serialize(data, size); } -bool retro_unserialize(const void *data, size_t size) { return libretro_dummy_retro_unserialize(data, size); } +bool retro_serialize(void *data, size_t len) { return libretro_dummy_retro_serialize(data, len); } +bool retro_unserialize(const void *data, size_t len) { return libretro_dummy_retro_unserialize(data, len); } void *retro_get_memory_data(unsigned id) { return libretro_dummy_retro_get_memory_data(id); } size_t retro_get_memory_size(unsigned id) { return libretro_dummy_retro_get_memory_size(id); } void retro_cheat_reset(void) { libretro_dummy_retro_cheat_reset(); } @@ -119,13 +119,6 @@ unsigned libretro_dummy_retro_api_version(void) return RETRO_API_VERSION; } -void libretro_dummy_retro_set_controller_port_device( - unsigned port, unsigned device) -{ - (void)port; - (void)device; -} - void libretro_dummy_retro_get_system_info( struct retro_system_info *info) { @@ -197,9 +190,6 @@ void libretro_dummy_retro_set_video_refresh(retro_video_refresh_t cb) dummy_video_cb = cb; } -void libretro_dummy_retro_reset(void) -{} - void libretro_dummy_retro_run(void) { dummy_input_poll_cb(); @@ -209,66 +199,22 @@ void libretro_dummy_retro_run(void) /* This should never be called, it's only used as a placeholder. */ bool libretro_dummy_retro_load_game(const struct retro_game_info *info) { - (void)info; return false; } -void libretro_dummy_retro_unload_game(void) -{} - -unsigned libretro_dummy_retro_get_region(void) -{ - return RETRO_REGION_NTSC; -} - +void libretro_dummy_retro_set_controller_port_device( + unsigned port, unsigned device) { } +void libretro_dummy_retro_reset(void) { } +unsigned libretro_dummy_retro_get_region(void) { return RETRO_REGION_NTSC; } +void libretro_dummy_retro_unload_game(void) { } bool libretro_dummy_retro_load_game_special(unsigned type, - const struct retro_game_info *info, size_t num) -{ - (void)type; - (void)info; - (void)num; - return false; -} - -size_t libretro_dummy_retro_serialize_size(void) -{ - return 0; -} - -bool libretro_dummy_retro_serialize(void *data, size_t size) -{ - (void)data; - (void)size; - return false; -} - + const struct retro_game_info *info, size_t num) { return false; } +size_t libretro_dummy_retro_serialize_size(void) { return 0; } +bool libretro_dummy_retro_serialize(void *data, size_t len) { return false; } bool libretro_dummy_retro_unserialize(const void *data, - size_t size) -{ - (void)data; - (void)size; - return false; -} - -void *libretro_dummy_retro_get_memory_data(unsigned id) -{ - (void)id; - return NULL; -} - -size_t libretro_dummy_retro_get_memory_size(unsigned id) -{ - (void)id; - return 0; -} - -void libretro_dummy_retro_cheat_reset(void) -{} - + size_t len) { return false; } +void *libretro_dummy_retro_get_memory_data(unsigned id) { return NULL; } +size_t libretro_dummy_retro_get_memory_size(unsigned id) { return 0; } +void libretro_dummy_retro_cheat_reset(void) { } void libretro_dummy_retro_cheat_set(unsigned idx, - bool enabled, const char *code) -{ - (void)idx; - (void)enabled; - (void)code; -} + bool enabled, const char *code) { } diff --git a/cores/internal_cores.h b/cores/internal_cores.h index 08e916d63e32..2d5193247e6d 100644 --- a/cores/internal_cores.h +++ b/cores/internal_cores.h @@ -59,9 +59,9 @@ void libretro_dummy_retro_run(void); size_t libretro_dummy_retro_serialize_size(void); -bool libretro_dummy_retro_serialize(void *data, size_t size); +bool libretro_dummy_retro_serialize(void *data, size_t len); -bool libretro_dummy_retro_unserialize(const void *data, size_t size); +bool libretro_dummy_retro_unserialize(const void *data, size_t len); void libretro_dummy_retro_cheat_reset(void); @@ -113,9 +113,9 @@ void libretro_ffmpeg_retro_run(void); size_t libretro_ffmpeg_retro_serialize_size(void); -bool libretro_ffmpeg_retro_serialize(void *data, size_t size); +bool libretro_ffmpeg_retro_serialize(void *data, size_t len); -bool libretro_ffmpeg_retro_unserialize(const void *data, size_t size); +bool libretro_ffmpeg_retro_unserialize(const void *data, size_t len); void libretro_ffmpeg_retro_cheat_reset(void); @@ -169,9 +169,9 @@ void libretro_mpv_retro_run(void); size_t libretro_mpv_retro_serialize_size(void); -bool libretro_mpv_retro_serialize(void *data, size_t size); +bool libretro_mpv_retro_serialize(void *data, size_t len); -bool libretro_mpv_retro_unserialize(const void *data, size_t size); +bool libretro_mpv_retro_unserialize(const void *data, size_t len); void libretro_mpv_retro_cheat_reset(void); @@ -225,9 +225,9 @@ void libretro_imageviewer_retro_run(void); size_t libretro_imageviewer_retro_serialize_size(void); -bool libretro_imageviewer_retro_serialize(void *data, size_t size); +bool libretro_imageviewer_retro_serialize(void *data, size_t len); -bool libretro_imageviewer_retro_unserialize(const void *data, size_t size); +bool libretro_imageviewer_retro_unserialize(const void *data, size_t len); void libretro_imageviewer_retro_cheat_reset(void); @@ -281,9 +281,9 @@ void libretro_netretropad_retro_run(void); size_t libretro_netretropad_retro_serialize_size(void); -bool libretro_netretropad_retro_serialize(void *data, size_t size); +bool libretro_netretropad_retro_serialize(void *data, size_t len); -bool libretro_netretropad_retro_unserialize(const void *data, size_t size); +bool libretro_netretropad_retro_unserialize(const void *data, size_t len); void libretro_netretropad_retro_cheat_reset(void); @@ -337,9 +337,9 @@ void libretro_videoprocessor_retro_run(void); size_t libretro_videoprocessor_retro_serialize_size(void); -bool libretro_videoprocessor_retro_serialize(void *data, size_t size); +bool libretro_videoprocessor_retro_serialize(void *data, size_t len); -bool libretro_videoprocessor_retro_unserialize(const void *data, size_t size); +bool libretro_videoprocessor_retro_unserialize(const void *data, size_t len); void libretro_videoprocessor_retro_cheat_reset(void); diff --git a/cores/libretro-ffmpeg/ffmpeg_core.c b/cores/libretro-ffmpeg/ffmpeg_core.c index 03a1525c9581..374d0a707268 100644 --- a/cores/libretro-ffmpeg/ffmpeg_core.c +++ b/cores/libretro-ffmpeg/ffmpeg_core.c @@ -222,14 +222,14 @@ static void ass_msg_cb(int level, const char *fmt, va_list args, void *data) } #endif -static void append_attachment(const uint8_t *data, size_t size) +static void append_attachment(const uint8_t *data, size_t len) { attachments = (struct attachment*)av_realloc( attachments, (attachments_size + 1) * sizeof(*attachments)); - attachments[attachments_size].data = (uint8_t*)av_malloc(size); - attachments[attachments_size].size = size; - memcpy(attachments[attachments_size].data, data, size); + attachments[attachments_size].data = (uint8_t*)av_malloc(len); + attachments[attachments_size].size = len; + memcpy(attachments[attachments_size].data, data, len); attachments_size++; } @@ -2278,41 +2278,12 @@ size_t CORE_PREFIX(retro_serialize_size)(void) return 0; } -bool CORE_PREFIX(retro_serialize)(void *data, size_t size) -{ - (void)data; - (void)size; - return false; -} - -bool CORE_PREFIX(retro_unserialize)(const void *data, size_t size) -{ - (void)data; - (void)size; - return false; -} - -void *CORE_PREFIX(retro_get_memory_data)(unsigned id) -{ - (void)id; - return NULL; -} - -size_t CORE_PREFIX(retro_get_memory_size)(unsigned id) -{ - (void)id; - return 0; -} - -void CORE_PREFIX(retro_cheat_reset)(void) -{} - -void CORE_PREFIX(retro_cheat_set)(unsigned index, bool enabled, const char *code) -{ - (void)index; - (void)enabled; - (void)code; -} +bool CORE_PREFIX(retro_serialize)(void *data, size_t len) { return false; } +bool CORE_PREFIX(retro_unserialize)(const void *data, size_t len) { return false; } +void *CORE_PREFIX(retro_get_memory_data)(unsigned id) { return NULL; } +size_t CORE_PREFIX(retro_get_memory_size)(unsigned id) { return 0; } +void CORE_PREFIX(retro_cheat_reset)(void) { } +void CORE_PREFIX(retro_cheat_set)(unsigned a, bool b, const char *c) { } #if defined(LIBRETRO_SWITCH) diff --git a/cores/libretro-video-processor/video_processor_v4l2.c b/cores/libretro-video-processor/video_processor_v4l2.c index dca3412f1bae..b8a5695b21a7 100644 --- a/cores/libretro-video-processor/video_processor_v4l2.c +++ b/cores/libretro-video-processor/video_processor_v4l2.c @@ -143,10 +143,7 @@ static void audio_callback(void) } } -static void -audio_set_state(bool enable) -{ -} +static void audio_set_state(bool enable) { } #endif static void @@ -330,9 +327,7 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_set_input_state)(retro_input_state_t VIDEOPROC_CORE_PREFIX(input_state_cb) = cb; } -RETRO_API void VIDEOPROC_CORE_PREFIX(retro_init)(void) -{ -} +RETRO_API void VIDEOPROC_CORE_PREFIX(retro_init)(void) { } static bool open_devices(void) { @@ -345,9 +340,8 @@ static bool open_devices(void) VIDEOPROC_CORE_PREFIX(environment_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &videodev); VIDEOPROC_CORE_PREFIX(environment_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &audiodev); - if (strcmp(videodev.value, "dummy") == 0) { + if (strcmp(videodev.value, "dummy") == 0) return true; - } /* Video device is required */ if (videodev.value == NULL) @@ -504,14 +498,17 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_get_system_av_info)(struct retro_syst VIDEOPROC_CORE_PREFIX(environment_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &videodev); - if (strcmp(videodev.value, "dummy") == 0) { + if (strcmp(videodev.value, "dummy") == 0) + { info->geometry.aspect_ratio = 4.0/3.0; info->geometry.base_width = info->geometry.max_width = video_cap_width; info->geometry.base_height = video_cap_height; /* out? */ info->geometry.max_height = video_out_height; info->timing.fps = 60; info->timing.sample_rate = AUDIO_SAMPLE_RATE; - } else { + } + else + { /* * Query the device cropping limits. If available, we can use this to find the capture pixel aspect. */ @@ -530,11 +527,10 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_get_system_av_info)(struct retro_syst (double)video_standard.frameperiod.numerator; info->timing.sample_rate = AUDIO_SAMPLE_RATE; - if (error == 0) { - /* TODO Allow for fixed 4:3 and 16:9 modes */ - info->geometry.aspect_ratio = (double)info->geometry.base_width / (double)info->geometry.max_height /\ - ((double)cc.pixelaspect.numerator / (double)cc.pixelaspect.denominator); - } + /* TODO/FIXME Allow for fixed 4:3 and 16:9 modes */ + if (error == 0) + info->geometry.aspect_ratio = (double)info->geometry.base_width / (double)info->geometry.max_height / + ((double)cc.pixelaspect.numerator / (double)cc.pixelaspect.denominator); } printf("Aspect ratio: %f\n",info->geometry.aspect_ratio); @@ -544,7 +540,7 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_get_system_av_info)(struct retro_syst info->geometry.max_height); } -RETRO_API void VIDEOPROC_CORE_PREFIX(retro_set_controller_port_device)(unsigned port, unsigned device) +RETRO_API void VIDEOPROC_CORE_PREFIX(retro_set_controller_port_device)(unsigned a, unsigned b) { } @@ -555,7 +551,8 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_reset)(void) } /* TODO improve this mess and make it generic enough for use with dummy mode */ -void v4l2_frame_times(struct v4l2_buffer buf) { +void v4l2_frame_times(struct v4l2_buffer buf) +{ if (strcmp("Off", video_frame_times) == 0) return; @@ -563,45 +560,49 @@ void v4l2_frame_times(struct v4l2_buffer buf) { ft_info = (char*)calloc(5000, sizeof(char)); if ( (buf.timestamp.tv_sec - ft_prevtime.tv_sec >= 1) && \ - (buf.timestamp.tv_usec + 1000000 - ft_prevtime2.tv_usec) >= 1000000) { + (buf.timestamp.tv_usec + 1000000 - ft_prevtime2.tv_usec) >= 1000000) + { double csec = ((double) buf.timestamp.tv_sec) + (buf.timestamp.tv_usec/1000000); double psec = ((double) ft_prevtime.tv_sec) + (ft_prevtime.tv_usec/1000000); printf("Fields last %.2f seconds: %d\n", csec - psec, ft_fcount); printf("Average frame times: %.3fms\n", ft_favg/(1000*ft_fcount)); printf("Fields timestampdiffs last second:\n%s\n", ft_info); free(ft_info); - ft_info = (char*)calloc(5000, sizeof(char)); - ft_fcount = 0; - ft_favg = 0; + ft_info = (char*)calloc(5000, sizeof(char)); + ft_fcount = 0; + ft_favg = 0; ft_prevtime = buf.timestamp; } ft_fcount++; ft_info2 = strdup(ft_info); ft_ftime = (double) (buf.timestamp.tv_usec + ((buf.timestamp.tv_sec - ft_prevtime2.tv_sec >= 1) ? 1000000 : 0) - ft_prevtime2.tv_usec); ft_favg += ft_ftime; - snprintf(ft_info, 5000 * sizeof(char), "%s %6.d %d %d %.2fms%s", ft_info2, buf.sequence, buf.index, buf.field, ft_ftime/1000, (!(ft_fcount % 7)) ? "\n" : ""); + snprintf(ft_info, 5000 * sizeof(char), "%s %6.d %d %d %.2fms%s", + ft_info2, buf.sequence, buf.index, buf.field, ft_ftime/1000, + (!(ft_fcount % 7)) ? "\n" : ""); free(ft_info2); ft_prevtime2 = buf.timestamp; } -void source_dummy(int width, int height) { +void source_dummy(int width, int height) +{ int i, triangpos, triangpos_t=0, triangpos_b=0, offset=0; bool field_ahead = false; uint8_t *src = frame_cap; float step = M_PI/64; - if (video_buf.field == V4L2_FIELD_TOP) { + if (video_buf.field == V4L2_FIELD_TOP) offset=0; - } else if (video_buf.field == V4L2_FIELD_BOTTOM) { + else if (video_buf.field == V4L2_FIELD_BOTTOM) offset=1; - } dummy_pos += step; /* no animation */ /* dummy_pos = M_PI/4; step = 0; */ triangpos = (sinf(dummy_pos)+1)/2*width; - if (video_buf.field == V4L2_FIELD_INTERLACED) { + if (video_buf.field == V4L2_FIELD_INTERLACED) + { if (video_half_feed_rate == 0) video_half_feed_rate = 1; triangpos_t = (sinf(dummy_pos)+1)/2*width; @@ -609,22 +610,28 @@ void source_dummy(int width, int height) { triangpos_b = (sinf(dummy_pos)+1)/2*width; } - for (i = 0; i < width * height; i+=1, src+=3) { + for (i = 0; i < width * height; i+=1, src+=3) + { float color = (clamp_float((float)(triangpos - (i%width) + offset)/10, -1, 1)+1)/2; src[0] = 0x10 + color*0xE0; src[1] = 0x10 + color*0xE0; src[2] = 0x10 + color*0xE0; /* End of a line */ - if ( ((i+1) % width) == 0 ) { + if ( ((i+1) % width) == 0 ) + { triangpos -= 2; /* offset should be half of this? */ triangpos_t -= 1; triangpos_b -= 1; - if (video_buf.field == V4L2_FIELD_INTERLACED) { - if (field_ahead) { + if (video_buf.field == V4L2_FIELD_INTERLACED) + { + if (field_ahead) + { triangpos = triangpos_b; field_ahead = false; - } else { + } + else + { triangpos = triangpos_t; field_ahead = true; } @@ -638,16 +645,17 @@ void source_dummy(int width, int height) { video_buf.field = V4L2_FIELD_TOP; } -void source_v4l2_normal(int width, int height) { +void source_v4l2_normal(int width, int height) +{ struct v4l2_buffer bufcp; int error; /* Wait until v4l2 dequees a buffer */ memset(&video_buf, 0, sizeof(struct v4l2_buffer)); - video_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + video_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; video_buf.memory = V4L2_MEMORY_MMAP; - error = v4l2_ioctl(video_device_fd, VIDIOC_DQBUF, &video_buf); + error = v4l2_ioctl(video_device_fd, VIDIOC_DQBUF, &video_buf); if (error != 0) { printf("VIDIOC_DQBUF failed: %s\n", strerror(errno)); @@ -665,7 +673,8 @@ void source_v4l2_normal(int width, int height) { v4l2_frame_times(bufcp); } -void source_v4l2_alternate_hack(int width, int height) { +void source_v4l2_alternate_hack(int width, int height) +{ struct v4l2_buffer bufcp; struct v4l2_format fmt; struct v4l2_requestbuffers reqbufs; @@ -677,7 +686,7 @@ void source_v4l2_alternate_hack(int width, int height) { /* For later, saving time */ memset(&fmt, 0, sizeof(fmt)); fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - error = v4l2_ioctl(video_device_fd, VIDIOC_G_FMT, &fmt); + error = v4l2_ioctl(video_device_fd, VIDIOC_G_FMT, &fmt); if (error != 0) { printf("VIDIOC_G_FMT failed: %s\n", strerror(errno)); @@ -700,7 +709,9 @@ void source_v4l2_alternate_hack(int width, int height) { /* Let's get the data as fast as possible! */ bufcp = video_buf; - memcpy( (uint32_t*) frame_cap, (uint8_t*) v4l2_capbuf[video_buf.index].start, video_format.fmt.pix.width * video_format.fmt.pix.height * 3); + memcpy( (uint32_t*) frame_cap, + (uint8_t*)v4l2_capbuf[video_buf.index].start, + video_format.fmt.pix.width * video_format.fmt.pix.height * 3); v4l2_munmap(v4l2_capbuf[0].start, v4l2_capbuf[0].len); @@ -730,20 +741,20 @@ void source_v4l2_alternate_hack(int width, int height) { v4l2_ncapbuf = reqbufs.count; /* printf("GOT v4l2_ncapbuf=%ld\n", v4l2_ncapbuf); */ - index = 0; + index = 0; memset(&video_buf, 0, sizeof(struct v4l2_buffer)); - video_buf.index = index; - video_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + video_buf.index = index; + video_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; video_buf.memory = V4L2_MEMORY_MMAP; v4l2_ioctl(video_device_fd, VIDIOC_QUERYBUF, &video_buf); - v4l2_capbuf[index].len = video_buf.length; + v4l2_capbuf[index].len = video_buf.length; v4l2_capbuf[index].start = v4l2_mmap(NULL, video_buf.length, PROT_READ|PROT_WRITE, MAP_SHARED, video_device_fd, video_buf.m.offset); memset(&video_buf, 0, sizeof(struct v4l2_buffer)); - video_buf.index = index; - video_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + video_buf.index = index; + video_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; video_buf.memory = V4L2_MEMORY_MMAP; v4l2_ioctl(video_device_fd, VIDIOC_QBUF,& video_buf); @@ -764,25 +775,31 @@ void source_v4l2_alternate_hack(int width, int height) { v4l2_frame_times(bufcp); } -void processing_heal(uint8_t *src, int width, int height) { - uint32_t *fp1 = frame_prev1; +void processing_heal(uint8_t *src, int width, int height) +{ int i; - for (i = 0; i < width * height; i+=1, src += 3, ++fp1) { + uint32_t *fp1 = frame_prev1; + for (i = 0; i < width * height; i+=1, src += 3, ++fp1) + { /* Tries to filter a bunch of blanked out scanline sections my capture cards spits out with this crazy hack * Since the blanked out scanlines are set to a black value bellow anything that can be captured, it's quite * easy to select the scanlines... */ - if (src[0] <= 0 && src[1] <= 0 && src[2] <= 0 && i >= width && i <= width * height - width) { + if (src[0] <= 0 && src[1] <= 0 && src[2] <= 0 && i >= width && i <= width * height - width) + { if (*(src + 0 - width*3) >= ((*fp1>> 0&0xFF)-6) && \ *(src + 1 - width*3) >= ((*fp1>> 8&0xFF)-6) && \ *(src + 2 - width*3) >= ((*fp1>>16&0xFF)-6) && \ *(src + 0 - width*3) <= ((*fp1>> 0&0xFF)+6) && \ *(src + 1 - width*3) <= ((*fp1>> 8&0xFF)+6) && \ - *(src + 2 - width*3) <= ((*fp1>>16&0xFF)+6)) { + *(src + 2 - width*3) <= ((*fp1>>16&0xFF)+6)) + { src[0] = (*fp1>> 0&0xFF); src[1] = (*fp1>> 8&0xFF); src[2] = (*fp1>>16&0xFF); - } else { + } + else + { src[0] = (*(fp1+i+width)>> 0&0xFF); src[1] = (*(fp1+i+width)>> 8&0xFF); src[2] = (*(fp1+i+width)>>16&0xFF); @@ -791,7 +808,9 @@ void processing_heal(uint8_t *src, int width, int height) { } } -void processing_deinterlacing_crap(uint32_t *src, uint32_t *dst, int width, int height, enum v4l2_field field, int skip_lines_src) { +void processing_deinterlacing_crap(uint32_t *src, uint32_t *dst, int width, + int height, enum v4l2_field field, int skip_lines_src) +{ int i, targetrow=0; uint32_t pixacul=0; uint32_t *fp1 = frame_prev1, *fp2 = frame_prev2, *fp3 = frame_prev3; @@ -806,9 +825,11 @@ void processing_deinterlacing_crap(uint32_t *src, uint32_t *dst, int width, int * On progressive sources, should only skip the destination lines, since all lines the source are the same fields * On interlaced sources, should skip both the source and the destination lines, since only half the lines in the source are the same fields (must also skip fields later) */ - if (field == V4L2_FIELD_BOTTOM) { + if (field == V4L2_FIELD_BOTTOM) + { dst += width; - if (skip_lines_src == 1) { + if (skip_lines_src == 1) + { src += width; fp1 += width; fp2 += width; @@ -816,7 +837,8 @@ void processing_deinterlacing_crap(uint32_t *src, uint32_t *dst, int width, int } } - for (i = 0; i < width * height; i+=1, src += 1, dst += 1, ++fp1, ++fp2, ++fp3) { + for (i = 0; i < width * height; i+=1, src += 1, dst += 1, ++fp1, ++fp2, ++fp3) + { /* Will fill the current destination line with current field * The masking is used to prserve some information set by the * deinterlacing process, uses the alpha channel to tell if a @@ -825,32 +847,35 @@ void processing_deinterlacing_crap(uint32_t *src, uint32_t *dst, int width, int *(dst) = (*(src) & 0x00FFFFFF) | (*dst & 0xFF000000); /* Crappy deinterlacing */ - if (i >= width && i <= (width*height-width)) { + if (i >= width && i <= (width*height-width)) + { pixacul=((((*(dst)>> 0&0xFF) + (pixacul>> 0&0xFF))>>1<<0 |\ ((*(dst)>> 8&0xFF) + (pixacul>> 8&0xFF))>>1<<8 |\ ((*(dst)>>16&0xFF) + (pixacul>>16&0xFF))>>1<<16) \ & 0x00FFFFFF) | 0xFE000000; if ( ((*(dst ) & 0xFF000000) == 0xFE000000) ||\ - ((*(dst+targetrow) & 0xFF000000) == 0xFE000000) ) { + ((*(dst+targetrow) & 0xFF000000) == 0xFE000000) ) + { *dst = pixacul | 0xFF000000; *(dst+targetrow) = pixacul | 0xFF000000; - } else { + } + else + { if (!(((*(src+0)>> 0&0xFF) >= ((*(fp2+0)>> 0&0xFF)-9) ) &&\ ((*(src+0)>> 8&0xFF) >= ((*(fp2+0)>> 8&0xFF)-9) ) &&\ ((*(src+0)>>16&0xFF) >= ((*(fp2+0)>>16&0xFF)-9) ) &&\ ((*(src+0)>> 0&0xFF) <= ((*(fp2+0)>> 0&0xFF)+9) ) &&\ ((*(src+0)>> 8&0xFF) <= ((*(fp2+0)>> 8&0xFF)+9) ) &&\ - ((*(src+0)>>16&0xFF) <= ((*(fp2+0)>>16&0xFF)+9) )) ) { + ((*(src+0)>>16&0xFF) <= ((*(fp2+0)>>16&0xFF)+9) )) ) *(dst+targetrow) = pixacul; - } else if (!(((*fp3>> 0&0xFF) >= ((*fp1>> 0&0xFF)-9) ) &&\ + else if (!(((*fp3>> 0&0xFF) >= ((*fp1>> 0&0xFF)-9) ) &&\ ((*fp3>> 8&0xFF) >= ((*fp1>> 8&0xFF)-9) ) &&\ ((*fp3>>16&0xFF) >= ((*fp1>>16&0xFF)-9) ) &&\ ((*fp3>> 0&0xFF) <= ((*fp1>> 0&0xFF)+9) ) &&\ ((*fp3>> 8&0xFF) <= ((*fp1>> 8&0xFF)+9) ) &&\ - ((*fp3>>16&0xFF) <= ((*fp1>>16&0xFF)+9) ))) { + ((*fp3>>16&0xFF) <= ((*fp1>>16&0xFF)+9) ))) *(dst+targetrow) = pixacul; - } } } @@ -858,9 +883,11 @@ void processing_deinterlacing_crap(uint32_t *src, uint32_t *dst, int width, int * On progressive sources, should only skip the destination lines, * On interlaced sources, should skip both the source and the destination lines */ - if ( ((i+1) % width) == 0 ) { + if ( ((i+1) % width) == 0 ) + { dst += width; - if (skip_lines_src == 1) { + if (skip_lines_src == 1) + { src += width; fp1 += width; fp2 += width; @@ -870,12 +897,12 @@ void processing_deinterlacing_crap(uint32_t *src, uint32_t *dst, int width, int } } -void processing_bgr_xrgb(uint8_t *src, uint32_t *dst, int width, int height) { +void processing_bgr_xrgb(uint8_t *src, uint32_t *dst, int width, int height) +{ /* BGR24 to XRGB8888 conversion */ int i; - for (i = 0; i < width * height; i+=1, src += 3, dst += 1) { + for (i = 0; i < width * height; i+=1, src += 3, dst += 1) *dst = 0xFF << 24 | src[2] << 16 | src[1] << 8 | src[0] << 0; - } } RETRO_API void VIDEOPROC_CORE_PREFIX(retro_run)(void) @@ -888,7 +915,8 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_run)(void) struct retro_variable frametimes = { "videoproc_frame_times", NULL }; bool updated = false; - if (VIDEOPROC_CORE_PREFIX(environment_cb)(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) { + if (VIDEOPROC_CORE_PREFIX(environment_cb)(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) + { VIDEOPROC_CORE_PREFIX(environment_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &videodev); VIDEOPROC_CORE_PREFIX(environment_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &audiodev); VIDEOPROC_CORE_PREFIX(environment_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &capturemode); @@ -900,15 +928,15 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_run)(void) if ((videodev.value && (strcmp(video_device, videodev.value) != 0)) ||\ (audiodev.value && (strcmp(audio_device, audiodev.value) != 0)) ||\ (capturemode.value && (strcmp(video_capture_mode, capturemode.value) != 0)) ||\ - (outputmode.value && (strcmp(video_output_mode, outputmode.value) != 0))) { + (outputmode.value && (strcmp(video_output_mode, outputmode.value) != 0))) + { VIDEOPROC_CORE_PREFIX(retro_unload_game)(); /* This core does not cares for the retro_game_info * argument? */ VIDEOPROC_CORE_PREFIX(retro_load_game)(NULL); } - if (frametimes.value != NULL) { + if (frametimes.value != NULL) strncpy(video_frame_times, frametimes.value, ENVVAR_BUFLEN-1); - } } VIDEOPROC_CORE_PREFIX(input_poll_cb)(); @@ -918,36 +946,45 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_run)(void) * half_feed_rate allows interlaced input to be fed at half the calls to this function * where the same frame is then read by the deinterlacer twice, for each field */ - if (video_half_feed_rate == 0) { + if (video_half_feed_rate == 0) + { /* Capture */ - if (strcmp(video_device, "dummy") == 0) { + if (strcmp(video_device, "dummy") == 0) + { source_dummy(video_cap_width, video_cap_height); - } else { - if (strcmp(video_capture_mode, "alternate_hack") == 0) { + } + else + { + if (strcmp(video_capture_mode, "alternate_hack") == 0) + { source_v4l2_alternate_hack(video_cap_width, video_cap_height); processing_heal(frame_cap, video_cap_width, video_cap_height); - } else { + } + else + { source_v4l2_normal(video_cap_width, video_cap_height); } } if (video_buf.field == V4L2_FIELD_INTERLACED) video_half_feed_rate = 1; - } else { - video_half_feed_rate = 0; } + else + video_half_feed_rate = 0; /* Converts from bgr to xrgb, deinterlacing, final copy to the outpuit buffer (frame_out) * Every frame except frame_cap shall be encoded in xrgb * Every frame except frame_out shall have the same height */ - if (strcmp(video_output_mode, "deinterlaced") == 0) { + if (strcmp(video_output_mode, "deinterlaced") == 0) + { processing_bgr_xrgb(frame_cap, frame_curr, video_cap_width, video_cap_height); /* When deinterlacing a interlaced input, we need to process both fields of a frame, * one at a time (retro_run needs to be called twice, vide_half_feed_rate prevents the * source from being read twice... */ - if (strcmp(video_capture_mode, "interlaced") == 0) { + if (strcmp(video_capture_mode, "interlaced") == 0) + { enum v4l2_field field_read; if (video_half_feed_rate == 0) field_read = V4L2_FIELD_TOP; @@ -957,34 +994,41 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_run)(void) * deinterlacing algo twice, extracting a given field for each run. */ processing_deinterlacing_crap(frame_curr, frame_out, video_cap_width, video_cap_height/2, field_read, 1); - } else { + } + else + { processing_deinterlacing_crap(frame_curr, frame_out, video_cap_width, video_cap_height, (enum v4l2_field)video_buf.field, 0); } - aux = frame_prev3; + aux = frame_prev3; frame_prev3 = frame_prev2; frame_prev2 = frame_prev1; frame_prev1 = frame_curr; - frame_curr = aux; + frame_curr = aux; VIDEOPROC_CORE_PREFIX(video_refresh_cb)(frame_out, video_cap_width, video_out_height, video_cap_width * sizeof(uint32_t)); - } else if (strcmp(video_capture_mode, "alternate_hack") == 0) { - /* Case where alternate_hack without deinterlacing would not generate previous frame for processing_heal */ + } + else if (strcmp(video_capture_mode, "alternate_hack") == 0) + { + /* Case where alternate_hack without deinterlacing would + * not generate previous frame for processing_heal */ processing_bgr_xrgb(frame_cap, frame_curr, video_cap_width, video_cap_height); - aux = frame_prev3; + aux = frame_prev3; frame_prev3 = frame_prev2; frame_prev2 = frame_prev1; frame_prev1 = frame_curr; - frame_curr = aux; + frame_curr = aux; - aux = frame_out; - frame_out = frame_curr; + aux = frame_out; + frame_out = frame_curr; VIDEOPROC_CORE_PREFIX(video_refresh_cb)(frame_out, video_cap_width, video_out_height, video_cap_width * sizeof(uint32_t)); - frame_out = aux; - } else { + frame_out = aux; + } + else + { processing_bgr_xrgb(frame_cap, frame_out, video_cap_width, video_out_height); VIDEOPROC_CORE_PREFIX(video_refresh_cb)(frame_out, video_cap_width, @@ -993,47 +1037,35 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_run)(void) } RETRO_API size_t VIDEOPROC_CORE_PREFIX(retro_serialize_size)(void) -{ - return 0; -} - -RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_serialize)(void *data, size_t size) -{ - return false; -} - -RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_unserialize)(const void *data, size_t size) -{ - return false; -} - -RETRO_API void VIDEOPROC_CORE_PREFIX(retro_cheat_reset)(void) -{ -} - -RETRO_API void VIDEOPROC_CORE_PREFIX(retro_cheat_set)(unsigned index, bool enabled, const char *code) -{ -} +{ return 0; } +RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_serialize)( + void *data, size_t len) { return false; } +RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_unserialize)( + const void *data, size_t len) { return false; } +RETRO_API void VIDEOPROC_CORE_PREFIX(retro_cheat_reset)(void) { } +RETRO_API void VIDEOPROC_CORE_PREFIX(retro_cheat_set)(unsigned a, + bool b, const char *c) { } #if 0 -static void videoinput_set_control_v4l2( uint32_t id, double val ) +static void videoinput_set_control_v4l2( uint32_t id, double val) { struct v4l2_queryctrl query; query.id = id; - if( ioctl( video_device_fd, VIDIOC_QUERYCTRL, &query ) >= 0 && !(query.flags & V4L2_CTRL_FLAG_DISABLED) ) { + if(ioctl(video_device_fd, VIDIOC_QUERYCTRL, &query) >= 0 && !(query.flags & V4L2_CTRL_FLAG_DISABLED)) + { struct v4l2_control control; control.id = id; control.value = query.minimum + ((int) ((val * ((double) (query.maximum - query.minimum))) + 0.5)); - ioctl( video_device_fd, VIDIOC_S_CTRL, &control ); + ioctl(video_device_fd, VIDIOC_S_CTRL, &control); } } #endif RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_load_game)(const struct retro_game_info *game) { - struct retro_variable videodev = { "videoproc_videodev", NULL }; - struct retro_variable audiodev = { "videoproc_audiodev", NULL }; + struct retro_variable videodev = { "videoproc_videodev", NULL }; + struct retro_variable audiodev = { "videoproc_audiodev", NULL }; struct retro_variable capture_mode = { "videoproc_capture_mode", NULL }; struct retro_variable output_mode = { "videoproc_output_mode", NULL }; struct retro_variable frame_times = { "videoproc_frame_times", NULL }; @@ -1056,7 +1088,8 @@ RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_load_game)(const struct retro_game_in } #ifdef HAVE_ALSA - if (audio_handle != NULL) { + if (audio_handle != NULL) + { struct retro_audio_callback audio_cb; audio_cb.callback = audio_callback; audio_cb.set_state = audio_set_state; @@ -1065,7 +1098,8 @@ RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_load_game)(const struct retro_game_in #endif VIDEOPROC_CORE_PREFIX(environment_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &videodev); - if (videodev.value == NULL) { + if (videodev.value == NULL) + { close_devices(); return false; } @@ -1073,13 +1107,13 @@ RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_load_game)(const struct retro_game_in /* Audio device is optional... */ VIDEOPROC_CORE_PREFIX(environment_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &audiodev); - if (audiodev.value != NULL) { + if (audiodev.value != NULL) strncpy(audio_device, audiodev.value, ENVVAR_BUFLEN-1); - } VIDEOPROC_CORE_PREFIX(environment_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &capture_mode); VIDEOPROC_CORE_PREFIX(environment_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &output_mode); - if (capture_mode.value == NULL || output_mode.value == NULL) { + if (capture_mode.value == NULL || output_mode.value == NULL) + { close_devices(); return false; } @@ -1087,32 +1121,37 @@ RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_load_game)(const struct retro_game_in strncpy(video_output_mode, output_mode.value, ENVVAR_BUFLEN-1); VIDEOPROC_CORE_PREFIX(environment_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &frame_times); - if (frame_times.value != NULL) { + if (frame_times.value != NULL) strncpy(video_frame_times, frame_times.value, ENVVAR_BUFLEN-1); - } - if (strcmp(video_device, "dummy") == 0) { - if (strcmp(video_capture_mode, "interlaced") == 0) { + if (strcmp(video_device, "dummy") == 0) + { + if (strcmp(video_capture_mode, "interlaced") == 0) + { video_format.fmt.pix.height = 480; - video_cap_height = 480; - video_buf.field = V4L2_FIELD_INTERLACED; - } else if (strcmp(video_capture_mode, "alternate") == 0 ||\ - strcmp(video_capture_mode, "top") == 0 ||\ - strcmp(video_capture_mode, "bottom") == 0 ||\ - strcmp(video_capture_mode, "alternate_hack") == 0) { + video_cap_height = 480; + video_buf.field = V4L2_FIELD_INTERLACED; + } + else if ( strcmp(video_capture_mode, "alternate") == 0 + || strcmp(video_capture_mode, "top") == 0 + || strcmp(video_capture_mode, "bottom") == 0 + || strcmp(video_capture_mode, "alternate_hack") == 0) + { video_format.fmt.pix.height = 240; - video_cap_height = 240; - video_buf.field = V4L2_FIELD_TOP; + video_cap_height = 240; + video_buf.field = V4L2_FIELD_TOP; } - dummy_pos=0; + dummy_pos = 0; video_format.fmt.pix.width = 640; - video_cap_width = 640; - } else { + video_cap_width = 640; + } + else + { memset(&fmt, 0, sizeof(fmt)); fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - error = v4l2_ioctl(video_device_fd, VIDIOC_G_FMT, &fmt); + error = v4l2_ioctl(video_device_fd, VIDIOC_G_FMT, &fmt); if (error != 0) { @@ -1129,29 +1168,33 @@ RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_load_game)(const struct retro_game_in fmt.fmt.pix.field = V4L2_FIELD_TOP; /* TODO Query the size and FPS */ - if (strcmp(video_capture_mode, "interlaced") == 0) { - v4l2_ncapbuf_target = 2; - fmt.fmt.pix.field = V4L2_FIELD_INTERLACED; + if (strcmp(video_capture_mode, "interlaced") == 0) + { + v4l2_ncapbuf_target = 2; + fmt.fmt.pix.field = V4L2_FIELD_INTERLACED; video_format.fmt.pix.height = 480; - video_cap_height = 480; - } else { - v4l2_ncapbuf_target = 2; + video_cap_height = 480; + } + else + { + v4l2_ncapbuf_target = 2; video_format.fmt.pix.height = 240; - video_cap_height = 240; + video_cap_height = 240; if (strcmp(video_capture_mode, "alternate") == 0) fmt.fmt.pix.field = V4L2_FIELD_ALTERNATE; else if (strcmp(video_capture_mode, "top") == 0) fmt.fmt.pix.field = V4L2_FIELD_TOP; else if (strcmp(video_capture_mode, "bottom") == 0) fmt.fmt.pix.field = V4L2_FIELD_BOTTOM; - else if (strcmp(video_capture_mode, "alternate_hack") == 0) { - fmt.fmt.pix.field = V4L2_FIELD_TOP; + else if (strcmp(video_capture_mode, "alternate_hack") == 0) + { + fmt.fmt.pix.field = V4L2_FIELD_TOP; v4l2_ncapbuf_target = 1; } } video_format.fmt.pix.width = 720; - video_cap_width = 720; + video_cap_width = 720; error = v4l2_ioctl(video_device_fd, VIDIOC_S_FMT, &fmt); if (error != 0) @@ -1170,13 +1213,13 @@ RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_load_game)(const struct retro_game_in { memset(&std, 0, sizeof(std)); std.index = index; - error = v4l2_ioctl(video_device_fd, VIDIOC_ENUMSTD, &std); + error = v4l2_ioctl(video_device_fd, VIDIOC_ENUMSTD, &std); if (error) break; if (std.id == std_id) { video_standard = std; - std_found = true; + std_found = true; } printf("VIDIOC_ENUMSTD[%u]: %s%s\n", index, std.name, std.id == std_id ? " [*]" : ""); } @@ -1190,11 +1233,11 @@ RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_load_game)(const struct retro_game_in /* TODO Check if what we got is indeed what we asked for */ memset(&reqbufs, 0, sizeof(reqbufs)); - reqbufs.count = v4l2_ncapbuf_target; - reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + reqbufs.count = v4l2_ncapbuf_target; + reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; reqbufs.memory = V4L2_MEMORY_MMAP; - error = v4l2_ioctl(video_device_fd, VIDIOC_REQBUFS, &reqbufs); + error = v4l2_ioctl(video_device_fd, VIDIOC_REQBUFS, &reqbufs); if (error != 0) { printf("VIDIOC_REQBUFS failed: %s\n", strerror(errno)); @@ -1206,18 +1249,18 @@ RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_load_game)(const struct retro_game_in for (index = 0; index < v4l2_ncapbuf; index++) { memset(&buf, 0, sizeof(buf)); - buf.index = index; - buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + buf.index = index; + buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.memory = V4L2_MEMORY_MMAP; - error = v4l2_ioctl(video_device_fd, VIDIOC_QUERYBUF, &buf); + error = v4l2_ioctl(video_device_fd, VIDIOC_QUERYBUF, &buf); if (error != 0) { printf("VIDIOC_QUERYBUF failed for %u: %s\n", index, strerror(errno)); return false; } - v4l2_capbuf[index].len = buf.length; + v4l2_capbuf[index].len = buf.length; v4l2_capbuf[index].start = v4l2_mmap(NULL, buf.length, PROT_READ|PROT_WRITE, MAP_SHARED, video_device_fd, buf.m.offset); if (v4l2_capbuf[index].start == MAP_FAILED) @@ -1230,19 +1273,20 @@ RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_load_game)(const struct retro_game_in for (index = 0; index < v4l2_ncapbuf; index++) { memset(&buf, 0, sizeof(buf)); - buf.index = index; - buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + buf.index = index; + buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.memory = V4L2_MEMORY_MMAP; - error = v4l2_ioctl(video_device_fd, VIDIOC_QBUF, &buf); + error = v4l2_ioctl(video_device_fd, VIDIOC_QBUF, &buf); if (error != 0) { - printf("VIDIOC_QBUF failed for %u: %s\n", index, strerror(errno)); + printf("VIDIOC_QBUF failed for %u: %s\n", index, + strerror(errno)); return false; } } - type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + type = V4L2_BUF_TYPE_VIDEO_CAPTURE; error = v4l2_ioctl(video_device_fd, VIDIOC_STREAMON, &type); if (error != 0) { @@ -1253,33 +1297,41 @@ RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_load_game)(const struct retro_game_in /* videoinput_set_control_v4l2(V4L2_CID_HUE, (double) 0.4f); */ } - /* TODO Framerates? - * Each frame should combine both fields into a full frame (if not already captured interlaced), half frame-rate + /* TODO/FIXME Framerates? + * Each frame should combine both fields into a full frame + * (if not already captured interlaced), half frame-rate */ - if (strcmp(video_output_mode, "interlaced") == 0) { - if (strcmp(video_capture_mode, "interlaced") == 0) { + if (strcmp(video_output_mode, "interlaced") == 0) + { + if (strcmp(video_capture_mode, "interlaced") == 0) video_out_height = video_cap_height; - } else { - printf("WARNING: Capture mode %s with output mode %s is not properly supported yet... (Is this even useful?)\n", \ + else + { + printf("WARNING: Capture mode %s with output mode %s is not" + " properly supported yet... (Is this even useful?)\n", \ video_capture_mode, video_output_mode); video_out_height = video_cap_height*2; } - /* Each frame has one field, full frame-rate */ - } else if (strcmp(video_output_mode, "progressive") == 0) { + /* Each frame has one field, full frame-rate */ + } + /* Each frame has one or both field to be deinterlaced + * into a full frame (double the lines if one field), full frame-rate */ + else if (strcmp(video_output_mode, "progressive") == 0) video_out_height = video_cap_height; - /* Each frame has one or both field to be deinterlaced into a full frame (double the lines if one field), full frame-rate */ - } else if (strcmp(video_output_mode, "deinterlaced") == 0) { + else if (strcmp(video_output_mode, "deinterlaced") == 0) + { if (strcmp(video_capture_mode, "interlaced") == 0) video_out_height = video_cap_height; else video_out_height = video_cap_height*2; - } else + } + else video_out_height = video_cap_height; printf("Capture Resolution %ux%u\n", video_cap_width, video_cap_height); printf("Output Resolution %ux%u\n", video_cap_width, video_out_height); - frame_cap = (uint8_t*)calloc(1, video_cap_width * video_cap_height * sizeof(uint8_t) * 3); + frame_cap = (uint8_t*)calloc (1, video_cap_width * video_cap_height * sizeof(uint8_t) * 3); frame_out = (uint32_t*)calloc(1, video_cap_width * video_out_height * sizeof(uint32_t)); /* TODO: Only allocate frames if we are going to use it (for deinterlacing or other filters?) */ frames[0] = (uint32_t*)calloc(1, video_cap_width * video_out_height * sizeof(uint32_t)); @@ -1287,17 +1339,14 @@ RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_load_game)(const struct retro_game_in frames[2] = (uint32_t*)calloc(1, video_cap_width * video_out_height * sizeof(uint32_t)); frames[3] = (uint32_t*)calloc(1, video_cap_width * video_out_height * sizeof(uint32_t)); - frame_curr = frames[0]; + frame_curr = frames[0]; frame_prev1 = frames[1]; frame_prev2 = frames[2]; frame_prev3 = frames[3]; /* TODO: Check frames[] allocation */ if (!frame_out || !frame_cap) - { - printf("Cannot allocate buffers\n"); return false; - } printf("Allocated %" PRI_SIZET " byte conversion buffer\n", (size_t)(video_cap_width * video_cap_height) * sizeof(uint32_t)); @@ -1318,7 +1367,8 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_unload_game)(void) int i; #ifdef HAVE_ALSA - if (audio_handle != NULL) { + if (audio_handle != NULL) + { VIDEOPROC_CORE_PREFIX(environment_cb)(RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK, NULL); } #endif @@ -1327,7 +1377,8 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_unload_game)(void) { uint32_t index; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - int error = v4l2_ioctl(video_device_fd, VIDIOC_STREAMOFF, &type); + int error = v4l2_ioctl(video_device_fd, + VIDIOC_STREAMOFF, &type); if (error != 0) printf("VIDIOC_STREAMOFF failed: %s\n", strerror(errno)); @@ -1351,7 +1402,8 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_unload_game)(void) free(frame_cap); frame_cap = NULL; - for (i = 0; i<4; ++i) { + for (i = 0; i<4; ++i) + { if (frames[i]) free(frames[i]); frames[i] = NULL; @@ -1361,12 +1413,14 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_unload_game)(void) frame_prev2 = NULL; frame_prev3 = NULL; - if (ft_info) { + if (ft_info) + { free(ft_info); ft_info = NULL; } - if (ft_info2) { + if (ft_info2) + { free(ft_info2); ft_info2 = NULL; } @@ -1377,10 +1431,7 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_unload_game)(void) } RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_load_game_special)(unsigned game_type, - const struct retro_game_info *info, size_t num_info) -{ - return false; -} + const struct retro_game_info *info, size_t num_info) { return false; } RETRO_API unsigned VIDEOPROC_CORE_PREFIX(retro_get_region)(void) { diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index 970dd376e6a7..79398a70c3ea 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -685,10 +685,8 @@ static enum frontend_architecture frontend_darwin_get_arch(void) return FRONTEND_ARCH_ARMV8; #else cpu_type_t type; - size_t size = sizeof(type); - - sysctlbyname("hw.cputype", &type, &size, NULL, 0); - + size_t _len = sizeof(type); + sysctlbyname("hw.cputype", &type, &_len, NULL, 0); if (type == CPU_TYPE_X86_64) return FRONTEND_ARCH_X86_64; else if (type == CPU_TYPE_X86) @@ -756,14 +754,14 @@ static uint64_t frontend_darwin_get_total_mem(void) uint64_t size; int mib[2] = { CTL_HW, HW_MEMSIZE }; u_int namelen = ARRAY_SIZE(mib); - size_t len = sizeof(size); - if (sysctl(mib, namelen, &size, &len, NULL, 0) >= 0) + size_t _len = sizeof(size); + if (sysctl(mib, namelen, &size, &_len, NULL, 0) >= 0) return size; #elif defined(IOS) - task_vm_info_data_t vmInfo; + task_vm_info_data_t vm_info; mach_msg_type_number_t count = TASK_VM_INFO_COUNT; - if (task_info(mach_task_self(), TASK_VM_INFO, (task_info_t) &vmInfo, &count) == KERN_SUCCESS) - return vmInfo.phys_footprint + vmInfo.limit_bytes_remaining; + if (task_info(mach_task_self(), TASK_VM_INFO, (task_info_t) &vm_info, &count) == KERN_SUCCESS) + return vm_info.phys_footprint + vm_info.limit_bytes_remaining; #endif return 0; } @@ -776,8 +774,8 @@ static uint64_t frontend_darwin_get_free_mem(void) mach_port_t mach_port = mach_host_self(); mach_msg_type_number_t count = sizeof(vm_stats) / sizeof(natural_t); - if (KERN_SUCCESS == host_page_size(mach_port, &page_size) && - KERN_SUCCESS == host_statistics64(mach_port, HOST_VM_INFO, + if ( KERN_SUCCESS == host_page_size(mach_port, &page_size) + && KERN_SUCCESS == host_statistics64(mach_port, HOST_VM_INFO, (host_info64_t)&vm_stats, &count)) { long long used_memory = ( @@ -787,10 +785,10 @@ static uint64_t frontend_darwin_get_free_mem(void) return used_memory; } #elif defined(IOS) - task_vm_info_data_t vmInfo; + task_vm_info_data_t vm_info; mach_msg_type_number_t count = TASK_VM_INFO_COUNT; - if (task_info(mach_task_self(), TASK_VM_INFO, (task_info_t) &vmInfo, &count) == KERN_SUCCESS) - return vmInfo.limit_bytes_remaining; + if (task_info(mach_task_self(), TASK_VM_INFO, (task_info_t) &vm_info, &count) == KERN_SUCCESS) + return vm_info.limit_bytes_remaining; #endif return 0; } @@ -808,7 +806,8 @@ static enum retro_language frontend_darwin_get_user_language(void) CFArrayRef langs = CFLocaleCopyPreferredLanguages(); CFStringRef langCode = CFArrayGetValueAtIndex(langs, 0); CFStringGetCString(langCode, s, sizeof(s), kCFStringEncodingUTF8); - /* iOS and OS X only support the language ID syntax consisting of a language designator and optional region or script designator. */ + /* iOS and OS X only support the language ID syntax consisting + * of a language designator and optional region or script designator. */ string_replace_all_chars(s, '-', '_'); return retroarch_get_language_from_iso(s); } diff --git a/frontend/drivers/platform_wii.c b/frontend/drivers/platform_wii.c index 45c7a0368c68..5d78a8f7fe3f 100644 --- a/frontend/drivers/platform_wii.c +++ b/frontend/drivers/platform_wii.c @@ -126,7 +126,7 @@ static void dol_copy_argv_path(const char *dolpath, const char *argpath) } static void dol_copy_raw_argv(const char *dolpath, - const void *args, size_t size) + const void *args, size_t len) { struct __argv *argv = (struct __argv*)ARGS_ADDR; char *cmdline = (char*)++argv; @@ -154,8 +154,8 @@ static void dol_copy_raw_argv(const char *dolpath, argv->length = (int)strlcat(cmdline, dolpath, PATH_MAX_LENGTH); argv->length += 1; - memcpy(cmdline + argv->length, args, size); - argv->length += size; + memcpy(cmdline + argv->length, args, len); + argv->length += len; DCFlushRange(argv, sizeof(*argv) + argv->length); } diff --git a/frontend/frontend_driver.c b/frontend/frontend_driver.c index eb1caaa95169..3937c9e96813 100644 --- a/frontend/frontend_driver.c +++ b/frontend/frontend_driver.c @@ -388,8 +388,7 @@ enum frontend_architecture frontend_driver_get_cpu_architecture(void) return FRONTEND_ARCH_NONE; } -const void *frontend_driver_get_cpu_architecture_str( - char *s, size_t len) +const void *frontend_driver_get_cpu_architecture_str(char *s, size_t len) { frontend_state_t *frontend_st = &frontend_driver_st; frontend_ctx_driver_t *frontend = frontend_st->current_frontend_ctx; diff --git a/frontend/frontend_driver.h b/frontend/frontend_driver.h index 01caeb27cfb6..b1d92140007c 100644 --- a/frontend/frontend_driver.h +++ b/frontend/frontend_driver.h @@ -162,8 +162,7 @@ void frontend_driver_free(void); enum frontend_architecture frontend_driver_get_cpu_architecture(void); -const void *frontend_driver_get_cpu_architecture_str( - char *frontend_architecture, size_t size); +const void *frontend_driver_get_cpu_architecture_str(char *s, size_t len); bool frontend_driver_has_get_video_driver_func(void); diff --git a/gfx/common/vulkan_common.h b/gfx/common/vulkan_common.h index 29a489cde530..714960d63280 100644 --- a/gfx/common/vulkan_common.h +++ b/gfx/common/vulkan_common.h @@ -683,7 +683,7 @@ typedef struct vk } vk_t; bool vulkan_buffer_chain_alloc(const struct vulkan_context *context, - struct vk_buffer_chain *chain, size_t size, + struct vk_buffer_chain *chain, size_t len, struct vk_buffer_range *range); struct vk_descriptor_pool *vulkan_alloc_descriptor_pool( @@ -703,7 +703,7 @@ void vulkan_debug_mark_buffer(VkDevice device, VkBuffer buffer); struct vk_buffer vulkan_create_buffer( const struct vulkan_context *context, - size_t size, VkBufferUsageFlags usage); + size_t len, VkBufferUsageFlags usage); void vulkan_destroy_buffer( VkDevice device, diff --git a/gfx/drivers/gl3.c b/gfx/drivers/gl3.c index 4d9e849f4132..3fdace418a56 100644 --- a/gfx/drivers/gl3.c +++ b/gfx/drivers/gl3.c @@ -282,12 +282,12 @@ uint32_t gl3_get_cross_compiler_target_version(void) return 100 * major + 10 * minor; } -static void gl3_bind_scratch_vbo(gl3_t *gl, const void *data, size_t size) +static void gl3_bind_scratch_vbo(gl3_t *gl, const void *data, size_t len) { if (!gl->scratch_vbos[gl->scratch_vbo_index]) glGenBuffers(1, &gl->scratch_vbos[gl->scratch_vbo_index]); glBindBuffer(GL_ARRAY_BUFFER, gl->scratch_vbos[gl->scratch_vbo_index]); - glBufferData(GL_ARRAY_BUFFER, size, data, GL_STREAM_DRAW); + glBufferData(GL_ARRAY_BUFFER, len, data, GL_STREAM_DRAW); gl->scratch_vbo_index++; if (gl->scratch_vbo_index >= GL_CORE_NUM_VBOS) gl->scratch_vbo_index = 0; diff --git a/gfx/drivers/omap_gfx.c b/gfx/drivers/omap_gfx.c index 517f4b410ea3..6c0beeba5c89 100644 --- a/gfx/drivers/omap_gfx.c +++ b/gfx/drivers/omap_gfx.c @@ -133,24 +133,19 @@ static void omapfb_page_flip(omapfb_data_t *pdata) pdata->old_page->used = false; } -static int omapfb_read_sysfs(const char *fname, char *buff, size_t size) +static int omapfb_read_sysfs(const char *fname, char *s, size_t len) { int ret; FILE *f = fopen(fname, "r"); - if (!f) return -1; - - ret = fread(buff, 1, size - 1, f); + ret = fread(s, 1, len - 1, f); fclose(f); - if (ret <= 0) return -1; - - buff[ret] = 0; - for (ret--; ret >= 0 && isspace(buff[ret]); ret--) - buff[ret] = 0; - + s[ret] = 0; + for (ret--; ret >= 0 && isspace(s[ret]); ret--) + s[ret] = 0; return 0; } diff --git a/gfx/drivers_shader/shader_gl3.cpp b/gfx/drivers_shader/shader_gl3.cpp index 26e206493b3b..2f9088bd1933 100644 --- a/gfx/drivers_shader/shader_gl3.cpp +++ b/gfx/drivers_shader/shader_gl3.cpp @@ -1683,11 +1683,11 @@ void Pass::build_commands( unsigned vertex_binding = locations.buffer_index_ubo_vertex; unsigned fragment_binding = locations.buffer_index_ubo_fragment; const void *data = uniforms.data(); - size_t size = reflection.ubo_size; + size_t _len = reflection.ubo_size; GLuint id = ubo_ring.buffers[ubo_ring.buffer_index]; glBindBuffer(GL_UNIFORM_BUFFER, id); - glBufferSubData(GL_UNIFORM_BUFFER, 0, size, data); + glBufferSubData(GL_UNIFORM_BUFFER, 0, _len, data); glBindBuffer(GL_UNIFORM_BUFFER, 0); if (vertex_binding != GL_INVALID_INDEX) glBindBufferBase(GL_UNIFORM_BUFFER, vertex_binding, id); diff --git a/input/drivers_hid/btstack_hid.c b/input/drivers_hid/btstack_hid.c index e5ea40e8f79c..e9bcbd0c83fc 100644 --- a/input/drivers_hid/btstack_hid.c +++ b/input/drivers_hid/btstack_hid.c @@ -766,12 +766,12 @@ static void btpad_increment_position(uint32_t *ptr) } static void btpad_connection_send_control(void *data, - uint8_t* data_buf, size_t size) + uint8_t* data_buf, size_t len) { struct btstack_hid_adapter *connection = (struct btstack_hid_adapter*)data; if (connection) - bt_send_l2cap_ptr(connection->channels[0], data_buf, size); + bt_send_l2cap_ptr(connection->channels[0], data_buf, len); } static void btpad_queue_process_cmd(struct btpad_queue_command *cmd) diff --git a/input/drivers_hid/iohidmanager_hid.c b/input/drivers_hid/iohidmanager_hid.c index 3de1c01d809d..74d63006f999 100644 --- a/input/drivers_hid/iohidmanager_hid.c +++ b/input/drivers_hid/iohidmanager_hid.c @@ -269,14 +269,14 @@ static bool iohidmanager_hid_joypad_rumble(void *data, unsigned pad, } static void iohidmanager_hid_device_send_control(void *data, - uint8_t* data_buf, size_t size) + uint8_t* data_buf, size_t len) { struct iohidmanager_hid_adapter *adapter = (struct iohidmanager_hid_adapter*)data; if (adapter) IOHIDDeviceSetReport(adapter->handle, - kIOHIDReportTypeOutput, 0x01, data_buf + 1, size - 1); + kIOHIDReportTypeOutput, 0x01, data_buf + 1, len - 1); } static void iohidmanager_hid_device_report(void *data, @@ -490,7 +490,7 @@ static void iohidmanager_hid_device_remove(IOHIDDeviceRef device, iohidmanager_h { int i, slot; struct iohidmanager_hid_adapter *adapter = NULL; - + /*loop though the controller ports and find the device with a matching IOHINDeviceRef*/ for (i=0; iptr, matcher); IOHIDManagerRegisterDeviceMatchingCallback(hid->ptr,iohidmanager_hid_device_matched, 0); IOHIDManagerRegisterDeviceRemovalCallback(hid->ptr,iohidmanager_hid_device_removed, 0); - + CFRelease(matcher); return 0; @@ -1088,27 +1088,29 @@ static void iohidmanager_hid_free(const void *data) static void iohidmanager_hid_poll(void *data) { } -static int32_t iohidmanager_set_report(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *data_buf, size_t size) +static int32_t iohidmanager_set_report(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *data_buf, size_t len) { struct iohidmanager_hid_adapter *adapter = (struct iohidmanager_hid_adapter*)handle; if (adapter) return IOHIDDeviceSetReport(adapter->handle, translate_hid_report_type(report_type), report_id, - data_buf + 1, size - 1); + data_buf + 1, len - 1); return -1; } static int32_t iohidmanager_get_report(void *handle, uint8_t report_type, uint8_t report_id, - uint8_t *data_buf, size_t size) + uint8_t *data_buf, size_t len) { struct iohidmanager_hid_adapter *adapter = (struct iohidmanager_hid_adapter*)handle; if (adapter) { - CFIndex length = size; - return IOHIDDeviceGetReport(adapter->handle, translate_hid_report_type(report_type), report_id, data_buf, &length); + CFIndex length = len; + return IOHIDDeviceGetReport(adapter->handle, + translate_hid_report_type(report_type), + report_id, data_buf, &length); } return -1; diff --git a/input/drivers_hid/libusb_hid.c b/input/drivers_hid/libusb_hid.c index 2df8fe142d86..30ad72b47dbe 100644 --- a/input/drivers_hid/libusb_hid.c +++ b/input/drivers_hid/libusb_hid.c @@ -124,7 +124,7 @@ static void adapter_thread(void *data) } static void libusb_hid_device_send_control(void *data, - uint8_t* data_buf, size_t size) + uint8_t* data_buf, size_t len) { struct libusb_adapter *adapter = (struct libusb_adapter*)data; @@ -133,10 +133,10 @@ static void libusb_hid_device_send_control(void *data, slock_lock(adapter->send_control_lock); - if (FIFO_WRITE_AVAIL(adapter->send_control_buffer) >= size + sizeof(size)) + if (FIFO_WRITE_AVAIL(adapter->send_control_buffer) >= len + sizeof(len)) { - fifo_write(adapter->send_control_buffer, &size, sizeof(size)); - fifo_write(adapter->send_control_buffer, data_buf, size); + fifo_write(adapter->send_control_buffer, &len, sizeof(len)); + fifo_write(adapter->send_control_buffer, data_buf, len); } else { diff --git a/input/drivers_hid/wiiusb_hid.c b/input/drivers_hid/wiiusb_hid.c index 4756d5e2737a..cb51f75e9d4b 100644 --- a/input/drivers_hid/wiiusb_hid.c +++ b/input/drivers_hid/wiiusb_hid.c @@ -120,7 +120,7 @@ static int32_t wiiusb_hid_read_cb(int32_t size, void *data) } static void wiiusb_hid_device_send_control(void *data, - uint8_t* data_buf, size_t size) + uint8_t* data_buf, size_t len) { uint8_t control_type; struct wiiusb_adapter *adapter = (struct wiiusb_adapter*)data; @@ -129,9 +129,9 @@ static void wiiusb_hid_device_send_control(void *data, /* first byte contains the type of control to use * which can be NONE, INT_MSG, CTRL_MSG, CTRL_MSG2 */ - control_type = data_buf[0]; + control_type = data_buf[0]; /* decrement size by one as we are getting rid of first byte */ - adapter->send_control_size = size - 1; + adapter->send_control_size = len - 1; /* increase the buffer address so we access the actual data */ data_buf++; memcpy(adapter->send_control_buffer, data_buf, adapter->send_control_size); diff --git a/input/drivers_keyboard/keyboard_event_xkb.c b/input/drivers_keyboard/keyboard_event_xkb.c index 4f7292559cca..2aa32fddbdc5 100644 --- a/input/drivers_keyboard/keyboard_event_xkb.c +++ b/input/drivers_keyboard/keyboard_event_xkb.c @@ -56,7 +56,7 @@ void free_xkb(void) xkb_state = NULL; } -int init_xkb(int fd, size_t size) +int init_xkb(int fd, size_t len) { mod_map_idx = (xkb_mod_index_t *)calloc( MOD_MAP_SIZE, sizeof(xkb_mod_index_t)); @@ -76,19 +76,19 @@ int init_xkb(int fd, size_t size) { if (fd >= 0) { - char *map_str = (char*)mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); + char *map_str = (char*)mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0); if (map_str == MAP_FAILED) goto error; xkb_map = xkb_keymap_new_from_string(xkb_ctx, map_str, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS); - munmap(map_str, size); + munmap(map_str, len); } else { struct xkb_rule_names rule = {0}; settings_t *settings = config_get_ptr(); - const char *input_keyboard_layout = + const char *input_keyboard_layout = settings->arrays.input_keyboard_layout; rule.rules = "evdev"; diff --git a/input/include/hid_driver.h b/input/include/hid_driver.h index 8d7143c4d4fa..b7c6d953bcc8 100644 --- a/input/include/hid_driver.h +++ b/input/include/hid_driver.h @@ -49,12 +49,12 @@ struct hid_driver bool (*set_rumble)(void *handle, unsigned pad, enum retro_rumble_effect effect, uint16_t); const char *(*name)(void *handle, unsigned pad); const char *ident; - void (*send_control)(void *handle, uint8_t *buf, size_t size); + void (*send_control)(void *handle, uint8_t *buf, size_t len); int32_t (*set_report)(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *data, size_t len); int32_t (*get_report)(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *data, size_t len); int32_t (*set_idle)(void *handle, uint8_t amount); int32_t (*set_protocol)(void *handle, uint8_t protocol); - int32_t (*read)(void *handle, void *buf, size_t size); + int32_t (*read)(void *handle, void *buf, size_t len); }; #endif /* HID_DRIVER_H__ */ diff --git a/libretro-common/formats/png/rpng.c b/libretro-common/formats/png/rpng.c index 9cd19f6d431d..bcdbca8882d6 100644 --- a/libretro-common/formats/png/rpng.c +++ b/libretro-common/formats/png/rpng.c @@ -500,7 +500,7 @@ static int rpng_reverse_filter_init(const struct png_ihdr *ihdr, { size_t pass_size; - if ( !(pngp->flags & RPNG_PROCESS_FLAG_ADAM7_PASS_INITIALIZED) + if ( !(pngp->flags & RPNG_PROCESS_FLAG_ADAM7_PASS_INITIALIZED) && ihdr->interlace) { if ( ihdr->width <= rpng_passes[pngp->pass_pos].x @@ -924,7 +924,7 @@ static enum png_chunk_type rpng_read_chunk_header( type[i] = byte; } - if ( + if ( type[0] == 'I' && type[1] == 'H' && type[2] == 'D' @@ -998,7 +998,7 @@ bool rpng_iterate_image(rpng_t *rpng) return false; case PNG_CHUNK_IHDR: - if ( (rpng->flags & RPNG_FLAG_HAS_IHDR) + if ( (rpng->flags & RPNG_FLAG_HAS_IHDR) || (rpng->flags & RPNG_FLAG_HAS_IDAT) || (rpng->flags & RPNG_FLAG_HAS_IEND)) return false; @@ -1016,8 +1016,8 @@ bool rpng_iterate_image(rpng_t *rpng) rpng->ihdr.filter = buf[11]; rpng->ihdr.interlace = buf[12]; - if ( rpng->ihdr.width == 0 - || rpng->ihdr.height == 0 + if ( rpng->ihdr.width == 0 + || rpng->ihdr.height == 0 /* ensure multiplications don't overflow and wrap around, that'd give buffer overflow crashes */ || (uint64_t)rpng->ihdr.width*rpng->ihdr.height*sizeof(uint32_t) >= 0x80000000) return false; @@ -1091,10 +1091,10 @@ bool rpng_iterate_image(rpng_t *rpng) break; case PNG_CHUNK_IDAT: - if ( !(rpng->flags & RPNG_FLAG_HAS_IHDR) + if ( !(rpng->flags & RPNG_FLAG_HAS_IHDR) || (rpng->flags & RPNG_FLAG_HAS_IEND) - || (rpng->ihdr.color_type == PNG_IHDR_COLOR_PLT - && + || (rpng->ihdr.color_type == PNG_IHDR_COLOR_PLT + && !(rpng->flags & RPNG_FLAG_HAS_PLTE))) return false; @@ -1112,7 +1112,7 @@ bool rpng_iterate_image(rpng_t *rpng) break; case PNG_CHUNK_IEND: - if ( !(rpng->flags & RPNG_FLAG_HAS_IHDR) + if ( !(rpng->flags & RPNG_FLAG_HAS_IHDR) || !(rpng->flags & RPNG_FLAG_HAS_IDAT)) return false; @@ -1129,7 +1129,7 @@ bool rpng_iterate_image(rpng_t *rpng) } int rpng_process_image(rpng_t *rpng, - void **_data, size_t size, unsigned *width, unsigned *height) + void **_data, size_t len, unsigned *width, unsigned *height) { uint32_t **data = (uint32_t**)_data; diff --git a/libretro-common/hash/lrc_hash.c b/libretro-common/hash/lrc_hash.c index cf2979f35f1b..71520e140d4c 100644 --- a/libretro-common/hash/lrc_hash.c +++ b/libretro-common/hash/lrc_hash.c @@ -179,7 +179,7 @@ static void sha256_subhash(struct sha256_ctx *p, uint32_t *t) * * Hashes SHA256 and outputs a human readable string. **/ -void sha256_hash(char *s, const uint8_t *in, size_t size) +void sha256_hash(char *s, const uint8_t *in, size_t len) { unsigned i; struct sha256_ctx sha; @@ -191,7 +191,7 @@ void sha256_hash(char *s, const uint8_t *in, size_t size) } shahash; sha256_init(&sha); - sha256_chunk(&sha, in, (unsigned)size); + sha256_chunk(&sha, in, (unsigned)len); sha256_final(&sha); sha256_subhash(&sha, shahash.u32); diff --git a/libretro-common/include/compat/msvc.h b/libretro-common/include/compat/msvc.h index a4c93a59ab21..d912e1115f45 100644 --- a/libretro-common/include/compat/msvc.h +++ b/libretro-common/include/compat/msvc.h @@ -38,12 +38,12 @@ extern "C" { #ifndef snprintf #define snprintf c99_snprintf_retro__ #endif - int c99_snprintf_retro__(char *outBuf, size_t size, const char *format, ...); + int c99_snprintf_retro__(char *s, size_t len, const char *format, ...); #ifndef vsnprintf #define vsnprintf c99_vsnprintf_retro__ #endif - int c99_vsnprintf_retro__(char *outBuf, size_t size, const char *format, va_list ap); + int c99_vsnprintf_retro__(char *s, size_t len, const char *format, va_list ap); #endif #ifdef __cplusplus diff --git a/libretro-common/include/compat/strl.h b/libretro-common/include/compat/strl.h index dfa4f1098697..dde0cbb3cbba 100644 --- a/libretro-common/include/compat/strl.h +++ b/libretro-common/include/compat/strl.h @@ -60,13 +60,13 @@ RETRO_BEGIN_DECLS * @brief Portable implementation of \c strlcpy(3). * @see https://linux.die.net/man/3/strlcpy */ -size_t strlcpy(char *dest, const char *source, size_t size); +size_t strlcpy(char *s, const char *source, size_t len); /** * @brief Portable implementation of \c strlcat(3). * @see https://linux.die.net/man/3/strlcpy */ -size_t strlcat(char *dest, const char *source, size_t size); +size_t strlcat(char *s, const char *source, size_t len); #endif diff --git a/libretro-common/include/fastcpy.h b/libretro-common/include/fastcpy.h index 7ecd460f7c7b..5ba5eae58b87 100644 --- a/libretro-common/include/fastcpy.h +++ b/libretro-common/include/fastcpy.h @@ -25,68 +25,68 @@ #include #include -static INLINE void* memcpy16(void* dst,void* src,size_t size) +static INLINE void* memcpy16(void* dst, void* src, size_t len) { - return memcpy(dst,src,size * 2); + return memcpy(dst, src, len * 2); } -static INLINE void* memcpy32(void* dst,void* src,size_t size) +static INLINE void* memcpy32(void* dst, void* src, size_t len) { - return memcpy(dst,src,size * 4); + return memcpy(dst, src, len * 4); } -static INLINE void* memcpy64(void* dst,void* src,size_t size) +static INLINE void* memcpy64(void* dst, void* src, size_t len) { - return memcpy(dst,src,size * 8); + return memcpy(dst, src, len * 8); } #ifdef USECPPSTDFILL #include -static INLINE void* memset16(void* dst,uint16_t val,size_t size) +static INLINE void* memset16(void* dst,uint16_t val, size_t len) { uint16_t *typedptr = (uint16_t*)dst; - std::fill(typedptr, typedptr + size, val); + std::fill(typedptr, typedptr + len, val); return dst; } -static INLINE void* memset32(void* dst,uint32_t val,size_t size) +static INLINE void* memset32(void* dst, uint32_t val, size_t len) { uint32_t *typedptr = (uint32_t*)dst; - std::fill(typedptr, typedptr + size, val); + std::fill(typedptr, typedptr + len, val); return dst; } -static INLINE void* memset64(void* dst,uint64_t val,size_t size) +static INLINE void* memset64(void* dst, uint64_t val, size_t len) { uint64_t *typedptr = (uint64_t*)dst; - std::fill(typedptr, typedptr + size, val); + std::fill(typedptr, typedptr + len, val); return dst; } #else -static INLINE void *memset16(void* dst,uint16_t val,size_t size) +static INLINE void *memset16(void* dst, uint16_t val, size_t len) { size_t i; uint16_t *typedptr = (uint16_t*)dst; - for (i = 0;i < size;i++) + for (i = 0; i < len; i++) typedptr[i] = val; return dst; } -static INLINE void *memset32(void* dst,uint32_t val,size_t size) +static INLINE void *memset32(void* dst, uint32_t val, size_t len) { size_t i; uint32_t *typedptr = (uint32_t*)dst; - for (i = 0; i < size; i++) + for (i = 0; i < len; i++) typedptr[i] = val; return dst; } -static INLINE void *memset64(void* dst,uint64_t val,size_t size) +static INLINE void *memset64(void* dst, uint64_t val, size_t len) { size_t i; uint64_t *typedptr = (uint64_t*)dst; - for (i = 0; i < size;i++) + for (i = 0; i < len;i++) typedptr[i] = val; return dst; } diff --git a/libretro-common/include/file/file_path.h b/libretro-common/include/file/file_path.h index bdaeef3f567b..e507e53138a3 100644 --- a/libretro-common/include/file/file_path.h +++ b/libretro-common/include/file/file_path.h @@ -220,7 +220,7 @@ size_t path_parent_dir(char *path, size_t len); * e.g. on Android it is "/" * Use of fill_pathname_resolve_relative() should be preferred **/ -char *path_resolve_realpath(char *buf, size_t size, bool resolve_symlinks); +char *path_resolve_realpath(char *buf, size_t len, bool resolve_symlinks); /** * path_relative_to: @@ -238,8 +238,8 @@ char *path_resolve_realpath(char *buf, size_t size, bool resolve_symlinks); * * @return Length of the string copied into @out **/ -size_t path_relative_to(char *out, const char *path, const char *base, - size_t size); +size_t path_relative_to(char *s, const char *path, const char *base, + size_t len); /** * path_is_absolute: @@ -253,24 +253,24 @@ bool path_is_absolute(const char *path); /** * fill_pathname: - * @out_path : output path + * @s : output path * @in_path : input path * @replace : what to replace - * @size : buffer size of output path + * @len : buffer size of output path * * FIXME: Verify * - * Replaces filename extension with 'replace' and outputs result to out_path. + * Replaces filename extension with 'replace' and outputs result to s. * The extension here is considered to be the string from the last '.' * to the end. * * Only '.'s after the last slash are considered as extensions. * If no '.' is present, in_path and replace will simply be concatenated. - * 'size' is buffer size of 'out_path'. + * 'len' is buffer size of 's'. * E.g.: in_path = "/foo/bar/baz/boo.c", replace = ".asm" => - * out_path = "/foo/bar/baz/boo.asm" + * s = "/foo/bar/baz/boo.asm" * E.g.: in_path = "/foo/bar/baz/boo.c", replace = "" => - * out_path = "/foo/bar/baz/boo" + * s = "/foo/bar/baz/boo" * * Hidden non-leaf function cost: * - calls strlcpy 2x @@ -279,20 +279,20 @@ bool path_is_absolute(const char *path); * * @return Length of the string copied into @out */ -size_t fill_pathname(char *out_path, const char *in_path, - const char *replace, size_t size); +size_t fill_pathname(char *s, const char *in_path, + const char *replace, size_t len); /** * fill_dated_filename: - * @out_filename : output filename + * @s : output filename * @ext : extension of output filename - * @size : buffer size of output filename + * @len : buffer size of output filename * * Creates a 'dated' filename prefixed by 'RetroArch', and * concatenates extension (@ext) to it. * * E.g.: - * out_filename = "RetroArch-{month}{day}-{Hours}{Minutes}.{@ext}" + * s = "RetroArch-{month}{day}-{Hours}{Minutes}.{@ext}" * * Hidden non-leaf function cost: * - Calls rtime_localtime() @@ -300,21 +300,20 @@ size_t fill_pathname(char *out_path, const char *in_path, * - Calls strlcat * **/ -size_t fill_dated_filename(char *out_filename, - const char *ext, size_t size); +size_t fill_dated_filename(char *s, const char *ext, size_t len); /** * fill_str_dated_filename: - * @out_filename : output filename + * @s : output filename * @in_str : input string * @ext : extension of output filename - * @size : buffer size of output filename + * @len : buffer size of output filename * * Creates a 'dated' filename prefixed by the string @in_str, and * concatenates extension (@ext) to it. * * E.g.: - * out_filename = "RetroArch-{year}{month}{day}-{Hour}{Minute}{Second}.{@ext}" + * s = "RetroArch-{year}{month}{day}-{Hour}{Minute}{Second}.{@ext}" * * Hidden non-leaf function cost: * - Calls time @@ -324,15 +323,13 @@ size_t fill_dated_filename(char *out_filename, * - Calls strftime * - Calls strlcat * - * @return Length of the string copied into @out_path + * @return Length of the string copied into @s **/ -size_t fill_str_dated_filename(char *out_filename, - const char *in_str, const char *ext, size_t size); +size_t fill_str_dated_filename(char *s, const char *in_str, const char *ext, size_t len); /** * find_last_slash: * @str : path - * @size : size of path * * Find last slash in path. Tries to find * a backslash on Windows too which takes precedence @@ -347,36 +344,36 @@ char *find_last_slash(const char *str); /** * fill_pathname_dir: - * @in_dir : input directory path - * @in_basename : input basename to be appended to @in_dir + * @s : input directory path + * @in_basename : input basename to be appended to @s * @replace : replacement to be appended to @in_basename - * @size : size of buffer + * @len : size of buffer * - * Appends basename of 'in_basename', to 'in_dir', along with 'replace'. + * Appends basename of 'in_basename', to 's', along with 'replace'. * Basename of in_basename is the string after the last '/' or '\\', * i.e the filename without directories. * * If in_basename has no '/' or '\\', the whole 'in_basename' will be used. - * 'size' is buffer size of 'in_dir'. + * 'len' is buffer size of 's'. * - * E.g..: in_dir = "/tmp/some_dir", in_basename = "/some_content/foo.c", - * replace = ".asm" => in_dir = "/tmp/some_dir/foo.c.asm" + * E.g..: s = "/tmp/some_dir", in_basename = "/some_content/foo.c", + * replace = ".asm" => s = "/tmp/some_dir/foo.c.asm" * * Hidden non-leaf function cost: * - Calls fill_pathname_slash() * - Calls path_basename() * - Calls strlcpy 2x **/ -size_t fill_pathname_dir(char *in_dir, const char *in_basename, - const char *replace, size_t size); +size_t fill_pathname_dir(char *s, const char *in_basename, + const char *replace, size_t len); /** * fill_pathname_base: - * @out : output path + * @s : output path * @in_path : input path * @size : size of output path * - * Copies basename of @in_path into @out_path. + * Copies basename of @in_path into @s. * * Hidden non-leaf function cost: * - Calls path_basename() @@ -384,23 +381,23 @@ size_t fill_pathname_dir(char *in_dir, const char *in_basename, * * @return length of the string copied into @out **/ -size_t fill_pathname_base(char *out_path, const char *in_path, size_t size); +size_t fill_pathname_base(char *s, const char *in_path, size_t len); /** * fill_pathname_basedir: - * @out_dir : output directory + * @s : output directory * @in_path : input path * @size : size of output directory * - * Copies base directory of @in_path into @out_path. + * Copies base directory of @in_path into @s. * If in_path is a path without any slashes (relative current directory), - * @out_path will get path "./". + * @s will get path "./". * * Hidden non-leaf function cost: * - Calls strlcpy * - Calls path_basedir() **/ -size_t fill_pathname_basedir(char *out_path, const char *in_path, size_t size); +size_t fill_pathname_basedir(char *s, const char *in_path, size_t len); /** * fill_pathname_parent_dir_name: @@ -435,27 +432,27 @@ size_t fill_pathname_parent_dir_name(char *s, * - Calls strlen if (@out_dir == @in_dir) * - Calls path_parent_dir() **/ -void fill_pathname_parent_dir(char *out_dir, - const char *in_dir, size_t size); +void fill_pathname_parent_dir(char *s, + const char *in_dir, size_t len); /** * fill_pathname_resolve_relative: - * @out_path : output path + * @s : output path * @in_refpath : input reference path * @in_path : input path - * @size : size of @out_path + * @size : size of @s * * Joins basedir of @in_refpath together with @in_path. - * If @in_path is an absolute path, out_path = in_path. + * If @in_path is an absolute path, s = in_path. * E.g.: in_refpath = "/foo/bar/baz.a", in_path = "foobar.cg", - * out_path = "/foo/bar/foobar.cg". + * s = "/foo/bar/foobar.cg". **/ -void fill_pathname_resolve_relative(char *out_path, const char *in_refpath, - const char *in_path, size_t size); +void fill_pathname_resolve_relative(char *s, const char *in_refpath, + const char *in_path, size_t len); /** * fill_pathname_join: - * @out_path : output path + * @s : output path * @dir : directory * @path : path * @size : size of output path @@ -469,24 +466,24 @@ void fill_pathname_resolve_relative(char *out_path, const char *in_refpath, * - calls fill_pathname_slash() * * Deprecated. Use fill_pathname_join_special() instead - * if you can ensure @dir != @out_path + * if you can ensure @dir != @s * - * @return Length of the string copied into @out_path + * @return Length of the string copied into @s **/ -size_t fill_pathname_join(char *out_path, const char *dir, - const char *path, size_t size); +size_t fill_pathname_join(char *s, const char *dir, + const char *path, size_t len); /** * fill_pathname_join_special: - * @out_path : output path - * @dir : directory. Cannot be identical to @out_path + * @s : output path + * @dir : directory. Cannot be identical to @s * @path : path * @size : size of output path * * * Specialized version of fill_pathname_join. * Unlike fill_pathname_join(), - * @dir and @out_path CANNOT be identical. + * @dir and @s CANNOT be identical. * * Joins a directory (@dir) and path (@path) together. * Makes sure not to get two consecutive slashes @@ -495,19 +492,19 @@ size_t fill_pathname_join(char *out_path, const char *dir, * Hidden non-leaf function cost: * - calls strlcpy 2x * - * @return Length of the string copied into @out_path + * @return Length of the string copied into @s **/ -size_t fill_pathname_join_special(char *out_path, - const char *dir, const char *path, size_t size); +size_t fill_pathname_join_special(char *s, + const char *dir, const char *path, size_t len); -size_t fill_pathname_join_special_ext(char *out_path, +size_t fill_pathname_join_special_ext(char *s, const char *dir, const char *path, const char *last, const char *ext, - size_t size); + size_t len); /** * fill_pathname_join_delim: - * @out_path : output path + * @s : output path * @dir : directory * @path : path * @delim : delimiter @@ -521,14 +518,14 @@ size_t fill_pathname_join_special_ext(char *out_path, * - can call strlcpy * - can call strlcat **/ -size_t fill_pathname_join_delim(char *out_path, const char *dir, - const char *path, const char delim, size_t size); +size_t fill_pathname_join_delim(char *s, const char *dir, + const char *path, const char delim, size_t len); -size_t fill_pathname_expand_special(char *out_path, - const char *in_path, size_t size); +size_t fill_pathname_expand_special(char *s, + const char *in_path, size_t len); -size_t fill_pathname_abbreviate_special(char *out_path, - const char *in_path, size_t size); +size_t fill_pathname_abbreviate_special(char *s, + const char *in_path, size_t len); /** * fill_pathname_abbreviated_or_relative: @@ -540,10 +537,10 @@ size_t fill_pathname_abbreviate_special(char *out_path, * the relative path will be used * @in_path can be an absolute, relative or abbreviated path * - * @return Length of the string copied into @out_path + * @return Length of the string copied into @s **/ -size_t fill_pathname_abbreviated_or_relative(char *out_path, - const char *in_refpath, const char *in_path, size_t size); +size_t fill_pathname_abbreviated_or_relative(char *s, + const char *in_refpath, const char *in_path, size_t len); /** * sanitize_path_part: @@ -557,7 +554,7 @@ size_t fill_pathname_abbreviated_or_relative(char *out_path, * * @returns new string that has been sanitized **/ -const char *sanitize_path_part(const char *path_part, size_t size); +const char *sanitize_path_part(const char *path_part, size_t len); /** * pathname_conform_slashes_to_os: @@ -569,7 +566,7 @@ const char *sanitize_path_part(const char *path_part, size_t size); * Changes the slashes to the correct kind for the os * So forward slash on linux and backslash on Windows **/ -void pathname_conform_slashes_to_os(char *path); +void pathname_conform_slashes_to_os(char *s); /** * pathname_make_slashes_portable: @@ -580,7 +577,7 @@ void pathname_conform_slashes_to_os(char *path); * Change all slashes to forward so they are more * portable between Windows and Linux **/ -void pathname_make_slashes_portable(char *path); +void pathname_make_slashes_portable(char *s); /** * path_basedir: @@ -589,7 +586,7 @@ void pathname_make_slashes_portable(char *path); * Extracts base directory by mutating path. * Keeps trailing '/'. **/ -void path_basedir_wrapper(char *path); +void path_basedir_wrapper(char *s); /** * path_char_is_slash: @@ -632,12 +629,12 @@ void path_basedir_wrapper(char *path); * - can call strlcat once if it returns false * - calls strlen **/ -size_t fill_pathname_slash(char *path, size_t size); +size_t fill_pathname_slash(char *s, size_t len); #if !defined(RARCH_CONSOLE) && defined(RARCH_INTERNAL) -size_t fill_pathname_application_path(char *buf, size_t size); -size_t fill_pathname_application_dir(char *buf, size_t size); -size_t fill_pathname_home_dir(char *buf, size_t size); +size_t fill_pathname_application_path(char *s, size_t len); +size_t fill_pathname_application_dir(char *s, size_t len); +size_t fill_pathname_home_dir(char *s, size_t len); #endif /** diff --git a/libretro-common/include/memalign.h b/libretro-common/include/memalign.h index 59ffbd7439b6..cbe94042a35f 100644 --- a/libretro-common/include/memalign.h +++ b/libretro-common/include/memalign.h @@ -29,9 +29,9 @@ RETRO_BEGIN_DECLS -void *memalign_alloc(size_t boundary, size_t size); +void *memalign_alloc(size_t boundary, size_t len); -void *memalign_alloc_aligned(size_t size); +void *memalign_alloc_aligned(size_t len); void memalign_free(void *ptr); diff --git a/libretro-common/include/net/net_http.h b/libretro-common/include/net/net_http.h index c328d4265f8a..7b68ddd6304d 100644 --- a/libretro-common/include/net/net_http.h +++ b/libretro-common/include/net/net_http.h @@ -84,7 +84,7 @@ bool net_http_update(struct http_t *state, size_t* progress, size_t* total); * Report HTTP status. 200, 404, or whatever. * * Leaf function. - * + * * @return HTTP status code. **/ int net_http_status(struct http_t *state); @@ -138,7 +138,7 @@ void net_http_urlencode(char **dest, const char *source); * * Re-encode a full URL **/ -void net_http_urlencode_full(char *dest, const char *source, size_t size); +void net_http_urlencode_full(char *s, const char *source, size_t len); RETRO_END_DECLS diff --git a/libretro-common/include/net/net_socket.h b/libretro-common/include/net/net_socket.h index 4fa5c13fff31..bca3a6b0e62d 100644 --- a/libretro-common/include/net/net_socket.h +++ b/libretro-common/include/net/net_socket.h @@ -81,23 +81,21 @@ int socket_poll(struct pollfd *fds, unsigned nfds, int timeout); bool socket_wait(int fd, bool *rd, bool *wr, int timeout); -bool socket_send_all_blocking(int fd, const void *data_, size_t size, bool no_signal); +bool socket_send_all_blocking(int fd, const void *data_, size_t len, bool no_signal); bool socket_send_all_blocking_with_timeout(int fd, - const void *data_, size_t size, - int timeout, bool no_signal); + const void *data_, size_t len, int timeout, bool no_signal); -ssize_t socket_send_all_nonblocking(int fd, const void *data_, size_t size, +ssize_t socket_send_all_nonblocking(int fd, const void *data_, size_t len, bool no_signal); -bool socket_receive_all_blocking(int fd, void *data_, size_t size); +bool socket_receive_all_blocking(int fd, void *data_, size_t len); bool socket_receive_all_blocking_with_timeout(int fd, - void *data_, size_t size, - int timeout); + void *data_, size_t len, int timeout); ssize_t socket_receive_all_nonblocking(int fd, bool *error, - void *data_, size_t size); + void *data_, size_t len); bool socket_bind(int fd, void *data); diff --git a/libretro-common/include/net/net_socket_ssl.h b/libretro-common/include/net/net_socket_ssl.h index 57e2627ed6f3..1ed9ce1bbe0b 100644 --- a/libretro-common/include/net/net_socket_ssl.h +++ b/libretro-common/include/net/net_socket_ssl.h @@ -33,13 +33,13 @@ void* ssl_socket_init(int fd, const char *domain); int ssl_socket_connect(void *state_data, void *data, bool timeout_enable, bool nonblock); -int ssl_socket_send_all_blocking(void *state_data, const void *data_, size_t size, bool no_signal); +int ssl_socket_send_all_blocking(void *state_data, const void *data_, size_t len, bool no_signal); -ssize_t ssl_socket_send_all_nonblocking(void *state_data, const void *data_, size_t size, bool no_signal); +ssize_t ssl_socket_send_all_nonblocking(void *state_data, const void *data_, size_t len, bool no_signal); -int ssl_socket_receive_all_blocking(void *state_data, void *data_, size_t size); +int ssl_socket_receive_all_blocking(void *state_data, void *data_, size_t len); -ssize_t ssl_socket_receive_all_nonblocking(void *state_data, bool *error, void *data_, size_t size); +ssize_t ssl_socket_receive_all_nonblocking(void *state_data, bool *error, void *data_, size_t len); void ssl_socket_close(void *state_data); diff --git a/libretro-common/include/queues/fifo_queue.h b/libretro-common/include/queues/fifo_queue.h index 5be3f3f58def..4879c3e96e1d 100644 --- a/libretro-common/include/queues/fifo_queue.h +++ b/libretro-common/include/queues/fifo_queue.h @@ -90,7 +90,7 @@ typedef struct fifo_buffer fifo_buffer_t; * @return The new queue if successful, \c NULL otherwise. * @see fifo_initialize */ -fifo_buffer_t *fifo_new(size_t size); +fifo_buffer_t *fifo_new(size_t len); /** * Initializes an existing FIFO queue with \c size bytes of memory. @@ -105,7 +105,7 @@ fifo_buffer_t *fifo_new(size_t size); * @return \c true if \c buf was initialized with the requested memory, * \c false if \c buf is \c NULL or there was an error. */ -bool fifo_initialize(fifo_buffer_t *buf, size_t size); +bool fifo_initialize(fifo_buffer_t *buf, size_t len); /** * Resets the bounds of \c buffer, @@ -130,7 +130,7 @@ static INLINE void fifo_clear(fifo_buffer_t *buffer) * @param in_buf The buffer to read bytes from. * @param size The length of \c in_buf, in bytes. */ -void fifo_write(fifo_buffer_t *buffer, const void *in_buf, size_t size); +void fifo_write(fifo_buffer_t *buffer, const void *in_buf, size_t len); /** * Reads \c size bytes from the given queue. @@ -140,7 +140,7 @@ void fifo_write(fifo_buffer_t *buffer, const void *in_buf, size_t size); * @param size The length of \c in_buf, in bytes. * @post Upon return, \c buffer will have up to \c size more bytes of space available for writing. */ -void fifo_read(fifo_buffer_t *buffer, void *in_buf, size_t size); +void fifo_read(fifo_buffer_t *buffer, void *in_buf, size_t len); /** * Releases \c buffer and its contents. diff --git a/libretro-common/include/queues/message_queue.h b/libretro-common/include/queues/message_queue.h index d79c064604b5..964129b351c8 100644 --- a/libretro-common/include/queues/message_queue.h +++ b/libretro-common/include/queues/message_queue.h @@ -73,16 +73,16 @@ typedef struct /** * msg_queue_new: - * @size : maximum size of message + * @len : maximum size of message * * Creates a message queue with maximum size different messages. * * Returns: NULL if allocation error, pointer to a message queue * if successful. Has to be freed manually. **/ -msg_queue_t *msg_queue_new(size_t size); +msg_queue_t *msg_queue_new(size_t len); -bool msg_queue_initialize(msg_queue_t *queue, size_t size); +bool msg_queue_initialize(msg_queue_t *queue, size_t len); /** * msg_queue_push: diff --git a/libretro-common/include/streams/network_stream.h b/libretro-common/include/streams/network_stream.h index e499db716d56..66ea47e46188 100644 --- a/libretro-common/include/streams/network_stream.h +++ b/libretro-common/include/streams/network_stream.h @@ -97,7 +97,7 @@ typedef struct netstream * or less than \c used. * @see netstream_close */ -bool netstream_open(netstream_t *stream, void *buf, size_t size, size_t used); +bool netstream_open(netstream_t *stream, void *buf, size_t len, size_t used); /** * Closes a network-order stream. diff --git a/libretro-common/include/streams/stdin_stream.h b/libretro-common/include/streams/stdin_stream.h index 1b66d0c455e6..afc85e9b24b1 100644 --- a/libretro-common/include/streams/stdin_stream.h +++ b/libretro-common/include/streams/stdin_stream.h @@ -43,7 +43,7 @@ RETRO_BEGIN_DECLS * but this function can read binary data as well. * @see https://man7.org/linux/man-pages/man3/stdout.3.html */ -size_t read_stdin(char *buf, size_t size); +size_t read_stdin(char *s, size_t len); RETRO_END_DECLS diff --git a/libretro-common/include/string/stdstring.h b/libretro-common/include/string/stdstring.h index e7cb76c71235..02e275ce0592 100644 --- a/libretro-common/include/string/stdstring.h +++ b/libretro-common/include/string/stdstring.h @@ -73,9 +73,9 @@ static INLINE bool string_is_equal(const char *a, const char *b) } static INLINE bool string_starts_with_size(const char *str, const char *prefix, - size_t size) + size_t len) { - return (str && prefix) ? !strncmp(prefix, str, size) : false; + return (str && prefix) ? !strncmp(prefix, str, len) : false; } static INLINE bool string_starts_with(const char *str, const char *prefix) @@ -106,11 +106,11 @@ static INLINE bool string_ends_with(const char *str, const char *suffix) * - If 'str' is not NULL and no '\0' character is found * in the first 'size' characters, returns 'size' **/ -static INLINE size_t strlen_size(const char *str, size_t size) +static INLINE size_t strlen_size(const char *str, size_t len) { size_t i = 0; if (str) - while (i < size && str[i]) i++; + while (i < len && str[i]) i++; return i; } diff --git a/libretro-common/net/net_socket_ssl_bear.c b/libretro-common/net/net_socket_ssl_bear.c index 3892e79587fc..691e1b08a7fb 100644 --- a/libretro-common/net/net_socket_ssl_bear.c +++ b/libretro-common/net/net_socket_ssl_bear.c @@ -61,20 +61,20 @@ static bool append_cert_x509(void* x509, size_t len) br_x509_pkey* pk; br_x509_decoder_context dc; br_x509_trust_anchor* ta = &TAs[TAs_NUM]; - + current_vdn = NULL; current_vdn_size = 0; - + br_x509_decoder_init(&dc, vdn_append, NULL); br_x509_decoder_push(&dc, x509, len); pk = br_x509_decoder_get_pkey(&dc); if (!pk || !br_x509_decoder_isCA(&dc)) return false; - + ta->dn.len = current_vdn_size; ta->dn.data = current_vdn; ta->flags = BR_X509_TA_CA; - + switch (pk->key_type) { case BR_KEYTYPE_RSA: @@ -93,7 +93,7 @@ static bool append_cert_x509(void* x509, size_t len) default: return false; } - + TAs_NUM++; return true; } @@ -120,7 +120,7 @@ static char* delete_linebreaks(char* in) return in; } -/* this rearranges its input, it's easier to implement +/* this rearranges its input, it's easier to implement * that way and caller doesn't need it anymore anyways */ static void append_certs_pem_x509(char * certs_pem) { @@ -148,7 +148,7 @@ static void append_certs_pem_x509(char * certs_pem) } } -/* TODO: not thread safe, rthreads doesn't provide any +/* TODO: not thread safe, rthreads doesn't provide any * statically allocatable mutex/etc */ static void initialize(void) { @@ -186,8 +186,8 @@ static bool process_inner(struct ssl_state *state, bool blocking) if (buflen) { if (blocking) - bytes = (socket_send_all_blocking(state->fd, buf, buflen, true) - ? buflen + bytes = (socket_send_all_blocking(state->fd, buf, buflen, true) + ? buflen : -1); else bytes = socket_send_all_nonblocking(state->fd, buf, buflen, true); @@ -196,9 +196,9 @@ static bool process_inner(struct ssl_state *state, bool blocking) br_ssl_engine_sendrec_ack(&state->sc.eng, bytes); if (bytes < 0) return false; - /* if we did something, return immediately so we + /* if we did something, return immediately so we * don't try to read if Bear still wants to send */ - return true; + return true; } buf = br_ssl_engine_recvrec_buf(&state->sc.eng, &buflen); @@ -252,51 +252,48 @@ int ssl_socket_connect(void *state_data, } ssize_t ssl_socket_receive_all_nonblocking(void *state_data, - bool *error, void *data_, size_t size) + bool *error, void *data_, size_t len) { + size_t __len; + uint8_t *bear_data; struct ssl_state *state = (struct ssl_state*)state_data; - uint8_t * bear_data; - size_t bear_data_size; - socket_set_block(state->fd, false); - if (!process_inner(state, false)) { *error = true; return -1; } - - bear_data = br_ssl_engine_recvapp_buf(&state->sc.eng, &bear_data_size); - if (bear_data_size > size) bear_data_size = size; - memcpy(data_, bear_data, bear_data_size); - if (bear_data_size) - br_ssl_engine_recvapp_ack(&state->sc.eng, bear_data_size); - - return bear_data_size; + bear_data = br_ssl_engine_recvapp_buf(&state->sc.eng, &__len); + if (__len > len) + __len = len; + memcpy(data_, bear_data, __len); + if (__len) + br_ssl_engine_recvapp_ack(&state->sc.eng, __len); + return __len; } int ssl_socket_receive_all_blocking(void *state_data, - void *data_, size_t size) + void *data_, size_t len) { + size_t __len; struct ssl_state *state = (struct ssl_state*)state_data; uint8_t *data = (uint8_t*)data_; uint8_t * bear_data; - size_t bear_data_size; socket_set_block(state->fd, true); for (;;) { - bear_data = br_ssl_engine_recvapp_buf(&state->sc.eng, &bear_data_size); - if (bear_data_size > size) - bear_data_size = size; - memcpy(data, bear_data, bear_data_size); - if (bear_data_size) - br_ssl_engine_recvapp_ack(&state->sc.eng, bear_data_size); - data += bear_data_size; - size -= bear_data_size; - - if (size) + bear_data = br_ssl_engine_recvapp_buf(&state->sc.eng, &__len); + if (__len > len) + __len = len; + memcpy(data, bear_data, __len); + if (__len) + br_ssl_engine_recvapp_ack(&state->sc.eng, __len); + data += __len; + len -= __len; + + if (len) process_inner(state, true); else break; @@ -305,27 +302,27 @@ int ssl_socket_receive_all_blocking(void *state_data, } int ssl_socket_send_all_blocking(void *state_data, - const void *data_, size_t size, bool no_signal) + const void *data_, size_t len, bool no_signal) { + size_t __len; struct ssl_state *state = (struct ssl_state*)state_data; const uint8_t *data = (const uint8_t*)data_; uint8_t * bear_data; - size_t bear_data_size; socket_set_block(state->fd, true); for (;;) { - bear_data = br_ssl_engine_sendapp_buf(&state->sc.eng, &bear_data_size); - if (bear_data_size > size) - bear_data_size = size; - memcpy(bear_data, data_, bear_data_size); - if (bear_data_size) - br_ssl_engine_sendapp_ack(&state->sc.eng, bear_data_size); - data += bear_data_size; - size -= bear_data_size; - - if (size) + bear_data = br_ssl_engine_sendapp_buf(&state->sc.eng, &__len); + if (__len > len) + __len = len; + memcpy(bear_data, data_, __len); + if (__len) + br_ssl_engine_sendapp_ack(&state->sc.eng, __len); + data += __len; + len -= __len; + + if (len) process_inner(state, true); else break; @@ -337,28 +334,25 @@ int ssl_socket_send_all_blocking(void *state_data, } ssize_t ssl_socket_send_all_nonblocking(void *state_data, - const void *data_, size_t size, bool no_signal) + const void *data_, size_t len, bool no_signal) { + size_t __len; + uint8_t *bear_data; struct ssl_state *state = (struct ssl_state*)state_data; - uint8_t * bear_data; - size_t bear_data_size; socket_set_block(state->fd, false); - - bear_data = br_ssl_engine_sendapp_buf(&state->sc.eng, &bear_data_size); - if (bear_data_size > size) - bear_data_size = size; - memcpy(bear_data, data_, bear_data_size); - if (bear_data_size) + bear_data = br_ssl_engine_sendapp_buf(&state->sc.eng, &__len); + if (__len > len) + __len = len; + memcpy(bear_data, data_, __len); + if (__len) { - br_ssl_engine_sendapp_ack(&state->sc.eng, bear_data_size); + br_ssl_engine_sendapp_ack(&state->sc.eng, __len); br_ssl_engine_flush(&state->sc.eng, false); } - if (!process_inner(state, false)) return -1; - - return bear_data_size; + return __len; } void ssl_socket_close(void *state_data) @@ -367,15 +361,15 @@ void ssl_socket_close(void *state_data) br_ssl_engine_close(&state->sc.eng); process_inner(state, false); /* send close notification */ - socket_close(state->fd); /* but immediately close socket - and don't worry about recipient + socket_close(state->fd); /* but immediately close socket + and don't worry about recipient getting our message */ } void ssl_socket_free(void *state_data) { struct ssl_state *state = (struct ssl_state*)state_data; - /* BearSSL does zero allocations of its own, + /* BearSSL does zero allocations of its own, * so other than this struct, there is nothing to free */ free(state); } diff --git a/libretro-common/net/net_socket_ssl_mbed.c b/libretro-common/net/net_socket_ssl_mbed.c index 76b1933e89b8..41abada776ad 100644 --- a/libretro-common/net/net_socket_ssl_mbed.c +++ b/libretro-common/net/net_socket_ssl_mbed.c @@ -171,7 +171,7 @@ int ssl_socket_connect(void *state_data, } ssize_t ssl_socket_receive_all_nonblocking(void *state_data, - bool *error, void *data_, size_t size) + bool *error, void *data_, size_t len) { ssize_t ret; struct ssl_state *state = (struct ssl_state*)state_data; @@ -180,7 +180,7 @@ ssize_t ssl_socket_receive_all_nonblocking(void *state_data, mbedtls_net_set_nonblock(&state->net_ctx); - ret = mbedtls_ssl_read(&state->ctx, (unsigned char*)data, size); + ret = mbedtls_ssl_read(&state->ctx, (unsigned char*)data, len); if (ret > 0) return ret; @@ -200,7 +200,7 @@ ssize_t ssl_socket_receive_all_nonblocking(void *state_data, } int ssl_socket_receive_all_blocking(void *state_data, - void *data_, size_t size) + void *data_, size_t len) { struct ssl_state *state = (struct ssl_state*)state_data; const uint8_t *data = (const uint8_t*)data_; @@ -209,12 +209,12 @@ int ssl_socket_receive_all_blocking(void *state_data, for (;;) { - /* mbedtls_ssl_read wants non-const data but it only reads it, + /* mbedtls_ssl_read wants non-const data but it only reads it, * so this cast is safe */ - int ret = mbedtls_ssl_read(&state->ctx, (unsigned char*)data, size); + int ret = mbedtls_ssl_read(&state->ctx, (unsigned char*)data, len); - if ( ret == MBEDTLS_ERR_SSL_WANT_READ || - ret == MBEDTLS_ERR_SSL_WANT_WRITE) + if ( ret == MBEDTLS_ERR_SSL_WANT_READ + || ret == MBEDTLS_ERR_SSL_WANT_WRITE) continue; if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) @@ -231,7 +231,7 @@ int ssl_socket_receive_all_blocking(void *state_data, } int ssl_socket_send_all_blocking(void *state_data, - const void *data_, size_t size, bool no_signal) + const void *data_, size_t len, bool no_signal) { int ret; struct ssl_state *state = (struct ssl_state*)state_data; @@ -239,9 +239,9 @@ int ssl_socket_send_all_blocking(void *state_data, mbedtls_net_set_block(&state->net_ctx); - while (size) + while (len) { - ret = mbedtls_ssl_write(&state->ctx, data, size); + ret = mbedtls_ssl_write(&state->ctx, data, len); if (!ret) continue; @@ -255,7 +255,7 @@ int ssl_socket_send_all_blocking(void *state_data, else { data += ret; - size -= ret; + len -= ret; } } @@ -263,21 +263,17 @@ int ssl_socket_send_all_blocking(void *state_data, } ssize_t ssl_socket_send_all_nonblocking(void *state_data, - const void *data_, size_t size, bool no_signal) + const void *data_, size_t len, bool no_signal) { int ret; - ssize_t sent = size; + ssize_t __len = len; struct ssl_state *state = (struct ssl_state*)state_data; const uint8_t *data = (const uint8_t*)data_; - mbedtls_net_set_nonblock(&state->net_ctx); - - ret = mbedtls_ssl_write(&state->ctx, data, size); - + ret = mbedtls_ssl_write(&state->ctx, data, len); if (ret <= 0) return -1; - - return sent; + return __len; } void ssl_socket_close(void *state_data) diff --git a/libretro-db/rmsgpack.c b/libretro-db/rmsgpack.c index 831bc95d1f54..ca4d2ea8ebec 100644 --- a/libretro-db/rmsgpack.c +++ b/libretro-db/rmsgpack.c @@ -353,14 +353,14 @@ int rmsgpack_write_uint(RFILE *fd, uint64_t value) return -1; } -static int rmsgpack_read_uint(RFILE *fd, uint64_t *out, size_t size) +static int rmsgpack_read_uint(RFILE *fd, uint64_t *out, size_t len) { union { uint64_t u64; uint32_t u32; uint16_t u16; uint8_t u8; } tmp; - if (filestream_read(fd, &tmp, size) == -1) + if (filestream_read(fd, &tmp, len) == -1) return -1; - switch (size) + switch (len) { case 1: *out = tmp.u8; @@ -378,14 +378,14 @@ static int rmsgpack_read_uint(RFILE *fd, uint64_t *out, size_t size) return 0; } -static int rmsgpack_read_int(RFILE *fd, int64_t *out, size_t size) +static int rmsgpack_read_int(RFILE *fd, int64_t *out, size_t len) { union { uint64_t u64; uint32_t u32; uint16_t u16; uint8_t u8; } tmp; - if (filestream_read(fd, &tmp, size) == -1) + if (filestream_read(fd, &tmp, len) == -1) return -1; - switch (size) + switch (len) { case 1: *out = (int8_t)tmp.u8; diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index c88dd76c81a6..2d6b8879330c 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -258,11 +258,11 @@ static int action_left_mainmenu(unsigned type, const char *label, #ifdef HAVE_XMB struct menu_state *menu_st = menu_state_get_ptr(); const menu_ctx_driver_t *driver_ctx = menu_st->driver_ctx; - size_t size = (driver_ctx && driver_ctx->list_get_size) ? driver_ctx->list_get_size(menu_st->userdata, MENU_LIST_PLAIN) : 0; + size_t _len = (driver_ctx && driver_ctx->list_get_size) ? driver_ctx->list_get_size(menu_st->userdata, MENU_LIST_PLAIN) : 0; const char *menu_ident = (driver_ctx && driver_ctx->ident) ? driver_ctx->ident : NULL; /* Tab switching functionality only applies * to XMB */ - if ( (size == 1) + if ( (_len == 1) && string_is_equal(menu_ident, "xmb")) { settings_t *settings = config_get_ptr(); diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index cac8d3f05a8d..d09f90ae610c 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -290,12 +290,12 @@ static int action_right_mainmenu(unsigned type, const char *label, const char *menu_ident = (driver_ctx && driver_ctx->ident) ? driver_ctx->ident : NULL; - size_t size = (driver_ctx && driver_ctx->list_get_size) + size_t _len = (driver_ctx && driver_ctx->list_get_size) ? driver_ctx->list_get_size(menu_st->userdata, MENU_LIST_PLAIN) : 0; /* Tab switching functionality only applies * to XMB */ - if ( (size == 1) + if ( (_len == 1) && string_is_equal(menu_ident, "xmb")) { size_t horiz_size = 0, tabs_size = 0, selection = 0; diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 0d3be498e42c..5e420738b303 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -11098,13 +11098,13 @@ static void materialui_list_insert( static void materialui_list_clear(file_list_t *list) { size_t i; - size_t size = list ? list->size : 0; + size_t _len = list ? list->size : 0; /* Must cancel pending thumbnail requests before * freeing node->thumbnails objects */ gfx_thumbnail_cancel_pending_requests(); - for (i = 0; i < size; i++) + for (i = 0; i < _len; i++) { materialui_node_t *node = (materialui_node_t*)list->list[i].userdata; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index b386968eaaae..8b3489593300 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -3592,13 +3592,13 @@ static int menu_displaylist_parse_horizontal_list( struct item_file *item = NULL; const menu_ctx_driver_t *driver_ctx = menu_st->driver_ctx; size_t selection = driver_ctx->list_get_selection ? driver_ctx->list_get_selection(menu_st->userdata) : 0; - size_t size = driver_ctx->list_get_size ? driver_ctx->list_get_size(menu_st->userdata, MENU_LIST_TABS) : 0; + size_t _len = driver_ctx->list_get_size ? driver_ctx->list_get_size(menu_st->userdata, MENU_LIST_TABS) : 0; if (!driver_ctx->list_get_entry) return -1; if (!(item = (struct item_file*)driver_ctx->list_get_entry(menu_st->userdata, MENU_LIST_HORIZONTAL, - (unsigned)(selection - (size +1))))) + (unsigned)(selection - (_len +1))))) return -1; /* When opening a saved view the explore menu will handle the list */ diff --git a/network/netplay/netplay_private.h b/network/netplay/netplay_private.h index 187822da3a47..d32161253f94 100644 --- a/network/netplay/netplay_private.h +++ b/network/netplay/netplay_private.h @@ -811,7 +811,7 @@ bool netplay_send_cur_input(netplay_t *netplay, */ bool netplay_send_raw_cmd(netplay_t *netplay, struct netplay_connection *connection, uint32_t cmd, const void *data, - size_t size); + size_t len); /** * netplay_send_raw_cmd_all @@ -822,7 +822,7 @@ bool netplay_send_raw_cmd(netplay_t *netplay, */ void netplay_send_raw_cmd_all(netplay_t *netplay, struct netplay_connection *except, uint32_t cmd, const void *data, - size_t size); + size_t len); /** * netplay_cmd_mode diff --git a/tasks/task_database.c b/tasks/task_database.c index da6bfa1f27a5..e2430170a3ea 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -331,11 +331,11 @@ static int task_database_cue_get_serial(const char *name, char *s, size_t len) { char track_path[PATH_MAX_LENGTH]; uint64_t offset = 0; - size_t size = 0; + size_t _len = 0; track_path[0] = '\0'; - if (cue_find_track(name, true, &offset, &size, + if (cue_find_track(name, true, &offset, &_len, track_path, sizeof(track_path)) < 0) { #ifdef DEBUG @@ -345,7 +345,7 @@ static int task_database_cue_get_serial(const char *name, char *s, size_t len) return 0; } - return intfstream_file_get_serial(track_path, offset, size, s, len); + return intfstream_file_get_serial(track_path, offset, _len, s, len); } static int task_database_gdi_get_serial(const char *name, char *s, size_t len) @@ -385,7 +385,7 @@ static int task_database_chd_get_serial(const char *name, char *serial, size_t l } static bool intfstream_file_get_crc(const char *name, - uint64_t offset, size_t size, uint32_t *crc) + uint64_t offset, size_t len, uint32_t *crc) { bool rv; intfstream_t *fd = intfstream_open_file(name, @@ -407,20 +407,20 @@ static bool intfstream_file_get_crc(const char *name, if (file_size < 0) goto error; - if (offset != 0 || size < (uint64_t) file_size) + if (offset != 0 || len < (uint64_t) file_size) { if (intfstream_seek(fd, (int64_t)offset, SEEK_SET) == -1) goto error; - data = (uint8_t*)malloc(size); + data = (uint8_t*)malloc(len); - if (intfstream_read(fd, data, size) != (int64_t) size) + if (intfstream_read(fd, data, len) != (int64_t)len) goto error; intfstream_close(fd); free(fd); fd = intfstream_open_memory(data, RETRO_VFS_FILE_ACCESS_READ, - RETRO_VFS_FILE_ACCESS_HINT_NONE, size); + RETRO_VFS_FILE_ACCESS_HINT_NONE, len); if (!fd) goto error; @@ -447,11 +447,11 @@ static int task_database_cue_get_crc(const char *name, uint32_t *crc) { char track_path[PATH_MAX_LENGTH]; uint64_t offset = 0; - size_t size = 0; + size_t _len = 0; track_path[0] = '\0'; - if (cue_find_track(name, false, &offset, &size, + if (cue_find_track(name, false, &offset, &_len, track_path, sizeof(track_path)) < 0) { #ifdef DEBUG @@ -461,7 +461,7 @@ static int task_database_cue_get_crc(const char *name, uint32_t *crc) return 0; } - return intfstream_file_get_crc(track_path, offset, size, crc); + return intfstream_file_get_crc(track_path, offset, _len, crc); } static int task_database_gdi_get_crc(const char *name, uint32_t *crc) diff --git a/tasks/task_menu_explore.c b/tasks/task_menu_explore.c index 110f088d631c..d1f6f3e27837 100644 --- a/tasks/task_menu_explore.c +++ b/tasks/task_menu_explore.c @@ -94,14 +94,14 @@ static void cb_task_menu_explore_init( const menu_ctx_driver_t *driver_ctx = menu_st->driver_ctx; if (driver_ctx->list_get_entry) { - size_t selection = driver_ctx->list_get_selection ? driver_ctx->list_get_selection(menu_st->userdata) : 0; - size_t size = driver_ctx->list_get_size ? driver_ctx->list_get_size(menu_st->userdata, MENU_LIST_TABS) : 0; - if (selection > 0 && size > 0) + size_t selection = driver_ctx->list_get_selection ? driver_ctx->list_get_selection(menu_st->userdata) : 0; + size_t _len = driver_ctx->list_get_size ? driver_ctx->list_get_size(menu_st->userdata, MENU_LIST_TABS) : 0; + if (selection > 0 && _len > 0) { struct item_file *item = NULL; /* Label contains the path and path contains the label */ if ((item = (struct item_file*)driver_ctx->list_get_entry(menu_st->userdata, MENU_LIST_HORIZONTAL, - (unsigned)(selection - (size +1))))) + (unsigned)(selection - (_len +1))))) menu_type = item->type; } } diff --git a/tasks/task_save.c b/tasks/task_save.c index d078a9b261dc..6ee35921f13f 100644 --- a/tasks/task_save.c +++ b/tasks/task_save.c @@ -989,7 +989,7 @@ static void content_load_state_cb(retro_task_t *task, unsigned i; bool ret; load_task_data_t *load_data = (load_task_data_t*)task_data; - ssize_t size = load_data->size; + ssize_t _len = load_data->size; unsigned num_blocks = 0; void *buf = load_data->data; struct sram_block *blocks = NULL; @@ -1005,10 +1005,10 @@ static void content_load_state_cb(retro_task_t *task, RARCH_LOG("[State]: %s \"%s\", %u %s.\n", msg_hash_to_str(MSG_LOADING_STATE), load_data->path, - (unsigned)size, + (unsigned)_len, msg_hash_to_str(MSG_BYTES)); - if (size < 0 || !buf) + if (_len < 0 || !buf) goto error; /* This means we're backing up the file in memory, @@ -1023,11 +1023,11 @@ static void content_load_state_cb(retro_task_t *task, undo_save_buf.data = NULL; } - if (!(undo_save_buf.data = malloc(size))) + if (!(undo_save_buf.data = malloc(_len))) goto error; - memcpy(undo_save_buf.data, buf, size); - undo_save_buf.size = size; + memcpy(undo_save_buf.data, buf, _len); + undo_save_buf.size = _len; strlcpy(undo_save_buf.path, load_data->path, sizeof(undo_save_buf.path)); free(buf); @@ -1083,7 +1083,7 @@ static void content_load_state_cb(retro_task_t *task, /* Backup the current state so we can undo this load */ content_save_state("RAM", false); - ret = content_deserialize_state(buf, size); + ret = content_deserialize_state(buf, _len); /* Flush back. */ for (i = 0; i < num_blocks; i++) diff --git a/ui/drivers/qt/qt_options.h b/ui/drivers/qt/qt_options.h index 6eb8d3228663..3ddbe3f491ca 100644 --- a/ui/drivers/qt/qt_options.h +++ b/ui/drivers/qt/qt_options.h @@ -57,16 +57,16 @@ class OptionsCategory : public QObject QString categoryIconName() const { return m_categoryIconName; } virtual void load() { - unsigned i; - size_t size = m_pages.size(); - for (i = 0; i < size; i++) + size_t i; + size_t _len = m_pages.size(); + for (i = 0; i < _len; i++) m_pages.at(i)->load(); } virtual void apply() { - unsigned i; - size_t size = m_pages.size(); - for (i = 0; i < size; i++) + size_t i; + size_t _len = m_pages.size(); + for (i = 0; i < _len; i++) m_pages.at(i)->apply(); } protected: diff --git a/ui/drivers/ui_qt.cpp b/ui/drivers/ui_qt.cpp index a3cd362a9d14..8f310942b998 100644 --- a/ui/drivers/ui_qt.cpp +++ b/ui/drivers/ui_qt.cpp @@ -1623,9 +1623,9 @@ void MainWindow::updateVisibleItems() { size_t i; QVector indexes = m_gridView->visibleIndexes(); - size_t size = indexes.size(); + size_t _len = indexes.size(); - for (i = 0; i < size; i++) + for (i = 0; i < _len; i++) m_playlistModel->loadThumbnail(m_proxyModel->mapToSource(indexes.at(i))); } } @@ -1662,9 +1662,9 @@ QVector > MainWindow::getPlaylists() { size_t i; QVector > playlists; - size_t size = m_listWidget->count(); + size_t _len = m_listWidget->count(); - for (i = 0; i < size; i++) + for (i = 0; i < _len; i++) { QString label, path; QPair pair; @@ -1740,10 +1740,10 @@ void MainWindow::onZoomValueChanged(int zoom_val) int new_size = 0; if (zoom_val < 50) - new_size = exp_scale( - lerp(0, 49, 25, 49, zoom_val) / 50.0, 102, 256); + new_size = exp_scale(lerp(0, 49, 25, 49, zoom_val) + / 50.0, 102, 256); else - new_size = exp_scale(zoom_val / 100.0, 256, 1024); + new_size = exp_scale(zoom_val / 100.0, 256, 1024); m_gridView->setGridSize(new_size); From 69ceb95ddcfcc50356cd731a9b0f8fe4f099db11 Mon Sep 17 00:00:00 2001 From: Apteryks Date: Fri, 17 Jan 2025 19:04:23 +0000 Subject: [PATCH 40/49] Add libretro assets directory search path, and have environment variables override configured values (#17054) * platform_win32: Fix sizeof for DEFAULT_DIR_PLAYLIST. * frontend/drivers/platform_win32.c (frontend_win32_env_get): Check the size of correct destination array. * frontend: Honor the LIBRETRO_ASSETS_DIRECTORY environment variable. This builds on 763fcd8267 ("unix, win32: Allow set the default libretro_directory via environment variable") to also allow specifying the assets directory via an environment variable. * frontend/drivers/platform_unix.c (frontend_unix_get_env) New variable. Use it to set DEFAULT_DIR_ASSETS, when available. * frontend/drivers/platform_win32.c (frontend_win32_env_get): Likewise. * platform: Honor the LIBRETRO_DIRECTORY environment variable. Until now, and unlike the defaut core directory, the default core *info* directory would be hard-coded relative to the installation directory. Honor the LIBRETRO_DIRECTORY environment variable the same instead. * frontend/drivers/platform_unix.c (frontend_unix_get_env): Set DEFAULT_DIR_CORE_INFO default to the value of the LIBRETRO_DIRECTORY environment variable, if available. * frontend/drivers/platform_win32.c (frontend_win32_env_get): Likewise. * platform: Honor the LIBRETRO_AUTOCONFIG_DIRECTORY environment variable. * frontend/drivers/platform_unix.c (libretro_autoconfig_directory): New variable. (frontend_unix_get_env): Set DEFAULT_DIR_AUTOCONFIG to the value of the LIBRETRO_AUTOCONFIG_DIRECTORY environment variable, if available. * frontend/drivers/platform_win32.c: Likewise. * platform: Honor the LIBRETRO_VIDEO_FILTER_DIRECTORY environment variable. * frontend/drivers/platform_unix.c (libretro_video_filter_directory): New variable. (frontend_unix_get_env): Set DEFAULT_DIR_VIDEO_FILTER to the value of the LIBRETRO_VIDEO_FILTER_DIRECTORY environment variable, if available. * frontend/drivers/platform_win32.c: Likewise. * platform: Honor the LIBRETRO_VIDEO_SHADER_DIRECTORY environment variable. * frontend/drivers/platform_unix.c (libretro_video_shader_directory): New variable. (frontend_unix_get_env): Set DEFAULT_DIR_SHADER to the value of the LIBRETRO_VIDEO_SHADER_DIRECTORY environment variable, if available. * frontend/drivers/platform_win32.c: Likewise. * platform: Honor the LIBRETRO_SYSTEM_DIRECTORY environment variable. * frontend/drivers/platform_unix.c (libretro_system_directory): New variable. (frontend_unix_get_env): Set DEFAULT_DIR_SYSTEM to the value of the LIBRETRO_SYSTEM_DIRECTORY environment variable, if available. * frontend/drivers/platform_win32.c: Likewise. * configuration: Have environment variables override configuration. Because the configuration file is systematically written when RetroArch terminates, persisting any previous default/configured value, setting the LIBRETRO_DIRECTORY, LIBRETRO_ASSETS_DIRECTORY, etc. environment variables would not have an effect unless the retroarch.cfg configuration file was cleared. This seems to go against the common expectation that environment variables are set by users to *override* the default behavior or configuration of an application. * configuration.c (config_load_file) : New variables. Use the values of the LIBRETRO_DIRECTORY, LIBRETRO_ASSETS_DIRECTORY, LIBRETRO_AUTOCONFIG_DIRECTORY, LIBRETRO_SYSTEM_DIRECTORY, LIBRETRO_VIDEO_FILTER_DIRECTORY and LIBRETRO_VIDEO_SHADER_DIRECTORY environment variables instead of their corresponding configured values, when set. * docs/retroarch.6: Document the environment variables honored and their behavior. --- configuration.c | 50 +++++++++++++++++++++----- docs/retroarch.6 | 41 ++++++++++++++++++++- frontend/drivers/platform_unix.c | 52 +++++++++++++++++++++------ frontend/drivers/platform_win32.c | 60 ++++++++++++++++++++++++------- 4 files changed, 169 insertions(+), 34 deletions(-) diff --git a/configuration.c b/configuration.c index 2631bc01fec6..301290e2f5b2 100644 --- a/configuration.c +++ b/configuration.c @@ -3568,6 +3568,12 @@ static bool config_load_file(global_t *global, { unsigned i; char tmp_str[PATH_MAX_LENGTH]; + char* libretro_directory = NULL; + char* libretro_assets_directory = NULL; + char* libretro_autoconfig_directory = NULL; + char* libretro_system_directory = NULL; + char* libretro_video_filter_directory = NULL; + char* libretro_video_shader_directory = NULL; static bool first_load = true; bool without_overrides = false; unsigned msg_color = 0; @@ -3849,12 +3855,6 @@ static bool config_load_file(global_t *global, strlcpy(path_settings[i].ptr, tmp_str, PATH_MAX_LENGTH); } -#if !IOS - if (config_get_path(conf, "libretro_directory", tmp_str, sizeof(tmp_str))) - configuration_set_string(settings, - settings->paths.directory_libretro, tmp_str); -#endif - #ifdef RARCH_CONSOLE if (conf) video_driver_load_settings(global, conf); @@ -3862,6 +3862,26 @@ static bool config_load_file(global_t *global, /* Post-settings load */ + libretro_directory = getenv("LIBRETRO_DIRECTORY"); + if (libretro_directory) { + configuration_set_string(settings, + settings->paths.directory_libretro, libretro_directory); + configuration_set_string(settings, + settings->paths.path_libretro_info, libretro_directory); + } + + libretro_autoconfig_directory = getenv("LIBRETRO_AUTOCONFIG_DIRECTORY"); + if (libretro_autoconfig_directory) + configuration_set_string(settings, + settings->paths.directory_autoconfig, + libretro_autoconfig_directory); + + libretro_system_directory = getenv("LIBRETRO_SYSTEM_DIRECTORY"); + if (libretro_system_directory) + configuration_set_string(settings, + settings->paths.directory_system, + libretro_system_directory); + if ( (rarch_flags & RARCH_FLAGS_HAS_SET_USERNAME) && (override_username)) { @@ -4026,15 +4046,27 @@ static bool config_load_file(global_t *global, *settings->paths.path_menu_wallpaper = '\0'; if (string_is_equal(settings->paths.path_rgui_theme_preset, "default")) *settings->paths.path_rgui_theme_preset = '\0'; - if (string_is_equal(settings->paths.directory_video_shader, "default")) + libretro_video_shader_directory = getenv("LIBRETRO_VIDEO_SHADER_DIRECTORY"); + if (libretro_video_shader_directory) { /* override configuration value */ + configuration_set_string(settings, settings->paths.directory_video_shader, + libretro_video_shader_directory); + } else if (string_is_equal(settings->paths.directory_video_shader, "default")) *settings->paths.directory_video_shader = '\0'; - if (string_is_equal(settings->paths.directory_video_filter, "default")) + libretro_video_filter_directory = getenv("LIBRETRO_VIDEO_FILTER_DIRECTORY"); + if (libretro_video_filter_directory) { /* override configuration value */ + configuration_set_string(settings, settings->paths.directory_video_filter, + libretro_video_filter_directory); + } else if (string_is_equal(settings->paths.directory_video_filter, "default")) *settings->paths.directory_video_filter = '\0'; if (string_is_equal(settings->paths.directory_audio_filter, "default")) *settings->paths.directory_audio_filter = '\0'; if (string_is_equal(settings->paths.directory_core_assets, "default")) *settings->paths.directory_core_assets = '\0'; - if (string_is_equal(settings->paths.directory_assets, "default")) + libretro_assets_directory = getenv("LIBRETRO_ASSETS_DIRECTORY"); + if (libretro_assets_directory) { /* override configuration value */ + configuration_set_string(settings, + settings->paths.directory_assets, libretro_assets_directory); + } else if (string_is_equal(settings->paths.directory_assets, "default")) *settings->paths.directory_assets = '\0'; #ifdef _3DS if (string_is_equal(settings->paths.directory_bottom_assets, "default")) diff --git a/docs/retroarch.6 b/docs/retroarch.6 index 7478040e176a..bc1ac8dfff78 100644 --- a/docs/retroarch.6 +++ b/docs/retroarch.6 @@ -1,6 +1,6 @@ .\" retroarch.6: -.TH "RETROARCH" "6" "November 1, 2011" "RETROARCH" "System Manager's Manual: retroarch" +.TH "RETROARCH" "6" "January 16, 2025" "RETROARCH" "System Manager's Manual: retroarch" .SH NAME @@ -239,3 +239,42 @@ Disables all kinds of content patching. .TP \fB-D, --detach\fR Detach from the current console. This is currently only relevant for Microsoft Windows. + +.SH ENVIRONMENT +\fBretroarch\fR honors the following environment variables: + +.TP +\fBLIBRETRO_DIRECTORY\fR +Specify the directory where RetroArch looks for core and info files, +overriding the value of the "libretro_directory" configuration file +option. + +.TP +\fBLIBRETRO_ASSETS_DIRECTORY\fR +Specify the directory where RetroArch looks for assets, overriding +the value of the "assets_directory" configuration file +option. + +.TP +\fBLIBRETRO_AUTOCONFIG_DIRECTORY\fR +Specify the directory where RetroArch looks for controller +auto-configuration files, overriding the value of the +"joypad_autoconfig_dir" configuration file option. + +.TP +\fBLIBRETRO_SYSTEM_DIRECTORY\fR +Specify the directory where RetroArch looks for system files, +overriding the value of the "system_directory" configuration file +option. + +.TP +\fBLIBRETRO_VIDEO_FILTER_DIRECTORY\fR +Specify the directory where RetroArch looks for video filters, +overriding the value of the "video_filter_dir" configuration file +option. + +.TP +\fBLIBRETRO_VIDEO_SHADER_DIRECTORY\fR +Specify the directory where RetroArch looks for video shaders, +overriding the value of the "video_shader_dir" configuration file +option. diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c index 9cd870655e0e..447a2f246dff 100644 --- a/frontend/drivers/platform_unix.c +++ b/frontend/drivers/platform_unix.c @@ -1323,6 +1323,11 @@ static void frontend_unix_get_env(int *argc, { unsigned i; const char* libretro_directory = getenv("LIBRETRO_DIRECTORY"); + const char* libretro_assets_directory = getenv("LIBRETRO_ASSETS_DIRECTORY"); + const char* libretro_autoconfig_directory = getenv("LIBRETRO_AUTOCONFIG_DIRECTORY"); + const char* libretro_system_directory = getenv("LIBRETRO_SYSTEM_DIRECTORY"); + const char* libretro_video_filter_directory = getenv("LIBRETRO_VIDEO_FILTER_DIRECTORY"); + const char* libretro_video_shader_directory = getenv("LIBRETRO_VIDEO_SHADER_DIRECTORY"); #ifdef ANDROID int32_t major, minor, rel; char device_model[PROP_VALUE_MAX] = {0}; @@ -1764,12 +1769,20 @@ static void frontend_unix_get_env(int *argc, "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); else #endif - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], base_path, - "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + if (!string_is_empty(libretro_directory)) + strlcpy(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], libretro_directory, + sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + else + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], base_path, + "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); #endif - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], base_path, - "autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); - + if (!string_is_empty(libretro_autoconfig_directory)) + strlcpy(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], + libretro_autoconfig_directory, + sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); + else + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], base_path, + "autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); #ifdef ASSETS_DIR if (path_is_directory(ASSETS_DIR "/assets")) fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], @@ -1777,7 +1790,10 @@ static void frontend_unix_get_env(int *argc, "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); else #endif - if (path_is_directory("/usr/local/share/retroarch/assets")) + if (!string_is_empty(libretro_assets_directory)) + strlcpy(g_defaults.dirs[DEFAULT_DIR_ASSETS], libretro_assets_directory, + sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); + else if (path_is_directory("/usr/local/share/retroarch/assets")) fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], "/usr/local/share/retroarch", "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); @@ -1837,7 +1853,11 @@ static void frontend_unix_get_env(int *argc, "filters/video", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER])); else #endif - if (path_is_directory("/usr/local/share/retroarch/filters/video")) + if (!string_is_empty(libretro_video_filter_directory)) + strlcpy(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], + libretro_video_filter_directory, + sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER])); + else if (path_is_directory("/usr/local/share/retroarch/filters/video")) fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], "/usr/local/share/retroarch", "filters/video", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER])); @@ -1871,8 +1891,13 @@ static void frontend_unix_get_env(int *argc, "records", sizeof(g_defaults.dirs[DEFAULT_DIR_RECORD_OUTPUT])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], base_path, "database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE])); - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], base_path, - "shaders", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); + if (!string_is_empty(libretro_video_shader_directory)) + strlcpy(g_defaults.dirs[DEFAULT_DIR_SHADER], + libretro_video_shader_directory, + sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); + else + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], base_path, + "shaders", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], base_path, "cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], base_path, @@ -1891,8 +1916,13 @@ static void frontend_unix_get_env(int *argc, "saves", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], base_path, "states", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE])); - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], base_path, - "system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); + if (!string_is_empty(libretro_system_directory)) + strlcpy(g_defaults.dirs[DEFAULT_DIR_SYSTEM], + libretro_system_directory, + sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); + else + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], base_path, + "system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); #endif #ifndef IS_SALAMANDER diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index adb27b425cfd..4726df08d381 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -566,24 +566,39 @@ static void frontend_win32_env_get(int *argc, char *argv[], { const char *tmp_dir = getenv("TMP"); const char *libretro_directory = getenv("LIBRETRO_DIRECTORY"); + const char *libretro_assets_directory = getenv("LIBRETRO_ASSETS_DIRECTORY"); + const char* libretro_autoconfig_directory = getenv("LIBRETRO_AUTOCONFIG_DIRECTORY"); + const char* libretro_system_directory = getenv("LIBRETRO_SYSTEM_DIRECTORY"); + const char* libretro_video_filter_directory = getenv("LIBRETRO_VIDEO_FILTER_DIRECTORY"); + const char* libretro_video_shader_directory = getenv("LIBRETRO_VIDEO_SHADER_DIRECTORY"); if (!string_is_empty(tmp_dir)) fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_CACHE], tmp_dir, sizeof(g_defaults.dirs[DEFAULT_DIR_CACHE])); gfx_set_dwm(); - fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_ASSETS], - ":\\assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); + if (!string_is_empty(libretro_assets_directory)) + strlcpy(g_defaults.dirs[DEFAULT_DIR_ASSETS], libretro_assets_directory, + sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); + else + fill_pathname_expand_special( + g_defaults.dirs[DEFAULT_DIR_ASSETS], + ":\\assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER], ":\\filters\\audio", sizeof(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER])); - fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], - ":\\filters\\video", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER])); + if (!string_is_empty(libretro_video_filter_directory)) + strlcpy(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], + libretro_video_filter_directory, + sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER])); + else + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], + ":\\filters\\video", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER])); fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_CHEATS], ":\\cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS])); fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_DATABASE], ":\\database\\rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE])); fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], - ":\\playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); + ":\\playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST])); fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_RECORD_CONFIG], ":\\config\\record", sizeof(g_defaults.dirs[DEFAULT_DIR_RECORD_CONFIG])); fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_RECORD_OUTPUT], @@ -606,12 +621,26 @@ static void frontend_win32_env_get(int *argc, char *argv[], else fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_CORE], ":\\cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); - fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], - ":\\info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); - fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], - ":\\autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); - fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_SHADER], - ":\\shaders", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); + if (!string_is_empty(libretro_directory)) + strlcpy(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], libretro_directory, + sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + else + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], + ":\\info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + if (!string_is_empty(libretro_autoconfig_directory)) + strlcpy(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], + libretro_autoconfig_directory, + sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); + else + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], + ":\\autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); + if (!string_is_empty(libretro_video_filter_directory)) + strlcpy(g_defaults.dirs[DEFAULT_DIR_SHADER], + libretro_video_shader_directory, + sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); + else + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_SHADER], + ":\\shaders", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], ":\\downloads", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS])); fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], @@ -620,8 +649,13 @@ static void frontend_win32_env_get(int *argc, char *argv[], ":\\saves", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM])); fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], ":\\states", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE])); - fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_SYSTEM], - ":\\system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); + if (!string_is_empty(libretro_system_directory)) + strlcpy(g_defaults.dirs[DEFAULT_DIR_SYSTEM], + libretro_system_directory, + sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); + else + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_SYSTEM], + ":\\system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_LOGS], ":\\logs", sizeof(g_defaults.dirs[DEFAULT_DIR_LOGS])); From fce755127ce462cc6b4713399666cfa3a9ab5d6b Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Fri, 17 Jan 2025 20:06:25 +0100 Subject: [PATCH 41/49] Cleanups/style nits --- libretro-db/libretrodb.c | 9 +++++---- state_manager.c | 3 ++- tasks/task_save.c | 5 +++-- uwp/uwp_async.h | 3 +-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/libretro-db/libretrodb.c b/libretro-db/libretrodb.c index 13bb4e8b79ab..aabe1e8c4cc7 100644 --- a/libretro-db/libretrodb.c +++ b/libretro-db/libretrodb.c @@ -238,7 +238,8 @@ static int libretrodb_find_index(libretrodb_t *db, const char *index_name, "key_size", &idx->key_size, "next", &idx->next, "count", &idx->count, - NULL) < 0) { + NULL) < 0) + { printf("Invalid index header\n"); break; } @@ -309,13 +310,13 @@ int libretrodb_find_entry(libretrodb_t *db, const char *index_name, rv = binsearch(buff, key, idx.count, (ssize_t)idx.key_size, &offset); free(buff); - if (rv == 0) { + if (rv == 0) + { filestream_seek(db->fd, (ssize_t)offset, RETRO_VFS_SEEK_POSITION_START); rmsgpack_dom_read(db->fd, out); return 0; - } else { - return -1; } + return -1; } /** diff --git a/state_manager.c b/state_manager.c index 8b16fa8bc12c..2ac5d729e812 100644 --- a/state_manager.c +++ b/state_manager.c @@ -513,7 +513,8 @@ static void state_manager_push_do(state_manager_t *state) uint8_t *compressed; const uint8_t *oldb, *newb; size_t headpos, tailpos, remaining; - if (state->capacity < sizeof(size_t) + state->maxcompsize) { + if (state->capacity < sizeof(size_t) + state->maxcompsize) + { RARCH_ERR("State capacity insufficient\n"); return; } diff --git a/tasks/task_save.c b/tasks/task_save.c index 6ee35921f13f..8419b391f9a5 100644 --- a/tasks/task_save.c +++ b/tasks/task_save.c @@ -911,10 +911,11 @@ static bool content_load_rastate1(unsigned char* input, size_t len) input += CONTENT_ALIGN_SIZE(block_size); } - if (!seen_core) { + if (!seen_core) + { RARCH_LOG("[State] no core\n"); return false; - } + } #ifdef HAVE_CHEEVOS if (!seen_cheevos) diff --git a/uwp/uwp_async.h b/uwp/uwp_async.h index f4c6b7fc0acd..f85387ea522a 100644 --- a/uwp/uwp_async.h +++ b/uwp/uwp_async.h @@ -59,9 +59,8 @@ namespace Windows::UI::Core::CoreWindow^ corewindow = Windows::UI::Core::CoreWindow::GetForCurrentThread(); while (!finished) { - if (corewindow) { + if (corewindow) corewindow->Dispatcher->ProcessEvents(Windows::UI::Core::CoreProcessEventsOption::ProcessAllIfPresent); - } } if (exception != nullptr) From 8aa445dfe2d60be684c73c713217b1e38c1cca33 Mon Sep 17 00:00:00 2001 From: Eric Warmenhoven Date: Fri, 17 Jan 2025 15:45:01 -0500 Subject: [PATCH 42/49] tvos build fix (#17426) --- menu/cbs/menu_cbs_ok.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index be032c88c2c9..ed8f94a7f62a 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -6467,7 +6467,7 @@ static int action_ok_open_uwp_permission_settings(const char *path, static int action_ok_open_picker(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { -#ifdef IOS +#if TARGET_OS_IOS ios_show_file_sheet(); return 0; #elif defined(OSX) && defined(HAVE_APPLE_STORE) From 48d903e811519e9adac54f068c987034fc849a3d Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Fri, 17 Jan 2025 21:52:26 +0100 Subject: [PATCH 43/49] print_buf_lines - cast to unsigned to avoid warnings --- menu/menu_displaylist.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 8b3489593300..02d7d7f3ad4c 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -13301,7 +13301,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, case DISPLAYLIST_CORE_CONTENT: menu_entries_clear(info->list); #ifdef HAVE_NETWORKING - count = print_buf_lines(info->list, menu->core_buf, "", + count = (unsigned)print_buf_lines(info->list, menu->core_buf, "", menu->core_len, FILE_TYPE_DOWNLOAD_CORE_CONTENT, true); @@ -13334,7 +13334,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, strlcpy(menu->core_buf, con, menu->core_len); free(info_path_cpy); - if ((count = print_buf_lines( + if ((count = (unsigned)print_buf_lines( info->list, menu->core_buf, new_label, menu->core_len, FILE_TYPE_DOWNLOAD_URL, false)) == 0) @@ -13364,7 +13364,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, network_buildbot_assets_url, "cores", sizeof(new_label)); - if ((count = print_buf_lines(info->list, menu->core_buf, new_label, + if ((count = (unsigned)print_buf_lines(info->list, menu->core_buf, new_label, menu->core_len, FILE_TYPE_DOWNLOAD_URL, true)) == 0) menu_entries_append(info->list, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_ENTRIES_TO_DISPLAY), @@ -13381,7 +13381,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, case DISPLAYLIST_CORE_SYSTEM_FILES: menu_entries_clear(info->list); #ifdef HAVE_NETWORKING - count = print_buf_lines(info->list, menu->core_buf, "", + count = (unsigned)print_buf_lines(info->list, menu->core_buf, "", menu->core_len, FILE_TYPE_DOWNLOAD_CORE_SYSTEM_FILES, true); @@ -13485,7 +13485,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, case DISPLAYLIST_THUMBNAILS_UPDATER: menu_entries_clear(info->list); #ifdef HAVE_NETWORKING - count = print_buf_lines(info->list, menu->core_buf, "", + count = (unsigned)print_buf_lines(info->list, menu->core_buf, "", menu->core_len, FILE_TYPE_DOWNLOAD_THUMBNAIL_CONTENT, true); @@ -13523,7 +13523,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, case DISPLAYLIST_LAKKA: menu_entries_clear(info->list); #ifdef HAVE_NETWORKING - count = print_buf_lines(info->list, menu->core_buf, "", + count = (unsigned)print_buf_lines(info->list, menu->core_buf, "", menu->core_len, FILE_TYPE_DOWNLOAD_LAKKA, true); From 90d3e0be17e354ec8ca43c2b645c3827b131ff0d Mon Sep 17 00:00:00 2001 From: Kreijstal Date: Sat, 18 Jan 2025 01:00:09 +0100 Subject: [PATCH 44/49] Allowing compilation on msys2 (#17369) ## Description Before there was no clear way of running msys2, and even if there was, there is no guarantee of it working, well I fixed it, and added a CI, so that we can always know if it works. Furthermore I added 2 targets more: UCRT64 and CLANG64, yes, compilation with clang64 means we can also compile with clang for windows on arm :D, plus clang has better error messages overall, anyway. ## Related Issues #17367 ## Reviewers Anyone, it's my first PR here. --- .github/workflows/MSYS2.yml | 77 +++++++++++++++++++++++++++ Makefile.common | 28 ++++++++++ audio/common/mmdevice_common_inline.h | 4 -- 3 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/MSYS2.yml diff --git a/.github/workflows/MSYS2.yml b/.github/workflows/MSYS2.yml new file mode 100644 index 000000000000..3d0bb30415c3 --- /dev/null +++ b/.github/workflows/MSYS2.yml @@ -0,0 +1,77 @@ +name: CI Windows (MSYS2) + +on: + push: + pull_request: + repository_dispatch: + types: [run_build] + +permissions: + contents: read + +jobs: + msys2-build-test: + strategy: + fail-fast: false + matrix: + sys: [MINGW64, UCRT64,CLANG64] + runs-on: windows-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up MSYS2 + uses: msys2/setup-msys2@v2 + with: + msystem: ${{ matrix.sys }} + update: true + install: base-devel git + pacboy: >- + gettext:p + gobject-introspection:p + graphite2:p + p11-kit:p + qt6:p + qt6-3d:p + qt6-charts:p + qt6-datavis3d:p + qt6-imageformats:p + qt6-location:p + qt6-lottie:p + qt6-networkauth:p + qt6-quick3dphysics:p + qt6-quicktimeline:p + qt6-remoteobjects:p + qt6-scxml:p + qt6-sensors:p + qt6-serialbus:p + qt6-speech:p + qt6-tools:p + qt6-translations:p + qt6-virtualkeyboard:p + qt6-webchannel:p + qt6-websockets:p + x264:p + cc:p + + - name: Configure and build RetroArch + shell: msys2 {0} + run: | + echo "Building RetroArch in ${{ matrix.sys }} environment" + ./configure + make -j$(nproc) + + - name: Collect DLLs and binaries + shell: msys2 {0} + run: | + echo "Collecting DLLs and binaries" + mkdir -p dist + cp retroarch.exe dist/ + ldd retroarch.exe|grep $MINGW_PREFIX |awk '{print $3}'|xargs -I {} cp {} dist/ + + - name: Archive build artifacts + if: success() + uses: actions/upload-artifact@v4 + with: + name: retroarch-${{ matrix.sys }} + path: dist/ diff --git a/Makefile.common b/Makefile.common index 01bae782ee5a..aab24e27697f 100644 --- a/Makefile.common +++ b/Makefile.common @@ -2648,4 +2648,32 @@ ifeq ($(HAVE_ODROIDGO2), 1) gfx/drivers/oga_gfx.o endif +# Detect the operating system +UNAME := $(shell uname -s) + +# Check if the system is MSYS2 (MINGW64 or MINGW32) +ifneq ($(findstring MINGW,$(UNAME)),) +$(info Detected MSYS2 environment) + +NT_VERSION := $(shell \ + echo '#include ' > temp.c; \ + echo '#ifdef _WIN32_WINNT' >> temp.c; \ + echo '#define GET_MACRO_VALUE(x) #x' >> temp.c; \ + echo '#define EXPAND_MACRO_VALUE(x) GET_MACRO_VALUE(x)' >> temp.c; \ + echo '#pragma message("_WIN32_WINNT=" EXPAND_MACRO_VALUE(_WIN32_WINNT))' >> temp.c; \ + echo '#endif' >> temp.c; \ + $(CC) -c temp.c 2>&1 | sed -n 's/^.*_WIN32_WINNT=\(0x[0-9A-Fa-f]\+\).*/\1/p'; \ + rm -f temp.c temp.o) + +ifneq ($(NT_VERSION),) +ifeq ($(shell [ $$(( $(NT_VERSION) )) -gt $$(( 0x602 )) ] && echo true),true) +LIBS += -lxaudio2_9 +endif +else +$(warning Windows NT version macro (_WIN32_WINNT) is not defined.) +endif + + +endif + ################################## diff --git a/audio/common/mmdevice_common_inline.h b/audio/common/mmdevice_common_inline.h index 255fdf5c9d9d..4ac8176c8854 100644 --- a/audio/common/mmdevice_common_inline.h +++ b/audio/common/mmdevice_common_inline.h @@ -20,10 +20,6 @@ /* Fix for MSYS2 increasing _WIN32_WINNT to 0x0603*/ #if defined(__MINGW32__) || defined(__MINGW64__) -#ifdef _WIN32_WINNT -#undef _WIN32_WINNT -#endif -#define _WIN32_WINNT 0x0600 #define WIN32_LEAN_AND_MEAN #else typedef enum EDataFlow EDataFlow; From cf0ec85c3544901e83d0b31ad680d5d5e94ed155 Mon Sep 17 00:00:00 2001 From: github-actions Date: Sat, 18 Jan 2025 00:13:21 +0000 Subject: [PATCH 45/49] Fetch translations from Crowdin --- intl/msg_hash_fr.h | 10 ++++++++- intl/msg_hash_gl.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++ intl/msg_hash_it.h | 8 +++++++ intl/msg_hash_uk.h | 8 +++++++ intl/progress.h | 10 ++++----- 5 files changed, 82 insertions(+), 6 deletions(-) diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index b4abcbff6e4b..27d2c0687eee 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -7134,7 +7134,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_CHEEVOS_HARDCORE_MODE_ENABLE, - "Désactive les cheats, le rembobinage, le ralenti et le chargement des sauvegardes instantanées. Les succès gagnés en mode hardcore sont marquées de façon unique pour que vous puissiez montrer aux autres ce que vous avez accompli sans fonctionnalités d'assistance d'émulateur. La désactivation de ce paramètre lors de l'exécution redémarrera le jeu." + "Désactive les cheats, le rembobinage, le ralenti et le chargement des sauvegardes instantanées. Les succès gagnés en mode Hardcore sont marquées de façon unique pour que vous puissiez montrer aux autres ce que vous avez accompli sans fonctionnalités d'assistance d'émulateur. La désactivation de ce paramètre lors de l'exécution redémarrera le jeu." ) MSG_HASH( MENU_ENUM_LABEL_VALUE_CHEEVOS_LEADERBOARDS_ENABLE, @@ -14755,6 +14755,14 @@ MSG_HASH( MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT, "Un cheat a été activé. Succès en mode Hardcore désactivés pour la session en cours." ) +MSG_HASH( + MSG_CHEEVOS_HARDCORE_MODE_CHANGED_BY_HOST, + "Le mode Hardcore des succès a été modifié par l'hôte." + ) +MSG_HASH( + MSG_CHEEVOS_HARDCORE_MODE_REQUIRES_NEWER_HOST, + "L'hôte du jeu en réseau doit être mis à jour. Succès en mode Hardcore désactivés pour la session en cours." + ) MSG_HASH( MSG_CHEEVOS_MASTERED_GAME, "Maîtrisé %s" diff --git a/intl/msg_hash_gl.h b/intl/msg_hash_gl.h index ec07ecf76fd2..56212473b303 100644 --- a/intl/msg_hash_gl.h +++ b/intl/msg_hash_gl.h @@ -914,6 +914,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_V4L2_SUPPORT, "Compatibilidade con Video4Linux2" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_SSL_SUPPORT, + "Soporte SSL" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LIBUSB_SUPPORT, "Compatibilidade con libusb" @@ -1950,6 +1954,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_BLACK_FRAME_INSERTION, "Inserción de Black Frame" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_BLACK_FRAME_INSERTION, + "ADVERTENCIA: O destello rápido pode causar retención de imaxe en algunhas pantallas. Usa esta opción baixo a túa responsabilidade // Insire fotograma(s) en negro no medio dos fotogramas. Pode reducir notablemente o desenfoque de movemento emulando o funcionamento dunha pantalla de tubo á costa de perder brillo." + ) MSG_HASH( MENU_ENUM_LABEL_HELP_VIDEO_BLACK_FRAME_INSERTION, "Insire cadro(s) negros entre cadros para mellorar a claridade do movemento. Use só a opción designada para a súa frecuencia de actualización da pantalla actual. Non se debe usar con frecuencias de actualización que non sexan múltiplos de 60 Hz, como 144 Hz, 165 Hz, etc. Non combines con Intervalo de intercambio > 1, subfotogramas, Retraso de fotogramas ou Sincronización con frecuencia de fotogramas de contido exacto. Deixar o sistema VRR activado está ben, pero non esa configuración. Se[...]" @@ -2030,6 +2038,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_SUBFRAMES, "Subcadros de sombreadores" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_SHADER_SUBFRAMES, + "ADVERTENCIA: O destello rápido pode causar retención de imaxe en algunhas pantallas. Usa esta opción baixo a túa responsabilidade // Simula unha liña de exploración básica ó longo de varios subfotogramas dividindo a pantalla verticalmente e renderizando cada parte da pantalla segundo o número de subfotogramas." + ) MSG_HASH( MENU_ENUM_LABEL_HELP_VIDEO_SHADER_SUBFRAMES, "Insire cadro(s) de sombreado extra entre os fotogramas para os posibles efectos de sombreado que estean deseñados para executarse máis rápido que a taxa de contido. Use só a opción designada para a súa frecuencia de actualización da pantalla actual. Non debe usarse con frecuencias de actualización que non sexan múltiplos de 60 Hz, como 144 Hz, 165 Hz, etc. Non combine con Intervalo de intercambio > 1, BFI, Retraso de fotogramas ou Sincronización con frecuencia de fotogramas de contido [...]" @@ -2102,6 +2114,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SCAN_SUBFRAMES, "Simulación de liña de escaneo rodante" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_SCAN_SUBFRAMES, + "ADVERTENCIA: O destello rápido pode causar retención de imaxe en algunhas pantallas. Usa esta opción baixo a túa responsabilidade // Simula unha liña de exploración básica ó longo de varios subfotogramas dividindo a pantalla verticalmente e renderizando cada parte da pantalla segundo o número de subfotogramas." + ) MSG_HASH( MENU_ENUM_LABEL_HELP_VIDEO_SCAN_SUBFRAMES, "Simula unha liña de escaneo en rotación básica sobre varios subfotogramas dividindo a pantalla verticalmente cara arriba e representando cada parte da pantalla segundo cantos subfotogramas haxa desde a parte superior da pantalla cara abaixo." @@ -2513,6 +2529,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SCALE_INTEGER_AXIS, "Eixo de escala enteira" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_SCALE_INTEGER_AXIS, + "Cambia a escala da altura, ancho ou ambas. As fraccións aplícanse só ás fontes de alta resolución." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SCALE_INTEGER_SCALING, "Escalado de escala enteira" @@ -3207,6 +3227,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_MIXER_ACTION_VOLUME, "Axusta o volume do fluxo de audio." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_STREAM_STATE_NONE, + "Estado: N/D" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_STREAM_STATE_PLAYING_SEQUENTIAL, + "Estado: Reproducindo (en secuencia)" + ) /* Settings > Audio > Menu Sounds */ @@ -4479,6 +4507,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_CORE_INFO_SAVESTATE_BYPASS, "Omite as funcións de gardar estados da información do núcleo" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_CORE_INFO_SAVESTATE_BYPASS, + "Especifica se ignorar a información do núcleo respecto as capacidades de salvar estados, o que permite experimentar con funcionalidades relacionadas (adiantar execución, rebobinar, etc.)." + ) #ifndef HAVE_DYNAMIC MSG_HASH( MENU_ENUM_LABEL_VALUE_ALWAYS_RELOAD_CORE_ON_RUN_CONTENT, @@ -4719,6 +4751,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_SAVESTATE_AUTO_SAVE, "Estado de gardado automático" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_SAVESTATE_AUTO_SAVE, + "Gardar o estado automaticamente cando se pecha o contido. Este estado gardado se carga no arranque se \"Auto Cargar Estado\" está activado." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_SAVESTATE_AUTO_LOAD, "Estado de carga automática" @@ -5262,6 +5298,10 @@ MSG_HASH( MENU_ENUM_SUBLABEL_INPUT_OVERLAY_ABXY_DIAGONAL_SENSITIVITY, "Axusta o tamaño das zonas de superposición no rombo do botón da cara. Establécese ao 100 % para a simetría de 8 vías." ) +MSG_HASH( + MENU_ENUM_SUBLABEL_INPUT_OVERLAY_ANALOG_RECENTER_ZONE, + "A entrada do stick analóxico será relativa ao primeiro toque cando se prema dentro desta zona." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_OVERLAY, "Superposición" @@ -14595,6 +14635,14 @@ MSG_HASH( MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT, "Activouse un truco. Logros Modo Hardcore desactivado para a sesión actual." ) +MSG_HASH( + MSG_CHEEVOS_HARDCORE_MODE_CHANGED_BY_HOST, + "Modo Hardcore dos logros cambiado polo host." + ) +MSG_HASH( + MSG_CHEEVOS_HARDCORE_MODE_REQUIRES_NEWER_HOST, + "O host do Xogo en Rede tense que actualizar. Modo Hardcore dos logros desactivado para esta sesión." + ) MSG_HASH( MSG_CHEEVOS_MASTERED_GAME, "Dominou %s" @@ -15505,6 +15553,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_BOTTOM_FONT_ENABLE, "Activar fonte" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_BOTTOM_FONT_ENABLE, + "Mostrar a fonte do menú inferior. Cando se activa mostra descricións dos botóns na parte inferior da pantalla. Isto exclúe a data do estado gardado." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_BOTTOM_FONT_COLOR_RED, "Cor da fonte Vermello" diff --git a/intl/msg_hash_it.h b/intl/msg_hash_it.h index 5abe4c8e173a..ed4e5de034a5 100644 --- a/intl/msg_hash_it.h +++ b/intl/msg_hash_it.h @@ -14607,6 +14607,14 @@ MSG_HASH( MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT, "Un trucco è stato attivato. Trofei della modalità Hardcore disabilitati per la sessione attuale." ) +MSG_HASH( + MSG_CHEEVOS_HARDCORE_MODE_CHANGED_BY_HOST, + "Modalirà Obiettivi Hardcore cambiata dall'host." + ) +MSG_HASH( + MSG_CHEEVOS_HARDCORE_MODE_REQUIRES_NEWER_HOST, + "L'host Netplay deve essere aggiornato. La modalirà Obiettivi Hardcore disattivata per la sessione corrente." + ) MSG_HASH( MSG_CHEEVOS_MASTERED_GAME, "Padroneggiato %s" diff --git a/intl/msg_hash_uk.h b/intl/msg_hash_uk.h index f2e91997ff09..453a42d0fb74 100644 --- a/intl/msg_hash_uk.h +++ b/intl/msg_hash_uk.h @@ -14895,6 +14895,14 @@ MSG_HASH( MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT, "Читання було активовано. Досягнення Хардкорного режиму вимкнено для поточного сеансу." ) +MSG_HASH( + MSG_CHEEVOS_HARDCORE_MODE_CHANGED_BY_HOST, + "Досягнення складного режиму змінено хостом." + ) +MSG_HASH( + MSG_CHEEVOS_HARDCORE_MODE_REQUIRES_NEWER_HOST, + "Netplay хост необхідно оновити. Досягнення в хардкорному режимі вимкнуто для поточної сесії." + ) MSG_HASH( MSG_CHEEVOS_MASTERED_GAME, "Опанував %s" diff --git a/intl/progress.h b/intl/progress.h index 69c5f5fc454a..135859f6cedc 100644 --- a/intl/progress.h +++ b/intl/progress.h @@ -59,11 +59,11 @@ #define LANGUAGE_PROGRESS_FINNISH_APPROVED 46 /* French */ -#define LANGUAGE_PROGRESS_FRENCH_TRANSLATED 99 -#define LANGUAGE_PROGRESS_FRENCH_APPROVED 99 +#define LANGUAGE_PROGRESS_FRENCH_TRANSLATED 100 +#define LANGUAGE_PROGRESS_FRENCH_APPROVED 100 /* Galician */ -#define LANGUAGE_PROGRESS_GALICIAN_TRANSLATED 98 +#define LANGUAGE_PROGRESS_GALICIAN_TRANSLATED 99 #define LANGUAGE_PROGRESS_GALICIAN_APPROVED 0 /* Hebrew */ @@ -83,7 +83,7 @@ #define LANGUAGE_PROGRESS_INDONESIAN_APPROVED 0 /* Italian */ -#define LANGUAGE_PROGRESS_ITALIAN_TRANSLATED 99 +#define LANGUAGE_PROGRESS_ITALIAN_TRANSLATED 100 #define LANGUAGE_PROGRESS_ITALIAN_APPROVED 0 /* Japanese */ @@ -143,7 +143,7 @@ #define LANGUAGE_PROGRESS_TATAR_APPROVED 0 /* Ukrainian */ -#define LANGUAGE_PROGRESS_UKRAINIAN_TRANSLATED 99 +#define LANGUAGE_PROGRESS_UKRAINIAN_TRANSLATED 100 #define LANGUAGE_PROGRESS_UKRAINIAN_APPROVED 7 /* Valencian */ From 984d5915734481b0ddbe5d6e06456a23e03403b0 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Sat, 18 Jan 2025 01:48:16 +0100 Subject: [PATCH 46/49] Silence some warnings --- input/drivers/sdl_input.c | 2 +- input/input_driver.c | 14 +++++++------- libretro-common/memmap/memmap.c | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/input/drivers/sdl_input.c b/input/drivers/sdl_input.c index f98f3c12b591..a65a94855b1b 100644 --- a/input/drivers/sdl_input.c +++ b/input/drivers/sdl_input.c @@ -338,7 +338,7 @@ static void sdl_input_free(void *data) #endif sdl_input_t *sdl = (sdl_input_t*)data; - if (!data) + if (!sdl) return; /* Flush out all pending events. */ diff --git a/input/input_driver.c b/input/input_driver.c index f4a16934b498..b9607db26b8c 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -5958,9 +5958,9 @@ bool bsv_movie_handle_read_input_event(bsv_movie_t *movie, /* if movie is old, just read two bytes and hope for the best */ if (movie->version == 0) { - int read = intfstream_read(movie->file, val, 2); - *val = swap_if_big16(*val); - return read == 2; + int64_t read = intfstream_read(movie->file, val, 2); + *val = swap_if_big16(*val); + return (read == 2); } for (i = 0; i < movie->input_event_count; i++) { @@ -5986,6 +5986,7 @@ void bsv_movie_finish_rewind(input_driver_state_t *input_st) handle->first_rewind = !handle->did_rewind; handle->did_rewind = false; } + void bsv_movie_read_next_events(bsv_movie_t *handle) { input_driver_state_t *input_st = input_state_get_ptr(); @@ -6079,6 +6080,7 @@ void bsv_movie_read_next_events(bsv_movie_t *handle) } } } + void bsv_movie_next_frame(input_driver_state_t *input_st) { settings_t *settings = config_get_ptr(); @@ -6144,9 +6146,7 @@ void bsv_movie_next_frame(input_driver_state_t *input_st) } if (input_st->bsv_movie_state.flags & BSV_FLAG_MOVIE_PLAYBACK) - { bsv_movie_read_next_events(handle); - } handle->frame_pos[handle->frame_counter & handle->frame_mask] = intfstream_tell(handle->file); } @@ -6165,8 +6165,8 @@ bool replay_get_serialized_data(void* buffer) if (input_st->bsv_movie_state.flags & (BSV_FLAG_MOVIE_RECORDING | BSV_FLAG_MOVIE_PLAYBACK)) { - long file_end = intfstream_tell(handle->file); - long read_amt = 0; + int64_t file_end = intfstream_tell(handle->file); + int64_t read_amt = 0; long file_end_lil = swap_if_big32(file_end); uint8_t *file_end_bytes = (uint8_t *)(&file_end_lil); uint8_t *buf = buffer; diff --git a/libretro-common/memmap/memmap.c b/libretro-common/memmap/memmap.c index 89e45e0edae3..35d9d6db3fca 100644 --- a/libretro-common/memmap/memmap.c +++ b/libretro-common/memmap/memmap.c @@ -135,8 +135,8 @@ int mprotect(void *addr, size_t len, int prot) int memsync(void *start, void *end) { - size_t _len = (char*)end - (char*)start; #if defined(__MACH__) && defined(__arm__) + size_t _len = (char*)end - (char*)start; sys_dcache_flush(start, _len); sys_icache_invalidate(start, _len); return 0; @@ -144,6 +144,7 @@ int memsync(void *start, void *end) __clear_cache(start, end); return 0; #elif defined(HAVE_MMAN) + size_t _len = (char*)end - (char*)start; return msync(start, _len, MS_SYNC | MS_INVALIDATE #ifdef __QNX__ MS_CACHE_ONLY From aefadc04c729ee2cf0a6c4f8b314031a0ad34373 Mon Sep 17 00:00:00 2001 From: sonninnos <45124675+sonninnos@users.noreply.github.com> Date: Sat, 18 Jan 2025 03:19:01 +0200 Subject: [PATCH 47/49] Analog to Digital refactor (#17429) --- config.def.keybinds.h | 614 +++++++++++++++++++++--------------------- configuration.c | 3 - input/input_driver.c | 221 +++++++++------ input/input_driver.h | 2 - input/input_types.h | 2 - runloop.c | 92 ------- 6 files changed, 453 insertions(+), 481 deletions(-) diff --git a/config.def.keybinds.h b/config.def.keybinds.h index d86c8b6413ec..bbfbda2c5880 100644 --- a/config.def.keybinds.h +++ b/config.def.keybinds.h @@ -25,252 +25,252 @@ static const struct retro_keybind retro_keybinds_1[] = { #ifdef __QNX__ { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B, RETROK_k, RETRO_DEVICE_ID_JOYPAD_B, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, RETROK_i, RETRO_DEVICE_ID_JOYPAD_Y, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT, RETROK_v, RETRO_DEVICE_ID_JOYPAD_SELECT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START, RETROK_b, RETRO_DEVICE_ID_JOYPAD_START, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP, RETROK_e, RETRO_DEVICE_ID_JOYPAD_UP, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN, RETROK_s, RETRO_DEVICE_ID_JOYPAD_DOWN, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT, RETROK_w, RETRO_DEVICE_ID_JOYPAD_LEFT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT, RETROK_d, RETRO_DEVICE_ID_JOYPAD_RIGHT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A, RETROK_l, RETRO_DEVICE_ID_JOYPAD_A, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X, RETROK_o, RETRO_DEVICE_ID_JOYPAD_X, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L, RETROK_f, RETRO_DEVICE_ID_JOYPAD_L, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R, RETROK_j, RETRO_DEVICE_ID_JOYPAD_R, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2, RETROK_r, RETRO_DEVICE_ID_JOYPAD_L2, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2, RETROK_u, RETRO_DEVICE_ID_JOYPAD_R2, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3, RETROK_g, RETRO_DEVICE_ID_JOYPAD_L3, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3, RETROK_h, RETRO_DEVICE_ID_JOYPAD_R3, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS, RETROK_UNKNOWN, RARCH_ANALOG_LEFT_X_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS, RETROK_UNKNOWN, RARCH_ANALOG_LEFT_X_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS, RETROK_UNKNOWN, RARCH_ANALOG_LEFT_Y_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS, RETROK_UNKNOWN, RARCH_ANALOG_LEFT_Y_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS, RETROK_UNKNOWN, RARCH_ANALOG_RIGHT_X_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS, RETROK_UNKNOWN, RARCH_ANALOG_RIGHT_X_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, RETROK_UNKNOWN, RARCH_ANALOG_RIGHT_Y_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, RETROK_UNKNOWN, RARCH_ANALOG_RIGHT_Y_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, RETROK_UNKNOWN, RARCH_LIGHTGUN_TRIGGER, RETRO_DEVICE_ID_MOUSE_LEFT, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, RETROK_UNKNOWN, RARCH_LIGHTGUN_RELOAD, RETRO_DEVICE_ID_MOUSE_RIGHT, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, RETROK_UNKNOWN, RARCH_LIGHTGUN_AUX_A, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, RETROK_UNKNOWN, RARCH_LIGHTGUN_AUX_B, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, RETROK_UNKNOWN, RARCH_LIGHTGUN_AUX_C, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, RETROK_UNKNOWN, RARCH_LIGHTGUN_START, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, RETROK_UNKNOWN, RARCH_LIGHTGUN_SELECT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, RETROK_UNKNOWN, RARCH_LIGHTGUN_DPAD_UP, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, RETROK_UNKNOWN, RARCH_LIGHTGUN_DPAD_DOWN, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, RETROK_UNKNOWN, RARCH_LIGHTGUN_DPAD_LEFT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, RETROK_UNKNOWN, RARCH_LIGHTGUN_DPAD_RIGHT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, RETROK_UNKNOWN, RARCH_TURBO_ENABLE, NO_BTN, NO_BTN, 0, true @@ -278,371 +278,371 @@ static const struct retro_keybind retro_keybinds_1[] = { /* Hotkeys */ { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY, RETROK_UNKNOWN, RARCH_ENABLE_HOTKEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_MENU_TOGGLE, RETROK_SPACE, RARCH_MENU_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_QUIT_KEY, RETROK_UNKNOWN, RARCH_QUIT_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_CLOSE_CONTENT_KEY, RETROK_UNKNOWN, RARCH_CLOSE_CONTENT_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_RESET, RETROK_UNKNOWN, RARCH_RESET, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY, RETROK_UNKNOWN, RARCH_FAST_FORWARD_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_HOLD_KEY, RETROK_UNKNOWN, RARCH_FAST_FORWARD_HOLD_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION_KEY, RETROK_UNKNOWN, RARCH_SLOWMOTION_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION_HOLD_KEY, RETROK_UNKNOWN, RARCH_SLOWMOTION_HOLD_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_REWIND, RETROK_UNKNOWN, RARCH_REWIND, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_PAUSE_TOGGLE, RETROK_UNKNOWN, RARCH_PAUSE_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_FRAMEADVANCE, RETROK_UNKNOWN, RARCH_FRAMEADVANCE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE, RETROK_UNKNOWN, RARCH_MUTE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP, RETROK_UNKNOWN, RARCH_VOLUME_UP, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_DOWN, RETROK_UNKNOWN, RARCH_VOLUME_DOWN, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_LOAD_STATE_KEY, RETROK_UNKNOWN, RARCH_LOAD_STATE_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SAVE_STATE_KEY, RETROK_UNKNOWN, RARCH_SAVE_STATE_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_PLUS, RETROK_UNKNOWN, RARCH_STATE_SLOT_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_MINUS, RETROK_UNKNOWN, RARCH_STATE_SLOT_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_PLAY_REPLAY_KEY, RETROK_UNKNOWN, RARCH_PLAY_REPLAY_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_RECORD_REPLAY_KEY, RETROK_UNKNOWN, RARCH_RECORD_REPLAY_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_HALT_REPLAY_KEY, RETROK_UNKNOWN, RARCH_HALT_REPLAY_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_REPLAY_SLOT_PLUS, RETROK_UNKNOWN, RARCH_REPLAY_SLOT_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_REPLAY_SLOT_MINUS, RETROK_UNKNOWN, RARCH_REPLAY_SLOT_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_EJECT_TOGGLE, RETROK_UNKNOWN, RARCH_DISK_EJECT_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_NEXT, RETROK_UNKNOWN, RARCH_DISK_NEXT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_PREV, RETROK_UNKNOWN, RARCH_DISK_PREV, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_TOGGLE, RETROK_UNKNOWN, RARCH_SHADER_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_NEXT, RETROK_UNKNOWN, RARCH_SHADER_NEXT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_PREV, RETROK_UNKNOWN, RARCH_SHADER_PREV, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_TOGGLE, RETROK_UNKNOWN, RARCH_CHEAT_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_PLUS, RETROK_UNKNOWN, RARCH_CHEAT_INDEX_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_MINUS, RETROK_UNKNOWN, RARCH_CHEAT_INDEX_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT, RETROK_UNKNOWN, RARCH_SCREENSHOT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_RECORDING_TOGGLE, RETROK_UNKNOWN, RARCH_RECORDING_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_STREAMING_TOGGLE, RETROK_UNKNOWN, RARCH_STREAMING_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_GRAB_MOUSE_TOGGLE, RETROK_UNKNOWN, RARCH_GRAB_MOUSE_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_GAME_FOCUS_TOGGLE, RETROK_UNKNOWN, RARCH_GAME_FOCUS_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY, RETROK_UNKNOWN, RARCH_FULLSCREEN_TOGGLE_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_UI_COMPANION_TOGGLE, RETROK_UNKNOWN, RARCH_UI_COMPANION_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_VRR_RUNLOOP_TOGGLE, RETROK_UNKNOWN, RARCH_VRR_RUNLOOP_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_RUNAHEAD_TOGGLE, RETROK_UNKNOWN, RARCH_RUNAHEAD_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_PREEMPT_TOGGLE, RETROK_UNKNOWN, RARCH_PREEMPT_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE, RETROK_UNKNOWN, RARCH_FPS_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_STATISTICS_TOGGLE, RETROK_UNKNOWN, RARCH_STATISTICS_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_AI_SERVICE, RETROK_UNKNOWN, RARCH_AI_SERVICE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_PING_TOGGLE, RETROK_UNKNOWN, RARCH_NETPLAY_PING_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_HOST_TOGGLE, RETROK_UNKNOWN, RARCH_NETPLAY_HOST_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH, RETROK_UNKNOWN, RARCH_NETPLAY_GAME_WATCH, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_PLAYER_CHAT, RETROK_UNKNOWN, RARCH_NETPLAY_PLAYER_CHAT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_FADE_CHAT_TOGGLE, RETROK_UNKNOWN, RARCH_NETPLAY_FADE_CHAT_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_OVERLAY_NEXT, RETROK_UNKNOWN, RARCH_OVERLAY_NEXT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK, RETROK_UNKNOWN, RARCH_OSK, NO_BTN, NO_BTN, 0, true @@ -651,7 +651,7 @@ static const struct retro_keybind retro_keybinds_1[] = { /* Deprecated */ { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SEND_DEBUG_INFO, RETROK_UNKNOWN, RARCH_SEND_DEBUG_INFO, NO_BTN, NO_BTN, 0, true @@ -660,252 +660,252 @@ static const struct retro_keybind retro_keybinds_1[] = { #elif defined(DINGUX) { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B, RETROK_LALT, RETRO_DEVICE_ID_JOYPAD_B, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, RETROK_LSHIFT, RETRO_DEVICE_ID_JOYPAD_Y, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT, RETROK_ESCAPE, RETRO_DEVICE_ID_JOYPAD_SELECT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START, RETROK_RETURN, RETRO_DEVICE_ID_JOYPAD_START, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP, RETROK_UP, RETRO_DEVICE_ID_JOYPAD_UP, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN, RETROK_DOWN, RETRO_DEVICE_ID_JOYPAD_DOWN, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT, RETROK_LEFT, RETRO_DEVICE_ID_JOYPAD_LEFT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT, RETROK_RIGHT, RETRO_DEVICE_ID_JOYPAD_RIGHT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A, RETROK_LCTRL, RETRO_DEVICE_ID_JOYPAD_A, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X, RETROK_SPACE, RETRO_DEVICE_ID_JOYPAD_X, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L, RETROK_TAB, RETRO_DEVICE_ID_JOYPAD_L, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R, RETROK_BACKSPACE, RETRO_DEVICE_ID_JOYPAD_R, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2, RETROK_PAGEUP, RETRO_DEVICE_ID_JOYPAD_L2, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2, RETROK_PAGEDOWN, RETRO_DEVICE_ID_JOYPAD_R2, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3, RETROK_KP_DIVIDE, RETRO_DEVICE_ID_JOYPAD_L3, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3, RETROK_KP_PERIOD, RETRO_DEVICE_ID_JOYPAD_R3, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS, RETROK_UNKNOWN, RARCH_ANALOG_LEFT_X_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS, RETROK_UNKNOWN, RARCH_ANALOG_LEFT_X_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS, RETROK_UNKNOWN, RARCH_ANALOG_LEFT_Y_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS, RETROK_UNKNOWN, RARCH_ANALOG_LEFT_Y_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS, RETROK_UNKNOWN, RARCH_ANALOG_RIGHT_X_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS, RETROK_UNKNOWN, RARCH_ANALOG_RIGHT_X_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, RETROK_UNKNOWN, RARCH_ANALOG_RIGHT_Y_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, RETROK_UNKNOWN, RARCH_ANALOG_RIGHT_Y_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, RETROK_UNKNOWN, RARCH_LIGHTGUN_TRIGGER, RETRO_DEVICE_ID_MOUSE_LEFT, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, RETROK_UNKNOWN, RARCH_LIGHTGUN_RELOAD, RETRO_DEVICE_ID_MOUSE_RIGHT, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, RETROK_UNKNOWN, RARCH_LIGHTGUN_AUX_A, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, RETROK_UNKNOWN, RARCH_LIGHTGUN_AUX_B, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, RETROK_UNKNOWN, RARCH_LIGHTGUN_AUX_C, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, RETROK_UNKNOWN, RARCH_LIGHTGUN_START, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, RETROK_UNKNOWN, RARCH_LIGHTGUN_SELECT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, RETROK_UNKNOWN, RARCH_LIGHTGUN_DPAD_UP, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, RETROK_UNKNOWN, RARCH_LIGHTGUN_DPAD_DOWN, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, RETROK_UNKNOWN, RARCH_LIGHTGUN_DPAD_LEFT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, RETROK_UNKNOWN, RARCH_LIGHTGUN_DPAD_RIGHT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, RETROK_UNKNOWN, RARCH_TURBO_ENABLE, NO_BTN, NO_BTN, 0, true @@ -913,371 +913,371 @@ static const struct retro_keybind retro_keybinds_1[] = { /* Hotkeys */ { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY, RETROK_UNKNOWN, RARCH_ENABLE_HOTKEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_MENU_TOGGLE, RETROK_HOME, RARCH_MENU_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_QUIT_KEY, RETROK_UNKNOWN, RARCH_QUIT_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_CLOSE_CONTENT_KEY, RETROK_UNKNOWN, RARCH_CLOSE_CONTENT_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_RESET, RETROK_UNKNOWN, RARCH_RESET, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY, RETROK_UNKNOWN, RARCH_FAST_FORWARD_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_HOLD_KEY, RETROK_UNKNOWN, RARCH_FAST_FORWARD_HOLD_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION_KEY, RETROK_UNKNOWN, RARCH_SLOWMOTION_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION_HOLD_KEY, RETROK_UNKNOWN, RARCH_SLOWMOTION_HOLD_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_REWIND, RETROK_UNKNOWN, RARCH_REWIND, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_PAUSE_TOGGLE, RETROK_UNKNOWN, RARCH_PAUSE_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_FRAMEADVANCE, RETROK_UNKNOWN, RARCH_FRAMEADVANCE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE, RETROK_UNKNOWN, RARCH_MUTE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP, RETROK_UNKNOWN, RARCH_VOLUME_UP, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_DOWN, RETROK_UNKNOWN, RARCH_VOLUME_DOWN, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_LOAD_STATE_KEY, RETROK_UNKNOWN, RARCH_LOAD_STATE_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SAVE_STATE_KEY, RETROK_UNKNOWN, RARCH_SAVE_STATE_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_PLUS, RETROK_UNKNOWN, RARCH_STATE_SLOT_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_MINUS, RETROK_UNKNOWN, RARCH_STATE_SLOT_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_PLAY_REPLAY_KEY, RETROK_UNKNOWN, RARCH_PLAY_REPLAY_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_RECORD_REPLAY_KEY, RETROK_UNKNOWN, RARCH_RECORD_REPLAY_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_HALT_REPLAY_KEY, RETROK_UNKNOWN, RARCH_HALT_REPLAY_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_REPLAY_SLOT_PLUS, RETROK_UNKNOWN, RARCH_REPLAY_SLOT_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_REPLAY_SLOT_MINUS, RETROK_UNKNOWN, RARCH_REPLAY_SLOT_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_EJECT_TOGGLE, RETROK_UNKNOWN, RARCH_DISK_EJECT_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_NEXT, RETROK_UNKNOWN, RARCH_DISK_NEXT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_PREV, RETROK_UNKNOWN, RARCH_DISK_PREV, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_TOGGLE, RETROK_UNKNOWN, RARCH_SHADER_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_NEXT, RETROK_UNKNOWN, RARCH_SHADER_NEXT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_PREV, RETROK_UNKNOWN, RARCH_SHADER_PREV, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_TOGGLE, RETROK_UNKNOWN, RARCH_CHEAT_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_PLUS, RETROK_UNKNOWN, RARCH_CHEAT_INDEX_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_MINUS, RETROK_UNKNOWN, RARCH_CHEAT_INDEX_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT, RETROK_UNKNOWN, RARCH_SCREENSHOT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_RECORDING_TOGGLE, RETROK_UNKNOWN, RARCH_RECORDING_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_STREAMING_TOGGLE, RETROK_UNKNOWN, RARCH_STREAMING_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_GRAB_MOUSE_TOGGLE, RETROK_UNKNOWN, RARCH_GRAB_MOUSE_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_GAME_FOCUS_TOGGLE, RETROK_UNKNOWN, RARCH_GAME_FOCUS_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY, RETROK_UNKNOWN, RARCH_FULLSCREEN_TOGGLE_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_UI_COMPANION_TOGGLE, RETROK_UNKNOWN, RARCH_UI_COMPANION_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_VRR_RUNLOOP_TOGGLE, RETROK_UNKNOWN, RARCH_VRR_RUNLOOP_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_RUNAHEAD_TOGGLE, RETROK_UNKNOWN, RARCH_RUNAHEAD_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_PREEMPT_TOGGLE, RETROK_UNKNOWN, RARCH_PREEMPT_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE, RETROK_UNKNOWN, RARCH_FPS_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_STATISTICS_TOGGLE, RETROK_UNKNOWN, RARCH_STATISTICS_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_AI_SERVICE, RETROK_UNKNOWN, RARCH_AI_SERVICE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_PING_TOGGLE, RETROK_UNKNOWN, RARCH_NETPLAY_PING_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_HOST_TOGGLE, RETROK_UNKNOWN, RARCH_NETPLAY_HOST_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH, RETROK_UNKNOWN, RARCH_NETPLAY_GAME_WATCH, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_PLAYER_CHAT, RETROK_UNKNOWN, RARCH_NETPLAY_PLAYER_CHAT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_FADE_CHAT_TOGGLE, RETROK_UNKNOWN, RARCH_NETPLAY_FADE_CHAT_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_OVERLAY_NEXT, RETROK_UNKNOWN, RARCH_OVERLAY_NEXT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK, RETROK_UNKNOWN, RARCH_OSK, NO_BTN, NO_BTN, 0, true @@ -1286,7 +1286,7 @@ static const struct retro_keybind retro_keybinds_1[] = { /* Deprecated */ { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SEND_DEBUG_INFO, RETROK_UNKNOWN, RARCH_SEND_DEBUG_INFO, NO_BTN, NO_BTN, 0, true @@ -1295,252 +1295,252 @@ static const struct retro_keybind retro_keybinds_1[] = { #else { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B, RETROK_z, RETRO_DEVICE_ID_JOYPAD_B, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, RETROK_a, RETRO_DEVICE_ID_JOYPAD_Y, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT, RETROK_RSHIFT, RETRO_DEVICE_ID_JOYPAD_SELECT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START, RETROK_RETURN, RETRO_DEVICE_ID_JOYPAD_START, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP, RETROK_UP, RETRO_DEVICE_ID_JOYPAD_UP, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN, RETROK_DOWN, RETRO_DEVICE_ID_JOYPAD_DOWN, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT, RETROK_LEFT, RETRO_DEVICE_ID_JOYPAD_LEFT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT, RETROK_RIGHT, RETRO_DEVICE_ID_JOYPAD_RIGHT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A, RETROK_x, RETRO_DEVICE_ID_JOYPAD_A, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X, RETROK_s, RETRO_DEVICE_ID_JOYPAD_X, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L, RETROK_q, RETRO_DEVICE_ID_JOYPAD_L, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R, RETROK_w, RETRO_DEVICE_ID_JOYPAD_R, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2, RETROK_UNKNOWN, RETRO_DEVICE_ID_JOYPAD_L2, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2, RETROK_UNKNOWN, RETRO_DEVICE_ID_JOYPAD_R2, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3, RETROK_UNKNOWN, RETRO_DEVICE_ID_JOYPAD_L3, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3, RETROK_UNKNOWN, RETRO_DEVICE_ID_JOYPAD_R3, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS, RETROK_UNKNOWN, RARCH_ANALOG_LEFT_X_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS, RETROK_UNKNOWN, RARCH_ANALOG_LEFT_X_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS, RETROK_UNKNOWN, RARCH_ANALOG_LEFT_Y_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS, RETROK_UNKNOWN, RARCH_ANALOG_LEFT_Y_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS, RETROK_UNKNOWN, RARCH_ANALOG_RIGHT_X_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS, RETROK_UNKNOWN, RARCH_ANALOG_RIGHT_X_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, RETROK_UNKNOWN, RARCH_ANALOG_RIGHT_Y_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, RETROK_UNKNOWN, RARCH_ANALOG_RIGHT_Y_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, RETROK_UNKNOWN, RARCH_LIGHTGUN_TRIGGER, RETRO_DEVICE_ID_MOUSE_LEFT, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, RETROK_UNKNOWN, RARCH_LIGHTGUN_RELOAD, RETRO_DEVICE_ID_MOUSE_RIGHT, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, RETROK_UNKNOWN, RARCH_LIGHTGUN_AUX_A, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, RETROK_UNKNOWN, RARCH_LIGHTGUN_AUX_B, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, RETROK_UNKNOWN, RARCH_LIGHTGUN_AUX_C, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, RETROK_UNKNOWN, RARCH_LIGHTGUN_START, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, RETROK_UNKNOWN, RARCH_LIGHTGUN_SELECT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, RETROK_UNKNOWN, RARCH_LIGHTGUN_DPAD_UP, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, RETROK_UNKNOWN, RARCH_LIGHTGUN_DPAD_DOWN, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, RETROK_UNKNOWN, RARCH_LIGHTGUN_DPAD_LEFT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, RETROK_UNKNOWN, RARCH_LIGHTGUN_DPAD_RIGHT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, RETROK_UNKNOWN, RARCH_TURBO_ENABLE, NO_BTN, NO_BTN, 0, true @@ -1548,14 +1548,14 @@ static const struct retro_keybind retro_keybinds_1[] = { /* Hotkeys */ { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY, RETROK_UNKNOWN, RARCH_ENABLE_HOTKEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_MENU_TOGGLE, RETROK_F1, RARCH_MENU_TOGGLE, NO_BTN, NO_BTN, 0, true @@ -1563,7 +1563,7 @@ static const struct retro_keybind retro_keybinds_1[] = { #ifdef HAVE_LAKKA { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_RESTART_KEY, RETROK_ESCAPE, RARCH_QUIT_KEY, NO_BTN, NO_BTN, 0, true @@ -1571,7 +1571,7 @@ static const struct retro_keybind retro_keybinds_1[] = { #else { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_QUIT_KEY, RETROK_ESCAPE, RARCH_QUIT_KEY, NO_BTN, NO_BTN, 0, true @@ -1579,350 +1579,350 @@ static const struct retro_keybind retro_keybinds_1[] = { #endif { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_CLOSE_CONTENT_KEY, RETROK_UNKNOWN, RARCH_CLOSE_CONTENT_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_RESET, RETROK_h, RARCH_RESET, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY, RETROK_SPACE, RARCH_FAST_FORWARD_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_HOLD_KEY, RETROK_l, RARCH_FAST_FORWARD_HOLD_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION_KEY, RETROK_UNKNOWN, RARCH_SLOWMOTION_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION_HOLD_KEY, RETROK_e, RARCH_SLOWMOTION_HOLD_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_REWIND, RETROK_r, RARCH_REWIND, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_PAUSE_TOGGLE, RETROK_p, RARCH_PAUSE_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_FRAMEADVANCE, RETROK_k, RARCH_FRAMEADVANCE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE, RETROK_F9, RARCH_MUTE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP, RETROK_KP_PLUS, RARCH_VOLUME_UP, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_DOWN, RETROK_KP_MINUS, RARCH_VOLUME_DOWN, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_LOAD_STATE_KEY, RETROK_F4, RARCH_LOAD_STATE_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SAVE_STATE_KEY, RETROK_F2, RARCH_SAVE_STATE_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_PLUS, RETROK_F7, RARCH_STATE_SLOT_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_MINUS, RETROK_F6, RARCH_STATE_SLOT_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_PLAY_REPLAY_KEY, RETROK_UNKNOWN, RARCH_PLAY_REPLAY_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_RECORD_REPLAY_KEY, RETROK_UNKNOWN, RARCH_RECORD_REPLAY_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_HALT_REPLAY_KEY, RETROK_UNKNOWN, RARCH_HALT_REPLAY_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_REPLAY_SLOT_PLUS, RETROK_UNKNOWN, RARCH_REPLAY_SLOT_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_REPLAY_SLOT_MINUS, RETROK_UNKNOWN, RARCH_REPLAY_SLOT_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_EJECT_TOGGLE, RETROK_UNKNOWN, RARCH_DISK_EJECT_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_NEXT, RETROK_UNKNOWN, RARCH_DISK_NEXT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_PREV, RETROK_UNKNOWN, RARCH_DISK_PREV, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_TOGGLE, RETROK_COMMA, RARCH_SHADER_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_NEXT, RETROK_m, RARCH_SHADER_NEXT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_PREV, RETROK_n, RARCH_SHADER_PREV, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_TOGGLE, RETROK_u, RARCH_CHEAT_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_PLUS, RETROK_y, RARCH_CHEAT_INDEX_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_MINUS, RETROK_t, RARCH_CHEAT_INDEX_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT, RETROK_F8, RARCH_SCREENSHOT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_RECORDING_TOGGLE, RETROK_UNKNOWN, RARCH_RECORDING_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_STREAMING_TOGGLE, RETROK_UNKNOWN, RARCH_STREAMING_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_GRAB_MOUSE_TOGGLE, RETROK_F11, RARCH_GRAB_MOUSE_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_GAME_FOCUS_TOGGLE, RETROK_SCROLLOCK, RARCH_GAME_FOCUS_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY, RETROK_f, RARCH_FULLSCREEN_TOGGLE_KEY, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_UI_COMPANION_TOGGLE, RETROK_F5, RARCH_UI_COMPANION_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_VRR_RUNLOOP_TOGGLE, RETROK_UNKNOWN, RARCH_VRR_RUNLOOP_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_RUNAHEAD_TOGGLE, RETROK_UNKNOWN, RARCH_RUNAHEAD_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_PREEMPT_TOGGLE, RETROK_UNKNOWN, RARCH_PREEMPT_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE, RETROK_F3, RARCH_FPS_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_STATISTICS_TOGGLE, RETROK_UNKNOWN, RARCH_STATISTICS_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_AI_SERVICE, RETROK_UNKNOWN, RARCH_AI_SERVICE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_PING_TOGGLE, RETROK_UNKNOWN, RARCH_NETPLAY_PING_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_HOST_TOGGLE, RETROK_UNKNOWN, RARCH_NETPLAY_HOST_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH, RETROK_i, RARCH_NETPLAY_GAME_WATCH, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_PLAYER_CHAT, RETROK_BACKQUOTE, RARCH_NETPLAY_PLAYER_CHAT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_FADE_CHAT_TOGGLE, RETROK_UNKNOWN, RARCH_NETPLAY_FADE_CHAT_TOGGLE, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_OVERLAY_NEXT, RETROK_UNKNOWN, RARCH_OVERLAY_NEXT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK, RETROK_UNKNOWN, RARCH_OSK, NO_BTN, NO_BTN, 0, true @@ -1931,7 +1931,7 @@ static const struct retro_keybind retro_keybinds_1[] = { /* Deprecated */ { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_META_SEND_DEBUG_INFO, RETROK_UNKNOWN, RARCH_SEND_DEBUG_INFO, NO_BTN, NO_BTN, 0, true @@ -1944,252 +1944,252 @@ static const struct retro_keybind retro_keybinds_1[] = { static const struct retro_keybind retro_keybinds_rest[] = { { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B, RETROK_UNKNOWN, RETRO_DEVICE_ID_JOYPAD_B, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, RETROK_UNKNOWN, RETRO_DEVICE_ID_JOYPAD_Y, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT, RETROK_UNKNOWN, RETRO_DEVICE_ID_JOYPAD_SELECT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START, RETROK_UNKNOWN, RETRO_DEVICE_ID_JOYPAD_START, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP, RETROK_UNKNOWN, RETRO_DEVICE_ID_JOYPAD_UP, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN, RETROK_UNKNOWN, RETRO_DEVICE_ID_JOYPAD_DOWN, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT, RETROK_UNKNOWN, RETRO_DEVICE_ID_JOYPAD_LEFT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT, RETROK_UNKNOWN, RETRO_DEVICE_ID_JOYPAD_RIGHT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A, RETROK_UNKNOWN, RETRO_DEVICE_ID_JOYPAD_A, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X, RETROK_UNKNOWN, RETRO_DEVICE_ID_JOYPAD_X, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L, RETROK_UNKNOWN, RETRO_DEVICE_ID_JOYPAD_L, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R, RETROK_UNKNOWN, RETRO_DEVICE_ID_JOYPAD_R, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2, RETROK_UNKNOWN, RETRO_DEVICE_ID_JOYPAD_L2, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2, RETROK_UNKNOWN, RETRO_DEVICE_ID_JOYPAD_R2, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3, RETROK_UNKNOWN, RETRO_DEVICE_ID_JOYPAD_L3, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3, RETROK_UNKNOWN, RETRO_DEVICE_ID_JOYPAD_R3, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS, RETROK_UNKNOWN, RARCH_ANALOG_LEFT_X_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS, RETROK_UNKNOWN, RARCH_ANALOG_LEFT_X_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS, RETROK_UNKNOWN, RARCH_ANALOG_LEFT_Y_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS, RETROK_UNKNOWN, RARCH_ANALOG_LEFT_Y_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS, RETROK_UNKNOWN, RARCH_ANALOG_RIGHT_X_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS, RETROK_UNKNOWN, RARCH_ANALOG_RIGHT_X_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, RETROK_UNKNOWN, RARCH_ANALOG_RIGHT_Y_PLUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, RETROK_UNKNOWN, RARCH_ANALOG_RIGHT_Y_MINUS, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, RETROK_UNKNOWN, RARCH_LIGHTGUN_TRIGGER, RETRO_DEVICE_ID_MOUSE_LEFT, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, RETROK_UNKNOWN, RARCH_LIGHTGUN_RELOAD, RETRO_DEVICE_ID_MOUSE_RIGHT, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, RETROK_UNKNOWN, RARCH_LIGHTGUN_AUX_A, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, RETROK_UNKNOWN, RARCH_LIGHTGUN_AUX_B, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, RETROK_UNKNOWN, RARCH_LIGHTGUN_AUX_C, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, RETROK_UNKNOWN, RARCH_LIGHTGUN_START, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, RETROK_UNKNOWN, RARCH_LIGHTGUN_SELECT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, RETROK_UNKNOWN, RARCH_LIGHTGUN_DPAD_UP, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, RETROK_UNKNOWN, RARCH_LIGHTGUN_DPAD_DOWN, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, RETROK_UNKNOWN, RARCH_LIGHTGUN_DPAD_LEFT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, RETROK_UNKNOWN, RARCH_LIGHTGUN_DPAD_RIGHT, NO_BTN, NO_BTN, 0, true }, { NULL, NULL, - AXIS_NONE, AXIS_NONE, AXIS_NONE, + AXIS_NONE, AXIS_NONE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, RETROK_UNKNOWN, RARCH_TURBO_ENABLE, NO_BTN, NO_BTN, 0, true diff --git a/configuration.c b/configuration.c index 301290e2f5b2..19e4ec730a0d 100644 --- a/configuration.c +++ b/configuration.c @@ -6496,9 +6496,6 @@ void input_config_parse_joy_axis( else bind->joyaxis = AXIS_NEG(i_axis); } - - /* Ensure that D-pad emulation doesn't screw this over. */ - bind->orig_joyaxis = bind->joyaxis; } fill_pathname_join_delim(key, s, diff --git a/input/input_driver.c b/input/input_driver.c index b9607db26b8c..6f1761676d78 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -1022,6 +1022,39 @@ static int16_t input_joypad_analog_axis( if (!bind_y_minus->valid || !bind_y_plus->valid) return 0; + /* Keyboard bind priority */ + if ( bind_plus->key != RETROK_UNKNOWN + || bind_minus->key != RETROK_UNKNOWN) + { + input_driver_state_t *input_st = &input_driver_st; + + if (bind_plus->key && input_state_wrap( + input_st->current_driver, + input_st->current_data, + input_st->primary_joypad, + NULL, + joypad_info, + (*input_st->libretro_input_binds), + (input_st->flags & INP_FLAG_KB_MAPPING_BLOCKED) ? true : false, + 0, RETRO_DEVICE_KEYBOARD, 0, + bind_plus->key)) + res = 0x7fff; + if (bind_minus->key && input_state_wrap( + input_st->current_driver, + input_st->current_data, + input_st->primary_joypad, + NULL, + joypad_info, + (*input_st->libretro_input_binds), + (input_st->flags & INP_FLAG_KB_MAPPING_BLOCKED) ? true : false, + 0, RETRO_DEVICE_KEYBOARD, 0, + bind_minus->key)) + res += -0x7fff; + + if (res) + return res; + } + { uint32_t axis_minus = (bind_minus->joyaxis == AXIS_NONE) ? joypad_info->auto_binds[ident_minus].joyaxis @@ -1796,17 +1829,18 @@ static int16_t input_state_internal( unsigned idx, unsigned id) { rarch_joypad_info_t joypad_info; - unsigned mapped_port; float input_analog_deadzone = settings->floats.input_analog_deadzone; float input_analog_sensitivity = settings->floats.input_analog_sensitivity; - unsigned *input_remap_port_map = settings->uints.input_remap_port_map[port]; - bool input_driver_analog_requested = input_st->analog_requested[port]; const input_device_driver_t *joypad = input_st->primary_joypad; #ifdef HAVE_MFI const input_device_driver_t *sec_joypad = input_st->secondary_joypad; #else const input_device_driver_t *sec_joypad = NULL; #endif + unsigned *input_remap_port_map = settings->uints.input_remap_port_map[port]; + uint8_t max_users = settings->uints.input_max_users; + uint8_t mapped_port = 0; + int16_t result = 0; #ifdef HAVE_MENU struct menu_state *menu_st = menu_state_get_ptr(); bool input_blocked = (menu_st->input_driver_flushing_input > 0) @@ -1814,9 +1848,8 @@ static int16_t input_state_internal( #else bool input_blocked = (input_st->flags & INP_FLAG_BLOCK_LIBRETRO_INPUT) ? true : false; #endif + bool input_driver_analog_requested = input_st->analog_requested[port]; bool bitmask_enabled = false; - unsigned max_users = settings->uints.input_max_users; - int16_t result = 0; device &= RETRO_DEVICE_MASK; bitmask_enabled = (device == RETRO_DEVICE_JOYPAD) @@ -1827,12 +1860,12 @@ static int16_t input_state_internal( * 'virtual' port index */ while ((mapped_port = *(input_remap_port_map++)) < MAX_USERS) { - int32_t ret = 0; - int32_t port_result = 0; - unsigned input_analog_dpad_mode = settings->uints.input_analog_dpad_mode[mapped_port]; + int16_t ret = 0; + int16_t port_result = 0; + uint8_t input_analog_dpad_mode = settings->uints.input_analog_dpad_mode[mapped_port]; - joypad_info.joy_idx = settings->uints.input_joypad_index[mapped_port]; - joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx]; + joypad_info.joy_idx = settings->uints.input_joypad_index[mapped_port]; + joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx]; /* Skip disabled input devices */ if (mapped_port >= max_users) @@ -1871,8 +1904,13 @@ static int16_t input_state_internal( (input_st->flags & INP_FLAG_KB_MAPPING_BLOCKED) ? true : false, mapped_port, device, idx, id); - if ( (device == RETRO_DEVICE_ANALOG) - && (ret == 0)) + /* Ignore analog sticks when using Analog to Digital */ + if ( (device == RETRO_DEVICE_ANALOG) + && (input_analog_dpad_mode != ANALOG_DPAD_NONE)) + ret = 0; + + if ( (device == RETRO_DEVICE_ANALOG) + && (ret == 0)) { if (input_st->libretro_input_binds[mapped_port]) { @@ -1942,7 +1980,7 @@ static int16_t input_state_internal( if (bitmask_enabled) { - unsigned i; + uint8_t i; for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) if (input_state_device(input_st, settings, handle, @@ -1955,6 +1993,69 @@ static int16_t input_state_internal( settings, handle, input_analog_dpad_mode, ret, mapped_port, device, idx, id, false); + + /* Handle Analog to Digital */ + if ( (device == RETRO_DEVICE_JOYPAD) + && (input_analog_dpad_mode != ANALOG_DPAD_NONE) + && (bitmask_enabled || (id >= RETRO_DEVICE_ID_JOYPAD_UP && id <= RETRO_DEVICE_ID_JOYPAD_RIGHT))) + { + int16_t ret_axis; + uint8_t s; + uint8_t a; + + for (s = RETRO_DEVICE_INDEX_ANALOG_LEFT; s <= RETRO_DEVICE_INDEX_ANALOG_RIGHT; s++) + { + if ( (s == RETRO_DEVICE_INDEX_ANALOG_LEFT && input_analog_dpad_mode != ANALOG_DPAD_LSTICK) + || (s == RETRO_DEVICE_INDEX_ANALOG_RIGHT && input_analog_dpad_mode != ANALOG_DPAD_RSTICK)) + continue; + + for (a = RETRO_DEVICE_ID_ANALOG_X; a <= RETRO_DEVICE_ID_ANALOG_Y; a++) + { + ret_axis = input_joypad_analog_axis( + ANALOG_DPAD_NONE, + settings->floats.input_analog_deadzone, + settings->floats.input_analog_sensitivity, + joypad, + &joypad_info, + s, + a, + (*input_st->libretro_input_binds[mapped_port])); + + if (ret_axis) + { + if (a == RETRO_DEVICE_ID_ANALOG_Y && (float)ret_axis / 0x7fff < -joypad_info.axis_threshold) + { + if (bitmask_enabled) + port_result |= (1 << RETRO_DEVICE_ID_JOYPAD_UP); + else if (id == RETRO_DEVICE_ID_JOYPAD_UP) + port_result = RETRO_DEVICE_ID_JOYPAD_UP; + } + else if (a == RETRO_DEVICE_ID_ANALOG_Y && (float)ret_axis / 0x7fff > joypad_info.axis_threshold) + { + if (bitmask_enabled) + port_result |= (1 << RETRO_DEVICE_ID_JOYPAD_DOWN); + else if (id == RETRO_DEVICE_ID_JOYPAD_DOWN) + port_result = RETRO_DEVICE_ID_JOYPAD_DOWN; + } + + if (a == RETRO_DEVICE_ID_ANALOG_X && (float)ret_axis / 0x7fff < -joypad_info.axis_threshold) + { + if (bitmask_enabled) + port_result |= (1 << RETRO_DEVICE_ID_JOYPAD_LEFT); + else if (id == RETRO_DEVICE_ID_JOYPAD_LEFT) + port_result = RETRO_DEVICE_ID_JOYPAD_LEFT; + } + else if (a == RETRO_DEVICE_ID_ANALOG_X && (float)ret_axis / 0x7fff > joypad_info.axis_threshold) + { + if (bitmask_enabled) + port_result |= (1 << RETRO_DEVICE_ID_JOYPAD_RIGHT); + else if (id == RETRO_DEVICE_ID_JOYPAD_RIGHT) + port_result = RETRO_DEVICE_ID_JOYPAD_RIGHT; + } + } + } + } + } } /* Digital values are represented by a bitmap; @@ -7038,9 +7139,8 @@ void input_remapping_set_defaults(bool clear_cache) void input_driver_collect_system_input(input_driver_state_t *input_st, settings_t *settings, input_bits_t *current_bits) { - int port; rarch_joypad_info_t joypad_info; - unsigned block_delay = settings->uints.input_hotkey_block_delay; + input_driver_t *current_input = input_st->current_driver; const input_device_driver_t *joypad = input_st->primary_joypad; #ifdef HAVE_MFI const input_device_driver_t @@ -7049,16 +7149,17 @@ void input_driver_collect_system_input(input_driver_state_t *input_st, const input_device_driver_t *sec_joypad = NULL; #endif + unsigned block_delay = settings->uints.input_hotkey_block_delay; + uint8_t max_users = settings->uints.input_max_users; + uint8_t port = 0; #ifdef HAVE_MENU + bool all_users_control_menu = settings->bools.input_all_users_control_menu; bool display_kb = menu_input_dialog_get_display_kb(); bool menu_is_alive = (menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE) ? true : false; bool menu_input_active = menu_is_alive && !(settings->bools.menu_unified_controls && !display_kb); #endif - input_driver_t *current_input = input_st->current_driver; - unsigned max_users = settings->uints.input_max_users; - bool all_users_control_menu = settings->bools.input_all_users_control_menu; joypad_info.axis_threshold = settings->floats.input_axis_threshold; /* Gather input from each (enabled) joypad */ @@ -7066,68 +7167,47 @@ void input_driver_collect_system_input(input_driver_state_t *input_st, { const struct retro_keybind *binds_norm = &input_config_binds[port][RARCH_ENABLE_HOTKEY]; const struct retro_keybind *binds_auto = &input_autoconf_binds[port][RARCH_ENABLE_HOTKEY]; - struct retro_keybind *auto_binds = input_autoconf_binds[port]; - struct retro_keybind *general_binds = input_config_binds[port]; + joypad_info.joy_idx = settings->uints.input_joypad_index[port]; joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx]; #ifdef HAVE_MENU if (menu_is_alive) { - int k; - int s; - - /* Remember original analog D-pad binds. */ - for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) - { - (auto_binds)[k].orig_joyaxis = (auto_binds)[k].joyaxis; - (general_binds)[k].orig_joyaxis = (general_binds)[k].joyaxis; - } + int16_t ret; + uint8_t s; + uint8_t a; /* Read input from analog sticks according to settings. */ for (s = RETRO_DEVICE_INDEX_ANALOG_LEFT; s <= RETRO_DEVICE_INDEX_ANALOG_RIGHT; s++) { - unsigned x_plus = RARCH_ANALOG_LEFT_X_PLUS; - unsigned y_plus = RARCH_ANALOG_LEFT_Y_PLUS; - unsigned x_minus = RARCH_ANALOG_LEFT_X_MINUS; - unsigned y_minus = RARCH_ANALOG_LEFT_Y_MINUS; - - if ((settings->bools.menu_disable_left_analog && s == RETRO_DEVICE_INDEX_ANALOG_LEFT ) || - (settings->bools.menu_disable_right_analog && s == RETRO_DEVICE_INDEX_ANALOG_RIGHT)) - continue; - if (s == RETRO_DEVICE_INDEX_ANALOG_RIGHT) - { - x_plus = RARCH_ANALOG_RIGHT_X_PLUS; - y_plus = RARCH_ANALOG_RIGHT_Y_PLUS; - x_minus = RARCH_ANALOG_RIGHT_X_MINUS; - y_minus = RARCH_ANALOG_RIGHT_Y_MINUS; - } + if ( (settings->bools.menu_disable_left_analog && s == RETRO_DEVICE_INDEX_ANALOG_LEFT) + || (settings->bools.menu_disable_right_analog && s == RETRO_DEVICE_INDEX_ANALOG_RIGHT)) + continue; - if (!INHERIT_JOYAXIS(auto_binds)) + for (a = RETRO_DEVICE_ID_ANALOG_X; a <= RETRO_DEVICE_ID_ANALOG_Y; a++) { - unsigned j = x_plus + 3; - /* Inherit joyaxis from analogs. */ - for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) - { - if ((auto_binds)[j].joyaxis != AXIS_NONE && - ((float)abs(joypad->axis(port, (uint32_t)(auto_binds)[j].joyaxis)) - / 0x8000) > joypad_info.axis_threshold) - (auto_binds)[k].joyaxis = (auto_binds)[j].joyaxis; - j--; - } - } + ret = input_joypad_analog_axis( + ANALOG_DPAD_NONE, + settings->floats.input_analog_deadzone, + settings->floats.input_analog_sensitivity, + joypad, + &joypad_info, + s, + a, + (*input_st->libretro_input_binds[port])); - if (!INHERIT_JOYAXIS(general_binds)) - { - unsigned j = x_plus + 3; - /* Inherit joyaxis from analogs. */ - for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) + if (ret) { - if ((general_binds)[j].joyaxis != AXIS_NONE && - ((float)abs(joypad->axis(port, (uint32_t)(general_binds)[j].joyaxis)) - / 0x8000) > joypad_info.axis_threshold) - (general_binds)[k].joyaxis = (general_binds)[j].joyaxis; - j--; + if (a == RETRO_DEVICE_ID_ANALOG_Y && (float)ret / 0x7fff < -joypad_info.axis_threshold) + BIT256_SET_PTR(current_bits, RETRO_DEVICE_ID_JOYPAD_UP); + else if (a == RETRO_DEVICE_ID_ANALOG_Y && (float)ret / 0x7fff > joypad_info.axis_threshold) + BIT256_SET_PTR(current_bits, RETRO_DEVICE_ID_JOYPAD_DOWN); + + if (a == RETRO_DEVICE_ID_ANALOG_X && (float)ret / 0x7fff < -joypad_info.axis_threshold) + BIT256_SET_PTR(current_bits, RETRO_DEVICE_ID_JOYPAD_LEFT); + else if (a == RETRO_DEVICE_ID_ANALOG_X && (float)ret / 0x7fff > joypad_info.axis_threshold) + BIT256_SET_PTR(current_bits, RETRO_DEVICE_ID_JOYPAD_RIGHT); } } } @@ -7153,15 +7233,6 @@ void input_driver_collect_system_input(input_driver_state_t *input_st, #ifdef HAVE_MENU if (menu_is_alive) { - int k; - - /* Restore analog D-pad binds temporarily overridden. */ - for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) - { - (auto_binds)[k].joyaxis = (auto_binds)[k].orig_joyaxis; - (general_binds)[k].joyaxis = (general_binds)[k].orig_joyaxis; - } - if (!all_users_control_menu) break; } diff --git a/input/input_driver.h b/input/input_driver.h index 09174b9219eb..ba4242a62571 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -100,8 +100,6 @@ #define MAPPER_SET_KEY(state, key) (state)->keys[(key) / 32] |= 1 << ((key) % 32) #define MAPPER_UNSET_KEY(state, key) (state)->keys[(key) / 32] &= ~(1 << ((key) % 32)) -#define INHERIT_JOYAXIS(binds) (((binds)[x_plus].joyaxis == (binds)[x_minus].joyaxis) || ( (binds)[y_plus].joyaxis == (binds)[y_minus].joyaxis)) - #define REPLAY_TOKEN_INVALID '\0' #define REPLAY_TOKEN_REGULAR_FRAME 'f' #define REPLAY_TOKEN_CHECKPOINT_FRAME 'c' diff --git a/input/input_types.h b/input/input_types.h index 301d6d684258..094559ecf000 100644 --- a/input/input_types.h +++ b/input/input_types.h @@ -75,8 +75,6 @@ struct retro_keybind uint32_t joyaxis; /* Default joy axis binding value for resetting bind to default. */ uint32_t def_joyaxis; - /* Used by input_{push,pop}_analog_dpad(). */ - uint32_t orig_joyaxis; enum msg_hash_enums enum_idx; diff --git a/runloop.c b/runloop.c index 1d5339c34e79..e93ef4f10a7b 100644 --- a/runloop.c +++ b/runloop.c @@ -6819,8 +6819,6 @@ static enum runloop_state_enum runloop_check_state( **/ int runloop_iterate(void) { - int i; - enum analog_dpad_mode dpad_mode[MAX_USERS]; input_driver_state_t *input_st = input_state_get_ptr(); audio_driver_state_t *audio_st = audio_state_get_ptr(); video_driver_state_t *video_st = video_state_get_ptr(); @@ -7015,77 +7013,6 @@ int runloop_iterate(void) camera_st->driver->poll(camera_st->data, camera_st->cb.frame_raw_framebuffer, camera_st->cb.frame_opengl_texture); - - /* Update binds for analog dpad modes. */ - for (i = 0; i < (int)max_users; i++) - { - dpad_mode[i] = (enum analog_dpad_mode) - settings->uints.input_analog_dpad_mode[i]; - - switch (dpad_mode[i]) - { - case ANALOG_DPAD_LSTICK: - case ANALOG_DPAD_RSTICK: - { - unsigned mapped_port = settings->uints.input_remap_ports[i]; - if (input_st->analog_requested[mapped_port]) - dpad_mode[i] = ANALOG_DPAD_NONE; - } - break; - case ANALOG_DPAD_LSTICK_FORCED: - dpad_mode[i] = ANALOG_DPAD_LSTICK; - break; - case ANALOG_DPAD_RSTICK_FORCED: - dpad_mode[i] = ANALOG_DPAD_RSTICK; - break; - default: - break; - } - - /* Push analog to D-Pad mappings to binds. */ - if (dpad_mode[i] != ANALOG_DPAD_NONE) - { - unsigned k; - unsigned joy_idx = settings->uints.input_joypad_index[i]; - struct retro_keybind *general_binds = input_config_binds[joy_idx]; - struct retro_keybind *auto_binds = input_autoconf_binds[joy_idx]; - unsigned x_plus = RARCH_ANALOG_RIGHT_X_PLUS; - unsigned y_plus = RARCH_ANALOG_RIGHT_Y_PLUS; - unsigned x_minus = RARCH_ANALOG_RIGHT_X_MINUS; - unsigned y_minus = RARCH_ANALOG_RIGHT_Y_MINUS; - - if (dpad_mode[i] == ANALOG_DPAD_LSTICK) - { - x_plus = RARCH_ANALOG_LEFT_X_PLUS; - y_plus = RARCH_ANALOG_LEFT_Y_PLUS; - x_minus = RARCH_ANALOG_LEFT_X_MINUS; - y_minus = RARCH_ANALOG_LEFT_Y_MINUS; - } - - for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) - { - (auto_binds)[k].orig_joyaxis = (auto_binds)[k].joyaxis; - (general_binds)[k].orig_joyaxis = (general_binds)[k].joyaxis; - } - - if (!INHERIT_JOYAXIS(auto_binds)) - { - unsigned j = x_plus + 3; - /* Inherit joyaxis from analogs. */ - for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) - (auto_binds)[k].joyaxis = (auto_binds)[j--].joyaxis; - } - - if (!INHERIT_JOYAXIS(general_binds)) - { - unsigned j = x_plus + 3; - /* Inherit joyaxis from analogs. */ - for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) - (general_binds)[k].joyaxis = (general_binds)[j--].joyaxis; - } - } - } - /* Measure the time between core_run() and video_driver_frame() */ runloop_st->core_run_time = cpu_features_get_time_usec(); @@ -7134,25 +7061,6 @@ int runloop_iterate(void) #ifdef HAVE_PRESENCE presence_update(PRESENCE_GAME); #endif - - /* Restores analog D-pad binds temporarily overridden. */ - for (i = 0; i < (int)max_users; i++) - { - if (dpad_mode[i] != ANALOG_DPAD_NONE) - { - int j; - unsigned joy_idx = settings->uints.input_joypad_index[i]; - struct retro_keybind *general_binds = input_config_binds[joy_idx]; - struct retro_keybind *auto_binds = input_autoconf_binds[joy_idx]; - - for (j = RETRO_DEVICE_ID_JOYPAD_UP; j <= RETRO_DEVICE_ID_JOYPAD_RIGHT; j++) - { - (auto_binds)[j].joyaxis = (auto_binds)[j].orig_joyaxis; - (general_binds)[j].joyaxis = (general_binds)[j].orig_joyaxis; - } - } - } - #ifdef HAVE_BSV_MOVIE bsv_movie_finish_rewind(input_st); if (input_st->bsv_movie_state.flags & BSV_FLAG_MOVIE_END) From 9bff7168e8ed379891722e5900438a07575389bf Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Sat, 18 Jan 2025 03:11:24 +0100 Subject: [PATCH 48/49] (input_driver.c) Style nits --- input/input_driver.c | 323 +++++++++++++++++++------------------------ 1 file changed, 144 insertions(+), 179 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index 6f1761676d78..398d181c62e4 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -523,10 +523,8 @@ bool input_driver_set_sensor( port, action, rate); } else if (input_driver_st.primary_joypad && input_driver_st.primary_joypad->set_sensor_state) - { return input_driver_st.primary_joypad->set_sensor_state(NULL, port, action, rate); - } return false; } @@ -545,10 +543,8 @@ float input_driver_get_sensor( } else if (sensors_enable && input_driver_st.primary_joypad && input_driver_st.primary_joypad->get_sensor_input) - { return input_driver_st.primary_joypad->get_sensor_input(NULL, port, id); - } } return 0.0f; @@ -647,10 +643,10 @@ static bool input_driver_button_combo_hold( bool input_driver_pointer_is_offscreen(int16_t x, int16_t y) { const int edge_detect = 32700; - if ((x >= -edge_detect) && - (y >= -edge_detect) && - (x <= edge_detect) && - (y <= edge_detect)) + if ( (x >= -edge_detect) + && (y >= -edge_detect) + && (x <= edge_detect) + && (y <= edge_detect)) return false; return true; } @@ -769,7 +765,7 @@ static int32_t input_state_wrap( unsigned idx, unsigned id) { - int32_t ret = 0; + int32_t ret = 0; if (!binds) return 0; @@ -781,11 +777,9 @@ static int32_t input_state_wrap( if (id == RETRO_DEVICE_ID_JOYPAD_MASK) { if (joypad) - ret |= joypad->state( - joypad_info, binds[_port], _port); + ret |= joypad->state(joypad_info, binds[_port], _port); if (sec_joypad) - ret |= sec_joypad->state( - joypad_info, binds[_port], _port); + ret |= sec_joypad->state(joypad_info, binds[_port], _port); } else { @@ -857,7 +851,7 @@ static int16_t input_joypad_axis( const input_device_driver_t *drv, unsigned port, uint32_t joyaxis, float normal_mag) { - int16_t val = (joyaxis != AXIS_NONE) ? drv->axis(port, joyaxis) : 0; + int16_t val = (joyaxis != AXIS_NONE) ? drv->axis(port, joyaxis) : 0; if (input_analog_deadzone) { @@ -878,14 +872,11 @@ static int16_t input_joypad_axis( if (input_analog_sensitivity != 1.0f) { float normalized = (1.0f / 0x7fff) * val; - int new_val = 0x7fff * normalized * - input_analog_sensitivity; - + int new_val = 0x7fff * normalized * input_analog_sensitivity; if (new_val > 0x7fff) return 0x7fff; else if (new_val < -0x7fff) return -0x7fff; - return new_val; } @@ -919,9 +910,9 @@ static int16_t input_joypad_analog_button( unsigned ident, const struct retro_keybind *bind) { - int16_t res = 0; - float normal_mag = 0.0f; - uint32_t axis = (bind->joyaxis == AXIS_NONE) + int16_t res = 0; + float normal_mag = 0.0f; + uint32_t axis = (bind->joyaxis == AXIS_NONE) ? joypad_info->auto_binds[ident].joyaxis : bind->joyaxis; @@ -998,8 +989,8 @@ static int16_t input_joypad_analog_axis( input_conv_analog_id_to_bind_id(idx, ident, ident_minus, ident_plus); - bind_minus = &binds[ident_minus]; - bind_plus = &binds[ident_plus]; + bind_minus = &binds[ident_minus]; + bind_plus = &binds[ident_plus]; if (!bind_minus->valid || !bind_plus->valid) return 0; @@ -1134,8 +1125,7 @@ void input_keyboard_line_append( const char *word, size_t len) { size_t i; - char *newbuf = (char*)realloc( - keyboard_line->buffer, + char *newbuf = (char*)realloc(keyboard_line->buffer, keyboard_line->size + len * 2); if (!newbuf) @@ -1195,34 +1185,34 @@ const char **input_keyboard_start_line( } #ifdef HAVE_OVERLAY -static int16_t input_overlay_device_mouse_state(input_overlay_t *ol, unsigned id) +static int16_t input_overlay_device_mouse_state( + input_overlay_t *ol, unsigned id) { - input_overlay_pointer_state_t *ptr_st = &ol->pointer_state; int16_t res; + input_overlay_pointer_state_t *ptr_st = &ol->pointer_state; switch(id) { case RETRO_DEVICE_ID_MOUSE_X: ptr_st->device_mask |= (1 << RETRO_DEVICE_MOUSE); - - res = ptr_st->mouse.scale_x + res = (ptr_st->mouse.scale_x) * (ptr_st->screen_x - ptr_st->mouse.prev_screen_x); ptr_st->mouse.prev_screen_x = ptr_st->screen_x; return res; case RETRO_DEVICE_ID_MOUSE_Y: - res = ptr_st->mouse.scale_y + res = (ptr_st->mouse.scale_y) * (ptr_st->screen_y - ptr_st->mouse.prev_screen_y); ptr_st->mouse.prev_screen_y = ptr_st->screen_y; return res; case RETRO_DEVICE_ID_MOUSE_LEFT: - return (ptr_st->mouse.click & 0x1) || - (ptr_st->mouse.hold & 0x1); + return (ptr_st->mouse.click & 0x1) + || (ptr_st->mouse.hold & 0x1); case RETRO_DEVICE_ID_MOUSE_RIGHT: - return (ptr_st->mouse.click & 0x2) || - (ptr_st->mouse.hold & 0x2); + return (ptr_st->mouse.click & 0x2) + || (ptr_st->mouse.hold & 0x2); case RETRO_DEVICE_ID_MOUSE_MIDDLE: - return (ptr_st->mouse.click & 0x4) || - (ptr_st->mouse.hold & 0x4); + return (ptr_st->mouse.click & 0x4) + || (ptr_st->mouse.hold & 0x4); default: break; } @@ -1285,7 +1275,7 @@ static int16_t input_overlay_pointer_state(input_overlay_t *ol, input_overlay_pointer_state_t *ptr_st, unsigned idx, unsigned id) { - ptr_st->device_mask |= (1 << RETRO_DEVICE_POINTER); + ptr_st->device_mask |= (1 << RETRO_DEVICE_POINTER); switch (id) { @@ -1504,8 +1494,9 @@ static int16_t input_state_device( * > 'id' is not equal to remapped button index * If these conditions are met, input here * is ignored */ - if ((menu_driver_alive || !input_remap_binds_enable) || - (id == remap_button)) + if ( (menu_driver_alive + || !input_remap_binds_enable) + || (id == remap_button)) res |= 1; } #endif @@ -5714,15 +5705,13 @@ static void input_keys_pressed( if (!libretro_input_pressed) { - bool keyboard_menu_pressed = false; - /* Ignore keyboard menu toggle button and check * joypad menu toggle button for pressing * it without 'enable_hotkey', because Guide button * is not part of the usual buttons. */ i = RARCH_MENU_TOGGLE; - keyboard_menu_pressed = binds[port][i].valid + if (!(binds[port][i].valid && input_state_wrap( input_st->current_driver, input_st->current_data, @@ -5732,9 +5721,7 @@ static void input_keys_pressed( binds, (input_st->flags & INP_FLAG_KB_MAPPING_BLOCKED) ? true : false, port, RETRO_DEVICE_KEYBOARD, 0, - input_config_binds[port][i].key); - - if (!keyboard_menu_pressed) + input_config_binds[port][i].key))) { bool bit_pressed = binds[port][i].valid && input_state_wrap( @@ -5922,7 +5909,8 @@ static void input_keys_pressed( /* Forward declaration */ void bsv_movie_free(bsv_movie_t*); -void bsv_movie_enqueue(input_driver_state_t *input_st, bsv_movie_t * state, enum bsv_flags flags) +void bsv_movie_enqueue(input_driver_state_t *input_st, + bsv_movie_t * state, enum bsv_flags flags) { if (input_st->bsv_movie_state_next_handle) bsv_movie_free(input_st->bsv_movie_state_next_handle); @@ -5949,7 +5937,8 @@ void bsv_movie_frame_rewind(void) { input_driver_state_t *input_st = &input_driver_st; bsv_movie_t *handle = input_st->bsv_movie_state_handle; - bool recording = (input_st->bsv_movie_state.flags & BSV_FLAG_MOVIE_RECORDING) ? true : false; + bool recording = (input_st->bsv_movie_state.flags + & BSV_FLAG_MOVIE_RECORDING) ? true : false; if (!handle) return; @@ -5991,7 +5980,12 @@ void bsv_movie_frame_rewind(void) { /* We rewound past the beginning. */ - if (!handle->playback) + if (handle->playback) + { + intfstream_seek(handle->file, (int)handle->min_file_pos, SEEK_SET); + bsv_movie_read_next_events(handle); + } + else { retro_ctx_serialize_info_t serial_info; @@ -6008,25 +6002,9 @@ void bsv_movie_frame_rewind(void) intfstream_write(handle->file, handle->state, handle->state_size); } - else - { - intfstream_seek(handle->file, (int)handle->min_file_pos, SEEK_SET); - bsv_movie_read_next_events(handle); - } } } -/* Zero out key events when playing back or recording */ -static void bsv_movie_handle_clear_key_events(bsv_movie_t *movie) -{ - movie->key_event_count = 0; -} -/* Zero out input events when playing back or recording */ -static void bsv_movie_handle_clear_input_events(bsv_movie_t *movie) -{ - movie->input_event_count = 0; -} - void bsv_movie_handle_push_key_event(bsv_movie_t *movie, uint8_t down, uint16_t mod, uint32_t code, uint32_t character) { @@ -6039,8 +6017,9 @@ void bsv_movie_handle_push_key_event(bsv_movie_t *movie, movie->key_events[movie->key_event_count] = data; movie->key_event_count++; } + void bsv_movie_handle_push_input_event(bsv_movie_t *movie, - uint8_t port, uint8_t dev, uint8_t idx, uint16_t id, int16_t val) + uint8_t port, uint8_t dev, uint8_t idx, uint16_t id, int16_t val) { bsv_input_data_t data; data.port = port; @@ -6052,8 +6031,9 @@ void bsv_movie_handle_push_input_event(bsv_movie_t *movie, movie->input_events[movie->input_event_count] = data; movie->input_event_count++; } + bool bsv_movie_handle_read_input_event(bsv_movie_t *movie, - uint8_t port, uint8_t dev, uint8_t idx, uint16_t id, int16_t* val) + uint8_t port, uint8_t dev, uint8_t idx, uint16_t id, int16_t* val) { int i; /* if movie is old, just read two bytes and hope for the best */ @@ -6066,10 +6046,10 @@ bool bsv_movie_handle_read_input_event(bsv_movie_t *movie, for (i = 0; i < movie->input_event_count; i++) { bsv_input_data_t evt = movie->input_events[i]; - if (evt.port == port && - evt.device == dev && - evt.idx == idx && - evt.id == id) + if ( (evt.port == port) + && (evt.device == dev) + && (evt.idx == idx) + && (evt.id == id)) { *val = swap_if_big16(evt.value); return true; @@ -6080,12 +6060,12 @@ bool bsv_movie_handle_read_input_event(bsv_movie_t *movie, void bsv_movie_finish_rewind(input_driver_state_t *input_st) { - bsv_movie_t *handle = input_st->bsv_movie_state_handle; + bsv_movie_t *handle = input_st->bsv_movie_state_handle; if (!handle) return; handle->frame_counter += 1; - handle->first_rewind = !handle->did_rewind; - handle->did_rewind = false; + handle->first_rewind = !handle->did_rewind; + handle->did_rewind = false; } void bsv_movie_read_next_events(bsv_movie_t *handle) @@ -6096,7 +6076,8 @@ void bsv_movie_read_next_events(bsv_movie_t *handle) int i; for (i = 0; i < handle->key_event_count; i++) { - if (intfstream_read(handle->file, &(handle->key_events[i]), sizeof(bsv_key_data_t)) != sizeof(bsv_key_data_t)) + if (intfstream_read(handle->file, &(handle->key_events[i]), + sizeof(bsv_key_data_t)) != sizeof(bsv_key_data_t)) { /* Unnatural EOF */ RARCH_ERR("[Replay] Keyboard replay ran out of keyboard inputs too early\n"); @@ -6120,7 +6101,8 @@ void bsv_movie_read_next_events(bsv_movie_t *handle) handle->input_event_count = swap_if_big16(handle->input_event_count); for (i = 0; i < handle->input_event_count; i++) { - if (intfstream_read(handle->file, &(handle->input_events[i]), sizeof(bsv_input_data_t)) != sizeof(bsv_input_data_t)) + if (intfstream_read(handle->file, &(handle->input_events[i]), + sizeof(bsv_input_data_t)) != sizeof(bsv_input_data_t)) { /* Unnatural EOF */ RARCH_ERR("[Replay] Input replay ran out of inputs too early\n"); @@ -6140,24 +6122,22 @@ void bsv_movie_read_next_events(bsv_movie_t *handle) { uint8_t next_frame_type=REPLAY_TOKEN_INVALID; - if (intfstream_read(handle->file, (uint8_t *)(&next_frame_type), sizeof(uint8_t)) != sizeof(uint8_t)) + if (intfstream_read(handle->file, (uint8_t *)(&next_frame_type), + sizeof(uint8_t)) != sizeof(uint8_t)) { /* Unnatural EOF */ RARCH_ERR("[Replay] Replay ran out of frames\n"); input_st->bsv_movie_state.flags |= BSV_FLAG_MOVIE_END; return; } - else if (next_frame_type == REPLAY_TOKEN_REGULAR_FRAME) - { - /* do nothing */ - } else if (next_frame_type == REPLAY_TOKEN_CHECKPOINT_FRAME) { uint64_t size; uint8_t *st; retro_ctx_serialize_info_t serial_info; - if (intfstream_read(handle->file, &(size), sizeof(uint64_t)) != sizeof(uint64_t)) + if (intfstream_read(handle->file, &(size), + sizeof(uint64_t)) != sizeof(uint64_t)) { RARCH_ERR("[Replay] Replay ran out of frames\n"); input_st->bsv_movie_state.flags |= BSV_FLAG_MOVIE_END; @@ -6213,16 +6193,22 @@ void bsv_movie_next_frame(input_driver_state_t *input_st) /* write key events, frame is over */ intfstream_write(handle->file, &(handle->key_event_count), 1); for (i = 0; i < handle->key_event_count; i++) - intfstream_write(handle->file, &(handle->key_events[i]), sizeof(bsv_key_data_t)); - bsv_movie_handle_clear_key_events(handle); + intfstream_write(handle->file, &(handle->key_events[i]), + sizeof(bsv_key_data_t)); + /* Zero out key events when playing back or recording */ + handle->key_event_count = 0; /* write input events, frame is over */ intfstream_write(handle->file, &evt_count, 2); for (i = 0; i < handle->input_event_count; i++) - intfstream_write(handle->file, &(handle->input_events[i]), sizeof(bsv_input_data_t)); - bsv_movie_handle_clear_input_events(handle); + intfstream_write(handle->file, &(handle->input_events[i]), + sizeof(bsv_input_data_t)); + /* Zero out input events when playing back or recording */ + handle->input_event_count = 0; /* Maybe record checkpoint */ - if (checkpoint_interval != 0 && handle->frame_counter > 0 && (handle->frame_counter % (checkpoint_interval*60) == 0)) + if ( (checkpoint_interval != 0) + && (handle->frame_counter > 0) + && (handle->frame_counter % (checkpoint_interval*60) == 0)) { retro_ctx_serialize_info_t serial_info; uint8_t frame_tok = REPLAY_TOKEN_CHECKPOINT_FRAME; @@ -6279,7 +6265,8 @@ bool replay_get_serialized_data(void* buffer) intfstream_rewind(handle->file); read_amt = intfstream_read(handle->file, (void *)buf, file_end); if (read_amt != file_end) - RARCH_ERR("[Replay] Failed to write correct number of replay bytes into state file: %d / %d\n", read_amt, file_end); + RARCH_ERR("[Replay] Failed to write correct number of replay bytes into state file: %d / %d\n", + read_amt, file_end); } return true; } @@ -6321,16 +6308,16 @@ bool replay_set_serialized_data(void* buf) } else { - int32_t loaded_len = swap_if_big32(((int32_t *)buffer)[0]); /* TODO: should factor the next few lines away, magic numbers ahoy */ - uint32_t *header = (uint32_t *)(buffer+sizeof(int32_t)); - int64_t *identifier_spot = (int64_t *)(header+4); - int64_t identifier = swap_if_big64(*identifier_spot); - int64_t handle_idx = intfstream_tell(input_st->bsv_movie_state_handle->file); - bool is_compatible = identifier == input_st->bsv_movie_state_handle->identifier; + uint32_t *header = (uint32_t *)(buffer + sizeof(int32_t)); + int64_t *ident_spot = (int64_t *)(header + 4); + int64_t ident = swap_if_big64(*ident_spot); - if (is_compatible) + if (ident == input_st->bsv_movie_state_handle->identifier) /* is compatible? */ { + int32_t loaded_len = swap_if_big32(((int32_t *)buffer)[0]); + int64_t handle_idx = intfstream_tell( + input_st->bsv_movie_state_handle->file); /* If the state is part of this replay, go back to that state and rewind/fast forward the replay. @@ -6400,9 +6387,9 @@ void input_driver_poll(void) bool input_remap_binds_enable = settings->bools.input_remap_binds_enable; uint8_t max_users = (uint8_t)settings->uints.input_max_users; - if ( joypad && joypad->poll) + if (joypad && joypad->poll) joypad->poll(); - if ( sec_joypad && sec_joypad->poll) + if (sec_joypad && sec_joypad->poll) sec_joypad->poll(); if ( input_st->current_driver && input_st->current_driver->poll) @@ -6422,23 +6409,17 @@ void input_driver_poll(void) * when mapping analog stick to dpad input. */ for (i = 0; i < max_users; i++) { - joypad_info[i].axis_threshold = settings->floats.input_axis_threshold; - joypad_info[i].joy_idx = settings->uints.input_joypad_index[i]; - joypad_info[i].auto_binds = input_autoconf_binds[joypad_info[i].joy_idx]; + joypad_info[i].axis_threshold = settings->floats.input_axis_threshold; + joypad_info[i].joy_idx = settings->uints.input_joypad_index[i]; + joypad_info[i].auto_binds = input_autoconf_binds[joypad_info[i].joy_idx]; - input_st->turbo_btns.frame_enable[i] = (*input_st->libretro_input_binds[i])[RARCH_TURBO_ENABLE].valid ? - input_state_wrap( - input_st->current_driver, - input_st->current_data, - joypad, - sec_joypad, - &joypad_info[i], + input_st->turbo_btns.frame_enable[i] = (*input_st->libretro_input_binds[i])[RARCH_TURBO_ENABLE].valid ? + input_state_wrap(input_st->current_driver, input_st->current_data, + joypad, sec_joypad, &joypad_info[i], (*input_st->libretro_input_binds), (input_st->flags & INP_FLAG_KB_MAPPING_BLOCKED) ? true : false, (unsigned)i, - RETRO_DEVICE_JOYPAD, - 0, - RARCH_TURBO_ENABLE) : 0; + RETRO_DEVICE_JOYPAD, 0, RARCH_TURBO_ENABLE) : 0; } #ifdef HAVE_OVERLAY @@ -6579,11 +6560,8 @@ void input_driver_poll(void) input_analog_dpad_mode, input_analog_deadzone, input_analog_sensitivity, - joypad, - &joypad_info[i], - k, - j, - (*input_st->libretro_input_binds[i])); + joypad, &joypad_info[i], + k, j, (*input_st->libretro_input_binds[i])); if (val >= 0) p_new_state->analogs[offset] = val; @@ -6619,21 +6597,15 @@ void input_driver_poll(void) * 32767; } else - { - current_button_value = - BIT256_GET_PTR(p_new_state, j); - } + current_button_value = BIT256_GET_PTR(p_new_state, j); #ifdef HAVE_OVERLAY if (poll_overlay && i == 0) { - input_overlay_state_t *ol_state = - overlay_pointer - ? &overlay_pointer->overlay_state - : NULL; + input_overlay_state_t *ol_state = overlay_pointer + ? &overlay_pointer->overlay_state : NULL; if (ol_state) - current_button_value |= - BIT256_GET(ol_state->buttons, j); + current_button_value |= BIT256_GET(ol_state->buttons, j); } #endif /* Press */ @@ -6687,12 +6659,11 @@ void input_driver_poll(void) if (poll_overlay && i == 0) { input_overlay_state_t *ol_state = - overlay_pointer + overlay_pointer ? &overlay_pointer->overlay_state : NULL; if (ol_state) - current_button_value |= - BIT256_GET(ol_state->buttons, j); + current_button_value |= BIT256_GET(ol_state->buttons, j); } #endif remap_valid = @@ -6760,8 +6731,8 @@ void input_driver_poll(void) if (remap_axis_bind < sizeof(handle->analog_value[i])) { int invert = 1; - if ( (k % 2 == 0 && remap_axis % 2 != 0) || - (k % 2 != 0 && remap_axis % 2 == 0) + if ( (k % 2 == 0 && remap_axis % 2 != 0) + || (k % 2 != 0 && remap_axis % 2 == 0) ) invert = -1; @@ -6851,10 +6822,13 @@ void input_driver_poll(void) rcheevos_pause_hardcore(); #endif k = input_st->bsv_movie_state_handle->key_events[i]; - input_keyboard_event(k.down, swap_if_big32(k.code), swap_if_big32(k.character), swap_if_big16(k.mod), RETRO_DEVICE_KEYBOARD); + input_keyboard_event(k.down, swap_if_big32(k.code), + swap_if_big32(k.character), swap_if_big16(k.mod), + RETRO_DEVICE_KEYBOARD); } /* Have to clear here so we don't double-apply key events */ - bsv_movie_handle_clear_key_events(input_st->bsv_movie_state_handle); + /* Zero out key events when playing back or recording */ + input_st->bsv_movie_state_handle->key_event_count = 0; } } #endif @@ -6874,12 +6848,7 @@ int16_t input_driver_state_wrapper(unsigned port, unsigned device, int16_t bsv_result = 0; bsv_movie_t *movie = input_st->bsv_movie_state_handle; if (bsv_movie_handle_read_input_event( - movie, - port, - device, - idx, - id, - &bsv_result)) + movie, port, device, idx, id, &bsv_result)) { #ifdef HAVE_CHEEVOS rcheevos_pause_hardcore(); @@ -6904,7 +6873,6 @@ int16_t input_driver_state_wrapper(unsigned port, unsigned device, #ifdef HAVE_BSV_MOVIE /* Save input to BSV record, if enabled */ if (BSV_MOVIE_IS_RECORDING()) - { bsv_movie_handle_push_input_event( input_st->bsv_movie_state_handle, port, @@ -6912,7 +6880,6 @@ int16_t input_driver_state_wrapper(unsigned port, unsigned device, idx, id, result); - } #endif return result; @@ -7174,7 +7141,6 @@ void input_driver_collect_system_input(input_driver_state_t *input_st, #ifdef HAVE_MENU if (menu_is_alive) { - int16_t ret; uint8_t s; uint8_t a; @@ -7187,7 +7153,7 @@ void input_driver_collect_system_input(input_driver_state_t *input_st, for (a = RETRO_DEVICE_ID_ANALOG_X; a <= RETRO_DEVICE_ID_ANALOG_Y; a++) { - ret = input_joypad_analog_axis( + int16_t ret = input_joypad_analog_axis( ANALOG_DPAD_NONE, settings->floats.input_analog_deadzone, settings->floats.input_analog_sensitivity, @@ -7443,20 +7409,20 @@ static const char *accessibility_lut_name(char key) void input_keyboard_event(bool down, unsigned code, uint32_t character, uint16_t mod, unsigned device) { - runloop_state_t *runloop_st = runloop_state_get_ptr(); + runloop_state_t *runloop_st = runloop_state_get_ptr(); retro_keyboard_event_t - *key_event = &runloop_st->key_event; + *key_event = &runloop_st->key_event; input_driver_state_t - *input_st = &input_driver_st; + *input_st = &input_driver_st; #ifdef HAVE_ACCESSIBILITY - access_state_t *access_st = access_state_get_ptr(); - settings_t *settings = config_get_ptr(); - bool accessibility_enable = settings->bools.accessibility_enable; + access_state_t *access_st = access_state_get_ptr(); + settings_t *settings = config_get_ptr(); + bool accessibility_enable = settings->bools.accessibility_enable; unsigned accessibility_narrator_speech_speed - = settings->uints.accessibility_narrator_speech_speed; + = settings->uints.accessibility_narrator_speech_speed; #endif #ifdef HAVE_MENU - struct menu_state *menu_st = menu_state_get_ptr(); + struct menu_state *menu_st = menu_state_get_ptr(); /* If screensaver is active, then it should be * disabled if: @@ -7479,20 +7445,20 @@ void input_keyboard_event(bool down, unsigned code, { if ( (down) && (code != RETROK_UNKNOWN) - && (menu_input_dialog_get_display_kb() || - !((code == RETROK_SPACE) || /* RETRO_DEVICE_ID_JOYPAD_START */ - (code == RETROK_SLASH) || /* RETRO_DEVICE_ID_JOYPAD_X */ - (code == RETROK_RSHIFT) || /* RETRO_DEVICE_ID_JOYPAD_SELECT */ - (code == RETROK_RIGHT) || /* RETRO_DEVICE_ID_JOYPAD_RIGHT */ - (code == RETROK_LEFT) || /* RETRO_DEVICE_ID_JOYPAD_LEFT */ - (code == RETROK_DOWN) || /* RETRO_DEVICE_ID_JOYPAD_DOWN */ - (code == RETROK_UP) || /* RETRO_DEVICE_ID_JOYPAD_UP */ - (code == RETROK_PAGEUP) || /* RETRO_DEVICE_ID_JOYPAD_L */ - (code == RETROK_PAGEDOWN) || /* RETRO_DEVICE_ID_JOYPAD_R */ - (code == RETROK_BACKSPACE)|| /* RETRO_DEVICE_ID_JOYPAD_B */ - (code == RETROK_RETURN) || /* RETRO_DEVICE_ID_JOYPAD_A */ - (code == RETROK_DELETE) || /* RETRO_DEVICE_ID_JOYPAD_Y */ - BIT512_GET(input_st->keyboard_mapping_bits, code)))) + && (menu_input_dialog_get_display_kb() + || !((code == RETROK_SPACE) /* RETRO_DEVICE_ID_JOYPAD_START */ + || (code == RETROK_SLASH) /* RETRO_DEVICE_ID_JOYPAD_X */ + || (code == RETROK_RSHIFT) /* RETRO_DEVICE_ID_JOYPAD_SELECT */ + || (code == RETROK_RIGHT) /* RETRO_DEVICE_ID_JOYPAD_RIGHT */ + || (code == RETROK_LEFT) /* RETRO_DEVICE_ID_JOYPAD_LEFT */ + || (code == RETROK_DOWN) /* RETRO_DEVICE_ID_JOYPAD_DOWN */ + || (code == RETROK_UP) /* RETRO_DEVICE_ID_JOYPAD_UP */ + || (code == RETROK_PAGEUP) /* RETRO_DEVICE_ID_JOYPAD_L */ + || (code == RETROK_PAGEDOWN) /* RETRO_DEVICE_ID_JOYPAD_R */ + || (code == RETROK_BACKSPACE) /* RETRO_DEVICE_ID_JOYPAD_B */ + || (code == RETROK_RETURN) /* RETRO_DEVICE_ID_JOYPAD_A */ + || (code == RETROK_DELETE) /* RETRO_DEVICE_ID_JOYPAD_Y */ + || (BIT512_GET(input_st->keyboard_mapping_bits, code))))) { struct menu_state *menu_st = menu_state_get_ptr(); menu_st->flags &= ~MENU_ST_FLAG_SCREENSAVER_ACTIVE; @@ -7508,9 +7474,9 @@ void input_keyboard_event(bool down, unsigned code, menu_st->input_last_time_us = menu_st->current_time_us; #ifdef HAVE_ACCESSIBILITY - if (menu_input_dialog_get_display_kb() - && down && is_accessibility_enabled( - accessibility_enable, + if ( menu_input_dialog_get_display_kb() + && down + && is_accessibility_enabled(accessibility_enable, access_st->enabled)) { if (code != 303 && code != 0) @@ -7524,10 +7490,8 @@ void input_keyboard_event(bool down, unsigned code, say_char[1] = '\0'; if (character == 127 || character == 8) - accessibility_speak_priority( - accessibility_enable, - accessibility_narrator_speech_speed, - "backspace", 10); + accessibility_speak_priority(accessibility_enable, + accessibility_narrator_speech_speed, "backspace", 10); else { const char *lut_name = accessibility_lut_name(c); @@ -7580,7 +7544,7 @@ void input_keyboard_event(bool down, unsigned code, input_keyboard_line_free(input_st); /* Unblock all hotkeys. */ - input_st->flags &= ~INP_FLAG_KB_MAPPING_BLOCKED; + input_st->flags &= ~INP_FLAG_KB_MAPPING_BLOCKED; } else { @@ -7601,9 +7565,9 @@ void input_keyboard_event(bool down, unsigned code, && BIT512_GET(input_st->keyboard_mapping_bits, code) && device != RETRO_DEVICE_POINTER) { + unsigned j; settings_t *settings = config_get_ptr(); unsigned max_users = settings->uints.input_max_users; - unsigned j; bool hotkey_pressed = (input_st->input_hotkey_block_counter > 0); bool block_key_event = false; @@ -7617,9 +7581,9 @@ void input_keyboard_event(bool down, unsigned code, * and only when modifier is a keyboard key. */ if ( j == 0 && !block_key_event - && !( !hotkey_pressed - && hotkey_code != RETROK_UNKNOWN - && hotkey_code != code)) + && !( !hotkey_pressed + && hotkey_code != RETROK_UNKNOWN + && hotkey_code != code)) { for (k = RARCH_FIRST_META_KEY; k < RARCH_BIND_LIST_END; k++) { @@ -7631,7 +7595,8 @@ void input_keyboard_event(bool down, unsigned code, } } - /* RetroPad blocking needed only when emulated device type is active. */ + /* RetroPad blocking needed only when emulated + * device type is active. */ if ( input_config_get_device(j) && !block_key_event) { @@ -7661,9 +7626,9 @@ void input_keyboard_event(bool down, unsigned code, #ifdef HAVE_BSV_MOVIE /* Save input to BSV record, if recording */ if (BSV_MOVIE_IS_RECORDING()) - { - bsv_movie_handle_push_key_event(input_st->bsv_movie_state_handle, down, mod, code, character); - } + bsv_movie_handle_push_key_event( + input_st->bsv_movie_state_handle, down, mod, + code, character); #endif } (*key_event)(down, code, character, mod); From 445547f00a0feaeabb1dcc6a11fcbc3ec72d4615 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Sat, 18 Jan 2025 04:09:36 +0100 Subject: [PATCH 49/49] Remove unused variable warning --- runloop.c | 1 - 1 file changed, 1 deletion(-) diff --git a/runloop.c b/runloop.c index e93ef4f10a7b..5336bd99d631 100644 --- a/runloop.c +++ b/runloop.c @@ -6830,7 +6830,6 @@ int runloop_iterate(void) settings_t *settings = config_get_ptr(); runloop_state_t *runloop_st = &runloop_state; bool vrr_runloop_enable = settings->bools.vrr_runloop_enable; - unsigned max_users = settings->uints.input_max_users; retro_time_t current_time = cpu_features_get_time_usec(); #ifdef HAVE_MENU #ifdef HAVE_NETWORKING