diff --git a/Makefile.common b/Makefile.common index 282e4a6971..cba3abe779 100644 --- a/Makefile.common +++ b/Makefile.common @@ -112,7 +112,7 @@ OBJ += frontend/frontend.o \ libretro-common/file//nbio/nbio_stdio.o \ libretro-common/file/file_path.o \ file_path_special.o \ - hash.o \ + libretro-common/hash/rhash.o \ audio/audio_driver.o \ input/input_driver.o \ input/input_hid_driver.o \ diff --git a/content.c b/content.c index f268067e58..a16190c32d 100644 --- a/content.c +++ b/content.c @@ -26,7 +26,7 @@ #include "movie.h" #include "patch.h" #include "compat/strl.h" -#include "hash.h" +#include #include #ifdef _WIN32 diff --git a/database_info.c b/database_info.c index 4dae6c5985..64380f1d12 100644 --- a/database_info.c +++ b/database_info.c @@ -15,12 +15,13 @@ * If not, see . */ +#include +#include + #include "file_ext.h" #include "dir_list_special.h" -#include #include "database_info.h" -#include "hash.h" #include "file_ops.h" #include "general.h" #include "runloop.h" @@ -49,6 +50,31 @@ #define DB_QUERY_ENTRY_RELEASEDATE_YEAR 0x9c7c6e91U #define DB_QUERY_ENTRY_MAX_USERS 0xbfcba816U +#define DB_CURSOR_NAME 0x7c9b0c46U +#define DB_CURSOR_DESCRIPTION 0x91b0c789U +#define DB_CURSOR_PUBLISHER 0x5e099013U +#define DB_CURSOR_DEVELOPER 0x1783d2abU +#define DB_CURSOR_ORIGIN 0x1315e3edU +#define DB_CURSOR_FRANCHISE 0xc3a526b8U +#define DB_CURSOR_BBFC_RATING 0xede26836U +#define DB_CURSOR_ESRB_RATING 0x4c3fa255U +#define DB_CURSOR_ELSPA_RATING 0xd9cab41eU +#define DB_CURSOR_CERO_RATING 0x084a1772U +#define DB_CURSOR_PEGI_RATING 0x431b736eU +#define DB_CURSOR_CHECKSUM_CRC32 0x0b88671dU +#define DB_CURSOR_CHECKSUM_SHA1 0x7c9de632U +#define DB_CURSOR_CHECKSUM_MD5 0x0b888fabU +#define DB_CURSOR_ENHANCEMENT_HW 0xab612029U +#define DB_CURSOR_EDGE_MAGAZINE_REVIEW 0xd3573eabU +#define DB_CURSOR_EDGE_MAGAZINE_RATING 0xd30dc4feU +#define DB_CURSOR_EDGE_MAGAZINE_ISSUE 0xa0f30d42U +#define DB_CURSOR_FAMITSU_MAGAZINE_RATING 0x0a50ca62U +#define DB_CURSOR_MAX_USERS 0x1084ff77U +#define DB_CURSOR_RELEASEDATE_MONTH 0x790ad76cU +#define DB_CURSOR_RELEASEDATE_YEAR 0x7fd06ed7U +#define DB_CURSOR_RUMBLE_SUPPORTED 0x1a4dc3ecU +#define DB_CURSOR_ANALOG_SUPPORTED 0xf220fc17U + int database_info_build_query(char *s, size_t len, const char *label, const char *path) { @@ -62,90 +88,61 @@ int database_info_build_query(char *s, size_t len, switch (value) { case DB_QUERY_ENTRY: - if (!strcmp(label, "displaylist_parse_database_entry")) - strlcat(s, "name", len); + strlcat(s, "name", len); break; case DB_QUERY_ENTRY_PUBLISHER: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_publisher")) - strlcat(s, "publisher", len); + strlcat(s, "publisher", len); break; case DB_QUERY_ENTRY_DEVELOPER: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_developer")) - strlcat(s, "developer", len); + strlcat(s, "developer", len); break; case DB_QUERY_ENTRY_ORIGIN: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_origin")) - strlcat(s, "origin", len); + strlcat(s, "origin", len); break; case DB_QUERY_ENTRY_FRANCHISE: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_franchise")) - strlcat(s, "franchise", len); + strlcat(s, "franchise", len); break; case DB_QUERY_ENTRY_RATING: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_esrb_rating")) - strlcat(s, "esrb_rating", len); + strlcat(s, "esrb_rating", len); break; case DB_QUERY_ENTRY_BBFC_RATING: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_bbfc_rating")) - strlcat(s, "bbfc_rating", len); + strlcat(s, "bbfc_rating", len); break; case DB_QUERY_ENTRY_ELSPA_RATING: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_elspa_rating")) - strlcat(s, "elspa_rating", len); + strlcat(s, "elspa_rating", len); break; case DB_QUERY_ENTRY_PEGI_RATING: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_pegi_rating")) - strlcat(s, "pegi_rating", len); + strlcat(s, "pegi_rating", len); break; case DB_QUERY_ENTRY_CERO_RATING: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_cero_rating")) - strlcat(s, "cero_rating", len); + strlcat(s, "cero_rating", len); break; case DB_QUERY_ENTRY_ENHANCEMENT_HW: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_enhancement_hw")) - strlcat(s, "enhancement_hw", len); + strlcat(s, "enhancement_hw", len); break; case DB_QUERY_ENTRY_EDGE_MAGAZINE_RATING: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_edge_magazine_rating")) - { - strlcat(s, "edge_rating", len); - add_quotes = false; - } + strlcat(s, "edge_rating", len); + add_quotes = false; break; case DB_QUERY_ENTRY_EDGE_MAGAZINE_ISSUE: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_edge_magazine_issue")) - { - strlcat(s, "edge_issue", len); - add_quotes = false; - } + strlcat(s, "edge_issue", len); + add_quotes = false; break; case DB_QUERY_ENTRY_FAMITSU_MAGAZINE_RATING: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_famitsu_magazine_rating")) - { - strlcat(s, "famitsu_rating", len); - add_quotes = false; - } + strlcat(s, "famitsu_rating", len); + add_quotes = false; break; case DB_QUERY_ENTRY_RELEASEDATE_MONTH: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_releasemonth")) - { - strlcat(s, "releasemonth", len); - add_quotes = false; - } + strlcat(s, "releasemonth", len); + add_quotes = false; break; case DB_QUERY_ENTRY_RELEASEDATE_YEAR: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_releaseyear")) - { - strlcat(s, "releaseyear", len); - add_quotes = false; - } + strlcat(s, "releaseyear", len); + add_quotes = false; break; case DB_QUERY_ENTRY_MAX_USERS: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_max_users")) - { - strlcat(s, "users", len); - add_quotes = false; - } + strlcat(s, "users", len); + add_quotes = false; break; default: RARCH_LOG("Unknown label: %s\n", label); @@ -179,30 +176,6 @@ static char *bin_to_hex_alloc(const uint8_t *data, size_t len) return ret; } -#define DB_CURSOR_NAME 0x7c9b0c46U -#define DB_CURSOR_DESCRIPTION 0x91b0c789U -#define DB_CURSOR_PUBLISHER 0x5e099013U -#define DB_CURSOR_DEVELOPER 0x1783d2abU -#define DB_CURSOR_ORIGIN 0x1315e3edU -#define DB_CURSOR_FRANCHISE 0xc3a526b8U -#define DB_CURSOR_BBFC_RATING 0xede26836U -#define DB_CURSOR_ESRB_RATING 0x4c3fa255U -#define DB_CURSOR_ELSPA_RATING 0xd9cab41eU -#define DB_CURSOR_CERO_RATING 0x084a1772U -#define DB_CURSOR_PEGI_RATING 0x431b736eU -#define DB_CURSOR_CHECKSUM_CRC32 0x0b88671dU -#define DB_CURSOR_CHECKSUM_SHA1 0x7c9de632U -#define DB_CURSOR_CHECKSUM_MD5 0x0b888fabU -#define DB_CURSOR_ENHANCEMENT_HW 0xab612029U -#define DB_CURSOR_EDGE_MAGAZINE_REVIEW 0xd3573eabU -#define DB_CURSOR_EDGE_MAGAZINE_RATING 0xd30dc4feU -#define DB_CURSOR_EDGE_MAGAZINE_ISSUE 0xa0f30d42U -#define DB_CURSOR_FAMITSU_MAGAZINE_RATING 0x0a50ca62U -#define DB_CURSOR_MAX_USERS 0x1084ff77U -#define DB_CURSOR_RELEASEDATE_MONTH 0x790ad76cU -#define DB_CURSOR_RELEASEDATE_YEAR 0x7fd06ed7U -#define DB_CURSOR_RUMBLE_SUPPORTED 0x1a4dc3ecU -#define DB_CURSOR_ANALOG_SUPPORTED 0xf220fc17U static int database_cursor_iterate(libretrodb_cursor_t *cur, database_info_t *db_info) @@ -238,100 +211,76 @@ static int database_cursor_iterate(libretrodb_cursor_t *cur, switch (value) { case DB_CURSOR_NAME: - if (!strcmp(str, "name")) - db_info->name = strdup(val->string.buff); + db_info->name = strdup(val->string.buff); break; case DB_CURSOR_DESCRIPTION: - if (!strcmp(str, "description")) - db_info->description = strdup(val->string.buff); + db_info->description = strdup(val->string.buff); break; case DB_CURSOR_PUBLISHER: - if (!strcmp(str, "publisher")) - db_info->publisher = strdup(val->string.buff); + db_info->publisher = strdup(val->string.buff); break; case DB_CURSOR_DEVELOPER: - if (!strcmp(str, "developer")) - db_info->developer = strdup(val->string.buff); + db_info->developer = strdup(val->string.buff); break; case DB_CURSOR_ORIGIN: - if (!strcmp(str, "origin")) - db_info->origin = strdup(val->string.buff); + db_info->origin = strdup(val->string.buff); break; case DB_CURSOR_FRANCHISE: - if (!strcmp(str, "franchise")) - db_info->franchise = strdup(val->string.buff); + db_info->franchise = strdup(val->string.buff); break; case DB_CURSOR_BBFC_RATING: - if (!strcmp(str, "bbfc_rating")) - db_info->bbfc_rating = strdup(val->string.buff); + db_info->bbfc_rating = strdup(val->string.buff); break; case DB_CURSOR_ESRB_RATING: - if (!strcmp(str, "esrb_rating")) - db_info->esrb_rating = strdup(val->string.buff); + db_info->esrb_rating = strdup(val->string.buff); break; case DB_CURSOR_ELSPA_RATING: - if (!strcmp(str, "elspa_rating")) - db_info->elspa_rating = strdup(val->string.buff); + db_info->elspa_rating = strdup(val->string.buff); break; case DB_CURSOR_CERO_RATING: - if (!strcmp(str, "cero_rating")) - db_info->cero_rating = strdup(val->string.buff); + db_info->cero_rating = strdup(val->string.buff); break; case DB_CURSOR_PEGI_RATING: - if (!strcmp(str, "pegi_rating")) - db_info->pegi_rating = strdup(val->string.buff); + db_info->pegi_rating = strdup(val->string.buff); break; case DB_CURSOR_ENHANCEMENT_HW: - if (!strcmp(str, "enhancement_hw")) - db_info->enhancement_hw = strdup(val->string.buff); + db_info->enhancement_hw = strdup(val->string.buff); break; case DB_CURSOR_EDGE_MAGAZINE_REVIEW: - if (!strcmp(str, "edge_review")) - db_info->edge_magazine_review = strdup(val->string.buff); + db_info->edge_magazine_review = strdup(val->string.buff); break; case DB_CURSOR_EDGE_MAGAZINE_RATING: - if (!strcmp(str, "edge_rating")) - db_info->edge_magazine_rating = val->uint_; + db_info->edge_magazine_rating = val->uint_; break; case DB_CURSOR_EDGE_MAGAZINE_ISSUE: - if (!strcmp(str, "edge_issue")) - db_info->edge_magazine_issue = val->uint_; + db_info->edge_magazine_issue = val->uint_; break; case DB_CURSOR_FAMITSU_MAGAZINE_RATING: - if (!strcmp(str, "famitsu_rating")) - db_info->famitsu_magazine_rating = val->uint_; + db_info->famitsu_magazine_rating = val->uint_; break; case DB_CURSOR_MAX_USERS: - if (!strcmp(str, "users")) - db_info->max_users = val->uint_; + db_info->max_users = val->uint_; break; case DB_CURSOR_RELEASEDATE_MONTH: - if (!strcmp(str, "releasemonth")) - db_info->releasemonth = val->uint_; + db_info->releasemonth = val->uint_; break; case DB_CURSOR_RELEASEDATE_YEAR: - if (!strcmp(str, "releaseyear")) - db_info->releaseyear = val->uint_; + db_info->releaseyear = val->uint_; break; case DB_CURSOR_RUMBLE_SUPPORTED: - if (!strcmp(str, "rumble")) - db_info->rumble_supported = val->uint_; + db_info->rumble_supported = val->uint_; break; case DB_CURSOR_ANALOG_SUPPORTED: - if (!strcmp(str, "analog")) - db_info->analog_supported = val->uint_; + db_info->analog_supported = val->uint_; break; case DB_CURSOR_CHECKSUM_CRC32: - if (!strcmp(str, "crc")) - db_info->crc32 = bin_to_hex_alloc((uint8_t*)val->binary.buff, val->binary.len); + db_info->crc32 = bin_to_hex_alloc((uint8_t*)val->binary.buff, val->binary.len); break; case DB_CURSOR_CHECKSUM_SHA1: - if (!strcmp(str, "sha1")) - db_info->sha1 = bin_to_hex_alloc((uint8_t*)val->binary.buff, val->binary.len); + db_info->sha1 = bin_to_hex_alloc((uint8_t*)val->binary.buff, val->binary.len); break; case DB_CURSOR_CHECKSUM_MD5: - if (!strcmp(str, "md5")) - db_info->md5 = bin_to_hex_alloc((uint8_t*)val->binary.buff, val->binary.len); + db_info->md5 = bin_to_hex_alloc((uint8_t*)val->binary.buff, val->binary.len); break; default: RARCH_LOG("Unknown value: %d\n", value); diff --git a/driver.c b/driver.c index d7b05748c8..21a34b39a2 100644 --- a/driver.c +++ b/driver.c @@ -14,6 +14,8 @@ * If not, see . */ +#include + #include "driver.h" #include "general.h" #include "retroarch.h" @@ -60,6 +62,15 @@ driver_t *driver_get_ptr(void) return g_driver; } +#define HASH_LOCATION_DRIVER 0x09189689U +#define HASH_CAMERA_DRIVER 0xf25db959U +#define HASH_MENU_DRIVER 0xd607fb05U +#define HASH_INPUT_DRIVER 0x4c087840U +#define HASH_INPUT_JOYPAD_DRIVER 0xab124146U +#define HASH_VIDEO_DRIVER 0x1805a5e7U +#define HASH_AUDIO_DRIVER 0x26594002U +#define HASH_AUDIO_RESAMPLER_DRIVER 0xedcba9ecU +#define HASH_RECORD_DRIVER 0x144cd2cfU /** * find_driver_nonempty: * @label : string of driver type to be found. @@ -77,62 +88,57 @@ static const void *find_driver_nonempty(const char *label, int i, char *s, size_t len) { const void *drv = NULL; + uint32_t hash = djb2_calculate(label); - if (!strcmp(label, "camera_driver")) + switch (hash) { - drv = camera_driver_find_handle(i); - if (drv) - strlcpy(s, camera_driver_find_ident(i), len); - } - else if (!strcmp(label, "location_driver")) - { - drv = location_driver_find_handle(i); - if (drv) - strlcpy(s, location_driver_find_ident(i), len); - } + case HASH_CAMERA_DRIVER: + drv = camera_driver_find_handle(i); + if (drv) + strlcpy(s, camera_driver_find_ident(i), len); + break; + case HASH_LOCATION_DRIVER: + drv = location_driver_find_handle(i); + if (drv) + strlcpy(s, location_driver_find_ident(i), len); + break; + case HASH_MENU_DRIVER: #ifdef HAVE_MENU - else if (!strcmp(label, "menu_driver")) - { - drv = menu_driver_find_handle(i); - if (drv) - strlcpy(s, menu_driver_find_ident(i), len); - } + drv = menu_driver_find_handle(i); + if (drv) + strlcpy(s, menu_driver_find_ident(i), len); #endif - else if (!strcmp(label, "input_driver")) - { - drv = input_driver_find_handle(i); - if (drv) - strlcpy(s, input_driver_find_ident(i), len); - } - else if (!strcmp(label, "input_joypad_driver")) - { - drv = joypad_driver_find_handle(i); - if (drv) - strlcpy(s, joypad_driver_find_ident(i), len); - } - else if (!strcmp(label, "video_driver")) - { - drv = video_driver_find_handle(i); - if (drv) - strlcpy(s, video_driver_find_ident(i), len); - } - else if (!strcmp(label, "audio_driver")) - { - drv = audio_driver_find_handle(i); - if (drv) - strlcpy(s, audio_driver_find_ident(i), len); - } - else if (!strcmp(label, "record_driver")) - { - drv = record_driver_find_handle(i); - if (drv) - strlcpy(s, record_driver_find_ident(i), len); - } - else if (!strcmp(label, "audio_resampler_driver")) - { - drv = audio_resampler_driver_find_handle(i); - if (drv) - strlcpy(s, audio_resampler_driver_find_ident(i), len); + break; + case HASH_INPUT_DRIVER: + drv = input_driver_find_handle(i); + if (drv) + strlcpy(s, input_driver_find_ident(i), len); + break; + case HASH_INPUT_JOYPAD_DRIVER: + drv = joypad_driver_find_handle(i); + if (drv) + strlcpy(s, joypad_driver_find_ident(i), len); + break; + case HASH_VIDEO_DRIVER: + drv = video_driver_find_handle(i); + if (drv) + strlcpy(s, video_driver_find_ident(i), len); + break; + case HASH_AUDIO_DRIVER: + drv = audio_driver_find_handle(i); + if (drv) + strlcpy(s, audio_driver_find_ident(i), len); + break; + case HASH_RECORD_DRIVER: + drv = record_driver_find_handle(i); + if (drv) + strlcpy(s, record_driver_find_ident(i), len); + break; + case HASH_AUDIO_RESAMPLER_DRIVER: + drv = audio_resampler_driver_find_handle(i); + if (drv) + strlcpy(s, audio_resampler_driver_find_ident(i), len); + break; } return drv; diff --git a/griffin/griffin.c b/griffin/griffin.c index 7986b70067..e0350020a2 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -81,7 +81,7 @@ CONFIG FILE CHEATS ============================================================ */ #include "../cheats.c" -#include "../hash.c" +#include "../libretro-common/hash/rhash.c" /*============================================================ UI COMMON CONTEXT diff --git a/hash.c b/libretro-common/hash/rhash.c similarity index 86% rename from hash.c rename to libretro-common/hash/rhash.c index 2f6922b985..cfe4f62c2c 100644 --- a/hash.c +++ b/libretro-common/hash/rhash.c @@ -1,17 +1,23 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2010-2015 - Daniel De Matteis - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. +/* Copyright (C) 2010-2015 The RetroArch team * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (rhash.c). + * --------------------------------------------------------------------------------------- * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include @@ -22,7 +28,7 @@ #else #include #endif -#include "hash.h" +#include #include #include @@ -109,20 +115,23 @@ static void sha256_block(struct sha256_ctx *p) p->inlen = 0; } -static void sha256_chunk(struct sha256_ctx *p, const uint8_t *s, unsigned len) +static void sha256_chunk(struct sha256_ctx *p, + const uint8_t *s, unsigned len) { unsigned l; + p->len += len; while (len) { - l = 64 - p->inlen; - l = (len < l) ? len : l; + l = 64 - p->inlen; + l = (len < l) ? len : l; memcpy(p->in.u8 + p->inlen, s, l); - s += l; + + s += l; p->inlen += l; - len -= l; + len -= l; if (p->inlen == 64) sha256_block(p); @@ -157,13 +166,13 @@ static void sha256_subhash(struct sha256_ctx *p, uint32_t *t) /** * sha256_hash: - * @out : Output. + * @s : Output. * @in : Input. - * @size : Size of @out. + * @size : Size of @s. * * Hashes SHA256 and outputs a human readable string. **/ -void sha256_hash(char *out, const uint8_t *in, size_t size) +void sha256_hash(char *s, const uint8_t *in, size_t size) { unsigned i; struct sha256_ctx sha; @@ -180,7 +189,7 @@ void sha256_hash(char *out, const uint8_t *in, size_t size) sha256_subhash(&sha, shahash.u32); for (i = 0; i < 32; i++) - snprintf(out + 2 * i, 3, "%02x", (unsigned)shahash.u8[i]); + snprintf(s + 2 * i, 3, "%02x", (unsigned)shahash.u8[i]); } #ifndef HAVE_ZLIB @@ -293,6 +302,9 @@ uint32_t crc32_calculate(const uint8_t *data, size_t length) static void SHA1Reset(SHA1Context *context) { + if (!context) + return; + context->Length_Low = 0; context->Length_High = 0; context->Message_Block_Index = 0; @@ -341,37 +353,37 @@ static void SHA1ProcessMessageBlock(SHA1Context *context) for(t = 0; t < 20; t++) { - temp = SHA1CircularShift(5,A) + + temp = SHA1CircularShift(5,A) + ((B & C) | ((~B) & D)) + E + W[t] + K[0]; temp &= 0xFFFFFFFF; - E = D; - D = C; - C = SHA1CircularShift(30,B); - B = A; - A = temp; + E = D; + D = C; + C = SHA1CircularShift(30,B); + B = A; + A = temp; } for(t = 20; t < 40; t++) { - temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1]; + temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1]; temp &= 0xFFFFFFFF; - E = D; - D = C; - C = SHA1CircularShift(30,B); - B = A; - A = temp; + E = D; + D = C; + C = SHA1CircularShift(30,B); + B = A; + A = temp; } for(t = 40; t < 60; t++) { - temp = SHA1CircularShift(5,A) + + temp = SHA1CircularShift(5,A) + ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2]; temp &= 0xFFFFFFFF; - E = D; - D = C; - C = SHA1CircularShift(30,B); - B = A; - A = temp; + E = D; + D = C; + C = SHA1CircularShift(30,B); + B = A; + A = temp; } for(t = 60; t < 80; t++) @@ -401,6 +413,9 @@ static void SHA1ProcessMessageBlock(SHA1Context *context) static void SHA1PadMessage(SHA1Context *context) { + if (!context) + return; + /* * Check to see if the current message block is too small to hold * the initial padding bits and length. If so, we will pad the @@ -447,9 +462,9 @@ static int SHA1Result(SHA1Context *context) return 1; } -static void SHA1Input( SHA1Context *context, - const unsigned char *message_array, - unsigned length) +static void SHA1Input(SHA1Context *context, + const unsigned char *message_array, + unsigned length) { if (!length) return; diff --git a/hash.h b/libretro-common/include/rhash.h similarity index 56% rename from hash.h rename to libretro-common/include/rhash.h index 4b9bc612cd..4067b22de6 100644 --- a/hash.h +++ b/libretro-common/include/rhash.h @@ -1,17 +1,23 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2015 - Daniel De Matteis - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. +/* Copyright (C) 2010-2015 The RetroArch team * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (rhash.h). + * --------------------------------------------------------------------------------------- * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* diff --git a/libretro-common/utils/Makefile b/libretro-common/utils/Makefile new file mode 100644 index 0000000000..bb24667712 --- /dev/null +++ b/libretro-common/utils/Makefile @@ -0,0 +1,92 @@ +compiler := gcc +extra_flags := +use_neon := 0 +release := release +DYLIB := + +ifeq ($(platform),) +platform = unix +ifeq ($(shell uname -a),) + platform = win +else ifneq ($(findstring MINGW,$(shell uname -a)),) + platform = win +else ifneq ($(findstring Darwin,$(shell uname -a)),) + platform = osx + arch = intel +ifeq ($(shell uname -p),powerpc) + arch = ppc +endif +else ifneq ($(findstring win,$(shell uname -a)),) + platform = win +endif +endif + +ifeq ($(platform),gcc) +extra_rules_gcc := $(shell $(compiler) -dumpmachine) +endif + +ifneq (,$(findstring armv7,$(extra_rules_gcc))) +extra_flags += -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon +use_neon := 1 +endif + +ifneq (,$(findstring hardfloat,$(extra_rules_gcc))) +extra_flags += -mfloat-abi=hard +endif + +ifeq (release,$(build)) +extra_flags += -O2 +endif + +ifeq (debug,$(build)) +extra_flags += -O0 -g +endif + +ldflags := -shared -Wl,--version-script=link.T + +ifeq ($(platform), unix) +DYLIB = +else ifeq ($(platform), osx) +compiler := $(CC) +DYLIB = +ldflags := -dynamiclib +else +extra_flags += -static-libgcc -static-libstdc++ +DYLIB = exe +endif + +CC := $(compiler) +CXX := $(subst CC,++,$(compiler)) +flags := -fPIC $(extra_flags) -I../../libretro-common/include +asflags := -fPIC $(extra_flags) +objects := +LDFLAGS := -lz +flags += -std=c99 + + +ifeq (1,$(use_neon)) +ASMFLAGS := -INEON/asm +asflags += -mfpu=neon +endif + +objects += crc32$(DYLIB) djb2$(DYLIB) md5$(DYLIB) sha1$(DYLIB) + +all: build; + +%.o: %.S + $(CC) -c -o $@ $(asflags) $(LDFLAGS) $(ASMFLAGS) $< + +%.o: %.c + $(CC) -c -o $@ $(flags) $< + +%.$(DYLIB): %.o + $(CC) -o $@ $(ldflags) $(flags) $^ + +build: $(objects) + +clean: + rm -f *.o + rm -f *.$(DYLIB) + +strip: + strip -s *.$(DYLIB) diff --git a/libretro-common/utils/crc32.c b/libretro-common/utils/crc32.c new file mode 100644 index 0000000000..6ccb866bb0 --- /dev/null +++ b/libretro-common/utils/crc32.c @@ -0,0 +1,42 @@ +/* gcc -O3 -o crc32 crc32.c -lz */ + +#include +#include +#include +#include + +int main(int argc, const char* argv[]) +{ + if (argc != 2 ) + { + fprintf( stderr, "Usage: crc32 \n" ); + return 1; + } + + FILE *file = fopen(argv[1], "rb"); + + if (file) + { + uLong crc = crc32(0L, Z_NULL, 0 ); + + for (;;) + { + Bytef buffer[16384]; + + int numread = fread((void*)buffer, 1, sizeof(buffer), file); + + if (numread > 0) + crc = crc32( crc, buffer, numread ); + else + break; + } + + fclose(file); + + printf("%08x\n", crc); + return 0; + } + + fprintf(stderr, "Error opening input file: %s\n", strerror(errno)); + return 1; +} diff --git a/libretro-common/utils/djb2.c b/libretro-common/utils/djb2.c new file mode 100644 index 0000000000..d70f2c81b4 --- /dev/null +++ b/libretro-common/utils/djb2.c @@ -0,0 +1,26 @@ +/* public domain */ +/* gcc -O3 -o djb2 djb2.c */ + +#include +#include + +static uint32_t djb2(const char* str) +{ + const unsigned char* aux = (const unsigned char*)str; + uint32_t hash = 5381; + + while (*aux) + hash = (hash << 5) + hash + *aux++; + + return hash; +} + +int main(int argc, const char* argv[]) +{ + int i; + + for (i = 1; i < argc; i++) + printf( "0x%08xU: %s\n", djb2( argv[ i ] ), argv[ i ] ); + + return 0; +} diff --git a/libretro-common/utils/md5.c b/libretro-common/utils/md5.c new file mode 100644 index 0000000000..3695cb7889 --- /dev/null +++ b/libretro-common/utils/md5.c @@ -0,0 +1,525 @@ +/* + ********************************************************************** + ** md5.h -- Header file for implementation of MD5 ** + ** RSA Data Security, Inc. MD5 Message Digest Algorithm ** + ** Created: 2/17/90 RLR ** + ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** + ** Revised (for MD5): RLR 4/27/91 ** + ** -- G modified to have y&~z instead of y&z ** + ** -- FF, GG, HH modified to add in last register done ** + ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** + ** -- distinct additive constant for each step ** + ** -- round 4 added, working mod 7 ** + ********************************************************************** + */ + +/* + ********************************************************************** + ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. ** + ** ** + ** License to copy and use this software is granted provided that ** + ** it is identified as the "RSA Data Security, Inc. MD5 Message ** + ** Digest Algorithm" in all material mentioning or referencing this ** + ** software or this function. ** + ** ** + ** License is also granted to make and use derivative works ** + ** provided that such works are identified as "derived from the RSA ** + ** Data Security, Inc. MD5 Message Digest Algorithm" in all ** + ** material mentioning or referencing the derived work. ** + ** ** + ** RSA Data Security, Inc. makes no representations concerning ** + ** either the merchantability of this software or the suitability ** + ** of this software for any particular purpose. It is provided "as ** + ** is" without express or implied warranty of any kind. ** + ** ** + ** These notices must be retained in any copies of any part of this ** + ** documentation and/or software. ** + ********************************************************************** + */ + +/* typedef a 32 bit type */ +typedef unsigned long int UINT4; + +/* Data structure for MD5 (Message Digest) computation */ +typedef struct +{ + UINT4 i[2]; /* number of _bits_ handled mod 2^64 */ + UINT4 buf[4]; /* scratch buffer */ + unsigned char in[64]; /* input buffer */ + unsigned char digest[16]; /* actual digest after MD5Final call */ +} MD5_CTX; + +/* + ********************************************************************** + ** End of md5.h ** + ******************************* (cut) ******************************** + */ + +/* + ********************************************************************** + ** md5.c ** + ** RSA Data Security, Inc. MD5 Message Digest Algorithm ** + ** Created: 2/17/90 RLR ** + ** Revised: 1/91 SRD,AJ,BSK,JT Reference C Version ** + ********************************************************************** + */ + +/* + ********************************************************************** + ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. ** + ** ** + ** License to copy and use this software is granted provided that ** + ** it is identified as the "RSA Data Security, Inc. MD5 Message ** + ** Digest Algorithm" in all material mentioning or referencing this ** + ** software or this function. ** + ** ** + ** License is also granted to make and use derivative works ** + ** provided that such works are identified as "derived from the RSA ** + ** Data Security, Inc. MD5 Message Digest Algorithm" in all ** + ** material mentioning or referencing the derived work. ** + ** ** + ** RSA Data Security, Inc. makes no representations concerning ** + ** either the merchantability of this software or the suitability ** + ** of this software for any particular purpose. It is provided "as ** + ** is" without express or implied warranty of any kind. ** + ** ** + ** These notices must be retained in any copies of any part of this ** + ** documentation and/or software. ** + ********************************************************************** + */ + +/* -- include the following line if the md5.h header file is separate -- */ +/* #include "md5.h" */ + +static unsigned char PADDING[64] = { + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +/* F, G and H are basic MD5 functions: selection, majority, parity */ +#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) +#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) +#define H(x, y, z) ((x) ^ (y) ^ (z)) +#define I(x, y, z) ((y) ^ ((x) | (~z))) + +/* ROTATE_LEFT rotates x left n bits */ +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) + +/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */ +/* Rotation is separate from addition to prevent recomputation */ +#define FF(a, b, c, d, x, s, ac) \ + {(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define GG(a, b, c, d, x, s, ac) \ + {(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define HH(a, b, c, d, x, s, ac) \ + {(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define II(a, b, c, d, x, s, ac) \ + {(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } + +void MD5Init(MD5_CTX *mdContext) +{ + mdContext->i[0] = mdContext->i[1] = (UINT4)0; + + /* Load magic initialization constants. + */ + mdContext->buf[0] = (UINT4)0x67452301; + mdContext->buf[1] = (UINT4)0xefcdab89; + mdContext->buf[2] = (UINT4)0x98badcfe; + mdContext->buf[3] = (UINT4)0x10325476; +} + +/* Basic MD5 step. Transform buf based on in. + */ +static void Transform (UINT4 *buf, UINT4 *in) +{ + UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3]; + + /* Round 1 */ +#define S11 7 +#define S12 12 +#define S13 17 +#define S14 22 + FF ( a, b, c, d, in[ 0], S11, 3614090360); /* 1 */ + FF ( d, a, b, c, in[ 1], S12, 3905402710); /* 2 */ + FF ( c, d, a, b, in[ 2], S13, 606105819); /* 3 */ + FF ( b, c, d, a, in[ 3], S14, 3250441966); /* 4 */ + FF ( a, b, c, d, in[ 4], S11, 4118548399); /* 5 */ + FF ( d, a, b, c, in[ 5], S12, 1200080426); /* 6 */ + FF ( c, d, a, b, in[ 6], S13, 2821735955); /* 7 */ + FF ( b, c, d, a, in[ 7], S14, 4249261313); /* 8 */ + FF ( a, b, c, d, in[ 8], S11, 1770035416); /* 9 */ + FF ( d, a, b, c, in[ 9], S12, 2336552879); /* 10 */ + FF ( c, d, a, b, in[10], S13, 4294925233); /* 11 */ + FF ( b, c, d, a, in[11], S14, 2304563134); /* 12 */ + FF ( a, b, c, d, in[12], S11, 1804603682); /* 13 */ + FF ( d, a, b, c, in[13], S12, 4254626195); /* 14 */ + FF ( c, d, a, b, in[14], S13, 2792965006); /* 15 */ + FF ( b, c, d, a, in[15], S14, 1236535329); /* 16 */ + + /* Round 2 */ +#define S21 5 +#define S22 9 +#define S23 14 +#define S24 20 + GG ( a, b, c, d, in[ 1], S21, 4129170786); /* 17 */ + GG ( d, a, b, c, in[ 6], S22, 3225465664); /* 18 */ + GG ( c, d, a, b, in[11], S23, 643717713); /* 19 */ + GG ( b, c, d, a, in[ 0], S24, 3921069994); /* 20 */ + GG ( a, b, c, d, in[ 5], S21, 3593408605); /* 21 */ + GG ( d, a, b, c, in[10], S22, 38016083); /* 22 */ + GG ( c, d, a, b, in[15], S23, 3634488961); /* 23 */ + GG ( b, c, d, a, in[ 4], S24, 3889429448); /* 24 */ + GG ( a, b, c, d, in[ 9], S21, 568446438); /* 25 */ + GG ( d, a, b, c, in[14], S22, 3275163606); /* 26 */ + GG ( c, d, a, b, in[ 3], S23, 4107603335); /* 27 */ + GG ( b, c, d, a, in[ 8], S24, 1163531501); /* 28 */ + GG ( a, b, c, d, in[13], S21, 2850285829); /* 29 */ + GG ( d, a, b, c, in[ 2], S22, 4243563512); /* 30 */ + GG ( c, d, a, b, in[ 7], S23, 1735328473); /* 31 */ + GG ( b, c, d, a, in[12], S24, 2368359562); /* 32 */ + + /* Round 3 */ +#define S31 4 +#define S32 11 +#define S33 16 +#define S34 23 + HH ( a, b, c, d, in[ 5], S31, 4294588738); /* 33 */ + HH ( d, a, b, c, in[ 8], S32, 2272392833); /* 34 */ + HH ( c, d, a, b, in[11], S33, 1839030562); /* 35 */ + HH ( b, c, d, a, in[14], S34, 4259657740); /* 36 */ + HH ( a, b, c, d, in[ 1], S31, 2763975236); /* 37 */ + HH ( d, a, b, c, in[ 4], S32, 1272893353); /* 38 */ + HH ( c, d, a, b, in[ 7], S33, 4139469664); /* 39 */ + HH ( b, c, d, a, in[10], S34, 3200236656); /* 40 */ + HH ( a, b, c, d, in[13], S31, 681279174); /* 41 */ + HH ( d, a, b, c, in[ 0], S32, 3936430074); /* 42 */ + HH ( c, d, a, b, in[ 3], S33, 3572445317); /* 43 */ + HH ( b, c, d, a, in[ 6], S34, 76029189); /* 44 */ + HH ( a, b, c, d, in[ 9], S31, 3654602809); /* 45 */ + HH ( d, a, b, c, in[12], S32, 3873151461); /* 46 */ + HH ( c, d, a, b, in[15], S33, 530742520); /* 47 */ + HH ( b, c, d, a, in[ 2], S34, 3299628645); /* 48 */ + + /* Round 4 */ +#define S41 6 +#define S42 10 +#define S43 15 +#define S44 21 + II ( a, b, c, d, in[ 0], S41, 4096336452); /* 49 */ + II ( d, a, b, c, in[ 7], S42, 1126891415); /* 50 */ + II ( c, d, a, b, in[14], S43, 2878612391); /* 51 */ + II ( b, c, d, a, in[ 5], S44, 4237533241); /* 52 */ + II ( a, b, c, d, in[12], S41, 1700485571); /* 53 */ + II ( d, a, b, c, in[ 3], S42, 2399980690); /* 54 */ + II ( c, d, a, b, in[10], S43, 4293915773); /* 55 */ + II ( b, c, d, a, in[ 1], S44, 2240044497); /* 56 */ + II ( a, b, c, d, in[ 8], S41, 1873313359); /* 57 */ + II ( d, a, b, c, in[15], S42, 4264355552); /* 58 */ + II ( c, d, a, b, in[ 6], S43, 2734768916); /* 59 */ + II ( b, c, d, a, in[13], S44, 1309151649); /* 60 */ + II ( a, b, c, d, in[ 4], S41, 4149444226); /* 61 */ + II ( d, a, b, c, in[11], S42, 3174756917); /* 62 */ + II ( c, d, a, b, in[ 2], S43, 718787259); /* 63 */ + II ( b, c, d, a, in[ 9], S44, 3951481745); /* 64 */ + + buf[0] += a; + buf[1] += b; + buf[2] += c; + buf[3] += d; +} + +void MD5Update (MD5_CTX *mdContext, + unsigned char *inBuf, unsigned int inLen) +{ + UINT4 in[16]; + int mdi; + unsigned int i, ii; + + /* compute number of bytes mod 64 */ + mdi = (int)((mdContext->i[0] >> 3) & 0x3F); + + /* update number of bits */ + if ((mdContext->i[0] + ((UINT4)inLen << 3)) < mdContext->i[0]) + mdContext->i[1]++; + mdContext->i[0] += ((UINT4)inLen << 3); + mdContext->i[1] += ((UINT4)inLen >> 29); + + while (inLen--) + { + /* add new character to buffer, increment mdi */ + mdContext->in[mdi++] = *inBuf++; + + /* transform if necessary */ + if (mdi == 0x40) + { + for (i = 0, ii = 0; i < 16; i++, ii += 4) + in[i] = (((UINT4)mdContext->in[ii+3]) << 24) | + (((UINT4)mdContext->in[ii+2]) << 16) | + (((UINT4)mdContext->in[ii+1]) << 8) | + ((UINT4)mdContext->in[ii]); + Transform (mdContext->buf, in); + mdi = 0; + } + } +} + +void MD5Final (MD5_CTX *mdContext) +{ + UINT4 in[16]; + int mdi; + unsigned int i, ii; + unsigned int padLen; + + /* save number of bits */ + in[14] = mdContext->i[0]; + in[15] = mdContext->i[1]; + + /* compute number of bytes mod 64 */ + mdi = (int)((mdContext->i[0] >> 3) & 0x3F); + + /* pad out to 56 mod 64 */ + padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi); + MD5Update (mdContext, PADDING, padLen); + + /* append length in bits and transform */ + for (i = 0, ii = 0; i < 14; i++, ii += 4) + in[i] = (((UINT4)mdContext->in[ii+3]) << 24) | + (((UINT4)mdContext->in[ii+2]) << 16) | + (((UINT4)mdContext->in[ii+1]) << 8) | + ((UINT4)mdContext->in[ii]); + Transform (mdContext->buf, in); + + /* store buffer in digest */ + for (i = 0, ii = 0; i < 4; i++, ii += 4) { + mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF); + mdContext->digest[ii+1] = + (unsigned char)((mdContext->buf[i] >> 8) & 0xFF); + mdContext->digest[ii+2] = + (unsigned char)((mdContext->buf[i] >> 16) & 0xFF); + mdContext->digest[ii+3] = + (unsigned char)((mdContext->buf[i] >> 24) & 0xFF); + } +} + + +/* + ********************************************************************** + ** End of md5.c ** + ******************************* (cut) ******************************** + */ + +/* + ********************************************************************** + ** md5driver.c -- sample routines to test ** + ** RSA Data Security, Inc. MD5 message digest algorithm. ** + ** Created: 2/16/90 RLR ** + ** Updated: 1/91 SRD ** + ********************************************************************** + */ + +/* + ********************************************************************** + ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. ** + ** ** + ** RSA Data Security, Inc. makes no representations concerning ** + ** either the merchantability of this software or the suitability ** + ** of this software for any particular purpose. It is provided "as ** + ** is" without express or implied warranty of any kind. ** + ** ** + ** These notices must be retained in any copies of any part of this ** + ** documentation and/or software. ** + ********************************************************************** + */ + +#include +#include +#include +#include + +/* -- include the following file if the file md5.h is separate -- */ +/* #include "md5.h" */ + +/* Prints message digest buffer in mdContext as 32 hexadecimal digits. + Order is from low-order byte to high-order byte of digest. + Each byte is printed with high-order hexadecimal digit first. + */ +static void MDPrint(MD5_CTX *mdContext) +{ + int i; + + for (i = 0; i < 16; i++) + printf ("%02x", mdContext->digest[i]); +} + +/* size of test block */ +#define TEST_BLOCK_SIZE 1000 + +/* number of blocks to process */ +#define TEST_BLOCKS 10000 + +/* number of test bytes = TEST_BLOCK_SIZE * TEST_BLOCKS */ +static long TEST_BYTES = (long)TEST_BLOCK_SIZE * (long)TEST_BLOCKS; + +/* A time trial routine, to measure the speed of MD5. + Measures wall time required to digest TEST_BLOCKS * TEST_BLOCK_SIZE + characters. + */ +static void MDTimeTrial(void) +{ + MD5_CTX mdContext; + time_t endTime, startTime; + unsigned char data[TEST_BLOCK_SIZE]; + unsigned int i; + + /* initialize test data */ + for (i = 0; i < TEST_BLOCK_SIZE; i++) + data[i] = (unsigned char)(i & 0xFF); + + /* start timer */ + printf ("MD5 time trial. Processing %ld characters...\n", TEST_BYTES); + time (&startTime); + + /* digest data in TEST_BLOCK_SIZE byte blocks */ + MD5Init (&mdContext); + for (i = TEST_BLOCKS; i > 0; i--) + MD5Update (&mdContext, data, TEST_BLOCK_SIZE); + MD5Final (&mdContext); + + /* stop timer, get time difference */ + time (&endTime); + MDPrint (&mdContext); + printf (" is digest of test input.\n"); + printf + ("Seconds to process test input: %ld\n", (long)(endTime-startTime)); + printf + ("Characters processed per second: %ld\n", + TEST_BYTES/(endTime-startTime)); +} + +/* Computes the message digest for string inString. + Prints out message digest, a space, the string (in quotes) and a + carriage return. + */ +static void MDString(char *inString) +{ + MD5_CTX mdContext; + unsigned int len = strlen (inString); + + MD5Init (&mdContext); + MD5Update (&mdContext, inString, len); + MD5Final (&mdContext); + MDPrint (&mdContext); + printf (" \"%s\"\n\n", inString); +} + +/* Computes the message digest for a specified file. + Prints out message digest, a space, the file name, and a carriage + return. + */ +static void MDFile (char *filename) +{ + FILE *inFile = fopen (filename, "rb"); + MD5_CTX mdContext; + int bytes; + unsigned char data[1024]; + + if (inFile == NULL) + { + printf ("%s can't be opened.\n", filename); + return; + } + + MD5Init (&mdContext); + while ((bytes = fread (data, 1, 1024, inFile)) != 0) + MD5Update (&mdContext, data, bytes); + MD5Final (&mdContext); + MDPrint (&mdContext); + printf (" %s\n", filename); + fclose (inFile); +} + +/* Writes the message digest of the data from stdin onto stdout, + followed by a carriage return. + */ +static void MDFilter(void) +{ + MD5_CTX mdContext; + int bytes; + unsigned char data[16]; + + MD5Init (&mdContext); + while ((bytes = fread (data, 1, 16, stdin)) != 0) + MD5Update (&mdContext, data, bytes); + MD5Final (&mdContext); + MDPrint (&mdContext); + printf ("\n"); +} + +/* Runs a standard suite of test data. + */ +static void MDTestSuite(void) +{ + printf ("MD5 test suite results:\n\n"); + MDString (""); + MDString ("a"); + MDString ("abc"); + MDString ("message digest"); + MDString ("abcdefghijklmnopqrstuvwxyz"); + MDString + ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); + MDString + ("1234567890123456789012345678901234567890\ + 1234567890123456789012345678901234567890"); + /* Contents of file foo are "abc" */ + MDFile ("foo"); +} + +int main (int argc, char *argv[]) +{ + int i; + + /* For each command line argument in turn: + ** filename -- prints message digest and name of file + ** -sstring -- prints message digest and contents of string + ** -t -- prints time trial statistics for 1M characters + ** -x -- execute a standard suite of test data + ** (no args) -- writes messages digest of stdin onto stdout + */ + if (argc == 1) + MDFilter (); + else + for (i = 1; i < argc; i++) + if (argv[i][0] == '-' && argv[i][1] == 's') + MDString (argv[i] + 2); + else if (strcmp (argv[i], "-t") == 0) + MDTimeTrial (); + else if (strcmp (argv[i], "-x") == 0) + MDTestSuite (); + else MDFile (argv[i]); + + return 0; +} + +/* + ********************************************************************** + ** End of md5driver.c ** + ******************************* (cut) ******************************** + */ diff --git a/libretro-common/utils/sha1.c b/libretro-common/utils/sha1.c new file mode 100644 index 0000000000..20741db2f0 --- /dev/null +++ b/libretro-common/utils/sha1.c @@ -0,0 +1,589 @@ +/* + * sha1.h + * + * Copyright (C) 1998, 2009 + * Paul E. Jones + * All Rights Reserved + * + ***************************************************************************** + * $Id: sha1.h 12 2009-06-22 19:34:25Z paulej $ + ***************************************************************************** + * + * Description: + * This class implements the Secure Hashing Standard as defined + * in FIPS PUB 180-1 published April 17, 1995. + * + * Many of the variable names in the SHA1Context, especially the + * single character names, were used because those were the names + * used in the publication. + * + * Please read the file sha1.c for more information. + * + */ + +#ifndef _SHA1_H_ +#define _SHA1_H_ + +/* + * This structure will hold context information for the hashing + * operation + */ +typedef struct SHA1Context +{ + unsigned Message_Digest[5]; /* Message Digest (output) */ + + unsigned Length_Low; /* Message length in bits */ + unsigned Length_High; /* Message length in bits */ + + unsigned char Message_Block[64]; /* 512-bit message blocks */ + int Message_Block_Index; /* Index into message block array */ + + int Computed; /* Is the digest computed? */ + int Corrupted; /* Is the message digest corruped? */ +} SHA1Context; + +/* + * Function Prototypes + */ +void SHA1Reset(SHA1Context *); +int SHA1Result(SHA1Context *); +void SHA1Input( SHA1Context *, + const unsigned char *, + unsigned); + +#endif + +/* + * sha1.c + * + * Copyright (C) 1998, 2009 + * Paul E. Jones + * All Rights Reserved + * + ***************************************************************************** + * $Id: sha1.c 12 2009-06-22 19:34:25Z paulej $ + ***************************************************************************** + * + * Description: + * This file implements the Secure Hashing Standard as defined + * in FIPS PUB 180-1 published April 17, 1995. + * + * The Secure Hashing Standard, which uses the Secure Hashing + * Algorithm (SHA), produces a 160-bit message digest for a + * given data stream. In theory, it is highly improbable that + * two messages will produce the same message digest. Therefore, + * this algorithm can serve as a means of providing a "fingerprint" + * for a message. + * + * Portability Issues: + * SHA-1 is defined in terms of 32-bit "words". This code was + * written with the expectation that the processor has at least + * a 32-bit machine word size. If the machine word size is larger, + * the code should still function properly. One caveat to that + * is that the input functions taking characters and character + * arrays assume that only 8 bits of information are stored in each + * character. + * + * Caveats: + * SHA-1 is designed to work with messages less than 2^64 bits + * long. Although SHA-1 allows a message digest to be generated for + * messages of any number of bits less than 2^64, this + * implementation only works with messages with a length that is a + * multiple of the size of an 8-bit character. + * + */ + +/*#include "sha1.h"*/ + +/* + * Define the circular shift macro + */ +#define SHA1CircularShift(bits,word) \ + ((((word) << (bits)) & 0xFFFFFFFF) | \ + ((word) >> (32-(bits)))) + +/* Function prototypes */ +void SHA1ProcessMessageBlock(SHA1Context *); +void SHA1PadMessage(SHA1Context *); + +/* + * SHA1Reset + * + * Description: + * This function will initialize the SHA1Context in preparation + * for computing a new message digest. + * + * Parameters: + * context: [in/out] + * The context to reset. + * + * Returns: + * Nothing. + * + * Comments: + * + */ +void SHA1Reset(SHA1Context *context) +{ + context->Length_Low = 0; + context->Length_High = 0; + context->Message_Block_Index = 0; + + context->Message_Digest[0] = 0x67452301; + context->Message_Digest[1] = 0xEFCDAB89; + context->Message_Digest[2] = 0x98BADCFE; + context->Message_Digest[3] = 0x10325476; + context->Message_Digest[4] = 0xC3D2E1F0; + + context->Computed = 0; + context->Corrupted = 0; +} + +/* + * SHA1Result + * + * Description: + * This function will return the 160-bit message digest into the + * Message_Digest array within the SHA1Context provided + * + * Parameters: + * context: [in/out] + * The context to use to calculate the SHA-1 hash. + * + * Returns: + * 1 if successful, 0 if it failed. + * + * Comments: + * + */ +int SHA1Result(SHA1Context *context) +{ + if (context->Corrupted) + return 0; + + if (!context->Computed) + { + SHA1PadMessage(context); + context->Computed = 1; + } + + return 1; +} + +/* + * SHA1Input + * + * Description: + * This function accepts an array of octets as the next portion of + * the message. + * + * Parameters: + * context: [in/out] + * The SHA-1 context to update + * message_array: [in] + * An array of characters representing the next portion of the + * message. + * length: [in] + * The length of the message in message_array + * + * Returns: + * Nothing. + * + * Comments: + * + */ +void SHA1Input( SHA1Context *context, + const unsigned char *message_array, + unsigned length) +{ + if (!length) + return; + + if (context->Computed || context->Corrupted) + { + context->Corrupted = 1; + return; + } + + while(length-- && !context->Corrupted) + { + context->Message_Block[context->Message_Block_Index++] = + (*message_array & 0xFF); + + context->Length_Low += 8; + /* Force it to 32 bits */ + context->Length_Low &= 0xFFFFFFFF; + if (context->Length_Low == 0) + { + context->Length_High++; + /* Force it to 32 bits */ + context->Length_High &= 0xFFFFFFFF; + if (context->Length_High == 0) + { + /* Message is too long */ + context->Corrupted = 1; + } + } + + if (context->Message_Block_Index == 64) + SHA1ProcessMessageBlock(context); + + message_array++; + } +} + +/* + * SHA1ProcessMessageBlock + * + * Description: + * This function will process the next 512 bits of the message + * stored in the Message_Block array. + * + * Parameters: + * None. + * + * Returns: + * Nothing. + * + * Comments: + * Many of the variable names in the SHAContext, especially the + * single character names, were used because those were the names + * used in the publication. + * + * + */ +void SHA1ProcessMessageBlock(SHA1Context *context) +{ + const unsigned K[] = /* Constants defined in SHA-1 */ + { + 0x5A827999, + 0x6ED9EBA1, + 0x8F1BBCDC, + 0xCA62C1D6 + }; + int t; /* Loop counter */ + unsigned temp; /* Temporary word value */ + unsigned W[80]; /* Word sequence */ + unsigned A, B, C, D, E; /* Word buffers */ + + /* + * Initialize the first 16 words in the array W + */ + for(t = 0; t < 16; t++) + { + W[t] = ((unsigned) context->Message_Block[t * 4]) << 24; + W[t] |= ((unsigned) context->Message_Block[t * 4 + 1]) << 16; + W[t] |= ((unsigned) context->Message_Block[t * 4 + 2]) << 8; + W[t] |= ((unsigned) context->Message_Block[t * 4 + 3]); + } + + for(t = 16; t < 80; t++) + { + W[t] = SHA1CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]); + } + + A = context->Message_Digest[0]; + B = context->Message_Digest[1]; + C = context->Message_Digest[2]; + D = context->Message_Digest[3]; + E = context->Message_Digest[4]; + + for(t = 0; t < 20; t++) + { + temp = SHA1CircularShift(5,A) + + ((B & C) | ((~B) & D)) + E + W[t] + K[0]; + temp &= 0xFFFFFFFF; + E = D; + D = C; + C = SHA1CircularShift(30,B); + B = A; + A = temp; + } + + for(t = 20; t < 40; t++) + { + temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1]; + temp &= 0xFFFFFFFF; + E = D; + D = C; + C = SHA1CircularShift(30,B); + B = A; + A = temp; + } + + for(t = 40; t < 60; t++) + { + temp = SHA1CircularShift(5,A) + + ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2]; + temp &= 0xFFFFFFFF; + E = D; + D = C; + C = SHA1CircularShift(30,B); + B = A; + A = temp; + } + + for(t = 60; t < 80; t++) + { + temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3]; + temp &= 0xFFFFFFFF; + E = D; + D = C; + C = SHA1CircularShift(30,B); + B = A; + A = temp; + } + + context->Message_Digest[0] = + (context->Message_Digest[0] + A) & 0xFFFFFFFF; + context->Message_Digest[1] = + (context->Message_Digest[1] + B) & 0xFFFFFFFF; + context->Message_Digest[2] = + (context->Message_Digest[2] + C) & 0xFFFFFFFF; + context->Message_Digest[3] = + (context->Message_Digest[3] + D) & 0xFFFFFFFF; + context->Message_Digest[4] = + (context->Message_Digest[4] + E) & 0xFFFFFFFF; + + context->Message_Block_Index = 0; +} + +/* + * SHA1PadMessage + * + * Description: + * According to the standard, the message must be padded to an even + * 512 bits. The first padding bit must be a '1'. The last 64 + * bits represent the length of the original message. All bits in + * between should be 0. This function will pad the message + * according to those rules by filling the Message_Block array + * accordingly. It will also call SHA1ProcessMessageBlock() + * appropriately. When it returns, it can be assumed that the + * message digest has been computed. + * + * Parameters: + * context: [in/out] + * The context to pad + * + * Returns: + * Nothing. + * + * Comments: + * + */ +void SHA1PadMessage(SHA1Context *context) +{ + /* + * Check to see if the current message block is too small to hold + * the initial padding bits and length. If so, we will pad the + * block, process it, and then continue padding into a second + * block. + */ + if (context->Message_Block_Index > 55) + { + context->Message_Block[context->Message_Block_Index++] = 0x80; + while(context->Message_Block_Index < 64) + context->Message_Block[context->Message_Block_Index++] = 0; + + SHA1ProcessMessageBlock(context); + + while(context->Message_Block_Index < 56) + context->Message_Block[context->Message_Block_Index++] = 0; + } + else + { + context->Message_Block[context->Message_Block_Index++] = 0x80; + while(context->Message_Block_Index < 56) + context->Message_Block[context->Message_Block_Index++] = 0; + } + + /* + * Store the message length as the last 8 octets + */ + context->Message_Block[56] = (context->Length_High >> 24) & 0xFF; + context->Message_Block[57] = (context->Length_High >> 16) & 0xFF; + context->Message_Block[58] = (context->Length_High >> 8) & 0xFF; + context->Message_Block[59] = (context->Length_High) & 0xFF; + context->Message_Block[60] = (context->Length_Low >> 24) & 0xFF; + context->Message_Block[61] = (context->Length_Low >> 16) & 0xFF; + context->Message_Block[62] = (context->Length_Low >> 8) & 0xFF; + context->Message_Block[63] = (context->Length_Low) & 0xFF; + + SHA1ProcessMessageBlock(context); +} + +/* + * sha.cpp + * + * Copyright (C) 1998, 2009 + * Paul E. Jones + * All Rights Reserved + * + ***************************************************************************** + * $Id: sha.c 12 2009-06-22 19:34:25Z paulej $ + ***************************************************************************** + * + * Description: + * This utility will display the message digest (fingerprint) for + * the specified file(s). + * + * Portability Issues: + * None. + */ + +#include +#include +#ifdef WIN32 +#include +#endif +#include +/*#include "sha1.h"*/ + +/* + * Function prototype + */ +void usage(void); + + +/* + * main + * + * Description: + * This is the entry point for the program + * + * Parameters: + * argc: [in] + * This is the count of arguments in the argv array + * argv: [in] + * This is an array of filenames for which to compute message + * digests + * + * Returns: + * Nothing. + * + * Comments: + * + */ +int main(int argc, char *argv[]) +{ + SHA1Context sha; /* SHA-1 context */ + FILE *fp; /* File pointer for reading files*/ + char c; /* Character read from file */ + int i; /* Counter */ + int reading_stdin; /* Are we reading standard in? */ + int read_stdin = 0; /* Have we read stdin? */ + + /* + * Check the program arguments and print usage information if -? + * or --help is passed as the first argument. + */ + if (argc > 1 && (!strcmp(argv[1],"-?") || + !strcmp(argv[1],"--help"))) + { + usage(); + return 1; + } + + /* + * For each filename passed in on the command line, calculate the + * SHA-1 value and display it. + */ + for(i = 0; i < argc; i++) + { + /* + * We start the counter at 0 to guarantee entry into the for + * loop. So if 'i' is zero, we will increment it now. If there + * is no argv[1], we will use STDIN below. + */ + if (i == 0) + i++; + + if (argc == 1 || !strcmp(argv[i],"-")) + { +#ifdef WIN32 + setmode(fileno(stdin), _O_BINARY); +#endif + fp = stdin; + reading_stdin = 1; + } + else + { + if (!(fp = fopen(argv[i],"rb"))) + { + fprintf(stderr, + "sha: unable to open file %s\n", + argv[i]); + return 2; + } + reading_stdin = 0; + } + + /* + * We do not want to read STDIN multiple times + */ + if (reading_stdin) + { + if (read_stdin) + continue; + + read_stdin = 1; + } + + /* + * Reset the SHA-1 context and process input + */ + SHA1Reset(&sha); + + c = fgetc(fp); + while(!feof(fp)) + { + SHA1Input(&sha, &c, 1); + c = fgetc(fp); + } + + if (!reading_stdin) + fclose(fp); + + if (!SHA1Result(&sha)) + { + fprintf(stderr, + "sha: could not compute message digest for %s\n", + reading_stdin?"STDIN":argv[i]); + } + else + { + printf( "%08X %08X %08X %08X %08X - %s\n", + sha.Message_Digest[0], + sha.Message_Digest[1], + sha.Message_Digest[2], + sha.Message_Digest[3], + sha.Message_Digest[4], + reading_stdin?"STDIN":argv[i]); + } + } + + return 0; +} + +/* + * usage + * + * Description: + * This function will display program usage information to the + * user. + * + * Parameters: + * None. + * + * Returns: + * Nothing. + * + * Comments: + * + */ +void usage(void) +{ + printf("usage: sha [ ...]\n"); + printf("\tThis program will display the message digest\n"); + printf("\tfor files using the Secure Hashing Algorithm (SHA-1).\n"); +} diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index fa6bf623e9..443f477b2c 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -21,17 +21,18 @@ #include #include +#include +#include + #include "../menu.h" #include "../menu_driver.h" #include "../menu_entry.h" #include "../menu_display.h" #include "../../runloop_data.h" -#include #include "../../gfx/video_thread_wrapper.h" #include "../../gfx/font_driver.h" #include "../../gfx/video_texture.h" -#include #include "../../retroarch_logger.h" #include "shared.h" @@ -61,6 +62,7 @@ static void glui_blit_line(float x, float y, { unsigned width, height; glui_handle_t *glui = NULL; + struct font_params params = {0}; menu_handle_t *menu = menu_driver_get_ptr(); if (!menu) @@ -70,8 +72,6 @@ static void glui_blit_line(float x, float y, glui = (glui_handle_t*)menu->userdata; - struct font_params params = {0}; - params.x = x / width; params.y = 1.0f - (y + glui->line_height/2 + menu->font.size/3) / height; @@ -186,8 +186,8 @@ static void glui_render_messagebox(const char *message) uint32_t normal_color; int x, y; struct string_list *list = NULL; - menu_handle_t *menu = menu_driver_get_ptr(); - settings_t *settings = config_get_ptr(); + menu_handle_t *menu = menu_driver_get_ptr(); + settings_t *settings = config_get_ptr(); if (!menu || !menu->userdata) return; @@ -297,7 +297,14 @@ static void glui_render_menu_list(glui_handle_t *glui, char entry_path[PATH_MAX_LENGTH], entry_value[PATH_MAX_LENGTH]; char message[PATH_MAX_LENGTH], entry_title_buf[PATH_MAX_LENGTH], type_str_buf[PATH_MAX_LENGTH]; - bool entry_selected = menu_entry_is_currently_selected(i); + bool entry_selected; + + y = menu->header_height - menu->scroll_y + (glui->line_height * i); + + if (y > height || y + glui->line_height < 0) + continue; + + entry_selected = menu_entry_is_currently_selected(i); menu_entry_get_value(i, entry_value, sizeof(entry_value)); menu_entry_get_path(i, entry_path, sizeof(entry_path)); @@ -308,8 +315,6 @@ static void glui_render_menu_list(glui_handle_t *glui, strlcpy(message, entry_title_buf, sizeof(message)); - y = menu->header_height - menu->scroll_y + (glui->line_height * i); - glui_blit_line(glui->margin, y, message, entry_selected ? hover_color : normal_color, TEXT_ALIGN_LEFT); diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 9a001b0c4f..460d1b32ab 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -21,13 +21,14 @@ #include #include -#include "../menu.h" -#include "../menu_entry.h" -#include "../menu_display.h" #include #include #include +#include "../menu.h" +#include "../menu_entry.h" +#include "../menu_display.h" + #include "../../gfx/drivers_font_renderer/bitmap.h" #include "shared.h" diff --git a/menu/drivers/rmenu.c b/menu/drivers/rmenu.c index da756fad3f..09fdf04c2b 100644 --- a/menu/drivers/rmenu.c +++ b/menu/drivers/rmenu.c @@ -21,6 +21,8 @@ #include #include +#include + #include "../menu_driver.h" #include "../menu_entry.h" #include "../menu_input.h" @@ -28,7 +30,6 @@ #include "../menu.h" #include "../../general.h" #include "../../config.def.h" -#include #include "../../performance.h" #include "../../screenshot.h" diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index fa39b066b9..6a519a69c4 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -20,18 +20,22 @@ #include #include +#include +#include +#include +#include + #include "../menu.h" #include "../menu_driver.h" #include "../menu_entry.h" #include "../menu_animation.h" #include "../menu_display.h" -#include +#include "../menu_entries_cbs.h" + #include "../../gfx/video_thread_wrapper.h" #include "../../gfx/font_driver.h" #include "../../gfx/video_texture.h" -#include -#include #include "../../runloop_data.h" @@ -1004,10 +1008,15 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, menu_entry_t entry; float icon_x, icon_y; char name[PATH_MAX_LENGTH], value[PATH_MAX_LENGTH]; - GLuint texture_switch = 0; - GLuint icon = 0; - xmb_node_t * node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i); - menu_handle_t *menu = menu_driver_get_ptr(); + GLuint texture_switch = 0; + GLuint icon = 0; + xmb_node_t * node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i); + menu_handle_t *menu = menu_driver_get_ptr(); + uint32_t hash_label = 0; + uint32_t hash_value = 0; + bool val1_enable = false; + bool val2_enable = false; + bool val3_enable = false; if (!node) continue; @@ -1025,31 +1034,47 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, menu_entry_get(&entry, i, list, true); + hash_label = djb2_calculate(entry.label); + hash_value = djb2_calculate(entry.value); + if (entry.type == MENU_FILE_CONTENTLIST_ENTRY) strlcpy(entry.path, path_basename(entry.path), sizeof(entry.path)); icon = xmb_icon_get_type(xmb, core_node, entry.type); - if (!strcmp(entry.label, "core_options")) - icon = xmb->textures.list[XMB_TEXTURE_CORE_OPTIONS].id; - else if (!strcmp(entry.label, "core_information")) - icon = xmb->textures.list[XMB_TEXTURE_CORE_INFO].id; - else if (!strcmp(entry.label, "core_input_remapping_options")) - icon = xmb->textures.list[XMB_TEXTURE_INPUT_REMAPPING_OPTIONS].id; - else if (!strcmp(entry.label, "core_cheat_options")) - icon = xmb->textures.list[XMB_TEXTURE_CHEAT_OPTIONS].id; - else if (!strcmp(entry.label, "core_disk_options")) - icon = xmb->textures.list[XMB_TEXTURE_DISK_OPTIONS].id; - else if (!strcmp(entry.label, "savestate")) - icon = xmb->textures.list[XMB_TEXTURE_SAVESTATE].id; - else if (!strcmp(entry.label, "loadstate")) - icon = xmb->textures.list[XMB_TEXTURE_LOADSTATE].id; - else if (!strcmp(entry.label, "take_screenshot")) - icon = xmb->textures.list[XMB_TEXTURE_SCREENSHOT].id; - else if (!strcmp(entry.label, "restart_content")) - icon = xmb->textures.list[XMB_TEXTURE_RELOAD].id; - else if (!strcmp(entry.label, "resume_content")) - icon = xmb->textures.list[XMB_TEXTURE_RESUME].id; + switch (hash_label) + { + case MENU_LABEL_CORE_OPTIONS: + icon = xmb->textures.list[XMB_TEXTURE_CORE_OPTIONS].id; + break; + case MENU_LABEL_CORE_INFORMATION: + icon = xmb->textures.list[XMB_TEXTURE_CORE_INFO].id; + break; + case MENU_LABEL_CORE_INPUT_REMAPPING_OPTIONS: + icon = xmb->textures.list[XMB_TEXTURE_INPUT_REMAPPING_OPTIONS].id; + break; + case MENU_LABEL_CORE_CHEAT_OPTIONS: + icon = xmb->textures.list[XMB_TEXTURE_CHEAT_OPTIONS].id; + break; + case MENU_LABEL_DISK_OPTIONS: + icon = xmb->textures.list[XMB_TEXTURE_DISK_OPTIONS].id; + break; + case MENU_LABEL_SAVESTATE: + icon = xmb->textures.list[XMB_TEXTURE_SAVESTATE].id; + break; + case MENU_LABEL_LOADSTATE: + icon = xmb->textures.list[XMB_TEXTURE_LOADSTATE].id; + break; + case MENU_LABEL_TAKE_SCREENSHOT: + icon = xmb->textures.list[XMB_TEXTURE_SCREENSHOT].id; + break; + case MENU_LABEL_RESTART_CONTENT: + icon = xmb->textures.list[XMB_TEXTURE_RELOAD].id; + break; + case MENU_LABEL_RESUME_CONTENT: + icon = xmb->textures.list[XMB_TEXTURE_RESUME].id; + break; + } menu_animation_ticker_line(name, 35, @@ -1066,19 +1091,22 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, frame_count / 20, entry.value, (i == current)); - if(( strcmp(entry.value, "...") - && strcmp(entry.value, "(CORE)") - && strcmp(entry.value, "(RDB)") - && strcmp(entry.value, "(CURSOR)") - && strcmp(entry.value, "(FILE)") - && strcmp(entry.value, "(DIR)") - && strcmp(entry.value, "(COMP)") - && strcmp(entry.value, "ON") - && strcmp(entry.value, "OFF")) - || ((!strcmp(entry.value, "ON") - && !xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id) - || (!strcmp(entry.value, "OFF") - && !xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id))) + val1_enable = ( + (hash_value != MENU_VALUE_MORE) + && (hash_value != MENU_VALUE_CORE) + && (hash_value != MENU_VALUE_RDB) + && (hash_value != MENU_VALUE_CURSOR) + && (hash_value != MENU_VALUE_FILE) + && (hash_value != MENU_VALUE_DIR) + && (hash_value != MENU_VALUE_COMP) + && (hash_value != MENU_VALUE_ON) + && (hash_value != MENU_VALUE_OFF) + ); + + val2_enable = ((hash_value == MENU_VALUE_ON) && !xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id); + val3_enable = ((hash_value == MENU_VALUE_OFF) && !xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id); + + if(val1_enable || val2_enable || val3_enable) xmb_draw_text(menu, xmb, value, node->x + xmb->margins.screen.left + xmb->icon.spacing.horizontal + xmb->margins.label.left + xmb->margins.setting.left, @@ -1087,16 +1115,21 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, node->label_alpha, TEXT_ALIGN_LEFT); - xmb_draw_icon_begin(gl); xmb_draw_icon(gl, xmb, icon, icon_x, icon_y, node->alpha, 0, node->zoom); - if (!strcmp(entry.value, "ON") && xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id) - texture_switch = xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id; - - if (!strcmp(entry.value, "OFF") && xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id) - texture_switch = xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id; + switch (hash_value) + { + case MENU_VALUE_ON: + if (xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id) + texture_switch = xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id; + break; + case MENU_VALUE_OFF: + if (xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id) + texture_switch = xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id; + break; + } if (texture_switch != 0) xmb_draw_icon_predone(gl, xmb, &mymat, diff --git a/menu/menu.c b/menu/menu.c index 272b729baf..8fd7b3984e 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -14,6 +14,8 @@ * If not, see . */ +#include + #include "menu.h" #include "menu_display.h" #include "menu_entry.h" @@ -22,7 +24,6 @@ #include "../frontend/frontend.h" #include "../../retroarch.h" #include "../../performance.h" -#include static void menu_environment_get(int *argc, char *argv[], void *args, void *params_data) diff --git a/menu/menu.h b/menu/menu.h index e8f9a5a031..22823db7d7 100644 --- a/menu/menu.h +++ b/menu/menu.h @@ -26,6 +26,7 @@ #include "../../general.h" #include "../../runloop.h" #include "menu_input.h" +#include "menu_hash.h" #if defined(HAVE_CG) || defined(HAVE_HLSL) || defined(HAVE_GLSL) #ifndef HAVE_SHADER_MANAGER diff --git a/menu/menu_animation.c b/menu/menu_animation.c index d74605dc5b..c8667f91ec 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -14,11 +14,12 @@ * If not, see . */ -#include "menu_animation.h" #include #include #include #include + +#include "menu_animation.h" #include "../runloop.h" /* from https://github.com/kikito/tween.lua/blob/master/tween.lua */ diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index b96337cb74..cc2300da47 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "menu.h" #include "menu_display.h" @@ -1106,6 +1107,7 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info) bool match_found = false; struct string_list *tmp_str_list = string_split( playlist->entries[j].crc32, "|"); + uint32_t hash_value = 0; if (!tmp_str_list) continue; @@ -1115,20 +1117,22 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info) if (tmp_str_list->size > 1) strlcpy(elem1, tmp_str_list->elems[1].data, sizeof(elem1)); - if (!strcmp(elem1, "crc")) + hash_value = djb2_calculate(elem1); + + switch (hash_value) { - if (!strcmp(db_info_entry->crc32, elem0)) - match_found = true; - } - else if (!strcmp(elem1, "sha1")) - { - if (!strcmp(db_info_entry->sha1, elem0)) - match_found = true; - } - else if (!strcmp(elem1, "md5")) - { - if (!strcmp(db_info_entry->md5, elem0)) - match_found = true; + case MENU_VALUE_CRC: + if (!strcmp(db_info_entry->crc32, elem0)) + match_found = true; + break; + case MENU_VALUE_SHA1: + if (!strcmp(db_info_entry->sha1, elem0)) + match_found = true; + break; + case MENU_VALUE_MD5: + if (!strcmp(db_info_entry->md5, elem0)) + match_found = true; + break; } string_list_free(tmp_str_list); @@ -1551,6 +1555,7 @@ static int menu_displaylist_parse_generic(menu_displaylist_info_t *info, bool *n menu_handle_t *menu = menu_driver_get_ptr(); global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); + uint32_t hash_label = djb2_calculate(info->label); (void)device; @@ -1629,7 +1634,7 @@ static int menu_displaylist_parse_generic(menu_displaylist_info_t *info, bool *n break; case RARCH_PLAIN_FILE: default: - if (!strcmp(info->label, "detect_core_list")) + if (hash_label == MENU_LABEL_DETECT_CORE_LIST) { if (path_is_compressed_file(str_list->elems[i].data)) { @@ -1657,23 +1662,24 @@ static int menu_displaylist_parse_generic(menu_displaylist_info_t *info, bool *n /* Push type further down in the chain. * Needed for shader manager currently. */ - if (!strcmp(info->label, "content_collection_list")) - { - file_type = MENU_FILE_PLAYLIST_COLLECTION; - } - else if (!strcmp(info->label, "core_list")) + switch (hash_label) { + case MENU_LABEL_CONTENT_COLLECTION_LIST: + file_type = MENU_FILE_PLAYLIST_COLLECTION; + break; + case MENU_LABEL_CORE_LIST: #ifdef HAVE_LIBRETRO_MANAGEMENT #ifdef RARCH_CONSOLE - if (is_dir || strcasecmp(path, SALAMANDER_FILE) == 0) - continue; + if (is_dir || strcasecmp(path, SALAMANDER_FILE) == 0) + continue; #endif #endif - /* Compressed cores are unsupported */ - if (file_type == MENU_FILE_CARCHIVE) - continue; + /* Compressed cores are unsupported */ + if (file_type == MENU_FILE_CARCHIVE) + continue; - file_type = is_dir ? MENU_FILE_DIRECTORY : MENU_FILE_CORE; + file_type = is_dir ? MENU_FILE_DIRECTORY : MENU_FILE_CORE; + break; } menu_list_push(info->list, path, label, @@ -1682,7 +1688,7 @@ static int menu_displaylist_parse_generic(menu_displaylist_info_t *info, bool *n string_list_free(str_list); - if (!strcmp(info->label, "core_list")) + if (hash_label == MENU_LABEL_CORE_LIST) { const char *dir = NULL; menu_list_get_last_stack(menu->menu_list, &dir, NULL, NULL); @@ -2070,7 +2076,7 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type) return ret; } -static int menu_displaylist_deferred_push(menu_displaylist_info_t *info) +static int menu_displaylist_deferred_push(menu_displaylist_info_t *info, uint32_t hash_label) { menu_file_list_cbs_t *cbs = NULL; menu_handle_t *menu = menu_driver_get_ptr(); @@ -2078,14 +2084,13 @@ static int menu_displaylist_deferred_push(menu_displaylist_info_t *info) if (!info->list) return -1; - if (!strcmp(info->label, "Main Menu")) + switch (hash_label) { - info->flags = SL_FLAG_MAIN_MENU; - return menu_displaylist_push_list(info, DISPLAYLIST_MAIN_MENU); - } - else if (!strcmp(info->label, "Horizontal Menu")) - { - return menu_displaylist_push_list(info, DISPLAYLIST_HORIZONTAL); + case MENU_VALUE_MAIN_MENU: + info->flags = SL_FLAG_MAIN_MENU; + return menu_displaylist_push_list(info, DISPLAYLIST_MAIN_MENU); + case MENU_VALUE_HORIZONTAL_MENU: + return menu_displaylist_push_list(info, DISPLAYLIST_HORIZONTAL); } cbs = (menu_file_list_cbs_t*) @@ -2104,6 +2109,8 @@ int menu_displaylist_push(file_list_t *list, file_list_t *menu_list) const char *label = NULL; menu_handle_t *menu = menu_driver_get_ptr(); menu_displaylist_info_t info = {0}; + uint32_t hash_value = 0; + menu_list_get_last_stack(menu->menu_list, &path, &label, &type); @@ -2113,7 +2120,9 @@ int menu_displaylist_push(file_list_t *list, file_list_t *menu_list) strlcpy(info.path, path, sizeof(info.path)); strlcpy(info.label, label, sizeof(info.label)); - return menu_displaylist_deferred_push(&info); + hash_value = djb2_calculate(label); + + return menu_displaylist_deferred_push(&info, hash_value); } /** diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 2dd6e1bd25..0127446860 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -16,6 +16,7 @@ #include #include + #include "menu_driver.h" #include "menu.h" #include "menu_entries_cbs.h" diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 9379f28c44..798b3b980a 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -14,6 +14,8 @@ */ #include +#include + #include "menu.h" #include "menu_entries_cbs.h" #include "menu_setting.h" @@ -26,34 +28,7 @@ #include "../runloop.h" #include "../file_ops.h" -#include "hash.h" - -#define MENU_LABEL_DRIVER_SETTINGS 0x81cd2d62U -#define MENU_LABEL_CORE_SETTINGS 0x06795dffU -#define MENU_LABEL_CONFIGURATION_SETTINGS 0x5a1558ceU -#define MENU_LABEL_LOGGING_SETTINGS 0x902c003dU -#define MENU_LABEL_SAVING_SETTINGS 0x32fea87eU -#define MENU_LABEL_REWIND_SETTINGS 0xbff7775fU -#define MENU_LABEL_VIDEO_SETTINGS 0x9dd23badU -#define MENU_LABEL_RECORDING_SETTINGS 0x1a80b313U -#define MENU_LABEL_FRAME_THROTTLE_SETTINGS 0x573b8837U -#define MENU_LABEL_SHADER_SETTINGS 0xd6657e8dU -#define MENU_LABEL_ONSCREEN_DISPLAY_SETTINGS 0x67571029U -#define MENU_LABEL_AUDIO_SETTINGS 0x8f74c888U -#define MENU_LABEL_INPUT_SETTINGS 0xddd30846U -#define MENU_LABEL_INPUT_HOTKEY_SETTINGS 0xa4fee31aU -#define MENU_LABEL_OVERLAY_SETTINGS 0x34377f98U -#define MENU_LABEL_ONSCREEN_KEYBOARD_OVERLAY_SETTINGS 0xa6de9ba6U -#define MENU_LABEL_MENU_SETTINGS 0x61e4544bU -#define MENU_LABEL_UI_SETTINGS 0xf8da6ef4U -#define MENU_LABEL_PATCH_SETTINGS 0xa78b0986U -#define MENU_LABEL_PLAYLIST_SETTINGS 0x4d276288U -#define MENU_LABEL_CORE_UPDATER_SETTINGS 0x124ad454U -#define MENU_LABEL_NETWORK_SETTINGS 0x8b50d180U -#define MENU_LABEL_ARCHIVE_SETTINGS 0x78e85398U -#define MENU_LABEL_USER_SETTINGS 0xcdc9a8f5U -#define MENU_LABEL_DIRECTORY_SETTINGS 0xb817bd2bU -#define MENU_LABEL_PRIVACY_SETTINGS 0xce106254U +#include void menu_entries_common_load_content(bool persist) { @@ -159,91 +134,92 @@ int menu_entries_common_is_settings_entry(const char *label) { uint32_t hash = djb2_calculate(label); const char* str = NULL; - + switch (hash) { - case MENU_LABEL_DRIVER_SETTINGS: - str = "Driver Settings"; - break; - case MENU_LABEL_CORE_SETTINGS: - str = "Core Settings"; - break; - case MENU_LABEL_CONFIGURATION_SETTINGS: - str = "Configuration Settings"; - break; - case MENU_LABEL_LOGGING_SETTINGS: - str = "Logging Settings"; - break; - case MENU_LABEL_SAVING_SETTINGS: - str = "Saving Settings"; - break; - case MENU_LABEL_REWIND_SETTINGS: - str = "Rewind Settings"; - break; - case MENU_LABEL_VIDEO_SETTINGS: - str = "Video Settings"; - break; - case MENU_LABEL_RECORDING_SETTINGS: - str = "Recording Settings"; - break; - case MENU_LABEL_FRAME_THROTTLE_SETTINGS: - str = "Frame Throttle Settings"; - break; - case MENU_LABEL_SHADER_SETTINGS: - str = "Shader Settings"; - break; - case MENU_LABEL_ONSCREEN_DISPLAY_SETTINGS: - str = "Onscreen Display Settings"; - break; - case MENU_LABEL_AUDIO_SETTINGS: - str = "Audio Settings"; - break; - case MENU_LABEL_INPUT_SETTINGS: - str = "Input Settings"; - break; - case MENU_LABEL_INPUT_HOTKEY_SETTINGS: - str = "Input Hotkey Settings"; - break; - case MENU_LABEL_OVERLAY_SETTINGS: - str = "Overlay Settings"; - break; - case MENU_LABEL_ONSCREEN_KEYBOARD_OVERLAY_SETTINGS: - str = "Onscreen Keyboard Overlay Settings"; - break; - case MENU_LABEL_MENU_SETTINGS: - str = "Menu Settings"; - break; - case MENU_LABEL_UI_SETTINGS: - str = "UI Settings"; - break; - case MENU_LABEL_PATCH_SETTINGS: - str = "Patch Settings"; - break; - case MENU_LABEL_PLAYLIST_SETTINGS: - str = "Playlist Settings"; - break; - case MENU_LABEL_CORE_UPDATER_SETTINGS: - str = "Core Updater Settings"; - break; - case MENU_LABEL_NETWORK_SETTINGS: - str = "Network Settings"; - break; - case MENU_LABEL_ARCHIVE_SETTINGS: - str = "Archive Settings"; - break; - case MENU_LABEL_USER_SETTINGS: - str = "User Settings"; - break; - case MENU_LABEL_DIRECTORY_SETTINGS: - str = "Directory Settings"; - break; - case MENU_LABEL_PRIVACY_SETTINGS: - str = "Privacy Settings"; - break; - default: - return 0; + case MENU_LABEL_DRIVER_SETTINGS: + str = "Driver Settings"; + break; + case MENU_LABEL_CORE_SETTINGS: + str = "Core Settings"; + break; + case MENU_LABEL_CONFIGURATION_SETTINGS: + str = "Configuration Settings"; + break; + case MENU_LABEL_LOGGING_SETTINGS: + str = "Logging Settings"; + break; + case MENU_LABEL_SAVING_SETTINGS: + str = "Saving Settings"; + break; + case MENU_LABEL_REWIND_SETTINGS: + str = "Rewind Settings"; + break; + case MENU_LABEL_VIDEO_SETTINGS: + str = "Video Settings"; + break; + case MENU_LABEL_RECORDING_SETTINGS: + str = "Recording Settings"; + break; + case MENU_LABEL_FRAME_THROTTLE_SETTINGS: + str = "Frame Throttle Settings"; + break; + case MENU_LABEL_SHADER_SETTINGS: + str = "Shader Settings"; + break; + case MENU_LABEL_ONSCREEN_DISPLAY_SETTINGS: + str = "Onscreen Display Settings"; + break; + case MENU_LABEL_AUDIO_SETTINGS: + str = "Audio Settings"; + break; + case MENU_LABEL_INPUT_SETTINGS: + str = "Input Settings"; + break; + case MENU_LABEL_INPUT_HOTKEY_SETTINGS: + str = "Input Hotkey Settings"; + break; + case MENU_LABEL_OVERLAY_SETTINGS: + str = "Overlay Settings"; + break; + case MENU_LABEL_ONSCREEN_KEYBOARD_OVERLAY_SETTINGS: + str = "Onscreen Keyboard Overlay Settings"; + break; + case MENU_LABEL_MENU_SETTINGS: + str = "Menu Settings"; + break; + case MENU_LABEL_UI_SETTINGS: + str = "UI Settings"; + break; + case MENU_LABEL_PATCH_SETTINGS: + str = "Patch Settings"; + break; + case MENU_LABEL_PLAYLIST_SETTINGS: + str = "Playlist Settings"; + break; + case MENU_LABEL_CORE_UPDATER_SETTINGS: + str = "Core Updater Settings"; + break; + case MENU_LABEL_NETWORK_SETTINGS: + str = "Network Settings"; + break; + case MENU_LABEL_ARCHIVE_SETTINGS: + str = "Archive Settings"; + break; + case MENU_LABEL_USER_SETTINGS: + str = "User Settings"; + break; + case MENU_LABEL_DIRECTORY_SETTINGS: + str = "Directory Settings"; + break; + case MENU_LABEL_PRIVACY_SETTINGS: + str = "Privacy Settings"; + break; + default: + RARCH_LOG("unknown hash: %d\n", hash); + return 0; } - + return !strcmp(label, str); } @@ -257,6 +233,7 @@ void menu_entries_cbs_init(void *data, menu_file_list_cbs_t *cbs = NULL; file_list_t *list = (file_list_t*)data; menu_handle_t *menu = menu_driver_get_ptr(); + uint32_t label_hash = 0, menu_label_hash = 0; if (!menu) return; @@ -285,20 +262,23 @@ void menu_entries_cbs_init(void *data, str_list = NULL; } - menu_entries_cbs_init_bind_ok(cbs, path, label, type, idx, elem0, elem1, menu_label); - menu_entries_cbs_init_bind_cancel(cbs, path, label, type, idx, elem0, elem1); - menu_entries_cbs_init_bind_scan(cbs, path, label, type, idx, elem0, elem1); - menu_entries_cbs_init_bind_start(cbs, path, label, type, idx, elem0, elem1); - menu_entries_cbs_init_bind_select(cbs, path, label, type, idx, elem0, elem1); - menu_entries_cbs_init_bind_info(cbs, path, label, type, idx, elem0, elem1); - menu_entries_cbs_init_bind_content_list_switch(cbs, path, label, type, idx, elem0, elem1); - menu_entries_cbs_init_bind_up(cbs, path, label, type, idx, elem0, elem1); - menu_entries_cbs_init_bind_down(cbs, path, label, type, idx, elem0, elem1); - menu_entries_cbs_init_bind_left(cbs, path, label, type, idx, elem0, elem1, menu_label); - menu_entries_cbs_init_bind_right(cbs, path, label, type, idx, elem0, elem1, menu_label); - menu_entries_cbs_init_bind_deferred_push(cbs, path, label, type, idx, elem0, elem1); - menu_entries_cbs_init_bind_refresh(cbs, path, label, type, idx, elem0, elem1); - menu_entries_cbs_init_bind_iterate(cbs, path, label, type, idx, elem0, elem1); - menu_entries_cbs_init_bind_get_string_representation(cbs, path, label, type, idx, elem0, elem1); - menu_entries_cbs_init_bind_title(cbs, path, label, type, idx, elem0, elem1); + label_hash = djb2_calculate(label); + menu_label_hash = djb2_calculate(menu_label); + + menu_entries_cbs_init_bind_ok(cbs, path, label, type, idx, elem0, elem1, menu_label, label_hash, menu_label_hash); + menu_entries_cbs_init_bind_cancel(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_entries_cbs_init_bind_scan(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_entries_cbs_init_bind_start(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_entries_cbs_init_bind_select(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_entries_cbs_init_bind_info(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_entries_cbs_init_bind_content_list_switch(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_entries_cbs_init_bind_up(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_entries_cbs_init_bind_down(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_entries_cbs_init_bind_left(cbs, path, label, type, idx, elem0, elem1, menu_label, label_hash, menu_label_hash); + menu_entries_cbs_init_bind_right(cbs, path, label, type, idx, elem0, elem1, menu_label, label_hash, menu_label_hash); + menu_entries_cbs_init_bind_deferred_push(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_entries_cbs_init_bind_refresh(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_entries_cbs_init_bind_iterate(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_entries_cbs_init_bind_get_string_representation(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_entries_cbs_init_bind_title(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); } diff --git a/menu/menu_entries_cbs.h b/menu/menu_entries_cbs.h index 6113e8362d..83dc8190f6 100644 --- a/menu/menu_entries_cbs.h +++ b/menu/menu_entries_cbs.h @@ -19,6 +19,8 @@ #include #include +#include "menu_hash.h" + #ifdef __cplusplus extern "C" { #endif @@ -35,67 +37,83 @@ int menu_entries_common_is_settings_entry(const char *label); void menu_entries_cbs_init_bind_left(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1, const char *menu_label); + const char *elem0, const char *elem1, const char *menu_label, + uint32_t label_hash, uint32_t menu_label_hash); void menu_entries_cbs_init_bind_right(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1, const char *menu_label); + const char *elem0, const char *elem1, const char *menu_label, + uint32_t label_hash, uint32_t menu_label_hash); void menu_entries_cbs_init_bind_refresh(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1); + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash); void menu_entries_cbs_init_bind_get_string_representation(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1); + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash); void menu_entries_cbs_init_bind_up(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1); + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash); void menu_entries_cbs_init_bind_down(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1); + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash); void menu_entries_cbs_init_bind_info(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1); + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash); void menu_entries_cbs_init_bind_start(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1); + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash); void menu_entries_cbs_init_bind_content_list_switch(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1); + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash); void menu_entries_cbs_init_bind_cancel(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1); + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash); void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1, const char *menu_label); + const char *elem0, const char *elem1, const char *menu_label, + uint32_t label_hash, uint32_t menu_label_hash); void menu_entries_cbs_init_bind_iterate(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1); + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash); void menu_entries_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1); + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash); void menu_entries_cbs_init_bind_select(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1); + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash); void menu_entries_cbs_init_bind_scan(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1); + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash); void menu_entries_cbs_init_bind_title(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1); + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash); int deferred_push_content_list(void *data, void *userdata, const char *path, const char *label, unsigned type); diff --git a/menu/menu_entries_cbs_cancel.c b/menu/menu_entries_cbs_cancel.c index 38c669af16..f3d1956a6d 100644 --- a/menu/menu_entries_cbs_cancel.c +++ b/menu/menu_entries_cbs_cancel.c @@ -27,7 +27,8 @@ static int action_cancel_pop_default(const char *path, void menu_entries_cbs_init_bind_cancel(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1) + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash) { if (!cbs) return; diff --git a/menu/menu_entries_cbs_contentlist_switch.c b/menu/menu_entries_cbs_contentlist_switch.c index dad95d4880..745aac4d4a 100644 --- a/menu/menu_entries_cbs_contentlist_switch.c +++ b/menu/menu_entries_cbs_contentlist_switch.c @@ -18,7 +18,8 @@ void menu_entries_cbs_init_bind_content_list_switch(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1) + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash) { if (!cbs) return; diff --git a/menu/menu_entries_cbs_deferred_push.c b/menu/menu_entries_cbs_deferred_push.c index 5ff48c2e66..8b33694988 100644 --- a/menu/menu_entries_cbs_deferred_push.c +++ b/menu/menu_entries_cbs_deferred_push.c @@ -14,6 +14,7 @@ */ #include + #include "menu.h" #include "menu_displaylist.h" #include "menu_entries_cbs.h" @@ -451,7 +452,8 @@ static int deferred_push_default(menu_displaylist_info_t *info) void menu_entries_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1) + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash) { settings_t *settings = config_get_ptr(); @@ -473,113 +475,163 @@ void menu_entries_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs, } if (strstr(label, "deferred_rdb_entry_detail")) + { cbs->action_deferred_push = deferred_push_rdb_entry_detail; -#ifdef HAVE_NETWORKING - else if (!strcmp(label, "deferred_core_updater_list")) - cbs->action_deferred_push = deferred_push_core_updater_list; -#endif - else if (!strcmp(label, "history_list")) - cbs->action_deferred_push = deferred_push_history_list; - else if (!strcmp(label, "database_manager_list")) - cbs->action_deferred_push = deferred_push_database_manager_list; - else if (!strcmp(label, "cursor_manager_list")) - cbs->action_deferred_push = deferred_push_cursor_manager_list; - else if (!strcmp(label, "cheat_file_load")) - cbs->action_deferred_push = deferred_push_cheat_file_load; - else if (!strcmp(label, "remap_file_load")) - cbs->action_deferred_push = deferred_push_remap_file_load; - else if (!strcmp(label, "record_config")) - cbs->action_deferred_push = deferred_push_record_configfile; - else if (!strcmp(label, "content_actions")) - cbs->action_deferred_push = deferred_push_content_actions; - else if (!strcmp(label, "shader_options")) - cbs->action_deferred_push = deferred_push_shader_options; - else if (!strcmp(label, "video_options")) - cbs->action_deferred_push = deferred_push_video_options; - else if (!strcmp(label, "options")) - cbs->action_deferred_push = deferred_push_options; - else if (!strcmp(label, "management")) - cbs->action_deferred_push = deferred_push_management_options; - else if (type == MENU_SETTING_GROUP) + return; + } + + if (type == MENU_SETTING_GROUP) cbs->action_deferred_push = deferred_push_category; else if (type == MENU_FILE_PLAYLIST_COLLECTION) cbs->action_deferred_push = deferred_push_rdb_collection; - else if (!strcmp(label, "deferred_core_list") || - !strcmp(label, "deferred_core_list_set")) - cbs->action_deferred_push = deferred_push_core_list_deferred; - else if (!strcmp(label, "deferred_video_filter")) - cbs->action_deferred_push = deferred_push_video_filter; - else if (!strcmp(label, "deferred_database_manager_list")) - cbs->action_deferred_push = deferred_push_database_manager_list_deferred; - else if (!strcmp(label, "deferred_cursor_manager_list")) - cbs->action_deferred_push = deferred_push_cursor_manager_list_deferred; - else if ( - !strcmp(label, "deferred_cursor_manager_list_rdb_entry_publisher") || - !strcmp(label, "deferred_cursor_manager_list_rdb_entry_developer") || - !strcmp(label, "deferred_cursor_manager_list_rdb_entry_origin") || - !strcmp(label, "deferred_cursor_manager_list_rdb_entry_franchise") || - !strcmp(label, "deferred_cursor_manager_list_rdb_entry_enhancement_hw") || - !strcmp(label, "deferred_cursor_manager_list_rdb_entry_esrb_rating") || - !strcmp(label, "deferred_cursor_manager_list_rdb_entry_bbfc_rating") || - !strcmp(label, "deferred_cursor_manager_list_rdb_entry_elspa_rating") || - !strcmp(label, "deferred_cursor_manager_list_rdb_entry_pegi_rating") || - !strcmp(label, "deferred_cursor_manager_list_rdb_entry_cero_rating") || - !strcmp(label, "deferred_cursor_manager_list_rdb_entry_edge_magazine_rating") || - !strcmp(label, "deferred_cursor_manager_list_rdb_entry_edge_magazine_issue") || - !strcmp(label, "deferred_cursor_manager_list_rdb_entry_famitsu_magazine_rating") || - !strcmp(label, "deferred_cursor_manager_list_rdb_entry_max_users") || - !strcmp(label, "deferred_cursor_manager_list_rdb_entry_releasemonth") || - !strcmp(label, "deferred_cursor_manager_list_rdb_entry_releaseyear") - ) - cbs->action_deferred_push = deferred_push_cursor_manager_list_deferred_query_subsearch; - else if (!strcmp(label, "core_information")) - cbs->action_deferred_push = deferred_push_core_information; - else if (!strcmp(label, "system_information")) - cbs->action_deferred_push = deferred_push_system_information; - else if (!strcmp(label, "performance_counters")) - cbs->action_deferred_push = deferred_push_performance_counters; - else if (!strcmp(label, "core_counters")) - cbs->action_deferred_push = deferred_push_core_counters; - else if (!strcmp(label, "video_shader_preset_parameters")) - cbs->action_deferred_push = deferred_push_video_shader_preset_parameters; - else if (!strcmp(label, "video_shader_parameters")) - cbs->action_deferred_push = deferred_push_video_shader_parameters; - else if (!strcmp(label, "settings")) - cbs->action_deferred_push = deferred_push_settings; - else if (!strcmp(label, "frontend_counters")) - cbs->action_deferred_push = deferred_push_frontend_counters; - else if (!strcmp(label, "core_options")) - cbs->action_deferred_push = deferred_push_core_options; - else if (!strcmp(label, "core_cheat_options")) - cbs->action_deferred_push = deferred_push_core_cheat_options; - else if (!strcmp(label, "core_input_remapping_options")) - cbs->action_deferred_push = deferred_push_core_input_remapping_options; - else if (!strcmp(label, "disk_options")) - cbs->action_deferred_push = deferred_push_disk_options; - else if (!strcmp(label, "core_list")) - cbs->action_deferred_push = deferred_push_core_list; - else if (!strcmp(label, "content_collection_list")) - cbs->action_deferred_push = deferred_push_content_collection_list; - else if (!strcmp(label, "configurations")) - cbs->action_deferred_push = deferred_push_configurations; - else if (!strcmp(label, "video_shader_preset")) - cbs->action_deferred_push = deferred_push_video_shader_preset; - else if (!strcmp(label, "video_shader_pass")) - cbs->action_deferred_push = deferred_push_video_shader_pass; - else if (!strcmp(label, "video_filter")) - cbs->action_deferred_push = deferred_push_video_filter; - else if (!strcmp(label, "menu_wallpaper")) - cbs->action_deferred_push = deferred_push_images; - else if (!strcmp(label, "audio_dsp_plugin")) - cbs->action_deferred_push = deferred_push_audio_dsp_plugin; - else if (!strcmp(label, "input_overlay")) - cbs->action_deferred_push = deferred_push_input_overlay; - else if (!strcmp(label, "input_osk_overlay")) - cbs->action_deferred_push = deferred_push_input_osk_overlay; - else if (!strcmp(label, "video_font_path")) - cbs->action_deferred_push = deferred_push_video_font_path; - else if (!strcmp(label, "content_history_path")) - cbs->action_deferred_push = deferred_push_content_history_path; - else if (!strcmp(label, "detect_core_list")) - cbs->action_deferred_push = deferred_push_detect_core_list; + else + { + switch (label_hash) + { + case MENU_LABEL_DEFERRED_CORE_UPDATER_LIST: +#ifdef HAVE_NETWORKING + cbs->action_deferred_push = deferred_push_core_updater_list; +#endif + break; + case MENU_LABEL_HISTORY_LIST: + cbs->action_deferred_push = deferred_push_history_list; + break; + case MENU_LABEL_DATABASE_MANAGER_LIST: + cbs->action_deferred_push = deferred_push_database_manager_list; + break; + case MENU_LABEL_CURSOR_MANAGER_LIST: + cbs->action_deferred_push = deferred_push_cursor_manager_list; + break; + case MENU_LABEL_CHEAT_FILE_LOAD: + cbs->action_deferred_push = deferred_push_cheat_file_load; + break; + case MENU_LABEL_REMAP_FILE_LOAD: + cbs->action_deferred_push = deferred_push_remap_file_load; + break; + case MENU_LABEL_RECORD_CONFIG: + cbs->action_deferred_push = deferred_push_record_configfile; + break; + case MENU_LABEL_CONTENT_ACTIONS: + cbs->action_deferred_push = deferred_push_content_actions; + break; + case MENU_LABEL_SHADER_OPTIONS: + cbs->action_deferred_push = deferred_push_shader_options; + break; + case MENU_LABEL_VIDEO_OPTIONS: + cbs->action_deferred_push = deferred_push_video_options; + break; + case MENU_LABEL_OPTIONS: + cbs->action_deferred_push = deferred_push_options; + break; + case MENU_LABEL_MANAGEMENT: + cbs->action_deferred_push = deferred_push_management_options; + break; + case MENU_LABEL_DEFERRED_CORE_LIST: + case MENU_LABEL_DEFERRED_CORE_LIST_SET: + cbs->action_deferred_push = deferred_push_core_list_deferred; + break; + case MENU_LABEL_DEFERRED_VIDEO_FILTER: + cbs->action_deferred_push = deferred_push_video_filter; + break; + case MENU_LABEL_DEFERRED_DATABASE_MANAGER_LIST: + cbs->action_deferred_push = deferred_push_database_manager_list_deferred; + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST: + cbs->action_deferred_push = deferred_push_cursor_manager_list_deferred; + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_PUBLISHER: + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_DEVELOPER: + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ORIGIN: + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_FRANCHISE: + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ENHANCEMENT_HW: + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ESRB_RATING: + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_BBFC_RATING: + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ELSPA_RATING: + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_PEGI_RATING: + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_CERO_RATING: + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_EDGE_MAGAZINE_RATING: + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_EDGE_MAGAZINE_ISSUE: + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_FAMITSU_MAGAZINE_RATING: + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_MAX_USERS: + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_RELEASEMONTH: + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_RELEASEYEAR: + cbs->action_deferred_push = deferred_push_cursor_manager_list_deferred_query_subsearch; + break; + case MENU_LABEL_CORE_INFORMATION: + cbs->action_deferred_push = deferred_push_core_information; + break; + case MENU_LABEL_SYSTEM_INFORMATION: + cbs->action_deferred_push = deferred_push_system_information; + break; + case MENU_LABEL_PERFORMANCE_COUNTERS: + cbs->action_deferred_push = deferred_push_performance_counters; + break; + case MENU_LABEL_CORE_COUNTERS: + cbs->action_deferred_push = deferred_push_core_counters; + break; + case MENU_LABEL_VIDEO_SHADER_PRESET_PARAMETERS: + cbs->action_deferred_push = deferred_push_video_shader_preset_parameters; + break; + case MENU_LABEL_VIDEO_SHADER_PARAMETERS: + cbs->action_deferred_push = deferred_push_video_shader_parameters; + break; + case MENU_LABEL_SETTINGS: + cbs->action_deferred_push = deferred_push_settings; + break; + case MENU_LABEL_FRONTEND_COUNTERS: + cbs->action_deferred_push = deferred_push_frontend_counters; + break; + case MENU_LABEL_CORE_OPTIONS: + cbs->action_deferred_push = deferred_push_core_options; + break; + case MENU_LABEL_CORE_CHEAT_OPTIONS: + cbs->action_deferred_push = deferred_push_core_cheat_options; + break; + case MENU_LABEL_CORE_INPUT_REMAPPING_OPTIONS: + cbs->action_deferred_push = deferred_push_core_input_remapping_options; + break; + case MENU_LABEL_DISK_OPTIONS: + cbs->action_deferred_push = deferred_push_disk_options; + break; + case MENU_LABEL_CORE_LIST: + cbs->action_deferred_push = deferred_push_core_list; + break; + case MENU_LABEL_CONTENT_COLLECTION_LIST: + cbs->action_deferred_push = deferred_push_content_collection_list; + break; + case MENU_LABEL_CONFIGURATIONS: + cbs->action_deferred_push = deferred_push_configurations; + break; + case MENU_LABEL_VIDEO_SHADER_PRESET: + cbs->action_deferred_push = deferred_push_video_shader_preset; + break; + case MENU_LABEL_VIDEO_SHADER_PASS: + cbs->action_deferred_push = deferred_push_video_shader_pass; + break; + case MENU_LABEL_VIDEO_FILTER: + cbs->action_deferred_push = deferred_push_video_filter; + break; + case MENU_LABEL_MENU_WALLPAPER: + cbs->action_deferred_push = deferred_push_images; + break; + case MENU_LABEL_AUDIO_DSP_PLUGIN: + cbs->action_deferred_push = deferred_push_audio_dsp_plugin; + break; + case MENU_LABEL_INPUT_OVERLAY: + cbs->action_deferred_push = deferred_push_input_overlay; + break; + case MENU_LABEL_INPUT_OSK_OVERLAY: + cbs->action_deferred_push = deferred_push_input_osk_overlay; + break; + case MENU_LABEL_VIDEO_FONT_PATH: + cbs->action_deferred_push = deferred_push_video_font_path; + break; + case MENU_LABEL_CONTENT_HISTORY_PATH: + cbs->action_deferred_push = deferred_push_content_history_path; + break; + case MENU_LABEL_DETECT_CORE_LIST: + cbs->action_deferred_push = deferred_push_detect_core_list; + break; + } + } } diff --git a/menu/menu_entries_cbs_down.c b/menu/menu_entries_cbs_down.c index 22c5613274..ffe05589f0 100644 --- a/menu/menu_entries_cbs_down.c +++ b/menu/menu_entries_cbs_down.c @@ -36,7 +36,8 @@ static int action_bind_down_generic(unsigned type, const char *label) void menu_entries_cbs_init_bind_down(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1) + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash) { if (!cbs) return; diff --git a/menu/menu_entries_cbs_info.c b/menu/menu_entries_cbs_info.c index e2518cb642..b1d0ba3b9e 100644 --- a/menu/menu_entries_cbs_info.c +++ b/menu/menu_entries_cbs_info.c @@ -31,7 +31,8 @@ static int action_info_default(unsigned type, const char *label) void menu_entries_cbs_init_bind_info(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1) + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash) { if (!cbs) return; diff --git a/menu/menu_entries_cbs_iterate.c b/menu/menu_entries_cbs_iterate.c index 37d2cc8b51..f762fe057a 100644 --- a/menu/menu_entries_cbs_iterate.c +++ b/menu/menu_entries_cbs_iterate.c @@ -14,7 +14,9 @@ */ #include +#include #include + #include "menu.h" #include "menu_display.h" #include "menu_entry.h" @@ -263,7 +265,7 @@ static int action_iterate_load_open_zip(const char *label, char *s, size_t len, return 0; } -static int action_iterate_menu_viewport(char *s, size_t len, const char *label, unsigned action) +static int action_iterate_menu_viewport(char *s, size_t len, const char *label, unsigned action, uint32_t hash) { int stride_x = 1, stride_y = 1; menu_displaylist_info_t info = {0}; @@ -344,7 +346,7 @@ static int action_iterate_menu_viewport(char *s, size_t len, const char *label, case MENU_ACTION_CANCEL: menu_list_pop_stack(menu_list); - if (!strcmp(label, "custom_viewport_2")) + if (hash == MENU_LABEL_CUSTOM_VIEWPORT_2) { info.list = menu_list->menu_stack; info.type = MENU_SETTINGS_CUSTOM_VIEWPORT; @@ -424,7 +426,7 @@ static int action_iterate_menu_viewport(char *s, size_t len, const char *label, { if (type == MENU_SETTINGS_CUSTOM_VIEWPORT) base_msg = "Set Upper-Left Corner"; - else if (!strcmp(label, "custom_viewport_2")) + else if (hash == MENU_LABEL_CUSTOM_VIEWPORT_2) base_msg = "Set Bottom-Right Corner"; snprintf(s, len, "%s (%d, %d : %4ux%4u)", @@ -457,27 +459,27 @@ enum action_iterate_type ITERATE_TYPE_BIND, }; -enum action_iterate_type action_iterate_type(const char *label) +static enum action_iterate_type action_iterate_type(uint32_t hash) { - if (!strcmp(label, "help")) - return ITERATE_TYPE_HELP; - else if (!strcmp(label, "info_screen")) - return ITERATE_TYPE_INFO; - else if (!strcmp(label, "load_open_zip")) - return ITERATE_TYPE_ZIP; - else if (!strcmp(label, "message")) - return ITERATE_TYPE_MESSAGE; - else if ( - !strcmp(label, "custom_viewport_1") || - !strcmp(label, "custom_viewport_2") - ) - return ITERATE_TYPE_VIEWPORT; - else if ( - !strcmp(label, "custom_bind") || - !strcmp(label, "custom_bind_all") || - !strcmp(label, "custom_bind_defaults") - ) - return ITERATE_TYPE_BIND; + switch (hash) + { + case MENU_LABEL_HELP: + return ITERATE_TYPE_HELP; + case MENU_LABEL_INFO_SCREEN: + return ITERATE_TYPE_INFO; + case MENU_LABEL_LOAD_OPEN_ZIP: + return ITERATE_TYPE_ZIP; + case MENU_LABEL_MESSAGE: + return ITERATE_TYPE_MESSAGE; + case MENU_LABEL_CUSTOM_VIEWPORT_1: + case MENU_LABEL_CUSTOM_VIEWPORT_2: + return ITERATE_TYPE_VIEWPORT; + case MENU_LABEL_CUSTOM_BIND: + case MENU_LABEL_CUSTOM_BIND_ALL: + case MENU_LABEL_CUSTOM_BIND_DEFAULTS: + return ITERATE_TYPE_BIND; + } + return ITERATE_TYPE_DEFAULT; } @@ -495,10 +497,11 @@ static int action_iterate_main(const char *label, unsigned action) int ret = 0; menu_handle_t *menu = menu_driver_get_ptr(); menu_list_t *menu_list = menu_list_get_ptr(); + uint32_t hash = djb2_calculate(label); if (!menu || !menu_list) return 0; - iterate_type = action_iterate_type(label); + iterate_type = action_iterate_type(hash); switch (iterate_type) { @@ -514,7 +517,7 @@ static int action_iterate_main(const char *label, unsigned action) menu_list_pop_stack(menu_list); break; case ITERATE_TYPE_VIEWPORT: - ret = action_iterate_menu_viewport(msg, sizeof(msg), label, action); + ret = action_iterate_menu_viewport(msg, sizeof(msg), label, action, hash); break; case ITERATE_TYPE_INFO: ret = action_iterate_info(msg, sizeof(msg), label); @@ -578,7 +581,8 @@ static int action_iterate_main(const char *label, unsigned action) void menu_entries_cbs_init_bind_iterate(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1) + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash) { if (cbs) cbs->action_iterate = action_iterate_main; diff --git a/menu/menu_entries_cbs_left.c b/menu/menu_entries_cbs_left.c index 8f2ab3ce5a..6549684817 100644 --- a/menu/menu_entries_cbs_left.c +++ b/menu/menu_entries_cbs_left.c @@ -14,6 +14,7 @@ */ #include + #include "menu.h" #include "menu_entries_cbs.h" #include "menu_setting.h" @@ -350,7 +351,8 @@ static int bind_left_generic(unsigned type, const char *label, void menu_entries_cbs_init_bind_left(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1, const char *menu_label) + const char *elem0, const char *elem1, const char *menu_label, + uint32_t label_hash, uint32_t menu_label_hash) { int i; @@ -393,11 +395,16 @@ void menu_entries_cbs_init_bind_left(menu_file_list_cbs_t *cbs, case MENU_FILE_CHEAT: case MENU_FILE_REMAP: case MENU_SETTING_GROUP: - if (!strcmp(menu_label, "Horizontal Menu") - || !strcmp(menu_label, "Main Menu")) - cbs->action_left = action_left_mainmenu; - else - cbs->action_left = action_left_scroll; + switch (menu_label_hash) + { + case MENU_VALUE_HORIZONTAL_MENU: + case MENU_VALUE_MAIN_MENU: + cbs->action_left = action_left_mainmenu; + break; + default: + cbs->action_left = action_left_scroll; + break; + } break; case MENU_SETTING_ACTION: case MENU_FILE_CONTENTLIST_ENTRY: @@ -420,23 +427,35 @@ void menu_entries_cbs_init_bind_left(menu_file_list_cbs_t *cbs, else if (type >= MENU_SETTINGS_INPUT_DESC_BEGIN && type <= MENU_SETTINGS_INPUT_DESC_END) cbs->action_left = action_left_input_desc; - else if (!strcmp(label, "savestate") || - !strcmp(label, "loadstate")) - cbs->action_left = action_left_save_state; - else if (!strcmp(label, "video_shader_scale_pass")) - cbs->action_left = action_left_shader_scale_pass; - else if (!strcmp(label, "video_shader_filter_pass")) - cbs->action_left = action_left_shader_filter_pass; - else if (!strcmp(label, "video_shader_default_filter")) - cbs->action_left = action_left_shader_filter_default; - else if (!strcmp(label, "video_shader_num_passes")) - cbs->action_left = action_left_shader_num_passes; - else if (!strcmp(label, "cheat_num_passes")) - cbs->action_left = action_left_cheat_num_passes; else if (type == MENU_SETTINGS_VIDEO_RESOLUTION) cbs->action_left = action_left_video_resolution; else if ((type >= MENU_SETTINGS_CORE_OPTION_START)) cbs->action_left = core_setting_left; + else + { + switch (label_hash) + { + case MENU_LABEL_SAVESTATE: + case MENU_LABEL_LOADSTATE: + cbs->action_left = action_left_save_state; + break; + case MENU_LABEL_VIDEO_SHADER_SCALE_PASS: + cbs->action_left = action_left_shader_scale_pass; + break; + case MENU_LABEL_VIDEO_SHADER_FILTER_PASS: + cbs->action_left = action_left_shader_filter_pass; + break; + case MENU_LABEL_VIDEO_SHADER_DEFAULT_FILTER: + cbs->action_left = action_left_shader_filter_default; + break; + case MENU_LABEL_VIDEO_SHADER_NUM_PASSES: + cbs->action_left = action_left_shader_num_passes; + break; + case MENU_LABEL_CHEAT_NUM_PASSES: + cbs->action_left = action_left_cheat_num_passes; + break; + } + } for (i = 0; i < MAX_USERS; i++) { diff --git a/menu/menu_entries_cbs_ok.c b/menu/menu_entries_cbs_ok.c index f0c3638203..b2bb9e9a07 100644 --- a/menu/menu_entries_cbs_ok.c +++ b/menu/menu_entries_cbs_ok.c @@ -14,6 +14,7 @@ */ #include + #include "menu.h" #include "menu_display.h" #include "menu_entries_cbs.h" @@ -21,6 +22,7 @@ #include "menu_entry.h" #include "menu_shader.h" #include "menu_navigation.h" +#include "menu_entries_cbs.h" #include "../retroarch.h" #include "../runloop_data.h" @@ -1398,165 +1400,176 @@ static int action_ok_video_resolution(const char *path, return 0; } -static int is_rdb_entry(const char *label) +static int is_rdb_entry(uint32_t label_hash) { - return ( - !(strcmp(label, "rdb_entry_publisher")) || - !(strcmp(label, "rdb_entry_developer")) || - !(strcmp(label, "rdb_entry_origin")) || - !(strcmp(label, "rdb_entry_franchise")) || - !(strcmp(label, "rdb_entry_enhancement_hw")) || - !(strcmp(label, "rdb_entry_esrb_rating")) || - !(strcmp(label, "rdb_entry_bbfc_rating")) || - !(strcmp(label, "rdb_entry_elspa_rating")) || - !(strcmp(label, "rdb_entry_pegi_rating")) || - !(strcmp(label, "rdb_entry_cero_rating")) || - !(strcmp(label, "rdb_entry_edge_magazine_rating")) || - !(strcmp(label, "rdb_entry_edge_magazine_issue")) || - !(strcmp(label, "rdb_entry_famitsu_magazine_rating")) || - !(strcmp(label, "rdb_entry_releasemonth")) || - !(strcmp(label, "rdb_entry_releaseyear")) || - !(strcmp(label, "rdb_entry_max_users")) - ); -} - -void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs, - const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1, const char *menu_label) -{ - rarch_setting_t *setting = menu_setting_find(label); - menu_handle_t *menu = menu_driver_get_ptr(); - - if (!cbs) - return; - if (!menu) - return; - -#if 0 - RARCH_LOG("path: %s, label: %s, elem0 : %s, elem1: %s\n", path, label, elem0, elem1); -#endif - - cbs->action_ok = action_ok_lookup_setting; - - if (elem0[0] != '\0' && is_rdb_entry(elem0)) + switch (label_hash) { - cbs->action_ok = action_ok_rdb_entry_submenu; - return; + case MENU_LABEL_RDB_ENTRY_PUBLISHER: + case MENU_LABEL_RDB_ENTRY_DEVELOPER: + case MENU_LABEL_RDB_ENTRY_ORIGIN: + case MENU_LABEL_RDB_ENTRY_FRANCHISE: + case MENU_LABEL_RDB_ENTRY_ENHANCEMENT_HW: + case MENU_LABEL_RDB_ENTRY_ESRB_RATING: + case MENU_LABEL_RDB_ENTRY_BBFC_RATING: + case MENU_LABEL_RDB_ENTRY_ELSPA_RATING: + case MENU_LABEL_RDB_ENTRY_PEGI_RATING: + case MENU_LABEL_RDB_ENTRY_CERO_RATING: + case MENU_LABEL_RDB_ENTRY_EDGE_MAGAZINE_RATING: + case MENU_LABEL_RDB_ENTRY_EDGE_MAGAZINE_ISSUE: + case MENU_LABEL_RDB_ENTRY_FAMITSU_MAGAZINE_RATING: + case MENU_LABEL_RDB_ENTRY_RELEASE_MONTH: + case MENU_LABEL_RDB_ENTRY_RELEASE_YEAR: + case MENU_LABEL_RDB_ENTRY_MAX_USERS: + break; + default: + return -1; } - if (!strcmp(label, "custom_bind_all")) - cbs->action_ok = action_ok_lookup_setting; - else if (type == MENU_SETTINGS_CUSTOM_BIND_KEYBOARD || - type == MENU_SETTINGS_CUSTOM_BIND) - cbs->action_ok = action_ok_lookup_setting; - else if (type >= MENU_SETTINGS_SHADER_PARAMETER_0 - && type <= MENU_SETTINGS_SHADER_PARAMETER_LAST) - cbs->action_ok = NULL; - else if (type >= MENU_SETTINGS_SHADER_PRESET_PARAMETER_0 - && type <= MENU_SETTINGS_SHADER_PRESET_PARAMETER_LAST) - cbs->action_ok = NULL; - else if (type >= MENU_SETTINGS_CHEAT_BEGIN - && type <= MENU_SETTINGS_CHEAT_END) - cbs->action_ok = action_ok_cheat; - else if (!strcmp(label, "savestate")) - cbs->action_ok = action_ok_save_state; - else if (!strcmp(label, "loadstate")) - cbs->action_ok = action_ok_load_state; - else if (!strcmp(label, "resume_content")) - cbs->action_ok = action_ok_resume_content; - else if (!strcmp(label, "restart_content")) - cbs->action_ok = action_ok_restart_content; - else if (!strcmp(label, "take_screenshot")) - cbs->action_ok = action_ok_screenshot; - else if (!strcmp(label, "file_load_or_resume")) - cbs->action_ok = action_ok_file_load_or_resume; - else if (!strcmp(label, "quit_retroarch")) - cbs->action_ok = action_ok_quit; - else if (!strcmp(label, "unload_core")) - cbs->action_ok = action_ok_unload_core; - else if (!strcmp(label, "save_new_config")) - cbs->action_ok = action_ok_save_new_config; - else if (!strcmp(label, "help")) - cbs->action_ok = action_ok_help; - else if (!strcmp(label, "video_shader_pass")) - cbs->action_ok = action_ok_shader_pass; - else if (!strcmp(label, "video_shader_preset")) - cbs->action_ok = action_ok_shader_preset; - else if (!strcmp(label, "cheat_file_load")) - cbs->action_ok = action_ok_cheat_file; - else if (!strcmp(label, "audio_dsp_plugin")) - cbs->action_ok = action_ok_audio_dsp_plugin; - else if (!strcmp(label, "video_filter")) - cbs->action_ok = action_ok_video_filter; - else if (!strcmp(label, "remap_file_load")) - cbs->action_ok = action_ok_remap_file; - else if (!strcmp(label, "record_config")) - cbs->action_ok = action_ok_record_configfile; - else if (!strcmp(label, "core_updater_list")) - cbs->action_ok = action_ok_core_updater_list; - else if (!strcmp(label, "video_shader_parameters") || - !strcmp(label, "video_shader_preset_parameters") - ) - cbs->action_ok = action_ok_shader_parameters; - else if ( - !strcmp(label, "shader_options") || - !strcmp(label, "video_options") || - !strcmp(label, "Input Settings") || - !strcmp(label, "core_options") || - !strcmp(label, "core_cheat_options") || - !strcmp(label, "core_input_remapping_options") || - !strcmp(label, "core_information") || - !strcmp(label, "system_information") || - !strcmp(label, "disk_options") || - !strcmp(label, "settings") || - !strcmp(label, "performance_counters") || - !strcmp(label, "frontend_counters") || - !strcmp(label, "core_counters") || - !strcmp(label, "management") || - !strcmp(label, "options") - ) - cbs->action_ok = action_ok_push_default; - else if ( - !strcmp(label, "load_content") || - !strcmp(label, "detect_core_list") - ) - cbs->action_ok = action_ok_push_content_list; - else if (!strcmp(label, "history_list") || - !strcmp(label, "cursor_manager_list") || - !strcmp(label, "database_manager_list") || - (setting && setting->browser_selection_type == ST_DIR) - ) - cbs->action_ok = action_ok_push_generic_list; - else if (!strcmp(label, "shader_apply_changes")) - cbs->action_ok = action_ok_shader_apply_changes; - else if (!strcmp(label, "cheat_apply_changes")) - cbs->action_ok = action_ok_cheat_apply_changes; - else if (!strcmp(label, "video_shader_preset_save_as")) - cbs->action_ok = action_ok_shader_preset_save_as; - else if (!strcmp(label, "cheat_file_save_as")) - cbs->action_ok = action_ok_cheat_file_save_as; - else if (!strcmp(label, "remap_file_save_as")) - cbs->action_ok = action_ok_remap_file_save_as; - else if (!strcmp(label, "remap_file_save_core")) - cbs->action_ok = action_ok_remap_file_save_core; - else if (!strcmp(label, "remap_file_save_game")) - cbs->action_ok = action_ok_remap_file_save_game; - else if (!strcmp(label, "content_collection_list")) - cbs->action_ok = action_ok_content_collection_list; - else if (!strcmp(label, "core_list")) - cbs->action_ok = action_ok_core_list; - else if (!strcmp(label, "disk_image_append")) - cbs->action_ok = action_ok_disk_image_append_list; - else if (!strcmp(label, "configurations")) - cbs->action_ok = action_ok_configurations_list; - else + return 0; +} + +static int menu_entries_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, + uint32_t hash) +{ + switch (hash) + { + case MENU_LABEL_CUSTOM_BIND_ALL: + cbs->action_ok = action_ok_lookup_setting; + break; + case MENU_LABEL_SAVESTATE: + cbs->action_ok = action_ok_save_state; + break; + case MENU_LABEL_LOADSTATE: + cbs->action_ok = action_ok_load_state; + break; + case MENU_LABEL_RESUME_CONTENT: + cbs->action_ok = action_ok_resume_content; + break; + case MENU_LABEL_RESTART_CONTENT: + cbs->action_ok = action_ok_restart_content; + break; + case MENU_LABEL_TAKE_SCREENSHOT: + cbs->action_ok = action_ok_screenshot; + break; + case MENU_LABEL_FILE_LOAD_OR_RESUME: + cbs->action_ok = action_ok_file_load_or_resume; + break; + case MENU_LABEL_QUIT_RETROARCH: + cbs->action_ok = action_ok_quit; + break; + case MENU_LABEL_UNLOAD_CORE: + cbs->action_ok = action_ok_unload_core; + break; + case MENU_LABEL_SAVE_NEW_CONFIG: + cbs->action_ok = action_ok_save_new_config; + break; + case MENU_LABEL_HELP: + cbs->action_ok = action_ok_help; + break; + case MENU_LABEL_VIDEO_SHADER_PASS: + cbs->action_ok = action_ok_shader_pass; + break; + case MENU_LABEL_VIDEO_SHADER_PRESET: + cbs->action_ok = action_ok_shader_preset; + break; + case MENU_LABEL_CHEAT_FILE_LOAD: + cbs->action_ok = action_ok_cheat_file; + break; + case MENU_LABEL_AUDIO_DSP_PLUGIN: + cbs->action_ok = action_ok_audio_dsp_plugin; + break; + case MENU_LABEL_VIDEO_FILTER: + cbs->action_ok = action_ok_video_filter; + break; + case MENU_LABEL_REMAP_FILE_LOAD: + cbs->action_ok = action_ok_remap_file; + break; + case MENU_LABEL_RECORD_CONFIG: + cbs->action_ok = action_ok_record_configfile; + break; + case MENU_LABEL_CORE_UPDATER_LIST: + cbs->action_ok = action_ok_core_updater_list; + break; + case MENU_LABEL_VIDEO_SHADER_PARAMETERS: + case MENU_LABEL_VIDEO_SHADER_PRESET_PARAMETERS: + cbs->action_ok = action_ok_shader_parameters; + break; + case MENU_LABEL_SHADER_OPTIONS: + case MENU_LABEL_VIDEO_OPTIONS: + case MENU_VALUE_INPUT_SETTINGS: + case MENU_LABEL_CORE_OPTIONS: + case MENU_LABEL_CORE_CHEAT_OPTIONS: + case MENU_LABEL_CORE_INPUT_REMAPPING_OPTIONS: + case MENU_LABEL_CORE_INFORMATION: + case MENU_LABEL_SYSTEM_INFORMATION: + case MENU_LABEL_DISK_OPTIONS: + case MENU_LABEL_SETTINGS: + case MENU_LABEL_PERFORMANCE_COUNTERS: + case MENU_LABEL_FRONTEND_COUNTERS: + case MENU_LABEL_CORE_COUNTERS: + case MENU_LABEL_MANAGEMENT: + case MENU_LABEL_OPTIONS: + cbs->action_ok = action_ok_push_default; + break; + case MENU_LABEL_LOAD_CONTENT: + case MENU_LABEL_DETECT_CORE_LIST: + cbs->action_ok = action_ok_push_content_list; + break; + case MENU_LABEL_HISTORY_LIST: + case MENU_LABEL_CURSOR_MANAGER_LIST: + case MENU_LABEL_DATABASE_MANAGER_LIST: + cbs->action_ok = action_ok_push_generic_list; + break; + case MENU_LABEL_SHADER_APPLY_CHANGES: + cbs->action_ok = action_ok_shader_apply_changes; + break; + case MENU_LABEL_CHEAT_APPLY_CHANGES: + cbs->action_ok = action_ok_cheat_apply_changes; + break; + case MENU_LABEL_VIDEO_SHADER_PRESET_SAVE_AS: + cbs->action_ok = action_ok_shader_preset_save_as; + break; + case MENU_LABEL_CHEAT_FILE_SAVE_AS: + cbs->action_ok = action_ok_cheat_file_save_as; + break; + case MENU_LABEL_REMAP_FILE_SAVE_AS: + cbs->action_ok = action_ok_remap_file_save_as; + break; + case MENU_LABEL_REMAP_FILE_SAVE_CORE: + cbs->action_ok = action_ok_remap_file_save_core; + break; + case MENU_LABEL_REMAP_FILE_SAVE_GAME: + cbs->action_ok = action_ok_remap_file_save_game; + break; + case MENU_LABEL_CONTENT_COLLECTION_LIST: + cbs->action_ok = action_ok_content_collection_list; + break; + case MENU_LABEL_CORE_LIST: + cbs->action_ok = action_ok_core_list; + break; + case MENU_LABEL_DISK_IMAGE_APPEND: + cbs->action_ok = action_ok_disk_image_append_list; + break; + case MENU_LABEL_CONFIGURATIONS: + cbs->action_ok = action_ok_configurations_list; + break; + default: + return -1; + } + + return 0; +} + +static int menu_entries_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs, + uint32_t label_hash, uint32_t menu_label_hash, unsigned type) +{ switch (type) { case MENU_SETTINGS_VIDEO_RESOLUTION: cbs->action_ok = action_ok_video_resolution; break; case MENU_FILE_PLAYLIST_ENTRY: - cbs->action_ok = action_ok_playlist_entry; + cbs->action_ok = action_ok_playlist_entry; break; case MENU_FILE_PLAYLIST_COLLECTION: cbs->action_ok = action_ok_playlist_collection; @@ -1595,16 +1608,23 @@ void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs, cbs->action_ok = action_ok_compressed_archive_push; break; case MENU_FILE_CORE: - if (!strcmp(menu_label, "deferred_core_list")) + if (label_hash == MENU_LABEL_DEFERRED_CORE_LIST) cbs->action_ok = action_ok_core_load_deferred; - else if (!strcmp(menu_label, "deferred_core_list_set")) - cbs->action_ok = action_ok_core_deferred_set; - else if (!strcmp(menu_label, "core_list")) - cbs->action_ok = action_ok_core_load; - else if (!strcmp(menu_label, "core_updater_list")) - cbs->action_ok = action_ok_core_download; else - return; + { + switch (menu_label_hash) + { + case MENU_LABEL_DEFERRED_CORE_LIST_SET: + cbs->action_ok = action_ok_core_deferred_set; + break; + case MENU_LABEL_CORE_LIST: + cbs->action_ok = action_ok_core_load; + break; + case MENU_LABEL_CORE_UPDATER_LIST: + cbs->action_ok = action_ok_core_download; + break; + } + } break; case MENU_FILE_DOWNLOAD_CORE: cbs->action_ok = action_ok_core_updater_download; @@ -1612,22 +1632,30 @@ void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs, case MENU_FILE_DOWNLOAD_CORE_INFO: break; case MENU_FILE_RDB: - if (!strcmp(menu_label, "deferred_database_manager_list")) - cbs->action_ok = action_ok_database_manager_list_deferred; - else if (!strcmp(menu_label, "database_manager_list") - || !strcmp(menu_label, "Horizontal Menu")) - cbs->action_ok = action_ok_database_manager_list; - else - return; + switch (menu_label_hash) + { + case MENU_LABEL_DEFERRED_DATABASE_MANAGER_LIST: + cbs->action_ok = action_ok_database_manager_list_deferred; + break; + case MENU_LABEL_DATABASE_MANAGER_LIST: + case MENU_VALUE_HORIZONTAL_MENU: + cbs->action_ok = action_ok_database_manager_list; + break; + } break; case MENU_FILE_RDB_ENTRY: cbs->action_ok = action_ok_rdb_entry; break; case MENU_FILE_CURSOR: - if (!strcmp(menu_label, "deferred_database_manager_list")) - cbs->action_ok = action_ok_cursor_manager_list_deferred; - else if (!strcmp(menu_label, "cursor_manager_list")) - cbs->action_ok = action_ok_cursor_manager_list; + switch (menu_label_hash) + { + case MENU_LABEL_DEFERRED_DATABASE_MANAGER_LIST: + cbs->action_ok = action_ok_cursor_manager_list_deferred; + break; + case MENU_LABEL_CURSOR_MANAGER_LIST: + cbs->action_ok = action_ok_cursor_manager_list; + break; + } break; case MENU_FILE_FONT: case MENU_FILE_OVERLAY: @@ -1641,12 +1669,18 @@ void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs, case MENU_FILE_IN_CARCHIVE: #endif case MENU_FILE_PLAIN: - if (!strcmp(menu_label, "detect_core_list")) - cbs->action_ok = action_ok_file_load_with_detect_core; - else if (!strcmp(menu_label, "disk_image_append")) - cbs->action_ok = action_ok_disk_image_append; - else - cbs->action_ok = action_ok_file_load; + switch (menu_label_hash) + { + case MENU_LABEL_DETECT_CORE_LIST: + cbs->action_ok = action_ok_file_load_with_detect_core; + break; + case MENU_LABEL_DISK_IMAGE_APPEND: + cbs->action_ok = action_ok_disk_image_append; + break; + default: + cbs->action_ok = action_ok_file_load; + break; + } break; case MENU_SETTINGS_CUSTOM_VIEWPORT: cbs->action_ok = action_ok_custom_viewport; @@ -1660,6 +1694,56 @@ void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs, cbs->action_ok = action_ok_disk_cycle_tray_status; break; default: - return; + return -1; } + + return 0; +} + +void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs, + const char *path, const char *label, unsigned type, size_t idx, + const char *elem0, const char *elem1, const char *menu_label, + uint32_t label_hash, uint32_t menu_label_hash) +{ + rarch_setting_t *setting = menu_setting_find(label); + menu_handle_t *menu = menu_driver_get_ptr(); + + if (!cbs || !menu) + return; + +#if 0 + RARCH_LOG("path: %s, label: %s, elem0 : %s, elem1: %s\n", path, label, elem0, elem1); +#endif + + cbs->action_ok = action_ok_lookup_setting; + + if (elem0[0] != '\0' && (is_rdb_entry(label_hash) == 0)) + { + cbs->action_ok = action_ok_rdb_entry_submenu; + return; + } + + if (setting && setting->browser_selection_type == ST_DIR) + { + cbs->action_ok = action_ok_push_generic_list; + return; + + } + + if (type == MENU_SETTINGS_CUSTOM_BIND_KEYBOARD || + type == MENU_SETTINGS_CUSTOM_BIND) + cbs->action_ok = action_ok_lookup_setting; + else if (type >= MENU_SETTINGS_SHADER_PARAMETER_0 + && type <= MENU_SETTINGS_SHADER_PARAMETER_LAST) + cbs->action_ok = NULL; + else if (type >= MENU_SETTINGS_SHADER_PRESET_PARAMETER_0 + && type <= MENU_SETTINGS_SHADER_PRESET_PARAMETER_LAST) + cbs->action_ok = NULL; + else if (type >= MENU_SETTINGS_CHEAT_BEGIN + && type <= MENU_SETTINGS_CHEAT_END) + cbs->action_ok = action_ok_cheat; + else if (menu_entries_cbs_init_bind_ok_compare_label(cbs, label_hash) == 0) + return; + + menu_entries_cbs_init_bind_ok_compare_type(cbs, label_hash, menu_label_hash, type); } diff --git a/menu/menu_entries_cbs_refresh.c b/menu/menu_entries_cbs_refresh.c index b4aeabb48d..0d300da7cf 100644 --- a/menu/menu_entries_cbs_refresh.c +++ b/menu/menu_entries_cbs_refresh.c @@ -24,7 +24,8 @@ static int action_refresh_default(file_list_t *list, file_list_t *menu_list) void menu_entries_cbs_init_bind_refresh(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1) + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash) { if (cbs) cbs->action_refresh = action_refresh_default; diff --git a/menu/menu_entries_cbs_representation.c b/menu/menu_entries_cbs_representation.c index 078e1ef009..108ee5d52c 100644 --- a/menu/menu_entries_cbs_representation.c +++ b/menu/menu_entries_cbs_representation.c @@ -14,6 +14,8 @@ */ #include +#include + #include "menu.h" #include "menu_entries_cbs.h" #include "menu_shader.h" @@ -762,15 +764,18 @@ static void menu_action_setting_disp_set_label(file_list_t* list, char *s2, size_t len2) { global_t *global = global_get_ptr(); + uint32_t hash_label = djb2_calculate(label); *s = '\0'; *w = 19; - if (!strcmp(label, "performance_counters")) - *w = strlen(label); - - if (!strcmp(label, "history_list")) - *w = strlen(label); + switch (hash_label) + { + case MENU_LABEL_PERFORMANCE_COUNTERS: + case MENU_LABEL_HISTORY_LIST: + *w = strlen(label); + break; + } if (type >= MENU_SETTINGS_CORE_OPTION_START) strlcpy( @@ -785,9 +790,58 @@ static void menu_action_setting_disp_set_label(file_list_t* list, strlcpy(s2, path, len2); } +static int menu_entries_cbs_init_bind_get_string_representation_compare_label( + menu_file_list_cbs_t *cbs, uint32_t label_hash) +{ + switch (label_hash) + { + case MENU_LABEL_CHEAT_NUM_PASSES: + cbs->action_get_representation = + menu_action_setting_disp_set_label_cheat_num_passes; + break; + case MENU_LABEL_REMAP_FILE_LOAD: + cbs->action_get_representation = + menu_action_setting_disp_set_label_remap_file_load; + break; + case MENU_LABEL_VIDEO_SHADER_FILTER_PASS: + cbs->action_get_representation = + menu_action_setting_disp_set_label_shader_filter_pass; + break; + case MENU_LABEL_VIDEO_SHADER_SCALE_PASS: + cbs->action_get_representation = + menu_action_setting_disp_set_label_shader_scale_pass; + break; + case MENU_LABEL_VIDEO_SHADER_NUM_PASSES: + cbs->action_get_representation = + menu_action_setting_disp_set_label_shader_num_passes; + break; + case MENU_LABEL_VIDEO_SHADER_PASS: + cbs->action_get_representation = + menu_action_setting_disp_set_label_shader_pass; + break; + case MENU_LABEL_VIDEO_SHADER_DEFAULT_FILTER: + cbs->action_get_representation = + menu_action_setting_disp_set_label_shader_default_filter; + break; + case MENU_LABEL_VIDEO_FILTER: + cbs->action_get_representation = + menu_action_setting_disp_set_label_filter; + break; + case MENU_LABEL_CONFIGURATIONS: + cbs->action_get_representation = + menu_action_setting_disp_set_label_configurations; + break; + default: + return - 1; + } + + return 0; +} + void menu_entries_cbs_init_bind_get_string_representation(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1) + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash) { if (!cbs) return; @@ -816,124 +870,97 @@ void menu_entries_cbs_init_bind_get_string_representation(menu_file_list_cbs_t * && type <= MENU_SETTINGS_SHADER_PARAMETER_LAST) cbs->action_get_representation = menu_action_setting_disp_set_label_shader_parameter; - else if (!strcmp(label, "cheat_num_passes")) - cbs->action_get_representation = - menu_action_setting_disp_set_label_cheat_num_passes; - else if (!strcmp(label, "remap_file_load")) - cbs->action_get_representation = - menu_action_setting_disp_set_label_remap_file_load; - else if (!strcmp(label, "video_shader_filter_pass")) - cbs->action_get_representation = - menu_action_setting_disp_set_label_shader_filter_pass; - else if (!strcmp(label, "video_shader_scale_pass")) - cbs->action_get_representation = - menu_action_setting_disp_set_label_shader_scale_pass; - else if (!strcmp(label, "video_shader_num_passes")) - cbs->action_get_representation = - menu_action_setting_disp_set_label_shader_num_passes; - else if (!strcmp(label, "video_shader_pass")) - cbs->action_get_representation = - menu_action_setting_disp_set_label_shader_pass; - else if (!strcmp(label, "video_shader_default_filter")) - cbs->action_get_representation = - menu_action_setting_disp_set_label_shader_default_filter; - else if (!strcmp(label, "video_filter")) - cbs->action_get_representation = - menu_action_setting_disp_set_label_filter; - else if (!strcmp(label, "configurations")) - cbs->action_get_representation = - menu_action_setting_disp_set_label_configurations; - else + else if (menu_entries_cbs_init_bind_get_string_representation_compare_label(cbs, label_hash) == 0) + return; + + switch (type) { - switch (type) - { - case MENU_FILE_CORE: - cbs->action_get_representation = - menu_action_setting_disp_set_label_menu_file_core; - break; - case MENU_FILE_PLAIN: - cbs->action_get_representation = - menu_action_setting_disp_set_label_menu_file_plain; - break; - case MENU_FILE_IMAGE: - cbs->action_get_representation = - menu_action_setting_disp_set_label_menu_file_image; - break; - case MENU_FILE_USE_DIRECTORY: - cbs->action_get_representation = - menu_action_setting_disp_set_label_menu_file_use_directory; - break; - case MENU_FILE_DIRECTORY: - cbs->action_get_representation = - menu_action_setting_disp_set_label_menu_file_directory; - break; - case MENU_FILE_CARCHIVE: - cbs->action_get_representation = - menu_action_setting_disp_set_label_menu_file_carchive; - break; - case MENU_FILE_OVERLAY: - cbs->action_get_representation = - menu_action_setting_disp_set_label_menu_file_overlay; - break; - case MENU_FILE_FONT: - cbs->action_get_representation = - menu_action_setting_disp_set_label_menu_file_font; - break; - case MENU_FILE_SHADER: - cbs->action_get_representation = - menu_action_setting_disp_set_label_menu_file_shader; - break; - case MENU_FILE_SHADER_PRESET: - cbs->action_get_representation = - menu_action_setting_disp_set_label_menu_file_shader_preset; - break; - case MENU_FILE_CONFIG: - cbs->action_get_representation = - menu_action_setting_disp_set_label_menu_file_config; - break; - case MENU_FILE_IN_CARCHIVE: - cbs->action_get_representation = - menu_action_setting_disp_set_label_menu_file_in_carchive; - break; - case MENU_FILE_VIDEOFILTER: - case MENU_FILE_AUDIOFILTER: - cbs->action_get_representation = - menu_action_setting_disp_set_label_menu_file_filter; - break; - case MENU_FILE_DOWNLOAD_CORE: - cbs->action_get_representation = - menu_action_setting_disp_set_label_menu_file_url; - break; - case MENU_FILE_RDB: - cbs->action_get_representation = - menu_action_setting_disp_set_label_menu_file_rdb; - break; - case MENU_FILE_CURSOR: - cbs->action_get_representation = - menu_action_setting_disp_set_label_menu_file_cursor; - break; - case MENU_FILE_CHEAT: - cbs->action_get_representation = - menu_action_setting_disp_set_label_menu_file_cheat; - break; - case MENU_SETTING_SUBGROUP: - case MENU_SETTINGS_CUSTOM_VIEWPORT: - case MENU_SETTINGS_CUSTOM_BIND_ALL: - case MENU_SETTINGS_CUSTOM_BIND_DEFAULT_ALL: - cbs->action_get_representation = - menu_action_setting_disp_set_label_menu_more; - break; - case MENU_SETTINGS_CORE_DISK_OPTIONS_DISK_INDEX: - cbs->action_get_representation = - menu_action_setting_disp_set_label_menu_disk_index; - break; - case MENU_SETTINGS_VIDEO_RESOLUTION: - cbs->action_get_representation = - menu_action_setting_disp_set_label_menu_video_resolution; - break; - default: - cbs->action_get_representation = menu_action_setting_disp_set_label; - break; - } + case MENU_FILE_CORE: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_file_core; + break; + case MENU_FILE_PLAIN: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_file_plain; + break; + case MENU_FILE_IMAGE: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_file_image; + break; + case MENU_FILE_USE_DIRECTORY: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_file_use_directory; + break; + case MENU_FILE_DIRECTORY: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_file_directory; + break; + case MENU_FILE_CARCHIVE: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_file_carchive; + break; + case MENU_FILE_OVERLAY: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_file_overlay; + break; + case MENU_FILE_FONT: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_file_font; + break; + case MENU_FILE_SHADER: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_file_shader; + break; + case MENU_FILE_SHADER_PRESET: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_file_shader_preset; + break; + case MENU_FILE_CONFIG: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_file_config; + break; + case MENU_FILE_IN_CARCHIVE: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_file_in_carchive; + break; + case MENU_FILE_VIDEOFILTER: + case MENU_FILE_AUDIOFILTER: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_file_filter; + break; + case MENU_FILE_DOWNLOAD_CORE: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_file_url; + break; + case MENU_FILE_RDB: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_file_rdb; + break; + case MENU_FILE_CURSOR: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_file_cursor; + break; + case MENU_FILE_CHEAT: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_file_cheat; + break; + case MENU_SETTING_SUBGROUP: + case MENU_SETTINGS_CUSTOM_VIEWPORT: + case MENU_SETTINGS_CUSTOM_BIND_ALL: + case MENU_SETTINGS_CUSTOM_BIND_DEFAULT_ALL: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_more; + break; + case MENU_SETTINGS_CORE_DISK_OPTIONS_DISK_INDEX: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_disk_index; + break; + case MENU_SETTINGS_VIDEO_RESOLUTION: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_video_resolution; + break; + default: + cbs->action_get_representation = menu_action_setting_disp_set_label; + break; } } diff --git a/menu/menu_entries_cbs_right.c b/menu/menu_entries_cbs_right.c index b908e2239b..3539a19ab4 100644 --- a/menu/menu_entries_cbs_right.c +++ b/menu/menu_entries_cbs_right.c @@ -14,6 +14,7 @@ */ #include + #include "menu.h" #include "menu_entries_cbs.h" #include "menu_setting.h" @@ -353,7 +354,8 @@ static int bind_right_generic(unsigned type, const char *label, void menu_entries_cbs_init_bind_right(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1, const char *menu_label) + const char *elem0, const char *elem1, const char *menu_label, + uint32_t label_hash, uint32_t menu_label_hash) { int i; @@ -396,12 +398,16 @@ void menu_entries_cbs_init_bind_right(menu_file_list_cbs_t *cbs, case MENU_FILE_CHEAT: case MENU_FILE_REMAP: case MENU_SETTING_GROUP: - if (!strcmp(menu_label, "Horizontal Menu") - || !strcmp(menu_label, "Main Menu")) - cbs->action_right = action_right_mainmenu; - else - cbs->action_right = action_right_scroll; - break; + switch (menu_label_hash) + { + case MENU_VALUE_HORIZONTAL_MENU: + case MENU_VALUE_MAIN_MENU: + cbs->action_right = action_right_mainmenu; + break; + default: + cbs->action_right = action_right_scroll; + break; + } case MENU_SETTING_ACTION: case MENU_FILE_CONTENTLIST_ENTRY: cbs->action_right = action_right_mainmenu; @@ -423,23 +429,35 @@ void menu_entries_cbs_init_bind_right(menu_file_list_cbs_t *cbs, else if (type >= MENU_SETTINGS_INPUT_DESC_BEGIN && type <= MENU_SETTINGS_INPUT_DESC_END) cbs->action_right = action_right_input_desc; - else if (!strcmp(label, "savestate") || - !strcmp(label, "loadstate")) - cbs->action_right = action_right_save_state; - else if (!strcmp(label, "video_shader_scale_pass")) - cbs->action_right = action_right_shader_scale_pass; - else if (!strcmp(label, "video_shader_filter_pass")) - cbs->action_right = action_right_shader_filter_pass; - else if (!strcmp(label, "video_shader_default_filter")) - cbs->action_right = action_right_shader_filter_default; - else if (!strcmp(label, "video_shader_num_passes")) - cbs->action_right = action_right_shader_num_passes; - else if (!strcmp(label, "cheat_num_passes")) - cbs->action_right = action_right_cheat_num_passes; else if (type == MENU_SETTINGS_VIDEO_RESOLUTION) cbs->action_right = action_right_video_resolution; else if ((type >= MENU_SETTINGS_CORE_OPTION_START)) cbs->action_right = core_setting_right; + else + { + switch (label_hash) + { + case MENU_LABEL_SAVESTATE: + case MENU_LABEL_LOADSTATE: + cbs->action_right = action_right_save_state; + break; + case MENU_LABEL_VIDEO_SHADER_SCALE_PASS: + cbs->action_right = action_right_shader_scale_pass; + break; + case MENU_LABEL_VIDEO_SHADER_FILTER_PASS: + cbs->action_right = action_right_shader_filter_pass; + break; + case MENU_LABEL_VIDEO_SHADER_DEFAULT_FILTER: + cbs->action_right = action_right_shader_filter_default; + break; + case MENU_LABEL_VIDEO_SHADER_NUM_PASSES: + cbs->action_right = action_right_shader_num_passes; + break; + case MENU_LABEL_CHEAT_NUM_PASSES: + cbs->action_right = action_right_cheat_num_passes; + break; + } + } for (i = 0; i < MAX_USERS; i++) { diff --git a/menu/menu_entries_cbs_scan.c b/menu/menu_entries_cbs_scan.c index 7626ffe5d2..8531e020cb 100644 --- a/menu/menu_entries_cbs_scan.c +++ b/menu/menu_entries_cbs_scan.c @@ -42,7 +42,8 @@ static int action_scan_directory(const char *path, void menu_entries_cbs_init_bind_scan(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1) + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash) { if (!cbs) return; diff --git a/menu/menu_entries_cbs_select.c b/menu/menu_entries_cbs_select.c index 4d1a5ada41..3870369cc5 100644 --- a/menu/menu_entries_cbs_select.c +++ b/menu/menu_entries_cbs_select.c @@ -59,7 +59,8 @@ static int action_select_directory(const char *path, const char *label, unsigned void menu_entries_cbs_init_bind_select(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1) + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash) { if (!cbs) return; diff --git a/menu/menu_entries_cbs_start.c b/menu/menu_entries_cbs_start.c index e5054c3b05..5201389a48 100644 --- a/menu/menu_entries_cbs_start.c +++ b/menu/menu_entries_cbs_start.c @@ -264,30 +264,53 @@ static int action_start_lookup_setting(unsigned type, const char *label) return ret; } +int menu_entries_cbs_init_bind_start_compare_label(menu_file_list_cbs_t *cbs, + uint32_t hash) +{ + switch (hash) + { + case MENU_LABEL_REMAP_FILE_LOAD: + cbs->action_start = action_start_remap_file_load; + break; + case MENU_LABEL_VIDEO_FILTER: + cbs->action_start = action_start_video_filter_file_load; + break; + case MENU_LABEL_VIDEO_SHADER_PASS: + cbs->action_start = action_start_shader_pass; + break; + case MENU_LABEL_VIDEO_SHADER_SCALE_PASS: + cbs->action_start = action_start_shader_scale_pass; + break; + case MENU_LABEL_VIDEO_SHADER_FILTER_PASS: + cbs->action_start = action_start_shader_filter_pass; + break; + case MENU_LABEL_VIDEO_SHADER_NUM_PASSES: + cbs->action_start = action_start_shader_num_passes; + break; + case MENU_LABEL_CHEAT_NUM_PASSES: + cbs->action_start = action_start_cheat_num_passes; + break; + default: + return -1; + } + + return 0; +} + void menu_entries_cbs_init_bind_start(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1) + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash) { if (!cbs) return; cbs->action_start = action_start_lookup_setting; + + if (menu_entries_cbs_init_bind_start_compare_label(cbs, label_hash) == 0) + return; - if (!strcmp(label, "remap_file_load")) - cbs->action_start = action_start_remap_file_load; - if (!strcmp(label, "video_filter")) - cbs->action_start = action_start_video_filter_file_load; - else if (!strcmp(label, "video_shader_pass")) - cbs->action_start = action_start_shader_pass; - else if (!strcmp(label, "video_shader_scale_pass")) - cbs->action_start = action_start_shader_scale_pass; - else if (!strcmp(label, "video_shader_filter_pass")) - cbs->action_start = action_start_shader_filter_pass; - else if (!strcmp(label, "video_shader_num_passes")) - cbs->action_start = action_start_shader_num_passes; - else if (!strcmp(label, "cheat_num_passes")) - cbs->action_start = action_start_cheat_num_passes; - else if (type >= MENU_SETTINGS_SHADER_PARAMETER_0 + if (type >= MENU_SETTINGS_SHADER_PARAMETER_0 && type <= MENU_SETTINGS_SHADER_PARAMETER_LAST) cbs->action_start = action_start_shader_action_parameter; else if (type >= MENU_SETTINGS_SHADER_PRESET_PARAMETER_0 diff --git a/menu/menu_entries_cbs_title.c b/menu/menu_entries_cbs_title.c index 6cc46fa17a..cb2c588933 100644 --- a/menu/menu_entries_cbs_title.c +++ b/menu/menu_entries_cbs_title.c @@ -20,102 +20,7 @@ #include "menu.h" #include "menu_entries_cbs.h" -#include "hash.h" - -#define MENU_LABEL_DEFERRED_DATABASE_MANAGER_LIST 0x7c0b704fU -#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST 0x45446638U -#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_DEVELOPER 0xcbd89be5U -#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_PUBLISHER 0x125e594dU -#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ORIGIN 0x4ebaa767U -#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_FRANCHISE 0x77f9eff2U -#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_EDGE_MAGAZINE_RATING 0x1c7f8a43U -#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_EDGE_MAGAZINE_ISSUE 0xaaeebde7U -#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_RELEASEMONTH 0x2b36ce66U -#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_RELEASEYEAR 0x9c7c6e91U -#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ESRB_RATING 0x68eba20fU -#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ELSPA_RATING 0x8bf6ab18U -#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_PEGI_RATING 0x5fc77328U -#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_CERO_RATING 0x24f6172cU -#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_BBFC_RATING 0x0a8e67f0U -#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_MAX_USERS 0xbfcba816U -#define MENU_LABEL_DEFERRED_RDB_ENTRY_DETAIL 0xc35416c0U -#define MENU_LABEL_DEFERRED_CORE_LIST 0xf157d289U -#define MENU_LABEL_CONFIGURATIONS 0x3e930a50U -#define MENU_LABEL_DISK_IMAGE_APPEND 0x5af7d709U -#define MENU_LABEL_PERFORMANCE_COUNTERS 0xd8ab5049U -#define MENU_LABEL_CORE_LIST 0xa8c3bfc9U -#define MENU_LABEL_MANAGEMENT 0xb8137ec2U -#define MENU_LABEL_OPTIONS 0x71f05091U -#define MENU_LABEL_SETTINGS 0x1304dc16U -#define MENU_LABEL_FRONTEND_COUNTERS 0xe5696877U -#define MENU_LABEL_CORE_COUNTERS 0x64cc83e0U -#define MENU_LABEL_HISTORY_LIST 0x60d82032U -#define MENU_LABEL_INFO_SCREEN 0xd97853d0U -#define MENU_LABEL_SYSTEM_INFORMATION 0x206ebf0fU -#define MENU_LABEL_CORE_INFORMATION 0xb638e0d3U -#define MENU_LABEL_VIDEO_SHADER_PARAMETERS 0x9895c3e5U -#define MENU_LABEL_VIDEO_SHADER_PRESET_PARAMETERS 0xd18158d7U -#define MENU_LABEL_DISK_OPTIONS 0xc61ab5fbU -#define MENU_LABEL_CORE_OPTIONS 0xf65e60f9U -#define MENU_LABEL_SHADER_OPTIONS 0x1f7d2fc7U -#define MENU_LABEL_VIDEO_OPTIONS 0x6390c4e7U -#define MENU_LABEL_CORE_CHEAT_OPTIONS 0x9293171dU -#define MENU_LABEL_CORE_INPUT_REMAPPING_OPTIONS 0x7836a8caU -#define MENU_LABEL_DATABASE_MANAGER_LIST 0x7f853d8fU -#define MENU_LABEL_CURSOR_MANAGER_LIST 0xa969e378U -#define MENU_LABEL_DEFERRED_CORE_UPDATER_LIST 0xbd4d493dU -#define MENU_LABEL_VIDEO_SHADER_PASS 0x4fa31028U -#define MENU_LABEL_VIDEO_SHADER_PRESET 0xc5d3bae4U -#define MENU_LABEL_CHEAT_FILE_LOAD 0x57336148U -#define MENU_LABEL_REMAP_FILE_LOAD 0x9c2799b8U -#define MENU_LABEL_CUSTOM_VIEWPORT_2 0x76c30170U -#define MENU_LABEL_HELP 0x7c97d2eeU -#define MENU_LABEL_INPUT_OVERLAY 0x24e24796U -#define MENU_LABEL_VIDEO_FONT_PATH 0xd0de729eU -#define MENU_LABEL_VIDEO_FILTER 0x1c0eb741U -#define MENU_LABEL_AUDIO_DSP_PLUGIN 0x4a69572bU -#define MENU_LABEL_RGUI_BROWSER_DIRECTORY 0xa86cba73U -#define MENU_LABEL_PLAYLIST_DIRECTORY 0x6361820bU -#define MENU_LABEL_CONTENT_DIRECTORY 0x7738dc14U -#define MENU_LABEL_SCREENSHOT_DIRECTORY 0x552612d7U -#define MENU_LABEL_VIDEO_SHADER_DIR 0x30f53b10U -#define MENU_LABEL_VIDEO_FILTER_DIR 0x67603f1fU -#define MENU_LABEL_AUDIO_FILTER_DIR 0x4bd96ebaU -#define MENU_LABEL_SAVESTATE_DIRECTORY 0x90551289U -#define MENU_LABEL_LIBRETRO_DIR_PATH 0x1af1eb72U -#define MENU_LABEL_LIBRETRO_INFO_PATH 0xe552b25fU -#define MENU_LABEL_RGUI_CONFIG_DIRECTORY 0x0cb3e005U -#define MENU_LABEL_SAVEFILE_DIRECTORY 0x92773488U -#define MENU_LABEL_OVERLAY_DIRECTORY 0xc4ed3d1bU -#define MENU_LABEL_SYSTEM_DIRECTORY 0x35a6fb9eU -#define MENU_LABEL_ASSETS_DIRECTORY 0xde1ae8ecU -#define MENU_LABEL_EXTRACTION_DIRECTORY 0x33b55ffaU -#define MENU_LABEL_JOYPAD_AUTOCONFIG_DIR 0x2f4822d8U -#define MENU_LABEL_DRIVER_SETTINGS 0x81cd2d62U -#define MENU_LABEL_CORE_SETTINGS 0x06795dffU -#define MENU_LABEL_CONFIGURATION_SETTINGS 0x5a1558ceU -#define MENU_LABEL_LOGGING_SETTINGS 0x902c003dU -#define MENU_LABEL_SAVING_SETTINGS 0x32fea87eU -#define MENU_LABEL_REWIND_SETTINGS 0xbff7775fU -#define MENU_LABEL_VIDEO_SETTINGS 0x9dd23badU -#define MENU_LABEL_RECORDING_SETTINGS 0x1a80b313U -#define MENU_LABEL_FRAME_THROTTLE_SETTINGS 0x573b8837U -#define MENU_LABEL_SHADER_SETTINGS 0xd6657e8dU -#define MENU_LABEL_FONT_SETTINGS 0x1bc2266dU -#define MENU_LABEL_AUDIO_SETTINGS 0x8f74c888U -#define MENU_LABEL_INPUT_SETTINGS 0xddd30846U -#define MENU_LABEL_OVERLAY_SETTINGS 0x34377f98U -#define MENU_LABEL_ONSCREEN_KEYBOARD_OVERLAY_SETTINGS 0xa6de9ba6U -#define MENU_LABEL_MENU_SETTINGS 0x61e4544bU -#define MENU_LABEL_UI_SETTINGS 0xf8da6ef4U -#define MENU_LABEL_PATCH_SETTINGS 0xa78b0986U -#define MENU_LABEL_PLAYLIST_SETTINGS 0x4d276288U -#define MENU_LABEL_CORE_UPDATER_SETTINGS 0x124ad454U -#define MENU_LABEL_NETWORK_SETTINGS 0x8b50d180U -#define MENU_LABEL_ARCHIVE_SETTINGS 0x78e85398U -#define MENU_LABEL_USER_SETTINGS 0xcdc9a8f5U -#define MENU_LABEL_DIRECTORY_SETTINGS 0xb817bd2bU -#define MENU_LABEL_PRIVACY_SETTINGS 0xce106254U +#include static INLINE void replace_chars(char *str, char c1, char c2) { @@ -173,431 +78,235 @@ static int action_get_title_default(const char *path, const char *label, switch (hash) { - case MENU_LABEL_DEFERRED_DATABASE_MANAGER_LIST: - if (!strcmp(label, "deferred_database_manager_list")) + case MENU_LABEL_DEFERRED_DATABASE_MANAGER_LIST: snprintf(s, len, "DATABASE SELECTION - %s", (elem0_path[0] != '\0') ? path_basename(elem0_path) : ""); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST: - if (!strcmp(label, "deferred_cursor_manager_list")) + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST: snprintf(s, len, "DATABASE CURSOR LIST - %s", (elem0_path[0] != '\0') ? path_basename(elem0_path) : ""); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_DEVELOPER: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_developer")) + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_DEVELOPER: snprintf(s, len, "DATABASE CURSOR LIST (FILTER: DEVELOPER - %s)", elem0_path); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_PUBLISHER: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_publisher")) + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_PUBLISHER: snprintf(s, len, "DATABASE CURSOR LIST (FILTER: PUBLISHER - %s)", elem0_path); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ORIGIN: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_origin")) + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ORIGIN: snprintf(s, len, "DATABASE CURSOR LIST (FILTER: ORIGIN - %s)", elem0_path); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_FRANCHISE: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_franchise")) + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_FRANCHISE: snprintf(s, len, "DATABASE CURSOR LIST (FILTER: FRANCHISE - %s)", elem0_path); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_EDGE_MAGAZINE_RATING: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_edge_magazine_rating")) + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_EDGE_MAGAZINE_RATING: snprintf(s, len, "DATABASE CURSOR LIST (FILTER: EDGE MAGAZINE RATING - %s)", elem0_path); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_EDGE_MAGAZINE_ISSUE: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_edge_magazine_issue")) + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_EDGE_MAGAZINE_ISSUE: snprintf(s, len, "DATABASE CURSOR LIST (FILTER: EDGE MAGAZINE ISSUE - %s)", elem0_path); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_RELEASEMONTH: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_releasemonth")) + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_RELEASEMONTH: snprintf(s, len, "DATABASE CURSOR LIST (FILTER: RELEASEDATE BY MONTH - %s)", elem0_path); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_RELEASEYEAR: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_releaseyear")) + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_RELEASEYEAR: snprintf(s, len, "DATABASE CURSOR LIST (FILTER: RELEASEDATE BY YEAR - %s)", elem0_path); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ESRB_RATING: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_esrb_rating")) + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ESRB_RATING: snprintf(s, len, "DATABASE CURSOR LIST (FILTER: ESRB RATING - %s)", elem0_path); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ELSPA_RATING: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_elspa_rating")) + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ELSPA_RATING: snprintf(s, len, "DATABASE CURSOR LIST (FILTER: ELSPA RATING - %s)", elem0_path); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_PEGI_RATING: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_pegi_rating")) + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_PEGI_RATING: snprintf(s, len, "DATABASE CURSOR LIST (FILTER: PEGI RATING - %s)", elem0_path); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_CERO_RATING: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_cero_rating")) + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_CERO_RATING: snprintf(s, len, "DATABASE CURSOR LIST (FILTER: CERO RATING - %s)", elem0_path); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_BBFC_RATING: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_bbfc_rating")) + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_BBFC_RATING: snprintf(s, len, "DATABASE CURSOR LIST (FILTER: BBFC RATING - %s)", elem0_path); - break; - case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_MAX_USERS: - if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_max_users")) + break; + case MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_MAX_USERS: snprintf(s, len, "DATABASE CURSOR LIST (FILTER: MAX USERS - %s)", elem0_path); - break; - case MENU_LABEL_DEFERRED_RDB_ENTRY_DETAIL: - if (!strcmp(label, "deferred_rdb_entry_detail")) + break; + case MENU_LABEL_DEFERRED_RDB_ENTRY_DETAIL: snprintf(s, len, "DATABASE INFO: %s", elem1); - break; - case MENU_LABEL_DEFERRED_CORE_LIST: - if (!strcmp(label, "deferred_core_list")) + break; + case MENU_LABEL_DEFERRED_CORE_LIST: snprintf(s, len, "DETECTED CORES %s", path); - break; - case MENU_LABEL_CONFIGURATIONS: - if (!strcmp(label, "configurations")) + break; + case MENU_LABEL_CONFIGURATIONS: snprintf(s, len, "CONFIG %s", path); - break; - case MENU_LABEL_DISK_IMAGE_APPEND: - if (!strcmp(label, "disk_image_append")) + break; + case MENU_LABEL_DISK_IMAGE_APPEND: snprintf(s, len, "DISK APPEND %s", path); - break; - case MENU_LABEL_PERFORMANCE_COUNTERS: - if (!strcmp(label, "performance_counters")) - { - is_performance_counters: + break; + case MENU_LABEL_PERFORMANCE_COUNTERS: + case MENU_LABEL_CORE_LIST: + case MENU_LABEL_MANAGEMENT: + case MENU_LABEL_OPTIONS: + case MENU_LABEL_SETTINGS: + case MENU_LABEL_FRONTEND_COUNTERS: + case MENU_LABEL_CORE_COUNTERS: + case MENU_LABEL_HISTORY_LIST: + case MENU_LABEL_INFO_SCREEN: + case MENU_LABEL_SYSTEM_INFORMATION: + case MENU_LABEL_CORE_INFORMATION: + case MENU_LABEL_VIDEO_SHADER_PARAMETERS: + case MENU_LABEL_VIDEO_SHADER_PRESET_PARAMETERS: + case MENU_LABEL_DISK_OPTIONS: + case MENU_LABEL_CORE_OPTIONS: + case MENU_LABEL_SHADER_OPTIONS: + case MENU_LABEL_VIDEO_OPTIONS: + case MENU_LABEL_CORE_CHEAT_OPTIONS: + case MENU_LABEL_CORE_INPUT_REMAPPING_OPTIONS: + case MENU_LABEL_DATABASE_MANAGER_LIST: + case MENU_LABEL_CURSOR_MANAGER_LIST: + case MENU_LABEL_DEFERRED_CORE_UPDATER_LIST: sanitize_to_string(s, label, len); - } - break; - case MENU_LABEL_CORE_LIST: - if (!strcmp(label, "core_list")) - goto is_performance_counters; - break; - case MENU_LABEL_MANAGEMENT: - if (!strcmp(label, "management")) - goto is_performance_counters; - break; - case MENU_LABEL_OPTIONS: - if (!strcmp(label, "options")) - goto is_performance_counters; - break; - case MENU_LABEL_SETTINGS: - if (!strcmp(label, "settings")) - goto is_performance_counters; - break; - case MENU_LABEL_FRONTEND_COUNTERS: - if (!strcmp(label, "frontend_counters")) - goto is_performance_counters; - break; - case MENU_LABEL_CORE_COUNTERS: - if (!strcmp(label, "core_counters")) - goto is_performance_counters; - break; - case MENU_LABEL_HISTORY_LIST: - if (!strcmp(label, "history_list")) - goto is_performance_counters; - break; - case MENU_LABEL_INFO_SCREEN: - if (!strcmp(label, "info_screen")) - goto is_performance_counters; - break; - case MENU_LABEL_SYSTEM_INFORMATION: - if (!strcmp(label, "system_information")) - goto is_performance_counters; - break; - case MENU_LABEL_CORE_INFORMATION: - if (!strcmp(label, "core_information")) - goto is_performance_counters; - break; - case MENU_LABEL_VIDEO_SHADER_PARAMETERS: - if (!strcmp(label, "video_shader_parameters")) - goto is_performance_counters; - break; - case MENU_LABEL_VIDEO_SHADER_PRESET_PARAMETERS: - if (!strcmp(label, "video_shader_preset_parameters")) - goto is_performance_counters; - break; - case MENU_LABEL_DISK_OPTIONS: - if (!strcmp(label, "disk_options")) - goto is_performance_counters; - break; - case MENU_LABEL_CORE_OPTIONS: - if (!strcmp(label, "core_options")) - goto is_performance_counters; - break; - case MENU_LABEL_SHADER_OPTIONS: - if (!strcmp(label, "shader_options")) - goto is_performance_counters; - break; - case MENU_LABEL_VIDEO_OPTIONS: - if (!strcmp(label, "video_options")) - goto is_performance_counters; - break; - case MENU_LABEL_CORE_CHEAT_OPTIONS: - if (!strcmp(label, "core_cheat_options")) - goto is_performance_counters; - break; - case MENU_LABEL_CORE_INPUT_REMAPPING_OPTIONS: - if (!strcmp(label, "core_input_remapping_options")) - goto is_performance_counters; - break; - case MENU_LABEL_DATABASE_MANAGER_LIST: - if (!strcmp(label, "database_manager_list")) - goto is_performance_counters; - break; - case MENU_LABEL_CURSOR_MANAGER_LIST: - if (!strcmp(label, "cursor_manager_list")) - goto is_performance_counters; - break; - case MENU_LABEL_DEFERRED_CORE_UPDATER_LIST: - if (!strcmp(label, "deferred_core_updater_list")) - goto is_performance_counters; - break; - case MENU_LABEL_VIDEO_SHADER_PASS: - if (!strcmp(label, "video_shader_pass")) + break; + case MENU_LABEL_VIDEO_SHADER_PASS: snprintf(s, len, "SHADER %s", path); - break; - case MENU_LABEL_VIDEO_SHADER_PRESET: - if (!strcmp(label, "video_shader_preset")) + break; + case MENU_LABEL_VIDEO_SHADER_PRESET: snprintf(s, len, "SHADER PRESET %s", path); - break; - case MENU_LABEL_CHEAT_FILE_LOAD: - if (!strcmp(label, "cheat_file_load")) + break; + case MENU_LABEL_CHEAT_FILE_LOAD: snprintf(s, len, "CHEAT FILE %s", path); - break; - case MENU_LABEL_REMAP_FILE_LOAD: - if (!strcmp(label, "remap_file_load")) + break; + case MENU_LABEL_REMAP_FILE_LOAD: snprintf(s, len, "REMAP FILE %s", path); - break; - case MENU_LABEL_CUSTOM_VIEWPORT_2: - if (!strcmp(label, "custom_viewport_2")) - { - is_custom_viewport_2: + break; + case MENU_LABEL_CUSTOM_VIEWPORT_2: + case MENU_LABEL_HELP: snprintf(s, len, "MENU %s", path); - } - break; - case MENU_LABEL_HELP: - if (!strcmp(label, "help")) - goto is_custom_viewport_2; - break; - case MENU_LABEL_INPUT_OVERLAY: - if (!strcmp(label, "input_overlay")) + break; + case MENU_LABEL_INPUT_OVERLAY: snprintf(s, len, "OVERLAY %s", path); - break; - case MENU_LABEL_VIDEO_FONT_PATH: - if (!strcmp(label, "video_font_path")) + break; + case MENU_LABEL_VIDEO_FONT_PATH: snprintf(s, len, "FONT %s", path); - break; - case MENU_LABEL_VIDEO_FILTER: - if (!strcmp(label, "video_filter")) + break; + case MENU_LABEL_VIDEO_FILTER: snprintf(s, len, "FILTER %s", path); - break; - case MENU_LABEL_AUDIO_DSP_PLUGIN: - if (!strcmp(label, "audio_dsp_plugin")) + break; + case MENU_LABEL_AUDIO_DSP_PLUGIN: snprintf(s, len, "DSP FILTER %s", path); - break; - case MENU_LABEL_RGUI_BROWSER_DIRECTORY: - if (!strcmp(label, "rgui_browser_directory")) + break; + case MENU_LABEL_RGUI_BROWSER_DIRECTORY: snprintf(s, len, "BROWSER DIR %s", path); - break; - case MENU_LABEL_PLAYLIST_DIRECTORY: - if (!strcmp(label, "playlist_directory")) + break; + case MENU_LABEL_PLAYLIST_DIRECTORY: snprintf(s, len, "PLAYLIST DIR %s", path); - break; - case MENU_LABEL_CONTENT_DIRECTORY: - if (!strcmp(label, "content_directory")) + break; + case MENU_LABEL_CONTENT_DIRECTORY: snprintf(s, len, "CONTENT DIR %s", path); - break; - case MENU_LABEL_SCREENSHOT_DIRECTORY: - if (!strcmp(label, "screenshot_directory")) + break; + case MENU_LABEL_SCREENSHOT_DIRECTORY: snprintf(s, len, "SCREENSHOT DIR %s", path); - break; - case MENU_LABEL_VIDEO_SHADER_DIR: - if (!strcmp(label, "video_shader_dir")) + break; + case MENU_LABEL_VIDEO_SHADER_DIR: snprintf(s, len, "SHADER DIR %s", path); - break; - case MENU_LABEL_VIDEO_FILTER_DIR: - if (!strcmp(label, "video_filter_dir")) + break; + case MENU_LABEL_VIDEO_FILTER_DIR: snprintf(s, len, "FILTER DIR %s", path); - break; - case MENU_LABEL_AUDIO_FILTER_DIR: - if (!strcmp(label, "audio_filter_dir")) + break; + case MENU_LABEL_AUDIO_FILTER_DIR: snprintf(s, len, "DSP FILTER DIR %s", path); - break; - case MENU_LABEL_SAVESTATE_DIRECTORY: - if (!strcmp(label, "savestate_directory")) + break; + case MENU_LABEL_SAVESTATE_DIRECTORY: snprintf(s, len, "SAVESTATE DIR %s", path); - break; - case MENU_LABEL_LIBRETRO_DIR_PATH: - if (!strcmp(label, "libretro_dir_path")) + break; + case MENU_LABEL_LIBRETRO_DIR_PATH: snprintf(s, len, "LIBRETRO DIR %s", path); - break; - case MENU_LABEL_LIBRETRO_INFO_PATH: - if (!strcmp(label, "libretro_info_path")) + break; + case MENU_LABEL_LIBRETRO_INFO_PATH: snprintf(s, len, "LIBRETRO INFO DIR %s", path); - break; - case MENU_LABEL_RGUI_CONFIG_DIRECTORY: - if (!strcmp(label, "rgui_config_directory")) + break; + case MENU_LABEL_RGUI_CONFIG_DIRECTORY: snprintf(s, len, "CONFIG DIR %s", path); - break; - case MENU_LABEL_SAVEFILE_DIRECTORY: - if (!strcmp(label, "savefile_directory")) + break; + case MENU_LABEL_SAVEFILE_DIRECTORY: snprintf(s, len, "SAVEFILE DIR %s", path); - break; - case MENU_LABEL_OVERLAY_DIRECTORY: - if (!strcmp(label, "overlay_directory")) + break; + case MENU_LABEL_OVERLAY_DIRECTORY: snprintf(s, len, "OVERLAY DIR %s", path); - break; - case MENU_LABEL_SYSTEM_DIRECTORY: - if (!strcmp(label, "system_directory")) + break; + case MENU_LABEL_SYSTEM_DIRECTORY: snprintf(s, len, "SYSTEM DIR %s", path); - break; - case MENU_LABEL_ASSETS_DIRECTORY: - if (!strcmp(label, "assets_directory")) + break; + case MENU_LABEL_ASSETS_DIRECTORY: snprintf(s, len, "ASSETS DIR %s", path); - break; - case MENU_LABEL_EXTRACTION_DIRECTORY: - if (!strcmp(label, "extraction_directory")) + break; + case MENU_LABEL_EXTRACTION_DIRECTORY: snprintf(s, len, "EXTRACTION DIR %s", path); - break; - case MENU_LABEL_JOYPAD_AUTOCONFIG_DIR: - if (!strcmp(label, "joypad_autoconfig_dir")) + break; + case MENU_LABEL_JOYPAD_AUTOCONFIG_DIR: snprintf(s, len, "AUTOCONFIG DIR %s", path); - break; - case MENU_LABEL_DRIVER_SETTINGS: - if (!strcmp(label, "Driver Settings")) - { - is_settings_entry: + break; + case MENU_LABEL_DRIVER_SETTINGS: + case MENU_LABEL_CORE_SETTINGS: + case MENU_LABEL_CONFIGURATION_SETTINGS: + case MENU_LABEL_LOGGING_SETTINGS: + case MENU_LABEL_SAVING_SETTINGS: + case MENU_LABEL_REWIND_SETTINGS: + case MENU_LABEL_VIDEO_SETTINGS: + case MENU_LABEL_RECORDING_SETTINGS: + case MENU_LABEL_FRAME_THROTTLE_SETTINGS: + case MENU_LABEL_SHADER_SETTINGS: + case MENU_LABEL_FONT_SETTINGS: + case MENU_LABEL_AUDIO_SETTINGS: + case MENU_LABEL_INPUT_SETTINGS: + case MENU_LABEL_INPUT_HOTKEY_SETTINGS: + case MENU_LABEL_OVERLAY_SETTINGS: + case MENU_LABEL_ONSCREEN_KEYBOARD_OVERLAY_SETTINGS: + case MENU_LABEL_MENU_SETTINGS: + case MENU_LABEL_UI_SETTINGS: + case MENU_LABEL_PATCH_SETTINGS: + case MENU_LABEL_PLAYLIST_SETTINGS: + case MENU_LABEL_CORE_UPDATER_SETTINGS: + case MENU_LABEL_NETWORK_SETTINGS: + case MENU_LABEL_ARCHIVE_SETTINGS: + case MENU_LABEL_USER_SETTINGS: + case MENU_LABEL_DIRECTORY_SETTINGS: + case MENU_LABEL_PRIVACY_SETTINGS: strlcpy(s, string_to_upper(elem0), len); if (elem1[0] != '\0') { strlcat(s, " - ", len); strlcat(s, string_to_upper(elem1), len); } - } - break; - case MENU_LABEL_CORE_SETTINGS: - if (!strcmp(label, "Core Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_CONFIGURATION_SETTINGS: - if (!strcmp(label, "Configuration Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_LOGGING_SETTINGS: - if (!strcmp(label, "Logging Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_SAVING_SETTINGS: - if (!strcmp(label, "Saving Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_REWIND_SETTINGS: - if (!strcmp(label, "Rewind Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_VIDEO_SETTINGS: - if (!strcmp(label, "Video Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_RECORDING_SETTINGS: - if (!strcmp(label, "Recording Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_FRAME_THROTTLE_SETTINGS: - if (!strcmp(label, "Frame Throttle Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_SHADER_SETTINGS: - if (!strcmp(label, "Shader Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_FONT_SETTINGS: - if (!strcmp(label, "Font Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_AUDIO_SETTINGS: - if (!strcmp(label, "Audio Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_INPUT_SETTINGS: - if (!strcmp(label, "Input Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_OVERLAY_SETTINGS: - if (!strcmp(label, "Overlay Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_ONSCREEN_KEYBOARD_OVERLAY_SETTINGS: - if (!strcmp(label, "Onscreen Keyboard Overlay Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_MENU_SETTINGS: - if (!strcmp(label, "Menu Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_UI_SETTINGS: - if (!strcmp(label, "UI Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_PATCH_SETTINGS: - if (!strcmp(label, "Patch Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_PLAYLIST_SETTINGS: - if (!strcmp(label, "Playlist Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_CORE_UPDATER_SETTINGS: - if (!strcmp(label, "Core Updater Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_NETWORK_SETTINGS: - if (!strcmp(label, "Network Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_ARCHIVE_SETTINGS: - if (!strcmp(label, "Archive Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_USER_SETTINGS: - if (!strcmp(label, "User Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_DIRECTORY_SETTINGS: - if (!strcmp(label, "Directory Settings")) - goto is_settings_entry; - break; - case MENU_LABEL_PRIVACY_SETTINGS: - if (!strcmp(label, "Privacy Settings")) - goto is_settings_entry; - break; - default: - if (menu_type == MENU_SETTINGS_CUSTOM_VIEWPORT || - menu_type == MENU_SETTINGS) - { - goto is_custom_viewport_2; - } - else if (menu_type == MENU_SETTINGS_CUSTOM_BIND || + break; + default: + if (menu_type == MENU_SETTINGS_CUSTOM_VIEWPORT || + menu_type == MENU_SETTINGS) + snprintf(s, len, "MENU %s", path); + else if (menu_type == MENU_SETTINGS_CUSTOM_BIND || menu_type == MENU_SETTINGS_CUSTOM_BIND_KEYBOARD) - { - strlcpy(s, "INPUT SETTINGS", len); - if (elem1[0] != '\0') { - strlcat(s, " - ", len); - strlcat(s, string_to_upper(elem1), len); + strlcpy(s, "INPUT SETTINGS", len); + if (elem1[0] != '\0') + { + strlcat(s, " - ", len); + strlcat(s, string_to_upper(elem1), len); + } } - } - else - { - driver_t *driver = driver_get_ptr(); - - if (driver->menu->defer_core) - snprintf(s, len, "CONTENT %s", path); else { - global_t *global = global_get_ptr(); - const char *core_name = global->menu.info.library_name; + driver_t *driver = driver_get_ptr(); - if (!core_name) - core_name = global->system.info.library_name; - if (!core_name) - core_name = "No Core"; - snprintf(s, len, "CONTENT (%s) %s", core_name, path); + if (driver->menu->defer_core) + snprintf(s, len, "CONTENT %s", path); + else + { + global_t *global = global_get_ptr(); + const char *core_name = global->menu.info.library_name; + + if (!core_name) + core_name = global->system.info.library_name; + if (!core_name) + core_name = "No Core"; + snprintf(s, len, "CONTENT (%s) %s", core_name, path); + } } - } - break; + break; } return 0; @@ -605,7 +314,8 @@ static int action_get_title_default(const char *path, const char *label, void menu_entries_cbs_init_bind_title(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1) + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash) { if (!cbs) return; diff --git a/menu/menu_entries_cbs_up.c b/menu/menu_entries_cbs_up.c index 5a2e912c05..25a5fd7cc9 100644 --- a/menu/menu_entries_cbs_up.c +++ b/menu/menu_entries_cbs_up.c @@ -36,7 +36,8 @@ static int action_bind_up_generic(unsigned type, const char *label) void menu_entries_cbs_init_bind_up(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, - const char *elem0, const char *elem1) + const char *elem0, const char *elem1, + uint32_t label_hash, uint32_t menu_label_hash) { if (!cbs) return; diff --git a/menu/menu_entry.c b/menu/menu_entry.c index 47a9b7e3fc..6d058c440e 100644 --- a/menu/menu_entry.c +++ b/menu/menu_entry.c @@ -281,7 +281,7 @@ void menu_entry_pathdir_selected(uint32_t i) { rarch_setting_t *setting = menu_entry_get_setting(i); if (menu_setting_is_of_path_type(setting)) - setting->action_toggle( setting, MENU_ACTION_RIGHT, false); + setting->action_right( setting, MENU_ACTION_RIGHT, false); } bool menu_entry_pathdir_allow_empty(uint32_t i) diff --git a/menu/menu_hash.h b/menu/menu_hash.h new file mode 100644 index 0000000000..2f5dd8cabf --- /dev/null +++ b/menu/menu_hash.h @@ -0,0 +1,337 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2011-2015 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#ifndef MENU_HASH_H__ +#define MENU_HASH_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#define MENU_LABEL_RESET 0x10474288U +#define MENU_LABEL_SLOWMOTION 0x6a269ea0U +#define MENU_LABEL_HOLD_FAST_FORWARD 0xebe2e4cdU +#define MENU_LABEL_CHEAT_TOGGLE 0xe515e0cbU +#define MENU_LABEL_PAUSE_TOGGLE 0x557634e4U +#define MENU_LABEL_SAVE_STATE 0x54a257f4U +#define MENU_LABEL_LOAD_STATE 0xe8c5dae5U +#define MENU_LABEL_REWIND 0x1931d5aeU +#define MENU_LABEL_NETPLAY_FLIP_PLAYERS 0x801425abU +#define MENU_LABEL_CHEAT_INDEX_MINUS 0x57f58b6cU +#define MENU_LABEL_CHEAT_INDEX_PLUS 0x678542a4U +#define MENU_LABEL_SCREENSHOT_DIRECTORY 0x552612d7U +#define MENU_LABEL_SHADER_NEXT 0x54d359baU +#define MENU_LABEL_SHADER_PREV 0x54d4a758U +#define MENU_LABEL_FRAME_ADVANCE 0xd80302a1U +#define MENU_LABEL_MOVIE_RECORD_TOGGLE 0xa2d2ff04U +#define MENU_LABEL_L_X_PLUS 0xd7370d4bU +#define MENU_LABEL_L_X_MINUS 0xbde0aaf3U +#define MENU_LABEL_L_Y_PLUS 0xd98c35ecU +#define MENU_LABEL_L_Y_MINUS 0x0adae7b4U +#define MENU_LABEL_R_X_PLUS 0x60c20a91U +#define MENU_LABEL_R_X_MINUS 0x78cb50f9U +#define MENU_LABEL_R_Y_MINUS 0xc5c58dbaU +#define MENU_LABEL_R_Y_PLUS 0x63173332U +#define MENU_LABEL_VIDEO_SWAP_INTERVAL 0x5673ff9aU +#define MENU_LABEL_VIDEO_GPU_SCREENSHOT 0xee2fcb44U +#define MENU_LABEL_PAUSE_NONACTIVE 0x580bf549U +#define MENU_LABEL_BLOCK_SRAM_OVERWRITE 0xc4e88d08U +#define MENU_LABEL_VIDEO_FULLSCREEN 0x9506dd4eU +#define MENU_LABEL_CORE_SPECIFIC_CONFIG 0x3c9a55e8U +#define MENU_LABEL_RGUI_SHOW_START_SCREEN 0x6b38f0e8U +#define MENU_LABEL_VIDEO_BLACK_FRAME_INSERTION 0x53477f5cU +#define MENU_LABEL_VIDEO_HARD_SYNC_FRAMES 0xce0ece13U +#define MENU_LABEL_VIDEO_FRAME_DELAY 0xd4aa9df4U +#define MENU_LABEL_SCREENSHOT 0x9a37f083U +#define MENU_LABEL_REWIND_GRANULARITY 0xe859cbdfU +#define MENU_LABEL_VIDEO_THREADED 0x0626179cU +#define MENU_LABEL_VIDEO_VSYNC 0x09c2d34eU +#define MENU_LABEL_VIDEO_HARD_SYNC 0xdcd623b6U +#define MENU_LABEL_SAVESTATE_AUTO_SAVE 0xf6f4a05bU +#define MENU_LABEL_SYSTEM_DIRECTORY 0x35a6fb9eU +#define MENU_LABEL_VIDEO_DISABLE_COMPOSITION 0x5cbb6222U +#define MENU_LABEL_VOLUME_UP 0xa66e9681U +#define MENU_LABEL_VOLUME_DOWN 0xfc64f3d4U +#define MENU_LABEL_LOG_VERBOSITY 0x6648c96dU +#define MENU_LABEL_OVERLAY_NEXT 0x7a459145U +#define MENU_LABEL_AUDIO_VOLUME 0x502173aeU +#define MENU_LABEL_AUDIO_LATENCY 0x32695386U +#define MENU_LABEL_NETPLAY_DELAY_FRAMES 0x86b2c48dU +#define MENU_LABEL_NETPLAY_SPECTATOR_MODE_ENABLE 0x6f9a9440U +#define MENU_LABEL_NETPLAY_IP_ADDRESS 0xac9a53ffU +#define MENU_LABEL_NETPLAY_MODE 0xc1cf6506U +#define MENU_LABEL_PERFCNT_ENABLE 0x6823dbddU + +#define MENU_LABEL_PAL60_ENABLE 0x62bc416eU +#define MENU_LABEL_SYSTEM_BGM_ENABLE 0x9287a1c5U + +#define MENU_LABEL_FASTFORWARD_RATIO 0x3a0c2706U +#define MENU_LABEL_VIDEO_MONITOR_INDEX 0xb6fcdc9aU +#define MENU_LABEL_VIDEO_REFRESH_RATE_AUTO 0x9addb6cdU +#define MENU_LABEL_VIDEO_ROTATION 0x4ce6882bU +#define MENU_LABEL_VIDEO_SCALE 0x09835d63U +#define MENU_LABEL_VIDEO_SMOOTH 0x3aabbb35U +#define MENU_LABEL_VIDEO_CROP_OVERSCAN 0x861f7a2fU +#define MENU_LABEL_VIDEO_SCALE_INTEGER 0x65c4b090U + +#define MENU_LABEL_AUDIO_RATE_CONTROL_DELTA 0xc8bde3cbU +#define MENU_LABEL_AUDIO_MAX_TIMING_SKEW 0x4c96f75cU + +#define MENU_LABEL_INPUT_PLAYER1_JOYPAD_INDEX 0xfad6ab2fU +#define MENU_LABEL_INPUT_PLAYER2_JOYPAD_INDEX 0x3616e4d0U +#define MENU_LABEL_INPUT_PLAYER3_JOYPAD_INDEX 0x71571e71U +#define MENU_LABEL_INPUT_PLAYER4_JOYPAD_INDEX 0xac975812U +#define MENU_LABEL_INPUT_PLAYER5_JOYPAD_INDEX 0xe7d791b3U + +#define MENU_LABEL_LIBRETRO_DIR_PATH 0x1af1eb72U + +#define MENU_LABEL_AUDIO_DEVICE 0x2574eac6U + +#define MENU_LABEL_REWIND_ENABLE 0x9761e074U +#define MENU_LABEL_ENABLE_HOTKEY 0xc04037bfU +#define MENU_LABEL_DISK_EJECT_TOGGLE 0x49633fbbU +#define MENU_LABEL_DISK_NEXT 0xeeaf6c6eU +#define MENU_LABEL_GRAB_MOUSE_TOGGLE 0xb2869aaaU +#define MENU_LABEL_MENU_TOGGLE 0xfb22e3dbU +#define MENU_LABEL_STATE_SLOT_DECREASE 0xe48b8082U +#define MENU_LABEL_STATE_SLOT_INCREASE 0x36a0cbb0U + +#define MENU_LABEL_LIBRETRO_LOG_LEVEL 0x57971ac0U + +#define MENU_LABEL_INPUT_BIND_DEVICE_ID 0xd1ea94ecU +#define MENU_LABEL_INPUT_BIND_DEVICE_TYPE 0xf6e9f041U + +#define MENU_LABEL_AUTOSAVE_INTERVAL 0xecc87351U +#define MENU_LABEL_CONFIG_SAVE_ON_EXIT 0x79b590feU + +#define MENU_LABEL_INPUT_DRIVER 0x4c087840U +#define MENU_LABEL_INPUT_DRIVER_LINUXRAW 0xc33c6b9fU +#define MENU_LABEL_INPUT_DRIVER_UDEV 0x7c9eeeb9U + +#define MENU_LABEL_VIDEO_DRIVER 0x1805a5e7U +#define MENU_LABEL_VIDEO_DRIVER_GL 0x005977f8U +#define MENU_LABEL_VIDEO_DRIVER_SDL2 0x7c9dd69aU +#define MENU_LABEL_VIDEO_DRIVER_SDL1 0x0b88a968U +#define MENU_LABEL_VIDEO_DRIVER_D3D 0x0b886340U +#define MENU_LABEL_VIDEO_DRIVER_EXYNOS 0xfc37c54bU +#define MENU_LABEL_VIDEO_DRIVER_SUNXI 0x10620e3cU + +#define MENU_LABEL_AUDIO_RESAMPLER_DRIVER 0xedcba9ecU +#define MENU_LABEL_AUDIO_RESAMPLER_DRIVER_SINC 0x7c9dec52U +#define MENU_LABEL_AUDIO_RESAMPLER_DRIVER_CC 0x0059732bU + +#define MENU_LABEL_SAVEFILE_DIRECTORY 0x92773488U +#define MENU_LABEL_SAVESTATE_DIRECTORY 0x90551289U +#define MENU_LABEL_ASSETS_DIRECTORY 0xde1ae8ecU +#define MENU_LABEL_DYNAMIC_WALLPAPERS_DIRECTORY 0x62f975b8U + +#define MENU_LABEL_SLOWMOTION_RATIO 0x626b3ffeU +#define MENU_LABEL_INPUT_AXIS_THRESHOLD 0xe95c2095U +#define MENU_LABEL_INPUT_TURBO_PERIOD 0xf7a97482U +#define MENU_LABEL_INPUT_AUTODETECT_ENABLE 0xb1e07facU + +#define MENU_LABEL_CAMERA_ALLOW 0xc14d302cU +#define MENU_LABEL_LOCATION_ALLOW 0xf089275cU + +#define MENU_LABEL_TURBO 0x107434f1U + + + + +#define MENU_LABEL_RDB_ENTRY_PUBLISHER 0x4d7bcdfbU +#define MENU_LABEL_RDB_ENTRY_DEVELOPER 0x06f61093U +#define MENU_LABEL_RDB_ENTRY_ORIGIN 0xb176aad5U +#define MENU_LABEL_RDB_ENTRY_FRANCHISE 0xb31764a0U +#define MENU_LABEL_RDB_ENTRY_ENHANCEMENT_HW 0x79ee4f11U +#define MENU_LABEL_RDB_ENTRY_ESRB_RATING 0xe138fa3dU +#define MENU_LABEL_RDB_ENTRY_BBFC_RATING 0x82dbc01eU +#define MENU_LABEL_RDB_ENTRY_ELSPA_RATING 0x0def0906U +#define MENU_LABEL_RDB_ENTRY_PEGI_RATING 0xd814cb56U +#define MENU_LABEL_RDB_ENTRY_CERO_RATING 0x9d436f5aU +#define MENU_LABEL_RDB_ENTRY_EDGE_MAGAZINE_RATING 0x9735f631U +#define MENU_LABEL_RDB_ENTRY_EDGE_MAGAZINE_ISSUE 0xd5706415U +#define MENU_LABEL_RDB_ENTRY_FAMITSU_MAGAZINE_RATING 0x01a50315U +#define MENU_LABEL_RDB_ENTRY_RELEASE_MONTH 0xad2f2c54U +#define MENU_LABEL_RDB_ENTRY_RELEASE_YEAR 0x14c9c6bfU +#define MENU_LABEL_RDB_ENTRY_MAX_USERS 0xfae91cc4U + +#define MENU_LABEL_VIDEO_SHADER_DEFAULT_FILTER 0x4468cb1bU +#define MENU_LABEL_VIDEO_SHADER_FILTER_PASS 0x1906c38dU +#define MENU_LABEL_VIDEO_SHADER_SCALE_PASS 0x18f7b82fU +#define MENU_LABEL_VIDEO_SHADER_NUM_PASSES 0x79b2992fU +#define MENU_LABEL_CHEAT_NUM_PASSES 0x1910eb87U + +#define MENU_VALUE_MD5 0x0b888fabU +#define MENU_VALUE_SHA1 0x7c9de632U +#define MENU_VALUE_CRC 0x0b88671dU +#define MENU_VALUE_MORE 0x0b877cafU +#define MENU_VALUE_INPUT_SETTINGS 0xddd30846U +#define MENU_VALUE_HORIZONTAL_MENU 0x35761704U +#define MENU_VALUE_MAIN_MENU 0x1625971fU +#define MENU_VALUE_ON 0x005974c2U +#define MENU_VALUE_OFF 0x0b880c40U +#define MENU_VALUE_TRUE 0x7c9e9fe5U +#define MENU_VALUE_FALSE 0x0f6bcef0U +#define MENU_VALUE_COMP 0x6a166ba5U +#define MENU_VALUE_CORE 0x6a167f7fU +#define MENU_VALUE_CURSOR 0x57bba8b4U +#define MENU_VALUE_FILE 0x6a496536U +#define MENU_VALUE_RDB 0x0b00f54eU +#define MENU_VALUE_DIR 0x0af95f55U + +#define MENU_LABEL_CONTENT_ACTIONS 0xa0d76970U +#define MENU_LABEL_DETECT_CORE_LIST 0xaa07c341U +#define MENU_LABEL_LOAD_CONTENT 0x5745de1fU +#define MENU_LABEL_CORE_UPDATER_LIST 0x0372767dU +#define MENU_LABEL_RECORD_CONFIG 0x11c3daf9U +#define MENU_LABEL_UNLOAD_CORE 0x4b622170U +#define MENU_LABEL_QUIT_RETROARCH 0x84b0bc71U +#define MENU_LABEL_DEFERRED_VIDEO_FILTER 0x966ad201U +#define MENU_LABEL_DEFERRED_CORE_LIST_SET 0xa6d5fdb4U +#define MENU_LABEL_DEFERRED_DATABASE_MANAGER_LIST 0x7c0b704fU +#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST 0x45446638U +#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_DEVELOPER 0xcbd89be5U +#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_PUBLISHER 0x125e594dU +#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ORIGIN 0x4ebaa767U +#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_FRANCHISE 0x77f9eff2U +#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_EDGE_MAGAZINE_RATING 0x1c7f8a43U +#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_EDGE_MAGAZINE_ISSUE 0xaaeebde7U +#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_FAMITSU_MAGAZINE_RATING 0xbf7ff5e7U +#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ENHANCEMENT_HW 0x9866bda3U +#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_RELEASEMONTH 0x2b36ce66U +#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_RELEASEYEAR 0x9c7c6e91U +#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ESRB_RATING 0x68eba20fU +#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_ELSPA_RATING 0x8bf6ab18U +#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_PEGI_RATING 0x5fc77328U +#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_CERO_RATING 0x24f6172cU +#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_BBFC_RATING 0x0a8e67f0U +#define MENU_LABEL_DEFERRED_CURSOR_MANAGER_LIST_RDB_ENTRY_MAX_USERS 0xbfcba816U +#define MENU_LABEL_DEFERRED_RDB_ENTRY_DETAIL 0xc35416c0U +#define MENU_LABEL_DEFERRED_CORE_LIST 0xf157d289U +#define MENU_LABEL_DEFERRED_CORE_UPDATER_LIST 0xbd4d493dU +#define MENU_LABEL_CONFIGURATIONS 0x3e930a50U +#define MENU_LABEL_DISK_IMAGE_APPEND 0x5af7d709U +#define MENU_LABEL_PERFORMANCE_COUNTERS 0xd8ab5049U +#define MENU_LABEL_CORE_LIST 0xa8c3bfc9U +#define MENU_LABEL_MANAGEMENT 0xb8137ec2U +#define MENU_LABEL_OPTIONS 0x71f05091U +#define MENU_LABEL_SETTINGS 0x1304dc16U +#define MENU_LABEL_FRONTEND_COUNTERS 0xe5696877U +#define MENU_LABEL_CORE_COUNTERS 0x64cc83e0U +#define MENU_LABEL_HISTORY_LIST 0x60d82032U +#define MENU_LABEL_INFO_SCREEN 0xd97853d0U +#define MENU_LABEL_SYSTEM_INFORMATION 0x206ebf0fU +#define MENU_LABEL_CORE_INFORMATION 0xb638e0d3U +#define MENU_LABEL_VIDEO_SHADER_PARAMETERS 0x9895c3e5U +#define MENU_LABEL_VIDEO_SHADER_PRESET_PARAMETERS 0xd18158d7U +#define MENU_LABEL_DISK_OPTIONS 0xc61ab5fbU +#define MENU_LABEL_CORE_OPTIONS 0xf65e60f9U +#define MENU_LABEL_SHADER_OPTIONS 0x1f7d2fc7U +#define MENU_LABEL_VIDEO_OPTIONS 0x6390c4e7U +#define MENU_LABEL_CORE_CHEAT_OPTIONS 0x9293171dU +#define MENU_LABEL_CORE_INPUT_REMAPPING_OPTIONS 0x7836a8caU +#define MENU_LABEL_DATABASE_MANAGER_LIST 0x7f853d8fU +#define MENU_LABEL_CURSOR_MANAGER_LIST 0xa969e378U +#define MENU_LABEL_VIDEO_SHADER_PASS 0x4fa31028U +#define MENU_LABEL_VIDEO_SHADER_PRESET 0xc5d3bae4U +#define MENU_LABEL_CHEAT_FILE_LOAD 0x57336148U +#define MENU_LABEL_REMAP_FILE_LOAD 0x9c2799b8U +#define MENU_LABEL_MESSAGE 0xbe463eeaU +#define MENU_LABEL_INFO_SCREEN 0xd97853d0U +#define MENU_LABEL_LOAD_OPEN_ZIP 0x8aa3c068U +#define MENU_LABEL_CUSTOM_VIEWPORT_1 0x76c3016fU +#define MENU_LABEL_CUSTOM_VIEWPORT_2 0x76c30170U +#define MENU_LABEL_HELP 0x7c97d2eeU +#define MENU_LABEL_INPUT_OVERLAY 0x24e24796U +#define MENU_LABEL_INPUT_OSK_OVERLAY 0x11f1c582U +#define MENU_LABEL_VIDEO_FONT_PATH 0xd0de729eU +#define MENU_LABEL_VIDEO_FILTER 0x1c0eb741U +#define MENU_LABEL_MENU_WALLPAPER 0x3b84de01U +#define MENU_LABEL_CONTENT_HISTORY_PATH 0x6f22fb9dU +#define MENU_LABEL_AUDIO_DSP_PLUGIN 0x4a69572bU +#define MENU_LABEL_RGUI_BROWSER_DIRECTORY 0xa86cba73U +#define MENU_LABEL_PLAYLIST_DIRECTORY 0x6361820bU +#define MENU_LABEL_CONTENT_DIRECTORY 0x7738dc14U +#define MENU_LABEL_SCREENSHOT_DIRECTORY 0x552612d7U +#define MENU_LABEL_VIDEO_SHADER_DIR 0x30f53b10U +#define MENU_LABEL_VIDEO_FILTER_DIR 0x67603f1fU +#define MENU_LABEL_AUDIO_FILTER_DIR 0x4bd96ebaU +#define MENU_LABEL_SAVESTATE_DIRECTORY 0x90551289U +#define MENU_LABEL_LIBRETRO_DIR_PATH 0x1af1eb72U +#define MENU_LABEL_LIBRETRO_INFO_PATH 0xe552b25fU +#define MENU_LABEL_RGUI_CONFIG_DIRECTORY 0x0cb3e005U +#define MENU_LABEL_SAVEFILE_DIRECTORY 0x92773488U +#define MENU_LABEL_OVERLAY_DIRECTORY 0xc4ed3d1bU +#define MENU_LABEL_SYSTEM_DIRECTORY 0x35a6fb9eU +#define MENU_LABEL_ASSETS_DIRECTORY 0xde1ae8ecU +#define MENU_LABEL_EXTRACTION_DIRECTORY 0x33b55ffaU +#define MENU_LABEL_JOYPAD_AUTOCONFIG_DIR 0x2f4822d8U +#define MENU_LABEL_DRIVER_SETTINGS 0x81cd2d62U +#define MENU_LABEL_CORE_SETTINGS 0x06795dffU +#define MENU_LABEL_CONFIGURATION_SETTINGS 0x5a1558ceU +#define MENU_LABEL_LOGGING_SETTINGS 0x902c003dU +#define MENU_LABEL_SAVING_SETTINGS 0x32fea87eU +#define MENU_LABEL_REWIND_SETTINGS 0xbff7775fU +#define MENU_LABEL_VIDEO_SETTINGS 0x9dd23badU +#define MENU_LABEL_RECORDING_SETTINGS 0x1a80b313U +#define MENU_LABEL_FRAME_THROTTLE_SETTINGS 0x573b8837U +#define MENU_LABEL_SHADER_SETTINGS 0xd6657e8dU +#define MENU_LABEL_FONT_SETTINGS 0x67571029U +#define MENU_LABEL_AUDIO_SETTINGS 0x8f74c888U +#define MENU_LABEL_INPUT_SETTINGS 0xddd30846U +#define MENU_LABEL_INPUT_HOTKEY_SETTINGS 0xa4fee31aU +#define MENU_LABEL_OVERLAY_SETTINGS 0x34377f98U +#define MENU_LABEL_ONSCREEN_KEYBOARD_OVERLAY_SETTINGS 0xa6de9ba6U +#define MENU_LABEL_MENU_SETTINGS 0x61e4544bU +#define MENU_LABEL_UI_SETTINGS 0xf8da6ef4U +#define MENU_LABEL_PATCH_SETTINGS 0xa78b0986U +#define MENU_LABEL_PLAYLIST_SETTINGS 0x4d276288U +#define MENU_LABEL_CORE_UPDATER_SETTINGS 0x124ad454U +#define MENU_LABEL_NETWORK_SETTINGS 0x8b50d180U +#define MENU_LABEL_ARCHIVE_SETTINGS 0x78e85398U +#define MENU_LABEL_USER_SETTINGS 0xcdc9a8f5U +#define MENU_LABEL_DIRECTORY_SETTINGS 0xb817bd2bU +#define MENU_LABEL_PRIVACY_SETTINGS 0xce106254U +#define MENU_LABEL_SHADER_APPLY_CHANGES 0x4f7306b9U +#define MENU_LABEL_SAVE_NEW_CONFIG 0xcce9ab72U +#define MENU_LABEL_ONSCREEN_DISPLAY_SETTINGS 0x67571029U +#define MENU_LABEL_CHEAT_APPLY_CHANGES 0xde88aa27U +#define MENU_LABEL_CUSTOM_BIND 0x1e84b3fcU +#define MENU_LABEL_CUSTOM_BIND_ALL 0x79ac14f4U +#define MENU_LABEL_CUSTOM_BIND_DEFAULTS 0xe88f7b13U +#define MENU_LABEL_SAVESTATE 0x3a4849b5U +#define MENU_LABEL_LOADSTATE 0xa39eb286U +#define MENU_LABEL_RESUME_CONTENT 0xd9f088b0U +#define MENU_LABEL_RESTART_CONTENT 0x1ea2e224U +#define MENU_LABEL_TAKE_SCREENSHOT 0x6786e867U +#define MENU_LABEL_FILE_LOAD_OR_RESUME 0x952941f4U +#define MENU_LABEL_DISK_IMAGE_APPEND 0x5af7d709U +#define MENU_LABEL_CONFIGURATIONS 0x3e930a50U +#define MENU_LABEL_CHEAT_FILE_SAVE_AS 0x1f58dccaU +#define MENU_LABEL_REMAP_FILE_SAVE_AS 0xcebf7f3aU +#define MENU_LABEL_VIDEO_SHADER_PRESET_SAVE_AS 0x3d6e5ce5U +#define MENU_LABEL_REMAP_FILE_SAVE_CORE 0x7c9d4c8fU +#define MENU_LABEL_REMAP_FILE_SAVE_GAME 0x7c9f41e0U +#define MENU_LABEL_CONTENT_COLLECTION_LIST 0x0f8a9086U +#define MENU_LABEL_OSK_ENABLE 0x8e208498U +#define MENU_LABEL_AUDIO_MUTE 0xe0ca1151U +#define MENU_LABEL_EXIT_EMULATOR 0x86d5d467U + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/menu/menu_input.c b/menu/menu_input.c index c2d390caaa..fe06802e96 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -22,6 +22,9 @@ #include #include #include + +#include + #include "menu_input.h" #include "menu.h" #include "menu_entry.h" @@ -135,12 +138,20 @@ void menu_input_st_string_callback(void *userdata, const char *str) } else { - if (!strcmp(menu->keyboard.label_setting, "video_shader_preset_save_as")) - menu_shader_manager_save_preset(str, false); - else if (!strcmp(menu->keyboard.label_setting, "remap_file_save_as")) - input_remapping_save_file(str); - else if (!strcmp(menu->keyboard.label_setting, "cheat_file_save_as")) - cheat_manager_save(global->cheat, str); + uint32_t hash_label = djb2_calculate(menu->keyboard.label_setting); + + switch (hash_label) + { + case MENU_LABEL_VIDEO_SHADER_PRESET_SAVE_AS: + menu_shader_manager_save_preset(str, false); + break; + case MENU_LABEL_REMAP_FILE_SAVE_AS: + input_remapping_save_file(str); + break; + case MENU_LABEL_CHEAT_FILE_SAVE_AS: + cheat_manager_save(global->cheat, str); + break; + } } } diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 32b66b3f71..9e32f0cc2d 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -15,6 +15,7 @@ */ #include +#include #include "menu.h" #include "menu_setting.h" @@ -205,14 +206,20 @@ static int setting_handler(rarch_setting_t *setting, unsigned action) switch (action) { case MENU_ACTION_UP: + if (setting->action_up) + return setting->action_up(setting, action); + break; case MENU_ACTION_DOWN: - if (setting->action_up_or_down) - return setting->action_up_or_down(setting, action); + if (setting->action_down) + return setting->action_down(setting, action); break; case MENU_ACTION_LEFT: + if (setting->action_left) + return setting->action_left(setting, action, true); + break; case MENU_ACTION_RIGHT: - if (setting->action_toggle) - return setting->action_toggle(setting, action, true); + if (setting->action_right) + return setting->action_right(setting, action, true); break; case MENU_ACTION_OK: if (setting->action_ok) @@ -739,18 +746,7 @@ static int setting_bind_action_start(void *data) ******* ACTION TOGGLE CALLBACK FUNCTIONS ******* **/ -/** - * setting_action_toggle_analog_dpad_mode - * @data : pointer to setting - * @action : toggle action value. Can be either one of : - * MENU_ACTION_RIGHT | MENU_ACTION_LEFT - * - * Function callback for 'Analog D-Pad Mode' action's 'Action Toggle' - * function pointer. - * - * Returns: 0 on success, -1 on error. - **/ -static int setting_action_toggle_analog_dpad_mode(void *data, +static int setting_action_left_analog_dpad_mode(void *data, unsigned action, bool wraparound) { unsigned port = 0; @@ -762,35 +758,33 @@ static int setting_action_toggle_analog_dpad_mode(void *data, port = setting->index_offset; - switch (action) - { - case MENU_ACTION_LEFT: - settings->input.analog_dpad_mode[port] = - (settings->input.analog_dpad_mode - [port] + ANALOG_DPAD_LAST - 1) % ANALOG_DPAD_LAST; - break; - case MENU_ACTION_RIGHT: - settings->input.analog_dpad_mode[port] = - (settings->input.analog_dpad_mode[port] + 1) - % ANALOG_DPAD_LAST; - break; - } + settings->input.analog_dpad_mode[port] = + (settings->input.analog_dpad_mode + [port] + ANALOG_DPAD_LAST - 1) % ANALOG_DPAD_LAST; return 0; } -/** - * setting_action_toggle_libretro_device_type - * @data : pointer to setting - * @action : toggle action value. Can be either one of : - * MENU_ACTION_RIGHT | MENU_ACTION_LEFT - * - * Function callback for 'Libretro Device Type' action's 'Action Toggle' - * function pointer. - * - * Returns: 0 on success, -1 on error. - **/ -static int setting_action_toggle_libretro_device_type( +static int setting_action_right_analog_dpad_mode(void *data, + unsigned action, bool wraparound) +{ + unsigned port = 0; + rarch_setting_t *setting = (rarch_setting_t*)data; + settings_t *settings = config_get_ptr(); + + if (!setting) + return -1; + + port = setting->index_offset; + + settings->input.analog_dpad_mode[port] = + (settings->input.analog_dpad_mode[port] + 1) + % ANALOG_DPAD_LAST; + + return 0; +} + +static int setting_action_left_libretro_device_type( void *data, unsigned action, bool wraparound) { unsigned current_device, current_idx, i, devices[128], @@ -839,39 +833,74 @@ static int setting_action_toggle_libretro_device_type( } } - switch (action) - { - case MENU_ACTION_LEFT: - current_device = devices - [(current_idx + types - 1) % types]; + current_device = devices + [(current_idx + types - 1) % types]; - settings->input.libretro_device[port] = current_device; - pretro_set_controller_port_device(port, current_device); - break; - case MENU_ACTION_RIGHT: - current_device = devices - [(current_idx + 1) % types]; - - settings->input.libretro_device[port] = current_device; - pretro_set_controller_port_device(port, current_device); - break; - } + settings->input.libretro_device[port] = current_device; + pretro_set_controller_port_device(port, current_device); return 0; } -/** - * setting_action_toggle_savestates - * @data : pointer to setting - * @action : toggle action value. Can be either one of : - * MENU_ACTION_RIGHT | MENU_ACTION_LEFT - * - * Function callback for 'SaveStates' action's 'Action Toggle' - * function pointer. - * - * Returns: 0 on success, -1 on error. - **/ -static int setting_action_toggle_savestates( +static int setting_action_right_libretro_device_type( + void *data, unsigned action, bool wraparound) +{ + unsigned current_device, current_idx, i, devices[128], + types = 0, port = 0; + const struct retro_controller_info *desc = NULL; + rarch_setting_t *setting = (rarch_setting_t*)data; + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + + if (!setting) + return -1; + + port = setting->index_offset; + + devices[types++] = RETRO_DEVICE_NONE; + devices[types++] = RETRO_DEVICE_JOYPAD; + + /* Only push RETRO_DEVICE_ANALOG as default if we use an + * older core which doesn't use SET_CONTROLLER_INFO. */ + if (!global->system.num_ports) + devices[types++] = RETRO_DEVICE_ANALOG; + + if (port < global->system.num_ports) + desc = &global->system.ports[port]; + + if (desc) + { + for (i = 0; i < desc->num_types; i++) + { + unsigned id = desc->types[i].id; + if (types < ARRAY_SIZE(devices) && + id != RETRO_DEVICE_NONE && + id != RETRO_DEVICE_JOYPAD) + devices[types++] = id; + } + } + + current_device = settings->input.libretro_device[port]; + current_idx = 0; + for (i = 0; i < types; i++) + { + if (current_device == devices[i]) + { + current_idx = i; + break; + } + } + + current_device = devices + [(current_idx + 1) % types]; + + settings->input.libretro_device[port] = current_device; + pretro_set_controller_port_device(port, current_device); + + return 0; +} + +static int setting_action_left_savestates( void *data, unsigned action, bool wraparound) { rarch_setting_t *setting = (rarch_setting_t*)data; @@ -880,33 +909,28 @@ static int setting_action_toggle_savestates( if (!setting) return -1; - switch (action) - { - case MENU_ACTION_LEFT: - /* Slot -1 is (auto) slot. */ - if (settings->state_slot >= 0) - settings->state_slot--; - break; - case MENU_ACTION_RIGHT: - settings->state_slot++; - break; - } + /* Slot -1 is (auto) slot. */ + if (settings->state_slot >= 0) + settings->state_slot--; return 0; } -/** - * setting_action_toggle_bind_device - * @data : pointer to setting - * @action : toggle action value. Can be either one of : - * MENU_ACTION_RIGHT | MENU_ACTION_LEFT - * - * Function callback for 'Bind Device' action's 'Action Toggle' - * function pointer. - * - * Returns: 0 on success, -1 on error. - **/ -static int setting_action_toggle_bind_device(void *data, +static int setting_action_right_savestates( + void *data, unsigned action, bool wraparound) +{ + rarch_setting_t *setting = (rarch_setting_t*)data; + settings_t *settings = config_get_ptr(); + + if (!setting) + return -1; + + settings->state_slot++; + + return 0; +} + +static int setting_action_left_bind_device(void *data, unsigned action, bool wraparound) { unsigned *p = NULL; @@ -918,19 +942,28 @@ static int setting_action_toggle_bind_device(void *data, p = &settings->input.joypad_map[setting->index_offset]; - switch (action) - { - case MENU_ACTION_LEFT: - if ((*p) >= settings->input.max_users) - *p = settings->input.max_users - 1; - else if ((*p) > 0) - (*p)--; - break; - case MENU_ACTION_RIGHT: - if (*p < settings->input.max_users) - (*p)++; - break; - } + if ((*p) >= settings->input.max_users) + *p = settings->input.max_users - 1; + else if ((*p) > 0) + (*p)--; + + return 0; +} + +static int setting_action_right_bind_device(void *data, + unsigned action, bool wraparound) +{ + unsigned *p = NULL; + rarch_setting_t *setting = (rarch_setting_t*)data; + settings_t *settings = config_get_ptr(); + + if (!setting) + return -1; + + p = &settings->input.joypad_map[setting->index_offset]; + + if (*p < settings->input.max_users) + (*p)++; return 0; } @@ -943,18 +976,12 @@ static int setting_bool_action_toggle_default(void *data, if (!setting) return -1; - switch (action) - { - case MENU_ACTION_LEFT: - case MENU_ACTION_RIGHT: - *setting->value.boolean = !(*setting->value.boolean); - break; - } + *setting->value.boolean = !(*setting->value.boolean); return 0; } -static int setting_uint_action_toggle_default(void *data, +static int setting_uint_action_left_default(void *data, unsigned action, bool wraparound) { rarch_setting_t *setting = (rarch_setting_t*)data; @@ -962,36 +989,40 @@ static int setting_uint_action_toggle_default(void *data, if (!setting) return -1; - switch (action) + if (*setting->value.unsigned_integer != setting->min) + *setting->value.unsigned_integer = + *setting->value.unsigned_integer - setting->step; + + if (setting->enforce_minrange) { - case MENU_ACTION_LEFT: - if (*setting->value.unsigned_integer != setting->min) - *setting->value.unsigned_integer = - *setting->value.unsigned_integer - setting->step; - - if (setting->enforce_minrange) - { - if (*setting->value.unsigned_integer < setting->min) - *setting->value.unsigned_integer = setting->min; - } - break; - - case MENU_ACTION_RIGHT: - *setting->value.unsigned_integer = - *setting->value.unsigned_integer + setting->step; - - if (setting->enforce_maxrange) - { - if (*setting->value.unsigned_integer > setting->max) - *setting->value.unsigned_integer = setting->max; - } - break; + if (*setting->value.unsigned_integer < setting->min) + *setting->value.unsigned_integer = setting->min; } return 0; } -static int setting_fraction_action_toggle_default( +static int setting_uint_action_right_default(void *data, + unsigned action, bool wraparound) +{ + rarch_setting_t *setting = (rarch_setting_t*)data; + + if (!setting) + return -1; + + *setting->value.unsigned_integer = + *setting->value.unsigned_integer + setting->step; + + if (setting->enforce_maxrange) + { + if (*setting->value.unsigned_integer > setting->max) + *setting->value.unsigned_integer = setting->max; + } + + return 0; +} + +static int setting_fraction_action_left_default( void *data, unsigned action, bool wraparound) { rarch_setting_t *setting = (rarch_setting_t*)data; @@ -999,35 +1030,39 @@ static int setting_fraction_action_toggle_default( if (!setting) return -1; - switch (action) + *setting->value.fraction = + *setting->value.fraction - setting->step; + + if (setting->enforce_minrange) { - case MENU_ACTION_LEFT: - *setting->value.fraction = - *setting->value.fraction - setting->step; - - if (setting->enforce_minrange) - { - if (*setting->value.fraction < setting->min) - *setting->value.fraction = setting->min; - } - break; - - case MENU_ACTION_RIGHT: - *setting->value.fraction = - *setting->value.fraction + setting->step; - - if (setting->enforce_maxrange) - { - if (*setting->value.fraction > setting->max) - *setting->value.fraction = setting->max; - } - break; + if (*setting->value.fraction < setting->min) + *setting->value.fraction = setting->min; } return 0; } -static int setting_string_action_toggle_driver(void *data, +static int setting_fraction_action_right_default( + void *data, unsigned action, bool wraparound) +{ + rarch_setting_t *setting = (rarch_setting_t*)data; + + if (!setting) + return -1; + + *setting->value.fraction = + *setting->value.fraction + setting->step; + + if (setting->enforce_maxrange) + { + if (*setting->value.fraction > setting->max) + *setting->value.fraction = setting->max; + } + + return 0; +} + +static int setting_string_action_left_driver(void *data, unsigned action, bool wraparound) { rarch_setting_t *setting = (rarch_setting_t*)data; @@ -1035,24 +1070,29 @@ static int setting_string_action_toggle_driver(void *data, if (!setting) return -1; - switch (action) + if (!find_prev_driver(setting->name, setting->value.string, setting->size)) { - case MENU_ACTION_LEFT: - if (!find_prev_driver(setting->name, setting->value.string, setting->size)) - { #if 0 - if (wraparound) - find_last_driver(setting->name, setting->value.string, setting->size); + if (wraparound) + find_last_driver(setting->name, setting->value.string, setting->size); #endif - } - break; - case MENU_ACTION_RIGHT: - if (!find_next_driver(setting->name, setting->value.string, setting->size)) - { - if (wraparound) - find_first_driver(setting->name, setting->value.string, setting->size); - } - break; + } + + return 0; +} + +static int setting_string_action_right_driver(void *data, + unsigned action, bool wraparound) +{ + rarch_setting_t *setting = (rarch_setting_t*)data; + + if (!setting) + return -1; + + if (!find_next_driver(setting->name, setting->value.string, setting->size)) + { + if (wraparound) + find_first_driver(setting->name, setting->value.string, setting->size); } return 0; @@ -1609,7 +1649,8 @@ static rarch_setting_t setting_action_setting(const char* name, result.get_string_representation = &setting_get_string_representation_default; result.action_start = NULL; result.action_iterate = NULL; - result.action_toggle = NULL; + result.action_left = NULL; + result.action_right = NULL; result.action_ok = setting_action_action_ok; result.action_cancel = NULL; @@ -1701,7 +1742,8 @@ static rarch_setting_t setting_float_setting(const char* name, result.original_value.fraction = *target; result.default_value.fraction = default_value; result.action_start = setting_generic_action_start_default; - result.action_toggle = setting_fraction_action_toggle_default; + result.action_left = setting_fraction_action_left_default; + result.action_right = setting_fraction_action_right_default; result.action_ok = setting_generic_action_ok_default; result.action_cancel = NULL; @@ -1751,7 +1793,8 @@ static rarch_setting_t setting_bool_setting(const char* name, result.boolean.on_label = on; result.action_start = setting_generic_action_start_default; - result.action_toggle = setting_bool_action_toggle_default; + result.action_left = setting_bool_action_toggle_default; + result.action_right = setting_bool_action_toggle_default; result.action_ok = setting_generic_action_ok_default; result.action_cancel = NULL; @@ -1834,7 +1877,8 @@ static rarch_setting_t setting_uint_setting(const char* name, result.original_value.unsigned_integer = *target; result.default_value.unsigned_integer = default_value; result.action_start = setting_generic_action_start_default; - result.action_toggle = setting_uint_action_toggle_default; + result.action_left = setting_uint_action_left_default; + result.action_right = setting_uint_action_right_default; result.action_ok = setting_generic_action_ok_default; result.action_cancel = NULL; result.get_string_representation = &setting_get_string_representation_uint; @@ -1877,7 +1921,8 @@ static rarch_setting_t setting_hex_setting(const char* name, result.original_value.unsigned_integer = *target; result.default_value.unsigned_integer = default_value; result.action_start = setting_generic_action_start_default; - result.action_toggle = NULL; + result.action_left = NULL; + result.action_right = NULL; result.action_ok = setting_generic_action_ok_default; result.action_cancel = NULL; result.get_string_representation = &setting_get_string_representation_hex; @@ -2021,6 +2066,954 @@ static rarch_setting_t setting_string_setting_options(enum setting_type type, return result; } +static int setting_get_description_compare_label(uint32_t label_hash, + settings_t *settings, char *s, size_t len) +{ + uint32_t driver_hash = 0; + + switch (label_hash) + { + case MENU_LABEL_INPUT_DRIVER: + driver_hash = djb2_calculate(settings->input.driver); + + switch (driver_hash) + { + case MENU_LABEL_INPUT_DRIVER_UDEV: + snprintf(s, len, + " -- udev Input driver. \n" + " \n" + "This driver can run without X. \n" + " \n" + "It uses the recent evdev joypad API \n" + "for joystick support. It supports \n" + "hotplugging and force feedback (if \n" + "supported by device). \n" + " \n" + "The driver reads evdev events for keyboard \n" + "support. It also supports keyboard callback, \n" + "mice and touchpads. \n" + " \n" + "By default in most distros, /dev/input nodes \n" + "are root-only (mode 600). You can set up a udev \n" + "rule which makes these accessible to non-root." + ); + break; + case MENU_LABEL_INPUT_DRIVER_LINUXRAW: + snprintf(s, len, + " -- linuxraw Input driver. \n" + " \n" + "This driver requires an active TTY. Keyboard \n" + "events are read directly from the TTY which \n" + "makes it simpler, but not as flexible as udev. \n" "Mice, etc, are not supported at all. \n" + " \n" + "This driver uses the older joystick API \n" + "(/dev/input/js*)."); + break; + default: + snprintf(s, len, + " -- Input driver.\n" + " \n" + "Depending on video driver, it might \n" + "force a different input driver."); + break; + } + break; + case MENU_LABEL_LOAD_CONTENT: + snprintf(s, len, + " -- Load Content. \n" + "Browse for content. \n" + " \n" + "To load content, you need a \n" + "libretro core to use, and a \n" + "content file. \n" + " \n" + "To control where the menu starts \n" + " to browse for content, set \n" + "Browser Directory. If not set, \n" + "it will start in root. \n" + " \n" + "The browser will filter out \n" + "extensions for the last core set \n" + "in 'Core', and use that core when \n" + "content is loaded." + ); + break; + case MENU_LABEL_CORE_LIST: + snprintf(s, len, + " -- Core Selection. \n" + " \n" + "Browse for a libretro core \n" + "implementation. Where the browser \n" + "starts depends on your Core Directory \n" + "path. If blank, it will start in root. \n" + " \n" + "If Core Directory is a directory, the menu \n" + "will use that as top folder. If Core \n" + "Directory is a full path, it will start \n" + "in the folder where the file is."); + break; + case MENU_LABEL_HISTORY_LIST: + snprintf(s, len, + " -- Loading content from history. \n" + " \n" + "As content is loaded, content and libretro \n" + "core combinations are saved to history. \n" + " \n" + "The history is saved to a file in the same \n" + "directory as the RetroArch config file. If \n" + "no config file was loaded in startup, history \n" + "will not be saved or loaded, and will not exist \n" + "in the main menu." + ); + break; + case MENU_LABEL_VIDEO_DRIVER: + driver_hash = djb2_calculate(settings->video.driver); + + switch (driver_hash) + { + case MENU_LABEL_VIDEO_DRIVER_GL: + snprintf(s, len, + " -- OpenGL Video driver. \n" + " \n" + "This driver allows libretro GL cores to \n" + "be used in addition to software-rendered \n" + "core implementations.\n" + " \n" + "Performance for software-rendered and \n" + "libretro GL core implementations is \n" + "dependent on your graphics card's \n" + "underlying GL driver)."); + break; + case MENU_LABEL_VIDEO_DRIVER_SDL2: + snprintf(s, len, + " -- SDL 2 Video driver.\n" + " \n" + "This is an SDL 2 software-rendered video \n" + "driver.\n" + " \n" + "Performance for software-rendered libretro \n" + "core implementations is dependent \n" + "on your platform SDL implementation."); + break; + case MENU_LABEL_VIDEO_DRIVER_SDL1: + snprintf(s, len, + " -- SDL Video driver.\n" + " \n" + "This is an SDL 1.2 software-rendered video \n" + "driver.\n" + " \n" + "Performance is considered to be suboptimal. \n" + "Consider using it only as a last resort."); + break; + case MENU_LABEL_VIDEO_DRIVER_D3D: + snprintf(s, len, + " -- Direct3D Video driver. \n" + " \n" + "Performance for software-rendered cores \n" + "is dependent on your graphic card's \n" + "underlying D3D driver)."); + break; + case MENU_LABEL_VIDEO_DRIVER_EXYNOS: + snprintf(s, len, + " -- Exynos-G2D Video Driver. \n" + " \n" + "This is a low-level Exynos video driver. \n" + "Uses the G2D block in Samsung Exynos SoC \n" + "for blit operations. \n" + " \n" + "Performance for software rendered cores \n" + "should be optimal."); + break; + case MENU_LABEL_VIDEO_DRIVER_SUNXI: + snprintf(s, len, + " -- Sunxi-G2D Video Driver. \n" + " \n" + "This is a low-level Sunxi video driver. \n" + "Uses the G2D block in Allwinner SoCs."); + break; + default: + snprintf(s, len, + " -- Current Video driver."); + break; + } + break; + case MENU_LABEL_AUDIO_DSP_PLUGIN: + snprintf(s, len, + " -- Audio DSP plugin.\n" + " Processes audio before it's sent to \n" + "the driver." + ); + break; + case MENU_LABEL_AUDIO_RESAMPLER_DRIVER: + driver_hash = djb2_calculate(settings->audio.resampler); + + switch (driver_hash) + { + case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_SINC: + snprintf(s, len, + " -- Windowed SINC implementation."); + break; + case MENU_LABEL_AUDIO_RESAMPLER_DRIVER_CC: + snprintf(s, len, + " -- Convoluted Cosine implementation."); + break; + } + break; + case MENU_LABEL_VIDEO_SHADER_PRESET: + snprintf(s, len, + " -- Load Shader Preset. \n" + " \n" + " Load a " +#ifdef HAVE_CG + "Cg" +#endif +#ifdef HAVE_GLSL +#ifdef HAVE_CG + "/" +#endif + "GLSL" +#endif +#ifdef HAVE_HLSL +#if defined(HAVE_CG) || defined(HAVE_HLSL) + "/" +#endif + "HLSL" +#endif + " preset directly. \n" + "The menu shader menu is updated accordingly. \n" + " \n" + "If the CGP uses scaling methods which are not \n" + "simple, (i.e. source scaling, same scaling \n" + "factor for X/Y), the scaling factor displayed \n" + "in the menu might not be correct." + ); + break; + case MENU_LABEL_VIDEO_SHADER_SCALE_PASS: + snprintf(s, len, + " -- Scale for this pass. \n" + " \n" + "The scale factor accumulates, i.e. 2x \n" + "for first pass and 2x for second pass \n" + "will give you a 4x total scale. \n" + " \n" + "If there is a scale factor for last \n" + "pass, the result is stretched to \n" + "screen with the filter specified in \n" + "'Default Filter'. \n" + " \n" + "If 'Don't Care' is set, either 1x \n" + "scale or stretch to fullscreen will \n" + "be used depending if it's not the last \n" + "pass or not." + ); + break; + case MENU_LABEL_VIDEO_SHADER_NUM_PASSES: + snprintf(s, len, + " -- Shader Passes. \n" + " \n" + "RetroArch allows you to mix and match various \n" + "shaders with arbitrary shader passes, with \n" + "custom hardware filters and scale factors. \n" + " \n" + "This option specifies the number of shader \n" + "passes to use. If you set this to 0, and use \n" + "Apply Shader Changes, you use a 'blank' shader. \n" + " \n" + "The Default Filter option will affect the \n" + "stretching filter."); + break; + case MENU_LABEL_VIDEO_SHADER_PARAMETERS: + snprintf(s, len, + "-- Shader Parameters. \n" + " \n" + "Modifies current shader directly. Will not be \n" + "saved to CGP/GLSLP preset file."); + break; + case MENU_LABEL_VIDEO_SHADER_PRESET_PARAMETERS: + snprintf(s, len, + "-- Shader Preset Parameters. \n" + " \n" + "Modifies shader preset currently in menu." + ); + break; + case MENU_LABEL_VIDEO_SHADER_PASS: + snprintf(s, len, + " -- Path to shader. \n" + " \n" + "All shaders must be of the same \n" + "type (i.e. CG, GLSL or HLSL). \n" + " \n" + "Set Shader Directory to set where \n" + "the browser starts to look for \n" + "shaders." + ); + break; + case MENU_LABEL_CONFIG_SAVE_ON_EXIT: + snprintf(s, len, + " -- Saves config to disk on exit.\n" + "Useful for menu as settings can be\n" + "modified. Overwrites the config.\n" + " \n" + "#include's and comments are not \n" + "preserved. \n" + " \n" + "By design, the config file is \n" + "considered immutable as it is \n" + "likely maintained by the user, \n" + "and should not be overwritten \n" + "behind the user's back." +#if defined(RARCH_CONSOLE) || defined(RARCH_MOBILE) + "\nThis is not not the case on \n" + "consoles however, where \n" + "looking at the config file \n" + "manually isn't really an option." +#endif + ); + break; + case MENU_LABEL_VIDEO_SHADER_FILTER_PASS: + snprintf(s, len, + " -- Hardware filter for this pass. \n" + " \n" + "If 'Don't Care' is set, 'Default \n" + "Filter' will be used." + ); + break; + case MENU_LABEL_AUTOSAVE_INTERVAL: + snprintf(s, len, + " -- Autosaves the non-volatile SRAM \n" + "at a regular interval.\n" + " \n" + "This is disabled by default unless set \n" + "otherwise. The interval is measured in \n" + "seconds. \n" + " \n" + "A value of 0 disables autosave."); + break; + case MENU_LABEL_INPUT_BIND_DEVICE_TYPE: + snprintf(s, len, + " -- Input Device Type. \n" + " \n" + "Picks which device type to use. This is \n" + "relevant for the libretro core itself." + ); + break; + case MENU_LABEL_LIBRETRO_LOG_LEVEL: + snprintf(s, len, + "-- Sets log level for libretro cores \n" + "(GET_LOG_INTERFACE). \n" + " \n" + " If a log level issued by a libretro \n" + " core is below libretro_log level, it \n" + " is ignored.\n" + " \n" + " DEBUG logs are always ignored unless \n" + " verbose mode is activated (--verbose).\n" + " \n" + " DEBUG = 0\n" + " INFO = 1\n" + " WARN = 2\n" + " ERROR = 3" + ); + break; + case MENU_LABEL_STATE_SLOT_INCREASE: + case MENU_LABEL_STATE_SLOT_DECREASE: + snprintf(s, len, + " -- State slots.\n" + " \n" + " With slot set to 0, save state name is *.state \n" + " (or whatever defined on commandline).\n" + "When slot is != 0, path will be (path)(d), \n" + "where (d) is slot number."); + break; + case MENU_LABEL_SHADER_APPLY_CHANGES: + snprintf(s, len, + " -- Apply Shader Changes. \n" + " \n" + "After changing shader settings, use this to \n" + "apply changes. \n" + " \n" + "Changing shader settings is a somewhat \n" + "expensive operation so it has to be \n" + "done explicitly. \n" + " \n" + "When you apply shaders, the menu shader \n" + "settings are saved to a temporary file (either \n" + "menu.cgp or menu.glslp) and loaded. The file \n" + "persists after RetroArch exits. The file is \n" + "saved to Shader Directory." + ); + break; + case MENU_LABEL_INPUT_BIND_DEVICE_ID: + snprintf(s, len, + " -- Input Device. \n" + " \n" + "Picks which gamepad to use for user N. \n" + "The name of the pad is available." + ); + break; + case MENU_LABEL_MENU_TOGGLE: + snprintf(s, len, + " -- Toggles menu."); + break; + case MENU_LABEL_GRAB_MOUSE_TOGGLE: + snprintf(s, len, + " -- Toggles mouse grab.\n" + " \n" + "When mouse is grabbed, RetroArch hides the \n" + "mouse, and keeps the mouse pointer inside \n" + "the window to allow relative mouse input to \n" + "work better."); + break; + case MENU_LABEL_DISK_NEXT: + snprintf(s, len, + " -- Cycles through disk images. Use after \n" + "ejecting. \n" + " \n" + " Complete by toggling eject again."); + break; + case MENU_LABEL_VIDEO_FILTER: +#ifdef HAVE_FILTERS_BUILTIN + snprintf(s, len, + " -- CPU-based video filter."); +#else + snprintf(s, len, + " -- CPU-based video filter.\n" + " \n" + "Path to a dynamic library."); +#endif + break; + case MENU_LABEL_AUDIO_DEVICE: + snprintf(s, len, + " -- Override the default audio device \n" + "the audio driver uses.\n" + "This is driver dependent. E.g.\n" +#ifdef HAVE_ALSA + " \n" + "ALSA wants a PCM device." +#endif +#ifdef HAVE_OSS + " \n" + "OSS wants a path (e.g. /dev/dsp)." +#endif +#ifdef HAVE_JACK + " \n" + "JACK wants portnames (e.g. system:playback1\n" + ",system:playback_2)." +#endif +#ifdef HAVE_RSOUND + " \n" + "RSound wants an IP address to an RSound \n" + "server." +#endif + ); + break; + case MENU_LABEL_DISK_EJECT_TOGGLE: + snprintf(s, len, + " -- Toggles eject for disks.\n" + " \n" + "Used for multiple-disk content."); + break; + case MENU_LABEL_ENABLE_HOTKEY: + snprintf(s, len, + " -- Enable other hotkeys.\n" + " \n" + " If this hotkey is bound to either keyboard, \n" + "joybutton or joyaxis, all other hotkeys will \n" + "be disabled unless this hotkey is also held \n" + "at the same time. \n" + " \n" + "This is useful for RETRO_KEYBOARD centric \n" + "implementations which query a large area of \n" + "the keyboard, where it is not desirable that \n" + "hotkeys get in the way."); + break; + case MENU_LABEL_REWIND_ENABLE: + snprintf(s, len, + " -- Enable rewinding.\n" + " \n" + "This will take a performance hit, \n" + "so it is disabled by default."); + break; + case MENU_LABEL_LIBRETRO_DIR_PATH: + snprintf(s, len, + " -- Core Directory. \n" + " \n" + "A directory for where to search for \n" + "libretro core implementations."); + break; + case MENU_LABEL_VIDEO_REFRESH_RATE_AUTO: + snprintf(s, len, + " -- Refresh Rate Auto.\n" + " \n" + "The accurate refresh rate of our monitor (Hz).\n" + "This is used to calculate audio input rate with \n" + "the formula: \n" + " \n" + "audio_input_rate = game input rate * display \n" + "refresh rate / game refresh rate\n" + " \n" + "If the implementation does not report any \n" + "values, NTSC defaults will be assumed for \n" + "compatibility.\n" + " \n" + "This value should stay close to 60Hz to avoid \n" + "large pitch changes. If your monitor does \n" + "not run at 60Hz, or something close to it, \n" + "disable VSync, and leave this at its default."); + break; + case MENU_LABEL_VIDEO_ROTATION: + snprintf(s, len, + " -- Forces a certain rotation \n" + "of the screen.\n" + " \n" + "The rotation is added to rotations which\n" + "the libretro core sets (see Video Allow\n" + "Rotate)."); + break; + case MENU_LABEL_VIDEO_SCALE: + snprintf(s, len, + " -- Fullscreen resolution.\n" + " \n" + "Resolution of 0 uses the \n" + "resolution of the environment.\n"); + break; + case MENU_LABEL_FASTFORWARD_RATIO: + snprintf(s, len, + " -- Fastforward ratio." + " \n" + "The maximum rate at which content will\n" + "be run when using fast forward.\n" + " \n" + " (E.g. 5.0 for 60 fps content => 300 fps \n" + "cap).\n" + " \n" + "RetroArch will go to sleep to ensure that \n" + "the maximum rate will not be exceeded.\n" + "Do not rely on this cap to be perfectly \n" + "accurate."); + break; + case MENU_LABEL_VIDEO_MONITOR_INDEX: + snprintf(s, len, + " -- Which monitor to prefer.\n" + " \n" + "0 (default) means no particular monitor \n" + "is preferred, 1 and up (1 being first \n" + "monitor), suggests RetroArch to use that \n" + "particular monitor."); + break; + case MENU_LABEL_VIDEO_CROP_OVERSCAN: + snprintf(s, len, + " -- Forces cropping of overscanned \n" + "frames.\n" + " \n" + "Exact behavior of this option is \n" + "core-implementation specific."); + break; + case MENU_LABEL_VIDEO_SCALE_INTEGER: + snprintf(s, len, + " -- Only scales video in integer \n" + "steps.\n" + " \n" + "The base size depends on system-reported \n" + "geometry and aspect ratio.\n" + " \n" + "If Force Aspect is not set, X/Y will be \n" + "integer scaled independently."); + break; + case MENU_LABEL_AUDIO_VOLUME: + snprintf(s, len, + " -- Audio volume, expressed in dB.\n" + " \n" + " 0 dB is normal volume. No gain will be applied.\n" + "Gain can be controlled in runtime with Input\n" + "Volume Up / Input Volume Down."); + break; + case MENU_LABEL_AUDIO_RATE_CONTROL_DELTA: + snprintf(s, len, + " -- Audio rate control.\n" + " \n" + "Setting this to 0 disables rate control.\n" + "Any other value controls audio rate control \n" + "delta.\n" + " \n" + "Defines how much input rate can be adjusted \n" + "dynamically.\n" + " \n" + " Input rate is defined as: \n" + " input rate * (1.0 +/- (rate control delta))"); + break; + case MENU_LABEL_AUDIO_MAX_TIMING_SKEW: + snprintf(s, len, + " -- Maximum audio timing skew.\n" + " \n" + "Defines the maximum change in input rate.\n" + "You may want to increase this to enable\n" + "very large changes in timing, for example\n" + "running PAL cores on NTSC displays, at the\n" + "cost of inaccurate audio pitch.\n" + " \n" + " Input rate is defined as: \n" + " input rate * (1.0 +/- (max timing skew))"); + break; + case MENU_LABEL_OVERLAY_NEXT: + snprintf(s, len, + " -- Toggles to next overlay.\n" + " \n" + "Wraps around."); + break; + case MENU_LABEL_LOG_VERBOSITY: + snprintf(s, len, + "-- Enable or disable verbosity level \n" + "of frontend."); + break; + case MENU_LABEL_VOLUME_UP: + snprintf(s, len, + " -- Increases audio volume."); + break; + case MENU_LABEL_VOLUME_DOWN: + snprintf(s, len, + " -- Decreases audio volume."); + break; + case MENU_LABEL_VIDEO_DISABLE_COMPOSITION: + snprintf(s, len, + "-- Forcibly disable composition.\n" + "Only valid on Windows Vista/7 for now."); + break; + case MENU_LABEL_PERFCNT_ENABLE: + snprintf(s, len, + "-- Enable or disable frontend \n" + "performance counters."); + break; + case MENU_LABEL_SYSTEM_DIRECTORY: + snprintf(s, len, + "-- System Directory. \n" + " \n" + "Sets the 'system' directory.\n" + "Cores can query for this\n" + "directory to load BIOSes, \n" + "system-specific configs, etc."); + break; + case MENU_LABEL_SAVESTATE_AUTO_SAVE: + snprintf(s, len, + " -- Automatically saves a savestate at the \n" + "end of RetroArch's lifetime.\n" + " \n" + "RetroArch will automatically load any savestate\n" + "with this path on startup if 'Auto Load State\n" + "is enabled."); + break; + case MENU_LABEL_VIDEO_THREADED: + snprintf(s, len, + " -- Use threaded video driver.\n" + " \n" + "Using this might improve performance at \n" + "possible cost of latency and more video \n" + "stuttering."); + break; + case MENU_LABEL_VIDEO_VSYNC: + snprintf(s, len, + " -- Video V-Sync.\n"); + break; + case MENU_LABEL_VIDEO_HARD_SYNC: + snprintf(s, len, + " -- Attempts to hard-synchronize \n" + "CPU and GPU.\n" + " \n" + "Can reduce latency at cost of \n" + "performance."); + break; + case MENU_LABEL_REWIND_GRANULARITY: + snprintf(s, len, + " -- Rewind granularity.\n" + " \n" + " When rewinding defined number of \n" + "frames, you can rewind several frames \n" + "at a time, increasing the rewinding \n" + "speed."); + break; + case MENU_LABEL_SCREENSHOT: + snprintf(s, len, + " -- Take screenshot."); + break; + case MENU_LABEL_VIDEO_FRAME_DELAY: + snprintf(s, len, + " -- Sets how many milliseconds to delay\n" + "after VSync before running the core.\n" + "\n" + "Can reduce latency at cost of\n" + "higher risk of stuttering.\n" + " \n" + "Maximum is 15."); + break; + case MENU_LABEL_VIDEO_HARD_SYNC_FRAMES: + snprintf(s, len, + " -- Sets how many frames CPU can \n" + "run ahead of GPU when using 'GPU \n" + "Hard Sync'.\n" + " \n" + "Maximum is 3.\n" + " \n" + " 0: Syncs to GPU immediately.\n" + " 1: Syncs to previous frame.\n" + " 2: Etc ..."); + break; + case MENU_LABEL_VIDEO_BLACK_FRAME_INSERTION: + snprintf(s, len, + " -- Inserts a black frame inbetween \n" + "frames.\n" + " \n" + "Useful for 120 Hz monitors who want to \n" + "play 60 Hz material with eliminated \n" + "ghosting.\n" + " \n" + "Video refresh rate should still be \n" + "configured as if it is a 60 Hz monitor \n" + "(divide refresh rate by 2)."); + break; + case MENU_LABEL_RGUI_SHOW_START_SCREEN: + snprintf(s, len, + " -- Show startup screen in menu.\n" + "Is automatically set to false when seen\n" + "for the first time.\n" + " \n" + "This is only updated in config if\n" + "'Save Configuration on Exit' is enabled.\n"); + break; + case MENU_LABEL_CORE_SPECIFIC_CONFIG: + snprintf(s, len, + " -- Load up a specific config file \n" + "based on the core being used.\n"); + break; + case MENU_LABEL_VIDEO_FULLSCREEN: + snprintf(s, len, " -- Toggles fullscreen."); + break; + case MENU_LABEL_BLOCK_SRAM_OVERWRITE: + snprintf(s, len, + " -- Block SRAM from being overwritten \n" + "when loading save states.\n" + " \n" + "Might potentially lead to buggy games."); + break; + case MENU_LABEL_PAUSE_NONACTIVE: + snprintf(s, len, + " -- Pause gameplay when window focus \n" + "is lost."); + break; + case MENU_LABEL_VIDEO_GPU_SCREENSHOT: + snprintf(s, len, + " -- Screenshots output of GPU shaded \n" + "material if available."); + break; + case MENU_LABEL_SCREENSHOT_DIRECTORY: + snprintf(s, len, + " -- Screenshot Directory. \n" + " \n" + "Directory to dump screenshots to." + ); + break; + case MENU_LABEL_VIDEO_SWAP_INTERVAL: + snprintf(s, len, + " -- VSync Swap Interval.\n" + " \n" + "Uses a custom swap interval for VSync. Set this \n" + "to effectively halve monitor refresh rate."); + break; + case MENU_LABEL_SAVEFILE_DIRECTORY: + snprintf(s, len, + " -- Savefile Directory. \n" + " \n" + "Save all save files (*.srm) to this \n" + "directory. This includes related files like \n" + ".bsv, .rt, .psrm, etc...\n" + " \n" + "This will be overridden by explicit command line\n" + "options."); + break; + case MENU_LABEL_SAVESTATE_DIRECTORY: + snprintf(s, len, + " -- Savestate Directory. \n" + " \n" + "Save all save states (*.state) to this \n" + "directory.\n" + " \n" + "This will be overridden by explicit command line\n" + "options."); + break; + case MENU_LABEL_ASSETS_DIRECTORY: + snprintf(s, len, + " -- Assets Directory. \n" + " \n" + " This location is queried by default when \n" + "menu interfaces try to look for loadable \n" + "assets, etc."); + break; + case MENU_LABEL_DYNAMIC_WALLPAPERS_DIRECTORY: + snprintf(s, len, + " -- Dynamic Wallpapers Directory. \n" + " \n" + " The place to store wallpapers that will \n" + "be loaded dynamically by the menu depending \n" + "on context."); + break; + case MENU_LABEL_SLOWMOTION_RATIO: + snprintf(s, len, + " -- Slowmotion ratio." + " \n" + "When slowmotion, content will slow\n" + "down by factor."); + break; + case MENU_LABEL_INPUT_AXIS_THRESHOLD: + snprintf(s, len, + " -- Defines axis threshold.\n" + " \n" + "How far an axis must be tilted to result\n" + "in a button press.\n" + " Possible values are [0.0, 1.0]."); + break; + case MENU_LABEL_INPUT_TURBO_PERIOD: + snprintf(s, len, + " -- Turbo period.\n" + " \n" + "Describes speed of which turbo-enabled\n" + "buttons toggle." + ); + break; + case MENU_LABEL_INPUT_AUTODETECT_ENABLE: + snprintf(s, len, + " -- Enable input auto-detection.\n" + " \n" + "Will attempt to auto-configure \n" + "joypads, Plug-and-Play style."); + break; + case MENU_LABEL_CAMERA_ALLOW: + snprintf(s, len, + " -- Allow or disallow camera access by \n" + "cores."); + break; + case MENU_LABEL_LOCATION_ALLOW: + snprintf(s, len, + " -- Allow or disallow location services \n" + "access by cores."); + break; + case MENU_LABEL_TURBO: + snprintf(s, len, + " -- Turbo enable.\n" + " \n" + "Holding the turbo while pressing another \n" + "button will let the button enter a turbo \n" + "mode where the button state is modulated \n" + "with a periodic signal. \n" + " \n" + "The modulation stops when the button \n" + "itself (not turbo button) is released."); + break; + case MENU_LABEL_OSK_ENABLE: + snprintf(s, len, + " -- Enable/disable on-screen keyboard."); + break; + case MENU_LABEL_AUDIO_MUTE: + snprintf(s, len, + " -- Mute/unmute audio."); + break; + case MENU_LABEL_REWIND: + snprintf(s, len, + " -- Hold button down to rewind.\n" + " \n" + "Rewind must be enabled."); + break; + case MENU_LABEL_EXIT_EMULATOR: + snprintf(s, len, + " -- Key to exit RetroArch cleanly." +#if !defined(RARCH_MOBILE) && !defined(RARCH_CONSOLE) + "\nKilling it in any hard way (SIGKILL, \n" + "etc) will terminate without saving\n" + "RAM, etc. On Unix-likes,\n" + "SIGINT/SIGTERM allows\n" + "a clean deinitialization." +#endif + ); + break; + case MENU_LABEL_LOAD_STATE: + snprintf(s, len, + " -- Loads state."); + break; + case MENU_LABEL_SAVE_STATE: + snprintf(s, len, + " -- Saves state."); + break; + case MENU_LABEL_NETPLAY_FLIP_PLAYERS: + snprintf(s, len, + " -- Netplay flip users."); + break; + case MENU_LABEL_CHEAT_INDEX_PLUS: + snprintf(s, len, + " -- Increment cheat index.\n"); + break; + case MENU_LABEL_CHEAT_INDEX_MINUS: + snprintf(s, len, + " -- Decrement cheat index.\n"); + break; + case MENU_LABEL_SHADER_PREV: + snprintf(s, len, + " -- Applies previous shader in directory."); + break; + case MENU_LABEL_SHADER_NEXT: + snprintf(s, len, + " -- Applies next shader in directory."); + break; + case MENU_LABEL_RESET: + snprintf(s, len, + " -- Reset the content.\n"); + break; + case MENU_LABEL_PAUSE_TOGGLE: + snprintf(s, len, + " -- Toggle between paused and non-paused state."); + break; + case MENU_LABEL_CHEAT_TOGGLE: + snprintf(s, len, + " -- Toggle cheat index.\n"); + break; + case MENU_LABEL_HOLD_FAST_FORWARD: + snprintf(s, len, + " -- Hold for fast-forward. Releasing button \n" + "disables fast-forward."); + break; + case MENU_LABEL_SLOWMOTION: + snprintf(s, len, + " -- Hold for slowmotion."); + break; + case MENU_LABEL_FRAME_ADVANCE: + snprintf(s, len, + " -- Frame advance when content is paused."); + break; + case MENU_LABEL_MOVIE_RECORD_TOGGLE: + snprintf(s, len, + " -- Toggle between recording and not."); + break; + case MENU_LABEL_L_X_PLUS: + case MENU_LABEL_L_X_MINUS: + case MENU_LABEL_L_Y_PLUS: + case MENU_LABEL_L_Y_MINUS: + case MENU_LABEL_R_X_PLUS: + case MENU_LABEL_R_X_MINUS: + case MENU_LABEL_R_Y_PLUS: + case MENU_LABEL_R_Y_MINUS: + snprintf(s, len, + " -- Axis for analog stick (DualShock-esque).\n" + " \n" + "Bound as usual, however, if a real analog \n" + "axis is bound, it can be read as a true analog.\n" + " \n" + "Positive X axis is right. \n" + "Positive Y axis is down."); + break; + default: + return -1; + } + + return 0; +} + /** * setting_get_description: * @label : identifier label of setting @@ -2037,947 +3030,13 @@ int setting_get_description(const char *label, char *s, size_t len) { settings_t *settings = config_get_ptr(); + uint32_t label_hash = djb2_calculate(label); - if (!strcmp(label, "input_driver")) - { - if (!strcmp(settings->input.driver, "udev")) - snprintf(s, len, - " -- udev Input driver. \n" - " \n" - "This driver can run without X. \n" - " \n" - "It uses the recent evdev joypad API \n" - "for joystick support. It supports \n" - "hotplugging and force feedback (if \n" - "supported by device). \n" - " \n" - "The driver reads evdev events for keyboard \n" - "support. It also supports keyboard callback, \n" - "mice and touchpads. \n" - " \n" - "By default in most distros, /dev/input nodes \n" - "are root-only (mode 600). You can set up a udev \n" - "rule which makes these accessible to non-root." - ); - else if (!strcmp(settings->input.driver, "linuxraw")) - snprintf(s, len, - " -- linuxraw Input driver. \n" - " \n" - "This driver requires an active TTY. Keyboard \n" - "events are read directly from the TTY which \n" - "makes it simpler, but not as flexible as udev. \n" "Mice, etc, are not supported at all. \n" - " \n" - "This driver uses the older joystick API \n" - "(/dev/input/js*)."); - else - snprintf(s, len, - " -- Input driver.\n" - " \n" - "Depending on video driver, it might \n" - "force a different input driver."); + if (setting_get_description_compare_label(label_hash, settings, s, len) == 0) + return 0; - } - else if (!strcmp(label, "load_content")) - { - snprintf(s, len, - " -- Load Content. \n" - "Browse for content. \n" - " \n" - "To load content, you need a \n" - "libretro core to use, and a \n" - "content file. \n" - " \n" - "To control where the menu starts \n" - " to browse for content, set \n" - "Browser Directory. If not set, \n" - "it will start in root. \n" - " \n" - "The browser will filter out \n" - "extensions for the last core set \n" - "in 'Core', and use that core when \n" - "content is loaded." - ); - } - else if (!strcmp(label, "core_list")) - { - snprintf(s, len, - " -- Core Selection. \n" - " \n" - "Browse for a libretro core \n" - "implementation. Where the browser \n" - "starts depends on your Core Directory \n" - "path. If blank, it will start in root. \n" - " \n" - "If Core Directory is a directory, the menu \n" - "will use that as top folder. If Core \n" - "Directory is a full path, it will start \n" - "in the folder where the file is."); - } - else if (!strcmp(label, "history_list")) - { - snprintf(s, len, - " -- Loading content from history. \n" - " \n" - "As content is loaded, content and libretro \n" - "core combinations are saved to history. \n" - " \n" - "The history is saved to a file in the same \n" - "directory as the RetroArch config file. If \n" - "no config file was loaded in startup, history \n" - "will not be saved or loaded, and will not exist \n" - "in the main menu." - ); - } - else if (!strcmp(label, "audio_resampler_driver")) - { - if (!strcmp(settings->audio.resampler, "sinc")) - snprintf(s, len, - " -- Windowed SINC implementation."); - else if (!strcmp(settings->audio.resampler, "CC")) - snprintf(s, len, - " -- Convoluted Cosine implementation."); - } - else if (!strcmp(label, "video_driver")) - { - if (!strcmp(settings->video.driver, "gl")) - snprintf(s, len, - " -- OpenGL Video driver. \n" - " \n" - "This driver allows libretro GL cores to \n" - "be used in addition to software-rendered \n" - "core implementations.\n" - " \n" - "Performance for software-rendered and \n" - "libretro GL core implementations is \n" - "dependent on your graphics card's \n" - "underlying GL driver)."); - else if (!strcmp(settings->video.driver, "sdl2")) - snprintf(s, len, - " -- SDL 2 Video driver.\n" - " \n" - "This is an SDL 2 software-rendered video \n" - "driver.\n" - " \n" - "Performance for software-rendered libretro \n" - "core implementations is dependent \n" - "on your platform SDL implementation."); - else if (!strcmp(settings->video.driver, "sdl")) - snprintf(s, len, - " -- SDL Video driver.\n" - " \n" - "This is an SDL 1.2 software-rendered video \n" - "driver.\n" - " \n" - "Performance is considered to be suboptimal. \n" - "Consider using it only as a last resort."); - else if (!strcmp(settings->video.driver, "d3d")) - snprintf(s, len, - " -- Direct3D Video driver. \n" - " \n" - "Performance for software-rendered cores \n" - "is dependent on your graphic card's \n" - "underlying D3D driver)."); - else if (!strcmp(settings->video.driver, "exynos")) - snprintf(s, len, - " -- Exynos-G2D Video Driver. \n" - " \n" - "This is a low-level Exynos video driver. \n" - "Uses the G2D block in Samsung Exynos SoC \n" - "for blit operations. \n" - " \n" - "Performance for software rendered cores \n" - "should be optimal."); - else if (!strcmp(settings->video.driver, "sunxi")) - snprintf(s, len, - " -- Sunxi-G2D Video Driver. \n" - " \n" - "This is a low-level Sunxi video driver. \n" - "Uses the G2D block in Allwinner SoCs."); - else - snprintf(s, len, - " -- Current Video driver."); - } - else if (!strcmp(label, "audio_dsp_plugin")) - { - snprintf(s, len, - " -- Audio DSP plugin.\n" - " Processes audio before it's sent to \n" - "the driver." - ); - } - else if (!strcmp(label, "libretro_dir_path")) - { - snprintf(s, len, - " -- Core Directory. \n" - " \n" - "A directory for where to search for \n" - "libretro core implementations."); - } - else if (!strcmp(label, "video_disable_composition")) - { - snprintf(s, len, - "-- Forcibly disable composition.\n" - "Only valid on Windows Vista/7 for now."); - } - else if (!strcmp(label, "libretro_log_level")) - { - snprintf(s, len, - "-- Sets log level for libretro cores \n" - "(GET_LOG_INTERFACE). \n" - " \n" - " If a log level issued by a libretro \n" - " core is below libretro_log level, it \n" - " is ignored.\n" - " \n" - " DEBUG logs are always ignored unless \n" - " verbose mode is activated (--verbose).\n" - " \n" - " DEBUG = 0\n" - " INFO = 1\n" - " WARN = 2\n" - " ERROR = 3" - ); - } - else if (!strcmp(label, "log_verbosity")) - { - snprintf(s, len, - "-- Enable or disable verbosity level \n" - "of frontend."); - } - else if (!strcmp(label, "perfcnt_enable")) - { - snprintf(s, len, - "-- Enable or disable frontend \n" - "performance counters."); - } - else if (!strcmp(label, "system_directory")) - { - snprintf(s, len, - "-- System Directory. \n" - " \n" - "Sets the 'system' directory.\n" - "Cores can query for this\n" - "directory to load BIOSes, \n" - "system-specific configs, etc."); - } - else if (!strcmp(label, "rgui_show_start_screen")) - { - snprintf(s, len, - " -- Show startup screen in menu.\n" - "Is automatically set to false when seen\n" - "for the first time.\n" - " \n" - "This is only updated in config if\n" - "'Save Configuration on Exit' is enabled.\n"); - } - else if (!strcmp(label, "config_save_on_exit")) - { - snprintf(s, len, - " -- Saves config to disk on exit.\n" - "Useful for menu as settings can be\n" - "modified. Overwrites the config.\n" - " \n" - "#include's and comments are not \n" - "preserved. \n" - " \n" - "By design, the config file is \n" - "considered immutable as it is \n" - "likely maintained by the user, \n" - "and should not be overwritten \n" - "behind the user's back." -#if defined(RARCH_CONSOLE) || defined(RARCH_MOBILE) - "\nThis is not not the case on \n" - "consoles however, where \n" - "looking at the config file \n" - "manually isn't really an option." -#endif - ); - } - else if (!strcmp(label, "core_specific_config")) - { - snprintf(s, len, - " -- Load up a specific config file \n" - "based on the core being used.\n"); - } - else if (!strcmp(label, "video_scale")) - { - snprintf(s, len, - " -- Fullscreen resolution.\n" - " \n" - "Resolution of 0 uses the \n" - "resolution of the environment.\n"); - } - else if (!strcmp(label, "video_vsync")) - { - snprintf(s, len, - " -- Video V-Sync.\n"); - } - else if (!strcmp(label, "video_hard_sync")) - { - snprintf(s, len, - " -- Attempts to hard-synchronize \n" - "CPU and GPU.\n" - " \n" - "Can reduce latency at cost of \n" - "performance."); - } - else if (!strcmp(label, "video_hard_sync_frames")) - { - snprintf(s, len, - " -- Sets how many frames CPU can \n" - "run ahead of GPU when using 'GPU \n" - "Hard Sync'.\n" - " \n" - "Maximum is 3.\n" - " \n" - " 0: Syncs to GPU immediately.\n" - " 1: Syncs to previous frame.\n" - " 2: Etc ..."); - } - else if (!strcmp(label, "video_frame_delay")) - { - snprintf(s, len, - " -- Sets how many milliseconds to delay\n" - "after VSync before running the core.\n" - "\n" - "Can reduce latency at cost of\n" - "higher risk of stuttering.\n" - " \n" - "Maximum is 15."); - } - else if (!strcmp(label, "audio_rate_control_delta")) - { - snprintf(s, len, - " -- Audio rate control.\n" - " \n" - "Setting this to 0 disables rate control.\n" - "Any other value controls audio rate control \n" - "delta.\n" - " \n" - "Defines how much input rate can be adjusted \n" - "dynamically.\n" - " \n" - " Input rate is defined as: \n" - " input rate * (1.0 +/- (rate control delta))"); - } - else if (!strcmp(label, "audio_max_timing_skew")) - { - snprintf(s, len, - " -- Maximum audio timing skew.\n" - " \n" - "Defines the maximum change in input rate.\n" - "You may want to increase this to enable\n" - "very large changes in timing, for example\n" - "running PAL cores on NTSC displays, at the\n" - "cost of inaccurate audio pitch.\n" - " \n" - " Input rate is defined as: \n" - " input rate * (1.0 +/- (max timing skew))"); - } - else if (!strcmp(label, "video_filter")) - { -#ifdef HAVE_FILTERS_BUILTIN - snprintf(s, len, - " -- CPU-based video filter."); -#else - snprintf(s, len, - " -- CPU-based video filter.\n" - " \n" - "Path to a dynamic library."); -#endif - } - else if (!strcmp(label, "video_fullscreen")) - { - snprintf(s, len, " -- Toggles fullscreen."); - } - else if (!strcmp(label, "audio_device")) - { - snprintf(s, len, - " -- Override the default audio device \n" - "the audio driver uses.\n" - "This is driver dependent. E.g.\n" -#ifdef HAVE_ALSA - " \n" - "ALSA wants a PCM device." -#endif -#ifdef HAVE_OSS - " \n" - "OSS wants a path (e.g. /dev/dsp)." -#endif -#ifdef HAVE_JACK - " \n" - "JACK wants portnames (e.g. system:playback1\n" - ",system:playback_2)." -#endif -#ifdef HAVE_RSOUND - " \n" - "RSound wants an IP address to an RSound \n" - "server." -#endif - ); - } - else if (!strcmp(label, "video_black_frame_insertion")) - { - snprintf(s, len, - " -- Inserts a black frame inbetween \n" - "frames.\n" - " \n" - "Useful for 120 Hz monitors who want to \n" - "play 60 Hz material with eliminated \n" - "ghosting.\n" - " \n" - "Video refresh rate should still be \n" - "configured as if it is a 60 Hz monitor \n" - "(divide refresh rate by 2)."); - } - else if (!strcmp(label, "video_threaded")) - { - snprintf(s, len, - " -- Use threaded video driver.\n" - " \n" - "Using this might improve performance at \n" - "possible cost of latency and more video \n" - "stuttering."); - } - else if (!strcmp(label, "video_scale_integer")) - { - snprintf(s, len, - " -- Only scales video in integer \n" - "steps.\n" - " \n" - "The base size depends on system-reported \n" - "geometry and aspect ratio.\n" - " \n" - "If Force Aspect is not set, X/Y will be \n" - "integer scaled independently."); - } - else if (!strcmp(label, "video_crop_overscan")) - { - snprintf(s, len, - " -- Forces cropping of overscanned \n" - "frames.\n" - " \n" - "Exact behavior of this option is \n" - "core-implementation specific."); - } - else if (!strcmp(label, "video_monitor_index")) - { - snprintf(s, len, - " -- Which monitor to prefer.\n" - " \n" - "0 (default) means no particular monitor \n" - "is preferred, 1 and up (1 being first \n" - "monitor), suggests RetroArch to use that \n" - "particular monitor."); - } - else if (!strcmp(label, "video_rotation")) - { - snprintf(s, len, - " -- Forces a certain rotation \n" - "of the screen.\n" - " \n" - "The rotation is added to rotations which\n" - "the libretro core sets (see Video Allow\n" - "Rotate)."); - } - else if (!strcmp(label, "audio_volume")) - { - snprintf(s, len, - " -- Audio volume, expressed in dB.\n" - " \n" - " 0 dB is normal volume. No gain will be applied.\n" - "Gain can be controlled in runtime with Input\n" - "Volume Up / Input Volume Down."); - } - else if (!strcmp(label, "block_sram_overwrite")) - { - snprintf(s, len, - " -- Block SRAM from being overwritten \n" - "when loading save states.\n" - " \n" - "Might potentially lead to buggy games."); - } - else if (!strcmp(label, "fastforward_ratio")) - { - snprintf(s, len, - " -- Fastforward ratio." - " \n" - "The maximum rate at which content will\n" - "be run when using fast forward.\n" - " \n" - " (E.g. 5.0 for 60 fps content => 300 fps \n" - "cap).\n" - " \n" - "RetroArch will go to sleep to ensure that \n" - "the maximum rate will not be exceeded.\n" - "Do not rely on this cap to be perfectly \n" - "accurate."); - } - else if (!strcmp(label, "pause_nonactive")) - { - snprintf(s, len, - " -- Pause gameplay when window focus \n" - "is lost."); - } - else if (!strcmp(label, "video_gpu_screenshot")) - { - snprintf(s, len, - " -- Screenshots output of GPU shaded \n" - "material if available."); - } - else if (!strcmp(label, "autosave_interval")) - { - snprintf(s, len, - " -- Autosaves the non-volatile SRAM \n" - "at a regular interval.\n" - " \n" - "This is disabled by default unless set \n" - "otherwise. The interval is measured in \n" - "seconds. \n" - " \n" - "A value of 0 disables autosave."); - } - else if (!strcmp(label, "screenshot_directory")) - { - snprintf(s, len, - " -- Screenshot Directory. \n" - " \n" - "Directory to dump screenshots to." - ); - } - else if (!strcmp(label, "video_swap_interval")) - { - snprintf(s, len, - " -- VSync Swap Interval.\n" - " \n" - "Uses a custom swap interval for VSync. Set this \n" - "to effectively halve monitor refresh rate."); - } - else if (!strcmp(label, "video_refresh_rate_auto")) - { - snprintf(s, len, - " -- Refresh Rate Auto.\n" - " \n" - "The accurate refresh rate of our monitor (Hz).\n" - "This is used to calculate audio input rate with \n" - "the formula: \n" - " \n" - "audio_input_rate = game input rate * display \n" - "refresh rate / game refresh rate\n" - " \n" - "If the implementation does not report any \n" - "values, NTSC defaults will be assumed for \n" - "compatibility.\n" - " \n" - "This value should stay close to 60Hz to avoid \n" - "large pitch changes. If your monitor does \n" - "not run at 60Hz, or something close to it, \n" - "disable VSync, and leave this at its default."); - } - else if (!strcmp(label, "savefile_directory")) - { - snprintf(s, len, - " -- Savefile Directory. \n" - " \n" - "Save all save files (*.srm) to this \n" - "directory. This includes related files like \n" - ".bsv, .rt, .psrm, etc...\n" - " \n" - "This will be overridden by explicit command line\n" - "options."); - } - else if (!strcmp(label, "savestate_directory")) - { - snprintf(s, len, - " -- Savestate Directory. \n" - " \n" - "Save all save states (*.state) to this \n" - "directory.\n" - " \n" - "This will be overridden by explicit command line\n" - "options."); - } - else if (!strcmp(label, "assets_directory")) - { - snprintf(s, len, - " -- Assets Directory. \n" - " \n" - " This location is queried by default when \n" - "menu interfaces try to look for loadable \n" - "assets, etc."); - } - else if (!strcmp(label, "dynamic_wallpapers_directory")) - { - snprintf(s, len, - " -- Dynamic Wallpapers Directory. \n" - " \n" - " The place to store wallpapers that will \n" - "be loaded dynamically by the menu depending \n" - "on context."); - } - else if (!strcmp(label, "slowmotion_ratio")) - { - snprintf(s, len, - " -- Slowmotion ratio." - " \n" - "When slowmotion, content will slow\n" - "down by factor."); - } - else if (!strcmp(label, "input_axis_threshold")) - { - snprintf(s, len, - " -- Defines axis threshold.\n" - " \n" - "How far an axis must be tilted to result\n" - "in a button press.\n" - " Possible values are [0.0, 1.0]."); - } - else if (!strcmp(label, "input_turbo_period")) - { - snprintf(s, len, - " -- Turbo period.\n" - " \n" - "Describes speed of which turbo-enabled\n" - "buttons toggle." - ); - } - else if (!strcmp(label, "rewind_granularity")) - { - snprintf(s, len, - " -- Rewind granularity.\n" - " \n" - " When rewinding defined number of \n" - "frames, you can rewind several frames \n" - "at a time, increasing the rewinding \n" - "speed."); - } - else if (!strcmp(label, "rewind_enable")) - { - snprintf(s, len, - " -- Enable rewinding.\n" - " \n" - "This will take a performance hit, \n" - "so it is disabled by default."); - } - else if (!strcmp(label, "input_autodetect_enable")) - { - snprintf(s, len, - " -- Enable input auto-detection.\n" - " \n" - "Will attempt to auto-configure \n" - "joypads, Plug-and-Play style."); - } - else if (!strcmp(label, "camera_allow")) - { - snprintf(s, len, - " -- Allow or disallow camera access by \n" - "cores."); - } - else if (!strcmp(label, "location_allow")) - { - snprintf(s, len, - " -- Allow or disallow location services \n" - "access by cores."); - } - else if (!strcmp(label, "savestate_auto_save")) - { - snprintf(s, len, - " -- Automatically saves a savestate at the \n" - "end of RetroArch's lifetime.\n" - " \n" - "RetroArch will automatically load any savestate\n" - "with this path on startup if 'Auto Load State\n" - "is enabled."); - } - else if (!strcmp(label, "shader_apply_changes")) - { - snprintf(s, len, - " -- Apply Shader Changes. \n" - " \n" - "After changing shader settings, use this to \n" - "apply changes. \n" - " \n" - "Changing shader settings is a somewhat \n" - "expensive operation so it has to be \n" - "done explicitly. \n" - " \n" - "When you apply shaders, the menu shader \n" - "settings are saved to a temporary file (either \n" - "menu.cgp or menu.glslp) and loaded. The file \n" - "persists after RetroArch exits. The file is \n" - "saved to Shader Directory." - ); - - } - else if (!strcmp(label, "video_shader_preset")) - { - snprintf(s, len, - " -- Load Shader Preset. \n" - " \n" - " Load a " -#ifdef HAVE_CG - "Cg" -#endif -#ifdef HAVE_GLSL -#ifdef HAVE_CG - "/" -#endif - "GLSL" -#endif -#ifdef HAVE_HLSL -#if defined(HAVE_CG) || defined(HAVE_HLSL) - "/" -#endif - "HLSL" -#endif - " preset directly. \n" - "The menu shader menu is updated accordingly. \n" - " \n" - "If the CGP uses scaling methods which are not \n" - "simple, (i.e. source scaling, same scaling \n" - "factor for X/Y), the scaling factor displayed \n" - "in the menu might not be correct." - ); - } - else if (!strcmp(label, "video_shader_num_passes")) - { - snprintf(s, len, - " -- Shader Passes. \n" - " \n" - "RetroArch allows you to mix and match various \n" - "shaders with arbitrary shader passes, with \n" - "custom hardware filters and scale factors. \n" - " \n" - "This option specifies the number of shader \n" - "passes to use. If you set this to 0, and use \n" - "Apply Shader Changes, you use a 'blank' shader. \n" - " \n" - "The Default Filter option will affect the \n" - "stretching filter."); - } - else if (!strcmp(label, "video_shader_parameters")) - { - snprintf(s, len, - "-- Shader Parameters. \n" - " \n" - "Modifies current shader directly. Will not be \n" - "saved to CGP/GLSLP preset file."); - } - else if (!strcmp(label, "video_shader_preset_parameters")) - { - snprintf(s, len, - "-- Shader Preset Parameters. \n" - " \n" - "Modifies shader preset currently in menu." - ); - } - else if (!strcmp(label, "video_shader_pass")) - { - snprintf(s, len, - " -- Path to shader. \n" - " \n" - "All shaders must be of the same \n" - "type (i.e. CG, GLSL or HLSL). \n" - " \n" - "Set Shader Directory to set where \n" - "the browser starts to look for \n" - "shaders." - ); - } - else if (!strcmp(label, "video_shader_filter_pass")) - { - snprintf(s, len, - " -- Hardware filter for this pass. \n" - " \n" - "If 'Don't Care' is set, 'Default \n" - "Filter' will be used." - ); - } - else if (!strcmp(label, "video_shader_scale_pass")) - { - snprintf(s, len, - " -- Scale for this pass. \n" - " \n" - "The scale factor accumulates, i.e. 2x \n" - "for first pass and 2x for second pass \n" - "will give you a 4x total scale. \n" - " \n" - "If there is a scale factor for last \n" - "pass, the result is stretched to \n" - "screen with the filter specified in \n" - "'Default Filter'. \n" - " \n" - "If 'Don't Care' is set, either 1x \n" - "scale or stretch to fullscreen will \n" - "be used depending if it's not the last \n" - "pass or not." - ); - } - else if ( - !strcmp(label, "l_x_plus") || - !strcmp(label, "l_x_minus") || - !strcmp(label, "l_y_plus") || - !strcmp(label, "l_y_minus") - ) - snprintf(s, len, - " -- Axis for analog stick (DualShock-esque).\n" - " \n" - "Bound as usual, however, if a real analog \n" - "axis is bound, it can be read as a true analog.\n" - " \n" - "Positive X axis is right. \n" - "Positive Y axis is down."); - else if (!strcmp(label, "turbo")) - snprintf(s, len, - " -- Turbo enable.\n" - " \n" - "Holding the turbo while pressing another \n" - "button will let the button enter a turbo \n" - "mode where the button state is modulated \n" - "with a periodic signal. \n" - " \n" - "The modulation stops when the button \n" - "itself (not turbo button) is released."); - else if (!strcmp(label, "exit_emulator")) - snprintf(s, len, - " -- Key to exit RetroArch cleanly." -#if !defined(RARCH_MOBILE) && !defined(RARCH_CONSOLE) - "\nKilling it in any hard way (SIGKILL, \n" - "etc) will terminate without saving\n" - "RAM, etc. On Unix-likes,\n" - "SIGINT/SIGTERM allows\n" - "a clean deinitialization." -#endif - ); - else if (!strcmp(label, "rewind")) - snprintf(s, len, - " -- Hold button down to rewind.\n" - " \n" - "Rewind must be enabled."); - else if (!strcmp(label, "load_state")) - snprintf(s, len, - " -- Loads state."); - else if (!strcmp(label, "save_state")) - snprintf(s, len, - " -- Saves state."); - else if (!strcmp(label, "state_slot_increase") || - !strcmp(label, "state_slot_decrease")) - snprintf(s, len, - " -- State slots.\n" - " \n" - " With slot set to 0, save state name is *.state \n" - " (or whatever defined on commandline).\n" - "When slot is != 0, path will be (path)(d), \n" - "where (d) is slot number."); - else if (!strcmp(label, "netplay_flip_players")) - snprintf(s, len, - " -- Netplay flip users."); - else if (!strcmp(label, "frame_advance")) - snprintf(s, len, - " -- Frame advance when content is paused."); - else if (!strcmp(label, "enable_hotkey")) - snprintf(s, len, - " -- Enable other hotkeys.\n" - " \n" - " If this hotkey is bound to either keyboard, \n" - "joybutton or joyaxis, all other hotkeys will \n" - "be disabled unless this hotkey is also held \n" - "at the same time. \n" - " \n" - "This is useful for RETRO_KEYBOARD centric \n" - "implementations which query a large area of \n" - "the keyboard, where it is not desirable that \n" - "hotkeys get in the way."); - else if (!strcmp(label, "slowmotion")) - snprintf(s, len, - " -- Hold for slowmotion."); - else if (!strcmp(label, "movie_record_toggle")) - snprintf(s, len, - " -- Toggle between recording and not."); - else if (!strcmp(label, "pause_toggle")) - snprintf(s, len, - " -- Toggle between paused and non-paused state."); - else if (!strcmp(label, "hold_fast_forward")) - snprintf(s, len, - " -- Hold for fast-forward. Releasing button \n" - "disables fast-forward."); - else if (!strcmp(label, "shader_next")) - snprintf(s, len, - " -- Applies next shader in directory."); - else if (!strcmp(label, "reset")) - snprintf(s, len, - " -- Reset the content.\n"); - else if (!strcmp(label, "cheat_index_plus")) - snprintf(s, len, - " -- Increment cheat index.\n"); - else if (!strcmp(label, "cheat_index_minus")) - snprintf(s, len, - " -- Decrement cheat index.\n"); - else if (!strcmp(label, "cheat_toggle")) - snprintf(s, len, - " -- Toggle cheat index.\n"); - else if (!strcmp(label, "shader_prev")) - snprintf(s, len, - " -- Applies previous shader in directory."); - else if (!strcmp(label, "audio_mute")) - snprintf(s, len, - " -- Mute/unmute audio."); - else if (!strcmp(label, "osk_enable")) - snprintf(s, len, - " -- Enable/disable on-screen keyboard."); - else if (!strcmp(label, "screenshot")) - snprintf(s, len, - " -- Take screenshot."); - else if (!strcmp(label, "volume_up")) - snprintf(s, len, - " -- Increases audio volume."); - else if (!strcmp(label, "volume_down")) - snprintf(s, len, - " -- Decreases audio volume."); - else if (!strcmp(label, "overlay_next")) - snprintf(s, len, - " -- Toggles to next overlay.\n" - " \n" - "Wraps around."); - else if (!strcmp(label, "disk_eject_toggle")) - snprintf(s, len, - " -- Toggles eject for disks.\n" - " \n" - "Used for multiple-disk content."); - else if (!strcmp(label, "disk_next")) - snprintf(s, len, - " -- Cycles through disk images. Use after \n" - "ejecting. \n" - " \n" - " Complete by toggling eject again."); - else if (!strcmp(label, "grab_mouse_toggle")) - snprintf(s, len, - " -- Toggles mouse grab.\n" - " \n" - "When mouse is grabbed, RetroArch hides the \n" - "mouse, and keeps the mouse pointer inside \n" - "the window to allow relative mouse input to \n" - "work better."); - else if (!strcmp(label, "menu_toggle")) - snprintf(s, len, - " -- Toggles menu."); - else if (!strcmp(label, "input_bind_device_id")) - snprintf(s, len, - " -- Input Device. \n" - " \n" - "Picks which gamepad to use for user N. \n" - "The name of the pad is available." - ); - else if (!strcmp(label, "input_bind_device_type")) - snprintf(s, len, - " -- Input Device Type. \n" - " \n" - "Picks which device type to use. This is \n" - "relevant for the libretro core itself." - ); - else - snprintf(s, len, - "-- No info on this item is available. --\n"); + snprintf(s, len, + "-- No info on this item is available. --\n"); return 0; } @@ -3054,38 +3113,48 @@ static void general_read_handler(void *data) { rarch_setting_t *setting = (rarch_setting_t*)data; settings_t *settings = config_get_ptr(); + uint32_t hash = setting ? djb2_calculate(setting->name) : 0; if (!setting) return; - if (!strcmp(setting->name, "audio_rate_control_delta")) + switch (hash) { - *setting->value.fraction = settings->audio.rate_control_delta; - if (*setting->value.fraction < 0.0005) - { - settings->audio.rate_control = false; - settings->audio.rate_control_delta = 0.0; - } - else - { - settings->audio.rate_control = true; - settings->audio.rate_control_delta = *setting->value.fraction; - } + case MENU_LABEL_AUDIO_RATE_CONTROL_DELTA: + *setting->value.fraction = settings->audio.rate_control_delta; + if (*setting->value.fraction < 0.0005) + { + settings->audio.rate_control = false; + settings->audio.rate_control_delta = 0.0; + } + else + { + settings->audio.rate_control = true; + settings->audio.rate_control_delta = *setting->value.fraction; + } + break; + case MENU_LABEL_AUDIO_MAX_TIMING_SKEW: + *setting->value.fraction = settings->audio.max_timing_skew; + break; + case MENU_LABEL_VIDEO_REFRESH_RATE_AUTO: + *setting->value.fraction = settings->video.refresh_rate; + break; + case MENU_LABEL_INPUT_PLAYER1_JOYPAD_INDEX: + *setting->value.integer = settings->input.joypad_map[0]; + break; + case MENU_LABEL_INPUT_PLAYER2_JOYPAD_INDEX: + *setting->value.integer = settings->input.joypad_map[1]; + break; + case MENU_LABEL_INPUT_PLAYER3_JOYPAD_INDEX: + *setting->value.integer = settings->input.joypad_map[2]; + break; + case MENU_LABEL_INPUT_PLAYER4_JOYPAD_INDEX: + *setting->value.integer = settings->input.joypad_map[3]; + break; + case MENU_LABEL_INPUT_PLAYER5_JOYPAD_INDEX: + *setting->value.integer = settings->input.joypad_map[4]; + break; } - else if (!strcmp(setting->name, "audio_max_timing_skew")) - *setting->value.fraction = settings->audio.max_timing_skew; - else if (!strcmp(setting->name, "video_refresh_rate_auto")) - *setting->value.fraction = settings->video.refresh_rate; - else if (!strcmp(setting->name, "input_player1_joypad_index")) - *setting->value.integer = settings->input.joypad_map[0]; - else if (!strcmp(setting->name, "input_player2_joypad_index")) - *setting->value.integer = settings->input.joypad_map[1]; - else if (!strcmp(setting->name, "input_player3_joypad_index")) - *setting->value.integer = settings->input.joypad_map[2]; - else if (!strcmp(setting->name, "input_player4_joypad_index")) - *setting->value.integer = settings->input.joypad_map[3]; - else if (!strcmp(setting->name, "input_player5_joypad_index")) - *setting->value.integer = settings->input.joypad_map[4]; } static void general_write_handler(void *data) @@ -3096,6 +3165,8 @@ static void general_write_handler(void *data) settings_t *settings = config_get_ptr(); driver_t *driver = driver_get_ptr(); global_t *global = global_get_ptr(); + menu_list_t *menu_list = menu_list_get_ptr(); + uint32_t hash = setting ? djb2_calculate(setting->name) : 0; if (!setting) return; @@ -3112,125 +3183,129 @@ static void general_write_handler(void *data) rarch_cmd = setting->cmd_trigger.idx; } - if (!strcmp(setting->name, "help")) + switch (hash) { - menu_handle_t *menu = menu_driver_get_ptr(); + case MENU_LABEL_HELP: + if (!menu_list) + return; - if (!menu || !menu->menu_list) - return; + if (*setting->value.boolean) + { + info.list = menu_list->menu_stack; + info.type = 0; + info.directory_ptr = 0; + strlcpy(info.label, "help", sizeof(info.label)); - if (*setting->value.boolean) - { - info.list = menu->menu_list->menu_stack; - info.type = 0; - info.directory_ptr = 0; - strlcpy(info.label, "help", sizeof(info.label)); + menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); + setting_set_with_string_representation(setting, "false"); + } + break; + case MENU_LABEL_AUDIO_MAX_TIMING_SKEW: + settings->audio.max_timing_skew = *setting->value.fraction; + break; + case MENU_LABEL_AUDIO_RATE_CONTROL_DELTA: + if (*setting->value.fraction < 0.0005) + { + settings->audio.rate_control = false; + settings->audio.rate_control_delta = 0.0; + } + else + { + settings->audio.rate_control = true; + settings->audio.rate_control_delta = *setting->value.fraction; + } + break; + case MENU_LABEL_VIDEO_REFRESH_RATE_AUTO: + if (driver->video && driver->video_data) + { + driver_set_refresh_rate(*setting->value.fraction); - menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); - setting_set_with_string_representation(setting, "false"); - } - } - else if (!strcmp(setting->name, "video_smooth")) - { - video_driver_set_filtering(1, settings->video.smooth); - } - else if (!strcmp(setting->name, "pal60_enable")) - { - if (*setting->value.boolean && global->console.screen.pal_enable) - rarch_cmd = EVENT_CMD_REINIT; - else - setting_set_with_string_representation(setting, "false"); - } - else if (!strcmp(setting->name, "video_rotation")) - { - video_driver_set_rotation( + /* In case refresh rate update forced non-block video. */ + rarch_cmd = EVENT_CMD_VIDEO_SET_BLOCKING_STATE; + } + break; + case MENU_LABEL_VIDEO_SCALE: + settings->video.scale = roundf(*setting->value.fraction); + + if (!settings->video.fullscreen) + rarch_cmd = EVENT_CMD_REINIT; + break; + case MENU_LABEL_INPUT_PLAYER1_JOYPAD_INDEX: + settings->input.joypad_map[0] = *setting->value.integer; + break; + case MENU_LABEL_INPUT_PLAYER2_JOYPAD_INDEX: + settings->input.joypad_map[1] = *setting->value.integer; + break; + case MENU_LABEL_INPUT_PLAYER3_JOYPAD_INDEX: + settings->input.joypad_map[2] = *setting->value.integer; + break; + case MENU_LABEL_INPUT_PLAYER4_JOYPAD_INDEX: + settings->input.joypad_map[3] = *setting->value.integer; + break; + case MENU_LABEL_INPUT_PLAYER5_JOYPAD_INDEX: + settings->input.joypad_map[4] = *setting->value.integer; + break; + case MENU_LABEL_LOG_VERBOSITY: + global->verbosity = *setting->value.boolean; + global->has_set_verbosity = *setting->value.boolean; + break; + case MENU_LABEL_VIDEO_SMOOTH: + video_driver_set_filtering(1, settings->video.smooth); + break; + case MENU_LABEL_VIDEO_ROTATION: + video_driver_set_rotation( (*setting->value.unsigned_integer + global->system.rotation) % 4); - } - else if (!strcmp(setting->name, "system_bgm_enable")) - { - if (*setting->value.boolean) - { + break; + case MENU_LABEL_AUDIO_VOLUME: + audio_driver_set_volume_gain(db_to_gain(*setting->value.fraction)); + break; + case MENU_LABEL_AUDIO_LATENCY: + rarch_cmd = EVENT_CMD_AUDIO_REINIT; + break; + case MENU_LABEL_PAL60_ENABLE: + if (*setting->value.boolean && global->console.screen.pal_enable) + rarch_cmd = EVENT_CMD_REINIT; + else + setting_set_with_string_representation(setting, "false"); + break; + case MENU_LABEL_SYSTEM_BGM_ENABLE: + if (*setting->value.boolean) + { #if defined(__CELLOS_LV2__) && (CELL_SDK_VERSION > 0x340000) - cellSysutilEnableBgmPlayback(); + cellSysutilEnableBgmPlayback(); #endif - } - else - { + } + else + { #if defined(__CELLOS_LV2__) && (CELL_SDK_VERSION > 0x340000) - cellSysutilDisableBgmPlayback(); + cellSysutilDisableBgmPlayback(); #endif - } - } - else if (!strcmp(setting->name, "audio_volume")) - { - audio_driver_set_volume_gain(db_to_gain(*setting->value.fraction)); - } - else if (!strcmp(setting->name, "audio_latency")) - rarch_cmd = EVENT_CMD_AUDIO_REINIT; - else if (!strcmp(setting->name, "audio_rate_control_delta")) - { - if (*setting->value.fraction < 0.0005) - { - settings->audio.rate_control = false; - settings->audio.rate_control_delta = 0.0; - } - else - { - settings->audio.rate_control = true; - settings->audio.rate_control_delta = *setting->value.fraction; - } - } - else if (!strcmp(setting->name, "audio_max_timing_skew")) - settings->audio.max_timing_skew = *setting->value.fraction; - else if (!strcmp(setting->name, "video_refresh_rate_auto")) - { - if (driver->video && driver->video_data) - { - driver_set_refresh_rate(*setting->value.fraction); - - /* In case refresh rate update forced non-block video. */ - rarch_cmd = EVENT_CMD_VIDEO_SET_BLOCKING_STATE; - } - } - else if (!strcmp(setting->name, "video_scale")) - { - settings->video.scale = roundf(*setting->value.fraction); - - if (!settings->video.fullscreen) - rarch_cmd = EVENT_CMD_REINIT; - } - else if (!strcmp(setting->name, "input_player1_joypad_index")) - settings->input.joypad_map[0] = *setting->value.integer; - else if (!strcmp(setting->name, "input_player2_joypad_index")) - settings->input.joypad_map[1] = *setting->value.integer; - else if (!strcmp(setting->name, "input_player3_joypad_index")) - settings->input.joypad_map[2] = *setting->value.integer; - else if (!strcmp(setting->name, "input_player4_joypad_index")) - settings->input.joypad_map[3] = *setting->value.integer; - else if (!strcmp(setting->name, "input_player5_joypad_index")) - settings->input.joypad_map[4] = *setting->value.integer; + } + break; + case MENU_LABEL_NETPLAY_IP_ADDRESS: #ifdef HAVE_NETPLAY - else if (!strcmp(setting->name, "netplay_ip_address")) - global->has_set_netplay_ip_address = (setting->value.string[0] != '\0'); - else if (!strcmp(setting->name, "netplay_mode")) - { - if (!global->netplay_is_client) - *global->netplay_server = '\0'; - global->has_set_netplay_mode = true; - } - else if (!strcmp(setting->name, "netplay_spectator_mode_enable")) - { - if (global->netplay_is_spectate) - *global->netplay_server = '\0'; - } - else if (!strcmp(setting->name, "netplay_delay_frames")) - global->has_set_netplay_delay_frames = (global->netplay_sync_frames > 0); + global->has_set_netplay_ip_address = (setting->value.string[0] != '\0'); #endif - else if (!strcmp(setting->name, "log_verbosity")) - { - global->verbosity = *setting->value.boolean; - global->has_set_verbosity = *setting->value.boolean; + break; + case MENU_LABEL_NETPLAY_MODE: +#ifdef HAVE_NETPLAY + if (!global->netplay_is_client) + *global->netplay_server = '\0'; + global->has_set_netplay_mode = true; +#endif + break; + case MENU_LABEL_NETPLAY_SPECTATOR_MODE_ENABLE: +#ifdef HAVE_NETPLAY + if (global->netplay_is_spectate) + *global->netplay_server = '\0'; +#endif + break; + case MENU_LABEL_NETPLAY_DELAY_FRAMES: +#ifdef HAVE_NETPLAY + global->has_set_netplay_delay_frames = (global->netplay_sync_frames > 0); +#endif + break; } if (rarch_cmd || setting->cmd_trigger.triggered) @@ -3348,7 +3423,10 @@ static void setting_add_special_callbacks( } } else if (values & SD_FLAG_IS_DRIVER) - (*list)[idx].action_toggle = setting_string_action_toggle_driver; + { + (*list)[idx].action_left = setting_string_action_left_driver; + (*list)[idx].action_right = setting_string_action_right_driver; + } } static void settings_data_list_current_add_flags( @@ -3401,7 +3479,8 @@ static bool setting_append_list_main_menu_options( // to put this callback. It should be called whenever the browser // needs to get the directory to browse into. It's not quite like // get_string_representation, but it is close. - (*list)[list_info->index - 1].action_toggle = core_list_action_toggle; + (*list)[list_info->index - 1].action_left = core_list_action_toggle; + (*list)[list_info->index - 1].action_right = core_list_action_toggle; menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_LOAD_CORE); settings_data_list_current_add_flags(list, list_info, SD_FLAG_BROWSER_ACTION); #endif @@ -3449,7 +3528,8 @@ static bool setting_append_list_main_menu_options( subgroup_info.name); (*list)[list_info->index - 1].size = sizeof(global->fullpath); (*list)[list_info->index - 1].value.string = global->fullpath; - (*list)[list_info->index - 1].action_toggle = load_content_action_toggle; + (*list)[list_info->index - 1].action_left = load_content_action_toggle; + (*list)[list_info->index - 1].action_right = load_content_action_toggle; menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_LOAD_CONTENT); settings_data_list_current_add_flags(list, list_info, SD_FLAG_BROWSER_ACTION); @@ -3513,7 +3593,8 @@ static bool setting_append_list_main_menu_options( "Save State", group_info.name, subgroup_info.name); - (*list)[list_info->index - 1].action_toggle = &setting_action_toggle_savestates; + (*list)[list_info->index - 1].action_left = &setting_action_left_savestates; + (*list)[list_info->index - 1].action_right = &setting_action_right_savestates; (*list)[list_info->index - 1].action_start = &setting_action_start_savestates; (*list)[list_info->index - 1].action_ok = &setting_bool_action_ok_exit; (*list)[list_info->index - 1].get_string_representation = &get_string_representation_savestate; @@ -3524,7 +3605,8 @@ static bool setting_append_list_main_menu_options( "Load State", group_info.name, subgroup_info.name); - (*list)[list_info->index - 1].action_toggle = &setting_action_toggle_savestates; + (*list)[list_info->index - 1].action_left = &setting_action_left_savestates; + (*list)[list_info->index - 1].action_right = &setting_action_left_savestates; (*list)[list_info->index - 1].action_start = &setting_action_start_savestates; (*list)[list_info->index - 1].action_ok = &setting_bool_action_ok_exit; (*list)[list_info->index - 1].get_string_representation = &get_string_representation_savestate; @@ -5242,7 +5324,8 @@ static bool setting_append_list_input_options( general_read_handler); (*list)[list_info->index - 1].index = user + 1; (*list)[list_info->index - 1].index_offset = user; - (*list)[list_info->index - 1].action_toggle = &setting_action_toggle_libretro_device_type; + (*list)[list_info->index - 1].action_left = &setting_action_left_libretro_device_type; + (*list)[list_info->index - 1].action_right = &setting_action_right_libretro_device_type; (*list)[list_info->index - 1].action_start = &setting_action_start_libretro_device_type; (*list)[list_info->index - 1].get_string_representation = &setting_get_string_representation_uint_libretro_device; @@ -5258,7 +5341,8 @@ static bool setting_append_list_input_options( general_read_handler); (*list)[list_info->index - 1].index = user + 1; (*list)[list_info->index - 1].index_offset = user; - (*list)[list_info->index - 1].action_toggle = &setting_action_toggle_analog_dpad_mode; + (*list)[list_info->index - 1].action_left = &setting_action_left_analog_dpad_mode; + (*list)[list_info->index - 1].action_right = &setting_action_right_analog_dpad_mode; (*list)[list_info->index - 1].action_start = &setting_action_start_analog_dpad_mode; (*list)[list_info->index - 1].get_string_representation = &setting_get_string_representation_uint_analog_dpad_mode; @@ -5271,7 +5355,8 @@ static bool setting_append_list_input_options( (*list)[list_info->index - 1].index = user + 1; (*list)[list_info->index - 1].index_offset = user; (*list)[list_info->index - 1].action_start = &setting_action_start_bind_device; - (*list)[list_info->index - 1].action_toggle = &setting_action_toggle_bind_device; + (*list)[list_info->index - 1].action_left = &setting_action_left_bind_device; + (*list)[list_info->index - 1].action_right = &setting_action_right_bind_device; (*list)[list_info->index - 1].get_string_representation = &get_string_representation_bind_device; CONFIG_ACTION( @@ -6941,7 +7026,7 @@ bool menu_setting_is_of_path_type(rarch_setting_t *setting) setting && setting->type == ST_ACTION && (setting->flags & SD_FLAG_BROWSER_ACTION) && - setting->action_toggle && + (setting->action_right || setting->action_left) && setting->change_handler) return true; return false; diff --git a/menu/menu_setting.h b/menu/menu_setting.h index 9be753c669..57ddf13901 100644 --- a/menu/menu_setting.h +++ b/menu/menu_setting.h @@ -103,8 +103,10 @@ enum setting_list_flags #define SL_FLAG_ALL_SETTINGS (SL_FLAG_ALL - SL_FLAG_MAIN_MENU) typedef void (*change_handler_t )(void *data); -typedef int (*action_toggle_handler_t )(void *data, unsigned action, bool wraparound); -typedef int (*action_up_or_down_handler_t )(void *data, unsigned action); +typedef int (*action_left_handler_t )(void *data, unsigned action, bool wraparound); +typedef int (*action_right_handler_t )(void *data, unsigned action, bool wraparound); +typedef int (*action_up_handler_t )(void *data, unsigned action); +typedef int (*action_down_handler_t )(void *data, unsigned action); typedef int (*action_start_handler_t )(void *data); typedef int (*action_iterate_handler_t )(unsigned action); typedef int (*action_cancel_handler_t )(void *data, unsigned action); @@ -147,8 +149,10 @@ typedef struct rarch_setting change_handler_t read_handler; action_start_handler_t action_start; action_iterate_handler_t action_iterate; - action_toggle_handler_t action_toggle; - action_up_or_down_handler_t action_up_or_down; + action_left_handler_t action_left; + action_right_handler_t action_right; + action_up_handler_t action_up; + action_down_handler_t action_down; action_cancel_handler_t action_cancel; action_ok_handler_t action_ok; get_string_representation_t get_string_representation; diff --git a/movie.c b/movie.c index c00059e528..db67ce5e72 100644 --- a/movie.c +++ b/movie.c @@ -15,7 +15,7 @@ */ #include "movie.h" -#include "hash.h" +#include #include #include #include