From 2311936580c75122dba0a22cf0e6185b72845bb2 Mon Sep 17 00:00:00 2001 From: Weedy Weed Smoker Date: Wed, 5 Feb 2020 02:59:48 +0700 Subject: [PATCH 01/75] French translation update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and small typo fix for the english file… --- intl/msg_hash_fr.c | 14 ++++++ intl/msg_hash_fr.h | 118 +++++++++++++++++++++++++++++++++++++++++++-- intl/msg_hash_us.h | 2 +- 3 files changed, 128 insertions(+), 6 deletions(-) diff --git a/intl/msg_hash_fr.c b/intl/msg_hash_fr.c index 8331f34291..9e27cbdb43 100644 --- a/intl/msg_hash_fr.c +++ b/intl/msg_hash_fr.c @@ -1620,6 +1620,20 @@ int menu_hash_get_help_fr_enum(enum msg_hash_enums msg, char *s, size_t len) "Les nombres sont décrits en images." ); break; + case MENU_ENUM_LABEL_INPUT_TURBO_MODE: + snprintf(s, len, + "Mode turbo.\n" + " \n" + "Sélectionne le comportement général du mode turbo." + ); + break; + case MENU_ENUM_LABEL_INPUT_TURBO_DEFAULT_BUTTON: + snprintf(s, len, + "Touche turbo par défaut.\n" + " \n" + "Touche active par défaut pour le mode turbo 'Touche unique'.\n" + ); + break; case MENU_ENUM_LABEL_INPUT_DUTY_CYCLE: snprintf(s, len, "Cycle de répétition des touches.\n" diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index d43cc41437..6729712a5d 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -292,7 +292,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_NETPLAY_TAB, - "Salons de jeu en réseau" + "Jeu en réseau" ) MSG_HASH( MENU_ENUM_LABEL_VALUE_ASK_ARCHIVE, @@ -808,13 +808,45 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_DIRECTORY_SETTINGS, "Dossiers" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_DISK_TRAY_EJECT, + "Éjecter le disque" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_DISK_TRAY_EJECT, + "Ouvre le plateau du lecteur de disque virtuel et retire le disque actuellement chargé. REMARQUE : Si RetroArch est configuré pour se mettre en pause lorsque le menu est actif, certains cœurs peuvent ne pas enregistrer les modifications à moins que le contenu ne soit repris pendant quelques secondes après chaque action liée au contrôle du disque." + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_DISK_TRAY_INSERT, + "Insérer le disque" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_DISK_TRAY_INSERT, + "Insère le disque correspondant au 'Numéro du disque actuel' et ferme le plateau du lecteur de disque virtuel. REMARQUE : Si RetroArch est configuré pour se mettre en pause lorsque le menu est actif, certains cœurs peuvent ne pas enregistrer les modifications à moins que le contenu ne soit repris pendant quelques secondes après chaque action liée au contrôle du disque." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_DISK_INDEX, - "Numéro du disque" + "Numéro du disque actuel" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_DISK_INDEX, + "Sélectionne le disque actuel dans la liste des images disponibles. Le disque sera chargé si 'Insérer le disque' est sélectionné." + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_DISK_IMAGE_APPEND, + "Charger un nouveau disque" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_DISK_IMAGE_APPEND, + "Éjecte le disque actuel, sélectionne un nouveau disque dans le système de fichiers, puis l'insère et ferme le plateau du lecteur de disque virtuel. REMARQUE : C'est une fonctionnalité obsolète. Il est plutôt recommandé de charger des titres multi-disques via des listes de lecture M3U, qui permettent la sélection du disque en utilisant les options 'Éjecter/Insérer le disque' et 'Numéro du disque actuel'." ) MSG_HASH( MENU_ENUM_LABEL_VALUE_DISK_OPTIONS, - "Contrôle de disque" + "Contrôle du disque" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_NO_DISK, + "Aucun disque sélectionné" ) MSG_HASH( MENU_ENUM_LABEL_VALUE_DONT_CARE, @@ -880,6 +912,10 @@ MSG_HASH( MSG_ALL_CORES_UPDATED, "Tous les cœurs installés sont à jour" ) +MSG_HASH( + MSG_NUM_CORES_UPDATED, + "cœurs mis à jour : " + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_MENU_SCALE_FACTOR, "Facteur de mise à l'échelle du menu" @@ -1565,6 +1601,14 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_INPUT_TURBO_PERIOD, "Délai d'activation du turbo " ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_INPUT_TURBO_MODE, + "Mode turbo" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_INPUT_TURBO_DEFAULT_BUTTON, + "Touche turbo par défaut" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_INPUT_USER_BINDS, "Touches du port %u" @@ -2159,6 +2203,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_NETWORK_ON_DEMAND_THUMBNAILS, "Télécharge automatiquement les miniatures manquantes lors de la navigation dans les listes de lecture. Affecte grandement les performances." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_NETWORK_HOSTING_SETTINGS, + "Hôte" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_SUBSYSTEM_SETTINGS, + "Sous-systèmes" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_NETWORK_SETTINGS, "Réseau" @@ -2365,7 +2417,15 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_MENU_SAVESTATE_RESUME, - "Ferme le menu automatiquement et reprends le contenu actuel après la sélection de 'Sauvegarde instantanée' ou 'Charger une sauvegarde instantanée' depuis le menu rapide. Désactiver cette option peut améliorer les performances de sauvegarde instantanée sur des appareils très lents." + "Ferme automatiquement le menu et reprends le contenu actuel après la sélection de 'Sauvegarde instantanée' ou 'Charger une sauvegarde instantanée' depuis le menu rapide. Désactiver cette option peut améliorer les performances de sauvegarde instantanée sur des appareils très lents." + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_MENU_INSERT_DISK_RESUME, + "Reprendre le contenu après le changement de disques" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_MENU_INSERT_DISK_RESUME, + "Ferme automatiquement le menu et reprends le contenu actuel après la sélection de 'Insérer le disque' ou 'Charger un nouveau disque' depuis le menu de contrôle du disque." ) MSG_HASH( MENU_ENUM_LABEL_VALUE_PAUSE_NONACTIVE, @@ -2459,6 +2519,22 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_THUMBNAIL_MODE_DEFAULT, "Par défaut du système" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_CLEAN_PLAYLIST, + "Nettoyer la liste de lecture" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_PLAYLIST_MANAGER_CLEAN_PLAYLIST, + "Supprime les entrées invalides/en double et valide les associations aux cœurs." + ) +MSG_HASH( + MSG_PLAYLIST_MANAGER_CLEANING_PLAYLIST, + "Nettoyage de la liste de lecture : " + ) +MSG_HASH( + MSG_PLAYLIST_MANAGER_PLAYLIST_CLEANED, + "Liste de lecture nettoyée : " + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_POINTER_ENABLE, "Prise en charge du tactile" @@ -2638,6 +2714,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_CONTENT_INFO_LAST_PLAYED, "Dernière partie" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CONTENT_INFO_CHEEVOS_HASH, + "Empreinte RetroSuccès" + ) #ifdef HAVE_LAKKA_SWITCH MSG_HASH( MENU_ENUM_LABEL_VALUE_REBOOT, @@ -4727,6 +4807,10 @@ MSG_HASH( MSG_APPENDED_DISK, "Disque ajouté" ) +MSG_HASH( + MSG_FAILED_TO_APPEND_DISK, + "Échec de l'ajout du disque" + ) MSG_HASH( MSG_APPLICATION_DIR, "Dossier de l'application" @@ -5539,6 +5623,14 @@ MSG_HASH( MSG_VIRTUAL_DISK_TRAY, "Lecteur de disque virtuel." ) +MSG_HASH( + MSG_VIRTUAL_DISK_TRAY_EJECT, + "éjecter" + ) +MSG_HASH( + MSG_VIRTUAL_DISK_TRAY_CLOSE, + "fermer" + ) MSG_HASH( MENU_ENUM_SUBLABEL_AUDIO_LATENCY, "Latence audio désirée en millisecondes. Peut être ignorée si le pilote audio ne peut fournir une telle valeur." @@ -5611,6 +5703,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_INPUT_DUTY_CYCLE, "Décrit la durée après laquelle une touche en mode turbo se répète. Les nombres sont décrits en images." ) +MSG_HASH( + MENU_ENUM_SUBLABEL_INPUT_TURBO_MODE, + "Sélectionne le comportement général du mode turbo." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_INPUT_TURBO_DEFAULT_BUTTON, + "Touche active par défaut pour le mode turbo 'Touche unique'." + ) MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_VSYNC, "Synchronise la sortie vidéo de la carte graphique avec la fréquence de rafraîchissement de l'écran. Recommandé." @@ -8899,7 +8999,11 @@ MSG_HASH( ) MSG_HASH( MSG_FAILED_TO_SET_DISK, - "Impossible de paramétrer le disque" + "Impossible de sélectionner le disque" + ) +MSG_HASH( + MSG_FAILED_TO_SET_INITIAL_DISK, + "Impossible de sélectionner le dernier disque utilisé..." ) MSG_HASH( MENU_ENUM_LABEL_VALUE_QT_CORE_OPTIONS, @@ -10026,6 +10130,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_DELETE_PLAYLIST, "Supprimer la liste de lecture" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_DELETE_PLAYLIST, + "Supprime la liste de lecture du système de fichiers." + ) #ifdef HAVE_LAKKA MSG_HASH( MENU_ENUM_LABEL_VALUE_LOCALAP_ENABLE, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index c634f5b74f..303938d078 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -806,7 +806,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_DISK_TRAY_EJECT, - "Opens virtual disk try and removes currently loaded disk. NOTE: If RetroArch is configured to pause while menu is active, some cores may not register changes unless content is resumed for a few seconds after each disk control action." + "Opens virtual disk tray and removes currently loaded disk. NOTE: If RetroArch is configured to pause while menu is active, some cores may not register changes unless content is resumed for a few seconds after each disk control action." ) MSG_HASH( MENU_ENUM_LABEL_VALUE_DISK_TRAY_INSERT, From 41b5387203ad3553e528ccd92c256eab4c1bc561 Mon Sep 17 00:00:00 2001 From: Weedy Weed Smoker Date: Wed, 5 Feb 2020 03:06:06 +0700 Subject: [PATCH 02/75] Small change to the french translation --- intl/msg_hash_fr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intl/msg_hash_fr.c b/intl/msg_hash_fr.c index 9e27cbdb43..59626614c3 100644 --- a/intl/msg_hash_fr.c +++ b/intl/msg_hash_fr.c @@ -1974,7 +1974,7 @@ int menu_hash_get_help_fr_enum(enum msg_hash_enums msg, char *s, size_t len) " \n" "Maintenir le turbo tout en appuyant sur une \n" "autre touche permet à la touche d'entrer dans \n" - "un mode turbo où l'état du bouton est modulé \n" + "un mode turbo où son état est modulé \n" "avec un signal périodique. \n" " \n" "La modulation s'arrête lorsque la touche \n" From 609dde098839ce34a7d09072818cd7b0d237602f Mon Sep 17 00:00:00 2001 From: Weedy Weed Smoker Date: Wed, 5 Feb 2020 03:15:03 +0700 Subject: [PATCH 03/75] Another small change to the french translation --- intl/msg_hash_fr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index 6729712a5d..66b4866292 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -2421,7 +2421,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_MENU_INSERT_DISK_RESUME, - "Reprendre le contenu après le changement de disques" + "Reprendre le contenu après le changement du disque" ) MSG_HASH( MENU_ENUM_SUBLABEL_MENU_INSERT_DISK_RESUME, From 446e44cb091bf90da6d4c86e2d68e52b01a96041 Mon Sep 17 00:00:00 2001 From: Jamiras Date: Wed, 5 Feb 2020 18:16:34 -0700 Subject: [PATCH 04/75] if the core says it's exposing SYSTEM_RAM, give it the benefit of the doubt --- cheevos-new/cheevos.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/cheevos-new/cheevos.c b/cheevos-new/cheevos.c index 0d7a369b3a..b75ce5685b 100644 --- a/cheevos-new/cheevos.c +++ b/cheevos-new/cheevos.c @@ -411,12 +411,32 @@ static int rcheevos_parse(const char* json) */ if (!rcheevos_patch_address(0, rcheevos_locals.patchdata.console_id)) { - /* Special case: the sameboy core exposes the RAM at $8000, but not the ROM at $0000. NES and - * Gameboy achievements do attempt to map the entire bus, and it's unlikely that an achievement - * will reference the ROM data, so if the RAM is still present, allow the core to load. If any - * achievements do reference the ROM data, they'll be marked "Unsupported" individually. - */ - if (!rcheevos_patch_address(0x8000, rcheevos_locals.patchdata.console_id)) + int delay_judgment = 0; + + rarch_system_info_t* system = runloop_get_system_info(); + if (system->mmaps.num_descriptors == 0) + { + /* Special case: the mupen64plus-nx core doesn't initialize the RAM immediately. To avoid a race + * condition - if the core says there's SYSTEM_RAM, but the pointer is NULL, proceed. If the memory + * isn't exposed when the achievements start processing, they'll be marked "Unsupported" individually. + */ + retro_ctx_memory_info_t meminfo; + meminfo.id = RETRO_MEMORY_SYSTEM_RAM; + core_get_memory(&meminfo); + + delay_judgment |= (meminfo.size > 0); + } + else + { + /* Special case: the sameboy core exposes the RAM at $8000, but not the ROM at $0000. NES and + * Gameboy achievements do attempt to map the entire bus, and it's unlikely that an achievement + * will reference the ROM data, so if the RAM is still present, allow the core to load. If any + * achievements do reference the ROM data, they'll be marked "Unsupported" individually. + */ + delay_judgment |= (rcheevos_patch_address(0x8000, rcheevos_locals.patchdata.console_id) != NULL); + } + + if (!delay_judgment) { CHEEVOS_ERR(RCHEEVOS_TAG "No memory exposed by core\n"); From 0c6bb6660a0f5e9b470b3bdf435fa061ba099675 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 10 Feb 2020 11:49:50 +0100 Subject: [PATCH 05/75] Cleanups --- config.def.h | 2 +- configuration.c | 2 +- menu/cbs/menu_cbs_start.c | 4 +++- menu/menu_setting.c | 2 +- retroarch.c | 50 +++++++++++++++++++-------------------- 5 files changed, 31 insertions(+), 29 deletions(-) diff --git a/config.def.h b/config.def.h index 2312cd1ddf..79ef068d47 100644 --- a/config.def.h +++ b/config.def.h @@ -868,7 +868,7 @@ static const int netplay_check_frames = 600; static const bool netplay_use_mitm_server = false; -static const char *netplay_mitm_server = "nyc"; +#define DEFAULT_NETPLAY_MITM_SERVER "nyc" #ifdef HAVE_NETWORKING static const unsigned netplay_share_digital = RARCH_NETPLAY_SHARE_DIGITAL_NO_PREFERENCE; diff --git a/configuration.c b/configuration.c index 18535947c2..6a466ef8df 100644 --- a/configuration.c +++ b/configuration.c @@ -1979,7 +1979,7 @@ void config_set_defaults(void *data) const char *def_location = config_get_default_location(); const char *def_record = config_get_default_record(); const char *def_midi = config_get_default_midi(); - const char *def_mitm = netplay_mitm_server; + const char *def_mitm = DEFAULT_NETPLAY_MITM_SERVER; struct config_float_setting *float_settings = populate_settings_float (settings, &float_settings_size); struct config_bool_setting *bool_settings = populate_settings_bool (settings, &bool_settings_size); struct config_int_setting *int_settings = populate_settings_int (settings, &int_settings_size); diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index b88284fb67..7b813698fd 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -244,7 +244,9 @@ static int action_start_netplay_mitm_server( unsigned type, size_t idx, size_t entry_idx) { settings_t *settings = config_get_ptr(); - strlcpy(settings->arrays.netplay_mitm_server, netplay_mitm_server, sizeof(settings->arrays.netplay_mitm_server)); + strlcpy(settings->arrays.netplay_mitm_server, + DEFAULT_NETPLAY_MITM_SERVER, + sizeof(settings->arrays.netplay_mitm_server)); return 0; } diff --git a/menu/menu_setting.c b/menu/menu_setting.c index e9e0484a05..0c0354eaae 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -15548,7 +15548,7 @@ static bool setting_append_list( sizeof(settings->arrays.netplay_mitm_server), MENU_ENUM_LABEL_NETPLAY_MITM_SERVER, MENU_ENUM_LABEL_VALUE_NETPLAY_MITM_SERVER, - netplay_mitm_server, + DEFAULT_NETPLAY_MITM_SERVER, &group_info, &subgroup_info, parent_group, diff --git a/retroarch.c b/retroarch.c index d27c840d74..2dc4b463cc 100644 --- a/retroarch.c +++ b/retroarch.c @@ -3551,31 +3551,6 @@ static char *strcpy_alloc_force(const char *src) return result; } -static void strcat_alloc(char **dst, const char *s) -{ - size_t len1; - char *src = *dst; - - if (!src) - { - src = strcpy_alloc_force(s); - *dst = src; - return; - } - - if (!s) - return; - - len1 = strlen(src); - src = (char*)realloc(src, len1 + strlen(s) + 1); - - if (!src) - return; - - *dst = src; - strcpy(src + len1, s); -} - #if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB) /* Forward declarations */ static bool secondary_core_create(void); @@ -10926,6 +10901,31 @@ static void set_load_content_info(const retro_ctx_load_content_info_t *ctx) /* RUNAHEAD - SECONDARY CORE */ #if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB) +static void strcat_alloc(char **dst, const char *s) +{ + size_t len1; + char *src = *dst; + + if (!src) + { + src = strcpy_alloc_force(s); + *dst = src; + return; + } + + if (!s) + return; + + len1 = strlen(src); + src = (char*)realloc(src, len1 + strlen(s) + 1); + + if (!src) + return; + + *dst = src; + strcpy(src + len1, s); +} + static void secondary_core_destroy(void) { if (!secondary_module) From 9dbad614a556f1490f07071496ce90ee41410231 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 10 Feb 2020 11:54:05 +0100 Subject: [PATCH 06/75] Prevent warnings --- config.def.h | 6 ++++-- configuration.c | 14 ++++++-------- menu/menu_setting.c | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/config.def.h b/config.def.h index 79ef068d47..5e27d5e224 100644 --- a/config.def.h +++ b/config.def.h @@ -1072,8 +1072,10 @@ static const enum resampler_quality audio_resampler_quality_level = RESAMPLER_QU #endif /* MIDI */ -static const char *midi_input = "Off"; -static const char *midi_output = "Off"; +#define DEFAULT_MIDI_INPUT "Off" + +#define DEFAULT_MIDI_OUTPUT "Off" + static const unsigned midi_volume = 100; /* Only applies to Android 7.0 (API 24) and up */ diff --git a/configuration.c b/configuration.c index 6a466ef8df..2cf65ebbfe 100644 --- a/configuration.c +++ b/configuration.c @@ -1166,8 +1166,8 @@ static struct config_array_setting *populate_settings_array(settings_t *settings SETTING_ARRAY("led_driver", settings->arrays.led_driver, false, NULL, true); SETTING_ARRAY("netplay_mitm_server", settings->arrays.netplay_mitm_server, false, NULL, true); SETTING_ARRAY("midi_driver", settings->arrays.midi_driver, false, NULL, true); - SETTING_ARRAY("midi_input", settings->arrays.midi_input, true, midi_input, true); - SETTING_ARRAY("midi_output", settings->arrays.midi_output, true, midi_output, true); + SETTING_ARRAY("midi_input", settings->arrays.midi_input, true, DEFAULT_MIDI_INPUT, true); + SETTING_ARRAY("midi_output", settings->arrays.midi_output, true, DEFAULT_MIDI_OUTPUT, true); SETTING_ARRAY("youtube_stream_key", settings->arrays.youtube_stream_key, true, NULL, true); SETTING_ARRAY("twitch_stream_key", settings->arrays.twitch_stream_key, true, NULL, true); SETTING_ARRAY("discord_app_id", settings->arrays.discord_app_id, true, DEFAULT_DISCORD_APP_ID, true); @@ -2420,12 +2420,10 @@ void config_set_defaults(void *data) free(temp_str); } - if (midi_input) - strlcpy(settings->arrays.midi_input, - midi_input, sizeof(settings->arrays.midi_input)); - if (midi_output) - strlcpy(settings->arrays.midi_output, - midi_output, sizeof(settings->arrays.midi_output)); + strlcpy(settings->arrays.midi_input, + DEFAULT_MIDI_INPUT, sizeof(settings->arrays.midi_input)); + strlcpy(settings->arrays.midi_output, + DEFAULT_MIDI_OUTPUT, sizeof(settings->arrays.midi_output)); #ifdef HAVE_CONFIGFILE /* Avoid reloading config on every content load */ diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 0c0354eaae..4133f24578 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -16769,7 +16769,7 @@ static bool setting_append_list( sizeof(settings->arrays.midi_input), MENU_ENUM_LABEL_MIDI_INPUT, MENU_ENUM_LABEL_VALUE_MIDI_INPUT, - midi_input, + DEFAULT_MIDI_INPUT, &group_info, &subgroup_info, parent_group, @@ -16785,7 +16785,7 @@ static bool setting_append_list( sizeof(settings->arrays.midi_output), MENU_ENUM_LABEL_MIDI_OUTPUT, MENU_ENUM_LABEL_VALUE_MIDI_OUTPUT, - midi_output, + DEFAULT_MIDI_OUTPUT, &group_info, &subgroup_info, parent_group, From 880391d0c5f2542aff10a735d3878ed1052cc450 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 10 Feb 2020 12:36:11 +0100 Subject: [PATCH 07/75] (libnx) Try to silence warnings --- audio/drivers/switch_audio.c | 9 ++- audio/drivers/switch_thread_audio.c | 3 +- disk_control_interface.c | 1 - frontend/drivers/platform_switch.c | 18 +++--- gfx/drivers/switch_nx_gfx.c | 2 +- gfx/drivers_context/switch_ctx.c | 4 +- gfx/drivers_font/switch_font.c | 98 ++++++++++++++++------------- input/drivers/switch_input.c | 2 + menu/cbs/menu_cbs_ok.c | 6 +- menu/menu_displaylist.c | 2 + 10 files changed, 83 insertions(+), 62 deletions(-) diff --git a/audio/drivers/switch_audio.c b/audio/drivers/switch_audio.c index 38caa1d849..4b9a20259c 100644 --- a/audio/drivers/switch_audio.c +++ b/audio/drivers/switch_audio.c @@ -32,7 +32,9 @@ static const int sample_rate = 48000; static const int max_num_samples = sample_rate; static const int num_channels = 2; +#ifndef HAVE_LIBNX static const size_t sample_buffer_size = ((max_num_samples * num_channels * sizeof(uint16_t)) + 0xfff) & ~0xfff; +#endif typedef struct { @@ -98,7 +100,9 @@ static ssize_t switch_audio_write(void *data, const void *buf, size_t size) while (!swa->current_buffer) { +#ifndef HAVE_LIBNX uint32_t handle_idx = 0; +#endif num = 0; #ifdef HAVE_LIBNX @@ -236,7 +240,9 @@ static void *switch_audio_init(const char *device, { unsigned i; char names[8][0x20]; +#ifndef HAVE_LIBNX uint32_t num_names = 0; +#endif switch_audio_t *swa = (switch_audio_t*) calloc(1, sizeof(*swa)); if (!swa) @@ -333,8 +339,9 @@ fail_audio_output: /* TODO/FIXME - fix libnx codepath */ #ifndef HAVE_LIBNX audio_ipc_output_close(&swa->output); -#endif fail_audio_ipc: +#endif + /* TODO/FIXME - fix libnx codepath */ #ifndef HAVE_LIBNX audio_ipc_finalize(); diff --git a/audio/drivers/switch_thread_audio.c b/audio/drivers/switch_thread_audio.c index f7848bf9be..ef1d10864b 100644 --- a/audio/drivers/switch_thread_audio.c +++ b/audio/drivers/switch_thread_audio.c @@ -39,7 +39,6 @@ static const size_t thread_stack_size = 1024 * 8; static const int thread_preferred_cpu = 2; static const int channel_count = 2; static const size_t sample_size = sizeof(uint16_t); -static const size_t frame_size = channel_count * sample_size; #define AUDIO_BUFFER_COUNT 2 @@ -144,8 +143,10 @@ static void *switch_thread_audio_init(const char *device, unsigned rate, unsigne Result rc; unsigned i; uint32_t prio; +#ifndef HAVE_LIBNX char names[8][0x20]; uint32_t num_names = 0; +#endif switch_thread_audio_t *swa = (switch_thread_audio_t *)calloc(1, sizeof(*swa)); if (!swa) diff --git a/disk_control_interface.c b/disk_control_interface.c index 98ef958a14..ef361bdbfe 100644 --- a/disk_control_interface.c +++ b/disk_control_interface.c @@ -236,7 +236,6 @@ void disk_control_get_image_label( error: label[0] = '\0'; - return; } /***********/ diff --git a/frontend/drivers/platform_switch.c b/frontend/drivers/platform_switch.c index b38372ad36..d2affe70d0 100644 --- a/frontend/drivers/platform_switch.c +++ b/frontend/drivers/platform_switch.c @@ -94,7 +94,6 @@ void libnx_apply_overclock(void) static void on_applet_hook(AppletHookType hook, void *param) { - u32 performance_mode; AppletFocusState focus_state; /* Exit request */ @@ -131,9 +130,11 @@ static void on_applet_hook(AppletHookType hook, void *param) /* Performance mode */ case AppletHookType_OnPerformanceMode: - /* 0 == Handheld, 1 == Docked - * Since CPU doesn't change we just re-apply */ - performance_mode = appletGetPerformanceMode(); + { + /* 0 == Handheld, 1 == Docked + * Since CPU doesn't change we just re-apply */ + u32 performance_mode = appletGetPerformanceMode(); + } libnx_apply_overclock(); break; @@ -318,17 +319,20 @@ static void frontend_switch_deinit(void *data) static void frontend_switch_exec(const char *path, bool should_load_game) { char game_path[PATH_MAX-4]; +#ifndef IS_SALAMANDER const char *arg_data[3]; int args = 0; - - game_path[0] = NULL; arg_data[0] = NULL; arg_data[args] = elf_path_cst; arg_data[args + 1] = NULL; args++; +#endif + + game_path[0] = NULL; RARCH_LOG("Attempt to load core: [%s].\n", path); + #ifndef IS_SALAMANDER if (should_load_game && !path_is_empty(RARCH_PATH_CONTENT)) { @@ -618,8 +622,6 @@ char *realpath(const char *name, char *resolved) for (start = end = name; *start; start = end) { - int n; - /* Skip sequence of multiple path-separators. */ while (*start == '/') ++start; diff --git a/gfx/drivers/switch_nx_gfx.c b/gfx/drivers/switch_nx_gfx.c index c25a77c8f0..102cea6bd9 100644 --- a/gfx/drivers/switch_nx_gfx.c +++ b/gfx/drivers/switch_nx_gfx.c @@ -580,7 +580,7 @@ static void switch_set_texture_frame( struct scaler_ctx *sctx = NULL; if (sw->menu_texture.pixels) - realloc(sw->menu_texture.pixels, sz); + sw->menu_texture.pixels = realloc(sw->menu_texture.pixels, sz); else sw->menu_texture.pixels = malloc(sz); diff --git a/gfx/drivers_context/switch_ctx.c b/gfx/drivers_context/switch_ctx.c index 5466371349..29bb3f3340 100644 --- a/gfx/drivers_context/switch_ctx.c +++ b/gfx/drivers_context/switch_ctx.c @@ -47,10 +47,8 @@ void switch_ctx_destroy(void *data) } static void switch_ctx_get_video_size(void *data, - unsigned *width, unsigned *height) + unsigned *width, unsigned *height) { - switch_ctx_data_t *ctx_nx = (switch_ctx_data_t *)data; - switch (appletGetOperationMode()) { default: diff --git a/gfx/drivers_font/switch_font.c b/gfx/drivers_font/switch_font.c index 1e9de648fa..831000f8af 100644 --- a/gfx/drivers_font/switch_font.c +++ b/gfx/drivers_font/switch_font.c @@ -46,7 +46,7 @@ static void *switch_font_init_font(void *data, const char *font_path, if (!font) return NULL; - if (!font_renderer_create_default((const void **)&font->font_driver, + if (!font_renderer_create_default(&font->font_driver, &font->font_data, font_path, font_size)) { RARCH_WARN("Couldn't initialize font renderer.\n"); @@ -250,73 +250,83 @@ static void switch_font_render_msg( void *data, const char *msg, const struct font_params *params) { - float x, y, scale, drop_mod, drop_alpha; - int drop_x, drop_y; - unsigned max_glyphs; + float x, y, scale; enum text_alignment text_align; - unsigned color, color_dark, r, g, b, - alpha, r_dark, g_dark, b_dark, alpha_dark; + unsigned color, r, g, b, alpha; switch_font_t *font = (switch_font_t *)data; - unsigned width = video_info->width; - unsigned height = video_info->height; +#if 0 + int drop_x, drop_y; + float drop_mod, drop_alpha; + unsigned max_glyphs; + unsigned color_dark, r_dark, g_dark, b_dark, alpha_dark; + unsigned width = video_info->width; + unsigned height = video_info->height; +#endif - if (!font || !msg || msg && !*msg) + if (!font || !msg || (msg && !*msg)) return; if (params) { - x = params->x; - y = params->y; - scale = params->scale; + x = params->x; + y = params->y; + scale = params->scale; text_align = params->text_align; - drop_x = params->drop_x; - drop_y = params->drop_y; - drop_mod = params->drop_mod; + +#if 0 + drop_x = params->drop_x; + drop_y = params->drop_y; drop_alpha = params->drop_alpha; + drop_mod = params->drop_mod; +#endif - r = FONT_COLOR_GET_RED(params->color); - g = FONT_COLOR_GET_GREEN(params->color); - b = FONT_COLOR_GET_BLUE(params->color); - alpha = FONT_COLOR_GET_ALPHA(params->color); + r = FONT_COLOR_GET_RED(params->color); + g = FONT_COLOR_GET_GREEN(params->color); + b = FONT_COLOR_GET_BLUE(params->color); + alpha = FONT_COLOR_GET_ALPHA(params->color); - color = params->color; + color = params->color; } else { - x = 0.0f; - y = 0.0f; - scale = 1.0f; + x = 0.0f; + y = 0.0f; + scale = 1.0f; text_align = TEXT_ALIGN_LEFT; - r = (video_info->font_msg_color_r * 255); - g = (video_info->font_msg_color_g * 255); - b = (video_info->font_msg_color_b * 255); - alpha = 255; - color = COLOR_ABGR(r, g, b, alpha); + r = (video_info->font_msg_color_r * 255); + g = (video_info->font_msg_color_g * 255); + b = (video_info->font_msg_color_b * 255); + alpha = 255; + color = COLOR_ABGR(r, g, b, alpha); - drop_x = -2; - drop_y = -2; - drop_mod = 0.3f; +#if 0 + drop_x = -2; + drop_y = -2; + drop_mod = 0.3f; drop_alpha = 1.0f; +#endif } +#if 0 max_glyphs = strlen(msg); - /*if (drop_x || drop_y) - max_glyphs *= 2; + if (drop_x || drop_y) + max_glyphs *= 2; - if (drop_x || drop_y) - { - r_dark = r * drop_mod; - g_dark = g * drop_mod; - b_dark = b * drop_mod; - alpha_dark = alpha * drop_alpha; - color_dark = COLOR_ABGR(r_dark, g_dark, b_dark, alpha_dark); + if (drop_x || drop_y) + { + r_dark = r * drop_mod; + g_dark = g * drop_mod; + b_dark = b * drop_mod; + alpha_dark = alpha * drop_alpha; + color_dark = COLOR_ABGR(r_dark, g_dark, b_dark, alpha_dark); - switch_font_render_message(video_info, font, msg, scale, color_dark, - x + scale * drop_x / width, y + - scale * drop_y / height, text_align); - }*/ + switch_font_render_message(video_info, font, msg, scale, color_dark, + x + scale * drop_x / width, y + + scale * drop_y / height, text_align); + } +#endif switch_font_render_message(video_info, font, msg, scale, color, x, y, text_align); diff --git a/input/drivers/switch_input.c b/input/drivers/switch_input.c index ebc8001f2b..baa36f5d7f 100644 --- a/input/drivers/switch_input.c +++ b/input/drivers/switch_input.c @@ -963,6 +963,8 @@ static bool switch_input_set_sensor_state(void *data, unsigned port, sw->sixaxis_handles_count[port] = handles_count; } return true; + case RETRO_SENSOR_DUMMY: + break; } #endif diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 40b422cc53..454e1d696b 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3276,18 +3276,18 @@ static int action_ok_deferred_list_stub(const char *path, static int action_ok_set_switch_cpu_profile(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - char* profile_name = SWITCH_CPU_PROFILES[entry_idx]; char command[PATH_MAX_LENGTH] = {0}; - #ifdef HAVE_LAKKA_SWITCH + char* profile_name = SWITCH_CPU_PROFILES[entry_idx]; + snprintf(command, sizeof(command), "cpu-profile set '%s'", profile_name); system(command); snprintf(command, sizeof(command), "Current profile set to %s", profile_name); #else + unsigned profile_clock = SWITCH_CPU_SPEEDS_VALUES[entry_idx]; config_get_ptr()->uints.libnx_overclock = entry_idx; - unsigned profile_clock = SWITCH_CPU_SPEEDS_VALUES[entry_idx]; if (hosversionBefore(8, 0, 0)) pcvSetClockRate(PcvModule_CpuBus, (u32)profile_clock); else diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index e44d988d52..a65da2f739 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -7944,7 +7944,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, unsigned i; char text[PATH_MAX_LENGTH]; char current_profile[PATH_MAX_LENGTH]; +#ifdef HAVE_LAKKA_SWITCH FILE *profile = NULL; +#endif const size_t profiles_count = sizeof(SWITCH_CPU_PROFILES)/sizeof(SWITCH_CPU_PROFILES[1]); runloop_msg_queue_push("Warning : extended overclocking can damage the Switch", 1, 90, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); From c142ee19ba90b9d5d8d4aeca38f1b9e527c74e3c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 10 Feb 2020 13:12:26 +0100 Subject: [PATCH 08/75] Cleanups --- retroarch.c | 59 +++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/retroarch.c b/retroarch.c index 2dc4b463cc..5d1ec731b2 100644 --- a/retroarch.c +++ b/retroarch.c @@ -3839,35 +3839,36 @@ static bool command_show_osd_msg(const char* arg) static bool command_get_config_param(const char* arg) { - char reply[4096] = {0}; - const char* value = "unsupported"; - settings_t* settings = config_get_ptr(); - - if (!strcmp(arg, "video_fullscreen")) { - if(configuration_settings->bools.video_fullscreen) - value = "true"; - else - value = "false"; - } - else if (!strcmp(arg, "savefile_directory")) - value = dir_get(RARCH_DIR_SAVEFILE); - else if (!strcmp(arg, "savestate_directory")) - value = dir_get(RARCH_DIR_SAVESTATE); - else if (!strcmp(arg, "runtime_log_directory")) - value = settings->paths.directory_runtime_log; - else if (!strcmp(arg, "log_dir")) - value = settings->paths.log_dir; - else if (!strcmp(arg, "cache_directory")) - value = settings->paths.directory_cache; - else if (!strcmp(arg, "system_directory")) - value = settings->paths.directory_system; - else if (!strcmp(arg, "netplay_nickname")) - value = settings->paths.username; - /* TODO: query any string */ - - snprintf(reply, sizeof(reply), "GET_CONFIG_PARAM %s %s\n", arg, value); - command_reply(reply, strlen(reply)); - return true; + char reply[4096] = {0}; + const char* value = "unsupported"; + settings_t* settings = configuration_settings; + + if (!strcmp(arg, "video_fullscreen")) + { + if(configuration_settings->bools.video_fullscreen) + value = "true"; + else + value = "false"; + } + else if (!strcmp(arg, "savefile_directory")) + value = dir_get(RARCH_DIR_SAVEFILE); + else if (!strcmp(arg, "savestate_directory")) + value = dir_get(RARCH_DIR_SAVESTATE); + else if (!strcmp(arg, "runtime_log_directory")) + value = settings->paths.directory_runtime_log; + else if (!strcmp(arg, "log_dir")) + value = settings->paths.log_dir; + else if (!strcmp(arg, "cache_directory")) + value = settings->paths.directory_cache; + else if (!strcmp(arg, "system_directory")) + value = settings->paths.directory_system; + else if (!strcmp(arg, "netplay_nickname")) + value = settings->paths.username; + /* TODO: query any string */ + + snprintf(reply, sizeof(reply), "GET_CONFIG_PARAM %s %s\n", arg, value); + command_reply(reply, strlen(reply)); + return true; } #if defined(HAVE_CHEEVOS) From 1fafdb28434596598b314123a09cec25048f75b5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 10 Feb 2020 13:18:27 +0100 Subject: [PATCH 09/75] Style nits --- menu/cbs/menu_cbs_scan.c | 4 ++-- menu/drivers/materialui.c | 6 +++--- menu/drivers/ozone/ozone_sidebar.c | 4 ++-- menu/drivers/rgui.c | 24 ++++++++++++------------ menu/drivers/xui.cpp | 8 ++++---- menu/drivers_display/menu_display_d3d8.c | 4 ++-- menu/drivers_display/menu_display_d3d9.c | 4 ++-- menu/drivers_display/menu_display_wiiu.c | 16 ++++++++-------- menu/menu_displaylist.c | 2 +- menu/menu_setting.c | 5 +++-- menu/menu_thumbnail.c | 4 ++-- midi/drivers/alsa_midi.c | 3 ++- midi/drivers/winmm_midi.c | 2 +- network/netplay/netplay_frontend.c | 2 +- retroarch.c | 2 +- 15 files changed, 46 insertions(+), 44 deletions(-) diff --git a/menu/cbs/menu_cbs_scan.c b/menu/cbs/menu_cbs_scan.c index 6ee008f23d..415e3c4f46 100644 --- a/menu/cbs/menu_cbs_scan.c +++ b/menu/cbs/menu_cbs_scan.c @@ -113,7 +113,7 @@ int action_switch_thumbnail(const char *path, * changing thumbnail view mode. * For other menu drivers, we cycle through available thumbnail * types. */ - if(!string_is_equal(settings->arrays.menu_driver, "rgui") && + if (!string_is_equal(settings->arrays.menu_driver, "rgui") && !string_is_equal(settings->arrays.menu_driver, "glui")) { settings->uints.menu_left_thumbnails++; @@ -131,7 +131,7 @@ int action_switch_thumbnail(const char *path, * changing thumbnail view mode. * For other menu drivers, we cycle through available thumbnail * types. */ - if(!string_is_equal(settings->arrays.menu_driver, "rgui") && + if (!string_is_equal(settings->arrays.menu_driver, "rgui") && !string_is_equal(settings->arrays.menu_driver, "glui")) { settings->uints.menu_thumbnails++; diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 526c2e1144..3b4670fdff 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -5874,7 +5874,7 @@ static void materialui_populate_nav_bar( mui->nav_bar.menu_tabs[menu_tab_index].active = string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_MAIN_MENU)); - if(mui->nav_bar.menu_tabs[menu_tab_index].active) + if (mui->nav_bar.menu_tabs[menu_tab_index].active) mui->nav_bar.active_menu_tab_index = menu_tab_index; menu_tab_index++; @@ -5889,7 +5889,7 @@ static void materialui_populate_nav_bar( mui->nav_bar.menu_tabs[menu_tab_index].active = string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_PLAYLISTS_TAB)); - if(mui->nav_bar.menu_tabs[menu_tab_index].active) + if (mui->nav_bar.menu_tabs[menu_tab_index].active) mui->nav_bar.active_menu_tab_index = menu_tab_index; menu_tab_index++; @@ -5903,7 +5903,7 @@ static void materialui_populate_nav_bar( mui->nav_bar.menu_tabs[menu_tab_index].active = string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_SETTINGS_TAB)); - if(mui->nav_bar.menu_tabs[menu_tab_index].active) + if (mui->nav_bar.menu_tabs[menu_tab_index].active) mui->nav_bar.active_menu_tab_index = menu_tab_index; menu_tab_index++; diff --git a/menu/drivers/ozone/ozone_sidebar.c b/menu/drivers/ozone/ozone_sidebar.c index 183ad626a0..bfb7170223 100644 --- a/menu/drivers/ozone/ozone_sidebar.c +++ b/menu/drivers/ozone/ozone_sidebar.c @@ -661,7 +661,7 @@ void ozone_context_reset_horizontal_list(ozone_handle_t *ozone) if (image_texture_load(&ti, texturepath)) { - if(ti.pixels) + if (ti.pixels) { video_driver_texture_unload(&node->icon); video_driver_texture_load(&ti, @@ -691,7 +691,7 @@ void ozone_context_reset_horizontal_list(ozone_handle_t *ozone) if (image_texture_load(&ti, content_texturepath)) { - if(ti.pixels) + if (ti.pixels) { video_driver_texture_unload(&node->content_icon); video_driver_texture_load(&ti, diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 8c226cf5b6..7819d26aeb 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -1676,7 +1676,7 @@ static bool request_thumbnail( { /* Would like to cancel any existing image load tasks * here, but can't see how to do it... */ - if(task_push_image_load(thumbnail->path, + if (task_push_image_load(thumbnail->path, video_driver_supports_rgba(), 0, (thumbnail_id == MENU_THUMBNAIL_LEFT) ? menu_display_handle_left_thumbnail_upload : menu_display_handle_thumbnail_upload, NULL)) @@ -1768,7 +1768,7 @@ static bool downscale_thumbnail(rgui_t *rgui, unsigned max_width, unsigned max_h * calls it - but do it anyway in case the * scaler_ctx_gen_filter() internals ever change... */ scaler_ctx_gen_reset(&rgui->image_scaler); - if(!scaler_ctx_gen_filter(&rgui->image_scaler)) + if (!scaler_ctx_gen_filter(&rgui->image_scaler)) { /* Could be leftovers if scaler_ctx_gen_filter() * fails, so reset just in case... */ @@ -2218,36 +2218,36 @@ static void load_custom_theme(rgui_t *rgui, rgui_theme_t *theme_colors, const ch goto end; /* Parse config file */ - if(!config_get_hex(conf, "rgui_entry_normal_color", &normal_color)) + if (!config_get_hex(conf, "rgui_entry_normal_color", &normal_color)) goto end; - if(!config_get_hex(conf, "rgui_entry_hover_color", &hover_color)) + if (!config_get_hex(conf, "rgui_entry_hover_color", &hover_color)) goto end; - if(!config_get_hex(conf, "rgui_title_color", &title_color)) + if (!config_get_hex(conf, "rgui_title_color", &title_color)) goto end; - if(!config_get_hex(conf, "rgui_bg_dark_color", &bg_dark_color)) + if (!config_get_hex(conf, "rgui_bg_dark_color", &bg_dark_color)) goto end; - if(!config_get_hex(conf, "rgui_bg_light_color", &bg_light_color)) + if (!config_get_hex(conf, "rgui_bg_light_color", &bg_light_color)) goto end; - if(!config_get_hex(conf, "rgui_border_dark_color", &border_dark_color)) + if (!config_get_hex(conf, "rgui_border_dark_color", &border_dark_color)) goto end; - if(!config_get_hex(conf, "rgui_border_light_color", &border_light_color)) + if (!config_get_hex(conf, "rgui_border_light_color", &border_light_color)) goto end; /* Make shadow colour optional (fallback to fully opaque black) * - i.e. if user has no intention of enabling shadows, they * should not have to include this entry */ - if(!config_get_hex(conf, "rgui_shadow_color", &shadow_color)) + if (!config_get_hex(conf, "rgui_shadow_color", &shadow_color)) shadow_color = 0xFF000000; /* Make particle colour optional too (fallback to normal * rgb with bg_light alpha) */ - if(!config_get_hex(conf, "rgui_particle_color", &particle_color)) + if (!config_get_hex(conf, "rgui_particle_color", &particle_color)) particle_color = (normal_color & 0x00FFFFFF) | (bg_light_color & 0xFF000000); @@ -3643,7 +3643,7 @@ static void rgui_render(void *data, * standard layout (even though it always will...), * so have to check whether there are an odd or even * number of entries... */ - if((rgui_term_layout.height & 1) == 0) + if ((rgui_term_layout.height & 1) == 0) { /* Even number of entries */ if ((show_thumbnail && (term_offset <= term_mid_point)) || diff --git a/menu/drivers/xui.cpp b/menu/drivers/xui.cpp index 18d4a954c1..d13e7be819 100644 --- a/menu/drivers/xui.cpp +++ b/menu/drivers/xui.cpp @@ -219,7 +219,7 @@ HRESULT XuiTextureLoader(IXuiDevice *pDevice, LPCWSTR szFileName, /* Cast our d3d device into our IDirect3DDevice9* interface */ d3dDevice = (IDirect3DDevice9*)pDevice->GetD3DDevice(); - if(!d3dDevice) + if (!d3dDevice) goto cleanup; /* Create our texture based on our conditions */ @@ -241,7 +241,7 @@ HRESULT XuiTextureLoader(IXuiDevice *pDevice, LPCWSTR szFileName, ppTex ); - if(hr != D3DXERR_INVALIDDATA ) + if (hr != D3DXERR_INVALIDDATA ) { pImageInfo->Depth = pSrc.Depth; pImageInfo->Format = pSrc.Format; @@ -477,7 +477,7 @@ static void xui_set_list_text(int index, const wchar_t* leftText, if (XuiHandleIsValid(hControl)) XuiControlGetVisual(hControl, &hVisual); - if(!XuiHandleIsValid(hVisual)) + if (!XuiHandleIsValid(hVisual)) return; XuiElementGetChildById(hVisual, L"LeftText", &hTextLeft); @@ -497,7 +497,7 @@ static void xui_set_list_text(int index, const wchar_t* leftText, XuiTextElementSetText(hTextLeft, leftText); XuiElementGetChildById(hVisual, L"RightText", &hTextRight); - if(XuiHandleIsValid(hTextRight)) + if (XuiHandleIsValid(hTextRight)) { currText = XuiTextElementGetText(hTextRight); XuiElementGetBounds(hTextRight, &width, &height); diff --git a/menu/drivers_display/menu_display_d3d8.c b/menu/drivers_display/menu_display_d3d8.c index 97a3890b1e..03a4f214d0 100644 --- a/menu/drivers_display/menu_display_d3d8.c +++ b/menu/drivers_display/menu_display_d3d8.c @@ -128,7 +128,7 @@ static void menu_display_d3d8_draw(menu_display_ctx_draw_t *draw, if (!d3d || !draw || draw->pipeline.id) return; - if((d3d->menu_display.offset + draw->coords->vertices ) + if ((d3d->menu_display.offset + draw->coords->vertices ) > (unsigned)d3d->menu_display.size) return; @@ -185,7 +185,7 @@ static void menu_display_d3d8_draw(menu_display_ctx_draw_t *draw, } d3d8_vertex_buffer_unlock(d3d->menu_display.buffer); - if(!draw->matrix_data) + if (!draw->matrix_data) draw->matrix_data = menu_display_d3d8_get_default_mvp(video_info); /* ugh */ diff --git a/menu/drivers_display/menu_display_d3d9.c b/menu/drivers_display/menu_display_d3d9.c index 74e4c3ebe4..bdf65090df 100644 --- a/menu/drivers_display/menu_display_d3d9.c +++ b/menu/drivers_display/menu_display_d3d9.c @@ -133,7 +133,7 @@ static void menu_display_d3d9_draw(menu_display_ctx_draw_t *draw, dev = d3d->dev; - if((d3d->menu_display.offset + draw->coords->vertices ) + if ((d3d->menu_display.offset + draw->coords->vertices ) > (unsigned)d3d->menu_display.size) return; @@ -180,7 +180,7 @@ static void menu_display_d3d9_draw(menu_display_ctx_draw_t *draw, d3d9_vertex_buffer_unlock((LPDIRECT3DVERTEXBUFFER9) d3d->menu_display.buffer); - if(!draw->matrix_data) + if (!draw->matrix_data) draw->matrix_data = menu_display_d3d9_get_default_mvp(video_info); /* ugh */ diff --git a/menu/drivers_display/menu_display_wiiu.c b/menu/drivers_display/menu_display_wiiu.c index 829e08876f..0fab93f858 100644 --- a/menu/drivers_display/menu_display_wiiu.c +++ b/menu/drivers_display/menu_display_wiiu.c @@ -67,7 +67,7 @@ static void menu_display_wiiu_draw(menu_display_ctx_draw_t *draw, if (!wiiu || !draw) return; - if(draw->pipeline.id) + if (draw->pipeline.id) { GX2SetShaderMode(GX2_SHADER_MODE_UNIFORM_BLOCK); @@ -113,7 +113,7 @@ static void menu_display_wiiu_draw(menu_display_ctx_draw_t *draw, } } - else if(draw->coords->vertex || draw->coords->color[0] != draw->coords->color[12]) + else if (draw->coords->vertex || draw->coords->color[0] != draw->coords->color[12]) { if (wiiu->vertex_cache_tex.current + 4 > wiiu->vertex_cache_tex.size) return; @@ -128,7 +128,7 @@ static void menu_display_wiiu_draw(menu_display_ctx_draw_t *draw, GX2SetAttribBuffer(0, wiiu->vertex_cache_tex.size * sizeof(*wiiu->vertex_cache_tex.v), sizeof(*wiiu->vertex_cache_tex.v), wiiu->vertex_cache_tex.v); - if(!draw->coords->vertex) + if (!draw->coords->vertex) { v[0].pos.x = 0.0f; v[0].pos.y = 1.0f; @@ -151,7 +151,7 @@ static void menu_display_wiiu_draw(menu_display_ctx_draw_t *draw, v[3].pos.y = 1.0 - draw->coords->vertex[7]; } - if(!draw->coords->tex_coord) + if (!draw->coords->tex_coord) { v[0].coord.u = 0.0f; v[0].coord.v = 1.0f; @@ -182,7 +182,7 @@ static void menu_display_wiiu_draw(menu_display_ctx_draw_t *draw, v[i].color.a = draw->coords->color[(i << 2) + 3]; } - if(draw->texture) + if (draw->texture) GX2SetPixelTexture((GX2Texture*)draw->texture, tex_shader.ps.samplerVars[0].location); GX2DrawEx(GX2_PRIMITIVE_MODE_TRIANGLE_STRIP, 4, wiiu->vertex_cache_tex.current, 1); @@ -206,7 +206,7 @@ static void menu_display_wiiu_draw(menu_display_ctx_draw_t *draw, v->color = COLOR_RGBA(0xFF * draw->coords->color[0], 0xFF * draw->coords->color[1], 0xFF * draw->coords->color[2], 0xFF * draw->coords->color[3]); - if(draw->texture) + if (draw->texture) GX2SetPixelTexture((GX2Texture*)draw->texture, sprite_shader.ps.samplerVars[0].location); GX2DrawEx(GX2_PRIMITIVE_MODE_POINTS, 1, wiiu->vertex_cache.current, 1); @@ -242,7 +242,7 @@ static void menu_display_wiiu_draw_pipeline(menu_display_ctx_draw_t *draw, case VIDEO_SHADER_MENU: case VIDEO_SHADER_MENU_2: ca = menu_display_get_coords_array(); - if(!wiiu->menu_shader_vbo) + if (!wiiu->menu_shader_vbo) { wiiu->menu_shader_vbo = MEM2_alloc(ca->coords.vertices * 2 * sizeof(float), GX2_VERTEX_BUFFER_ALIGNMENT); memcpy(wiiu->menu_shader_vbo, ca->coords.vertex, ca->coords.vertices * 2 * sizeof(float)); @@ -266,7 +266,7 @@ static void menu_display_wiiu_draw_pipeline(menu_display_ctx_draw_t *draw, return; } - if(!wiiu->menu_shader_ubo) + if (!wiiu->menu_shader_ubo) { wiiu->menu_shader_ubo = MEM2_alloc(sizeof(*wiiu->menu_shader_ubo), GX2_UNIFORM_BLOCK_ALIGNMENT); matrix_4x4_ortho(wiiu->menu_shader_ubo->mvp, 0, 1, 1, 0, -1, 1); diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index a65da2f739..7e7caa0e5d 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -7961,7 +7961,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, snprintf(text, sizeof(text), "Current profile : %s", current_profile); #else u32 currentClock = 0; - if(hosversionBefore(8, 0, 0)) + if (hosversionBefore(8, 0, 0)) pcvGetClockRate(PcvModule_CpuBus, ¤tClock); else { diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 4133f24578..b8dfcdcb3d 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -2567,7 +2567,8 @@ static int setting_action_ok_bind_all_save_autoconfig(rarch_setting_t *setting, index_offset = setting->index_offset; name = input_config_get_device_name(index_offset); - if(!string_is_empty(name) && config_save_autoconf_profile(name, index_offset)) + if (!string_is_empty(name) && + config_save_autoconf_profile(name, index_offset)) runloop_msg_queue_push( msg_hash_to_str(MSG_AUTOCONFIG_FILE_SAVED_SUCCESSFULLY), 1, 100, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); @@ -6861,7 +6862,7 @@ static void overlay_auto_rotate_toggle_change_handler(rarch_setting_t *setting) #ifdef HAVE_VIDEO_LAYOUT static void change_handler_video_layout_enable(rarch_setting_t *setting) { - if(*setting->value.target.boolean) + if (*setting->value.target.boolean) { settings_t *settings = config_get_ptr(); void *driver = video_driver_get_ptr(false); diff --git a/menu/menu_thumbnail.c b/menu/menu_thumbnail.c index 60268be912..15911da0dc 100644 --- a/menu/menu_thumbnail.c +++ b/menu/menu_thumbnail.c @@ -250,7 +250,7 @@ void menu_thumbnail_request( /* Would like to cancel any existing image load tasks * here, but can't see how to do it... */ - if(task_push_image_load( + if (task_push_image_load( thumbnail_path, video_driver_supports_rgba(), menu_thumbnail_upscale_threshold, menu_thumbnail_handle_upload, thumbnail_tag)) @@ -343,7 +343,7 @@ void menu_thumbnail_request_file( /* Would like to cancel any existing image load tasks * here, but can't see how to do it... */ - if(task_push_image_load( + if (task_push_image_load( file_path, video_driver_supports_rgba(), menu_thumbnail_upscale_threshold, menu_thumbnail_handle_upload, thumbnail_tag)) diff --git a/midi/drivers/alsa_midi.c b/midi/drivers/alsa_midi.c index bd8f20afaf..632074e31f 100644 --- a/midi/drivers/alsa_midi.c +++ b/midi/drivers/alsa_midi.c @@ -405,7 +405,8 @@ static bool alsa_midi_write(void *p, const midi_event_t *event) ev.time.time.tv_sec = d->out_ev_time.tv_sec + event->delta_time / 1000000; ev.time.time.tv_nsec = d->out_ev_time.tv_nsec + (event->delta_time % 1000000) * 1000; - if(ev.time.time.tv_nsec >= 1000000000) + + if (ev.time.time.tv_nsec >= 1000000000) { ev.time.time.tv_sec += 1; ev.time.time.tv_nsec -= 1000000000; diff --git a/midi/drivers/winmm_midi.c b/midi/drivers/winmm_midi.c index 0699accb9c..4268a9ceb7 100644 --- a/midi/drivers/winmm_midi.c +++ b/midi/drivers/winmm_midi.c @@ -168,7 +168,7 @@ static void CALLBACK winmm_midi_input_callback(HMIDIIN dev, UINT msg, #endif } } - else if(msg == MIM_LONGDATA) + else if (msg == MIM_LONGDATA) { #ifdef DEBUG RARCH_WARN("[MIDI]: SysEx input not implemented, event dropped.\n"); diff --git a/network/netplay/netplay_frontend.c b/network/netplay/netplay_frontend.c index 11aeafdea0..f164dbe292 100644 --- a/network/netplay/netplay_frontend.c +++ b/network/netplay/netplay_frontend.c @@ -856,7 +856,7 @@ static void netplay_announce(void) frontend_drv->ident, frontend_architecture_tmp); #ifdef HAVE_DISCORD - if(discord_is_ready()) + if (discord_is_ready()) net_http_urlencode(&username, discord_get_own_username()); else #endif diff --git a/retroarch.c b/retroarch.c index 5d1ec731b2..9d34784a43 100644 --- a/retroarch.c +++ b/retroarch.c @@ -3845,7 +3845,7 @@ static bool command_get_config_param(const char* arg) if (!strcmp(arg, "video_fullscreen")) { - if(configuration_settings->bools.video_fullscreen) + if (configuration_settings->bools.video_fullscreen) value = "true"; else value = "false"; From 0fd00ca82fdb65828a85ecdb4131e56f0a75945c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 10 Feb 2020 15:24:14 +0100 Subject: [PATCH 10/75] Cleanup --- frontend/drivers/platform_xdk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/drivers/platform_xdk.c b/frontend/drivers/platform_xdk.c index 24909f9356..b016b346aa 100644 --- a/frontend/drivers/platform_xdk.c +++ b/frontend/drivers/platform_xdk.c @@ -181,7 +181,7 @@ static void frontend_xdk_get_environment_settings(int *argc, char *argv[], if ( !string_is_empty(extracted_path) - && (strstr(extracted_path, "Pool") == NULL) + && (!strstr(extracted_path, "Pool")) /* Hack. Unknown problem */) { /* Auto-start game */ From 5e20a7ef5e2356602c6d301d615fe4236648cc79 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 10 Feb 2020 15:33:32 +0100 Subject: [PATCH 11/75] Rework some of the config.def.h variables --- config.def.h | 72 +++++++++++++++---------------- configuration.c | 2 +- menu/menu_setting.c | 2 +- ui/drivers/qt/updateretroarch.cpp | 2 +- 4 files changed, 39 insertions(+), 39 deletions(-) diff --git a/config.def.h b/config.def.h index 5e27d5e224..02a5a830de 100644 --- a/config.def.h +++ b/config.def.h @@ -1101,95 +1101,95 @@ static const bool enable_device_vibration = false; #endif #if defined(HAKCHI) -static const char buildbot_server_url[] = "http://hakchicloud.com/Libretro_Cores/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://hakchicloud.com/Libretro_Cores/" #elif defined(ANDROID) #if defined(ANDROID_ARM_V7) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/android/latest/armeabi-v7a/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/android/latest/armeabi-v7a/" #elif defined(ANDROID_ARM) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/android/latest/armeabi/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/android/latest/armeabi/" #elif defined(ANDROID_AARCH64) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/android/latest/arm64-v8a/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/android/latest/arm64-v8a/" #elif defined(ANDROID_X86) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/android/latest/x86/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/android/latest/x86/" #elif defined(ANDROID_X64) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/android/latest/x86_64/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/android/latest/x86_64/" #else -static const char buildbot_server_url[] = ""; +#define DEFAULT_BUILDBOT_SERVER_URL "" #endif #elif defined(__QNX__) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/blackberry/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/blackberry/latest/" #elif defined(IOS) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/apple/ios/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/apple/ios/latest/" #elif defined(OSX) #if defined(__x86_64__) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/apple/osx/x86_64/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/apple/osx/x86_64/latest/" #elif defined(__i386__) || defined(__i486__) || defined(__i686__) -static const char buildbot_server_url[] = "http://bot.libretro.com/nightly/apple/osx/x86/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://bot.libretro.com/nightly/apple/osx/x86/latest/" #else -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/apple/osx/ppc/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/apple/osx/ppc/latest/" #endif #elif defined(_WIN32) && !defined(_XBOX) #if _MSC_VER >= 1910 #ifndef __WINRT__ #if defined(__x86_64__) || defined(_M_X64) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2017-desktop/x64/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/windows-msvc2017-desktop/x64/latest/" #elif defined(__i386__) || defined(__i486__) || defined(__i686__) || defined(_M_IX86) || defined(_M_IA64) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2017-desktop/x86/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/windows-msvc2017-desktop/x86/latest/" #elif defined(__arm__) || defined(_M_ARM) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2017-desktop/arm/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/windows-msvc2017-desktop/arm/latest/" #elif defined(__aarch64__) || defined(_M_ARM64) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2017-desktop/arm64/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/windows-msvc2017-desktop/arm64/latest/" #endif #else #if defined(__x86_64__) || defined(_M_X64) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2017-uwp/x64/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/windows-msvc2017-uwp/x64/latest/" #elif defined(__i386__) || defined(__i486__) || defined(__i686__) || defined(_M_IX86) || defined(_M_IA64) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2017-uwp/x86/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/windows-msvc2017-uwp/x86/latest/" #elif defined(__arm__) || defined(_M_ARM) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2017-uwp/arm/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/windows-msvc2017-uwp/arm/latest/" #elif defined(__aarch64__) || defined(_M_ARM64) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2017-uwp/arm64/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/windows-msvc2017-uwp/arm64/latest/" #endif #endif #elif _MSC_VER == 1600 #if defined(__x86_64__) || defined(_M_X64) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2010/x86_64/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/windows-msvc2010/x86_64/latest/" #elif defined(__i386__) || defined(__i486__) || defined(__i686__) || defined(_M_IX86) || defined(_M_IA64) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2010/x86/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/windows-msvc2010/x86/latest/" #endif #elif _MSC_VER == 1400 -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2005/x86/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/windows-msvc2005/x86/latest/" #elif _MSC_VER == 1310 -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2003/x86/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/windows-msvc2003/x86/latest/" #else #if defined(__x86_64__) || defined(_M_X64) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows/x86_64/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/windows/x86_64/latest/" #elif defined(__i386__) || defined(__i486__) || defined(__i686__) || defined(_M_IX86) || defined(_M_IA64) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows/x86/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/windows/x86/latest/" #endif #endif #elif defined(__linux__) #if defined(__x86_64__) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/linux/x86_64/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/linux/x86_64/latest/" #elif defined(__i386__) || defined(__i486__) || defined(__i686__) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/linux/x86/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/linux/x86/latest/" #elif defined(__arm__) && __ARM_ARCH == 7 && defined(__ARM_PCS_VFP) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/linux/armhf/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/linux/armhf/latest/" #else -static const char buildbot_server_url[] = ""; +#define DEFAULT_BUILDBOT_SERVER_URL "" #endif #elif defined(WIIU) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/nintendo/wiiu/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/nintendo/wiiu/latest/" #elif defined(HAVE_LIBNX) -static const char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/nintendo/switch/libnx/latest/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://buildbot.libretro.com/nightly/nintendo/switch/libnx/latest/" #elif defined(__CELLOS_LV2__) && defined(DEX_BUILD) -static const char buildbot_server_url[] = "http://libretro.xbins.org/libretro/nightly/playstation/ps3/latest/dex-ps3/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://libretro.xbins.org/libretro/nightly/playstation/ps3/latest/dex-ps3/" #elif defined(__CELLOS_LV2__) && defined(CEX_BUILD) -static const char buildbot_server_url[] = "http://libretro.xbins.org/libretro/nightly/playstation/ps3/latest/cex-ps3/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://libretro.xbins.org/libretro/nightly/playstation/ps3/latest/cex-ps3/" #elif defined(__CELLOS_LV2__) && defined(ODE_BUILD) -static const char buildbot_server_url[] = "http://libretro.xbins.org/libretro/nightly/playstation/ps3/latest/ode-ps3/"; +#define DEFAULT_BUILDBOT_SERVER_URL "http://libretro.xbins.org/libretro/nightly/playstation/ps3/latest/ode-ps3/" #else -static const char buildbot_server_url[] = ""; +#define DEFAULT_BUILDBOT_SERVER_URL "" #endif #define DEFAULT_BUILDBOT_ASSETS_SERVER_URL "http://buildbot.libretro.com/assets/" diff --git a/configuration.c b/configuration.c index 2cf65ebbfe..4d6c717aa3 100644 --- a/configuration.c +++ b/configuration.c @@ -2165,7 +2165,7 @@ void config_set_defaults(void *data) } } - strlcpy(settings->paths.network_buildbot_url, buildbot_server_url, + strlcpy(settings->paths.network_buildbot_url, DEFAULT_BUILDBOT_SERVER_URL, sizeof(settings->paths.network_buildbot_url)); strlcpy(settings->paths.network_buildbot_assets_url, DEFAULT_BUILDBOT_ASSETS_SERVER_URL, diff --git a/menu/menu_setting.c b/menu/menu_setting.c index b8dfcdcb3d..8129566c7c 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -15452,7 +15452,7 @@ static bool setting_append_list( sizeof(settings->paths.network_buildbot_url), MENU_ENUM_LABEL_CORE_UPDATER_BUILDBOT_URL, MENU_ENUM_LABEL_VALUE_CORE_UPDATER_BUILDBOT_URL, - buildbot_server_url, + DEFAULT_BUILDBOT_SERVER_URL, &group_info, &subgroup_info, parent_group, diff --git a/ui/drivers/qt/updateretroarch.cpp b/ui/drivers/qt/updateretroarch.cpp index 30f5e1988e..22ae04ecd5 100644 --- a/ui/drivers/qt/updateretroarch.cpp +++ b/ui/drivers/qt/updateretroarch.cpp @@ -235,7 +235,7 @@ void MainWindow::onUpdateDownloadReadyRead() void MainWindow::updateRetroArchNightly() { - QUrl url(QUrl(buildbot_server_url).resolved(QUrl(RETROARCH_NIGHTLY_UPDATE_PATH))); + QUrl url(QUrl(DEFAULT_BUILDBOT_SERVER_URL).resolved(QUrl(RETROARCH_NIGHTLY_UPDATE_PATH))); QNetworkRequest request(url); QNetworkReply *reply = NULL; QByteArray urlArray = url.toString().toUtf8(); From 70e3ddb2246bf8ebc8ed3162620b022a55607f7b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 10 Feb 2020 17:19:49 +0100 Subject: [PATCH 12/75] Cleanups --- configuration.c | 8 ++++++-- configuration.h | 8 -------- retroarch.c | 7 +------ 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/configuration.c b/configuration.c index 4d6c717aa3..d604443737 100644 --- a/configuration.c +++ b/configuration.c @@ -623,6 +623,11 @@ static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_NULL; #define SETTING_OVERRIDE(override_setting) \ tmp[count-1].override = override_setting +/* Forward declarations */ +#ifdef HAVE_CONFIGFILE +static void config_parse_file(global_t *global); +#endif + struct defaults g_defaults; /** @@ -3595,9 +3600,8 @@ success: * Loads a config file and reads all the values into memory. * */ -void config_parse_file(void *data) +static void config_parse_file(global_t *global) { - global_t *global = (global_t*)data; if (path_is_empty(RARCH_PATH_CONFIG)) { RARCH_LOG("[config] Loading default config.\n"); diff --git a/configuration.h b/configuration.h index 6d631f718d..66fedf606b 100644 --- a/configuration.h +++ b/configuration.h @@ -809,14 +809,6 @@ const char *config_get_midi_driver_options(void); const char *config_get_default_record(void); -/** - * config_parse_file: - * - * Loads a config file and reads all the values into memory. - * - */ -void config_parse_file(void *data); - #ifdef HAVE_CONFIGFILE /** * config_load_override: diff --git a/retroarch.c b/retroarch.c index 9d34784a43..e1c27d33a7 100644 --- a/retroarch.c +++ b/retroarch.c @@ -24753,12 +24753,7 @@ static void retroarch_parse_input_and_config(int argc, char *argv[]) #ifdef HAVE_CONFIGFILE if (!rarch_block_config_read) #endif - { - config_set_defaults(&g_extern); -#ifdef HAVE_CONFIGFILE - config_parse_file(&g_extern); -#endif - } + config_load(&g_extern); /* Second pass: All other arguments override the config file */ optind = 1; From bc5349061f15014f3a177faf000fdd70f3d3aeb9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 10 Feb 2020 20:39:53 +0100 Subject: [PATCH 13/75] Missing prototype --- configuration.h | 2 ++ retroarch.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/configuration.h b/configuration.h index 66fedf606b..b425e1c292 100644 --- a/configuration.h +++ b/configuration.h @@ -881,6 +881,8 @@ bool config_overlay_enable_default(void); void config_set_defaults(void *data); +void config_load(void *data); + settings_t *config_get_ptr(void); RETRO_END_DECLS diff --git a/retroarch.c b/retroarch.c index e1c27d33a7..a2a2fd872a 100644 --- a/retroarch.c +++ b/retroarch.c @@ -5913,7 +5913,6 @@ static bool command_event_init_core(enum rarch_core_type type) sizeof(runloop_system.valid_extensions)); #ifdef HAVE_CONFIGFILE - /* auto overrides: apply overrides */ if (settings->bools.auto_overrides_enable) runloop_overrides_active = config_load_override(&runloop_system); #endif From 1f6b90a4f919d3088d88bdaa07073a375e155963 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 10 Feb 2020 20:45:17 +0100 Subject: [PATCH 14/75] Prevent warnings --- wiiu/fs/fs_utils.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wiiu/fs/fs_utils.c b/wiiu/fs/fs_utils.c index 5188970303..a474351ef7 100644 --- a/wiiu/fs/fs_utils.c +++ b/wiiu/fs/fs_utils.c @@ -175,16 +175,16 @@ int CreateSubfolder(const char * fullpath) return 1; { + char *ptr; char parentpath[strlen(dirnoslash)+2]; - size_t copied = strcpy(parentpath, dirnoslash); - char * ptr = strrchr(parentpath, '/'); + strcpy(parentpath, dirnoslash); + ptr = strrchr(parentpath, '/'); if (!ptr) { - struct stat filestat; /* Device root directory (must be with '/') */ - parentpath[copied] = '/'; - parentpath[copied+1] = '\0'; + struct stat filestat; + strcat(parentpath, "/"); if (stat(parentpath, &filestat) == 0) return 1; From fff9a4f0c53692385f5b0e4de4c8419dd5087a3c Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Tue, 11 Feb 2020 17:02:47 +0000 Subject: [PATCH 15/75] (Ozone) Add DPI-based scaling --- menu/drivers/ozone/ozone.c | 426 ++++++++++++++++++++--------- menu/drivers/ozone/ozone.h | 22 ++ menu/drivers/ozone/ozone_display.c | 91 +++--- menu/drivers/ozone/ozone_entries.c | 84 +++--- menu/drivers/ozone/ozone_sidebar.c | 167 +++++++---- menu/menu_setting.c | 5 +- 6 files changed, 533 insertions(+), 262 deletions(-) diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 98207291af..d5174e5168 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -150,6 +150,10 @@ static void *ozone_init(void **userdata, bool video_is_threaded) *userdata = ozone; + ozone->last_width = width; + ozone->last_height = height; + ozone->last_scale_factor = menu_display_get_dpi_scale(width, height); + ozone->selection_buf_old = (file_list_t*)calloc(1, sizeof(file_list_t)); ozone->draw_sidebar = true; @@ -444,101 +448,204 @@ static void ozone_refresh_thumbnail_image(void *data, unsigned i) ozone_update_thumbnail_image(ozone); } -/* TODO: Scale text */ -static void ozone_context_reset(void *data, bool is_threaded) +/* Determines the size of all menu elements */ +static void ozone_set_layout(ozone_handle_t *ozone, bool is_threaded) { - /* Fonts init */ - unsigned i; - unsigned size; + int font_size; + float scale_factor; char font_path[PATH_MAX_LENGTH]; - float scale = 1; /*TODO: compute that from screen resolution and dpi */ + font_path[0] = '\0'; + if (!ozone) + return; + + /* Due to the 'multi-column' menu layout + * (i.e. sidebars + entries), actual scale factor + * must be capped to a sensible upper limit + * > Normal left hand sidebar width must be no + * more than 1/3 of the total screen width, + * otherwise menu becomes unusable */ + ozone->capped_scale_factor = + (SIDEBAR_WIDTH * ozone->last_scale_factor) > (ozone->last_width * 0.3333333f) ? + ((float)ozone->last_width * 0.3333333f / (float)SIDEBAR_WIDTH) : ozone->last_scale_factor; + scale_factor = ozone->capped_scale_factor; + + /* Calculate dimensions */ + ozone->dimensions.header_height = HEADER_HEIGHT * scale_factor; + ozone->dimensions.footer_height = FOOTER_HEIGHT * scale_factor; + + ozone->dimensions.entry_padding_horizontal_half = ENTRY_PADDING_HORIZONTAL_HALF * scale_factor; + ozone->dimensions.entry_padding_horizontal_full = ENTRY_PADDING_HORIZONTAL_FULL * scale_factor; + ozone->dimensions.entry_padding_vertical = ENTRY_PADDING_VERTICAL * scale_factor; + ozone->dimensions.entry_height = ENTRY_HEIGHT * scale_factor; + ozone->dimensions.entry_spacing = ENTRY_SPACING * scale_factor; + ozone->dimensions.entry_icon_size = ENTRY_ICON_SIZE * scale_factor; + ozone->dimensions.entry_icon_padding = ENTRY_ICON_PADDING * scale_factor; + + ozone->dimensions.sidebar_entry_height = SIDEBAR_ENTRY_HEIGHT * scale_factor; + ozone->dimensions.sidebar_padding_horizontal = SIDEBAR_X_PADDING * scale_factor; + ozone->dimensions.sidebar_padding_vertical = SIDEBAR_Y_PADDING * scale_factor; + ozone->dimensions.sidebar_entry_padding_vertical = SIDEBAR_ENTRY_Y_PADDING * scale_factor; + ozone->dimensions.sidebar_entry_icon_size = SIDEBAR_ENTRY_ICON_SIZE * scale_factor; + ozone->dimensions.sidebar_entry_icon_padding = SIDEBAR_ENTRY_ICON_PADDING * scale_factor; + ozone->dimensions.sidebar_gradient_height = SIDEBAR_GRADIENT_HEIGHT * scale_factor; + + ozone->dimensions.sidebar_width_normal = SIDEBAR_WIDTH * scale_factor; + ozone->dimensions.sidebar_width_collapsed = + ozone->dimensions.sidebar_entry_icon_size + + ozone->dimensions.sidebar_entry_icon_padding * 2 + + ozone->dimensions.sidebar_padding_horizontal * 2; + + if (ozone->dimensions.sidebar_width == 0) + ozone->dimensions.sidebar_width = (float)ozone->dimensions.sidebar_width_normal; + + ozone->dimensions.thumbnail_bar_width = + ozone->dimensions.sidebar_width_normal - + ozone->dimensions.sidebar_entry_icon_size - + ozone->dimensions.sidebar_entry_icon_padding; + + ozone->dimensions.cursor_size = CURSOR_SIZE * scale_factor; + + ozone->dimensions.fullscreen_thumbnail_padding = FULLSCREEN_THUMBNAIL_PADDING * scale_factor; + + ozone->dimensions.spacer_1px = (scale_factor > 1.0f) ? (unsigned)(scale_factor + 0.5f) : 1; + ozone->dimensions.spacer_2px = ozone->dimensions.spacer_1px * 2; + ozone->dimensions.spacer_3px = (unsigned)((scale_factor * 3.0f) + 0.5f); + ozone->dimensions.spacer_5px = (unsigned)((scale_factor * 5.0f) + 0.5f); + + /* Initialise fonts */ + + /* > Free existing */ + if (ozone->fonts.footer) + { + menu_display_font_free(ozone->fonts.footer); + ozone->fonts.footer = NULL; + } + if (ozone->fonts.entries_label) + { + menu_display_font_free(ozone->fonts.entries_label); + ozone->fonts.entries_label = NULL; + } + if (ozone->fonts.entries_sublabel) + { + menu_display_font_free(ozone->fonts.entries_sublabel); + ozone->fonts.entries_sublabel = NULL; + } + if (ozone->fonts.time) + { + menu_display_font_free(ozone->fonts.time); + ozone->fonts.time = NULL; + } + if (ozone->fonts.sidebar) + { + menu_display_font_free(ozone->fonts.sidebar); + ozone->fonts.sidebar = NULL; + } + if (ozone->fonts.title) + { + menu_display_font_free(ozone->fonts.title); + ozone->fonts.title = NULL; + } + + /* > Cache 'naive' font heights */ + ozone->title_font_glyph_height = FONT_SIZE_TITLE * scale_factor; + ozone->entry_font_glyph_height = FONT_SIZE_ENTRIES_LABEL * scale_factor; + ozone->sublabel_font_glyph_height = FONT_SIZE_ENTRIES_SUBLABEL * scale_factor; + ozone->footer_font_glyph_height = FONT_SIZE_FOOTER * scale_factor; + ozone->sidebar_font_glyph_height = FONT_SIZE_SIDEBAR * scale_factor; + ozone->time_font_glyph_height = FONT_SIZE_TIME * scale_factor; + + /* > Create 'bold' font objects */ + fill_pathname_join(font_path, ozone->assets_path, "bold.ttf", sizeof(font_path)); + ozone->fonts.title = menu_display_font_file(font_path, ozone->title_font_glyph_height, is_threaded); + + /* > Create 'regular' font objects */ + fill_pathname_join(font_path, ozone->assets_path, "regular.ttf", sizeof(font_path)); + ozone->fonts.entries_label = menu_display_font_file(font_path, ozone->entry_font_glyph_height, is_threaded); + ozone->fonts.entries_sublabel = menu_display_font_file(font_path, ozone->sublabel_font_glyph_height, is_threaded); + ozone->fonts.footer = menu_display_font_file(font_path, ozone->footer_font_glyph_height, is_threaded); + ozone->fonts.sidebar = menu_display_font_file(font_path, ozone->sidebar_font_glyph_height, is_threaded); + ozone->fonts.time = menu_display_font_file(font_path, ozone->time_font_glyph_height, is_threaded); + + /* > Check for missing assets */ + if (!ozone->fonts.title || + !ozone->fonts.entries_label || + !ozone->fonts.entries_sublabel || + !ozone->fonts.footer || + !ozone->fonts.sidebar || + !ozone->fonts.time) + ozone->has_all_assets = false; + + /* > Cache 'naive' font widths */ + ozone->title_font_glyph_width = ozone->title_font_glyph_height * 3.0f/4.0f; + ozone->entry_font_glyph_width = ozone->entry_font_glyph_height * 3.0f/4.0f; + ozone->sublabel_font_glyph_width = ozone->sublabel_font_glyph_height * 3.0f/4.0f; + ozone->footer_font_glyph_width = ozone->footer_font_glyph_height * 3.0f/4.0f; + ozone->sidebar_font_glyph_width = ozone->sidebar_font_glyph_height * 3.0f/4.0f; + ozone->time_font_glyph_width = ozone->time_font_glyph_height * 3.0f/4.0f; + + /* > Determine more realistic font widths */ + font_size = font_driver_get_message_width(ozone->fonts.title, "a", 1, 1); + if (font_size > 0) + ozone->title_font_glyph_width = (unsigned)font_size; + font_size = font_driver_get_message_width(ozone->fonts.entries_label, "a", 1, 1); + if (font_size > 0) + ozone->entry_font_glyph_width = (unsigned)font_size; + font_size = font_driver_get_message_width(ozone->fonts.entries_sublabel, "a", 1, 1); + if (font_size > 0) + ozone->sublabel_font_glyph_width = (unsigned)font_size; + font_size = font_driver_get_message_width(ozone->fonts.footer, "a", 1, 1); + if (font_size > 0) + ozone->footer_font_glyph_width = (unsigned)font_size; + font_size = font_driver_get_message_width(ozone->fonts.sidebar, "a", 1, 1); + if (font_size > 0) + ozone->sidebar_font_glyph_width = (unsigned)font_size; + font_size = font_driver_get_message_width(ozone->fonts.time, "a", 1, 1); + if (font_size > 0) + ozone->time_font_glyph_width = (unsigned)font_size; + + /* > Get actual font heights */ + font_size = font_driver_get_line_height(ozone->fonts.title, 1.0f); + if (font_size > 0) + ozone->title_font_glyph_height = (unsigned)font_size; + font_size = font_driver_get_line_height(ozone->fonts.entries_label, 1.0f); + if (font_size > 0) + ozone->entry_font_glyph_height = (unsigned)font_size; + font_size = font_driver_get_line_height(ozone->fonts.entries_sublabel, 1.0f); + if (font_size > 0) + ozone->sublabel_font_glyph_height = (unsigned)font_size; + font_size = font_driver_get_line_height(ozone->fonts.footer, 1.0f); + if (font_size > 0) + ozone->footer_font_glyph_height = (unsigned)font_size; + font_size = font_driver_get_line_height(ozone->fonts.sidebar, 1.0f); + if (font_size > 0) + ozone->sidebar_font_glyph_height = (unsigned)font_size; + font_size = font_driver_get_line_height(ozone->fonts.time, 1.0f); + if (font_size > 0) + ozone->time_font_glyph_height = (unsigned)font_size; + + /* Multiple sidebar parameters are set via animations + * > ozone_refresh_sidebars() cancels any existing + * animations and 'force updates' the affected + * variables with newly scaled values */ + ozone_refresh_sidebars(ozone, ozone->last_height); + + /* Entry dimensions must be recalculated after + * updating menu layout */ + ozone->need_compute = true; +} + +static void ozone_context_reset(void *data, bool is_threaded) +{ + unsigned i; ozone_handle_t *ozone = (ozone_handle_t*) data; if (ozone) { ozone->has_all_assets = true; - fill_pathname_join(font_path, ozone->assets_path, "regular.ttf", sizeof(font_path)); - ozone->fonts.footer = menu_display_font_file(font_path, FONT_SIZE_FOOTER, is_threaded); - ozone->fonts.entries_label = menu_display_font_file(font_path, FONT_SIZE_ENTRIES_LABEL, is_threaded); - ozone->fonts.entries_sublabel = menu_display_font_file(font_path, FONT_SIZE_ENTRIES_SUBLABEL, is_threaded); - ozone->fonts.time = menu_display_font_file(font_path, FONT_SIZE_TIME, is_threaded); - ozone->fonts.sidebar = menu_display_font_file(font_path, FONT_SIZE_SIDEBAR, is_threaded); - - fill_pathname_join(font_path, ozone->assets_path, "bold.ttf", sizeof(font_path)); - ozone->fonts.title = menu_display_font_file(font_path, FONT_SIZE_TITLE, is_threaded); - - if ( - !ozone->fonts.footer || - !ozone->fonts.entries_label || - !ozone->fonts.entries_sublabel || - !ozone->fonts.time || - !ozone->fonts.sidebar || - !ozone->fonts.title - ) - { - ozone->has_all_assets = false; - } - - /* Dimensions */ - ozone->dimensions.header_height = HEADER_HEIGHT * scale; - ozone->dimensions.footer_height = FOOTER_HEIGHT * scale; - - ozone->dimensions.entry_padding_horizontal_half = ENTRY_PADDING_HORIZONTAL_HALF * scale; - ozone->dimensions.entry_padding_horizontal_full = ENTRY_PADDING_HORIZONTAL_FULL * scale; - ozone->dimensions.entry_padding_vertical = ENTRY_PADDING_VERTICAL * scale; - ozone->dimensions.entry_height = ENTRY_HEIGHT * scale; - ozone->dimensions.entry_spacing = ENTRY_SPACING * scale; - ozone->dimensions.entry_icon_size = ENTRY_ICON_SIZE * scale; - ozone->dimensions.entry_icon_padding = ENTRY_ICON_PADDING * scale; - - ozone->dimensions.sidebar_entry_height = SIDEBAR_ENTRY_HEIGHT * scale; - ozone->dimensions.sidebar_padding_horizontal = SIDEBAR_X_PADDING * scale; - ozone->dimensions.sidebar_padding_vertical = SIDEBAR_Y_PADDING * scale; - ozone->dimensions.sidebar_entry_padding_vertical = SIDEBAR_ENTRY_Y_PADDING * scale; - ozone->dimensions.sidebar_entry_icon_size = SIDEBAR_ENTRY_ICON_SIZE * scale; - ozone->dimensions.sidebar_entry_icon_padding = SIDEBAR_ENTRY_ICON_PADDING * scale; - - ozone->dimensions.sidebar_width_normal = SIDEBAR_WIDTH * scale; - ozone->dimensions.sidebar_width_collapsed = ozone->dimensions.sidebar_entry_icon_size - + ozone->dimensions.sidebar_entry_icon_padding * 2 - + ozone->dimensions.sidebar_padding_horizontal * 2; - - if (ozone->dimensions.sidebar_width == 0) - ozone->dimensions.sidebar_width = (float) ozone->dimensions.sidebar_width_normal; - - ozone->dimensions.thumbnail_bar_width = ozone->dimensions.sidebar_width_normal - - ozone->dimensions.sidebar_entry_icon_size - - ozone->dimensions.sidebar_entry_icon_padding; - ozone->dimensions.cursor_size = CURSOR_SIZE * scale; - - ozone->dimensions.fullscreen_thumbnail_padding = FULLSCREEN_THUMBNAIL_PADDING * scale; - - /* Naive font size */ - ozone->title_font_glyph_width = FONT_SIZE_TITLE * 3/4; - ozone->entry_font_glyph_width = FONT_SIZE_ENTRIES_LABEL * 3/4; - ozone->sublabel_font_glyph_width = FONT_SIZE_ENTRIES_SUBLABEL * 3/4; - ozone->sidebar_font_glyph_width = FONT_SIZE_SIDEBAR * 3/4; - ozone->footer_font_glyph_width = FONT_SIZE_FOOTER * 3/4; - - /* More realistic font size */ - size = font_driver_get_message_width(ozone->fonts.title, "a", 1, 1); - if (size) - ozone->title_font_glyph_width = size; - size = font_driver_get_message_width(ozone->fonts.entries_label, "a", 1, 1); - if (size) - ozone->entry_font_glyph_width = size; - size = font_driver_get_message_width(ozone->fonts.entries_sublabel, "a", 1, 1); - if (size) - ozone->sublabel_font_glyph_width = size; - size = font_driver_get_message_width(ozone->fonts.sidebar, "a", 1, 1); - if (size) - ozone->sidebar_font_glyph_width = size; - size = font_driver_get_message_width(ozone->fonts.footer, "a", 1, 1); - if (size) - ozone->footer_font_glyph_width = size; + ozone_set_layout(ozone, is_threaded); /* Textures init */ for (i = 0; i < OZONE_TEXTURE_LAST; i++) @@ -984,11 +1091,30 @@ static void ozone_render(void *data, bool is_idle) { size_t i; + float scale_factor; unsigned end = (unsigned)menu_entries_get_size(); ozone_handle_t *ozone = (ozone_handle_t*)data; - if (!data) + if (!ozone) return; + /* Check whether screen dimensions or menu scale + * factor have changed */ + scale_factor = menu_display_get_dpi_scale(width, height); + + if ((scale_factor != ozone->last_scale_factor) || + (width != ozone->last_width) || + (height != ozone->last_height)) + { + ozone->last_scale_factor = scale_factor; + ozone->last_width = width; + ozone->last_height = height; + + /* Note: We don't need a full context reset here + * > Just rescale layout, and reset frame time counter */ + ozone_set_layout(ozone, video_driver_is_threaded()); + video_driver_monitor_reset(); + } + if (ozone->need_compute) { ozone_compute_entries_position(ozone); @@ -1016,10 +1142,14 @@ static void ozone_draw_header(ozone_handle_t *ozone, video_frame_info_t *video_i menu_animation_ctx_ticker_t ticker; menu_animation_ctx_ticker_smooth_t ticker_smooth; static const char* const ticker_spacer = OZONE_TICKER_SPACER; - unsigned ticker_x_offset = 0; - settings_t *settings = config_get_ptr(); - unsigned timedate_offset = 0; - bool use_smooth_ticker = settings->bools.menu_ticker_smooth; + unsigned ticker_x_offset = 0; + settings_t *settings = config_get_ptr(); + unsigned timedate_offset = 0; + bool use_smooth_ticker = settings->bools.menu_ticker_smooth; + float scale_factor = ozone->capped_scale_factor; + unsigned logo_icon_size = 60 * scale_factor; + unsigned status_icon_size = 92 * scale_factor; + unsigned seperator_margin = 30 * scale_factor; /* Initial ticker configuration */ if (use_smooth_ticker) @@ -1039,14 +1169,14 @@ static void ozone_draw_header(ozone_handle_t *ozone, video_frame_info_t *video_i } /* Separator */ - menu_display_draw_quad(video_info, 30, ozone->dimensions.header_height, video_info->width - 60, 1, video_info->width, video_info->height, ozone->theme->header_footer_separator); + menu_display_draw_quad(video_info, seperator_margin, ozone->dimensions.header_height, video_info->width - seperator_margin * 2, ozone->dimensions.spacer_1px, video_info->width, video_info->height, ozone->theme->header_footer_separator); /* Title */ if (use_smooth_ticker) { ticker_smooth.font = ozone->fonts.title; ticker_smooth.selected = true; - ticker_smooth.field_width = (video_info->width - 128 - 47 - 180); + ticker_smooth.field_width = (video_info->width - (128 + 47 + 180) * scale_factor); ticker_smooth.src_str = ozone->show_fullscreen_thumbnails ? ozone->fullscreen_thumbnail_label : ozone->title; ticker_smooth.dst_str = title; ticker_smooth.dst_str_len = sizeof(title); @@ -1056,23 +1186,41 @@ static void ozone_draw_header(ozone_handle_t *ozone, video_frame_info_t *video_i else { ticker.s = title; - ticker.len = (video_info->width - 128 - 47 - 180) / ozone->title_font_glyph_width; + ticker.len = (video_info->width - (128 + 47 + 180) * scale_factor) / ozone->title_font_glyph_width; ticker.str = ozone->show_fullscreen_thumbnails ? ozone->fullscreen_thumbnail_label : ozone->title; ticker.selected = true; menu_animation_ticker(&ticker); } - ozone_draw_text(video_info, ozone, title, ticker_x_offset + 128, ozone->dimensions.header_height / 2 + FONT_SIZE_TITLE * 3/8, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.title, ozone->theme->text_rgba, false); + ozone_draw_text(video_info, ozone, title, ticker_x_offset + 128 * scale_factor, ozone->dimensions.header_height / 2 + ozone->title_font_glyph_height * 3.0f/10.0f, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.title, ozone->theme->text_rgba, false); /* Icon */ menu_display_blend_begin(video_info); #if 0 if (discord_avatar_is_ready()) - ozone_draw_icon(video_info, 60, 60, ozone->textures[OZONE_TEXTURE_DISCORD_OWN_AVATAR], 47, 14, video_info->width, video_info->height, 0, 1, ozone->theme->entries_icon); + ozone_draw_icon( + video_info, + logo_icon_size, + logo_icon_size, + ozone->textures[OZONE_TEXTURE_DISCORD_OWN_AVATAR], + 47 * scale_factor, + 14 * scale_factor, /* Where does this come from...? */ + video_info->width, + video_info->height, + 0, 1, ozone->theme->entries_icon); else #endif - ozone_draw_icon(video_info, 60, 60, ozone->textures[OZONE_TEXTURE_RETROARCH], 47, (ozone->dimensions.header_height - 60) / 2, video_info->width, video_info->height, 0, 1, ozone->theme->entries_icon); + ozone_draw_icon( + video_info, + logo_icon_size, + logo_icon_size, + ozone->textures[OZONE_TEXTURE_RETROARCH], + 47 * scale_factor, + (ozone->dimensions.header_height - logo_icon_size) / 2, + video_info->width, + video_info->height, + 0, 1, ozone->theme->entries_icon); menu_display_blend_end(video_info); /* Battery */ @@ -1090,12 +1238,21 @@ static void ozone_draw_header(ozone_handle_t *ozone, video_frame_info_t *video_i if (powerstate.battery_enabled) { - timedate_offset = 95; + timedate_offset = 95 * scale_factor; - ozone_draw_text(video_info, ozone, msg, video_info->width - 85, ozone->dimensions.header_height / 2 + FONT_SIZE_TIME * 3/8, TEXT_ALIGN_RIGHT, video_info->width, video_info->height, ozone->fonts.time, ozone->theme->text_rgba, false); + ozone_draw_text(video_info, ozone, msg, video_info->width - 85 * scale_factor, ozone->dimensions.header_height / 2 + ozone->time_font_glyph_height * 3.0f/10.0f, TEXT_ALIGN_RIGHT, video_info->width, video_info->height, ozone->fonts.time, ozone->theme->text_rgba, false); menu_display_blend_begin(video_info); - ozone_draw_icon(video_info, 92, 92, ozone->icons_textures[powerstate.charging? OZONE_ENTRIES_ICONS_TEXTURE_BATTERY_CHARGING : (powerstate.percent > 80)? OZONE_ENTRIES_ICONS_TEXTURE_BATTERY_FULL : (powerstate.percent > 60)? OZONE_ENTRIES_ICONS_TEXTURE_BATTERY_80 : (powerstate.percent > 40)? OZONE_ENTRIES_ICONS_TEXTURE_BATTERY_60 : (powerstate.percent > 20)? OZONE_ENTRIES_ICONS_TEXTURE_BATTERY_40 : OZONE_ENTRIES_ICONS_TEXTURE_BATTERY_20], video_info->width - 60 - 56, ozone->dimensions.header_height / 2 - 42, video_info->width, video_info->height, 0, 1, ozone->theme->entries_icon); + ozone_draw_icon( + video_info, + status_icon_size, + status_icon_size, + ozone->icons_textures[powerstate.charging? OZONE_ENTRIES_ICONS_TEXTURE_BATTERY_CHARGING : (powerstate.percent > 80)? OZONE_ENTRIES_ICONS_TEXTURE_BATTERY_FULL : (powerstate.percent > 60)? OZONE_ENTRIES_ICONS_TEXTURE_BATTERY_80 : (powerstate.percent > 40)? OZONE_ENTRIES_ICONS_TEXTURE_BATTERY_60 : (powerstate.percent > 20)? OZONE_ENTRIES_ICONS_TEXTURE_BATTERY_40 : OZONE_ENTRIES_ICONS_TEXTURE_BATTERY_20], + video_info->width - (60 + 56) * scale_factor, + 0, + video_info->width, + video_info->height, + 0, 1, ozone->theme->entries_icon); menu_display_blend_end(video_info); } } @@ -1114,43 +1271,55 @@ static void ozone_draw_header(ozone_handle_t *ozone, video_frame_info_t *video_i menu_display_timedate(&datetime); - ozone_draw_text(video_info, ozone, timedate, video_info->width - 85 - timedate_offset, ozone->dimensions.header_height / 2 + FONT_SIZE_TIME * 3/8, TEXT_ALIGN_RIGHT, video_info->width, video_info->height, ozone->fonts.time, ozone->theme->text_rgba, false); + ozone_draw_text(video_info, ozone, timedate, video_info->width - (85 * scale_factor) - timedate_offset, ozone->dimensions.header_height / 2 + ozone->time_font_glyph_height * 3.0f/10.0f, TEXT_ALIGN_RIGHT, video_info->width, video_info->height, ozone->fonts.time, ozone->theme->text_rgba, false); menu_display_blend_begin(video_info); - ozone_draw_icon(video_info, 92, 92, ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_CLOCK], video_info->width - 60 - 56 - timedate_offset, ozone->dimensions.header_height / 2 - 42, video_info->width, video_info->height, 0, 1, ozone->theme->entries_icon); + ozone_draw_icon( + video_info, + status_icon_size, + status_icon_size, + ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_CLOCK], + video_info->width - (60 + 56) * scale_factor - timedate_offset, + 0, + video_info->width, + video_info->height, + 0, 1, ozone->theme->entries_icon); menu_display_blend_end(video_info); } } static void ozone_draw_footer(ozone_handle_t *ozone, video_frame_info_t *video_info, settings_t *settings) { + float scale_factor = ozone->capped_scale_factor; + unsigned seperator_margin = 30 * scale_factor; + /* Separator */ - menu_display_draw_quad(video_info, 30, video_info->height - ozone->dimensions.footer_height, video_info->width - 60, 1, video_info->width, video_info->height, ozone->theme->header_footer_separator); + menu_display_draw_quad(video_info, seperator_margin, video_info->height - ozone->dimensions.footer_height, video_info->width - seperator_margin * 2, ozone->dimensions.spacer_1px, video_info->width, video_info->height, ozone->theme->header_footer_separator); /* Core title or Switch icon */ if (settings->bools.menu_core_enable) { char core_title[255]; menu_entries_get_core_title(core_title, sizeof(core_title)); - ozone_draw_text(video_info, ozone, core_title, 59, video_info->height - ozone->dimensions.footer_height / 2 + FONT_SIZE_FOOTER * 3/8, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.footer, ozone->theme->text_rgba, false); + ozone_draw_text(video_info, ozone, core_title, 59 * scale_factor, video_info->height - ozone->dimensions.footer_height / 2 + ozone->footer_font_glyph_height * 3.0f/10.0f, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.footer, ozone->theme->text_rgba, false); } else - ozone_draw_icon(video_info, 69, 30, ozone->theme->textures[OZONE_THEME_TEXTURE_SWITCH], 59, video_info->height - ozone->dimensions.footer_height / 2 - 15, video_info->width,video_info->height, 0, 1, NULL); + ozone_draw_icon(video_info, 69 * scale_factor, 30 * scale_factor, ozone->theme->textures[OZONE_THEME_TEXTURE_SWITCH], 59 * scale_factor, video_info->height - ozone->dimensions.footer_height / 2 - 15 * scale_factor, video_info->width,video_info->height, 0, 1, NULL); /* Buttons */ { - unsigned back_width = 215; - unsigned ok_width = 96; - unsigned search_width = 343; - unsigned thumb_width = 343 + 188 + 80; - unsigned icon_size = 35; + unsigned back_width = 215 * scale_factor; + unsigned ok_width = 96 * scale_factor; + unsigned search_width = 343 * scale_factor; + unsigned thumb_width = (343 + 188 + 80) * scale_factor; + unsigned icon_size = 35 * scale_factor; unsigned icon_offset = icon_size / 2; bool do_swap = video_info->input_menu_swap_ok_cancel_buttons; if (do_swap) { - back_width = 96; - ok_width = 215; + back_width = 96 * scale_factor; + ok_width = 215 * scale_factor; } menu_display_blend_begin(video_info); @@ -1159,19 +1328,19 @@ static void ozone_draw_footer(ozone_handle_t *ozone, video_frame_info_t *video_i if (do_swap) { - ozone_draw_icon(video_info, icon_size, icon_size, ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_D], video_info->width - 138, video_info->height - ozone->dimensions.footer_height / 2 - icon_offset, video_info->width,video_info->height, 0, 1, ozone->theme_dynamic.entries_icon); - ozone_draw_icon(video_info, icon_size, icon_size, ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_R], video_info->width - 256, video_info->height - ozone->dimensions.footer_height / 2 - icon_offset, video_info->width,video_info->height, 0, 1, ozone->theme_dynamic.entries_icon); + ozone_draw_icon(video_info, icon_size, icon_size, ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_D], video_info->width - 138 * scale_factor, video_info->height - ozone->dimensions.footer_height / 2 - icon_offset, video_info->width,video_info->height, 0, 1, ozone->theme_dynamic.entries_icon); + ozone_draw_icon(video_info, icon_size, icon_size, ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_R], video_info->width - 256 * scale_factor, video_info->height - ozone->dimensions.footer_height / 2 - icon_offset, video_info->width,video_info->height, 0, 1, ozone->theme_dynamic.entries_icon); } else { - ozone_draw_icon(video_info, icon_size, icon_size, ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_D], video_info->width - 256, video_info->height - ozone->dimensions.footer_height / 2 - icon_offset, video_info->width,video_info->height, 0, 1, ozone->theme_dynamic.entries_icon); - ozone_draw_icon(video_info, icon_size, icon_size, ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_R], video_info->width - 138, video_info->height - ozone->dimensions.footer_height / 2 - icon_offset, video_info->width,video_info->height, 0, 1, ozone->theme_dynamic.entries_icon); + ozone_draw_icon(video_info, icon_size, icon_size, ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_D], video_info->width - 256 * scale_factor, video_info->height - ozone->dimensions.footer_height / 2 - icon_offset, video_info->width,video_info->height, 0, 1, ozone->theme_dynamic.entries_icon); + ozone_draw_icon(video_info, icon_size, icon_size, ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_R], video_info->width - 138 * scale_factor, video_info->height - ozone->dimensions.footer_height / 2 - icon_offset, video_info->width,video_info->height, 0, 1, ozone->theme_dynamic.entries_icon); } - ozone_draw_icon(video_info, icon_size, icon_size, ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_U], video_info->width - 384, video_info->height - ozone->dimensions.footer_height / 2 - icon_offset, video_info->width,video_info->height, 0, 1, ozone->theme_dynamic.entries_icon); + ozone_draw_icon(video_info, icon_size, icon_size, ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_U], video_info->width - 384 * scale_factor, video_info->height - ozone->dimensions.footer_height / 2 - icon_offset, video_info->width,video_info->height, 0, 1, ozone->theme_dynamic.entries_icon); if (ozone->is_playlist && !ozone->cursor_in_sidebar) - ozone_draw_icon(video_info, icon_size, icon_size, ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_L], video_info->width - 384 - 118 - 100 - 50, video_info->height - ozone->dimensions.footer_height / 2 - icon_offset, video_info->width,video_info->height, 0, 1, ozone->theme_dynamic.entries_icon); + ozone_draw_icon(video_info, icon_size, icon_size, ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_INPUT_BTN_L], video_info->width - (384 + 118 + 100 + 50) * scale_factor, video_info->height - ozone->dimensions.footer_height / 2 - icon_offset, video_info->width,video_info->height, 0, 1, ozone->theme_dynamic.entries_icon); menu_display_blend_end(video_info); @@ -1179,21 +1348,21 @@ static void ozone_draw_footer(ozone_handle_t *ozone, video_frame_info_t *video_i do_swap ? msg_hash_to_str(MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_OK) : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_BACK), - video_info->width - back_width, video_info->height - ozone->dimensions.footer_height / 2 + FONT_SIZE_FOOTER * 3/8, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.footer, ozone->theme->text_rgba, false); + video_info->width - back_width, video_info->height - ozone->dimensions.footer_height / 2 + ozone->footer_font_glyph_height * 3.0f/10.0f, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.footer, ozone->theme->text_rgba, false); ozone_draw_text(video_info, ozone, do_swap ? msg_hash_to_str(MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_BACK) : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_OK), - video_info->width - ok_width, video_info->height - ozone->dimensions.footer_height / 2 + FONT_SIZE_FOOTER * 3/8, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.footer, ozone->theme->text_rgba, false); + video_info->width - ok_width, video_info->height - ozone->dimensions.footer_height / 2 + ozone->footer_font_glyph_height * 3.0f/10.0f, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.footer, ozone->theme->text_rgba, false); ozone_draw_text(video_info, ozone, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SEARCH), - video_info->width - search_width, video_info->height - ozone->dimensions.footer_height / 2 + FONT_SIZE_FOOTER * 3/8, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.footer, ozone->theme->text_rgba, false); + video_info->width - search_width, video_info->height - ozone->dimensions.footer_height / 2 + ozone->footer_font_glyph_height * 3.0f/10.0f, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.footer, ozone->theme->text_rgba, false); if (ozone->is_playlist && !ozone->cursor_in_sidebar) ozone_draw_text(video_info, ozone, msg_hash_to_str(MSG_CHANGE_THUMBNAIL_TYPE), - video_info->width - thumb_width, video_info->height - ozone->dimensions.footer_height / 2 + FONT_SIZE_FOOTER * 3/8, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.footer, ozone->theme->text_rgba, false); + video_info->width - thumb_width, video_info->height - ozone->dimensions.footer_height / 2 + ozone->footer_font_glyph_height * 3.0f/10.0f, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.footer, ozone->theme->text_rgba, false); } @@ -1581,7 +1750,7 @@ static void ozone_frame(void *data, video_frame_info_t *video_info) ozone_draw_sidebar(ozone, video_info); /* Menu entries */ - menu_display_scissor_begin(video_info, ozone->sidebar_offset + (unsigned) ozone->dimensions.sidebar_width, ozone->dimensions.header_height + 1, video_info->width - (unsigned) ozone->dimensions.sidebar_width + (-ozone->sidebar_offset), video_info->height - ozone->dimensions.header_height - ozone->dimensions.footer_height - 1); + menu_display_scissor_begin(video_info, ozone->sidebar_offset + (unsigned) ozone->dimensions.sidebar_width, ozone->dimensions.header_height + ozone->dimensions.spacer_1px, video_info->width - (unsigned) ozone->dimensions.sidebar_width + (-ozone->sidebar_offset), video_info->height - ozone->dimensions.header_height - ozone->dimensions.footer_height - ozone->dimensions.spacer_1px); /* Current list */ ozone_draw_entries(ozone, @@ -1733,6 +1902,7 @@ static void ozone_animation_end(void *userdata) static void ozone_list_open(ozone_handle_t *ozone) { + menu_animation_ctx_tag sidebar_tag = (uintptr_t)&ozone->sidebar_offset; struct menu_animation_ctx_entry entry; ozone->draw_old_list = true; @@ -1761,7 +1931,7 @@ static void ozone_list_open(ozone_handle_t *ozone) entry.duration = ANIMATION_PUSH_ENTRY_DURATION; entry.easing_enum = EASING_OUT_QUAD; entry.subject = &ozone->sidebar_offset; - entry.tag = (uintptr_t) NULL; + entry.tag = sidebar_tag; entry.target_value = 0.0f; entry.userdata = NULL; @@ -1775,7 +1945,7 @@ static void ozone_list_open(ozone_handle_t *ozone) entry.duration = ANIMATION_PUSH_ENTRY_DURATION; entry.easing_enum = EASING_OUT_QUAD; entry.subject = &ozone->sidebar_offset; - entry.tag = (uintptr_t) NULL; + entry.tag = sidebar_tag; entry.target_value = -ozone->dimensions.sidebar_width; entry.userdata = (void*) ozone; @@ -2017,6 +2187,7 @@ static void ozone_list_cache(void *data, unsigned video_info_height; float bottom_boundary; ozone_node_t *first_node; + float scale_factor; unsigned first = 0; unsigned last = 0; file_list_t *selection_buf = NULL; @@ -2025,6 +2196,7 @@ static void ozone_list_cache(void *data, if (!ozone) return; + scale_factor = ozone->capped_scale_factor; ozone->need_compute = true; ozone->selection_old_list = ozone->selection; ozone->scroll_old = ozone->animations.scroll_y; @@ -2044,12 +2216,12 @@ static void ozone_list_cache(void *data, if (!node) continue; - if (y + ozone->animations.scroll_y + node->height + 20 < ozone->dimensions.header_height + ozone->dimensions.entry_padding_vertical) + if (y + ozone->animations.scroll_y + node->height + 20 * scale_factor < ozone->dimensions.header_height + ozone->dimensions.entry_padding_vertical) { first++; goto text_iterate; } - else if (y + ozone->animations.scroll_y - node->height - 20 > bottom_boundary) + else if (y + ozone->animations.scroll_y - node->height - 20 * scale_factor > bottom_boundary) goto text_iterate; last++; @@ -2405,7 +2577,6 @@ static enum menu_action ozone_parse_menu_entry_action( if (!ozone->cursor_in_sidebar) break; - tag = (uintptr_t)ozone; new_selection = (int)(ozone->categories_selection_ptr + 1); if (new_selection >= (int)(ozone->system_tab_end + horizontal_list_size + 1)) @@ -2420,7 +2591,6 @@ static enum menu_action ozone_parse_menu_entry_action( if (!ozone->cursor_in_sidebar) break; - tag = (uintptr_t)ozone; new_selection = (int)ozone->categories_selection_ptr - 1; if (new_selection < 0) diff --git a/menu/drivers/ozone/ozone.h b/menu/drivers/ozone/ozone.h index 1da024c6b6..84858261b8 100644 --- a/menu/drivers/ozone/ozone.h +++ b/menu/drivers/ozone/ozone.h @@ -59,6 +59,7 @@ typedef struct ozone_handle ozone_handle_t; #define SIDEBAR_ENTRY_Y_PADDING 10 #define SIDEBAR_ENTRY_ICON_SIZE 46 #define SIDEBAR_ENTRY_ICON_PADDING 15 +#define SIDEBAR_GRADIENT_HEIGHT 28 #define FULLSCREEN_THUMBNAIL_PADDING 48 @@ -151,6 +152,14 @@ struct ozone_handle unsigned sublabel_font_glyph_width; unsigned footer_font_glyph_width; unsigned sidebar_font_glyph_width; + unsigned time_font_glyph_width; + + unsigned title_font_glyph_height; + unsigned entry_font_glyph_height; + unsigned sublabel_font_glyph_height; + unsigned footer_font_glyph_height; + unsigned sidebar_font_glyph_height; + unsigned time_font_glyph_height; ozone_theme_t *theme; @@ -167,6 +176,11 @@ struct ozone_handle float message_background[16]; } theme_dynamic; + unsigned last_width; + unsigned last_height; + float last_scale_factor; + float capped_scale_factor; + bool need_compute; file_list_t *selection_buf_old; @@ -213,11 +227,17 @@ struct ozone_handle int sidebar_entry_height; int sidebar_entry_icon_size; int sidebar_entry_icon_padding; + int sidebar_gradient_height; int cursor_size; int thumbnail_bar_width; int fullscreen_thumbnail_padding; + + int spacer_1px; + int spacer_2px; + int spacer_3px; + int spacer_5px; } dimensions; bool show_cursor; @@ -316,6 +336,8 @@ void ozone_update_scroll(ozone_handle_t *ozone, bool allow_animation, ozone_node void ozone_sidebar_update_collapse(ozone_handle_t *ozone, bool allow_animation); +void ozone_refresh_sidebars(ozone_handle_t *ozone, unsigned video_height); + void ozone_entries_update_thumbnail_bar(ozone_handle_t *ozone, bool is_playlist, bool allow_animation); void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, video_frame_info_t *video_info); diff --git a/menu/drivers/ozone/ozone_display.c b/menu/drivers/ozone/ozone_display.c index 45b6b6739a..276987f1c9 100644 --- a/menu/drivers/ozone/ozone_display.c +++ b/menu/drivers/ozone/ozone_display.c @@ -118,6 +118,12 @@ static void ozone_draw_cursor_slice(ozone_handle_t *ozone, unsigned width, unsigned height, size_t y, float alpha) { + float scale_factor = ozone->capped_scale_factor; + int slice_x = x_offset - 14 * scale_factor; + int slice_y = (int)y + 8 * scale_factor; + unsigned slice_new_w = width + (3 + 28 - 4) * scale_factor; + unsigned slice_new_h = height + 20 * scale_factor; + menu_display_set_alpha(ozone->theme_dynamic.cursor_alpha, alpha); menu_display_set_alpha(ozone->theme_dynamic.cursor_border, alpha); @@ -126,28 +132,28 @@ static void ozone_draw_cursor_slice(ozone_handle_t *ozone, /* Cursor without border */ menu_display_draw_texture_slice( video_info, - x_offset - 14, - (int)(y + 8), + slice_x, + slice_y, 80, 80, - width + 3 + 28 - 4, - height + 20, + slice_new_w, + slice_new_h, video_info->width, video_info->height, ozone->theme_dynamic.cursor_alpha, - 20, 1.0, + 20, scale_factor, ozone->theme->textures[OZONE_THEME_TEXTURE_CURSOR_NO_BORDER] ); /* Tainted border */ menu_display_draw_texture_slice( video_info, - x_offset - 14, - (int)(y + 8), + slice_x, + slice_y, 80, 80, - width + 3 + 28 - 4, - height + 20, + slice_new_w, + slice_new_h, video_info->width, video_info->height, ozone->theme_dynamic.cursor_border, - 20, 1.0, + 20, scale_factor, ozone->textures[OZONE_TEXTURE_CURSOR_BORDER] ); @@ -164,21 +170,21 @@ static void ozone_draw_cursor_fallback(ozone_handle_t *ozone, menu_display_set_alpha(ozone->theme_dynamic.selection, alpha); /* Fill */ - menu_display_draw_quad(video_info, x_offset, (int)y, width, height - 5, video_info->width, video_info->height, ozone->theme_dynamic.selection); + menu_display_draw_quad(video_info, x_offset, (int)y, width, height - ozone->dimensions.spacer_5px, video_info->width, video_info->height, ozone->theme_dynamic.selection); /* Borders (can't do one single quad because of alpha) */ /* Top */ - menu_display_draw_quad(video_info, x_offset - 3, (int)(y - 3), width + 6, 3, video_info->width, video_info->height, ozone->theme_dynamic.selection_border); + menu_display_draw_quad(video_info, x_offset - ozone->dimensions.spacer_3px, (int)(y - ozone->dimensions.spacer_3px), width + ozone->dimensions.spacer_3px * 2, ozone->dimensions.spacer_3px, video_info->width, video_info->height, ozone->theme_dynamic.selection_border); /* Bottom */ - menu_display_draw_quad(video_info, x_offset - 3, (int)(y + height - 5), width + 6, 3, video_info->width, video_info->height, ozone->theme_dynamic.selection_border); + menu_display_draw_quad(video_info, x_offset - ozone->dimensions.spacer_3px, (int)(y + height - ozone->dimensions.spacer_5px), width + ozone->dimensions.spacer_3px * 2, ozone->dimensions.spacer_3px, video_info->width, video_info->height, ozone->theme_dynamic.selection_border); /* Left */ - menu_display_draw_quad(video_info, (int)(x_offset - 3), (int)y, 3, height - 5, video_info->width, video_info->height, ozone->theme_dynamic.selection_border); + menu_display_draw_quad(video_info, (int)(x_offset - ozone->dimensions.spacer_3px), (int)y, ozone->dimensions.spacer_3px, height - ozone->dimensions.spacer_5px, video_info->width, video_info->height, ozone->theme_dynamic.selection_border); /* Right */ - menu_display_draw_quad(video_info, x_offset + width, (int)y, 3, height - 5, video_info->width, video_info->height, ozone->theme_dynamic.selection_border); + menu_display_draw_quad(video_info, x_offset + width, (int)y, ozone->dimensions.spacer_3px, height - ozone->dimensions.spacer_5px, video_info->width, video_info->height, ozone->theme_dynamic.selection_border); } void ozone_draw_cursor(ozone_handle_t *ozone, @@ -255,8 +261,9 @@ void ozone_draw_osk(ozone_handle_t *ozone, unsigned text_color; struct string_list *list; - unsigned margin = 75; - unsigned padding = 10; + float scale_factor = ozone->capped_scale_factor; + unsigned margin = 75 * scale_factor; + unsigned padding = 10 * scale_factor; unsigned bottom_end = video_info->height/2; unsigned y_offset = 0; bool draw_placeholder = string_is_empty(str); @@ -272,20 +279,20 @@ void ozone_draw_osk(ozone_handle_t *ozone, /* Border */ /* Top */ - menu_display_draw_quad(video_info, margin, margin, video_info->width - margin*2, 1, video_info->width, video_info->height, ozone->theme->entries_border); + menu_display_draw_quad(video_info, margin, margin, video_info->width - margin*2, ozone->dimensions.spacer_1px, video_info->width, video_info->height, ozone->theme->entries_border); /* Bottom */ - menu_display_draw_quad(video_info, margin, bottom_end - margin, video_info->width - margin*2, 1, video_info->width, video_info->height, ozone->theme->entries_border); + menu_display_draw_quad(video_info, margin, bottom_end - margin, video_info->width - margin*2, ozone->dimensions.spacer_1px, video_info->width, video_info->height, ozone->theme->entries_border); /* Left */ - menu_display_draw_quad(video_info, margin, margin, 1, bottom_end - margin*2, video_info->width, video_info->height, ozone->theme->entries_border); + menu_display_draw_quad(video_info, margin, margin, ozone->dimensions.spacer_1px, bottom_end - margin*2, video_info->width, video_info->height, ozone->theme->entries_border); /* Right */ - menu_display_draw_quad(video_info, video_info->width - margin, margin, 1, bottom_end - margin*2, video_info->width, video_info->height, ozone->theme->entries_border); + menu_display_draw_quad(video_info, video_info->width - margin, margin, ozone->dimensions.spacer_1px, bottom_end - margin*2, video_info->width, video_info->height, ozone->theme->entries_border); /* Backdrop */ /* TODO: Remove the backdrop if blur shader is available */ - menu_display_draw_quad(video_info, margin + 1, margin + 1, video_info->width - margin*2 - 2, bottom_end - margin*2 - 2, video_info->width, video_info->height, ozone_osk_backdrop); + menu_display_draw_quad(video_info, margin + ozone->dimensions.spacer_1px, margin + ozone->dimensions.spacer_1px, video_info->width - margin*2 - ozone->dimensions.spacer_2px, bottom_end - margin*2 - ozone->dimensions.spacer_2px, video_info->width, video_info->height, ozone_osk_backdrop); /* Placeholder & text*/ if (!draw_placeholder) @@ -307,7 +314,7 @@ void ozone_draw_osk(ozone_handle_t *ozone, { const char *msg = list->elems[i].data; - ozone_draw_text(video_info, ozone, msg, margin + padding * 2, margin + padding + FONT_SIZE_ENTRIES_LABEL + y_offset, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.entries_label, text_color, false); + ozone_draw_text(video_info, ozone, msg, margin + padding * 2, margin + padding + ozone->sublabel_font_glyph_height + y_offset, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.entries_label, text_color, false); /* Cursor */ if (i == list->size - 1) @@ -315,12 +322,12 @@ void ozone_draw_osk(ozone_handle_t *ozone, if (ozone->osk_cursor) { unsigned cursor_x = draw_placeholder ? 0 : font_driver_get_message_width(ozone->fonts.entries_label, msg, (unsigned)strlen(msg), 1); - menu_display_draw_quad(video_info, margin + padding*2 + cursor_x, margin + padding + y_offset + 3, 1, 25, video_info->width, video_info->height, ozone_pure_white); + menu_display_draw_quad(video_info, margin + padding*2 + cursor_x, margin + padding + y_offset + ozone->dimensions.spacer_3px, ozone->dimensions.spacer_1px, 25 * scale_factor, video_info->width, video_info->height, ozone_pure_white); } } else { - y_offset += 25; + y_offset += 25 * scale_factor; } } @@ -342,11 +349,11 @@ void ozone_draw_messagebox(ozone_handle_t *ozone, { unsigned i, y_position; int x, y, longest = 0, longest_width = 0; - float line_height = 0; unsigned width = video_info->width; unsigned height = video_info->height; struct string_list *list = !string_is_empty(message) ? string_split(message, "\n") : NULL; + float scale_factor = ozone->capped_scale_factor; if (!list || !ozone || !ozone->fonts.footer) { @@ -358,14 +365,12 @@ void ozone_draw_messagebox(ozone_handle_t *ozone, if (list->elems == 0) goto end; - line_height = 25; - y_position = height / 2; if (menu_input_dialog_get_display_kb()) y_position = height / 4; x = width / 2; - y = y_position - (list->size-1) * line_height / 2; + y = y_position - (list->size * ozone->footer_font_glyph_height) / 2; /* find the longest line width */ for (i = 0; i < list->size; i++) @@ -386,18 +391,24 @@ void ozone_draw_messagebox(ozone_handle_t *ozone, menu_display_blend_begin(video_info); if (ozone->has_all_assets) /* avoid drawing a black box if there's no assets */ + { + int slice_x = x - longest_width/2 - 48 * scale_factor; + unsigned slice_new_w = longest_width + 48 * 2 * scale_factor; + unsigned slice_new_h = ozone->footer_font_glyph_height * (list->size + 2); + menu_display_draw_texture_slice( video_info, - x - longest_width/2 - 48, - y + 16 - 48, + slice_x, + y, 256, 256, - longest_width + 48 * 2, - line_height * list->size + 48 * 2, + slice_new_w, + slice_new_h, width, height, ozone->theme_dynamic.message_background, - 16, 1.0, + 16, scale_factor, ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_DIALOG_SLICE] ); + } for (i = 0; i < list->size; i++) { @@ -407,7 +418,7 @@ void ozone_draw_messagebox(ozone_handle_t *ozone, ozone_draw_text(video_info, ozone, msg, x - longest_width/2.0, - y + (i+0.75) * line_height, + y + (i + 1) * ozone->footer_font_glyph_height, TEXT_ALIGN_LEFT, width, height, ozone->fonts.footer, @@ -434,7 +445,7 @@ void ozone_draw_fullscreen_thumbnails( unsigned width = video_info->width; unsigned height = video_info->height; int view_width = (int)width; - int view_height = (int)height - ozone->dimensions.header_height - ozone->dimensions.footer_height - 1; + int view_height = (int)height - ozone->dimensions.header_height - ozone->dimensions.footer_height - ozone->dimensions.spacer_1px; int thumbnail_margin = ozone->dimensions.fullscreen_thumbnail_padding; bool show_right_thumbnail = false; bool show_left_thumbnail = false; @@ -506,7 +517,7 @@ void ozone_draw_fullscreen_thumbnails( /* > Thumbnail bounding box height + y position * are fixed */ thumbnail_box_height = view_height - (thumbnail_margin * 2); - thumbnail_y = ozone->dimensions.header_height + thumbnail_margin + 1; + thumbnail_y = ozone->dimensions.header_height + thumbnail_margin + ozone->dimensions.spacer_1px; /* Thumbnail bounding box width and x position * depend upon number of active thumbnails */ @@ -597,7 +608,7 @@ void ozone_draw_fullscreen_thumbnails( menu_display_draw_quad( video_info, 0, - ozone->dimensions.header_height + 1, + ozone->dimensions.header_height + ozone->dimensions.spacer_1px, width, (unsigned)view_height, width, @@ -610,7 +621,7 @@ void ozone_draw_fullscreen_thumbnails( 0, ozone->dimensions.header_height, width, - 1, + ozone->dimensions.spacer_1px, width, height, separator_color); @@ -620,7 +631,7 @@ void ozone_draw_fullscreen_thumbnails( 0, height - ozone->dimensions.footer_height, width, - 1, + ozone->dimensions.spacer_1px, width, height, separator_color); diff --git a/menu/drivers/ozone/ozone_entries.c b/menu/drivers/ozone/ozone_entries.c index fd361bd0aa..52d523a9f9 100644 --- a/menu/drivers/ozone/ozone_entries.c +++ b/menu/drivers/ozone/ozone_entries.c @@ -53,8 +53,9 @@ static void ozone_draw_entry_value(ozone_handle_t *ozone, uint32_t alpha_uint32, menu_entry_t *entry) { - bool switch_is_on = true; - bool do_draw_text = false; + bool switch_is_on = true; + bool do_draw_text = false; + float scale_factor = ozone->capped_scale_factor; if (!entry->checked && string_is_empty(value)) return; @@ -63,7 +64,7 @@ static void ozone_draw_entry_value(ozone_handle_t *ozone, if (entry->checked) { menu_display_blend_begin(video_info); - ozone_draw_icon(video_info, 30, 30, ozone->theme->textures[OZONE_THEME_TEXTURE_CHECK], x - 20, y - 22, video_info->width, video_info->height, 0, 1, ozone->theme_dynamic.entries_checkmark); + ozone_draw_icon(video_info, 30 * scale_factor, 30 * scale_factor, ozone->theme->textures[OZONE_THEME_TEXTURE_CHECK], x - 20 * scale_factor, y - 22 * scale_factor, video_info->width, video_info->height, 0, 1, ozone->theme_dynamic.entries_checkmark); menu_display_blend_end(video_info); return; } @@ -145,7 +146,7 @@ void ozone_update_scroll(ozone_handle_t *ozone, bool allow_animation, ozone_node node->position_y + node->height / 2; - bottom_boundary = video_info_height - ozone->dimensions.header_height - 1 - ozone->dimensions.footer_height; + bottom_boundary = video_info_height - ozone->dimensions.header_height - ozone->dimensions.spacer_1px - ozone->dimensions.footer_height; entries_middle = video_info_height/2; new_scroll = ozone->animations.scroll_y - (current_selection_middle_onscreen - entries_middle); @@ -199,7 +200,7 @@ void ozone_compute_entries_position(ozone_handle_t *ozone) file_list_t *selection_buf = NULL; int entry_padding = ozone_get_entries_padding(ozone, false); - unsigned sublabel_line_height = font_driver_get_line_height(ozone->fonts.entries_sublabel, 1.0f); + float scale_factor = ozone->capped_scale_factor; menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i); @@ -254,7 +255,7 @@ void ozone_compute_entries_position(ozone_handle_t *ozone) char wrapped_sublabel_str[MENU_SUBLABEL_MAX_LENGTH]; wrapped_sublabel_str[0] = '\0'; - node->height += ozone->dimensions.entry_spacing + 40; + node->height += ozone->dimensions.entry_spacing + 40 * scale_factor; sublabel_max_width = video_info_width - entry_padding * 2 - ozone->dimensions.entry_icon_padding * 2; @@ -271,7 +272,7 @@ void ozone_compute_entries_position(ozone_handle_t *ozone) if (lines > 1) { - node->height += (lines - 1) * sublabel_line_height; + node->height += (lines - 1) * ozone->sublabel_font_glyph_height; node->wrap = true; } } @@ -363,6 +364,8 @@ void ozone_draw_entries(ozone_handle_t *ozone, video_frame_info_t *video_info, int16_t cursor_x = 0; int16_t cursor_y = 0; + float scale_factor = ozone->capped_scale_factor; + menu_input_get_pointer_state(&pointer); if (pointer.type != MENU_POINTER_DISABLED) @@ -385,7 +388,7 @@ void ozone_draw_entries(ozone_handle_t *ozone, video_frame_info_t *video_info, menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i); entries_end = file_list_get_size(selection_buf); - y = ozone->dimensions.header_height + 1 + ozone->dimensions.entry_padding_vertical; + y = ozone->dimensions.header_height + ozone->dimensions.spacer_1px + ozone->dimensions.entry_padding_vertical; sidebar_offset = ozone->sidebar_offset; entry_width = video_info->width - (unsigned) ozone->dimensions.sidebar_width - ozone->sidebar_offset - entry_padding * 2 - ozone->animations.thumbnail_bar_position; button_height = ozone->dimensions.entry_height; /* height of the button (entry minus sublabel) */ @@ -402,9 +405,9 @@ void ozone_draw_entries(ozone_handle_t *ozone, video_frame_info_t *video_info, if (alpha != 1.0f) { if (old_list) - x_offset += invert * -(alpha_anim * 120); /* left */ + x_offset += invert * -(alpha_anim * 120 * scale_factor); /* left */ else - x_offset += invert * (alpha_anim * 120); /* right */ + x_offset += invert * (alpha_anim * 120 * scale_factor); /* right */ } x_offset += (int) sidebar_offset; @@ -431,9 +434,9 @@ void ozone_draw_entries(ozone_handle_t *ozone, video_frame_info_t *video_info, if (!node || ozone->empty_playlist) goto border_iterate; - if (y + scroll_y + node->height + 20 < ozone->dimensions.header_height + ozone->dimensions.entry_padding_vertical) + if (y + scroll_y + node->height + 20 * scale_factor < ozone->dimensions.header_height + ozone->dimensions.entry_padding_vertical) goto border_iterate; - else if (y + scroll_y - node->height - 20 > bottom_boundary) + else if (y + scroll_y - node->height - 20 * scale_factor > bottom_boundary) goto border_iterate; border_start_x = (unsigned) ozone->dimensions.sidebar_width + x_offset + entry_padding; @@ -444,9 +447,9 @@ void ozone_draw_entries(ozone_handle_t *ozone, video_frame_info_t *video_info, /* Borders */ menu_display_draw_quad(video_info, border_start_x, - border_start_y, entry_width, 1, video_info->width, video_info->height, ozone->theme_dynamic.entries_border); + border_start_y, entry_width, ozone->dimensions.spacer_1px, video_info->width, video_info->height, ozone->theme_dynamic.entries_border); menu_display_draw_quad(video_info, border_start_x, - border_start_y + button_height, entry_width, 1, video_info->width, video_info->height, ozone->theme_dynamic.entries_border); + border_start_y + button_height, entry_width, ozone->dimensions.spacer_1px, video_info->width, video_info->height, ozone->theme_dynamic.entries_border); /* Cursor */ if (!old_list && ozone->cursor_mode) @@ -461,16 +464,16 @@ border_iterate: /* Cursor(s) layer - current */ if (!ozone->cursor_in_sidebar) - ozone_draw_cursor(ozone, video_info, (unsigned) ozone->dimensions.sidebar_width + x_offset + entry_padding + 3, - entry_width - 5, button_height + 2, selection_y + scroll_y + 1, ozone->animations.cursor_alpha * alpha); + ozone_draw_cursor(ozone, video_info, (unsigned) ozone->dimensions.sidebar_width + x_offset + entry_padding + ozone->dimensions.spacer_3px, + entry_width - ozone->dimensions.spacer_5px, button_height + ozone->dimensions.spacer_2px, selection_y + scroll_y + ozone->dimensions.spacer_1px, ozone->animations.cursor_alpha * alpha); /* Old*/ if (!ozone->cursor_in_sidebar_old) - ozone_draw_cursor(ozone, video_info, (unsigned) ozone->dimensions.sidebar_width + x_offset + entry_padding + 3, - entry_width - 5, button_height + 2, old_selection_y + scroll_y + 1, (1-ozone->animations.cursor_alpha) * alpha); + ozone_draw_cursor(ozone, video_info, (unsigned) ozone->dimensions.sidebar_width + x_offset + entry_padding + ozone->dimensions.spacer_3px, + entry_width - ozone->dimensions.spacer_5px, button_height + ozone->dimensions.spacer_2px, old_selection_y + scroll_y + ozone->dimensions.spacer_1px, (1-ozone->animations.cursor_alpha) * alpha); /* Icons + text */ - y = ozone->dimensions.header_height + 1 + ozone->dimensions.entry_padding_vertical; + y = ozone->dimensions.header_height + ozone->dimensions.spacer_1px + ozone->dimensions.entry_padding_vertical; if (old_list) y += ozone->old_list_offset_y; @@ -527,9 +530,9 @@ border_iterate: if (!node) continue; - if (y + scroll_y + node->height + 20 < ozone->dimensions.header_height + ozone->dimensions.entry_padding_vertical) + if (y + scroll_y + node->height + 20 * scale_factor < ozone->dimensions.header_height + ozone->dimensions.entry_padding_vertical) goto icons_iterate; - else if (y + scroll_y - node->height - 20 > bottom_boundary) + else if (y + scroll_y - node->height - 20 * scale_factor > bottom_boundary) goto icons_iterate; /* Prepare text */ @@ -538,7 +541,7 @@ border_iterate: if (use_smooth_ticker) { ticker_smooth.selected = entry_selected && !ozone->cursor_in_sidebar; - ticker_smooth.field_width = entry_width - entry_padding - 10 - ozone->dimensions.entry_icon_padding; + ticker_smooth.field_width = entry_width - entry_padding - (10 * scale_factor) - ozone->dimensions.entry_icon_padding; ticker_smooth.src_str = entry_rich_label; ticker_smooth.dst_str = rich_label; ticker_smooth.dst_str_len = sizeof(rich_label); @@ -550,7 +553,7 @@ border_iterate: ticker.s = rich_label; ticker.str = entry_rich_label; ticker.selected = entry_selected && !ozone->cursor_in_sidebar; - ticker.len = (entry_width - entry_padding - 10 - ozone->dimensions.entry_icon_padding) / ozone->entry_font_glyph_width; + ticker.len = (entry_width - entry_padding - (10 * scale_factor) - ozone->dimensions.entry_icon_padding) / ozone->entry_font_glyph_width; menu_animation_ticker(&ticker); } @@ -560,8 +563,8 @@ border_iterate: /* Note: This entry can never be selected, so ticker_x_offset * is irrelevant here (i.e. this text will never scroll) */ unsigned text_width = font_driver_get_message_width(ozone->fonts.entries_label, rich_label, (unsigned)strlen(rich_label), 1); - x_offset = (video_info_width - (unsigned) ozone->dimensions.sidebar_width - entry_padding * 2) / 2 - text_width / 2 - 60; - y = video_info_height / 2 - 60; + x_offset = (video_info_width - (unsigned) ozone->dimensions.sidebar_width - entry_padding * 2) / 2 - text_width / 2 - 60 * scale_factor; + y = video_info_height / 2 - 60 * scale_factor; } menu_entry_get_sublabel(&entry, &sublabel_str); @@ -628,10 +631,10 @@ border_iterate: /* Draw text */ ozone_draw_text(video_info, ozone, rich_label, ticker_x_offset + text_offset + (unsigned) ozone->dimensions.sidebar_width + x_offset + entry_padding + ozone->dimensions.entry_icon_size + ozone->dimensions.entry_icon_padding * 2, - y + ozone->dimensions.entry_height / 2 + FONT_SIZE_ENTRIES_LABEL * 3/8 + scroll_y, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.entries_label, COLOR_TEXT_ALPHA(ozone->theme->text_rgba, alpha_uint32), false); + y + ozone->dimensions.entry_height / 2 + ozone->entry_font_glyph_height * 3.0f/10.0f + scroll_y, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.entries_label, COLOR_TEXT_ALPHA(ozone->theme->text_rgba, alpha_uint32), false); if (!string_is_empty(sublabel_str)) ozone_draw_text(video_info, ozone, sublabel_str, (unsigned) ozone->dimensions.sidebar_width + x_offset + entry_padding + ozone->dimensions.entry_icon_padding, - y + ozone->dimensions.entry_height + 1 + 5 + FONT_SIZE_ENTRIES_SUBLABEL + scroll_y, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.entries_sublabel, COLOR_TEXT_ALPHA(ozone->theme->text_sublabel_rgba, alpha_uint32), false); + y + ozone->dimensions.entry_height + ozone->dimensions.spacer_1px + ozone->dimensions.spacer_5px + ozone->sublabel_font_glyph_height + scroll_y, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.entries_sublabel, COLOR_TEXT_ALPHA(ozone->theme->text_sublabel_rgba, alpha_uint32), false); /* Value */ if (use_smooth_ticker) @@ -661,7 +664,7 @@ border_iterate: ozone_draw_entry_value(ozone, video_info, entry_value_ticker, value_x_offset + (unsigned) ozone->dimensions.sidebar_width + entry_padding + x_offset + entry_width - ozone->dimensions.entry_icon_padding, - y + ozone->dimensions.entry_height / 2 + FONT_SIZE_ENTRIES_LABEL * 3/8 + scroll_y, alpha_uint32, &entry); + y + ozone->dimensions.entry_height / 2 + ozone->entry_font_glyph_height * 3.0f/10.0f + scroll_y, alpha_uint32, &entry); icons_iterate: y += node->height; @@ -680,7 +683,6 @@ static void ozone_draw_no_thumbnail_available(ozone_handle_t *ozone, { unsigned icon = OZONE_ENTRIES_ICONS_TEXTURE_CORE_INFO; unsigned icon_size = (unsigned)((float)ozone->dimensions.sidebar_entry_icon_size * 1.5f); - unsigned text_height = font_driver_get_line_height(ozone->fonts.footer, 1.0f); menu_display_blend_begin(video_info); ozone_draw_icon(video_info, @@ -698,7 +700,7 @@ static void ozone_draw_no_thumbnail_available(ozone_handle_t *ozone, ozone, msg_hash_to_str(MSG_NO_THUMBNAIL_AVAILABLE), x_position + sidebar_width/2, - video_info->height / 2 - icon_size/2 + text_height * 3 + FONT_SIZE_FOOTER - y_offset, + video_info->height / 2 - icon_size/2 + ozone->footer_font_glyph_height * 4 - y_offset, TEXT_ALIGN_CENTER, video_info->width, video_info->height, ozone->fonts.footer, @@ -710,12 +712,10 @@ static void ozone_draw_no_thumbnail_available(ozone_handle_t *ozone, static void ozone_content_metadata_line(video_frame_info_t *video_info, ozone_handle_t *ozone, unsigned *y, unsigned column_x, const char *text, unsigned lines_count) { - int line_height = font_driver_get_line_height(ozone->fonts.footer, 1); - ozone_draw_text(video_info, ozone, text, column_x, - *y + FONT_SIZE_FOOTER, + *y + ozone->footer_font_glyph_height, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.footer, @@ -724,16 +724,16 @@ static void ozone_content_metadata_line(video_frame_info_t *video_info, ozone_ha ); if (lines_count > 0) - *y += (unsigned)(line_height * (lines_count - 1)) + (unsigned)((float)line_height * 1.5f); + *y += (unsigned)(ozone->footer_font_glyph_height * (lines_count - 1)) + (unsigned)((float)ozone->footer_font_glyph_height * 1.5f); } void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, video_frame_info_t *video_info) { - unsigned sidebar_height = video_info->height - ozone->dimensions.header_height - 55 - ozone->dimensions.footer_height; + unsigned sidebar_height = video_info->height - ozone->dimensions.header_height - ozone->dimensions.sidebar_gradient_height * 2 - ozone->dimensions.footer_height; unsigned sidebar_width = ozone->dimensions.thumbnail_bar_width; unsigned x_position = video_info->width - (unsigned) ozone->animations.thumbnail_bar_position; unsigned thumbnail_width = sidebar_width - (ozone->dimensions.sidebar_entry_icon_padding * 2); - unsigned thumbnail_height = (video_info->height - ozone->dimensions.header_height - 2 - ozone->dimensions.footer_height - (ozone->dimensions.sidebar_entry_icon_padding * 3)) / 2; + unsigned thumbnail_height = (video_info->height - ozone->dimensions.header_height - ozone->dimensions.spacer_2px - ozone->dimensions.footer_height - (ozone->dimensions.sidebar_entry_icon_padding * 3)) / 2; int thumbnail_x_position = x_position + ozone->dimensions.sidebar_entry_icon_padding; int right_thumbnail_y_position = 0; int left_thumbnail_y_position = 0; @@ -744,9 +744,9 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, video_frame_info_t *video_i /* Background */ if (!video_info->libretro_running) { - menu_display_draw_quad(video_info, x_position, ozone->dimensions.header_height + 1, (unsigned) ozone->animations.thumbnail_bar_position, 55/2, video_info->width, video_info->height, ozone->theme->sidebar_top_gradient); - menu_display_draw_quad(video_info, x_position, ozone->dimensions.header_height + 1 + 55/2, (unsigned) ozone->animations.thumbnail_bar_position, sidebar_height, video_info->width, video_info->height, ozone->theme->sidebar_background); - menu_display_draw_quad(video_info, x_position, video_info->height - ozone->dimensions.footer_height - 55/2 - 1, (unsigned) ozone->animations.thumbnail_bar_position, 55/2 + 1, video_info->width, video_info->height, ozone->theme->sidebar_bottom_gradient); + menu_display_draw_quad(video_info, x_position, ozone->dimensions.header_height + ozone->dimensions.spacer_1px, (unsigned) ozone->animations.thumbnail_bar_position, ozone->dimensions.sidebar_gradient_height, video_info->width, video_info->height, ozone->theme->sidebar_top_gradient); + menu_display_draw_quad(video_info, x_position, ozone->dimensions.header_height + ozone->dimensions.spacer_1px + ozone->dimensions.sidebar_gradient_height, (unsigned) ozone->animations.thumbnail_bar_position, sidebar_height, video_info->width, video_info->height, ozone->theme->sidebar_background); + menu_display_draw_quad(video_info, x_position, video_info->height - ozone->dimensions.footer_height - ozone->dimensions.sidebar_gradient_height - ozone->dimensions.spacer_1px, (unsigned) ozone->animations.thumbnail_bar_position, ozone->dimensions.sidebar_gradient_height + ozone->dimensions.spacer_1px, video_info->width, video_info->height, ozone->theme->sidebar_bottom_gradient); } /* Thumbnails */ @@ -787,7 +787,7 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, video_frame_info_t *video_i } else right_thumbnail_y_position = - ozone->dimensions.header_height + 1 + + ozone->dimensions.header_height + ozone->dimensions.spacer_1px + ozone->dimensions.sidebar_entry_icon_padding; menu_thumbnail_draw( @@ -812,7 +812,7 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, video_frame_info_t *video_i /* Bottom row : "left" thumbnail or content metadata */ left_thumbnail_y_position = - ozone->dimensions.header_height + 1 + + ozone->dimensions.header_height + ozone->dimensions.spacer_1px + thumbnail_height + (ozone->dimensions.sidebar_entry_icon_padding * 2); @@ -877,7 +877,7 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, video_frame_info_t *video_i /* Separator */ menu_display_draw_quad(video_info, x_position + separator_padding, y, - sidebar_width - separator_padding*2, 1, + sidebar_width - separator_padding*2, ozone->dimensions.spacer_1px, video_info->width, video_info->height, ozone->theme_dynamic.entries_border); diff --git a/menu/drivers/ozone/ozone_sidebar.c b/menu/drivers/ozone/ozone_sidebar.c index bfb7170223..bdb4205490 100644 --- a/menu/drivers/ozone/ozone_sidebar.c +++ b/menu/drivers/ozone/ozone_sidebar.c @@ -116,6 +116,7 @@ void ozone_draw_sidebar(ozone_handle_t *ozone, video_frame_info_t *video_info) settings_t *settings = config_get_ptr(); uint32_t text_alpha = ozone->animations.sidebar_text_alpha * 255.0f; bool use_smooth_ticker = settings->bools.menu_ticker_smooth; + float scale_factor = ozone->capped_scale_factor; /* Initial ticker configuration */ if (use_smooth_ticker) @@ -148,32 +149,32 @@ void ozone_draw_sidebar(ozone_handle_t *ozone, video_frame_info_t *video_info) menu_display_scissor_begin(video_info, 0, ozone->dimensions.header_height, (unsigned) ozone->dimensions.sidebar_width, video_info->height - ozone->dimensions.header_height - ozone->dimensions.footer_height); /* Background */ - sidebar_height = video_info->height - ozone->dimensions.header_height - 55 - ozone->dimensions.footer_height; + sidebar_height = video_info->height - ozone->dimensions.header_height - ozone->dimensions.sidebar_gradient_height * 2 - ozone->dimensions.footer_height; if (!video_info->libretro_running) { - menu_display_draw_quad(video_info, ozone->sidebar_offset, ozone->dimensions.header_height + 1, (unsigned) ozone->dimensions.sidebar_width, 55/2, video_info->width, video_info->height, ozone->theme->sidebar_top_gradient); - menu_display_draw_quad(video_info, ozone->sidebar_offset, ozone->dimensions.header_height + 1 + 55/2, (unsigned) ozone->dimensions.sidebar_width, sidebar_height, video_info->width, video_info->height, ozone->theme->sidebar_background); - menu_display_draw_quad(video_info, ozone->sidebar_offset, video_info->height - ozone->dimensions.footer_height - 55/2 - 1, (unsigned) ozone->dimensions.sidebar_width, 55/2 + 1, video_info->width, video_info->height, ozone->theme->sidebar_bottom_gradient); + menu_display_draw_quad(video_info, ozone->sidebar_offset, ozone->dimensions.header_height + ozone->dimensions.spacer_1px, (unsigned) ozone->dimensions.sidebar_width, ozone->dimensions.sidebar_gradient_height, video_info->width, video_info->height, ozone->theme->sidebar_top_gradient); + menu_display_draw_quad(video_info, ozone->sidebar_offset, ozone->dimensions.header_height + ozone->dimensions.spacer_1px + ozone->dimensions.sidebar_gradient_height, (unsigned) ozone->dimensions.sidebar_width, sidebar_height, video_info->width, video_info->height, ozone->theme->sidebar_background); + menu_display_draw_quad(video_info, ozone->sidebar_offset, video_info->height - ozone->dimensions.footer_height - ozone->dimensions.sidebar_gradient_height - ozone->dimensions.spacer_1px, (unsigned) ozone->dimensions.sidebar_width, ozone->dimensions.sidebar_gradient_height + ozone->dimensions.spacer_1px, video_info->width, video_info->height, ozone->theme->sidebar_bottom_gradient); } /* Tabs */ /* y offset computation */ - y = ozone->dimensions.header_height + 1 + ozone->dimensions.sidebar_padding_vertical; + y = ozone->dimensions.header_height + ozone->dimensions.spacer_1px + ozone->dimensions.sidebar_padding_vertical; for (i = 0; i < ozone->system_tab_end + horizontal_list_size + 1; i++) { if (i == ozone->categories_selection_ptr) { selection_y = (unsigned)y; if (ozone->categories_selection_ptr > ozone->system_tab_end) - selection_y += ozone->dimensions.sidebar_entry_padding_vertical + 1; + selection_y += ozone->dimensions.sidebar_entry_padding_vertical + ozone->dimensions.spacer_1px; } if (i == ozone->categories_active_idx_old) { selection_old_y = (unsigned)y; if (ozone->categories_active_idx_old > ozone->system_tab_end) - selection_old_y += ozone->dimensions.sidebar_entry_padding_vertical + 1; + selection_old_y += ozone->dimensions.sidebar_entry_padding_vertical + ozone->dimensions.spacer_1px; } y += ozone->dimensions.sidebar_entry_height + ozone->dimensions.sidebar_entry_padding_vertical; @@ -183,15 +184,15 @@ void ozone_draw_sidebar(ozone_handle_t *ozone, video_frame_info_t *video_info) /* Cursor */ if (ozone->cursor_in_sidebar) - ozone_draw_cursor(ozone, video_info, ozone->sidebar_offset + ozone->dimensions.sidebar_padding_horizontal + 3, - entry_width - 5, ozone->dimensions.sidebar_entry_height + 2, selection_y + 1 + ozone->animations.scroll_y_sidebar, ozone->animations.cursor_alpha); + ozone_draw_cursor(ozone, video_info, ozone->sidebar_offset + ozone->dimensions.sidebar_padding_horizontal + ozone->dimensions.spacer_3px, + entry_width - ozone->dimensions.spacer_5px, ozone->dimensions.sidebar_entry_height + ozone->dimensions.spacer_2px, selection_y + ozone->dimensions.spacer_2px + ozone->animations.scroll_y_sidebar, ozone->animations.cursor_alpha); if (ozone->cursor_in_sidebar_old) - ozone_draw_cursor(ozone, video_info, ozone->sidebar_offset + ozone->dimensions.sidebar_padding_horizontal + 3, - entry_width - 5, ozone->dimensions.sidebar_entry_height + 2, selection_old_y + 1 + ozone->animations.scroll_y_sidebar, 1-ozone->animations.cursor_alpha); + ozone_draw_cursor(ozone, video_info, ozone->sidebar_offset + ozone->dimensions.sidebar_padding_horizontal + ozone->dimensions.spacer_3px, + entry_width - ozone->dimensions.spacer_5px, ozone->dimensions.sidebar_entry_height + ozone->dimensions.spacer_2px, selection_old_y + ozone->dimensions.spacer_2px + ozone->animations.scroll_y_sidebar, 1-ozone->animations.cursor_alpha); /* Menu tabs */ - y = ozone->dimensions.header_height + 1 + ozone->dimensions.sidebar_padding_vertical; + y = ozone->dimensions.header_height + ozone->dimensions.spacer_1px + ozone->dimensions.sidebar_padding_vertical; menu_display_blend_begin(video_info); for (i = 0; i < (unsigned)(ozone->system_tab_end+1); i++) @@ -214,7 +215,7 @@ void ozone_draw_sidebar(ozone_handle_t *ozone, video_frame_info_t *video_info) /* Text */ if (!ozone->sidebar_collapsed) ozone_draw_text(video_info, ozone, title, ozone->sidebar_offset + ozone->dimensions.sidebar_padding_horizontal + ozone->dimensions.sidebar_entry_icon_padding * 2 + ozone->dimensions.sidebar_entry_icon_size, - y + ozone->dimensions.sidebar_entry_height / 2 + FONT_SIZE_SIDEBAR * 3/8 + ozone->animations.scroll_y_sidebar, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.sidebar, text_color, true); + y + ozone->dimensions.sidebar_entry_height / 2 + ozone->sidebar_font_glyph_height * 3.0f/10.0f + ozone->animations.scroll_y_sidebar, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.sidebar, text_color, true); y += ozone->dimensions.sidebar_entry_height + ozone->dimensions.sidebar_entry_padding_vertical; } @@ -224,9 +225,9 @@ void ozone_draw_sidebar(ozone_handle_t *ozone, video_frame_info_t *video_info) /* Console tabs */ if (horizontal_list_size > 0) { - menu_display_draw_quad(video_info, ozone->sidebar_offset + ozone->dimensions.sidebar_padding_horizontal, y + ozone->animations.scroll_y_sidebar, entry_width, 1, video_info->width, video_info->height, ozone->theme->entries_border); + menu_display_draw_quad(video_info, ozone->sidebar_offset + ozone->dimensions.sidebar_padding_horizontal, y + ozone->animations.scroll_y_sidebar, entry_width, ozone->dimensions.spacer_1px, video_info->width, video_info->height, ozone->theme->entries_border); - y += ozone->dimensions.sidebar_entry_padding_vertical + 1; + y += ozone->dimensions.sidebar_entry_padding_vertical + ozone->dimensions.spacer_1px; menu_display_blend_begin(video_info); @@ -253,7 +254,7 @@ void ozone_draw_sidebar(ozone_handle_t *ozone, video_frame_info_t *video_info) if (use_smooth_ticker) { ticker_smooth.selected = selected; - ticker_smooth.field_width = (entry_width - ozone->dimensions.sidebar_entry_icon_size - 40); + ticker_smooth.field_width = (entry_width - ozone->dimensions.sidebar_entry_icon_size - 40 * scale_factor); ticker_smooth.src_str = node->console_name; ticker_smooth.dst_str = console_title; ticker_smooth.dst_str_len = sizeof(console_title); @@ -262,7 +263,7 @@ void ozone_draw_sidebar(ozone_handle_t *ozone, video_frame_info_t *video_info) } else { - ticker.len = (entry_width - ozone->dimensions.sidebar_entry_icon_size - 40) / ozone->sidebar_font_glyph_width; + ticker.len = (entry_width - ozone->dimensions.sidebar_entry_icon_size - 40 * scale_factor) / ozone->sidebar_font_glyph_width; ticker.s = console_title; ticker.selected = selected; ticker.str = node->console_name; @@ -271,7 +272,7 @@ void ozone_draw_sidebar(ozone_handle_t *ozone, video_frame_info_t *video_info) } ozone_draw_text(video_info, ozone, console_title, ticker_x_offset + ozone->sidebar_offset + ozone->dimensions.sidebar_padding_horizontal + ozone->dimensions.sidebar_entry_icon_padding * 2 + ozone->dimensions.sidebar_entry_icon_size, - y + ozone->dimensions.sidebar_entry_height / 2 + FONT_SIZE_SIDEBAR * 3/8 + ozone->animations.scroll_y_sidebar, TEXT_ALIGN_LEFT, + y + ozone->dimensions.sidebar_entry_height / 2 + ozone->sidebar_font_glyph_height * 3.0f/10.0f + ozone->animations.scroll_y_sidebar, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.sidebar, text_color, true); console_iterate: @@ -344,14 +345,14 @@ unsigned ozone_get_selected_sidebar_y_position(ozone_handle_t *ozone) { return ozone->categories_selection_ptr * ozone->dimensions.sidebar_entry_height + (ozone->categories_selection_ptr - 1) * ozone->dimensions.sidebar_entry_padding_vertical + ozone->dimensions.sidebar_padding_vertical + - (ozone->categories_selection_ptr > ozone->system_tab_end ? ozone->dimensions.sidebar_entry_padding_vertical + 1 : 0); + (ozone->categories_selection_ptr > ozone->system_tab_end ? ozone->dimensions.sidebar_entry_padding_vertical + ozone->dimensions.spacer_1px : 0); } unsigned ozone_get_sidebar_height(ozone_handle_t *ozone) { int entries = (int)(ozone->system_tab_end + 1 + (ozone->horizontal_list ? ozone->horizontal_list->size : 0)); return entries * ozone->dimensions.sidebar_entry_height + (entries - 1) * ozone->dimensions.sidebar_entry_padding_vertical + ozone->dimensions.sidebar_padding_vertical + - (ozone->horizontal_list && ozone->horizontal_list->size > 0 ? ozone->dimensions.sidebar_entry_padding_vertical + 1 : 0); + (ozone->horizontal_list && ozone->horizontal_list->size > 0 ? ozone->dimensions.sidebar_entry_padding_vertical + ozone->dimensions.spacer_1px : 0); } static void ozone_sidebar_collapse_end(void *userdata) @@ -435,6 +436,33 @@ void ozone_sidebar_update_collapse(ozone_handle_t *ozone, bool allow_animation) ozone_entries_update_thumbnail_bar(ozone, is_playlist, allow_animation); } +static float ozone_sidebar_get_scroll_y(ozone_handle_t *ozone, unsigned video_height) +{ + float scroll_y = ozone->animations.scroll_y_sidebar; + float selected_position_y; + float current_selection_middle_onscreen; + float bottom_boundary; + float entries_middle; + float entries_height; + + selected_position_y = ozone_get_selected_sidebar_y_position(ozone); + current_selection_middle_onscreen = ozone->dimensions.header_height + ozone->dimensions.spacer_1px + ozone->animations.scroll_y_sidebar + selected_position_y + ozone->dimensions.sidebar_entry_height / 2.0f; + bottom_boundary = (float)video_height - (ozone->dimensions.header_height + ozone->dimensions.spacer_1px) - ozone->dimensions.footer_height; + entries_middle = (float)video_height / 2.0f; + entries_height = ozone_get_sidebar_height(ozone); + + if (current_selection_middle_onscreen != entries_middle) + scroll_y = ozone->animations.scroll_y_sidebar - (current_selection_middle_onscreen - entries_middle); + + if (scroll_y + entries_height < bottom_boundary) + scroll_y = bottom_boundary - entries_height - ozone->dimensions.sidebar_padding_vertical; + + if (scroll_y > 0.0f) + scroll_y = 0.0f; + + return scroll_y; +} + void ozone_sidebar_goto(ozone_handle_t *ozone, unsigned new_selection) { unsigned video_info_height; @@ -443,13 +471,6 @@ void ozone_sidebar_goto(ozone_handle_t *ozone, unsigned new_selection) menu_animation_ctx_tag tag; - float new_scroll; - float selected_position_y; - float current_selection_middle_onscreen; - float bottom_boundary; - float entries_middle; - float entries_height; - video_driver_get_size(NULL, &video_info_height); tag = (uintptr_t)ozone; @@ -478,29 +499,13 @@ void ozone_sidebar_goto(ozone_handle_t *ozone, unsigned new_selection) menu_animation_push(&entry); /* Scroll animation */ - new_scroll = 0; - selected_position_y = ozone_get_selected_sidebar_y_position(ozone); - current_selection_middle_onscreen = ozone->dimensions.header_height + 1 + ozone->animations.scroll_y_sidebar + selected_position_y + ozone->dimensions.sidebar_entry_height / 2; - bottom_boundary = video_info_height - (ozone->dimensions.header_height + 1) - ozone->dimensions.footer_height; - entries_middle = video_info_height/2; - entries_height = ozone_get_sidebar_height(ozone); - - if (current_selection_middle_onscreen != entries_middle) - new_scroll = ozone->animations.scroll_y_sidebar - (current_selection_middle_onscreen - entries_middle); - - if (new_scroll + entries_height < bottom_boundary) - new_scroll = bottom_boundary - entries_height - ozone->dimensions.sidebar_padding_vertical; - - if (new_scroll > 0) - new_scroll = 0; - - entry.cb = NULL; - entry.duration = ANIMATION_CURSOR_DURATION; - entry.easing_enum = EASING_OUT_QUAD; - entry.subject = &ozone->animations.scroll_y_sidebar; - entry.tag = tag; - entry.target_value = new_scroll; - entry.userdata = NULL; + entry.cb = NULL; + entry.duration = ANIMATION_CURSOR_DURATION; + entry.easing_enum = EASING_OUT_QUAD; + entry.subject = &ozone->animations.scroll_y_sidebar; + entry.tag = tag; + entry.target_value = ozone_sidebar_get_scroll_y(ozone, video_info_height); + entry.userdata = NULL; menu_animation_push(&entry); @@ -514,6 +519,68 @@ void ozone_sidebar_goto(ozone_handle_t *ozone, unsigned new_selection) } } +void ozone_refresh_sidebars(ozone_handle_t *ozone, unsigned video_height) +{ + settings_t *settings = config_get_ptr(); + menu_animation_ctx_tag collapsed_tag = (uintptr_t)&ozone->sidebar_collapsed; + menu_animation_ctx_tag offset_tag = (uintptr_t)&ozone->sidebar_offset; + menu_animation_ctx_tag thumbnail_tag = (uintptr_t)&ozone->show_thumbnail_bar; + menu_animation_ctx_tag scroll_tag = (uintptr_t)ozone; + bool is_playlist = ozone_is_playlist(ozone, false); + + /* Kill any existing animations */ + menu_animation_kill_by_tag(&collapsed_tag); + menu_animation_kill_by_tag(&offset_tag); + menu_animation_kill_by_tag(&thumbnail_tag); + if (ozone->depth == 1) + menu_animation_kill_by_tag(&scroll_tag); + + /* Set sidebar width */ + if (settings->bools.ozone_collapse_sidebar || (is_playlist && !ozone->cursor_in_sidebar)) + { + ozone->animations.sidebar_text_alpha = 0.0f; + ozone->dimensions.sidebar_width = ozone->dimensions.sidebar_width_collapsed; + ozone->sidebar_collapsed = true; + } + else if (ozone->cursor_in_sidebar || (!is_playlist && !settings->bools.ozone_collapse_sidebar)) + { + ozone->animations.sidebar_text_alpha = 1.0f; + ozone->dimensions.sidebar_width = ozone->dimensions.sidebar_width_normal; + ozone->sidebar_collapsed = false; + } + + /* Set sidebar offset */ + if (ozone->depth == 1) + { + ozone->sidebar_offset = 0.0f; + ozone->draw_sidebar = true; + } + else if (ozone->depth > 1) + { + ozone->sidebar_offset = -ozone->dimensions.sidebar_width; + ozone->draw_sidebar = false; + } + + /* Set thumbnail bar position */ + if (is_playlist && !ozone->cursor_in_sidebar && ozone->depth == 1) + { + ozone->animations.thumbnail_bar_position = ozone->dimensions.thumbnail_bar_width; + ozone->show_thumbnail_bar = true; + } + else + { + ozone->animations.thumbnail_bar_position = 0.0f; + ozone->show_thumbnail_bar = false; + } + + /* If sidebar is on-screen, update scroll position */ + if (ozone->depth == 1) + { + ozone->animations.cursor_alpha = 1.0f; + ozone->animations.scroll_y_sidebar = ozone_sidebar_get_scroll_y(ozone, video_height); + } +} + void ozone_change_tab(ozone_handle_t *ozone, enum msg_hash_enums tab, enum menu_settings_type type) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 8129566c7c..359beba8cf 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -12844,9 +12844,10 @@ static bool setting_append_list( START_SUB_GROUP(list, list_info, "Display", &group_info, &subgroup_info, parent_group); - /* Only implemented for GLUI and XMB at present */ + /* Only implemented for GLUI, XMB and Ozone at present */ if (string_is_equal(settings->arrays.menu_driver, "glui") || - string_is_equal(settings->arrays.menu_driver, "xmb")) + string_is_equal(settings->arrays.menu_driver, "xmb") || + string_is_equal(settings->arrays.menu_driver, "ozone")) CONFIG_FLOAT( list, list_info, &settings->floats.menu_scale_factor, From 83a03b6679222f4ab4093d72e0c18b69841ffe69 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 12 Feb 2020 14:16:09 +0100 Subject: [PATCH 16/75] Silence this warning --- menu/menu_driver.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 505573c10a..cfa5f9d14e 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -204,11 +204,12 @@ static bool menu_display_null_font_init_first( bool is_threaded) { font_data_t **handle = (font_data_t**)font_handle; - *handle = font_driver_init_first(video_data, + if ((*handle = font_driver_init_first(video_data, font_path, font_size, true, is_threaded, - FONT_DRIVER_RENDER_DONT_CARE); - return *handle; + FONT_DRIVER_RENDER_DONT_CARE))) + return true; + return false; } static const float *menu_display_null_get_default_vertices(void) From b1773cc73bde0948346ba5d63c0a34f3421e464b Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Wed, 12 Feb 2020 14:25:49 +0000 Subject: [PATCH 17/75] (Switch) Report correct (approximate) DPI in 'docked' mode --- gfx/drivers_context/switch_ctx.c | 37 +++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/gfx/drivers_context/switch_ctx.c b/gfx/drivers_context/switch_ctx.c index 29bb3f3340..34bf345e39 100644 --- a/gfx/drivers_context/switch_ctx.c +++ b/gfx/drivers_context/switch_ctx.c @@ -303,7 +303,42 @@ bool switch_ctx_get_metrics(void *data, switch (type) { case DISPLAY_METRIC_DPI: - *value = 236.87; /* FIXME: Don't hardcode this value */ + /* FIXME: DPI values should be obtained by querying + * the hardware - these hard-coded values are a kludge */ + switch (appletGetOperationMode()) + { + case AppletOperationMode_Docked: + /* Docked mode + * > Resolution: 1920x1080 + * > Screen Size: 39 inch + * - Have to make an assumption here. We select + * a 'default' screen size of 39 inches which + * corresponds to the optimal diagonal screen + * size for HD television as reported in: + * "HDTV displays: subjective effects of scanning + * standards and domestic picture sizes," + * N. E. Tanton and M. A. Stone, + * BBC Research Department Report 1989/09, + * January 1989 + * This agrees with the median recorded TV + * size in: + * "A Survey of UK Television Viewing Conditions," + * Katy C. Noland and Louise H. Truong, + * BBC R&D White Paper WHP 287 January 2015 + * > DPI: sqrt((1920 * 1920) + (1080 * 1080)) / 39 + */ + *value = 56.48480f; + break; + case AppletOperationMode_Handheld: + default: + /* Handheld mode + * > Resolution: 1280x720 + * > Screen size: 6.2 inch + * > DPI: sqrt((1280 * 1280) + (720 * 720)) / 6.2 + */ + *value = 236.8717f; + break; + } return true; default: break; From d918c1791a21387d9aa93bdd11b6ad59f3005517 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 12 Feb 2020 16:09:30 +0100 Subject: [PATCH 18/75] Get rid of some configuration.h dependencies --- gfx/drivers_font_renderer/freetype.c | 14 -------------- gfx/drivers_renderchain/d3d9_cg_renderchain.c | 1 - gfx/drivers_renderchain/d3d9_hlsl_renderchain.c | 1 - 3 files changed, 16 deletions(-) diff --git a/gfx/drivers_font_renderer/freetype.c b/gfx/drivers_font_renderer/freetype.c index 99507dc5f8..f3158bb00d 100644 --- a/gfx/drivers_font_renderer/freetype.c +++ b/gfx/drivers_font_renderer/freetype.c @@ -304,23 +304,9 @@ static const char *font_renderer_ft_get_default_font(void) return ""; #else size_t i; -#if 0 - char asset_path[PATH_MAX_LENGTH]; -#endif for (i = 0; i < ARRAY_SIZE(font_paths); i++) { -#if 0 - /* Check if we are getting the font from the assets directory. */ - if (string_is_equal(font_paths[i], "assets://pkg/osd-font.ttf")) - { - settings_t *settings = config_get_ptr(); - fill_pathname_join(asset_path, - settings->paths.directory_assets, "pkg/osd-font.ttf", PATH_MAX_LENGTH); - font_paths[i] = asset_path; - } -#endif - if (path_is_valid(font_paths[i])) return font_paths[i]; } diff --git a/gfx/drivers_renderchain/d3d9_cg_renderchain.c b/gfx/drivers_renderchain/d3d9_cg_renderchain.c index 018b0ff910..e2f4cba174 100644 --- a/gfx/drivers_renderchain/d3d9_cg_renderchain.c +++ b/gfx/drivers_renderchain/d3d9_cg_renderchain.c @@ -34,7 +34,6 @@ #include "../common/d3d_common.h" #include "../drivers/d3d_shaders/opaque.cg.d3d9.h" -#include "../../configuration.h" #include "../../retroarch.h" #include "../../verbosity.h" diff --git a/gfx/drivers_renderchain/d3d9_hlsl_renderchain.c b/gfx/drivers_renderchain/d3d9_hlsl_renderchain.c index 535e556bb8..e449da4dbe 100644 --- a/gfx/drivers_renderchain/d3d9_hlsl_renderchain.c +++ b/gfx/drivers_renderchain/d3d9_hlsl_renderchain.c @@ -34,7 +34,6 @@ #include "../video_shader_parse.h" #include "../../managers/state_manager.h" -#include "../../configuration.h" #include "../../retroarch.h" #include "../../verbosity.h" From 1105d1019d6b27314b81f02719ad369e0116c012 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 12 Feb 2020 16:13:28 +0100 Subject: [PATCH 19/75] Reduce some configuration dependencies --- gfx/video_shader_parse.c | 3 ++- gfx/video_shader_parse.h | 1 + menu/menu_shader.c | 10 +++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 63bd620d61..ede222fcaf 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -583,6 +583,7 @@ bool video_shader_resolve_parameters(config_file_t *conf, * See: video_shader_read_preset **/ bool video_shader_write_preset(const char *path, + const char *shader_dir, const struct video_shader *shader, bool reference) { /* We need to clean up paths to be able to properly process them @@ -596,7 +597,7 @@ bool video_shader_write_preset(const char *path, fill_pathname_join( preset_dir, - config_get_ptr()->paths.directory_video_shader, + shader_dir, "presets", sizeof(preset_dir)); diff --git a/gfx/video_shader_parse.h b/gfx/video_shader_parse.h index a7a492df79..bb49f07f1c 100644 --- a/gfx/video_shader_parse.h +++ b/gfx/video_shader_parse.h @@ -170,6 +170,7 @@ struct video_shader * See: video_shader_read_preset **/ bool video_shader_write_preset(const char *path, + const char *shader_dir, const struct video_shader *shader, bool reference); /** diff --git a/menu/menu_shader.c b/menu/menu_shader.c index eab010355b..fba6985707 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -229,6 +229,7 @@ static bool menu_shader_manager_save_preset_internal( { bool ret = false; enum rarch_shader_type type = RARCH_SHADER_NONE; + settings_t *settings = config_get_ptr(); char *preset_path = NULL; size_t i = 0; char fullname[PATH_MAX_LENGTH]; @@ -271,7 +272,9 @@ static bool menu_shader_manager_save_preset_internal( { preset_path = fullname; - ret = video_shader_write_preset(preset_path, shader, save_reference); + ret = video_shader_write_preset(preset_path, + settings->paths.directory_video_shader, + shader, save_reference); if (ret) RARCH_LOG("Saved shader preset to %s.\n", preset_path); @@ -281,7 +284,6 @@ static bool menu_shader_manager_save_preset_internal( else { const char *dirs[3] = {0}; - settings_t *settings = config_get_ptr(); char config_directory[PATH_MAX_LENGTH]; config_directory[0] = '\0'; @@ -306,7 +308,9 @@ static bool menu_shader_manager_save_preset_internal( preset_path = buffer; - ret = video_shader_write_preset(preset_path, shader, save_reference); + ret = video_shader_write_preset(preset_path, + settings->paths.directory_video_shader, + shader, save_reference); if (ret) { From dd01ae8ebcd7ce4803dbf7e3d3c36a4f9ccbbde5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 12 Feb 2020 16:31:15 +0100 Subject: [PATCH 20/75] menu_animation.c - no more dependency on configuration.h --- menu/menu_animation.c | 40 ++++++++++++++++++++++++++-------------- menu/menu_animation.h | 7 ++++++- retroarch.c | 6 +++++- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/menu/menu_animation.c b/menu/menu_animation.c index 1c7834a01d..c9f81dd26d 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -34,7 +34,6 @@ #include "menu_animation.h" #include "menu_driver.h" -#include "../configuration.h" #include "../performance_counters.h" struct tween @@ -1186,7 +1185,11 @@ bool menu_animation_push(menu_animation_ctx_entry_t *entry) return true; } -static void menu_animation_update_time(bool timedate_enable, unsigned video_width, unsigned video_height) +static void menu_animation_update_time( + const char *menu_driver, + bool timedate_enable, + unsigned video_width, unsigned video_height, + float menu_ticker_speed) { static retro_time_t last_clock_update = 0; @@ -1198,12 +1201,13 @@ static void menu_animation_update_time(bool timedate_enable, unsigned video_widt static float ticker_pixel_accumulator = 0.0f; unsigned ticker_pixel_accumulator_uint = 0; float ticker_pixel_increment = 0.0f; - /* Adjust ticker speed */ - settings_t *settings = config_get_ptr(); - float speed_factor = settings->floats.menu_ticker_speed > 0.0001f ? settings->floats.menu_ticker_speed : 1.0f; - unsigned ticker_speed = (unsigned)(((float)TICKER_SPEED / speed_factor) + 0.5); - unsigned ticker_slow_speed = (unsigned)(((float)TICKER_SLOW_SPEED / speed_factor) + 0.5); + float speed_factor = (menu_ticker_speed > 0.0001f) + ? menu_ticker_speed : 1.0f; + unsigned ticker_speed = + (unsigned)(((float)TICKER_SPEED / speed_factor) + 0.5); + unsigned ticker_slow_speed = + (unsigned)(((float)TICKER_SLOW_SPEED / speed_factor) + 0.5); /* Note: cur_time & old_time are in us, delta_time is in ms */ cur_time = cpu_features_get_time_usec(); @@ -1262,13 +1266,13 @@ static void menu_animation_update_time(bool timedate_enable, unsigned video_widt * multiplied by a small correction factor (since the * default 1.0x speed is just a little faster than the * non-smooth ticker) */ - if (string_is_equal(settings->arrays.menu_driver, "rgui")) + if (string_is_equal(menu_driver, "rgui")) ticker_pixel_increment *= 0.25f; /* TODO/FIXME: Remove this Ozone special case if/when * Ozone gets proper DPI scaling */ - else if (string_is_equal(settings->arrays.menu_driver, "ozone")) + else if (string_is_equal(menu_driver, "ozone")) ticker_pixel_increment *= 0.5f; - else if (string_is_equal(settings->arrays.menu_driver, "glui")) + else if (string_is_equal(menu_driver, "glui")) ticker_pixel_increment *= (menu_display_get_dpi_scale(video_width, video_height) * 0.8f); else if (video_width > 0) ticker_pixel_increment *= ((float)video_width / 1920.0f); @@ -1286,12 +1290,20 @@ static void menu_animation_update_time(bool timedate_enable, unsigned video_widt } } -bool menu_animation_update(unsigned video_width, unsigned video_height) +bool menu_animation_update( + const char *menu_driver, + bool menu_timedate_enable, + float menu_ticker_speed, + unsigned video_width, + unsigned video_height) { unsigned i; - settings_t *settings = config_get_ptr(); - menu_animation_update_time(settings->bools.menu_timedate_enable, video_width, video_height); + menu_animation_update_time( + menu_driver, + menu_timedate_enable, + video_width, video_height, + menu_ticker_speed); anim.in_update = true; anim.pending_deletes = false; @@ -1305,7 +1317,7 @@ bool menu_animation_update(unsigned video_width, unsigned video_height) tween->running_since += delta_time; - *tween->subject = tween->easing( + *tween->subject = tween->easing( tween->running_since, tween->initial_value, tween->target_value - tween->initial_value, diff --git a/menu/menu_animation.h b/menu/menu_animation.h index da32191a43..14a1015d84 100644 --- a/menu/menu_animation.h +++ b/menu/menu_animation.h @@ -198,7 +198,12 @@ void menu_timer_start(menu_timer_t *timer, menu_timer_ctx_entry_t *timer_entry); void menu_timer_kill(menu_timer_t *timer); -bool menu_animation_update(unsigned video_width, unsigned video_height); +bool menu_animation_update( + const char *menu_driver, + bool menu_timedate_enable, + float menu_ticker_speed, + unsigned video_width, + unsigned video_height); bool menu_animation_ticker(menu_animation_ctx_ticker_t *ticker); diff --git a/retroarch.c b/retroarch.c index a2a2fd872a..0ee85febd2 100644 --- a/retroarch.c +++ b/retroarch.c @@ -27117,7 +27117,11 @@ static enum runloop_state runloop_check_state(void) } #if defined(HAVE_MENU) - menu_animation_update(video_driver_width, video_driver_height); + menu_animation_update( + settings->arrays.menu_driver, + settings->bools.menu_timedate_enable, + settings->floats.menu_ticker_speed, + video_driver_width, video_driver_height); #ifdef HAVE_MENU_WIDGETS if (menu_widgets_inited) From bb0840956f83ee38b080c69f82b5af2bb56dba43 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 12 Feb 2020 16:45:50 +0100 Subject: [PATCH 21/75] (menu_osk) Cleanup - take out configuration.h dependencies --- menu/widgets/menu_osk.c | 27 +++++++++------------------ menu/widgets/menu_osk.h | 2 +- retroarch.c | 30 ++++++++++++++++++++++-------- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/menu/widgets/menu_osk.c b/menu/widgets/menu_osk.c index 3a32e0955f..de61d2247a 100644 --- a/menu/widgets/menu_osk.c +++ b/menu/widgets/menu_osk.c @@ -31,7 +31,6 @@ #include "menu_osk.h" #include "../../input/input_driver.h" -#include "../../configuration.h" static char *osk_grid[45] = {NULL}; @@ -82,16 +81,8 @@ void menu_event_set_osk_ptr(int i) osk_ptr = i; } -void menu_event_osk_append(int ptr) +void menu_event_osk_append(int ptr, bool is_rgui) { - settings_t *settings = config_get_ptr(); - bool is_rgui; - - if (ptr < 0 || !settings) - return; - - is_rgui = string_is_equal(settings->arrays.menu_driver, "rgui"); - #ifdef HAVE_LANGEXTRA if (string_is_equal(osk_grid[ptr],"\xe2\x87\xa6")) /* backspace character */ input_keyboard_event(true, '\x7f', '\x7f', 0, RETRO_DEVICE_KEYBOARD); @@ -99,9 +90,9 @@ void menu_event_osk_append(int ptr) input_keyboard_event(true, '\n', '\n', 0, RETRO_DEVICE_KEYBOARD); else if (string_is_equal(osk_grid[ptr],"\xe2\x87\xa7")) /* up arrow */ - menu_event_set_osk_idx(OSK_UPPERCASE_LATIN); + osk_idx = OSK_UPPERCASE_LATIN; else if (string_is_equal(osk_grid[ptr],"\xe2\x87\xa9")) /* down arrow */ - menu_event_set_osk_idx(OSK_LOWERCASE_LATIN); + osk_idx = OSK_LOWERCASE_LATIN; else if (string_is_equal(osk_grid[ptr],"\xe2\x8a\x95")) /* plus sign (next button) */ #else if (string_is_equal(osk_grid[ptr], "Bksp")) @@ -110,22 +101,22 @@ void menu_event_osk_append(int ptr) input_keyboard_event(true, '\n', '\n', 0, RETRO_DEVICE_KEYBOARD); else if (string_is_equal(osk_grid[ptr], "Upper")) - menu_event_set_osk_idx(OSK_UPPERCASE_LATIN); + osk_idx = OSK_UPPERCASE_LATIN; else if (string_is_equal(osk_grid[ptr], "Lower")) - menu_event_set_osk_idx(OSK_LOWERCASE_LATIN); + osk_idx = OSK_LOWERCASE_LATIN; else if (string_is_equal(osk_grid[ptr], "Next")) #endif - if (menu_event_get_osk_idx() < (is_rgui ? OSK_SYMBOLS_PAGE1 : OSK_TYPE_LAST - 1)) - menu_event_set_osk_idx((enum osk_type)(menu_event_get_osk_idx() + 1)); + if (osk_idx < (is_rgui ? OSK_SYMBOLS_PAGE1 : OSK_TYPE_LAST - 1)) + osk_idx = (enum osk_type)(osk_idx + 1); else - menu_event_set_osk_idx((enum osk_type)(OSK_TYPE_UNKNOWN + 1)); + osk_idx = ((enum osk_type)(OSK_TYPE_UNKNOWN + 1)); else input_keyboard_line_append(osk_grid[ptr]); } void menu_event_osk_iterate(void) { - switch (menu_event_get_osk_idx()) + switch (osk_idx) { #ifdef HAVE_LANGEXTRA case OSK_HIRAGANA_PAGE1: diff --git a/menu/widgets/menu_osk.h b/menu/widgets/menu_osk.h index 2c460a7efb..b0614e9cde 100644 --- a/menu/widgets/menu_osk.h +++ b/menu/widgets/menu_osk.h @@ -55,7 +55,7 @@ int menu_event_get_osk_ptr(void); void menu_event_set_osk_ptr(int a); -void menu_event_osk_append(int a); +void menu_event_osk_append(int a, bool is_rgui); void menu_event_osk_iterate(void); diff --git a/retroarch.c b/retroarch.c index 0ee85febd2..b4969e5631 100644 --- a/retroarch.c +++ b/retroarch.c @@ -14746,7 +14746,16 @@ static unsigned menu_event( RETRO_DEVICE_ID_JOYPAD_A : RETRO_DEVICE_ID_JOYPAD_B; unsigned ok_current = BIT256_GET_PTR(p_input, menu_ok_btn); unsigned ok_trigger = ok_current & ~ok_old; - bool is_rgui = string_is_equal(settings->arrays.menu_driver, "rgui"); +#ifdef HAVE_RGUI + /* TODO/FIXME - instead of looking explicitly for the name rgui, instead + * perhaps check if set_texture is set - I assume we want to check if + * a menu driver is framebuffer-based instead of specifically looking if + * it's RGUI */ + bool is_rgui = string_is_equal( + settings->arrays.menu_driver, "rgui"); +#else + bool is_rgui = false; +#endif ok_old = ok_current; @@ -14829,26 +14838,29 @@ static unsigned menu_event( if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_L)) { - if (menu_event_get_osk_idx() > OSK_TYPE_UNKNOWN + 1) + enum osk_type osk_type_idx = menu_event_get_osk_idx(); + if (osk_type_idx > OSK_TYPE_UNKNOWN + 1) menu_event_set_osk_idx((enum osk_type)( - menu_event_get_osk_idx() - 1)); + osk_type_idx - 1)); else menu_event_set_osk_idx((enum osk_type)(is_rgui ? OSK_SYMBOLS_PAGE1 : OSK_TYPE_LAST - 1)); } if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_R)) { - if (menu_event_get_osk_idx() < (is_rgui ? OSK_SYMBOLS_PAGE1 : OSK_TYPE_LAST - 1)) + enum osk_type osk_type_idx = menu_event_get_osk_idx(); + if (osk_type_idx < (is_rgui ? OSK_SYMBOLS_PAGE1 : OSK_TYPE_LAST - 1)) menu_event_set_osk_idx((enum osk_type)( - menu_event_get_osk_idx() + 1)); + osk_type_idx + 1)); else menu_event_set_osk_idx((enum osk_type)(OSK_TYPE_UNKNOWN + 1)); } if (BIT256_GET_PTR(p_trigger_input, menu_ok_btn)) { - if (menu_event_get_osk_ptr() >= 0) - menu_event_osk_append(menu_event_get_osk_ptr()); + int ptr = menu_event_get_osk_ptr(); + if (ptr >= 0) + menu_event_osk_append(ptr, is_rgui); } if (BIT256_GET_PTR(p_trigger_input, menu_cancel_btn)) @@ -15510,7 +15522,9 @@ static int menu_input_pointer_post_iterate( if (point.retcode > -1) { menu_event_set_osk_ptr(point.retcode); - menu_event_osk_append(point.retcode); + menu_event_osk_append(point.retcode, + string_is_equal( + configuration_settings->arrays.menu_driver, "rgui")); } } } From ec53a400a7e2f4870dbaa9746af43ec6548cfa8c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 12 Feb 2020 17:06:53 +0100 Subject: [PATCH 22/75] Reduce dependency on settings in menu_widgets.c --- menu/widgets/menu_widgets.c | 52 +++++++++++++++++++++---------------- menu/widgets/menu_widgets.h | 15 ++++++++--- retroarch.c | 25 +++++++++++++----- 3 files changed, 59 insertions(+), 33 deletions(-) diff --git a/menu/widgets/menu_widgets.c b/menu/widgets/menu_widgets.c index 2a4769d15f..deb504fa8f 100644 --- a/menu/widgets/menu_widgets.c +++ b/menu/widgets/menu_widgets.c @@ -336,7 +336,8 @@ void menu_widgets_msg_queue_push( char *title, enum message_queue_icon icon, enum message_queue_category category, - unsigned prio, bool flush) + unsigned prio, bool flush, + float video_font_size) { menu_widget_msg_t* msg_widget = NULL; @@ -423,9 +424,9 @@ void menu_widgets_msg_queue_push( unsigned width = menu_driver_is_alive() ? msg_queue_default_rect_width_menu_alive : msg_queue_default_rect_width; unsigned text_width = font_driver_get_message_width(font_regular, title, title_length, msg_queue_text_scale_factor); - settings_t *settings = config_get_ptr(); - msg_widget->text_height = msg_queue_text_scale_factor * settings->floats.video_font_size; + msg_widget->text_height = msg_queue_text_scale_factor + * video_font_size; /* Text is too wide, split it into two lines */ if (text_width > width) @@ -863,7 +864,9 @@ static void menu_widgets_hourglass_tick(void *userdata) menu_animation_push(&entry); } -void menu_widgets_iterate(unsigned width, unsigned height) +void menu_widgets_iterate( + float video_font_size, + unsigned width, unsigned height) { size_t i; @@ -944,8 +947,6 @@ void menu_widgets_iterate(unsigned width, unsigned height) if (screenshot_filename[0] != '\0') { menu_timer_ctx_entry_t timer; - settings_t *settings = config_get_ptr(); - float video_font_size = settings->floats.video_font_size; video_driver_texture_unload(&screenshot_texture); @@ -981,6 +982,7 @@ void menu_widgets_iterate(unsigned width, unsigned height) static int menu_widgets_draw_indicator(video_frame_info_t *video_info, menu_texture_item icon, int y, int top_right_x_advance, + float video_font_size, enum msg_hash_enums msg) { unsigned width; @@ -1013,8 +1015,6 @@ static int menu_widgets_draw_indicator(video_frame_info_t *video_info, { unsigned height = simple_widget_height; const char *txt = msg_hash_to_str(msg); - settings_t *settings = config_get_ptr(); - float video_font_size = settings->floats.video_font_size; width = font_driver_get_message_width(font_regular, txt, (unsigned)strlen(txt), 1) + simple_widget_padding*2; @@ -1038,7 +1038,8 @@ static int menu_widgets_draw_indicator(video_frame_info_t *video_info, return width; } -static void menu_widgets_draw_task_msg(menu_widget_msg_t *msg, video_frame_info_t *video_info) +static void menu_widgets_draw_task_msg( + menu_widget_msg_t *msg, video_frame_info_t *video_info) { unsigned text_color; unsigned bar_width; @@ -1791,21 +1792,25 @@ void menu_widgets_frame(void *data) if (video_info->widgets_is_paused) top_right_x_advance -= menu_widgets_draw_indicator(video_info, menu_widgets_icons_textures[MENU_WIDGETS_ICON_PAUSED], (video_info->fps_show ? simple_widget_height : 0), top_right_x_advance, + video_font_size, MSG_PAUSED); if (video_info->widgets_is_fast_forwarding) top_right_x_advance -= menu_widgets_draw_indicator(video_info, menu_widgets_icons_textures[MENU_WIDGETS_ICON_FAST_FORWARD], (video_info->fps_show ? simple_widget_height : 0), top_right_x_advance, + video_font_size, MSG_PAUSED); if (video_info->widgets_is_rewinding) top_right_x_advance -= menu_widgets_draw_indicator(video_info, menu_widgets_icons_textures[MENU_WIDGETS_ICON_REWIND], (video_info->fps_show ? simple_widget_height : 0), top_right_x_advance, + video_font_size, MSG_REWINDING); if (video_info->runloop_is_slowmotion) top_right_x_advance -= menu_widgets_draw_indicator(video_info, menu_widgets_icons_textures[MENU_WIDGETS_ICON_SLOW_MOTION], (video_info->fps_show ? simple_widget_height : 0), top_right_x_advance, + video_font_size, MSG_SLOW_MOTION); /* Screenshot */ @@ -1863,8 +1868,13 @@ error: return false; } -void menu_widgets_context_reset(bool is_threaded, - unsigned width, unsigned height) +void menu_widgets_context_reset( + bool is_threaded, + unsigned width, unsigned height, + float video_font_size, + const char *dir_assets, + char *path_font + ) { int i; char xmb_path[PATH_MAX_LENGTH]; @@ -1873,20 +1883,18 @@ void menu_widgets_context_reset(bool is_threaded, char theme_path[PATH_MAX_LENGTH]; char ozone_path[PATH_MAX_LENGTH]; char font_path[PATH_MAX_LENGTH]; - settings_t *settings = config_get_ptr(); - float video_font_size = settings->floats.video_font_size; /* Textures paths */ fill_pathname_join( menu_widgets_path, - settings->paths.directory_assets, + dir_assets, "menu_widgets", sizeof(menu_widgets_path) ); fill_pathname_join( xmb_path, - settings->paths.directory_assets, + dir_assets, "xmb", sizeof(xmb_path) ); @@ -1923,13 +1931,13 @@ void menu_widgets_context_reset(bool is_threaded, /* Fonts paths */ fill_pathname_join( ozone_path, - settings->paths.directory_assets, + dir_assets, "ozone", sizeof(ozone_path) ); /* Fonts */ - if (settings->paths.path_font[0] == '\0') + if (path_font[0] == '\0') { fill_pathname_join(font_path, ozone_path, "regular.ttf", sizeof(font_path)); font_regular = menu_display_font_file(font_path, video_font_size, is_threaded); @@ -1939,8 +1947,8 @@ void menu_widgets_context_reset(bool is_threaded, } else { - font_regular = menu_display_font_file(settings->paths.path_font, video_font_size, is_threaded); - font_bold = menu_display_font_file(settings->paths.path_font, video_font_size, is_threaded); + font_regular = menu_display_font_file(path_font, video_font_size, is_threaded); + font_bold = menu_display_font_file(path_font, video_font_size, is_threaded); } /* Metrics */ @@ -2013,7 +2021,7 @@ void menu_widgets_context_destroy(void) menu_display_font_free(font_bold); font_regular = NULL; - font_bold = NULL; + font_bold = NULL; } static void menu_widgets_achievement_free(void *userdata) @@ -2122,12 +2130,10 @@ static void menu_widgets_volume_timer_end(void *userdata) menu_animation_push(&entry); } -void menu_widgets_volume_update_and_show(void) +void menu_widgets_volume_update_and_show(float new_volume) { menu_timer_ctx_entry_t entry; - settings_t *settings = config_get_ptr(); bool mute = *(audio_get_bool_ptr(AUDIO_ACTION_MUTE_ENABLE)); - float new_volume = settings->floats.audio_volume; menu_animation_kill_by_tag(&volume_tag); diff --git a/menu/widgets/menu_widgets.h b/menu/widgets/menu_widgets.h index 287bd21cdc..ef2d128381 100644 --- a/menu/widgets/menu_widgets.h +++ b/menu/widgets/menu_widgets.h @@ -46,11 +46,14 @@ void menu_widgets_msg_queue_push( char *title, enum message_queue_icon icon, enum message_queue_category category, - unsigned prio, bool flush); + unsigned prio, bool flush, + float video_font_size); -void menu_widgets_volume_update_and_show(void); +void menu_widgets_volume_update_and_show(float new_volume); -void menu_widgets_iterate(unsigned width, unsigned height); +void menu_widgets_iterate( + float video_font_size, + unsigned width, unsigned height); void menu_widgets_screenshot_taken(const char *shotname, const char *filename); @@ -70,7 +73,11 @@ void menu_widgets_start_load_content_animation( void menu_widgets_cleanup_load_content_animation(void); void menu_widgets_context_reset(bool is_threaded, - unsigned width, unsigned height); + unsigned width, unsigned height, + float video_font_size, + const char *dir_assets, + char *font_path + ); void menu_widgets_context_destroy(void); diff --git a/retroarch.c b/retroarch.c index b4969e5631..3a89d6e2e6 100644 --- a/retroarch.c +++ b/retroarch.c @@ -5407,7 +5407,7 @@ static void command_event_set_volume(float gain) #if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) if (menu_widgets_inited) - menu_widgets_volume_update_and_show(); + menu_widgets_volume_update_and_show(settings->floats.audio_volume); else #endif runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); @@ -6889,7 +6889,8 @@ TODO: Add a setting for these tweaks */ #if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) if (menu_widgets_inited) - menu_widgets_volume_update_and_show(); + menu_widgets_volume_update_and_show( + configuration_settings->floats.audio_volume); else #endif runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); @@ -23425,7 +23426,11 @@ static void drivers_init(int flags) if (menu_widgets_inited) menu_widgets_context_reset(video_is_threaded, - video_driver_width, video_driver_height); + video_driver_width, video_driver_height, + settings->floats.video_font_size, + settings->paths.directory_assets, + settings->paths.path_font + ); } else { @@ -25768,7 +25773,12 @@ static void runloop_task_msg_queue_push( runloop_msg_queue_lock(); ui_companion_driver_msg_queue_push(msg, prio, task ? duration : duration * 60 / 1000, flush); - menu_widgets_msg_queue_push(task, msg, duration, NULL, (enum message_queue_icon)MESSAGE_QUEUE_CATEGORY_INFO, (enum message_queue_category)MESSAGE_QUEUE_ICON_DEFAULT, prio, flush); + menu_widgets_msg_queue_push(task, msg, duration, NULL, + (enum message_queue_icon)MESSAGE_QUEUE_CATEGORY_INFO, + (enum message_queue_category)MESSAGE_QUEUE_ICON_DEFAULT, + prio, flush, + configuration_settings->floats.video_font_size + ); runloop_msg_queue_unlock(); } else @@ -26640,7 +26650,8 @@ void runloop_msg_queue_push(const char *msg, { menu_widgets_msg_queue_push(NULL, msg, roundf((float)duration / 60.0f * 1000.0f), - title, icon, category, prio, flush); + title, icon, category, prio, flush, + configuration_settings->floats.video_font_size); duration = duration * 60 / 1000; } else @@ -27141,7 +27152,9 @@ static enum runloop_state runloop_check_state(void) if (menu_widgets_inited) { runloop_msg_queue_lock(); - menu_widgets_iterate(video_driver_width, video_driver_height); + menu_widgets_iterate( + settings->floats.video_font_size, + video_driver_width, video_driver_height); runloop_msg_queue_unlock(); } #endif From 7eb41e70571f50bd3541935037b6776335985b3f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 12 Feb 2020 17:13:47 +0100 Subject: [PATCH 23/75] (JACK) Get rid of configuration.h dependency --- audio/drivers/jack.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/audio/drivers/jack.c b/audio/drivers/jack.c index 3275b3d62f..fd68cc8600 100644 --- a/audio/drivers/jack.c +++ b/audio/drivers/jack.c @@ -26,7 +26,6 @@ #include #include "../../retroarch.h" -#include "../../configuration.h" #include "../../verbosity.h" #define FRAMES(x) (x / (sizeof(float) * 2)) @@ -97,13 +96,13 @@ static void shutdown_cb(void *data) #endif } -static int parse_ports(char **dest_ports, const char **jports) +static int parse_ports(const char *audio_device, + char **dest_ports, const char **jports) { int i; char *save = NULL; int parsed = 0; - settings_t *settings = config_get_ptr(); - char *audio_device_cpy = strdup(settings->arrays.audio_device); + char *audio_device_cpy = strdup(audio_device); const char *con = strtok_r(audio_device_cpy, ",", &save); if (con) @@ -146,7 +145,8 @@ static size_t find_buffersize(jack_t *jd, int latency, unsigned out_rate) return buffer_frames * sizeof(jack_default_audio_sample_t); } -static void *ja_init(const char *device, unsigned rate, unsigned latency, +static void *ja_init(const char *device, + unsigned rate, unsigned latency, unsigned block_frames, unsigned *new_rate) { @@ -203,7 +203,7 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency, } } - parsed = parse_ports(dest_ports, jports); + parsed = parse_ports(device, dest_ports, jports); if (jack_activate(jd->client) < 0) { From 71030e4d819a90a7fdc9f77ce0cb79c13b1a73de Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 12 Feb 2020 17:18:14 +0100 Subject: [PATCH 24/75] Cleanup --- menu/widgets/menu_filebrowser.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/menu/widgets/menu_filebrowser.c b/menu/widgets/menu_filebrowser.c index 6b56db1e2e..f3ce55024e 100644 --- a/menu/widgets/menu_filebrowser.c +++ b/menu/widgets/menu_filebrowser.c @@ -102,20 +102,22 @@ void filebrowser_parse(menu_displaylist_info_t *info, unsigned type_data) } else if (!string_is_empty(path)) { + bool show_hidden_files = settings->bools.show_hidden_files; + if (filebrowser_types == FILEBROWSER_SELECT_FILE_SUBSYSTEM) { if (subsystem && subsystem_current_count > 0 && content_get_subsystem_rom_id() < subsystem->num_roms) str_list = dir_list_new(path, (filter_ext && info) ? subsystem->roms[content_get_subsystem_rom_id()].valid_extensions : NULL, - true, settings->bools.show_hidden_files, true, false); + true, show_hidden_files, true, false); } else if (info && ((info->type_default == FILE_TYPE_MANUAL_SCAN_DAT) || (info->type_default == FILE_TYPE_SIDELOAD_CORE))) str_list = dir_list_new(path, - info->exts, true, settings->bools.show_hidden_files, false, false); + info->exts, true, show_hidden_files, false, false); else str_list = dir_list_new(path, (filter_ext && info) ? info->exts : NULL, - true, settings->bools.show_hidden_files, true, false); + true, show_hidden_files, true, false); } switch (filebrowser_types) From e93244e0cba78375ee3083a2a2618081d3efa859 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 12 Feb 2020 17:26:54 +0100 Subject: [PATCH 25/75] Cleanups --- retroarch.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/retroarch.c b/retroarch.c index 3a89d6e2e6..a9188c64af 100644 --- a/retroarch.c +++ b/retroarch.c @@ -5865,19 +5865,17 @@ static void command_event_runtime_log_init(void) strlcpy(runtime_core_path, core_path, sizeof(runtime_core_path)); } -static void retroarch_set_frame_limit(void) +static void retroarch_set_frame_limit(float fastforward_ratio_orig) { - settings_t *settings = configuration_settings; struct retro_system_av_info *av_info = &video_driver_av_info; - float fastforward_ratio_orig = settings->floats.fastforward_ratio; - float fastforward_ratio = (fastforward_ratio_orig == 0.0f) ? 1.0f : fastforward_ratio_orig; + float fastforward_ratio = (fastforward_ratio_orig == 0.0f) + ? 1.0f : fastforward_ratio_orig; frame_limit_last_time = cpu_features_get_time_usec(); frame_limit_minimum_time = (retro_time_t)roundf(1000000.0f / (av_info->timing.fps * fastforward_ratio)); } - static bool command_event_init_core(enum rarch_core_type type) { settings_t *settings = configuration_settings; @@ -5958,7 +5956,7 @@ static bool command_event_init_core(enum rarch_core_type type) if (!core_load(settings->uints.input_poll_type_behavior)) return false; - retroarch_set_frame_limit(); + retroarch_set_frame_limit(configuration_settings->floats.fastforward_ratio); command_event_runtime_log_init(); return true; } @@ -7724,7 +7722,8 @@ TODO: Add a setting for these tweaks */ command_event_set_mixer_volume(-0.5f); break; case CMD_EVENT_SET_FRAME_LIMIT: - retroarch_set_frame_limit(); + retroarch_set_frame_limit( + configuration_settings->floats.fastforward_ratio); break; case CMD_EVENT_DISCORD_INIT: #ifdef HAVE_DISCORD @@ -9774,17 +9773,20 @@ static bool rarch_environment_cb(unsigned cmd, void *data) case RETRO_ENVIRONMENT_GET_PREFERRED_HW_RENDER: { unsigned *cb = (unsigned*)data; - settings_t *settings = configuration_settings; + settings_t *settings = configuration_settings; + const char *video_driver_name = settings->arrays.video_driver; + RARCH_LOG("[Environ]: GET_PREFERRED_HW_RENDER.\n"); + if (!settings->bools.driver_switch_enable) return false; - else if (!strcmp(settings->arrays.video_driver, "glcore")) + else if (!strcmp(video_driver_name, "glcore")) *cb = RETRO_HW_CONTEXT_OPENGL_CORE; - else if (!strcmp(settings->arrays.video_driver, "gl")) + else if (!strcmp(video_driver_name, "gl")) *cb = RETRO_HW_CONTEXT_OPENGL; - else if (!strcmp(settings->arrays.video_driver, "vulkan")) + else if (!strcmp(video_driver_name, "vulkan")) *cb = RETRO_HW_CONTEXT_VULKAN; - else if (!strncmp(settings->arrays.video_driver, "d3d", 3)) + else if (!strncmp(video_driver_name, "d3d", 3)) *cb = RETRO_HW_CONTEXT_DIRECT3D; else *cb = RETRO_HW_CONTEXT_NONE; @@ -9979,12 +9981,13 @@ static bool rarch_environment_cb(unsigned cmd, void *data) case RETRO_ENVIRONMENT_GET_CORE_ASSETS_DIRECTORY: { - const char **dir = (const char**)data; + const char **dir = (const char**)data; + const char *dir_core_assets = settings->paths.directory_core_assets; - *dir = *settings->paths.directory_core_assets ? - settings->paths.directory_core_assets : NULL; + *dir = *dir_core_assets ? + dir_core_assets : NULL; RARCH_LOG("[Environ]: CORE_ASSETS_DIRECTORY: \"%s\".\n", - settings->paths.directory_core_assets); + dir_core_assets); break; } From 013117318c3b8d7c30877582c54e3efa2d0e7541 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 12 Feb 2020 20:01:48 +0100 Subject: [PATCH 26/75] (network) Get rid of all the settings pointer grabbing --- network/netplay/netplay_frontend.c | 7 ++- network/netplay/netplay_handshake.c | 95 +++++++++++++++++------------ network/netplay/netplay_init.c | 6 +- network/netplay/netplay_private.h | 11 +++- network/netplay/netplay_sync.c | 8 ++- 5 files changed, 81 insertions(+), 46 deletions(-) diff --git a/network/netplay/netplay_frontend.c b/network/netplay/netplay_frontend.c index f164dbe292..bca1e75cbe 100644 --- a/network/netplay/netplay_frontend.c +++ b/network/netplay/netplay_frontend.c @@ -1039,7 +1039,10 @@ bool netplay_pre_frame(netplay_t *netplay) } } - sync_stalled = !netplay_sync_pre_frame(netplay); + sync_stalled = !netplay_sync_pre_frame(netplay, + settings->paths.netplay_password, + settings->paths.netplay_spectate_password + ); /* If we're disconnected, deinitialize */ if (!netplay->is_server && !netplay->connections[0].active) @@ -1466,6 +1469,8 @@ bool init_netplay(void *direct_host, const char *server, unsigned port) discord_get_own_username() ? discord_get_own_username() : #endif settings->paths.username, + settings->paths.netplay_password, + settings->paths.netplay_spectate_password, quirks); if (netplay_data) diff --git a/network/netplay/netplay_handshake.c b/network/netplay/netplay_handshake.c index e6494ecad1..d77656aa4c 100644 --- a/network/netplay/netplay_handshake.c +++ b/network/netplay/netplay_handshake.c @@ -94,15 +94,11 @@ void netplay_log_connection(const struct sockaddr_storage *their_addr, } if (str) - { snprintf(s, len, msg_hash_to_str(MSG_GOT_CONNECTION_FROM_NAME), nick, str); - } else - { snprintf(s, len, msg_hash_to_str(MSG_GOT_CONNECTION_FROM), nick); - } } #else @@ -199,11 +195,12 @@ static uint32_t simple_rand_uint32(void) * Initialize our handshake and send the first part of the handshake protocol. */ bool netplay_handshake_init_send(netplay_t *netplay, - struct netplay_connection *connection) + struct netplay_connection *connection, + const char *netplay_password, + const char *netplay_spectate_password) { uint32_t header[6]; - unsigned conn_salt = 0; - settings_t *settings = config_get_ptr(); + unsigned conn_salt = 0; header[0] = htonl(netplay_magic); header[1] = htonl(netplay_platform_magic()); @@ -213,8 +210,8 @@ bool netplay_handshake_init_send(netplay_t *netplay, header[5] = htonl(netplay_impl_magic()); if (netplay->is_server && - (settings->paths.netplay_password[0] || - settings->paths.netplay_spectate_password[0])) + (netplay_password[0] || + netplay_spectate_password[0])) { /* Demand a password */ if (simple_rand_next == 1) @@ -496,7 +493,7 @@ static void netplay_handshake_ready(netplay_t *netplay, * * Send an INFO command. */ -bool netplay_handshake_info(netplay_t *netplay, +static bool netplay_handshake_info(netplay_t *netplay, struct netplay_connection *connection) { struct info_buf_s info_buf; @@ -545,7 +542,7 @@ bool netplay_handshake_info(netplay_t *netplay, * * Send a SYNC command. */ -bool netplay_handshake_sync(netplay_t *netplay, +static bool netplay_handshake_sync(netplay_t *netplay, struct netplay_connection *connection) { /* If we're the server, now we send sync info */ @@ -690,8 +687,11 @@ bool netplay_handshake_sync(netplay_t *netplay, * Data receiver for the second stage of handshake, receiving the other side's * nickname. */ -bool netplay_handshake_pre_nick(netplay_t *netplay, - struct netplay_connection *connection, bool *had_input) +static bool netplay_handshake_pre_nick(netplay_t *netplay, + struct netplay_connection *connection, bool *had_input, + const char *netplay_password, + const char *netplay_spectate_password + ) { struct nick_buf_s nick_buf; ssize_t recvd; @@ -724,11 +724,9 @@ bool netplay_handshake_pre_nick(netplay_t *netplay, if (netplay->is_server) { - settings_t *settings = config_get_ptr(); - /* There's a password, so just put them in PRE_PASSWORD mode */ - if ( settings->paths.netplay_password[0] || - settings->paths.netplay_spectate_password[0]) + if ( netplay_password[0] || + netplay_spectate_password[0]) connection->mode = NETPLAY_CONNECTION_PRE_PASSWORD; else { @@ -753,8 +751,10 @@ bool netplay_handshake_pre_nick(netplay_t *netplay, * Data receiver for the third, optional stage of server handshake, receiving * the password and sending core/content info. */ -bool netplay_handshake_pre_password(netplay_t *netplay, - struct netplay_connection *connection, bool *had_input) +static bool netplay_handshake_pre_password(netplay_t *netplay, + struct netplay_connection *connection, bool *had_input, + const char *netplay_password, + const char *netplay_spectate_password) { struct password_buf_s password_buf; char password[8+NETPLAY_PASS_LEN]; /* 8 for salt */ @@ -762,7 +762,6 @@ bool netplay_handshake_pre_password(netplay_t *netplay, ssize_t recvd; char msg[512]; bool correct = false; - settings_t *settings = config_get_ptr(); msg[0] = '\0'; @@ -789,10 +788,10 @@ bool netplay_handshake_pre_password(netplay_t *netplay, correct = false; snprintf(password, sizeof(password), "%08X", connection->salt); - if (settings->paths.netplay_password[0]) + if (netplay_password[0]) { strlcpy(password + 8, - settings->paths.netplay_password, sizeof(password)-8); + netplay_password, sizeof(password)-8); sha256_hash(hash, (uint8_t *) password, strlen(password)); @@ -802,10 +801,10 @@ bool netplay_handshake_pre_password(netplay_t *netplay, connection->can_play = true; } } - if (settings->paths.netplay_spectate_password[0]) + if (netplay_spectate_password[0]) { strlcpy(password + 8, - settings->paths.netplay_spectate_password, sizeof(password)-8); + netplay_spectate_password, sizeof(password)-8); sha256_hash(hash, (uint8_t *) password, strlen(password)); @@ -833,7 +832,7 @@ bool netplay_handshake_pre_password(netplay_t *netplay, * Data receiver for the third stage of server handshake, receiving * the password. */ -bool netplay_handshake_pre_info(netplay_t *netplay, +static bool netplay_handshake_pre_info(netplay_t *netplay, struct netplay_connection *connection, bool *had_input) { struct info_buf_s info_buf; @@ -937,8 +936,9 @@ bool netplay_handshake_pre_info(netplay_t *netplay, * Data receiver for the client's third handshake stage, receiving the * synchronization information. */ -bool netplay_handshake_pre_sync(netplay_t *netplay, - struct netplay_connection *connection, bool *had_input) +static bool netplay_handshake_pre_sync(netplay_t *netplay, + struct netplay_connection *connection, bool *had_input, + bool netplay_start_as_spectator) { uint32_t cmd[2]; uint32_t new_frame_count, client_num; @@ -1069,7 +1069,8 @@ bool netplay_handshake_pre_sync(netplay_t *netplay, snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_NETPLAY_CHANGED_NICK), netplay->nick); RARCH_LOG("%s\n", msg); - runloop_msg_queue_push(msg, 1, 180, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + runloop_msg_queue_push(msg, 1, 180, false, NULL, + MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); } /* Now check the SRAM */ @@ -1102,7 +1103,8 @@ bool netplay_handshake_pre_sync(netplay_t *netplay, uint32_t quickbuf; while (remote_sram_size > 0) { - RECV(&quickbuf, (remote_sram_size > sizeof(uint32_t)) ? sizeof(uint32_t) : remote_sram_size) + RECV(&quickbuf, (remote_sram_size > sizeof(uint32_t)) + ? sizeof(uint32_t) : remote_sram_size) { RARCH_ERR("%s\n", msg_hash_to_str(MSG_FAILED_TO_RECEIVE_SRAM_DATA_FROM_HOST)); @@ -1123,18 +1125,15 @@ bool netplay_handshake_pre_sync(netplay_t *netplay, #endif /* We're ready! */ - *had_input = true; + *had_input = true; netplay->self_mode = NETPLAY_CONNECTION_SPECTATING; - connection->mode = NETPLAY_CONNECTION_PLAYING; + connection->mode = NETPLAY_CONNECTION_PLAYING; netplay_handshake_ready(netplay, connection); netplay_recv_flush(&connection->recv_packet_buffer); /* Ask to switch to playing mode if we should */ - { - settings_t *settings = config_get_ptr(); - if (!settings->bools.netplay_start_as_spectator) - return netplay_cmd_mode(netplay, NETPLAY_CONNECTION_PLAYING); - } + if (!netplay_start_as_spectator) + return netplay_cmd_mode(netplay, NETPLAY_CONNECTION_PLAYING); return true; } @@ -1147,7 +1146,7 @@ bool netplay_handshake_pre_sync(netplay_t *netplay, bool netplay_handshake(netplay_t *netplay, struct netplay_connection *connection, bool *had_input) { - bool ret = false; + bool ret = false; switch (connection->mode) { @@ -1155,16 +1154,32 @@ bool netplay_handshake(netplay_t *netplay, ret = netplay_handshake_init(netplay, connection, had_input); break; case NETPLAY_CONNECTION_PRE_NICK: - ret = netplay_handshake_pre_nick(netplay, connection, had_input); + { + settings_t *settings = config_get_ptr(); + ret = netplay_handshake_pre_nick(netplay, connection, had_input, + settings->paths.netplay_password, + settings->paths.netplay_spectate_password + ); + } break; case NETPLAY_CONNECTION_PRE_PASSWORD: - ret = netplay_handshake_pre_password(netplay, connection, had_input); + { + settings_t *settings = config_get_ptr(); + ret = netplay_handshake_pre_password(netplay, connection, had_input, + settings->paths.netplay_password, + settings->paths.netplay_spectate_password + ); + } break; case NETPLAY_CONNECTION_PRE_INFO: ret = netplay_handshake_pre_info(netplay, connection, had_input); break; case NETPLAY_CONNECTION_PRE_SYNC: - ret = netplay_handshake_pre_sync(netplay, connection, had_input); + { + settings_t *settings = config_get_ptr(); + ret = netplay_handshake_pre_sync(netplay, connection, had_input, + settings->bools.netplay_start_as_spectator); + } break; case NETPLAY_CONNECTION_NONE: default: diff --git a/network/netplay/netplay_init.c b/network/netplay/netplay_init.c index 3b506097bd..35f3e304ab 100644 --- a/network/netplay/netplay_init.c +++ b/network/netplay/netplay_init.c @@ -418,6 +418,8 @@ static bool netplay_init_buffers(netplay_t *netplay) netplay_t *netplay_new(void *direct_host, const char *server, uint16_t port, bool stateless_mode, int check_frames, const struct retro_callbacks *cb, bool nat_traversal, const char *nick, + const char *netplay_password, + const char *netplay_spectate_password, uint64_t quirks) { netplay_t *netplay = (netplay_t*)calloc(1, sizeof(*netplay)); @@ -487,7 +489,9 @@ netplay_t *netplay_new(void *direct_host, const char *server, uint16_t port, else { /* Start our handshake */ - netplay_handshake_init_send(netplay, &netplay->connections[0]); + netplay_handshake_init_send(netplay, &netplay->connections[0], + netplay_password, + netplay_spectate_password); netplay->connections[0].mode = NETPLAY_CONNECTION_INIT; netplay->self_mode = NETPLAY_CONNECTION_INIT; diff --git a/network/netplay/netplay_private.h b/network/netplay/netplay_private.h index df67ef7d71..686a9bf421 100644 --- a/network/netplay/netplay_private.h +++ b/network/netplay/netplay_private.h @@ -735,7 +735,9 @@ void input_poll_net(void); * Initialize our handshake and send the first part of the handshake protocol. */ bool netplay_handshake_init_send(netplay_t *netplay, - struct netplay_connection *connection); + struct netplay_connection *connection, + const char *netplay_password, + const char *netplay_spectate_password); /** * netplay_handshake @@ -788,6 +790,8 @@ bool netplay_wait_and_init_serialization(netplay_t *netplay); netplay_t *netplay_new(void *direct_host, const char *server, uint16_t port, bool stateless_mode, int check_frames, const struct retro_callbacks *cb, bool nat_traversal, const char *nick, + const char *netplay_password, + const char *netplay_spectate_password, uint64_t quirks); /** @@ -965,7 +969,10 @@ bool netplay_resolve_input(netplay_t *netplay, size_t sim_ptr, bool resim); * * Pre-frame for Netplay synchronization. */ -bool netplay_sync_pre_frame(netplay_t *netplay); +bool netplay_sync_pre_frame(netplay_t *netplay, + const char *netplay_password, + const char *netplay_spectate_password + ); /** * netplay_sync_post_frame diff --git a/network/netplay/netplay_sync.c b/network/netplay/netplay_sync.c index 7e3beb9f58..95656eb689 100644 --- a/network/netplay/netplay_sync.c +++ b/network/netplay/netplay_sync.c @@ -551,7 +551,10 @@ static void netplay_handle_frame_hash(netplay_t *netplay, * * Pre-frame for Netplay synchronization. */ -bool netplay_sync_pre_frame(netplay_t *netplay) +bool netplay_sync_pre_frame(netplay_t *netplay, + const char *netplay_password, + const char *netplay_spectate_password + ) { retro_ctx_serialize_info_t serial_info; @@ -726,7 +729,8 @@ bool netplay_sync_pre_frame(netplay_t *netplay) goto process; } - netplay_handshake_init_send(netplay, connection); + netplay_handshake_init_send(netplay, connection, + netplay_password, netplay_spectate_password); } } From 4c95d1af4e106ae11ff2be0ef7b6db0f3c26bd66 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 12 Feb 2020 20:06:21 +0100 Subject: [PATCH 27/75] (network) Turn some functions into static functions --- network/netplay/netplay_frontend.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/network/netplay/netplay_frontend.c b/network/netplay/netplay_frontend.c index bca1e75cbe..db1067e3a4 100644 --- a/network/netplay/netplay_frontend.c +++ b/network/netplay/netplay_frontend.c @@ -990,7 +990,7 @@ static void netplay_frontend_paused(netplay_t *netplay, bool paused) * Returns: true (1) if the frontend is cleared to emulate the frame, false (0) * if we're stalled or paused **/ -bool netplay_pre_frame(netplay_t *netplay) +static bool netplay_pre_frame(netplay_t *netplay) { bool sync_stalled = false; settings_t *settings = config_get_ptr(); @@ -1071,7 +1071,7 @@ bool netplay_pre_frame(netplay_t *netplay) * We check if we have new input and replay from recorded input. * Call this after running retro_run(). **/ -void netplay_post_frame(netplay_t *netplay) +static void netplay_post_frame(netplay_t *netplay) { size_t i; retro_assert(netplay); @@ -1147,7 +1147,7 @@ static void netplay_force_future(netplay_t *netplay) * Send a loaded savestate to those connected peers using the given compression * scheme. */ -void netplay_send_savestate(netplay_t *netplay, +static void netplay_send_savestate(netplay_t *netplay, retro_ctx_serialize_info_t *serial_info, uint32_t cx, struct compression_transcoder *z) { @@ -1288,7 +1288,8 @@ static void netplay_core_reset(netplay_t *netplay) * * Get the preferred share mode */ -uint8_t netplay_settings_share_mode(unsigned share_digital, unsigned share_analog) +uint8_t netplay_settings_share_mode(unsigned share_digital, + unsigned share_analog) { if (share_digital || share_analog) { From 699a21fa8783f802cddf8e94dc84a5689f16d6f6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 01:09:27 +0100 Subject: [PATCH 28/75] Cleanups --- menu/menu_shader.c | 54 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/menu/menu_shader.c b/menu/menu_shader.c index fba6985707..b40f1dde2b 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -225,11 +225,12 @@ end: static bool menu_shader_manager_save_preset_internal( const struct video_shader *shader, const char *basename, + const char *dir_video_shader, + const char *dir_menu_config, bool apply, bool save_reference) { bool ret = false; enum rarch_shader_type type = RARCH_SHADER_NONE; - settings_t *settings = config_get_ptr(); char *preset_path = NULL; size_t i = 0; char fullname[PATH_MAX_LENGTH]; @@ -273,7 +274,7 @@ static bool menu_shader_manager_save_preset_internal( preset_path = fullname; ret = video_shader_write_preset(preset_path, - settings->paths.directory_video_shader, + dir_video_shader, shader, save_reference); if (ret) @@ -294,8 +295,8 @@ static bool menu_shader_manager_save_preset_internal( path_get(RARCH_PATH_CONFIG), sizeof(config_directory)); - dirs[0] = settings->paths.directory_video_shader; - dirs[1] = settings->paths.directory_menu_config; + dirs[0] = dir_video_shader; + dirs[1] = dir_menu_config; dirs[2] = config_directory; for (i = 0; i < ARRAY_SIZE(dirs); i++) @@ -309,7 +310,7 @@ static bool menu_shader_manager_save_preset_internal( preset_path = buffer; ret = video_shader_write_preset(preset_path, - settings->paths.directory_video_shader, + dir_video_shader, shader, save_reference); if (ret) @@ -332,24 +333,26 @@ static bool menu_shader_manager_save_preset_internal( return ret; } -static bool menu_shader_manager_operate_auto_preset(enum auto_shader_operation op, - const struct video_shader *shader, enum auto_shader_type type, bool apply) +static bool menu_shader_manager_operate_auto_preset( + enum auto_shader_operation op, + const struct video_shader *shader, + const char *dir_video_shader, + const char *dir_menu_config, + enum auto_shader_type type, bool apply) { char tmp[PATH_MAX_LENGTH]; char directory[PATH_MAX_LENGTH]; char file[PATH_MAX_LENGTH]; bool success = false; - settings_t *settings = config_get_ptr(); struct retro_system_info *system = runloop_get_libretro_system_info(); const char *core_name = system ? system->library_name : NULL; - const char *path_dir_video_shader = settings->paths.directory_video_shader; tmp[0] = directory[0] = file[0] = '\0'; if (type == SHADER_PRESET_GLOBAL) fill_pathname_join( directory, - path_dir_video_shader, + dir_video_shader, "presets", sizeof(directory)); else if (string_is_empty(core_name)) @@ -358,7 +361,7 @@ static bool menu_shader_manager_operate_auto_preset(enum auto_shader_operation o { fill_pathname_join( tmp, - path_dir_video_shader, + dir_video_shader, "presets", sizeof(tmp)); fill_pathname_join( @@ -401,7 +404,10 @@ static bool menu_shader_manager_operate_auto_preset(enum auto_shader_operation o path_mkdir(directory); return menu_shader_manager_save_preset_internal( - shader, file, apply, true); + shader, file, + dir_video_shader, + dir_menu_config, + apply, true); case AUTO_SHADER_OP_REMOVE: { /* remove all supported auto-shaders of given type */ @@ -465,8 +471,12 @@ static bool menu_shader_manager_operate_auto_preset(enum auto_shader_operation o bool menu_shader_manager_save_auto_preset(const struct video_shader *shader, enum auto_shader_type type, bool apply) { + settings_t *settings = config_get_ptr(); return menu_shader_manager_operate_auto_preset( - AUTO_SHADER_OP_SAVE, shader, type, apply); + AUTO_SHADER_OP_SAVE, shader, + settings->paths.directory_video_shader, + settings->paths.directory_menu_config, + type, apply); } /** @@ -481,8 +491,12 @@ bool menu_shader_manager_save_auto_preset(const struct video_shader *shader, bool menu_shader_manager_save_preset(const struct video_shader *shader, const char *basename, bool apply) { + settings_t *settings = config_get_ptr(); return menu_shader_manager_save_preset_internal( - shader, basename, apply, false); + shader, basename, + settings->paths.directory_video_shader, + settings->paths.directory_menu_config, + apply, false); } /** @@ -493,8 +507,12 @@ bool menu_shader_manager_save_preset(const struct video_shader *shader, **/ bool menu_shader_manager_remove_auto_preset(enum auto_shader_type type) { + settings_t *settings = config_get_ptr(); return menu_shader_manager_operate_auto_preset( - AUTO_SHADER_OP_REMOVE, NULL, type, false); + AUTO_SHADER_OP_REMOVE, NULL, + settings->paths.directory_video_shader, + settings->paths.directory_menu_config, + type, false); } /** @@ -505,8 +523,12 @@ bool menu_shader_manager_remove_auto_preset(enum auto_shader_type type) **/ bool menu_shader_manager_auto_preset_exists(enum auto_shader_type type) { + settings_t *settings = config_get_ptr(); return menu_shader_manager_operate_auto_preset( - AUTO_SHADER_OP_EXISTS, NULL, type, false); + AUTO_SHADER_OP_EXISTS, NULL, + settings->paths.directory_video_shader, + settings->paths.directory_menu_config, + type, false); } int menu_shader_manager_clear_num_passes(struct video_shader *shader) From b7a17442d98b167cb1853b53cae52c7fd84a3449 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 02:04:35 +0100 Subject: [PATCH 29/75] (menu_shader.c) Remove configuration.h dependency --- menu/cbs/menu_cbs_ok.c | 19 ++++++++-- menu/menu_displaylist.c | 21 ++++++++--- menu/menu_shader.c | 52 +++++++++++++++++----------- menu/menu_shader.h | 28 +++++++++++---- retroarch.c | 5 ++- ui/drivers/qt/shaderparamsdialog.cpp | 37 ++++++++++++++++---- 6 files changed, 121 insertions(+), 41 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 454e1d696b..f5a9884800 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -2731,6 +2731,7 @@ static void menu_input_st_string_cb_save_preset(void *userdata, if (!string_is_empty(str)) { rarch_setting_t *setting = NULL; + settings_t *settings = config_get_ptr(); bool ret = false; const char *label = menu_input_dialog_get_label_buffer(); @@ -2744,7 +2745,10 @@ static void menu_input_st_string_cb_save_preset(void *userdata, } else if (!string_is_empty(label)) ret = menu_shader_manager_save_preset(menu_shader_get(), - str, true); + str, + settings->paths.directory_video_shader, + settings->paths.directory_menu_config, + true); if (ret) runloop_msg_queue_push( @@ -2849,6 +2853,8 @@ static int generic_action_ok_shader_preset_remove(const char *path, unsigned action_type) { enum auto_shader_type preset_type; + settings_t *settings = config_get_ptr(); + switch (action_type) { case ACTION_OK_SHADER_PRESET_REMOVE_GLOBAL: @@ -2867,7 +2873,9 @@ static int generic_action_ok_shader_preset_remove(const char *path, return 0; } - if (menu_shader_manager_remove_auto_preset(preset_type)) + if (menu_shader_manager_remove_auto_preset(preset_type, + settings->paths.directory_video_shader, + settings->paths.directory_menu_config)) { bool refresh = false; @@ -2892,6 +2900,8 @@ static int generic_action_ok_shader_preset_save(const char *path, unsigned action_type) { enum auto_shader_type preset_type; + settings_t *settings = config_get_ptr(); + switch (action_type) { case ACTION_OK_SHADER_PRESET_SAVE_GLOBAL: @@ -2910,7 +2920,10 @@ static int generic_action_ok_shader_preset_save(const char *path, return 0; } - if (menu_shader_manager_save_auto_preset(menu_shader_get(), preset_type, true)) + if (menu_shader_manager_save_auto_preset(menu_shader_get(), preset_type, + settings->paths.directory_video_shader, + settings->paths.directory_menu_config, + true)) runloop_msg_queue_push( msg_hash_to_str(MSG_SHADER_PRESET_SAVED_SUCCESSFULLY), 1, 100, true, diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 7e7caa0e5d..64b2d294e2 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -4239,7 +4239,11 @@ unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ct case DISPLAYLIST_SHADER_PRESET_REMOVE: { #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) - if (menu_shader_manager_auto_preset_exists(SHADER_PRESET_GLOBAL)) + settings_t *settings = config_get_ptr(); + if (menu_shader_manager_auto_preset_exists(SHADER_PRESET_GLOBAL, + settings->paths.directory_video_shader, + settings->paths.directory_menu_config + )) if (menu_entries_append_enum(list, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE_GLOBAL), msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_REMOVE_GLOBAL), @@ -4247,7 +4251,10 @@ unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ct MENU_SETTING_ACTION, 0, 0)) count++; - if (menu_shader_manager_auto_preset_exists(SHADER_PRESET_CORE)) + if (menu_shader_manager_auto_preset_exists(SHADER_PRESET_CORE, + settings->paths.directory_video_shader, + settings->paths.directory_menu_config + )) if (menu_entries_append_enum(list, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE_CORE), msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_REMOVE_CORE), @@ -4255,7 +4262,10 @@ unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ct MENU_SETTING_ACTION, 0, 0)) count++; - if (menu_shader_manager_auto_preset_exists(SHADER_PRESET_PARENT)) + if (menu_shader_manager_auto_preset_exists(SHADER_PRESET_PARENT, + settings->paths.directory_video_shader, + settings->paths.directory_menu_config + )) if (menu_entries_append_enum(list, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE_PARENT), msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_REMOVE_PARENT), @@ -4263,7 +4273,10 @@ unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ct MENU_SETTING_ACTION, 0, 0)) count++; - if (menu_shader_manager_auto_preset_exists(SHADER_PRESET_GAME)) + if (menu_shader_manager_auto_preset_exists(SHADER_PRESET_GAME, + settings->paths.directory_video_shader, + settings->paths.directory_menu_config + )) if (menu_entries_append_enum(list, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE_GAME), msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_REMOVE_GAME), diff --git a/menu/menu_shader.c b/menu/menu_shader.c index b40f1dde2b..9689cb8f89 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -29,7 +29,6 @@ #include "menu_driver.h" #include "menu_shader.h" #include "../file_path_special.h" -#include "../configuration.h" #include "../paths.h" #include "../retroarch.h" #include "../verbosity.h" @@ -468,14 +467,17 @@ static bool menu_shader_manager_operate_auto_preset( * Needs to be consistent with retroarch_load_shader_preset() * Auto-shaders will be saved as a reference if possible **/ -bool menu_shader_manager_save_auto_preset(const struct video_shader *shader, - enum auto_shader_type type, bool apply) +bool menu_shader_manager_save_auto_preset( + const struct video_shader *shader, + enum auto_shader_type type, + const char *dir_video_shader, + const char *dir_menu_config, + bool apply) { - settings_t *settings = config_get_ptr(); return menu_shader_manager_operate_auto_preset( AUTO_SHADER_OP_SAVE, shader, - settings->paths.directory_video_shader, - settings->paths.directory_menu_config, + dir_video_shader, + dir_menu_config, type, apply); } @@ -489,13 +491,15 @@ bool menu_shader_manager_save_auto_preset(const struct video_shader *shader, * Save a shader preset to disk. **/ bool menu_shader_manager_save_preset(const struct video_shader *shader, - const char *basename, bool apply) + const char *basename, + const char *dir_video_shader, + const char *dir_menu_config, + bool apply) { - settings_t *settings = config_get_ptr(); return menu_shader_manager_save_preset_internal( shader, basename, - settings->paths.directory_video_shader, - settings->paths.directory_menu_config, + dir_video_shader, + dir_menu_config, apply, false); } @@ -505,13 +509,15 @@ bool menu_shader_manager_save_preset(const struct video_shader *shader, * * Deletes an auto-shader. **/ -bool menu_shader_manager_remove_auto_preset(enum auto_shader_type type) +bool menu_shader_manager_remove_auto_preset( + enum auto_shader_type type, + const char *dir_video_shader, + const char *dir_menu_config) { - settings_t *settings = config_get_ptr(); return menu_shader_manager_operate_auto_preset( AUTO_SHADER_OP_REMOVE, NULL, - settings->paths.directory_video_shader, - settings->paths.directory_menu_config, + dir_video_shader, + dir_menu_config, type, false); } @@ -521,13 +527,15 @@ bool menu_shader_manager_remove_auto_preset(enum auto_shader_type type) * * Tests if an auto-shader of the given type exists. **/ -bool menu_shader_manager_auto_preset_exists(enum auto_shader_type type) +bool menu_shader_manager_auto_preset_exists( + enum auto_shader_type type, + const char *dir_video_shader, + const char *dir_menu_config) { - settings_t *settings = config_get_ptr(); return menu_shader_manager_operate_auto_preset( AUTO_SHADER_OP_EXISTS, NULL, - settings->paths.directory_video_shader, - settings->paths.directory_menu_config, + dir_video_shader, + dir_menu_config, type, false); } @@ -668,7 +676,10 @@ enum rarch_shader_type menu_shader_manager_get_type( * * Apply shader state changes. **/ -void menu_shader_manager_apply_changes(struct video_shader *shader) +void menu_shader_manager_apply_changes( + struct video_shader *shader, + const char *dir_video_shader, + const char *dir_menu_config) { enum rarch_shader_type type = RARCH_SHADER_NONE; @@ -679,7 +690,8 @@ void menu_shader_manager_apply_changes(struct video_shader *shader) if (shader->passes && type != RARCH_SHADER_NONE) { - menu_shader_manager_save_preset(shader, NULL, true); + menu_shader_manager_save_preset(shader, NULL, + dir_video_shader, dir_menu_config, true); return; } diff --git a/menu/menu_shader.h b/menu/menu_shader.h index 615433a351..6a80892fc7 100644 --- a/menu/menu_shader.h +++ b/menu/menu_shader.h @@ -70,8 +70,12 @@ bool menu_shader_manager_set_preset( * Needs to be consistent with retroarch_load_shader_preset() * Auto-shaders will be saved as a reference if possible **/ -bool menu_shader_manager_save_auto_preset(const struct video_shader *shader, - enum auto_shader_type type, bool apply); +bool menu_shader_manager_save_auto_preset( + const struct video_shader *shader, + enum auto_shader_type type, + const char *dir_video_shader, + const char *dir_menu_config, + bool apply); /** * menu_shader_manager_save_preset: @@ -82,7 +86,10 @@ bool menu_shader_manager_save_auto_preset(const struct video_shader *shader, * Save a shader preset to disk. **/ bool menu_shader_manager_save_preset(const struct video_shader *shader, - const char *basename, bool apply); + const char *basename, + const char *dir_video_shader, + const char *dir_menu_config, + bool apply); /** * menu_shader_manager_get_type: @@ -100,7 +107,10 @@ enum rarch_shader_type menu_shader_manager_get_type( * * Apply shader state changes. **/ -void menu_shader_manager_apply_changes(struct video_shader *shader); +void menu_shader_manager_apply_changes( + struct video_shader *shader, + const char *dir_video_shader, + const char *dir_menu_config); int menu_shader_manager_clear_num_passes(struct video_shader *shader); @@ -122,9 +132,15 @@ void menu_shader_manager_clear_pass_path(struct video_shader *shader, * * Deletes an auto-shader. **/ -bool menu_shader_manager_remove_auto_preset(enum auto_shader_type type); +bool menu_shader_manager_remove_auto_preset( + enum auto_shader_type type, + const char *dir_video_shader, + const char *dir_menu_config); -bool menu_shader_manager_auto_preset_exists(enum auto_shader_type type); +bool menu_shader_manager_auto_preset_exists( + enum auto_shader_type type, + const char *dir_video_shader, + const char *dir_menu_config); void menu_shader_set_modified(bool modified); diff --git a/retroarch.c b/retroarch.c index a9188c64af..c984c0d09a 100644 --- a/retroarch.c +++ b/retroarch.c @@ -7255,7 +7255,10 @@ TODO: Add a setting for these tweaks */ case CMD_EVENT_SHADERS_APPLY_CHANGES: #ifdef HAVE_MENU #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) - menu_shader_manager_apply_changes(menu_shader_get()); + menu_shader_manager_apply_changes(menu_shader_get(), + configuration_settings->paths.directory_video_shader, + configuration_settings->paths.directory_menu_config + ); #endif #endif ui_companion_event_command(cmd); diff --git a/ui/drivers/qt/shaderparamsdialog.cpp b/ui/drivers/qt/shaderparamsdialog.cpp index 1159069290..96a5daa962 100644 --- a/ui/drivers/qt/shaderparamsdialog.cpp +++ b/ui/drivers/qt/shaderparamsdialog.cpp @@ -697,6 +697,7 @@ void ShaderParamsDialog::operateShaderPreset(bool save, const char *path, unsign { bool ret; enum auto_shader_type preset_type; + settings_t *settings = config_get_ptr(); switch (action_type) { @@ -721,9 +722,16 @@ void ShaderParamsDialog::operateShaderPreset(bool save, const char *path, unsign if (save) { if (action_type == QT_SHADER_PRESET_NORMAL) - ret = menu_shader_manager_save_preset(menu_shader_get(), path, true); + ret = menu_shader_manager_save_preset(menu_shader_get(), path, + settings->paths.directory_video_shader, + settings->paths.directory_menu_config, + true); else - ret = menu_shader_manager_save_auto_preset(menu_shader_get(), preset_type, true); + ret = menu_shader_manager_save_auto_preset(menu_shader_get(), + preset_type, + settings->paths.directory_video_shader, + settings->paths.directory_menu_config, + true); if (ret) runloop_msg_queue_push( @@ -743,7 +751,9 @@ void ShaderParamsDialog::operateShaderPreset(bool save, const char *path, unsign else { if (action_type != QT_SHADER_PRESET_NORMAL && - menu_shader_manager_remove_auto_preset(preset_type)) + menu_shader_manager_remove_auto_preset(preset_type, + settings->paths.directory_video_shader, + settings->paths.directory_menu_config)) { #ifdef HAVE_MENU bool refresh = false; @@ -881,14 +891,27 @@ void ShaderParamsDialog::onShaderApplyClicked() void ShaderParamsDialog::updateRemovePresetButtonsState() { + settings_t *settings = config_get_ptr(); if (removeGlobalPresetAction) - removeGlobalPresetAction->setEnabled(menu_shader_manager_auto_preset_exists(SHADER_PRESET_GLOBAL)); + removeGlobalPresetAction->setEnabled(menu_shader_manager_auto_preset_exists(SHADER_PRESET_GLOBAL, + settings->paths.directory_video_shader, + settings->paths.directory_menu_config + )); if (removeCorePresetAction) - removeCorePresetAction->setEnabled(menu_shader_manager_auto_preset_exists(SHADER_PRESET_CORE)); + removeCorePresetAction->setEnabled(menu_shader_manager_auto_preset_exists(SHADER_PRESET_CORE, + settings->paths.directory_video_shader, + settings->paths.directory_menu_config + )); if (removeParentPresetAction) - removeParentPresetAction->setEnabled(menu_shader_manager_auto_preset_exists(SHADER_PRESET_PARENT)); + removeParentPresetAction->setEnabled(menu_shader_manager_auto_preset_exists(SHADER_PRESET_PARENT, + settings->paths.directory_video_shader, + settings->paths.directory_menu_config + )); if (removeGamePresetAction) - removeGamePresetAction->setEnabled(menu_shader_manager_auto_preset_exists(SHADER_PRESET_GAME)); + removeGamePresetAction->setEnabled(menu_shader_manager_auto_preset_exists(SHADER_PRESET_GAME, + settings->paths.directory_video_shader, + settings->paths.directory_menu_config + )); } void ShaderParamsDialog::reload() From 2e0f921ded1f261c8f36c3201a2495465538bad2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 02:18:38 +0100 Subject: [PATCH 30/75] Cleanups --- gfx/common/win32_common.c | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 22b8593233..07e8220f9a 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -575,23 +575,6 @@ static bool win32_drag_query_file(HWND hwnd, WPARAM wparam) return false; } -static void win32_set_position_from_config(void) -{ - settings_t *settings = config_get_ptr(); - int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); - int title_bar_height = GetSystemMetrics(SM_CYCAPTION); - - if (!settings->bools.video_window_save_positions) - return; - - g_win32_pos_x = settings->uints.window_position_x; - g_win32_pos_y = settings->uints.window_position_y; - g_win32_pos_width = settings->uints.window_position_width - + border_thickness * 2; - g_win32_pos_height = settings->uints.window_position_height - + border_thickness * 2 + title_bar_height; -} - static void win32_save_position(void) { RECT rect; @@ -943,16 +926,15 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message, return 0; } return DefWindowProc(hwnd, message, wparam, lparam); - case WM_MOVE: - win32_save_position(); - break; + case WM_CLOSE: case WM_DESTROY: case WM_QUIT: - win32_save_position(); - g_win32_quit = true; *quit = true; + /* fall-through */ + case WM_MOVE: + win32_save_position(); break; case WM_SIZE: /* Do not send resize message if we minimize. */ @@ -1515,7 +1497,17 @@ void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use, if (settings->bools.video_window_save_positions) { - win32_set_position_from_config(); + /* Set position from config */ + int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); + int title_bar_height = GetSystemMetrics(SM_CYCAPTION); + + g_win32_pos_x = settings->uints.window_position_x; + g_win32_pos_y = settings->uints.window_position_y; + g_win32_pos_width = settings->uints.window_position_width + + border_thickness * 2; + g_win32_pos_height = settings->uints.window_position_height + + border_thickness * 2 + title_bar_height; + if (g_win32_pos_width != 0 && g_win32_pos_height != 0) position_set_from_config = true; } From b004202cbf79a784264cca6864213cbbacc90c5f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 14:11:52 +0100 Subject: [PATCH 31/75] Revert "Reduce dependency on settings in menu_widgets.c" This reverts commit ec53a400a7e2f4870dbaa9746af43ec6548cfa8c. --- menu/widgets/menu_widgets.c | 52 ++++++++++++++++--------------------- menu/widgets/menu_widgets.h | 15 +++-------- retroarch.c | 25 +++++------------- 3 files changed, 33 insertions(+), 59 deletions(-) diff --git a/menu/widgets/menu_widgets.c b/menu/widgets/menu_widgets.c index deb504fa8f..2a4769d15f 100644 --- a/menu/widgets/menu_widgets.c +++ b/menu/widgets/menu_widgets.c @@ -336,8 +336,7 @@ void menu_widgets_msg_queue_push( char *title, enum message_queue_icon icon, enum message_queue_category category, - unsigned prio, bool flush, - float video_font_size) + unsigned prio, bool flush) { menu_widget_msg_t* msg_widget = NULL; @@ -424,9 +423,9 @@ void menu_widgets_msg_queue_push( unsigned width = menu_driver_is_alive() ? msg_queue_default_rect_width_menu_alive : msg_queue_default_rect_width; unsigned text_width = font_driver_get_message_width(font_regular, title, title_length, msg_queue_text_scale_factor); + settings_t *settings = config_get_ptr(); - msg_widget->text_height = msg_queue_text_scale_factor - * video_font_size; + msg_widget->text_height = msg_queue_text_scale_factor * settings->floats.video_font_size; /* Text is too wide, split it into two lines */ if (text_width > width) @@ -864,9 +863,7 @@ static void menu_widgets_hourglass_tick(void *userdata) menu_animation_push(&entry); } -void menu_widgets_iterate( - float video_font_size, - unsigned width, unsigned height) +void menu_widgets_iterate(unsigned width, unsigned height) { size_t i; @@ -947,6 +944,8 @@ void menu_widgets_iterate( if (screenshot_filename[0] != '\0') { menu_timer_ctx_entry_t timer; + settings_t *settings = config_get_ptr(); + float video_font_size = settings->floats.video_font_size; video_driver_texture_unload(&screenshot_texture); @@ -982,7 +981,6 @@ void menu_widgets_iterate( static int menu_widgets_draw_indicator(video_frame_info_t *video_info, menu_texture_item icon, int y, int top_right_x_advance, - float video_font_size, enum msg_hash_enums msg) { unsigned width; @@ -1015,6 +1013,8 @@ static int menu_widgets_draw_indicator(video_frame_info_t *video_info, { unsigned height = simple_widget_height; const char *txt = msg_hash_to_str(msg); + settings_t *settings = config_get_ptr(); + float video_font_size = settings->floats.video_font_size; width = font_driver_get_message_width(font_regular, txt, (unsigned)strlen(txt), 1) + simple_widget_padding*2; @@ -1038,8 +1038,7 @@ static int menu_widgets_draw_indicator(video_frame_info_t *video_info, return width; } -static void menu_widgets_draw_task_msg( - menu_widget_msg_t *msg, video_frame_info_t *video_info) +static void menu_widgets_draw_task_msg(menu_widget_msg_t *msg, video_frame_info_t *video_info) { unsigned text_color; unsigned bar_width; @@ -1792,25 +1791,21 @@ void menu_widgets_frame(void *data) if (video_info->widgets_is_paused) top_right_x_advance -= menu_widgets_draw_indicator(video_info, menu_widgets_icons_textures[MENU_WIDGETS_ICON_PAUSED], (video_info->fps_show ? simple_widget_height : 0), top_right_x_advance, - video_font_size, MSG_PAUSED); if (video_info->widgets_is_fast_forwarding) top_right_x_advance -= menu_widgets_draw_indicator(video_info, menu_widgets_icons_textures[MENU_WIDGETS_ICON_FAST_FORWARD], (video_info->fps_show ? simple_widget_height : 0), top_right_x_advance, - video_font_size, MSG_PAUSED); if (video_info->widgets_is_rewinding) top_right_x_advance -= menu_widgets_draw_indicator(video_info, menu_widgets_icons_textures[MENU_WIDGETS_ICON_REWIND], (video_info->fps_show ? simple_widget_height : 0), top_right_x_advance, - video_font_size, MSG_REWINDING); if (video_info->runloop_is_slowmotion) top_right_x_advance -= menu_widgets_draw_indicator(video_info, menu_widgets_icons_textures[MENU_WIDGETS_ICON_SLOW_MOTION], (video_info->fps_show ? simple_widget_height : 0), top_right_x_advance, - video_font_size, MSG_SLOW_MOTION); /* Screenshot */ @@ -1868,13 +1863,8 @@ error: return false; } -void menu_widgets_context_reset( - bool is_threaded, - unsigned width, unsigned height, - float video_font_size, - const char *dir_assets, - char *path_font - ) +void menu_widgets_context_reset(bool is_threaded, + unsigned width, unsigned height) { int i; char xmb_path[PATH_MAX_LENGTH]; @@ -1883,18 +1873,20 @@ void menu_widgets_context_reset( char theme_path[PATH_MAX_LENGTH]; char ozone_path[PATH_MAX_LENGTH]; char font_path[PATH_MAX_LENGTH]; + settings_t *settings = config_get_ptr(); + float video_font_size = settings->floats.video_font_size; /* Textures paths */ fill_pathname_join( menu_widgets_path, - dir_assets, + settings->paths.directory_assets, "menu_widgets", sizeof(menu_widgets_path) ); fill_pathname_join( xmb_path, - dir_assets, + settings->paths.directory_assets, "xmb", sizeof(xmb_path) ); @@ -1931,13 +1923,13 @@ void menu_widgets_context_reset( /* Fonts paths */ fill_pathname_join( ozone_path, - dir_assets, + settings->paths.directory_assets, "ozone", sizeof(ozone_path) ); /* Fonts */ - if (path_font[0] == '\0') + if (settings->paths.path_font[0] == '\0') { fill_pathname_join(font_path, ozone_path, "regular.ttf", sizeof(font_path)); font_regular = menu_display_font_file(font_path, video_font_size, is_threaded); @@ -1947,8 +1939,8 @@ void menu_widgets_context_reset( } else { - font_regular = menu_display_font_file(path_font, video_font_size, is_threaded); - font_bold = menu_display_font_file(path_font, video_font_size, is_threaded); + font_regular = menu_display_font_file(settings->paths.path_font, video_font_size, is_threaded); + font_bold = menu_display_font_file(settings->paths.path_font, video_font_size, is_threaded); } /* Metrics */ @@ -2021,7 +2013,7 @@ void menu_widgets_context_destroy(void) menu_display_font_free(font_bold); font_regular = NULL; - font_bold = NULL; + font_bold = NULL; } static void menu_widgets_achievement_free(void *userdata) @@ -2130,10 +2122,12 @@ static void menu_widgets_volume_timer_end(void *userdata) menu_animation_push(&entry); } -void menu_widgets_volume_update_and_show(float new_volume) +void menu_widgets_volume_update_and_show(void) { menu_timer_ctx_entry_t entry; + settings_t *settings = config_get_ptr(); bool mute = *(audio_get_bool_ptr(AUDIO_ACTION_MUTE_ENABLE)); + float new_volume = settings->floats.audio_volume; menu_animation_kill_by_tag(&volume_tag); diff --git a/menu/widgets/menu_widgets.h b/menu/widgets/menu_widgets.h index ef2d128381..287bd21cdc 100644 --- a/menu/widgets/menu_widgets.h +++ b/menu/widgets/menu_widgets.h @@ -46,14 +46,11 @@ void menu_widgets_msg_queue_push( char *title, enum message_queue_icon icon, enum message_queue_category category, - unsigned prio, bool flush, - float video_font_size); + unsigned prio, bool flush); -void menu_widgets_volume_update_and_show(float new_volume); +void menu_widgets_volume_update_and_show(void); -void menu_widgets_iterate( - float video_font_size, - unsigned width, unsigned height); +void menu_widgets_iterate(unsigned width, unsigned height); void menu_widgets_screenshot_taken(const char *shotname, const char *filename); @@ -73,11 +70,7 @@ void menu_widgets_start_load_content_animation( void menu_widgets_cleanup_load_content_animation(void); void menu_widgets_context_reset(bool is_threaded, - unsigned width, unsigned height, - float video_font_size, - const char *dir_assets, - char *font_path - ); + unsigned width, unsigned height); void menu_widgets_context_destroy(void); diff --git a/retroarch.c b/retroarch.c index c984c0d09a..c2966d6028 100644 --- a/retroarch.c +++ b/retroarch.c @@ -5407,7 +5407,7 @@ static void command_event_set_volume(float gain) #if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) if (menu_widgets_inited) - menu_widgets_volume_update_and_show(settings->floats.audio_volume); + menu_widgets_volume_update_and_show(); else #endif runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); @@ -6887,8 +6887,7 @@ TODO: Add a setting for these tweaks */ #if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) if (menu_widgets_inited) - menu_widgets_volume_update_and_show( - configuration_settings->floats.audio_volume); + menu_widgets_volume_update_and_show(); else #endif runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); @@ -23432,11 +23431,7 @@ static void drivers_init(int flags) if (menu_widgets_inited) menu_widgets_context_reset(video_is_threaded, - video_driver_width, video_driver_height, - settings->floats.video_font_size, - settings->paths.directory_assets, - settings->paths.path_font - ); + video_driver_width, video_driver_height); } else { @@ -25779,12 +25774,7 @@ static void runloop_task_msg_queue_push( runloop_msg_queue_lock(); ui_companion_driver_msg_queue_push(msg, prio, task ? duration : duration * 60 / 1000, flush); - menu_widgets_msg_queue_push(task, msg, duration, NULL, - (enum message_queue_icon)MESSAGE_QUEUE_CATEGORY_INFO, - (enum message_queue_category)MESSAGE_QUEUE_ICON_DEFAULT, - prio, flush, - configuration_settings->floats.video_font_size - ); + menu_widgets_msg_queue_push(task, msg, duration, NULL, (enum message_queue_icon)MESSAGE_QUEUE_CATEGORY_INFO, (enum message_queue_category)MESSAGE_QUEUE_ICON_DEFAULT, prio, flush); runloop_msg_queue_unlock(); } else @@ -26656,8 +26646,7 @@ void runloop_msg_queue_push(const char *msg, { menu_widgets_msg_queue_push(NULL, msg, roundf((float)duration / 60.0f * 1000.0f), - title, icon, category, prio, flush, - configuration_settings->floats.video_font_size); + title, icon, category, prio, flush); duration = duration * 60 / 1000; } else @@ -27158,9 +27147,7 @@ static enum runloop_state runloop_check_state(void) if (menu_widgets_inited) { runloop_msg_queue_lock(); - menu_widgets_iterate( - settings->floats.video_font_size, - video_driver_width, video_driver_height); + menu_widgets_iterate(video_driver_width, video_driver_height); runloop_msg_queue_unlock(); } #endif From d02dbcfeddc0522972b0f5689a40238d2e5564a0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 14:18:30 +0100 Subject: [PATCH 32/75] Update CHANGES.md --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 70fbf11674..d6e7fdf33d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ - CHEEVOS: Don't block Sameboy core because it only exposes some memory - CHEEVOS: Support for extended Sega CD memory - CHEEVOS: Show RetroAchievements Hash in content information list +- CHEEVOS: If the core says it's exposing SYSTEM_RAM, give it the benefit of the doubt - DISK CONTROL: Add disk labels to 'disk inserted' notifications - EMSCRIPTEN: Recreate input event listeners properly - FFMPEG CORE: Fix crash on seeking when using HW decoding in some cases @@ -12,6 +13,7 @@ - LOCALIZATION: Update Polish translation - LOCALIZATION: Update Spanish translation - MENU/WIDGETS: Allow notifications to use full screen width when not displaying menu +- MENU/OZONE: Add DPI-based scaling - NETPLAY/MENU/BUGFIX: Fix Netplay Stateless Mode doesn't save. Affects other netplay settings which can be overridden by commandline option - NETPLAY/ROOMS/BUGFIX: Prevent out-of-bounds array indexing when displaying/selecting netplay rooms in menus - VIDEO: Set hardware 'Bilinear filtering' off by default From 732fe2e99601ff5f5ed1308ffcd5a079bb7634bc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 17:01:06 +0100 Subject: [PATCH 33/75] Simplify menu_shader_manager_set_preset --- menu/menu_shader.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/menu/menu_shader.c b/menu/menu_shader.c index 9689cb8f89..16975ec230 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -168,24 +168,12 @@ bool menu_shader_manager_set_preset(struct video_shader *shader, bool ret = false; if (apply && !retroarch_apply_shader(type, preset_path, true)) - { - /* We don't want to disable shaders entirely here, - * just reset number of passes - * > Note: Disabling shaders at this point would in - * fact be dangerous, since it changes the number of - * entries in the shader options menu which can in - * turn lead to the menu selection pointer going out - * of bounds. This causes undefined behaviour/segfaults */ - menu_shader_manager_clear_num_passes(shader); - command_event(CMD_EVENT_SHADER_PRESET_LOADED, NULL); - return false; - } + goto clear; if (string_is_empty(preset_path)) { - menu_shader_manager_clear_num_passes(shader); - command_event(CMD_EVENT_SHADER_PRESET_LOADED, NULL); - return true; + ret = true; + goto clear; } if (!shader) @@ -220,6 +208,18 @@ end: menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); #endif return ret; + +clear: + /* We don't want to disable shaders entirely here, + * just reset number of passes + * > Note: Disabling shaders at this point would in + * fact be dangerous, since it changes the number of + * entries in the shader options menu which can in + * turn lead to the menu selection pointer going out + * of bounds. This causes undefined behaviour/segfaults */ + menu_shader_manager_clear_num_passes(shader); + command_event(CMD_EVENT_SHADER_PRESET_LOADED, NULL); + return ret; } static bool menu_shader_manager_save_preset_internal( From 2f64329c98a1e2844aa6ab330ec015245eabf589 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 17:04:49 +0100 Subject: [PATCH 34/75] Cleanups --- menu/menu_shader.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/menu/menu_shader.c b/menu/menu_shader.c index 16975ec230..e12b82070d 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -204,9 +204,7 @@ bool menu_shader_manager_set_preset(struct video_shader *shader, end: command_event(CMD_EVENT_SHADER_PRESET_LOADED, NULL); -#ifdef HAVE_MENU menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); -#endif return ret; clear: @@ -548,9 +546,7 @@ int menu_shader_manager_clear_num_passes(struct video_shader *shader) shader->passes = 0; -#ifdef HAVE_MENU menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); -#endif video_shader_resolve_parameters(NULL, shader); @@ -647,7 +643,7 @@ enum rarch_shader_type menu_shader_manager_get_type( if (type == RARCH_SHADER_NONE) { type = video_shader_parse_type(shader->pass[0].source.path); - i = 1; + i = 1; } for (; i < shader->passes; i++) From 5cb7d29c17f17fb792b47c6d42f427dc432d8a59 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 17:11:57 +0100 Subject: [PATCH 35/75] Style nits --- menu/widgets/menu_input_bind_dialog.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/menu/widgets/menu_input_bind_dialog.c b/menu/widgets/menu_input_bind_dialog.c index e25f44de2e..8281fe0083 100644 --- a/menu/widgets/menu_input_bind_dialog.c +++ b/menu/widgets/menu_input_bind_dialog.c @@ -628,7 +628,7 @@ bool menu_input_key_bind_iterate(menu_input_ctx_bind_t *bind) /*keep resetting bind during the hold period, or we'll potentially bind joystick and mouse, etc.*/ binds.buffer = *( binds.output ); - if ( menu_input_key_bind_poll_find_hold( &binds, &binds.buffer ) ) + if (menu_input_key_bind_poll_find_hold(&binds, &binds.buffer)) { /*inhibit timeout*/ rarch_timer_begin_new_time( &binds.timer_timeout, settings->uints.input_bind_timeout ); @@ -642,10 +642,8 @@ bool menu_input_key_bind_iterate(menu_input_ctx_bind_t *bind) menu_input_binds.begin - MENU_SETTINGS_BIND_BEGIN ) ); /*hold complete?*/ - if ( rarch_timer_has_expired( &binds.timer_hold ) ) - { + if (rarch_timer_has_expired(&binds.timer_hold)) complete = true; - } } else { @@ -655,7 +653,7 @@ bool menu_input_key_bind_iterate(menu_input_ctx_bind_t *bind) #else - if ( ( binds.skip && !menu_input_binds.skip ) || + if ((binds.skip && !menu_input_binds.skip) || menu_input_key_bind_poll_find_trigger( &menu_input_binds, &binds, &( binds.buffer ) ) ) { complete = true; @@ -663,7 +661,7 @@ bool menu_input_key_bind_iterate(menu_input_ctx_bind_t *bind) #endif - if ( complete ) + if (complete) { input_driver_t *input_drv = input_get_ptr(); @@ -678,7 +676,7 @@ bool menu_input_key_bind_iterate(menu_input_ctx_bind_t *bind) binds.begin++; - if ( binds.begin > binds.last ) + if (binds.begin > binds.last) { input_keyboard_ctl( RARCH_INPUT_KEYBOARD_CTL_CANCEL_WAIT_KEYS, NULL ); return true; From 7090de541ad2143a60000f4ccaf70cd69a1d0973 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 17:26:11 +0100 Subject: [PATCH 36/75] - Merge runahead/mylist.c into retroarch.c - General cleanups --- Makefile.common | 1 - gfx/display_servers/dispserv_android.c | 36 +----- griffin/griffin.c | 4 - retroarch.c | 145 +++++++++++++++++++-- runahead/mylist.c | 167 ------------------------- runahead/mylist.h | 40 ------ 6 files changed, 141 insertions(+), 252 deletions(-) delete mode 100644 runahead/mylist.c delete mode 100644 runahead/mylist.h diff --git a/Makefile.common b/Makefile.common index 1222bef126..535cfd9d4b 100644 --- a/Makefile.common +++ b/Makefile.common @@ -282,7 +282,6 @@ endif ifeq ($(HAVE_RUNAHEAD), 1) DEFINES += -DHAVE_RUNAHEAD - OBJ += runahead/mylist.o endif ifeq ($(HAVE_CC_RESAMPLER), 1) diff --git a/gfx/display_servers/dispserv_android.c b/gfx/display_servers/dispserv_android.c index a77861347a..4b4072d1ba 100644 --- a/gfx/display_servers/dispserv_android.c +++ b/gfx/display_servers/dispserv_android.c @@ -19,30 +19,11 @@ #include "../video_display_server.h" #include "../../frontend/drivers/platform_unix.h" -static void* android_display_server_init(void) -{ - return NULL; -} - -static void android_display_server_destroy(void *data) -{ - (void)data; -} - -static bool android_display_server_set_window_opacity(void *data, unsigned opacity) -{ - (void)data; - (void)opacity; - return true; -} - -static bool android_display_server_set_window_progress(void *data, int progress, bool finished) -{ - (void)data; - (void)progress; - (void)finished; - return true; -} +static void* android_display_server_init(void) { return NULL; } +static void android_display_server_destroy(void *data) { } +static bool android_display_server_set_window_opacity(void *data, unsigned opacity) { return true; } +static bool android_display_server_set_window_progress(void *data, int progress, bool finished) { return true; } +static uint32_t android_display_server_get_flags(void *data) { return 0; } static void android_display_server_set_screen_orientation(enum rotation rotation) { @@ -56,13 +37,6 @@ static void android_display_server_set_screen_orientation(enum rotation rotation g_android->setScreenOrientation, rotation); } -static uint32_t android_display_server_get_flags(void *data) -{ - uint32_t flags = 0; - - return flags; -} - const video_display_server_t dispserv_android = { android_display_server_init, android_display_server_destroy, diff --git a/griffin/griffin.c b/griffin/griffin.c index f4cc840c64..f22cf24390 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -1379,10 +1379,6 @@ MENU #include "../libretro-common/net/net_http_parse.c" #endif -#ifdef HAVE_RUNAHEAD -#include "../runahead/mylist.c" -#endif - /*============================================================ DEPENDENCIES ============================================================ */ diff --git a/retroarch.c b/retroarch.c index c2966d6028..75138a9c75 100644 --- a/retroarch.c +++ b/retroarch.c @@ -223,10 +223,6 @@ #include "retroarch.h" -#ifdef HAVE_RUNAHEAD -#include "runahead/mylist.h" -#endif - #ifdef HAVE_ACCESSIBILITY #include "accessibility.h" #endif @@ -3239,6 +3235,18 @@ static bool request_fast_savestate = false; static bool hard_disable_audio = false; /* Save State List for Run Ahead */ +typedef void *(*constructor_t)(void); +typedef void (*destructor_t )(void*); + +typedef struct MyList_t +{ + void **data; + int capacity; + int size; + constructor_t constructor; + destructor_t destructor; +} MyList; + static MyList *runahead_save_state_list = NULL; static MyList *input_state_list = NULL; @@ -23690,14 +23698,133 @@ bool driver_ctl(enum driver_ctl_state state, void *data) /* RUNAHEAD */ #ifdef HAVE_RUNAHEAD +static void mylist_resize(MyList *list, int new_size, bool run_constructor) +{ + int i; + int new_capacity; + int old_size; + void *element = NULL; + if (new_size < 0) + new_size = 0; + if (!list) + return; + new_capacity = new_size; + old_size = list->size; + + if (new_size == old_size) + return; + + if (new_size > list->capacity) + { + if (new_capacity < list->capacity * 2) + new_capacity = list->capacity * 2; + + /* try to realloc */ + list->data = (void**)realloc( + (void*)list->data, new_capacity * sizeof(void*)); + + for (i = list->capacity; i < new_capacity; i++) + list->data[i] = NULL; + + list->capacity = new_capacity; + } + + if (new_size <= list->size) + { + for (i = new_size; i < list->size; i++) + { + element = list->data[i]; + + if (element) + { + list->destructor(element); + list->data[i] = NULL; + } + } + } + else + { + for (i = list->size; i < new_size; i++) + { + list->data[i] = NULL; + if (run_constructor) + list->data[i] = list->constructor(); + } + } + + list->size = new_size; +} + +static void *mylist_add_element(MyList *list) +{ + int old_size; + + if (!list) + return NULL; + + old_size = list->size; + mylist_resize(list, old_size + 1, true); + return list->data[old_size]; +} + +static void mylist_destroy(MyList **list_p) +{ + MyList *list = NULL; + if (!list_p) + return; + + list = *list_p; + + if (list) + { + mylist_resize(list, 0, false); + free(list->data); + free(list); + *list_p = NULL; + } +} + + +static void mylist_create(MyList **list_p, int initial_capacity, + constructor_t constructor, destructor_t destructor) +{ + MyList *list = NULL; + + if (!list_p) + return; + + if (initial_capacity < 0) + initial_capacity = 0; + + list = *list_p; + if (list) + mylist_destroy(list_p); + + list = (MyList*)malloc(sizeof(MyList)); + *list_p = list; + list->size = 0; + list->constructor = constructor; + list->destructor = destructor; + + if (initial_capacity > 0) + { + list->data = (void**)calloc(initial_capacity, sizeof(void*)); + list->capacity = initial_capacity; + } + else + { + list->data = NULL; + list->capacity = 0; + } +} static void *input_list_element_constructor(void) { - void *ptr = calloc(1, sizeof(input_list_element)); - input_list_element *element = (input_list_element*)ptr; + void *ptr = calloc(1, sizeof(input_list_element)); + input_list_element *element = (input_list_element*)ptr; - element->state_size = 256; - element->state = (int16_t*)calloc( + element->state_size = 256; + element->state = (int16_t*)calloc( element->state_size, sizeof(int16_t)); return ptr; @@ -24028,7 +24155,7 @@ static bool runahead_create(void) static bool runahead_save_state(void) { retro_ctx_serialize_info_t *serialize_info; - bool okay = false; + bool okay = false; if (!runahead_save_state_list) return false; diff --git a/runahead/mylist.c b/runahead/mylist.c deleted file mode 100644 index 20bfd91b0d..0000000000 --- a/runahead/mylist.c +++ /dev/null @@ -1,167 +0,0 @@ -#include -#include - -#include "mylist.h" - -void mylist_resize(MyList *list, int new_size, bool run_constructor) -{ - int new_capacity; - int old_size; - int i; - void *element = NULL; - if (new_size < 0) - new_size = 0; - if (!list) - return; - new_capacity = new_size; - old_size = list->size; - - if (new_size == old_size) - return; - - if (new_size > list->capacity) - { - if (new_capacity < list->capacity * 2) - new_capacity = list->capacity * 2; - - /* try to realloc */ - list->data = (void**)realloc( - (void*)list->data, new_capacity * sizeof(void*)); - - for (i = list->capacity; i < new_capacity; i++) - list->data[i] = NULL; - - list->capacity = new_capacity; - } - - if (new_size <= list->size) - { - for (i = new_size; i < list->size; i++) - { - element = list->data[i]; - - if (element) - { - list->destructor(element); - list->data[i] = NULL; - } - } - } - else - { - for (i = list->size; i < new_size; i++) - { - if (run_constructor) - list->data[i] = list->constructor(); - else - list->data[i] = NULL; - } - } - - list->size = new_size; -} - -void *mylist_add_element(MyList *list) -{ - int old_size; - - if (!list) - return NULL; - - old_size = list->size; - mylist_resize(list, old_size + 1, true); - return list->data[old_size]; -} - -void mylist_create(MyList **list_p, int initial_capacity, - constructor_t constructor, destructor_t destructor) -{ - MyList *list = NULL; - - if (!list_p) - return; - - if (initial_capacity < 0) - initial_capacity = 0; - - list = *list_p; - if (list) - mylist_destroy(list_p); - - list = (MyList*)malloc(sizeof(MyList)); - *list_p = list; - list->size = 0; - list->constructor = constructor; - list->destructor = destructor; - - if (initial_capacity > 0) - { - list->data = (void**)calloc(initial_capacity, sizeof(void*)); - list->capacity = initial_capacity; - } - else - { - list->data = NULL; - list->capacity = 0; - } -} - -void mylist_destroy(MyList **list_p) -{ - MyList *list = NULL; - if (!list_p) - return; - - list = *list_p; - - if (list) - { - mylist_resize(list, 0, false); - free(list->data); - free(list); - *list_p = NULL; - } -} - -void mylist_assign(MyList *list, int index, void *value) -{ - void *old_element = NULL; - - if (index < 0 || index >= list->size) - return; - - old_element = list->data[index]; - list->destructor(old_element); - list->data[index] = value; -} - -void mylist_remove_at(MyList *list, int index) -{ - int i; - - if (index < 0 || index >= list->size) - return; - - mylist_assign(list, index, NULL); - - for (i = index + 1; i < list->size; i++) - list->data[i - 1] = list->data[i]; - - list->size--; - list->data[list->size] = NULL; -} - -void mylist_pop_front(MyList *list) -{ - mylist_remove_at(list, 0); -} - -void mylist_push_back(MyList *list, void *value) -{ - int old_size; - if (!list) - return; - old_size = list->size; - mylist_resize(list, old_size + 1, false); - list->data[old_size] = value; -} diff --git a/runahead/mylist.h b/runahead/mylist.h deleted file mode 100644 index cdc03efab0..0000000000 --- a/runahead/mylist.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef __MYLIST_H__ -#define __MYLIST_H__ - -#include -#include -#include -#include - -RETRO_BEGIN_DECLS - -typedef void *(*constructor_t)(void); -typedef void (*destructor_t )(void*); - -typedef struct MyList_t -{ - void **data; - int capacity; - int size; - constructor_t constructor; - destructor_t destructor; -} MyList; - -void *mylist_add_element(MyList *list); - -void mylist_resize(MyList *list, int newSize, bool run_constructor); - -void mylist_create(MyList **list_p, int initial_capacity, - constructor_t constructor, destructor_t destructor); - -void mylist_destroy(MyList **list_p); - -void mylist_assign(MyList *list, int index, void *value); - -void mylist_remove_at(MyList *list, int index); - -void mylist_pop_front(MyList *list); - -RETRO_END_DECLS - -#endif From a0ab7ab6fc23868484364a04f47c5aa7fcf22b6c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 18:13:21 +0100 Subject: [PATCH 37/75] (Menu) Cleanups --- menu/cbs/menu_cbs_sublabel.c | 38 ++++++++++++--- menu/cbs/menu_cbs_title.c | 91 ++++++++++++++++++++---------------- 2 files changed, 84 insertions(+), 45 deletions(-) diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index bfe7604fdf..88ce152d8f 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -2018,34 +2018,47 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, break; case MENU_ENUM_LABEL_THUMBNAILS: settings = config_get_ptr(); +#ifdef HAVE_RGUI if (string_is_equal(settings->arrays.menu_driver, "rgui")) { BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_thumbnails_rgui); } - else if (string_is_equal(settings->arrays.menu_driver, "glui")) + else +#endif +#ifdef HAVE_MATERIALUI + if (string_is_equal(settings->arrays.menu_driver, "glui")) { BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_thumbnails_materialui); } else +#endif { BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_thumbnails); } break; case MENU_ENUM_LABEL_LEFT_THUMBNAILS: settings = config_get_ptr(); +#ifdef HAVE_RGUI if (string_is_equal(settings->arrays.menu_driver, "rgui")) { BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_left_thumbnails_rgui); } - else if (string_is_equal(settings->arrays.menu_driver, "ozone")) + else +#endif +#ifdef HAVE_OZONE + if (string_is_equal(settings->arrays.menu_driver, "ozone")) { BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_left_thumbnails_ozone); } - else if (string_is_equal(settings->arrays.menu_driver, "glui")) + else +#endif +#ifdef HAVE_MATERIALUI + if (string_is_equal(settings->arrays.menu_driver, "glui")) { BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_left_thumbnails_materialui); } else +#endif { BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_left_thumbnails); } @@ -2798,15 +2811,20 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_PLAYLIST_MANAGER_RIGHT_THUMBNAIL_MODE: settings = config_get_ptr(); /* Uses same sublabels as MENU_ENUM_LABEL_THUMBNAILS */ +#ifdef HAVE_RGUI if (string_is_equal(settings->arrays.menu_driver, "rgui")) { BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_thumbnails_rgui); } - else if (string_is_equal(settings->arrays.menu_driver, "glui")) + else +#endif +#ifdef HAVE_MATERIALUI + if (string_is_equal(settings->arrays.menu_driver, "glui")) { BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_thumbnails_materialui); } else +#endif { BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_thumbnails); } @@ -2814,19 +2832,27 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_PLAYLIST_MANAGER_LEFT_THUMBNAIL_MODE: settings = config_get_ptr(); /* Uses same sublabels as MENU_ENUM_LABEL_LEFT_THUMBNAILS */ +#ifdef HAVE_RGUI if (string_is_equal(settings->arrays.menu_driver, "rgui")) { BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_left_thumbnails_rgui); } - else if (string_is_equal(settings->arrays.menu_driver, "ozone")) + else +#endif +#ifdef HAVE_OZONE + if (string_is_equal(settings->arrays.menu_driver, "ozone")) { BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_left_thumbnails_ozone); } - else if (string_is_equal(settings->arrays.menu_driver, "glui")) + else +#endif +#ifdef HAVE_MATERIALUI + if (string_is_equal(settings->arrays.menu_driver, "glui")) { BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_left_thumbnails_materialui); } else +#endif { BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_left_thumbnails); } diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index 076cd8df18..ee6f6543d3 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -89,17 +89,23 @@ static int action_get_title_remap_port(const char *path, const char *label, } static int action_get_title_thumbnails( - const char *path, const char *label, unsigned menu_type, char *s, size_t len) + const char *path, const char *label, unsigned menu_type, + char *s, size_t len) { - settings_t *settings = config_get_ptr(); const char *title = NULL; enum msg_hash_enums label_value = MENU_ENUM_LABEL_VALUE_THUMBNAILS; - +#if defined(HAVE_RGUI) || defined(HAVE_MATERIALUI) + settings_t *settings = config_get_ptr(); /* Get label value */ +#ifdef HAVE_RGUI if (string_is_equal(settings->arrays.menu_driver, "rgui")) label_value = MENU_ENUM_LABEL_VALUE_THUMBNAILS_RGUI; - else if (string_is_equal(settings->arrays.menu_driver, "glui")) +#endif +#ifdef HAVE_MATERIALUI + if (string_is_equal(settings->arrays.menu_driver, "glui")) label_value = MENU_ENUM_LABEL_VALUE_THUMBNAILS_MATERIALUI; +#endif +#endif title = msg_hash_to_str(label_value); @@ -113,19 +119,27 @@ static int action_get_title_thumbnails( } static int action_get_title_left_thumbnails( - const char *path, const char *label, unsigned menu_type, char *s, size_t len) + const char *path, const char *label, unsigned menu_type, + char *s, size_t len) { - settings_t *settings = config_get_ptr(); const char *title = NULL; enum msg_hash_enums label_value = MENU_ENUM_LABEL_VALUE_LEFT_THUMBNAILS; - +#if defined(HAVE_RGUI) || defined(HAVE_OZONE) || defined(HAVE_MATERIALUI) + settings_t *settings = config_get_ptr(); /* Get label value */ +#ifdef HAVE_RGUI if (string_is_equal(settings->arrays.menu_driver, "rgui")) label_value = MENU_ENUM_LABEL_VALUE_LEFT_THUMBNAILS_RGUI; - else if (string_is_equal(settings->arrays.menu_driver, "ozone")) +#endif +#ifdef HAVE_OZONE + if (string_is_equal(settings->arrays.menu_driver, "ozone")) label_value = MENU_ENUM_LABEL_VALUE_LEFT_THUMBNAILS_OZONE; - else if (string_is_equal(settings->arrays.menu_driver, "glui")) +#endif +#ifdef HAVE_MATERIALUI + if (string_is_equal(settings->arrays.menu_driver, "glui")) label_value = MENU_ENUM_LABEL_VALUE_LEFT_THUMBNAILS_MATERIALUI; +#endif +#endif title = msg_hash_to_str(label_value); @@ -138,7 +152,9 @@ static int action_get_title_left_thumbnails( return 0; } -static int action_get_title_dropdown_item(const char *path, const char *label, unsigned menu_type, char *s, size_t len) +static int action_get_title_dropdown_item( + const char *path, const char *label, unsigned menu_type, + char *s, size_t len) { /* Sanity check */ if (string_is_empty(path)) @@ -158,15 +174,16 @@ static int action_get_title_dropdown_item(const char *path, const char *label, u if (coreopts) { + unsigned i; settings_t *settings = config_get_ptr(); unsigned menu_index = string_to_unsigned(tmp_str_list->elems[(unsigned)tmp_str_list->size - 1].data); unsigned visible_index = 0; unsigned option_index = 0; bool option_found = false; - unsigned i; + bool game_specific_options = settings->bools.game_specific_options; /* Convert menu index to option index */ - if (settings->bools.game_specific_options) + if (game_specific_options) menu_index--; for (i = 0; i < coreopts->size; i++) @@ -186,7 +203,8 @@ static int action_get_title_dropdown_item(const char *path, const char *label, u /* If option was found, title == option description */ if (option_found) { - const char *title = core_option_manager_get_desc(coreopts, option_index); + const char *title = core_option_manager_get_desc( + coreopts, option_index); if (s && !string_is_empty(title)) { @@ -215,7 +233,8 @@ static int action_get_title_dropdown_item(const char *path, const char *label, u * MENU_ENUM_LABEL_VALUE_##STR * to get 'MENU_ENUM_LABEL_VALUE_' from a * 'MENU_ENUM_LABEL_', we therefore add 2... */ - enum msg_hash_enums enum_idx = (enum msg_hash_enums)(string_to_unsigned(path) + 2); + enum msg_hash_enums enum_idx = (enum msg_hash_enums) + (string_to_unsigned(path) + 2); /* Check if enum index is valid * Note: This is a very crude check, but better than nothing */ @@ -225,19 +244,25 @@ static int action_get_title_dropdown_item(const char *path, const char *label, u * MENU_ENUM_LABEL_LEFT_THUMBNAILS require special * treatment, since their titles depend upon the * current menu driver... */ - if (enum_idx == MENU_ENUM_LABEL_VALUE_THUMBNAILS) - return action_get_title_thumbnails(path, label, menu_type, s, len); - else if (enum_idx == MENU_ENUM_LABEL_VALUE_LEFT_THUMBNAILS) - return action_get_title_left_thumbnails(path, label, menu_type, s, len); - else + switch (enum_idx) { - const char *title = msg_hash_to_str(enum_idx); + case MENU_ENUM_LABEL_VALUE_THUMBNAILS: + return action_get_title_thumbnails( + path, label, menu_type, s, len); + case MENU_ENUM_LABEL_VALUE_LEFT_THUMBNAILS: + return action_get_title_left_thumbnails( + path, label, menu_type, s, len); + default: + { + const char *title = msg_hash_to_str(enum_idx); - if (s && !string_is_empty(title)) - { - sanitize_to_string(s, title, len); - return 1; - } + if (s && !string_is_empty(title)) + { + sanitize_to_string(s, title, len); + return 1; + } + } + break; } } } @@ -297,18 +322,6 @@ static int action_get_title_deferred_playlist_list(const char *path, const char return 0; } -static int action_get_title_dropdown_playlist_right_thumbnail_mode_item( - const char *path, const char *label, unsigned menu_type, char *s, size_t len) -{ - return action_get_title_thumbnails(path, label, menu_type, s, len); -} - -static int action_get_title_dropdown_playlist_left_thumbnail_mode_item( - const char *path, const char *label, unsigned menu_type, char *s, size_t len) -{ - return action_get_title_left_thumbnails(path, label, menu_type, s, len); -} - default_title_macro(action_get_quick_menu_override_options, MENU_ENUM_LABEL_VALUE_QUICK_MENU_OVERRIDE_OPTIONS) default_title_macro(action_get_user_accounts_cheevos_list, MENU_ENUM_LABEL_VALUE_ACCOUNTS_RETRO_ACHIEVEMENTS) default_title_macro(action_get_user_accounts_youtube_list, MENU_ENUM_LABEL_VALUE_ACCOUNTS_YOUTUBE) @@ -1474,8 +1487,8 @@ int menu_cbs_init_bind_title(menu_file_list_cbs_t *cbs, {MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_VIDEO_SHADER_NUM_PASSES, action_get_title_dropdown_video_shader_num_pass_item }, {MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_DEFAULT_CORE, action_get_title_dropdown_playlist_default_core_item}, {MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_LABEL_DISPLAY_MODE, action_get_title_dropdown_playlist_label_display_mode_item}, - {MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_RIGHT_THUMBNAIL_MODE, action_get_title_dropdown_playlist_right_thumbnail_mode_item}, - {MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_LEFT_THUMBNAIL_MODE, action_get_title_dropdown_playlist_left_thumbnail_mode_item}, + {MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_RIGHT_THUMBNAIL_MODE, action_get_title_thumbnails}, + {MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_LEFT_THUMBNAIL_MODE, action_get_title_left_thumbnails}, {MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_MANUAL_CONTENT_SCAN_SYSTEM_NAME, action_get_title_dropdown_manual_content_scan_system_name_item}, {MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_MANUAL_CONTENT_SCAN_CORE_NAME, action_get_title_dropdown_manual_content_scan_core_name_item}, {MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_DISK_INDEX, action_get_title_dropdown_disk_index}, From d645478f89cd6f1493c0a60095429274440fa450 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 18:19:04 +0100 Subject: [PATCH 38/75] Cleanups --- menu/drivers/materialui.c | 41 ++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 3b4670fdff..0cadf92c1c 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -2271,6 +2271,9 @@ static void materialui_render(void *data, unsigned width, unsigned height, bool is_idle) { + size_t i; + float bottom; + float scale_factor; settings_t *settings = config_get_ptr(); materialui_handle_t *mui = (materialui_handle_t*)data; unsigned header_height = menu_display_get_header_height(); @@ -2278,9 +2281,6 @@ static void materialui_render(void *data, file_list_t *list = menu_entries_get_selection_buf_ptr(0); bool first_entry_found = false; bool last_entry_found = false; - size_t i; - float bottom; - float scale_factor; if (!settings || !mui || !list) return; @@ -2499,21 +2499,26 @@ static void materialui_render(void *data, if ((mui->list_view_type != MUI_LIST_VIEW_DEFAULT) && (mui->list_view_type != MUI_LIST_VIEW_PLAYLIST)) { - bool on_screen = first_entry_found && !last_entry_found; + bool on_screen = + first_entry_found && !last_entry_found; + unsigned thumbnail_upscale_threshold = + settings->uints.menu_thumbnail_upscale_threshold; + bool network_on_demand_thumbnails = + settings->bools.network_on_demand_thumbnails; if (mui->secondary_thumbnail_enabled) menu_thumbnail_process_streams( mui->thumbnail_path_data, mui->playlist, i, &node->thumbnails.primary, &node->thumbnails.secondary, on_screen, - settings->uints.menu_thumbnail_upscale_threshold, - settings->bools.network_on_demand_thumbnails); + thumbnail_upscale_threshold, + network_on_demand_thumbnails); else menu_thumbnail_process_stream( mui->thumbnail_path_data, MENU_THUMBNAIL_RIGHT, mui->playlist, i, &node->thumbnails.primary, on_screen, - settings->uints.menu_thumbnail_upscale_threshold, - settings->bools.network_on_demand_thumbnails); + thumbnail_upscale_threshold, + network_on_demand_thumbnails); } else if (last_entry_found) break; @@ -5915,16 +5920,16 @@ static void materialui_populate_nav_bar( static void materialui_init_transition_animation( materialui_handle_t *mui, settings_t *settings) { + menu_animation_ctx_entry_t alpha_entry; + menu_animation_ctx_entry_t x_offset_entry; size_t stack_size = materialui_list_get_size(mui, MENU_LIST_PLAIN); menu_animation_ctx_tag alpha_tag = (uintptr_t)&mui->transition_alpha; menu_animation_ctx_tag x_offset_tag = (uintptr_t)&mui->transition_x_offset; - menu_animation_ctx_entry_t alpha_entry; - menu_animation_ctx_entry_t x_offset_entry; + unsigned transition_animation = settings->uints.menu_materialui_transition_animation; /* If animations are disabled, reset alpha/x offset * values and return immediately */ - if (settings->uints.menu_materialui_transition_animation == - MATERIALUI_TRANSITION_ANIM_NONE) + if (transition_animation == MATERIALUI_TRANSITION_ANIM_NONE) { mui->transition_alpha = 1.0f; mui->transition_x_offset = 0.0f; @@ -5966,29 +5971,25 @@ static void materialui_init_transition_animation( * - We apply a standard 'back' animation here */ if (mui->menu_stack_flushed) { - if (settings->uints.menu_materialui_transition_animation != - MATERIALUI_TRANSITION_ANIM_FADE) + if (transition_animation != MATERIALUI_TRANSITION_ANIM_FADE) mui->transition_x_offset = -1.0f; } /* >> Menu 'forward' action */ else if (stack_size > mui->last_stack_size) { - if (settings->uints.menu_materialui_transition_animation == - MATERIALUI_TRANSITION_ANIM_SLIDE) + if (transition_animation == MATERIALUI_TRANSITION_ANIM_SLIDE) mui->transition_x_offset = 1.0f; } /* >> Menu 'back' action */ else if (stack_size < mui->last_stack_size) { - if (settings->uints.menu_materialui_transition_animation == - MATERIALUI_TRANSITION_ANIM_SLIDE) + if (transition_animation == MATERIALUI_TRANSITION_ANIM_SLIDE) mui->transition_x_offset = -1.0f; } /* >> Menu tab 'switch' action - using navigation * bar to switch between top level menus */ else if ((stack_size == 1) && - (settings->uints.menu_materialui_transition_animation != - MATERIALUI_TRANSITION_ANIM_FADE)) + (transition_animation != MATERIALUI_TRANSITION_ANIM_FADE)) { /* We're not changing menu levels here, so set * slide to match horizontal list 'movement' From e8a2a39d7229d1fd59eb58c8d74d0b671f4f7934 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Thu, 13 Feb 2020 17:26:16 +0000 Subject: [PATCH 39/75] (Menu Widgets) Add scaling --- intl/msg_hash_lbl.h | 2 + intl/msg_hash_us.h | 8 + menu/cbs/menu_cbs_sublabel.c | 11 +- menu/menu_driver.c | 39 ++++ menu/menu_driver.h | 1 + menu/menu_setting.c | 19 +- menu/widgets/menu_widgets.c | 350 ++++++++++++++++++++++------------- menu/widgets/menu_widgets.h | 11 +- msg_hash.h | 1 + retroarch.c | 16 +- 10 files changed, 322 insertions(+), 136 deletions(-) diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index 766ba2ebd1..b56bede3ca 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -502,6 +502,8 @@ MSG_HASH(MENU_ENUM_LABEL_CONTENT_DIR, "content_directory") MSG_HASH(MENU_ENUM_LABEL_MENU_SCALE_FACTOR, "menu_scale_factor") +MSG_HASH(MENU_ENUM_LABEL_MENU_WIDGET_SCALE_FACTOR, + "menu_widget_scale_factor") MSG_HASH(MENU_ENUM_LABEL_DRIVER_SETTINGS, "driver_settings") MSG_HASH(MENU_ENUM_LABEL_CHECK_FOR_MISSING_FIRMWARE, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 303938d078..2e11fd698d 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -916,6 +916,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_MENU_SCALE_FACTOR, "Applies a global scaling factor when drawing the menu. Can be used to increase or decrease the size of the user interface." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_MENU_WIDGET_SCALE_FACTOR, + "Menu Widget Scale Factor" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_MENU_WIDGET_SCALE_FACTOR, + "Applies a scaling factor when drawing menu widgets. Can be used to increase or decrease the size of decorated notifications, indicators and controls." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_DRIVER_SETTINGS, "Drivers" diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 88ce152d8f..a2c5935906 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -523,6 +523,7 @@ default_sublabel_macro(action_bind_sublabel_ozone_truncate_playlist_name, default_sublabel_macro(action_bind_sublabel_ozone_scroll_content_metadata, MENU_ENUM_SUBLABEL_OZONE_SCROLL_CONTENT_METADATA) default_sublabel_macro(action_bind_sublabel_menu_use_preferred_system_color_theme, MENU_ENUM_SUBLABEL_MENU_USE_PREFERRED_SYSTEM_COLOR_THEME) default_sublabel_macro(action_bind_sublabel_menu_scale_factor, MENU_ENUM_SUBLABEL_MENU_SCALE_FACTOR) +default_sublabel_macro(action_bind_sublabel_menu_widget_scale_factor, MENU_ENUM_SUBLABEL_MENU_WIDGET_SCALE_FACTOR) default_sublabel_macro(action_bind_sublabel_menu_wallpaper_opacity, MENU_ENUM_SUBLABEL_MENU_WALLPAPER_OPACITY) default_sublabel_macro(action_bind_sublabel_menu_framebuffer_opacity, MENU_ENUM_SUBLABEL_MENU_FRAMEBUFFER_OPACITY) default_sublabel_macro(action_bind_sublabel_menu_horizontal_animation, MENU_ENUM_SUBLABEL_MENU_HORIZONTAL_ANIMATION) @@ -1740,7 +1741,15 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_xmb_animation_opening_main_menu); break; case MENU_ENUM_LABEL_MENU_SCALE_FACTOR: - BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_scale_factor); + settings = config_get_ptr(); + if (string_is_equal(settings->arrays.menu_driver, "rgui")) + { + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_widget_scale_factor); + } + else + { + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_scale_factor); + } break; case MENU_ENUM_LABEL_MENU_WALLPAPER_OPACITY: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_wallpaper_opacity); diff --git a/menu/menu_driver.c b/menu/menu_driver.c index cfa5f9d14e..a163e523aa 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -2045,6 +2045,45 @@ void menu_display_unset_framebuffer_dirty_flag(void) menu_display_framebuf_dirty = false; } +float menu_display_get_pixel_scale(unsigned width, unsigned height) +{ + static unsigned last_width = 0; + static unsigned last_height = 0; + static float scale = 0.0f; + static bool scale_cached = false; + settings_t *settings = config_get_ptr(); + + /* We need to perform a square root here, which + * can be slow on some platforms (not *slow*, but + * it involves enough work that it's worth trying + * to optimise). We therefore cache the pixel scale, + * and only update on first run or when the video + * size changes */ + if (!scale_cached || + (width != last_width) || + (height != last_height)) + { + /* Baseline reference is a 1080p display */ + scale = (float)( + sqrt((double)((width * width) + (height * height))) / + DIAGONAL_PIXELS_1080P); + + scale_cached = true; + last_width = width; + last_height = height; + } + + /* Apply user scaling factor */ + if (settings) + { + float menu_scale_factor = settings->floats.menu_scale_factor; + return scale * ((menu_scale_factor > 0.0001f) ? + menu_scale_factor : 1.0f); + } + + return scale; +} + float menu_display_get_dpi_scale(unsigned width, unsigned height) { static unsigned last_width = 0; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index b25593343c..1537ecf636 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -594,6 +594,7 @@ void menu_display_unset_viewport(unsigned width, unsigned height); bool menu_display_get_framebuffer_dirty_flag(void); void menu_display_set_framebuffer_dirty_flag(void); void menu_display_unset_framebuffer_dirty_flag(void); +float menu_display_get_pixel_scale(unsigned width, unsigned height); float menu_display_get_dpi_scale(unsigned width, unsigned height); bool menu_display_init_first_driver(bool video_is_threaded); bool menu_display_restore_clear_color(void); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 359beba8cf..fa48f8edbc 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -12844,15 +12844,29 @@ static bool setting_append_list( START_SUB_GROUP(list, list_info, "Display", &group_info, &subgroup_info, parent_group); - /* Only implemented for GLUI, XMB and Ozone at present */ + /* > MaterialUI, XMB and Ozone all support menu scaling + * > RGUI does not, but since scale factor is also used + * for menu widgets, show the setting if widgets are + * enabled */ if (string_is_equal(settings->arrays.menu_driver, "glui") || string_is_equal(settings->arrays.menu_driver, "xmb") || +#ifdef HAVE_MENU_WIDGETS + string_is_equal(settings->arrays.menu_driver, "ozone") || + (string_is_equal(settings->arrays.menu_driver, "rgui") && + settings->bools.menu_enable_widgets)) +#else string_is_equal(settings->arrays.menu_driver, "ozone")) +#endif + { + enum msg_hash_enums menu_scale_factor_label_value = + string_is_equal(settings->arrays.menu_driver, "rgui") ? + MENU_ENUM_LABEL_VALUE_MENU_WIDGET_SCALE_FACTOR : MENU_ENUM_LABEL_VALUE_MENU_SCALE_FACTOR; + CONFIG_FLOAT( list, list_info, &settings->floats.menu_scale_factor, MENU_ENUM_LABEL_MENU_SCALE_FACTOR, - MENU_ENUM_LABEL_VALUE_MENU_SCALE_FACTOR, + menu_scale_factor_label_value, DEFAULT_MENU_SCALE_FACTOR, "%.2fx", &group_info, @@ -12862,6 +12876,7 @@ static bool setting_append_list( general_read_handler); (*list)[list_info->index - 1].action_ok = &setting_action_ok_uint; menu_settings_list_current_add_range(list, list_info, 0.2, 5.0, 0.01, true, true); + } #ifdef HAVE_XMB if (string_is_equal(settings->arrays.menu_driver, "xmb")) diff --git a/menu/widgets/menu_widgets.c b/menu/widgets/menu_widgets.c index 2a4769d15f..088bba96ed 100644 --- a/menu/widgets/menu_widgets.c +++ b/menu/widgets/menu_widgets.c @@ -289,10 +289,16 @@ static unsigned libretro_message_width = 0; static char libretro_message[LIBRETRO_MESSAGE_SIZE] = {'\0'}; /* Metrics */ +#define BASE_FONT_SIZE 32.0f +#define OZONE_SIDEBAR_WIDTH 408 + +static bool is_ozone; +static bool is_xmb; + +static float widget_font_size; static unsigned simple_widget_padding = 0; static unsigned simple_widget_height; static unsigned glyph_width; -static unsigned line_height; static unsigned msg_queue_height; static unsigned msg_queue_icon_size_x; @@ -316,6 +322,16 @@ static unsigned msg_queue_task_hourglass_x; static unsigned generic_message_height; /* used for both generic and libretro messages */ +static unsigned load_content_animation_icon_size_initial; +static unsigned load_content_animation_icon_size_target; + +static unsigned divider_width_1px; + +static unsigned last_video_width; +static unsigned last_video_height; +static float last_scale_factor; +static float capped_scale_factor; + static void msg_widget_msg_transition_animation_done(void *userdata) { menu_widget_msg_t *msg = (menu_widget_msg_t*) userdata; @@ -423,9 +439,8 @@ void menu_widgets_msg_queue_push( unsigned width = menu_driver_is_alive() ? msg_queue_default_rect_width_menu_alive : msg_queue_default_rect_width; unsigned text_width = font_driver_get_message_width(font_regular, title, title_length, msg_queue_text_scale_factor); - settings_t *settings = config_get_ptr(); - msg_widget->text_height = msg_queue_text_scale_factor * settings->floats.video_font_size; + msg_widget->text_height = msg_queue_text_scale_factor * widget_font_size; /* Text is too wide, split it into two lines */ if (text_width > width) @@ -863,10 +878,38 @@ static void menu_widgets_hourglass_tick(void *userdata) menu_animation_push(&entry); } -void menu_widgets_iterate(unsigned width, unsigned height) +/* Forward declaration */ +static void menu_widgets_layout( + bool is_threaded, const char *dir_assets, char *font_path); + +void menu_widgets_iterate( + unsigned width, unsigned height, + const char *dir_assets, char *font_path) { size_t i; + /* Check whether screen dimensions or menu scale + * factor have changed */ + float scale_factor = is_xmb ? + menu_display_get_pixel_scale(width, height) : + menu_display_get_dpi_scale(width, height); + + if ((scale_factor != last_scale_factor) || + (width != last_video_width) || + (height != last_video_height)) + { + last_scale_factor = scale_factor; + last_video_width = width; + last_video_height = height; + + /* Note: We don't need a full context reset here + * > Just rescale layout, and reset frame time counter */ + menu_widgets_layout( + video_driver_is_threaded(), + dir_assets, font_path); + video_driver_monitor_reset(); + } + /* Messages queue */ /* Consume one message if available */ @@ -944,8 +987,6 @@ void menu_widgets_iterate(unsigned width, unsigned height) if (screenshot_filename[0] != '\0') { menu_timer_ctx_entry_t timer; - settings_t *settings = config_get_ptr(); - float video_font_size = settings->floats.video_font_size; video_driver_texture_unload(&screenshot_texture); @@ -953,7 +994,7 @@ void menu_widgets_iterate(unsigned width, unsigned height) "", &screenshot_texture, TEXTURE_FILTER_MIPMAP_LINEAR, &screenshot_texture_width, &screenshot_texture_height); - screenshot_height = video_font_size * 4; + screenshot_height = widget_font_size * 4; screenshot_width = width; screenshot_scale_factor = menu_widgets_get_thumbnail_scale_factor( @@ -1013,8 +1054,6 @@ static int menu_widgets_draw_indicator(video_frame_info_t *video_info, { unsigned height = simple_widget_height; const char *txt = msg_hash_to_str(msg); - settings_t *settings = config_get_ptr(); - float video_font_size = settings->floats.video_font_size; width = font_driver_get_message_width(font_regular, txt, (unsigned)strlen(txt), 1) + simple_widget_padding*2; @@ -1027,7 +1066,7 @@ static int menu_widgets_draw_indicator(video_frame_info_t *video_info, menu_display_draw_text(font_regular, txt, - top_right_x_advance - width + simple_widget_padding, video_font_size + simple_widget_padding/4, + top_right_x_advance - width + simple_widget_padding, widget_font_size + simple_widget_padding/4, video_info->width, video_info->height, 0xFFFFFFFF, TEXT_ALIGN_LEFT, 1.0f, @@ -1054,8 +1093,6 @@ static void menu_widgets_draw_task_msg(menu_widget_msg_t *msg, video_frame_info_ bool draw_msg_new = false; unsigned task_percentage_offset = 0; char task_percentage[256] = {0}; - settings_t *settings = config_get_ptr(); - float video_font_size = settings->floats.video_font_size; if (msg->msg_new) draw_msg_new = !string_is_equal(msg->msg_new, msg->msg); @@ -1143,7 +1180,7 @@ static void menu_widgets_draw_task_msg(menu_widget_msg_t *msg, video_frame_info_ menu_display_draw_text(font_regular, msg->msg_new, msg_queue_task_text_start_x, - video_info->height - msg->offset_y + msg_queue_text_scale_factor * video_font_size + msg_queue_height/4 - video_font_size/2.25f - msg_queue_height/2 + msg->msg_transition_animation, + video_info->height - msg->offset_y + msg_queue_text_scale_factor * widget_font_size + msg_queue_height/4 - widget_font_size/2.25f - msg_queue_height/2 + msg->msg_transition_animation, video_info->width, video_info->height, text_color, TEXT_ALIGN_LEFT, @@ -1157,7 +1194,7 @@ static void menu_widgets_draw_task_msg(menu_widget_msg_t *msg, video_frame_info_ menu_display_draw_text(font_regular, msg->msg, msg_queue_task_text_start_x, - video_info->height - msg->offset_y + msg_queue_text_scale_factor * video_font_size + msg_queue_height/4 - video_font_size/2.25f + msg->msg_transition_animation, + video_info->height - msg->offset_y + msg_queue_text_scale_factor * widget_font_size + msg_queue_height/4 - widget_font_size/2.25f + msg->msg_transition_animation, video_info->width, video_info->height, text_color, TEXT_ALIGN_LEFT, @@ -1180,7 +1217,7 @@ static void menu_widgets_draw_task_msg(menu_widget_msg_t *msg, video_frame_info_ menu_display_draw_text(font_regular, task_percentage, msg_queue_rect_start_x - msg_queue_icon_size_x + rect_width - msg_queue_glyph_width, - video_info->height - msg->offset_y + msg_queue_text_scale_factor * video_font_size + msg_queue_height/4 - video_font_size/2.25f, + video_info->height - msg->offset_y + msg_queue_text_scale_factor * widget_font_size + msg_queue_height/4 - widget_font_size/2.25f, video_info->width, video_info->height, text_color, TEXT_ALIGN_RIGHT, @@ -1300,12 +1337,11 @@ static void menu_widgets_draw_backdrop(video_frame_info_t *video_info, float alp static void menu_widgets_draw_load_content_animation(video_frame_info_t *video_info) { - /* TODO: scale this right ? (change metrics) */ - + /* TODO: change metrics? */ int icon_size = (int) load_content_animation_icon_size; uint32_t text_alpha = load_content_animation_fade_alpha * 255.0f; uint32_t text_color = COLOR_TEXT_ALPHA(0xB8B8B800, text_alpha); - unsigned text_offset = -25 * load_content_animation_fade_alpha; + unsigned text_offset = -25 * capped_scale_factor * load_content_animation_fade_alpha; float *icon_color = load_content_animation_icon_color; /* Fade out */ @@ -1328,7 +1364,7 @@ static void menu_widgets_draw_load_content_animation(video_frame_info_t *video_i menu_display_draw_text(font_bold, load_content_animation_content_name, video_info->width/2, - video_info->height/2 + 175 + 25 + text_offset, + video_info->height/2 + (175 + 25) * capped_scale_factor + text_offset, video_info->width, video_info->height, text_color, @@ -1356,8 +1392,6 @@ void menu_widgets_frame(void *data) video_frame_info_t *video_info = (video_frame_info_t*)data; int top_right_x_advance = video_info->width; int scissor_me_timbers = 0; - settings_t *settings = config_get_ptr(); - float video_font_size = settings->floats.video_font_size; menu_widgets_frame_count++; @@ -1391,28 +1425,28 @@ void menu_widgets_frame(void *data) /* top line */ menu_display_draw_quad(video_info, 0, 0, - video_info->width, 1, + video_info->width, divider_width_1px, video_info->width, video_info->height, outline_color ); /* bottom line */ menu_display_draw_quad(video_info, - 0, video_info->height-1, - video_info->width, 1, + 0, video_info->height-divider_width_1px, + video_info->width, divider_width_1px, video_info->width, video_info->height, outline_color ); /* left line */ menu_display_draw_quad(video_info, 0, 0, - 1, video_info->height, + divider_width_1px, video_info->height, video_info->width, video_info->height, outline_color ); /* right line */ menu_display_draw_quad(video_info, - video_info->width-1, 0, - 1, video_info->height, + video_info->width-divider_width_1px, 0, + divider_width_1px, video_info->height, video_info->width, video_info->height, outline_color ); @@ -1436,7 +1470,7 @@ void menu_widgets_frame(void *data) menu_display_draw_text(font_regular, libretro_message, simple_widget_padding, - video_info->height - generic_message_height/2 + line_height/4, + video_info->height - generic_message_height/2 + widget_font_size/4, video_info->width, video_info->height, text_color, TEXT_ALIGN_LEFT, 1, false, 0, false); @@ -1456,7 +1490,7 @@ void menu_widgets_frame(void *data) menu_display_draw_text(font_regular, generic_message, video_info->width/2, - video_info->height - generic_message_height/2 + line_height/4, + video_info->height - generic_message_height/2 + widget_font_size/4, video_info->width, video_info->height, text_color, TEXT_ALIGN_CENTER, 1, false, 0, false); @@ -1488,7 +1522,7 @@ void menu_widgets_frame(void *data) menu_display_draw_text(font_regular, msg_hash_to_str(MSG_SCREENSHOT_SAVED), - screenshot_thumbnail_width + simple_widget_padding, video_font_size * 1.9f + screenshot_y, + screenshot_thumbnail_width + simple_widget_padding, widget_font_size * 1.9f + screenshot_y, video_info->width, video_info->height, text_color_faint, TEXT_ALIGN_LEFT, @@ -1505,7 +1539,7 @@ void menu_widgets_frame(void *data) menu_display_draw_text(font_regular, shotname, - screenshot_thumbnail_width + simple_widget_padding, video_font_size * 2.9f + screenshot_y, + screenshot_thumbnail_width + simple_widget_padding, widget_font_size * 2.9f + screenshot_y, video_info->width, video_info->height, text_color_info, TEXT_ALIGN_LEFT, @@ -1569,7 +1603,7 @@ void menu_widgets_frame(void *data) /* Title */ menu_display_draw_text(font_regular, msg_hash_to_str(MSG_ACHIEVEMENT_UNLOCKED), - cheevo_height + simple_widget_padding - unfold_offet, video_font_size * 1.9f + cheevo_y, + cheevo_height + simple_widget_padding - unfold_offet, widget_font_size * 1.9f + cheevo_y, video_info->width, video_info->height, text_color_faint, TEXT_ALIGN_LEFT, @@ -1582,7 +1616,7 @@ void menu_widgets_frame(void *data) menu_display_draw_text(font_regular, cheevo_title, - cheevo_height + simple_widget_padding - unfold_offet, video_font_size * 2.9f + cheevo_y, + cheevo_height + simple_widget_padding - unfold_offet, widget_font_size * 2.9f + cheevo_y, video_info->width, video_info->height, text_color_info, TEXT_ALIGN_LEFT, @@ -1606,13 +1640,13 @@ void menu_widgets_frame(void *data) menu_texture_item volume_icon = 0; unsigned volume_width = video_info->width / 3; - unsigned volume_height = video_font_size * 4; + unsigned volume_height = widget_font_size * 4; unsigned icon_size = menu_widgets_icons_textures[MENU_WIDGETS_ICON_VOLUME_MED] ? volume_height : simple_widget_padding; unsigned text_color = COLOR_TEXT_ALPHA(0xffffffff, (unsigned)(volume_text_alpha*255.0f)); unsigned text_color_db = COLOR_TEXT_ALPHA(text_color_faint, (unsigned)(volume_text_alpha*255.0f)); unsigned bar_x = icon_size; - unsigned bar_height = video_font_size / 2; + unsigned bar_height = widget_font_size / 2; unsigned bar_width = volume_width - bar_x - simple_widget_padding; unsigned bar_y = volume_height / 2 + bar_height/2; @@ -1688,7 +1722,7 @@ void menu_widgets_frame(void *data) const char *text = msg_hash_to_str(MSG_AUDIO_MUTED); menu_display_draw_text(font_regular, text, - volume_width/2, volume_height/2 + video_font_size / 3, + volume_width/2, volume_height/2 + widget_font_size / 3, video_info->width, video_info->height, text_color, TEXT_ALIGN_CENTER, 1, false, 0, false @@ -1724,7 +1758,7 @@ void menu_widgets_frame(void *data) menu_display_draw_text(font_regular, msg, - volume_width - simple_widget_padding, video_font_size * 2, + volume_width - simple_widget_padding, widget_font_size * 2, video_info->width, video_info->height, text_color_db, TEXT_ALIGN_RIGHT, @@ -1733,7 +1767,7 @@ void menu_widgets_frame(void *data) menu_display_draw_text(font_regular, percentage_msg, - icon_size, video_font_size * 2, + icon_size, widget_font_size * 2, video_info->width, video_info->height, text_color, TEXT_ALIGN_LEFT, @@ -1779,7 +1813,7 @@ void menu_widgets_frame(void *data) menu_display_draw_text(font_regular, text, - top_right_x_advance - simple_widget_padding - text_width, video_font_size + simple_widget_padding/4, + top_right_x_advance - simple_widget_padding - text_width, widget_font_size + simple_widget_padding/4, video_info->width, video_info->height, 0xFFFFFFFF, TEXT_ALIGN_LEFT, @@ -1835,7 +1869,7 @@ void menu_widgets_frame(void *data) menu_display_unset_viewport(video_info->width, video_info->height); } -bool menu_widgets_init(bool video_is_threaded) +bool menu_widgets_init(bool video_is_threaded, const char *menu_driver) { if (!menu_display_init_first_driver(video_is_threaded)) goto error; @@ -1855,6 +1889,19 @@ bool menu_widgets_init(bool video_is_threaded) if (!file_list_reserve(current_msgs, MSG_QUEUE_ONSCREEN_MAX)) goto error; + /* Initialise scaling parameters + * NOTE - special cases: + * > Ozone has a capped scale factor + * > XMB uses pixel based scaling - all other drivers + * use DPI based scaling */ + is_ozone = string_is_equal(menu_driver, "ozone"); + is_xmb = string_is_equal(menu_driver, "xmb"); + + video_driver_get_size(&last_video_width, &last_video_height); + last_scale_factor = is_xmb ? + menu_display_get_pixel_scale(last_video_width, last_video_height) : + menu_display_get_dpi_scale(last_video_width, last_video_height); + return true; error: @@ -1863,93 +1910,75 @@ error: return false; } -void menu_widgets_context_reset(bool is_threaded, - unsigned width, unsigned height) +static void menu_widgets_layout( + bool is_threaded, const char *dir_assets, char *font_path) { - int i; - char xmb_path[PATH_MAX_LENGTH]; - char monochrome_png_path[PATH_MAX_LENGTH]; - char menu_widgets_path[PATH_MAX_LENGTH]; - char theme_path[PATH_MAX_LENGTH]; - char ozone_path[PATH_MAX_LENGTH]; - char font_path[PATH_MAX_LENGTH]; - settings_t *settings = config_get_ptr(); - float video_font_size = settings->floats.video_font_size; + int font_height = 0; - /* Textures paths */ - fill_pathname_join( - menu_widgets_path, - settings->paths.directory_assets, - "menu_widgets", - sizeof(menu_widgets_path) - ); + /* Ozone is a unique case, in that it has a capped + * scale factor */ + if (is_ozone) + capped_scale_factor = + (OZONE_SIDEBAR_WIDTH * last_scale_factor) > (last_video_width * 0.3333333f) ? + ((float)last_video_width * 0.3333333f / (float)OZONE_SIDEBAR_WIDTH) : last_scale_factor; + else + capped_scale_factor = last_scale_factor; - fill_pathname_join( - xmb_path, - settings->paths.directory_assets, - "xmb", - sizeof(xmb_path) - ); + /* Base font size must be determined first */ + widget_font_size = BASE_FONT_SIZE * capped_scale_factor; - /* Monochrome */ - fill_pathname_join( - theme_path, - xmb_path, - "monochrome", - sizeof(theme_path) - ); + /* Initialise fonts */ - fill_pathname_join( - monochrome_png_path, - theme_path, - "png", - sizeof(monochrome_png_path) - ); - - /* Load textures */ - /* Icons */ - for (i = 0; i < MENU_WIDGETS_ICON_LAST; i++) + /* > Free existing */ + if (font_regular) { - menu_display_reset_textures_list(menu_widgets_icons_names[i], monochrome_png_path, &menu_widgets_icons_textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL); + menu_display_font_free(font_regular); + font_regular = NULL; + } + if (font_bold) + { + menu_display_font_free(font_bold); + font_bold = NULL; } - /* Message queue */ - menu_display_reset_textures_list("msg_queue_icon.png", menu_widgets_path, &msg_queue_icon, TEXTURE_FILTER_LINEAR, NULL, NULL); - menu_display_reset_textures_list("msg_queue_icon_outline.png", menu_widgets_path, &msg_queue_icon_outline, TEXTURE_FILTER_LINEAR, NULL, NULL); - menu_display_reset_textures_list("msg_queue_icon_rect.png", menu_widgets_path, &msg_queue_icon_rect, TEXTURE_FILTER_NEAREST, NULL, NULL); - - msg_queue_has_icons = msg_queue_icon && msg_queue_icon_outline && msg_queue_icon_rect; - - /* Fonts paths */ - fill_pathname_join( - ozone_path, - settings->paths.directory_assets, - "ozone", - sizeof(ozone_path) - ); - - /* Fonts */ - if (settings->paths.path_font[0] == '\0') + /* > Create new */ + if (string_is_empty(font_path)) { - fill_pathname_join(font_path, ozone_path, "regular.ttf", sizeof(font_path)); - font_regular = menu_display_font_file(font_path, video_font_size, is_threaded); + char ozone_path[PATH_MAX_LENGTH]; + char font_path[PATH_MAX_LENGTH]; + ozone_path[0] = '\0'; + font_path[0] = '\0'; + + /* Base path */ + fill_pathname_join(ozone_path, dir_assets, "ozone", sizeof(ozone_path)); + + /* Create regular font */ + fill_pathname_join(font_path, ozone_path, "regular.ttf", sizeof(font_path)); + font_regular = menu_display_font_file(font_path, widget_font_size, is_threaded); + + /* Create bold font */ fill_pathname_join(font_path, ozone_path, "bold.ttf", sizeof(font_path)); - font_bold = menu_display_font_file(font_path, video_font_size, is_threaded); + font_bold = menu_display_font_file(font_path, widget_font_size, is_threaded); } else { - font_regular = menu_display_font_file(settings->paths.path_font, video_font_size, is_threaded); - font_bold = menu_display_font_file(settings->paths.path_font, video_font_size, is_threaded); + /* Load fonts from user-supplied path */ + font_regular = menu_display_font_file(font_path, widget_font_size, is_threaded); + font_bold = menu_display_font_file(font_path, widget_font_size, is_threaded); } - /* Metrics */ - simple_widget_padding = video_font_size * 2/3; - simple_widget_height = video_font_size + simple_widget_padding; - glyph_width = font_driver_get_message_width(font_regular, "a", 1, 1); - line_height = font_driver_get_line_height(font_regular, 1); + /* > Get actual font size */ + font_height = font_driver_get_line_height(font_regular, 1.0f); + if (font_height > 0) + widget_font_size = (float)font_height; - msg_queue_height = video_font_size * 2.5f; + /* Calculate dimensions */ + simple_widget_padding = widget_font_size * 2.0f/3.0f; + simple_widget_height = widget_font_size + simple_widget_padding; + glyph_width = font_driver_get_message_width(font_regular, "a", 1, 1); + + msg_queue_height = widget_font_size * 2.5f; if (msg_queue_has_icons) { @@ -1984,14 +2013,89 @@ void menu_widgets_context_reset(bool is_threaded, msg_queue_task_text_start_x -= msg_queue_glyph_width*2; msg_queue_regular_text_start = msg_queue_rect_start_x + msg_queue_regular_padding_x; - msg_queue_regular_text_base_y = video_font_size * msg_queue_text_scale_factor + msg_queue_height/2; + msg_queue_regular_text_base_y = widget_font_size * msg_queue_text_scale_factor + msg_queue_height/2; msg_queue_task_hourglass_x = msg_queue_rect_start_x - msg_queue_icon_size_x; - generic_message_height = video_font_size * 2; + generic_message_height = widget_font_size * 2; msg_queue_default_rect_width_menu_alive = msg_queue_glyph_width * 40; - msg_queue_default_rect_width = width - msg_queue_regular_text_start - (2 * simple_widget_padding); + msg_queue_default_rect_width = last_video_width - msg_queue_regular_text_start - (2 * simple_widget_padding); + + load_content_animation_icon_size_initial = LOAD_CONTENT_ANIMATION_INITIAL_ICON_SIZE * capped_scale_factor; + load_content_animation_icon_size_target = LOAD_CONTENT_ANIMATION_TARGET_ICON_SIZE * capped_scale_factor; + + divider_width_1px = (capped_scale_factor > 1.0f) ? (unsigned)(capped_scale_factor + 0.5f) : 1; +} + +void menu_widgets_context_reset(bool is_threaded, + unsigned width, unsigned height, + const char *dir_assets, char *font_path) +{ + int i; + char xmb_path[PATH_MAX_LENGTH]; + char monochrome_png_path[PATH_MAX_LENGTH]; + char menu_widgets_path[PATH_MAX_LENGTH]; + char theme_path[PATH_MAX_LENGTH]; + + xmb_path[0] = '\0'; + monochrome_png_path[0] = '\0'; + menu_widgets_path[0] = '\0'; + theme_path[0] = '\0'; + + /* Textures paths */ + fill_pathname_join( + menu_widgets_path, + dir_assets, + "menu_widgets", + sizeof(menu_widgets_path) + ); + + fill_pathname_join( + xmb_path, + dir_assets, + "xmb", + sizeof(xmb_path) + ); + + /* Monochrome */ + fill_pathname_join( + theme_path, + xmb_path, + "monochrome", + sizeof(theme_path) + ); + + fill_pathname_join( + monochrome_png_path, + theme_path, + "png", + sizeof(monochrome_png_path) + ); + + /* Load textures */ + /* Icons */ + for (i = 0; i < MENU_WIDGETS_ICON_LAST; i++) + { + menu_display_reset_textures_list(menu_widgets_icons_names[i], monochrome_png_path, &menu_widgets_icons_textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL); + } + + /* Message queue */ + menu_display_reset_textures_list("msg_queue_icon.png", menu_widgets_path, &msg_queue_icon, TEXTURE_FILTER_LINEAR, NULL, NULL); + menu_display_reset_textures_list("msg_queue_icon_outline.png", menu_widgets_path, &msg_queue_icon_outline, TEXTURE_FILTER_LINEAR, NULL, NULL); + menu_display_reset_textures_list("msg_queue_icon_rect.png", menu_widgets_path, &msg_queue_icon_rect, TEXTURE_FILTER_NEAREST, NULL, NULL); + + msg_queue_has_icons = msg_queue_icon && msg_queue_icon_outline && msg_queue_icon_rect; + + /* Update scaling/dimensions */ + last_video_width = width; + last_video_height = height; + last_scale_factor = is_xmb ? + menu_display_get_pixel_scale(last_video_width, last_video_height) : + menu_display_get_dpi_scale(last_video_width, last_video_height); + menu_widgets_layout(is_threaded, dir_assets, font_path); + + video_driver_monitor_reset(); } void menu_widgets_context_destroy(void) @@ -2009,8 +2113,10 @@ void menu_widgets_context_destroy(void) video_driver_texture_unload(&msg_queue_icon_rect); /* Fonts */ - menu_display_font_free(font_regular); - menu_display_font_free(font_bold); + if (font_regular) + menu_display_font_free(font_regular); + if (font_bold) + menu_display_font_free(font_bold); font_regular = NULL; font_bold = NULL; @@ -2122,12 +2228,10 @@ static void menu_widgets_volume_timer_end(void *userdata) menu_animation_push(&entry); } -void menu_widgets_volume_update_and_show(void) +void menu_widgets_volume_update_and_show(float new_volume) { menu_timer_ctx_entry_t entry; - settings_t *settings = config_get_ptr(); - bool mute = *(audio_get_bool_ptr(AUDIO_ACTION_MUTE_ENABLE)); - float new_volume = settings->floats.audio_volume; + bool mute = *(audio_get_bool_ptr(AUDIO_ACTION_MUTE_ENABLE)); menu_animation_kill_by_tag(&volume_tag); @@ -2245,7 +2349,6 @@ void menu_widgets_cleanup_load_content_animation(void) void menu_widgets_start_load_content_animation(const char *content_name, bool remove_extension) { /* TODO: finish the animation based on design, correct all timings */ - /* TODO: scale the icon correctly */ menu_animation_ctx_entry_t entry; menu_timer_ctx_entry_t timer_entry; int i; @@ -2270,7 +2373,7 @@ void menu_widgets_start_load_content_animation(const char *content_name, bool re path_remove_extension(load_content_animation_content_name); /* Reset animation state */ - load_content_animation_icon_size = LOAD_CONTENT_ANIMATION_INITIAL_ICON_SIZE; + load_content_animation_icon_size = load_content_animation_icon_size_initial; load_content_animation_icon_alpha = 0.0f; load_content_animation_fade_alpha = 0.0f; load_content_animation_final_fade_alpha = 0.0f; @@ -2287,7 +2390,7 @@ void menu_widgets_start_load_content_animation(const char *content_name, bool re /* Position */ entry.duration = ANIMATION_LOAD_CONTENT_DURATION; entry.subject = &load_content_animation_icon_size; - entry.target_value = LOAD_CONTENT_ANIMATION_TARGET_ICON_SIZE; + entry.target_value = load_content_animation_icon_size_target; menu_animation_push(&entry); @@ -2404,8 +2507,7 @@ static void menu_widgets_achievement_unfold(void *userdata) static void menu_widgets_start_achievement_notification(void) { menu_animation_ctx_entry_t entry; - settings_t *settings = config_get_ptr(); - cheevo_height = settings->floats.video_font_size * 4; + cheevo_height = widget_font_size * 4; cheevo_width = MAX( font_driver_get_message_width(font_regular, msg_hash_to_str(MSG_ACHIEVEMENT_UNLOCKED), 0, 1), font_driver_get_message_width(font_regular, cheevo_title, 0, 1) diff --git a/menu/widgets/menu_widgets.h b/menu/widgets/menu_widgets.h index 287bd21cdc..d1ad1758e7 100644 --- a/menu/widgets/menu_widgets.h +++ b/menu/widgets/menu_widgets.h @@ -36,7 +36,7 @@ #define HOURGLASS_DURATION 1000 #define GENERIC_MESSAGE_DURATION 3000 -bool menu_widgets_init(bool video_is_threaded); +bool menu_widgets_init(bool video_is_threaded, const char *menu_driver); void menu_widgets_free(void); @@ -48,9 +48,11 @@ void menu_widgets_msg_queue_push( enum message_queue_category category, unsigned prio, bool flush); -void menu_widgets_volume_update_and_show(void); +void menu_widgets_volume_update_and_show(float new_volume); -void menu_widgets_iterate(unsigned width, unsigned height); +void menu_widgets_iterate( + unsigned width, unsigned height, + const char *dir_assets, char *font_path); void menu_widgets_screenshot_taken(const char *shotname, const char *filename); @@ -70,7 +72,8 @@ void menu_widgets_start_load_content_animation( void menu_widgets_cleanup_load_content_animation(void); void menu_widgets_context_reset(bool is_threaded, - unsigned width, unsigned height); + unsigned width, unsigned height, + const char *dir_assets, char *font_path); void menu_widgets_context_destroy(void); diff --git a/msg_hash.h b/msg_hash.h index 1834aef9f1..6e80ce675c 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -517,6 +517,7 @@ enum msg_hash_enums MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_END = MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_BEGIN + RARCH_BIND_LIST_END, MENU_LABEL(MENU_SCALE_FACTOR), + MENU_LABEL(MENU_WIDGET_SCALE_FACTOR), MENU_LABEL(MENU_WALLPAPER_OPACITY), MENU_LABEL(MENU_FRAMEBUFFER_OPACITY), MENU_LABEL(MENU_USE_PREFERRED_SYSTEM_COLOR_THEME), diff --git a/retroarch.c b/retroarch.c index 75138a9c75..3748731396 100644 --- a/retroarch.c +++ b/retroarch.c @@ -5415,7 +5415,7 @@ static void command_event_set_volume(float gain) #if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) if (menu_widgets_inited) - menu_widgets_volume_update_and_show(); + menu_widgets_volume_update_and_show(settings->floats.audio_volume); else #endif runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); @@ -6895,7 +6895,7 @@ TODO: Add a setting for these tweaks */ #if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) if (menu_widgets_inited) - menu_widgets_volume_update_and_show(); + menu_widgets_volume_update_and_show(configuration_settings->floats.audio_volume); else #endif runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); @@ -23435,11 +23435,14 @@ static void drivers_init(int flags) && video_driver_has_widgets()) { if (!menu_widgets_inited) - menu_widgets_inited = menu_widgets_init(video_is_threaded); + menu_widgets_inited = menu_widgets_init( + video_is_threaded, settings->arrays.menu_driver); if (menu_widgets_inited) menu_widgets_context_reset(video_is_threaded, - video_driver_width, video_driver_height); + video_driver_width, video_driver_height, + settings->paths.directory_assets, + settings->paths.path_font); } else { @@ -27274,7 +27277,10 @@ static enum runloop_state runloop_check_state(void) if (menu_widgets_inited) { runloop_msg_queue_lock(); - menu_widgets_iterate(video_driver_width, video_driver_height); + menu_widgets_iterate( + video_driver_width, video_driver_height, + settings->paths.directory_assets, + settings->paths.path_font); runloop_msg_queue_unlock(); } #endif From 108643473da2140bbc6d333c3ea3495575e73712 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 18:34:40 +0100 Subject: [PATCH 40/75] (Intl Ja) Remove duplicate Japanese strings --- intl/msg_hash_ja.h | 877 --------------------------------------------- 1 file changed, 877 deletions(-) diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index c741366bd1..2e92f2b9e0 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -2194,10 +2194,6 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_DEFAULT_CORE, "デフォルトのコア" ) -MSG_HASH( - MENU_ENUM_SUBLABEL_PLAYLIST_MANAGER_DEFAULT_CORE, - "Specify core to use when launching content via a playlist entry that does not have an existing core association." -) MSG_HASH( MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_RESET_CORES, "コアの関連付けのリセット" @@ -2206,14 +2202,6 @@ MSG_HASH( MENU_ENUM_SUBLABEL_PLAYLIST_MANAGER_RESET_CORES, "全エントリーのコアの関連付けをリセット" ) -MSG_HASH( - MSG_PLAYLIST_MANAGER_RESETTING_CORES, - "Resetting cores: " -) -MSG_HASH( - MSG_PLAYLIST_MANAGER_CORES_RESET, - "Cores reset: " -) MSG_HASH( MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE, "ラベルの表示モード" @@ -3199,122 +3187,6 @@ MSG_HASH( "画質を改善します。 " "中程度のパフォーマンスへの影響があります。" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_MENU_RGUI_INLINE_THUMBNAILS, - "Show Playlist Thumbnails" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_MENU_RGUI_INLINE_THUMBNAILS, - "Enable display of inline downscaled thumbnails while viewing playlists. When disabled, 'Top Thumbnail' may still be toggled fullscreen by pressing RetroPad Y." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_MENU_RGUI_SWAP_THUMBNAILS, - "Swap Thumbnails" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_MENU_RGUI_SWAP_THUMBNAILS, - "Swaps the display positions of 'Top Thumbnail' and 'Bottom Thumbnail'." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_MENU_RGUI_THUMBNAIL_DELAY, - "Thumbnail Delay (ms)" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_MENU_RGUI_THUMBNAIL_DELAY, - "Applies a time delay between selecting a playlist entry and loading its associated thumbnails. Setting this to a value of at least 256 ms enables fast lag-free scrolling on even the slowest devices." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_MENU_RGUI_THUMBNAIL_DOWNSCALER, - "Thumbnail Downscaling Method" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_MENU_RGUI_THUMBNAIL_DOWNSCALER, - "Resampling method used when shrinking large thumbnails to fit the display." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_THUMB_SCALE_POINT, - "Nearest Neighbour (Fast)" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_THUMB_SCALE_BILINEAR, - "Bilinear" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_THUMB_SCALE_SINC, - "Sinc/Lanczos3 (Slow)" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_UPSCALE_NONE, - "None" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_UPSCALE_AUTO, - "Auto" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_UPSCALE_X2, - "x2" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_UPSCALE_X3, - "x3" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_UPSCALE_X4, - "x4" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_UPSCALE_X5, - "x5" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_UPSCALE_X6, - "x6" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_UPSCALE_X7, - "x7" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_UPSCALE_X8, - "x8" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_UPSCALE_X9, - "x9" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_4_3, - "4:3" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_16_9, - "16:9" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_16_9_CENTRE, - "16:9 (Centered)" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_16_10, - "16:10" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_16_10_CENTRE, - "16:10 (Centered)" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_LOCK_NONE, - "OFF" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_LOCK_FIT_SCREEN, - "Fit Screen" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_LOCK_INTEGER, - "Integer Scale" -) MSG_HASH( MENU_ENUM_LABEL_VALUE_THUMBNAILS_DIRECTORY, "サムネイル" @@ -3424,154 +3296,6 @@ MSG_HASH( "長いテキスト文字列を表示するときのスクロールをスムーズにします。 " "パフォーマンスに少し影響します。" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME, - "Menu Color Theme" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_RGUI_MENU_COLOR_THEME, - "Select a different color theme. Choosing 'Custom' enables the use of menu theme preset files." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_THEME_PRESET, - "Custom Menu Theme Preset" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_RGUI_MENU_THEME_PRESET, - "Select a menu theme preset from the file browser." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_CUSTOM, - "Custom" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_CLASSIC_RED, - "Classic Red" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_CLASSIC_ORANGE, - "Classic Orange" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_CLASSIC_YELLOW, - "Classic Yellow" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_CLASSIC_GREEN, - "Classic Green" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_CLASSIC_BLUE, - "Classic Blue" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_CLASSIC_VIOLET, - "Classic Violet" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_CLASSIC_GREY, - "Classic Grey" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_LEGACY_RED, - "Legacy Red" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_DARK_PURPLE, - "Dark Purple" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_MIDNIGHT_BLUE, - "Midnight Blue" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_GOLDEN, - "Golden" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_ELECTRIC_BLUE, - "Electric Blue" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_APPLE_GREEN, - "Apple Green" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_VOLCANIC_RED, - "Volcanic Red" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_LAGOON, - "Lagoon" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_BROGRAMMER, - "Brogrammer" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_DRACULA, - "Dracula" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_FAIRYFLOSS, - "Fairy Floss" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_FLATUI, - "Flat UI" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_GRUVBOX_DARK, - "Gruvbox Dark" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_GRUVBOX_LIGHT, - "Gruvbox Light" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_HACKING_THE_KERNEL, - "Hacking the Kernel" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_NORD, - "Nord" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_NOVA, - "Nova" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_ONE_DARK, - "One Dark" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_PALENIGHT, - "Palenight" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_SOLARIZED_DARK, - "Solarized Dark" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_SOLARIZED_LIGHT, - "Solarized Light" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_TANGO_DARK, - "Tango Dark" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_TANGO_LIGHT, - "Tango Light" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_ZENBURN, - "Zenburn" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_ANTI_ZENBURN, - "Anti-Zenburn" -) MSG_HASH( MENU_ENUM_LABEL_VALUE_TRUE, "真" @@ -3721,34 +3445,6 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_3DS_LCD_BOTTOM, "3DSボトム画面" ) -MSG_HASH( - MENU_ENUM_SUBLABEL_VIDEO_3DS_LCD_BOTTOM, - "Enable display of status information on bottom screen. Disable to increase battery life and improve performance." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_VIDEO_3DS_DISPLAY_MODE, - "3DS Display Mode" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_VIDEO_3DS_DISPLAY_MODE, - "Selects between 3D and 2D display modes. In '3D' mode, pixels are square and a depth effect is applied when viewing the Quick Menu. '2D' mode provides the best performance." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_CTR_VIDEO_MODE_3D, - "3D" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_CTR_VIDEO_MODE_2D, - "2D" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_CTR_VIDEO_MODE_2D_400x240, - "2D (Pixel Grid Effect)" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_CTR_VIDEO_MODE_2D_800x240, - "2D (High Resolution)" -) #endif MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_DRIVER, @@ -3886,18 +3582,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET, "シェーダのプリセットをロード" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE, - "Save ..." -) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS, "シェーダのプリセットに名前を付けて保存" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_GLOBAL, - "Save Global Preset" -) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_CORE, "コアのプリセットを保存" @@ -3954,26 +3642,6 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_VIEWPORT_CUSTOM_Y, "カスタム表示領域のY位置" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_VIDEO_VI_WIDTH, - "Set VI Screen Width" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_VIDEO_OVERSCAN_CORRECTION_TOP, - "Overscan Correction (Top)" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_VIDEO_OVERSCAN_CORRECTION_TOP, - "Adjust display overscan cropping by reducing image size by specified number of scanlines (taken from top of screen). Note: May introduce scaling artefacts." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_VIDEO_OVERSCAN_CORRECTION_BOTTOM, - "Overscan Correction (Bottom)" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_VIDEO_OVERSCAN_CORRECTION_BOTTOM, - "Adjust display overscan cropping by reducing image size by specified number of scanlines (taken from bottom of screen). Note: May introduce scaling artefacts." -) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_VSYNC, "垂直同期" @@ -3998,32 +3666,6 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_FULLSCREEN_Y, "フルスクリーンの高さ" ) -#ifdef HAVE_VIDEO_LAYOUT -MSG_HASH( - MENU_ENUM_LABEL_VALUE_VIDEO_LAYOUT_ENABLE, - "Enable Video Layout" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_VIDEO_LAYOUT_ENABLE, - "Video layouts are used for bezels and other artwork." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_VIDEO_LAYOUT_PATH, - "Video Layout Path" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_VIDEO_LAYOUT_PATH, - "Select a video layout from the file browser." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_VIDEO_LAYOUT_SELECTED_VIEW, - "Selected View" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_VIDEO_LAYOUT_SELECTED_VIEW, - "Select a view within the loaded layout." -) -#endif MSG_HASH( MENU_ENUM_LABEL_VALUE_WIFI_DRIVER, "Wi-Fiのドライバ" @@ -4092,14 +3734,6 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_XMB_ICON_THEME_DOTART, "ドットアート" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_XMB_ICON_THEME_AUTOMATIC, - "Automatic" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_XMB_ICON_THEME_AUTOMATIC_INVERTED, - "Automatic Inverted" -) MSG_HASH( MENU_ENUM_LABEL_VALUE_XMB_MENU_COLOR_THEME, "メニューの色テーマ" @@ -4152,10 +3786,6 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_XMB_MENU_COLOR_THEME_VOLCANIC_RED, "ボルカニックレッド" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_XMB_MENU_COLOR_THEME_SUNBEAM, - "Sunbeam" -) MSG_HASH( MENU_ENUM_LABEL_VALUE_XMB_RIBBON_ENABLE, "メニューのシェーダパイプライン" @@ -4471,14 +4101,6 @@ MSG_HASH( MSG_ADDED_TO_FAVORITES, "お気に入りに追加しました" ) -MSG_HASH( - MSG_ADD_TO_FAVORITES_FAILED, - "Failed to add favorite: playlist full" -) -MSG_HASH( - MSG_SET_CORE_ASSOCIATION, - "Core set: " -) MSG_HASH( MSG_RESET_CORE_ASSOCIATION, "プレイリストエントリのコアの関連付けがリセットされました" @@ -4575,14 +4197,6 @@ MSG_HASH( MSG_COULD_NOT_READ_STATE_FROM_MOVIE, "動画から状態を読み込むことができませんでした" ) -MSG_HASH( - MSG_CRC32_CHECKSUM_MISMATCH, - "CRC32 checksum mismatch between content file and saved content checksum in replay file header) replay highly likely to desync on playback." -) -MSG_HASH( - MSG_CUSTOM_TIMING_GIVEN, - "Custom timing given" -) MSG_HASH( MSG_DECOMPRESSION_ALREADY_IN_PROGRESS, "解凍は既に進行中です" @@ -4627,22 +4241,6 @@ MSG_HASH( MSG_ERROR, "エラー" ) -MSG_HASH( - MSG_ERROR_LIBRETRO_CORE_REQUIRES_CONTENT, - "Libretro core requires content, but nothing was provided." -) -MSG_HASH( - MSG_ERROR_LIBRETRO_CORE_REQUIRES_SPECIAL_CONTENT, - "Libretro core requires special content, but none were provided." -) -MSG_HASH( - MSG_ERROR_LIBRETRO_CORE_REQUIRES_VFS, - "Core does not support VFS, and loading from a local copy failed" -) -MSG_HASH( - MSG_ERROR_PARSING_ARGUMENTS, - "Error parsing arguments." -) MSG_HASH( MSG_ERROR_SAVING_CORE_OPTIONS_FILE, "コアの設定ファイルの保存に失敗しました" @@ -4843,10 +4441,6 @@ MSG_HASH( MSG_FRAMES, "フレーム" ) -MSG_HASH( - MSG_GAME_SPECIFIC_CORE_OPTIONS_FOUND_AT, - "Per-Game Options: game-specific core options found at" -) MSG_HASH( MSG_GOT_INVALID_DISK_INDEX, "無効なディスクインデックスです" @@ -4863,14 +4457,6 @@ MSG_HASH( MSG_GAME_FOCUS_OFF, "ゲームフォーカスをオフにしました。" ) -MSG_HASH( - MSG_HW_RENDERED_MUST_USE_POSTSHADED_RECORDING, - "Libretro core is hardware rendered. Must use post-shaded recording as well." -) -MSG_HASH( - MSG_INFLATED_CHECKSUM_DID_NOT_MATCH_CRC32, - "Inflated checksum did not match CRC32." -) MSG_HASH( MSG_INPUT_CHEAT, "チートを入力" @@ -4915,10 +4501,6 @@ MSG_HASH( MSG_IN_MEGABYTES, "(メガバイト)" ) -MSG_HASH( - MSG_LIBRETRO_ABI_BREAK, - "is compiled against a different version of libretro than this libretro implementation." -) MSG_HASH( MSG_LIBRETRO_FRONTEND, "libretroのフロントエンド" @@ -4959,14 +4541,6 @@ MSG_HASH( MSG_MEMORY, "メモリ" ) -MSG_HASH( - MSG_MOVIE_FILE_IS_NOT_A_VALID_BSV1_FILE, - "Movie file is not a valid BSV1 file." -) -MSG_HASH( - MSG_MOVIE_FORMAT_DIFFERENT_SERIALIZER_VERSION, - "Movie format seems to have a different serializer version. Will most likely fail." -) MSG_HASH( MSG_MOVIE_PLAYBACK_ENDED, "動画の再生を終了しました" @@ -4979,10 +4553,6 @@ MSG_HASH( MSG_NETPLAY_FAILED, "ネットプレイの初期化に失敗しました" ) -MSG_HASH( - MSG_NO_CONTENT_STARTING_DUMMY_CORE, - "No content, starting dummy core." -) MSG_HASH( MSG_NO_SAVE_STATE_HAS_BEEN_OVERWRITTEN_YET, "ステートセーブはまだ上書きされていません" @@ -5003,26 +4573,10 @@ MSG_HASH( MSG_PAUSED, "一時停止" ) -MSG_HASH( - MSG_PROGRAM, - "RetroArch" -) MSG_HASH( MSG_READING_FIRST_DATA_TRACK, "最初のデータトラックを読み込んでいます..." ) -MSG_HASH( - MSG_RECEIVED, - "received" -) -MSG_HASH( - MSG_RECORDING_TERMINATED_DUE_TO_RESIZE, - "Recording terminated due to resize." -) -MSG_HASH( - MSG_RECORDING_TO, - "Recording to" -) MSG_HASH( MSG_REDIRECTING_CHEATFILE_TO, "チートファイルの出力先を変更しています to" @@ -5055,18 +4609,10 @@ MSG_HASH( MSG_RESET, "リセット" ) -MSG_HASH( - MSG_RESTARTING_RECORDING_DUE_TO_DRIVER_REINIT, - "Restarting recording due to driver reinit." -) MSG_HASH( MSG_RESTORED_OLD_SAVE_STATE, "以前のステートセーブを復元しました" ) -MSG_HASH( - MSG_RESTORING_DEFAULT_SHADER_PRESET_TO, - "Shaders: restoring default shader preset to" -) MSG_HASH( MSG_REVERTING_SAVEFILE_DIRECTORY_TO, "セーブフォルダを元に戻しています to" @@ -5079,18 +4625,10 @@ MSG_HASH( MSG_REWINDING, "巻き戻しています" ) -MSG_HASH( - MSG_REWIND_INIT, - "Initializing rewind buffer with size" -) MSG_HASH( MSG_REWIND_INIT_FAILED, "巻き戻しバッファの初期化に失敗しました。巻き戻しが無効になります" ) -MSG_HASH( - MSG_REWIND_INIT_FAILED_THREADED_AUDIO, - "Implementation uses threaded audio. Cannot use rewind." -) MSG_HASH( MSG_REWIND_REACHED_END, "巻き戻しバッファの終わりに達しました" @@ -5131,10 +4669,6 @@ MSG_HASH( MSG_SENDING_COMMAND, "コマンドを送信中" ) -MSG_HASH( - MSG_SEVERAL_PATCHES_ARE_EXPLICITLY_DEFINED, - "Several patches are explicitly defined, ignoring all..." -) MSG_HASH( MSG_SHADER, "シェーダ" @@ -5183,30 +4717,6 @@ MSG_HASH( MSG_TAKING_SCREENSHOT, "スクリーンショットを撮影中" ) -MSG_HASH( - MSG_SCREENSHOT_SAVED, - "Screenshot saved" -) -MSG_HASH( - MSG_ACHIEVEMENT_UNLOCKED, - "Achievement Unlocked" -) -MSG_HASH( - MSG_CHANGE_THUMBNAIL_TYPE, - "Change thumbnail type" -) -MSG_HASH( - MSG_NO_THUMBNAIL_AVAILABLE, - "No thumbnail available" -) -MSG_HASH( - MSG_PRESS_AGAIN_TO_QUIT, - "Press again to quit..." -) -MSG_HASH( - MSG_TO, - "to" -) MSG_HASH( MSG_UNDID_LOAD_STATE, "ステートロードを取り消しました" @@ -5223,18 +4733,6 @@ MSG_HASH( MSG_UNPAUSED, "一時停止解除" ) -MSG_HASH( - MSG_UNRECOGNIZED_COMMAND, - "Unrecognized command" -) -MSG_HASH( - MSG_USING_CORE_NAME_FOR_NEW_CONFIG, - "Using core name for new config." -) -MSG_HASH( - MSG_USING_LIBRETRO_DUMMY_CORE_RECORDING_SKIPPED, - "Using libretro dummy core. Skipping recording." -) MSG_HASH( MSG_VALUE_CONNECT_DEVICE_FROM_A_VALID_PORT, "デバイスを有効なポートから接続してください" @@ -5251,18 +4749,6 @@ MSG_HASH( MSG_VALUE_SHUTTING_DOWN, "シャットダウンしています..." ) -MSG_HASH( - MSG_VERSION_OF_LIBRETRO_API, - "Version of libretro API" -) -MSG_HASH( - MSG_VIEWPORT_SIZE_CALCULATION_FAILED, - "Viewport size calculation failed! Will continue using raw data. This will probably not work right ..." -) -MSG_HASH( - MSG_VIRTUAL_DISK_TRAY, - "virtual disk tray." -) MSG_HASH( MENU_ENUM_SUBLABEL_AUDIO_LATENCY, "オーディオの遅延時間(ms)です。ドライバ対応に依存します。" @@ -5303,18 +4789,6 @@ MSG_HASH( "オーディオの音量(dB)です。 " "0dB は通常の音量で, 増幅されません。" ) -MSG_HASH( - MENU_ENUM_SUBLABEL_AUDIO_WASAPI_EXCLUSIVE_MODE, - "Allow the WASAPI driver to take exclusive control of the audio device. If disabled, it will use shared mode instead." -) -MSG_HASH( - MENU_ENUM_SUBLABEL_AUDIO_WASAPI_FLOAT_FORMAT, - "Use float format for the WASAPI driver, if supported by your audio device." -) -MSG_HASH( - MENU_ENUM_SUBLABEL_AUDIO_WASAPI_SH_BUFFER_LENGTH, - "The intermediate buffer length (in frames) when using the WASAPI driver in shared mode." -) MSG_HASH( MENU_ENUM_SUBLABEL_AUDIO_SYNC, "オーディオを同期します(推奨)。" @@ -5386,10 +4860,6 @@ MSG_HASH( MSG_DEVICE_NOT_CONFIGURED, "設定されていません" ) -MSG_HASH( - MSG_DEVICE_NOT_CONFIGURED_FALLBACK, - "not configured, using fallback" -) MSG_HASH( MENU_ENUM_LABEL_VALUE_DATABASE_CURSOR_LIST, "データベースのカーソル表" @@ -5632,10 +5102,6 @@ MSG_HASH( MENU_ENUM_SUBLABEL_CORE_LIST, "使用するコアを選択します。" ) -MSG_HASH( - MENU_ENUM_SUBLABEL_START_CORE, - "Start core without content." -) MSG_HASH( MENU_ENUM_SUBLABEL_DOWNLOAD_CORE, "オンラインアップデータからコアをインストールします。" @@ -5716,10 +5182,6 @@ MSG_HASH( MENU_ENUM_SUBLABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS, "オーバーレイにキーボード/コントローラ入力を表示します。" ) -MSG_HASH( - MENU_ENUM_SUBLABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT, - "Select the port for the overlay to listen to if Show Inputs On Overlay is enabled." -) MSG_HASH( MENU_ENUM_SUBLABEL_INPUT_OVERLAY_SHOW_MOUSE_CURSOR, "オーバーレイにマウスカーソルを表示します。" @@ -5821,19 +5283,6 @@ MSG_HASH( MENU_ENUM_SUBLABEL_CHEAT_APPLY_AFTER_LOAD, "ゲームをロードしたときにチートを自動で適用します。" ) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_REPEAT_COUNT, - "The number of times the cheat will be applied. " - "Use with the other two Iteration options to affect large areas of memory." -) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_REPEAT_ADD_TO_ADDRESS, - "After each 'Number of Iterations' the Memory Address will be increased by this number times the 'Memory Search Size'." -) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_REPEAT_ADD_TO_VALUE, - "After each 'Number of Iterations' the Value will be increased by this amount." -) MSG_HASH( MENU_ENUM_SUBLABEL_REWIND_GRANULARITY, "定義した数のフレームを巻き戻すときは, 一度に複数のフレームを巻き戻すことができ, 巻き戻し速度が速くなります。" @@ -5846,22 +5295,6 @@ MSG_HASH( MENU_ENUM_SUBLABEL_REWIND_BUFFER_SIZE_STEP, "このUIで巻き戻しバッファサイズの値を増減するたびに, この量だけ変化します。" ) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_IDX, - "Index position in list." -) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_ADDRESS_BIT_POSITION, - "Address bitmask when Memory Search Size < 8-bit." -) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_MATCH_IDX, - "Select the match to view." -) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_START_OR_CONT, - "" -) MSG_HASH( MENU_ENUM_SUBLABEL_CHEAT_START_OR_RESTART, "左/右でビット幅を変更します。" @@ -5870,30 +5303,6 @@ MSG_HASH( MENU_ENUM_SUBLABEL_CHEAT_SEARCH_EXACT, "左/右で値を変更します。" ) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_SEARCH_LT, - "" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_SEARCH_GT, - "" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_SEARCH_LTE, - "" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_SEARCH_GTE, - "" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_SEARCH_EQ, - "" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_SEARCH_NEQ, - "" -) MSG_HASH( MENU_ENUM_SUBLABEL_CHEAT_SEARCH_EQPLUS, "左/右で値を変更します。" @@ -5902,38 +5311,6 @@ MSG_HASH( MENU_ENUM_SUBLABEL_CHEAT_SEARCH_EQMINUS, "左/右で値を変更します。" ) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_ADD_MATCHES, - "" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_VIEW_MATCHES, - "" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_CREATE_OPTION, - "" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_DELETE_OPTION, - "" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_ADD_NEW_TOP, - "" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_ADD_NEW_BOTTOM, - "" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_DELETE_ALL, - "" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_RELOAD_CHEATS, - "" -) MSG_HASH( MENU_ENUM_SUBLABEL_CHEAT_BIG_ENDIAN, "ビッグエンディアン : 258 = 0x0102, " @@ -6137,22 +5514,10 @@ MSG_HASH( MENU_ENUM_SUBLABEL_THUMBNAILS, "表示するサムネイルの種類です。" ) -MSG_HASH( - MENU_ENUM_SUBLABEL_THUMBNAILS_RGUI, - "Type of thumbnail to display at the top right of playlists. This thumbnail may be toggled fullscreen by pressing RetroPad Y." -) MSG_HASH( MENU_ENUM_SUBLABEL_LEFT_THUMBNAILS, "左側に表示するサムネイルの種類です。" ) -MSG_HASH( - MENU_ENUM_SUBLABEL_LEFT_THUMBNAILS_RGUI, - "Type of thumbnail to display at the bottom right of playlists." -) -MSG_HASH( - MENU_ENUM_SUBLABEL_LEFT_THUMBNAILS_OZONE, - "Replace the content metadata panel by another thumbnail." -) MSG_HASH( MENU_ENUM_SUBLABEL_XMB_VERTICAL_THUMBNAILS, "左側サムネイルを右側サムネイルの下に表示し, 両方ともスクリーンの右側に配置します。" @@ -6319,14 +5684,6 @@ MSG_HASH( MENU_ENUM_SUBLABEL_INPUT_META_REWIND, "巻き戻しの設定を管理します。" ) -MSG_HASH( - MENU_ENUM_SUBLABEL_INPUT_META_CHEAT_DETAILS, - "Manages cheat details settings." -) -MSG_HASH( - MENU_ENUM_SUBLABEL_INPUT_META_CHEAT_SEARCH, - "Start or continue a cheat code search." -) MSG_HASH( MENU_ENUM_SUBLABEL_RESTART_CONTENT, "コンテンツを最初から再起動します。" @@ -6336,10 +5693,6 @@ MSG_HASH( "このコアでロードされたすべてのコンテンツに適用するオーバーライド設定ファイルを保存します。 " "メイン設定より優先されます。" ) -MSG_HASH( - MENU_ENUM_SUBLABEL_SAVE_CURRENT_CONFIG_OVERRIDE_CONTENT_DIR, - "Saves an override configuration file which will apply for all content loaded from the same directory as the current file. Will take precedence over the main configuration." -) MSG_HASH( MENU_ENUM_SUBLABEL_SAVE_CURRENT_CONFIG_OVERRIDE_GAME, "現在のコンテンツにのみ適用するオーバーライド設定ファイルを保存します。 " @@ -6604,58 +5957,10 @@ MSG_HASH( "シェーダパイプラインのパス数を増加または減少させます。 " "各パイプラインに別々のシェーダをバインドし, フィルタリングとスケールを設定することができます。" ) -MSG_HASH( - MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET, - "Load a shader preset. The shader pipeline will be automatically set-up." -) -MSG_HASH( - MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE, - "Save shader preset as ..." -) -MSG_HASH( - MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_AS, - "Save the current shader settings as a new shader preset." -) -MSG_HASH( - MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_CORE, - "Save the current shader settings as the default settings for this application/core." -) -MSG_HASH( - MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_PARENT, - "Save the current shader settings as the default settings for all files in the current content directory." -) -MSG_HASH( - MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_GAME, - "Save the current shader settings as the default settings for the content." -) -MSG_HASH( - MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_GLOBAL, - "Save the current shader settings as the default global setting." -) -MSG_HASH( - MENU_ENUM_SUBLABEL_VIDEO_SHADER_PARAMETERS, - "Modifies the current shader directly. Changes will not be saved to the preset file." -) -MSG_HASH( - MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_PARAMETERS, - "Modifies the shader preset itself currently used in the menu." -) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_NUM_PASSES, - "Increase or decrease the amount of cheats." -) MSG_HASH( MENU_ENUM_SUBLABEL_CHEAT_APPLY_CHANGES, "チートの変更はただちに適用されます。" ) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_START_SEARCH, - "Start search for a new cheat. Number of bits can be changed." -) -MSG_HASH( - MENU_ENUM_SUBLABEL_CHEAT_CONTINUE_SEARCH, - "Continue search for a new cheat." -) MSG_HASH( MENU_ENUM_SUBLABEL_CHEAT_FILE_LOAD, "チートファイルをロードして既存のチートを置き換えます。" @@ -7266,118 +6571,6 @@ MSG_HASH( MENU_ENUM_SUBLABEL_STATISTICS_SHOW, "技術的な統計を画面に表示します。" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_MENU_RGUI_BORDER_FILLER_ENABLE, - "Border filler" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_MENU_RGUI_BORDER_FILLER_ENABLE, - "Display menu border." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_MENU_RGUI_BORDER_FILLER_THICKNESS_ENABLE, - "Border filler thickness" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_MENU_RGUI_BORDER_FILLER_THICKNESS_ENABLE, - "Increase coarseness of menu border chequerboard pattern." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_MENU_RGUI_BACKGROUND_FILLER_THICKNESS_ENABLE, - "Background filler thickness" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_MENU_RGUI_BACKGROUND_FILLER_THICKNESS_ENABLE, - "Increase coarseness of menu background chequerboard pattern." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_MENU_RGUI_ASPECT_RATIO_LOCK, - "Lock Menu Aspect Ratio" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_MENU_RGUI_ASPECT_RATIO_LOCK, - "Ensures that the menu is always displayed with the correct aspect ratio. If disabled, the quick menu will be stretched to match the currently loaded content." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_MENU_RGUI_INTERNAL_UPSCALE_LEVEL, - "Internal Upscaling" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_MENU_RGUI_INTERNAL_UPSCALE_LEVEL, - "Upscale menu interface before drawing to screen. When used with 'Menu Linear Filter' enabled, removes scaling artefacts (uneven pixels) while maintaining a sharp image. Has a significant performance impact that increases with upscaling level." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_MENU_RGUI_ASPECT_RATIO, - "Menu Aspect Ratio" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_MENU_RGUI_ASPECT_RATIO, - "Select menu aspect ratio. Widescreen ratios increase the horizontal resolution of the menu interface. (May require a restart if 'Lock Menu Aspect Ratio' is disabled)" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_MENU_RGUI_FULL_WIDTH_LAYOUT, - "Use Full-Width Layout" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_MENU_RGUI_FULL_WIDTH_LAYOUT, - "Resize and position menu entries to make best use of available screen space. Disable this to use classic fixed-width two column layout." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_MENU_RGUI_SHADOWS, - "Shadow Effects" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_MENU_RGUI_SHADOWS, - "Enable drop shadows for menu text, borders and thumbnails. Has a modest performance impact." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_MENU_RGUI_PARTICLE_EFFECT, - "Background Animation" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_MENU_RGUI_PARTICLE_EFFECT, - "Enable background particle animation effect. Has a significant performance impact." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_PARTICLE_EFFECT_NONE, - "OFF" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_PARTICLE_EFFECT_SNOW, - "Snow (Light)" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_PARTICLE_EFFECT_SNOW_ALT, - "Snow (Heavy)" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_PARTICLE_EFFECT_RAIN, - "Rain" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_PARTICLE_EFFECT_VORTEX, - "Vortex" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_RGUI_PARTICLE_EFFECT_STARFIELD, - "Star Field" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_MENU_RGUI_PARTICLE_EFFECT_SPEED, - "Background Animation Speed" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_MENU_RGUI_PARTICLE_EFFECT_SPEED, - "Adjust speed of background particle animation effects." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_MENU_RGUI_EXTENDED_ASCII, - "Extended ASCII Support" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_MENU_RGUI_EXTENDED_ASCII, - "Enable display of non-standard ASCII characters. Required for compatibility with certain non-English Western languages. Has a moderate performance impact." -) MSG_HASH( MENU_ENUM_SUBLABEL_CRT_SWITCH_RESOLUTION, "CRTディスプレイ専用です。 " @@ -7419,16 +6612,6 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_CONTENT_SHOW_OVERLAYS, "[OSDオーバーレイ]を表示" ) -#ifdef HAVE_VIDEO_LAYOUT -MSG_HASH( - MENU_ENUM_LABEL_VALUE_CONTENT_SHOW_VIDEO_LAYOUT, - "Show Video Layout Settings" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_CONTENT_SHOW_VIDEO_LAYOUT, - "Show/hide Video Layout options." -) -#endif MSG_HASH( MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE_MENU, "メニューのオーディオを有効" @@ -7629,14 +6812,6 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_QT_LOG, "ログ" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_QT_ITEMS_COUNT, - "%1 items" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_QT_DROP_IMAGE_HERE, - "Drop image here" -) #ifdef HAVE_QT MSG_HASH( MENU_ENUM_LABEL_VALUE_QT_SCAN_FINISHED, @@ -8166,14 +7341,6 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_STARTUP_PLAYLIST, "起動時に表示するプレイリスト:" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THUMBNAIL_TYPE, - "Thumbnail" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THUMBNAIL_CACHE_LIMIT, - "Thumbnail cache limit:" -) MSG_HASH( MENU_ENUM_LABEL_VALUE_QT_DOWNLOAD_ALL_THUMBNAILS, "すべてのサムネイルをダウンロード" @@ -8194,14 +7361,6 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_QT_DOWNLOAD_PLAYLIST_THUMBNAIL_PROGRESS, "成功した数: %1 失敗した数: %2" ) -MSG_HASH( - MSG_DEVICE_CONFIGURED_IN_PORT, - "Configured in port:" -) -MSG_HASH( - MSG_FAILED_TO_SET_DISK, - "Failed to set disk" -) MSG_HASH( MENU_ENUM_LABEL_VALUE_QT_CORE_OPTIONS, "コア設定" @@ -8291,10 +7450,6 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_INPUT_META_AI_SERVICE, "AIサービス" ) -MSG_HASH( - MSG_CHEEVOS_HARDCORE_MODE_DISABLED, - "A savestate was loaded, Achievements Hardcore Mode disabled for the current session. Restart to enable hardcore mode." -) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_RECORD_QUALITY, "録画の品質" @@ -8311,14 +7466,6 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_UDP_STREAM_PORT, "UDP配信ポート" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_ACCOUNTS_TWITCH, - "Twitch" -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_ACCOUNTS_YOUTUBE, - "YouTube" -) MSG_HASH( MENU_ENUM_LABEL_VALUE_TWITCH_STREAM_KEY, "Twitch配信キー" @@ -8367,30 +7514,10 @@ MSG_HASH( MENU_ENUM_SUBLABEL_OZONE_MENU_COLOR_THEME, "色テーマを選択します。" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_OZONE_COLLAPSE_SIDEBAR, - "Collapse the sidebar" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_OZONE_COLLAPSE_SIDEBAR, - "Have the left sidebar always collapsed." -) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_OZONE_TRUNCATE_PLAYLIST_NAME, - "Truncate Playlist names" -) -MSG_HASH( - MENU_ENUM_SUBLABEL_OZONE_TRUNCATE_PLAYLIST_NAME, - "When enabled, will remove the system names from the playlists. For example, display 'PlayStation' instead of 'Sony - PlayStation'. Changes require a restart to take effect." -) MSG_HASH( MENU_ENUM_LABEL_VALUE_MENU_USE_PREFERRED_SYSTEM_COLOR_THEME, "システムの優先色テーマを使用" ) -MSG_HASH( - MENU_ENUM_SUBLABEL_MENU_USE_PREFERRED_SYSTEM_COLOR_THEME, - "Use your operating system's color theme (if any) - overrides theme settings." -) MSG_HASH( MSG_RESAMPLER_QUALITY_LOWEST, "最低" @@ -8427,10 +7554,6 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_FAVORITES_AVAILABLE, "お気に入りがありません。" ) -MSG_HASH( - MSG_MISSING_ASSETS, - "Warning: Missing assets, use the Online Updater if available" -) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, "ウィンドウの位置とサイズを記憶" From bf35c1faf5acccbde6b852b4c4a723a0503b0f88 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 18:42:11 +0100 Subject: [PATCH 41/75] Cleanup --- retroarch.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/retroarch.c b/retroarch.c index 75138a9c75..243af30cb5 100644 --- a/retroarch.c +++ b/retroarch.c @@ -21648,12 +21648,10 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp, unsigned base_width; /* Use system reported sizes as these define the * geometry for the "normal" case. */ - unsigned base_height; + unsigned base_height = video_driver_av_info.geometry.base_height; if (retroarch_get_rotation() % 2) base_height = video_driver_av_info.geometry.base_width; - else - base_height = video_driver_av_info.geometry.base_height; if (base_height == 0) base_height = 1; From 3f34f5072f599aac59ebe4486c4cde76583d1c4d Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Thu, 13 Feb 2020 18:20:49 +0000 Subject: [PATCH 42/75] (Menu Widgets) Add comment notifying that OZONE_SIDEBAR_WIDTH must be kept in sync between menu_widgets.c and ozone.h --- menu/drivers/ozone/ozone.h | 2 ++ menu/widgets/menu_widgets.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/menu/drivers/ozone/ozone.h b/menu/drivers/ozone/ozone.h index 84858261b8..7350f091ea 100644 --- a/menu/drivers/ozone/ozone.h +++ b/menu/drivers/ozone/ozone.h @@ -52,6 +52,8 @@ typedef struct ozone_handle ozone_handle_t; #define ENTRY_ICON_SIZE 46 #define ENTRY_ICON_PADDING 15 +/* > 'SIDEBAR_WIDTH' must be kept in sync with + * menu widgets metrics */ #define SIDEBAR_WIDTH 408 #define SIDEBAR_X_PADDING 40 #define SIDEBAR_Y_PADDING 20 diff --git a/menu/widgets/menu_widgets.c b/menu/widgets/menu_widgets.c index 088bba96ed..d9c79461fc 100644 --- a/menu/widgets/menu_widgets.c +++ b/menu/widgets/menu_widgets.c @@ -290,6 +290,8 @@ static char libretro_message[LIBRETRO_MESSAGE_SIZE] = {'\0'}; /* Metrics */ #define BASE_FONT_SIZE 32.0f +/* > 'OZONE_SIDEBAR_WIDTH' must be kept in sync + * with ozone menu driver metrics */ #define OZONE_SIDEBAR_WIDTH 408 static bool is_ozone; From a92943d66c72156b22ff79a6292b1a2ef9e3d71f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 20:23:41 +0100 Subject: [PATCH 43/75] Buildfix for --disable-menu --- menu/menu_shader.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/menu/menu_shader.c b/menu/menu_shader.c index e12b82070d..0a9ab874bf 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -203,8 +203,10 @@ bool menu_shader_manager_set_preset(struct video_shader *shader, ret = true; end: - command_event(CMD_EVENT_SHADER_PRESET_LOADED, NULL); +#ifdef HAVE_MENU menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); +#endif + command_event(CMD_EVENT_SHADER_PRESET_LOADED, NULL); return ret; clear: @@ -546,7 +548,9 @@ int menu_shader_manager_clear_num_passes(struct video_shader *shader) shader->passes = 0; +#ifdef HAVE_MENU menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); +#endif video_shader_resolve_parameters(NULL, shader); From d0c40e3295c4d8cc862e2407622e03f4bafa8d0a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 21:15:23 +0100 Subject: [PATCH 44/75] Remove duplicate English strings --- intl/msg_hash_it.h | 40 ---------------------------------------- intl/msg_hash_ja.h | 4 ---- intl/msg_hash_vn.h | 8 -------- 3 files changed, 52 deletions(-) diff --git a/intl/msg_hash_it.h b/intl/msg_hash_it.h index fdbe4504ea..7cc562ae1f 100644 --- a/intl/msg_hash_it.h +++ b/intl/msg_hash_it.h @@ -3810,34 +3810,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_LANG_AZERBAIJANI, "Azerbaijani" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_LANG_ALBANIAN, - "Albanese" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_LANG_AFRIKAANS, - "Afrikaans" - ) MSG_HASH( MENU_ENUM_LABEL_VALUE_LANG_ESTONIAN, "Estone" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_LANG_FILIPINO, - "Filippino" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_LANG_FINNISH, - "Finnish" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_LANG_GALICIAN, - "Galician" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_LANG_GEORGIAN, - "Georgian" - ) MSG_HASH( MENU_ENUM_LABEL_VALUE_LANG_GUJARATI, "Gujarati" @@ -3858,18 +3834,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_LANG_HUNGARIAN, "Ungherese" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_LANG_ICELANDIC, - "Icelandic" - ) MSG_HASH( MENU_ENUM_LABEL_VALUE_LANG_INDONESIAN, "Indonesiano" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_LANG_IRISH, - "Irish" - ) MSG_HASH( MENU_ENUM_LABEL_VALUE_LANG_KANNADA, "Kannada" @@ -3946,14 +3914,6 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_LANG_URDU, "Urdu" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_LANG_WELSH, - "Welsh" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_LANG_YIDDISH, - "Yiddish" - ) MSG_HASH(MENU_ENUM_SUBLABEL_LOAD_DISC, "Carica un disco fisico multimediale. Dovresti prima selezionare il core (Carica Core) che intendi utilizzare con il disco.") MSG_HASH(MENU_ENUM_SUBLABEL_DUMP_DISC, diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index 2e92f2b9e0..791470f910 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -624,10 +624,6 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_CONTENT_FAVORITES_SIZE, "お気に入りの保存件数" ) -MSG_HASH( - MENU_ENUM_SUBLABEL_CONTENT_FAVORITES_SIZE, - "Limit the number of entries in the favorites playlist. Once limit is reached, new additions will be prevented until old entries are removed. Setting a value of -1 allows 'unlimited' (99999) entries. WARNING: Reducing the value will delete existing entries!" -) MSG_HASH( MENU_ENUM_LABEL_VALUE_PLAYLIST_ENTRY_REMOVE, "エントリの削除を許可" diff --git a/intl/msg_hash_vn.h b/intl/msg_hash_vn.h index 4bc91ab86a..42d2b64c9f 100644 --- a/intl/msg_hash_vn.h +++ b/intl/msg_hash_vn.h @@ -320,10 +320,6 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_CLOSE_CONTENT, "Đóng nội dung" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_CONFIG, - "Config" - ) MSG_HASH( MENU_ENUM_LABEL_VALUE_CONFIGURATIONS, "Tải cấu hình" @@ -437,8 +433,6 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_DRIVER_SETTINGS, "Trình điều khiển") MSG_HASH(MENU_ENUM_LABEL_VALUE_DUMMY_ON_CORE_SHUTDOWN, "Tải Core giả khi tắt máy") -MSG_HASH(MENU_ENUM_LABEL_VALUE_CHECK_FOR_MISSING_FIRMWARE, - "Check for Missing Firmware Before Loading") MSG_HASH(MENU_ENUM_LABEL_VALUE_DYNAMIC_WALLPAPER, "Nền năng động") MSG_HASH(MENU_ENUM_LABEL_VALUE_DYNAMIC_WALLPAPERS_DIRECTORY, @@ -556,8 +550,6 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_APPLY_CHANGES, "Áp dụng Changes") MSG_HASH(MENU_ENUM_LABEL_VALUE_SHOW_ADVANCED_SETTINGS, "Show Advanced thiết lập") -MSG_HASH(MENU_ENUM_LABEL_VALUE_SHOW_HIDDEN_FILES, - "Show Hidden Files and Folders") MSG_HASH(MENU_ENUM_LABEL_VALUE_SHUTDOWN, "Tắt Máy") #ifdef HAVE_LAKKA From f4d93587a34270d7cb34c8b7c789b6c989483d63 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 21:17:46 +0100 Subject: [PATCH 45/75] Remove unnecessary strings --- intl/msg_hash_fr.h | 80 ---------------------------------------------- 1 file changed, 80 deletions(-) diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index 66b4866292..381b7920e0 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -42,10 +42,6 @@ MSG_HASH( MSG_UNKNOWN_COMPILER, "Compilateur inconnu" ) -MSG_HASH( - MSG_NATIVE, - "Native" - ) MSG_HASH( MSG_DEVICE_DISCONNECTED_FROM_PORT, "Périphérique déconnecté du port" @@ -7730,10 +7726,6 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_MENU_RGUI_PARTICLE_EFFECT_SPEED, "Vitesse de l'animation en arrière-plan" ) -MSG_HASH( - MENU_ENUM_SUBLABEL_MENU_RGUI_PARTICLE_EFFECT_SPEED, - "Adjust speed of background particle animation effects." - ) MSG_HASH( MENU_ENUM_LABEL_VALUE_MENU_RGUI_EXTENDED_ASCII, "Prise en charge de l'ASCII étendu" @@ -8273,10 +8265,6 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_CHEAT_BROWSE_MEMORY, "Parcourir l'adresse : %08X" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_CHEAT_DESC, - "Description" - ) MSG_HASH( MENU_ENUM_LABEL_VALUE_CHEAT_STATE, "Activé" @@ -8477,70 +8465,6 @@ MSG_HASH( MENU_ENUM_LABEL_CHEAT_MEMORY_SIZE_32, "32-bit, valeur max = 0xFFFFFFFF" ) -MSG_HASH( - MENU_ENUM_LABEL_RUMBLE_PORT_0, - "1" - ) -MSG_HASH( - MENU_ENUM_LABEL_RUMBLE_PORT_1, - "2" - ) -MSG_HASH( - MENU_ENUM_LABEL_RUMBLE_PORT_2, - "3" - ) -MSG_HASH( - MENU_ENUM_LABEL_RUMBLE_PORT_3, - "4" - ) -MSG_HASH( - MENU_ENUM_LABEL_RUMBLE_PORT_4, - "5" - ) -MSG_HASH( - MENU_ENUM_LABEL_RUMBLE_PORT_5, - "6" - ) -MSG_HASH( - MENU_ENUM_LABEL_RUMBLE_PORT_6, - "7" - ) -MSG_HASH( - MENU_ENUM_LABEL_RUMBLE_PORT_7, - "8" - ) -MSG_HASH( - MENU_ENUM_LABEL_RUMBLE_PORT_8, - "9" - ) -MSG_HASH( - MENU_ENUM_LABEL_RUMBLE_PORT_9, - "10" - ) -MSG_HASH( - MENU_ENUM_LABEL_RUMBLE_PORT_10, - "11" - ) -MSG_HASH( - MENU_ENUM_LABEL_RUMBLE_PORT_11, - "12" - ) -MSG_HASH( - MENU_ENUM_LABEL_RUMBLE_PORT_12, - "13" - ) -MSG_HASH( - MENU_ENUM_LABEL_RUMBLE_PORT_13, - "14" - ) -MSG_HASH( - MENU_ENUM_LABEL_RUMBLE_PORT_14, - "15" - ) -MSG_HASH( - MENU_ENUM_LABEL_RUMBLE_PORT_15, - "16" - ) MSG_HASH( MENU_ENUM_LABEL_RUMBLE_PORT_16, "Tous" @@ -8777,10 +8701,6 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_QT_CONFIRM_DELETE_PLAYLIST, "Êtes-vous sûr de vouloir supprimer la liste de lecture \"%1\"?" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_QT_QUESTION, - "Question" - ) MSG_HASH( MENU_ENUM_LABEL_VALUE_QT_COULD_NOT_DELETE_FILE, "Impossible de supprimer le fichier." From a6d64696e32ca3b3c2ac30e2e2aaf3de8d229e17 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 21:24:02 +0100 Subject: [PATCH 46/75] (menu_animation.c) Cleanups --- menu/menu_animation.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/menu/menu_animation.c b/menu/menu_animation.c index c9f81dd26d..799e7b7550 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -1377,11 +1377,9 @@ static void build_ticker_loop_string( /* Copy 'trailing' chunk of source string, if required */ if (num_chars1 > 0) - { utf8cpy( dest_str, dest_str_len, utf8skip(src_str, char_offset1), num_chars1); - } /* Copy chunk of spacer string, if required */ if (num_chars2 > 0) @@ -1484,7 +1482,6 @@ bool menu_animation_ticker(menu_animation_ctx_ticker_t *ticker) /* 'Fixed width' font version of menu_animation_ticker_smooth() */ bool menu_animation_ticker_smooth_fw(menu_animation_ctx_ticker_smooth_t *ticker) { - size_t src_str_len = 0; size_t spacer_len = 0; unsigned glyph_width = ticker->glyph_width; unsigned src_str_width = 0; @@ -1497,7 +1494,7 @@ bool menu_animation_ticker_smooth_fw(menu_animation_ctx_ticker_smooth_t *ticker) * repeat */ /* Get length + width of src string */ - src_str_len = utf8len(ticker->src_str); + size_t src_str_len = utf8len(ticker->src_str); if (src_str_len < 1) goto end; @@ -1507,8 +1504,8 @@ bool menu_animation_ticker_smooth_fw(menu_animation_ctx_ticker_smooth_t *ticker) * can just copy the entire string */ if (src_str_width <= ticker->field_width) { - utf8cpy(ticker->dst_str, ticker->dst_str_len, ticker->src_str, src_str_len); - + utf8cpy(ticker->dst_str, ticker->dst_str_len, + ticker->src_str, src_str_len); if (ticker->dst_str_width) *ticker->dst_str_width = src_str_width; *ticker->x_offset = 0; @@ -1604,11 +1601,9 @@ bool menu_animation_ticker_smooth_fw(menu_animation_ctx_ticker_smooth_t *ticker) /* Copy required substring */ if (num_chars > 0) - { utf8cpy( ticker->dst_str, ticker->dst_str_len, utf8skip(ticker->src_str, char_offset), num_chars); - } if (ticker->dst_str_width) *ticker->dst_str_width = num_chars * glyph_width; @@ -1678,17 +1673,18 @@ bool menu_animation_ticker_smooth(menu_animation_ctx_ticker_smooth_t *ticker) if (glyph_width < 0) goto end; - src_char_widths[i] = (unsigned)glyph_width; - src_str_width += (unsigned)glyph_width; + src_char_widths[i] = (unsigned)glyph_width; + src_str_width += (unsigned)glyph_width; - str_ptr = utf8skip(str_ptr, 1); + str_ptr = utf8skip(str_ptr, 1); } /* If total src string width is <= text field width, we * can just copy the entire string */ if (src_str_width <= ticker->field_width) { - utf8cpy(ticker->dst_str, ticker->dst_str_len, ticker->src_str, src_str_len); + utf8cpy(ticker->dst_str, ticker->dst_str_len, + ticker->src_str, src_str_len); if (ticker->dst_str_width) *ticker->dst_str_width = src_str_width; @@ -1705,7 +1701,8 @@ bool menu_animation_ticker_smooth(menu_animation_ctx_ticker_smooth_t *ticker) unsigned current_width = 0; unsigned num_chars = 0; int period_width = - font_driver_get_message_width(ticker->font, ".", 1, ticker->font_scale); + font_driver_get_message_width(ticker->font, + ".", 1, ticker->font_scale); /* Sanity check */ if (period_width < 0) @@ -1733,7 +1730,8 @@ bool menu_animation_ticker_smooth(menu_animation_ctx_ticker_smooth_t *ticker) } /* Copy string segment + add suffix */ - utf8cpy(ticker->dst_str, ticker->dst_str_len, ticker->src_str, num_chars); + utf8cpy(ticker->dst_str, ticker->dst_str_len, + ticker->src_str, num_chars); strlcat(ticker->dst_str, "...", ticker->dst_str_len); if (ticker->dst_str_width) @@ -1816,16 +1814,16 @@ bool menu_animation_ticker_smooth(menu_animation_ctx_ticker_smooth_t *ticker) menu_animation_ticker_smooth_generic( ticker->idx, - src_char_widths, src_str_len, src_str_width, ticker->field_width, - &char_offset, &num_chars, ticker->x_offset, ticker->dst_str_width); + src_char_widths, src_str_len, + src_str_width, ticker->field_width, + &char_offset, &num_chars, + ticker->x_offset, ticker->dst_str_width); /* Copy required substring */ if (num_chars > 0) - { utf8cpy( ticker->dst_str, ticker->dst_str_len, utf8skip(ticker->src_str, char_offset), num_chars); - } break; } @@ -1861,7 +1859,8 @@ end: } static void build_line_ticker_string( - size_t num_display_lines, size_t line_offset, struct string_list *lines, + size_t num_display_lines, size_t line_offset, + struct string_list *lines, char *dest_str, size_t dest_str_len) { size_t i; From 835acec8f3c446f066f691a9a8ad678ee6ed7262 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 21:39:24 +0100 Subject: [PATCH 47/75] (record_ffmpeg.c) Cleanups --- record/drivers/record_ffmpeg.c | 206 +++++++++++++++++++-------------- 1 file changed, 120 insertions(+), 86 deletions(-) diff --git a/record/drivers/record_ffmpeg.c b/record/drivers/record_ffmpeg.c index 009efe9638..597209019c 100644 --- a/record/drivers/record_ffmpeg.c +++ b/record/drivers/record_ffmpeg.c @@ -310,18 +310,18 @@ static void ffmpeg_audio_resolve_sample_rate(ffmpeg_t *handle, int input_rate = (int)param->samplerate; /* Favor closest sampling rate, but always prefer ratio > 1.0. */ - int best_rate = codec->supported_samplerates[0]; - int best_diff = best_rate - input_rate; + int best_rate = codec->supported_samplerates[0]; + int best_diff = best_rate - input_rate; for (i = 1; codec->supported_samplerates[i]; i++) { - bool better_rate; - int diff = codec->supported_samplerates[i] - input_rate; + bool better_rate = false; + int diff = codec->supported_samplerates[i] - input_rate; if (best_diff < 0) - better_rate = (diff > best_diff); + better_rate = (diff > best_diff); else - better_rate = ((diff >= 0) && (diff < best_diff)); + better_rate = ((diff >= 0) && (diff < best_diff)); if (better_rate) { @@ -350,9 +350,9 @@ static bool ffmpeg_init_audio(ffmpeg_t *handle) return false; } - audio->encoder = codec; + audio->encoder = codec; - audio->codec = avcodec_alloc_context3(codec); + audio->codec = avcodec_alloc_context3(codec); audio->codec->codec_type = AVMEDIA_TYPE_AUDIO; audio->codec->channels = param->channels; @@ -364,9 +364,10 @@ static bool ffmpeg_init_audio(ffmpeg_t *handle) if (params->sample_rate) { - audio->ratio = (double)params->sample_rate / param->samplerate; + audio->ratio = (double)params->sample_rate + / param->samplerate; audio->codec->sample_rate = params->sample_rate; - audio->codec->time_base = av_d2q(1.0 / params->sample_rate, 1000000); + audio->codec->time_base = av_d2q(1.0 / params->sample_rate, 1000000); retro_resampler_realloc(&audio->resampler_data, &audio->resampler, @@ -376,29 +377,31 @@ static bool ffmpeg_init_audio(ffmpeg_t *handle) } else { - audio->codec->sample_fmt = AV_SAMPLE_FMT_S16; + audio->codec->sample_fmt = AV_SAMPLE_FMT_S16; audio->codec->sample_rate = (int)roundf(param->samplerate); - audio->codec->time_base = av_d2q(1.0 / param->samplerate, 1000000); + audio->codec->time_base = av_d2q(1.0 / param->samplerate, 1000000); } if (params->audio_qscale) { - audio->codec->flags |= AV_CODEC_FLAG_QSCALE; - audio->codec->global_quality = params->audio_global_quality; + audio->codec->flags |= AV_CODEC_FLAG_QSCALE; + audio->codec->global_quality = params->audio_global_quality; } else if (params->audio_bit_rate) - audio->codec->bit_rate = params->audio_bit_rate; + audio->codec->bit_rate = params->audio_bit_rate; /* Allow experimental codecs. */ audio->codec->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; if (handle->muxer.ctx->oformat->flags & AVFMT_GLOBALHEADER) - audio->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; + audio->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; - if (avcodec_open2(audio->codec, codec, params->audio_opts ? ¶ms->audio_opts : NULL) != 0) + if (avcodec_open2(audio->codec, codec, + params->audio_opts ? ¶ms->audio_opts : NULL) != 0) return false; - if (!audio->codec->frame_size) /* If not set (PCM), just set something. */ + /* If not set (PCM), just set something. */ + if (!audio->codec->frame_size) audio->codec->frame_size = 1024; audio->buffer = (uint8_t*)av_malloc( @@ -414,7 +417,8 @@ static bool ffmpeg_init_audio(ffmpeg_t *handle) return false; audio->outbuf_size = AV_INPUT_BUFFER_MIN_SIZE; - audio->outbuf = (uint8_t*)av_malloc(audio->outbuf_size); + audio->outbuf = (uint8_t*)av_malloc(audio->outbuf_size); + if (!audio->outbuf) return false; @@ -427,7 +431,7 @@ static bool ffmpeg_init_video(ffmpeg_t *handle) struct ff_config_param *params = &handle->config; struct ff_video_info *video = &handle->video; struct record_params *param = &handle->params; - AVCodec *codec = NULL; + AVCodec *codec = NULL; if (*params->vcodec) codec = avcodec_find_encoder_by_name(params->vcodec); @@ -540,15 +544,15 @@ static bool ffmpeg_init_video(ffmpeg_t *handle) /* Allocate a big buffer. ffmpeg API doesn't seem to give us some * clues how big this buffer should be. */ - video->outbuf_size = 1 << 23; - video->outbuf = (uint8_t*)av_malloc(video->outbuf_size); + video->outbuf_size = 1 << 23; + video->outbuf = (uint8_t*)av_malloc(video->outbuf_size); video->frame_drop_ratio = params->frame_drop_ratio; size = avpicture_get_size(video->pix_fmt, param->out_width, param->out_height); - video->conv_frame_buf = (uint8_t*)av_malloc(size); - video->conv_frame = av_frame_alloc(); + video->conv_frame_buf = (uint8_t*)av_malloc(size); + video->conv_frame = av_frame_alloc(); avpicture_fill((AVPicture*)video->conv_frame, video->conv_frame_buf, video->pix_fmt, param->out_width, param->out_height); @@ -560,15 +564,19 @@ static bool ffmpeg_init_video(ffmpeg_t *handle) return true; } -static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned preset) +static bool ffmpeg_init_config_common(struct ff_config_param *params, + unsigned preset, + bool video_gpu_record, + unsigned video_record_scale_factor, + unsigned video_stream_scale_factor, + unsigned streaming_mode, + unsigned video_record_threads) { - settings_t *settings = config_get_ptr(); - switch (preset) { case RECORD_CONFIG_TYPE_RECORDING_LOW_QUALITY: case RECORD_CONFIG_TYPE_STREAMING_LOW_QUALITY: - params->threads = settings->uints.video_record_threads; + params->threads = video_record_threads; params->frame_drop_ratio = 1; params->audio_enable = true; params->audio_global_quality = 75; @@ -584,7 +592,7 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p break; case RECORD_CONFIG_TYPE_RECORDING_MED_QUALITY: case RECORD_CONFIG_TYPE_STREAMING_MED_QUALITY: - params->threads = settings->uints.video_record_threads; + params->threads = video_record_threads; params->frame_drop_ratio = 1; params->audio_enable = true; params->audio_global_quality = 75; @@ -600,7 +608,7 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p break; case RECORD_CONFIG_TYPE_RECORDING_HIGH_QUALITY: case RECORD_CONFIG_TYPE_STREAMING_HIGH_QUALITY: - params->threads = settings->uints.video_record_threads; + params->threads = video_record_threads; params->frame_drop_ratio = 1; params->audio_enable = true; params->audio_global_quality = 100; @@ -615,7 +623,7 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p av_dict_set(¶ms->audio_opts, "audio_global_quality", "100", 0); break; case RECORD_CONFIG_TYPE_RECORDING_LOSSLESS_QUALITY: - params->threads = settings->uints.video_record_threads; + params->threads = video_record_threads; params->frame_drop_ratio = 1; params->audio_enable = true; params->audio_global_quality = 80; @@ -628,7 +636,7 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p av_dict_set(¶ms->audio_opts, "audio_global_quality", "100", 0); break; case RECORD_CONFIG_TYPE_RECORDING_WEBM_FAST: - params->threads = settings->uints.video_record_threads; + params->threads = video_record_threads; params->frame_drop_ratio = 1; params->audio_enable = true; params->audio_global_quality = 50; @@ -642,7 +650,7 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p av_dict_set(¶ms->audio_opts, "audio_global_quality", "50", 0); break; case RECORD_CONFIG_TYPE_RECORDING_WEBM_HIGH_QUALITY: - params->threads = settings->uints.video_record_threads; + params->threads = video_record_threads; params->frame_drop_ratio = 1; params->audio_enable = true; params->audio_global_quality = 75; @@ -656,7 +664,7 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p av_dict_set(¶ms->audio_opts, "audio_global_quality", "75", 0); break; case RECORD_CONFIG_TYPE_RECORDING_GIF: - params->threads = settings->uints.video_record_threads; + params->threads = video_record_threads; params->frame_drop_ratio = 4; params->audio_enable = false; params->audio_global_quality = 0; @@ -669,7 +677,7 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p av_dict_set(¶ms->audio_opts, "audio_global_quality", "0", 0); break; case RECORD_CONFIG_TYPE_RECORDING_APNG: - params->threads = settings->uints.video_record_threads; + params->threads = video_record_threads; params->frame_drop_ratio = 1; params->audio_enable = false; params->audio_global_quality = 0; @@ -682,7 +690,7 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p av_dict_set(¶ms->audio_opts, "audio_global_quality", "0", 0); break; case RECORD_CONFIG_TYPE_STREAMING_NETPLAY: - params->threads = settings->uints.video_record_threads; + params->threads = video_record_threads; params->frame_drop_ratio = 1; params->audio_enable = true; params->audio_global_quality = 50; @@ -715,27 +723,27 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p if (preset <= RECORD_CONFIG_TYPE_RECORDING_LOSSLESS_QUALITY) { - if (!settings->bools.video_gpu_record) - params->scale_factor = settings->uints.video_record_scale_factor > 0 ? - settings->uints.video_record_scale_factor : 1; + if (!video_gpu_record) + params->scale_factor = (video_record_scale_factor > 0) ? + video_record_scale_factor : 1; else params->scale_factor = 1; strlcpy(params->format, "matroska", sizeof(params->format)); } else if (preset >= RECORD_CONFIG_TYPE_RECORDING_WEBM_FAST && preset < RECORD_CONFIG_TYPE_RECORDING_GIF) { - if (!settings->bools.video_gpu_record) - params->scale_factor = settings->uints.video_record_scale_factor > 0 ? - settings->uints.video_record_scale_factor : 1; + if (!video_gpu_record) + params->scale_factor = (video_record_scale_factor > 0) ? + video_record_scale_factor : 1; else params->scale_factor = 1; strlcpy(params->format, "webm", sizeof(params->format)); } else if (preset >= RECORD_CONFIG_TYPE_RECORDING_GIF && preset < RECORD_CONFIG_TYPE_RECORDING_APNG) { - if (!settings->bools.video_gpu_record) - params->scale_factor = settings->uints.video_record_scale_factor > 0 ? - settings->uints.video_record_scale_factor : 1; + if (!video_gpu_record) + params->scale_factor = (video_record_scale_factor > 0) ? + video_record_scale_factor : 1; else params->scale_factor = 1; strlcpy(params->format, "gif", sizeof(params->format)); @@ -747,12 +755,13 @@ static bool ffmpeg_init_config_common(struct ff_config_param *params, unsigned p } else if (preset <= RECORD_CONFIG_TYPE_STREAMING_HIGH_QUALITY) { - if (!settings->bools.video_gpu_record) - params->scale_factor = settings->uints.video_stream_scale_factor > 0 ? - settings->uints.video_stream_scale_factor : 1; + if (!video_gpu_record) + params->scale_factor = (video_stream_scale_factor > 0) ? + video_stream_scale_factor : 1; else params->scale_factor = 1; - if (settings->uints.streaming_mode == STREAMING_MODE_YOUTUBE || settings->uints.streaming_mode == STREAMING_MODE_TWITCH) + if ( streaming_mode == STREAMING_MODE_YOUTUBE || + streaming_mode == STREAMING_MODE_TWITCH) strlcpy(params->format, "flv", sizeof(params->format)); else strlcpy(params->format, "mpegts", sizeof(params->format)); @@ -1033,23 +1042,37 @@ static void ffmpeg_free(void *data) static void *ffmpeg_new(const struct record_params *params) { - ffmpeg_t *handle = (ffmpeg_t*)calloc(1, sizeof(*handle)); + settings_t *settings = config_get_ptr(); + ffmpeg_t *handle = (ffmpeg_t*)calloc(1, sizeof(*handle)); if (!handle) return NULL; av_register_all(); avformat_network_init(); - handle->params = *params; + handle->params = *params; - if (params->preset == RECORD_CONFIG_TYPE_RECORDING_CUSTOM || params->preset == RECORD_CONFIG_TYPE_STREAMING_CUSTOM) + switch (params->preset) { - RARCH_LOG("config: %s %s\n", &handle->config, params->config); - if (!ffmpeg_init_config(&handle->config, params->config)) - goto error; + case RECORD_CONFIG_TYPE_RECORDING_CUSTOM: + case RECORD_CONFIG_TYPE_STREAMING_CUSTOM: + if (!ffmpeg_init_config( + &handle->config, + params->config)) + goto error; + break; + default: + ffmpeg_init_config_common( + &handle->config, + params->preset, + settings->bools.video_gpu_record, + settings->uints.video_record_scale_factor, + settings->uints.video_stream_scale_factor, + settings->uints.streaming_mode, + settings->uints.video_record_threads + ); + break; } - else - ffmpeg_init_config_common(&handle->config, params->preset); if (!ffmpeg_init_muxer_pre(handle)) goto error; @@ -1077,15 +1100,15 @@ static bool ffmpeg_push_video(void *data, const struct record_video_data *vid) { unsigned y; - bool drop_frame; struct record_video_data attr_data; + bool drop_frame = false; ffmpeg_t *handle = (ffmpeg_t*)data; int offset = 0; if (!handle || !vid) return false; - drop_frame = handle->video.frame_drop_count++ % + drop_frame = handle->video.frame_drop_count++ % handle->video.frame_drop_ratio; handle->video.frame_drop_count %= handle->video.frame_drop_ratio; @@ -1096,6 +1119,7 @@ static bool ffmpeg_push_video(void *data, for (;;) { unsigned avail; + slock_lock(handle->lock); avail = fifo_write_avail(handle->attr_fifo); slock_unlock(handle->lock); @@ -1157,6 +1181,7 @@ static bool ffmpeg_push_audio(void *data, for (;;) { unsigned avail; + slock_lock(handle->lock); avail = fifo_write_avail(handle->audio_fifo); slock_unlock(handle->lock); @@ -1257,7 +1282,7 @@ static void ffmpeg_scale_input(ffmpeg_t *handle, if (handle->video.use_sws) { - int linesize = vid->pitch; + int linesize = vid->pitch; handle->video.sws = sws_getCachedContext(handle->video.sws, vid->width, vid->height, handle->video.in_pix_fmt, @@ -1270,7 +1295,6 @@ static void ffmpeg_scale_input(ffmpeg_t *handle, handle->video.conv_frame->linesize); } else - { video_frame_record_scale( &handle->video.scaler, handle->video.conv_frame->data[0], @@ -1282,7 +1306,6 @@ static void ffmpeg_scale_input(ffmpeg_t *handle, vid->height, vid->pitch, shrunk); - } } static bool ffmpeg_push_video_thread(ffmpeg_t *handle, @@ -1356,10 +1379,12 @@ static bool encode_audio(ffmpeg_t *handle, bool dry) int ret; av_init_packet(&pkt); + pkt.data = handle->audio.outbuf; pkt.size = handle->audio.outbuf_size; - frame = av_frame_alloc(); + frame = av_frame_alloc(); + if (!frame) return false; @@ -1370,14 +1395,17 @@ static bool encode_audio(ffmpeg_t *handle, bool dry) planarize_audio(handle); - samples_size = av_samples_get_buffer_size(NULL, + samples_size = av_samples_get_buffer_size( + NULL, handle->audio.codec->channels, handle->audio.frames_in_buffer, handle->audio.codec->sample_fmt, 0); - avcodec_fill_audio_frame(frame, handle->audio.codec->channels, + avcodec_fill_audio_frame(frame, + handle->audio.codec->channels, handle->audio.codec->sample_fmt, - handle->audio.is_planar ? (uint8_t*)handle->audio.planar_buf : + handle->audio.is_planar + ? (uint8_t*)handle->audio.planar_buf : handle->audio.buffer, samples_size, 0); @@ -1449,21 +1477,25 @@ static void ffmpeg_audio_resample(ffmpeg_t *handle, if (!handle->audio.float_conv) return; - handle->audio.float_conv_frames = aud->frames; - + handle->audio.float_conv_frames = aud->frames; /* To make sure we don't accidentially overflow. */ - handle->audio.resample_out_frames = aud->frames * handle->audio.ratio + 16; - - handle->audio.resample_out = (float*)av_realloc(handle->audio.resample_out, - handle->audio.resample_out_frames * - handle->params.channels * sizeof(float)); + handle->audio.resample_out_frames = aud->frames + * handle->audio.ratio + 16; + handle->audio.resample_out = (float*) + av_realloc(handle->audio.resample_out, + handle->audio.resample_out_frames * + handle->params.channels * sizeof(float)); if (!handle->audio.resample_out) return; - handle->audio.fixed_conv_frames = MAX(handle->audio.resample_out_frames, + handle->audio.fixed_conv_frames = MAX( + handle->audio.resample_out_frames, handle->audio.float_conv_frames); - handle->audio.fixed_conv = (int16_t*)av_realloc(handle->audio.fixed_conv, - handle->audio.fixed_conv_frames * handle->params.channels * sizeof(int16_t)); + handle->audio.fixed_conv = (int16_t*)av_realloc( + handle->audio.fixed_conv, + handle->audio.fixed_conv_frames * + handle->params.channels * sizeof(int16_t)); + if (!handle->audio.fixed_conv) return; } @@ -1471,7 +1503,8 @@ static void ffmpeg_audio_resample(ffmpeg_t *handle, if (handle->audio.use_float || handle->audio.resampler) { convert_s16_to_float(handle->audio.float_conv, - (const int16_t*)aud->data, aud->frames * handle->params.channels, 1.0); + (const int16_t*)aud->data, aud->frames + * handle->params.channels, 1.0); aud->data = handle->audio.float_conv; } @@ -1509,11 +1542,11 @@ static bool ffmpeg_push_audio_thread(ffmpeg_t *handle, while (written_frames < aud->frames) { - size_t can_write = handle->audio.codec->frame_size - + size_t can_write = handle->audio.codec->frame_size - handle->audio.frames_in_buffer; - size_t write_left = aud->frames - written_frames; - size_t write_frames = write_left > can_write ? can_write : write_left; - size_t write_size = write_frames * + size_t write_left = aud->frames - written_frames; + size_t write_frames = write_left > can_write ? can_write : write_left; + size_t write_size = write_frames * handle->params.channels * handle->audio.sample_size; size_t bytes_in_buffer = handle->audio.frames_in_buffer * @@ -1529,7 +1562,8 @@ static bool ffmpeg_push_audio_thread(ffmpeg_t *handle, handle->audio.frames_in_buffer += write_frames; if ((handle->audio.frames_in_buffer - < (size_t)handle->audio.codec->frame_size) && require_block) + < (size_t)handle->audio.codec->frame_size) + && require_block) break; if (!encode_audio(handle, false)) @@ -1569,13 +1603,13 @@ static void ffmpeg_flush_video(ffmpeg_t *handle) static void ffmpeg_flush_buffers(ffmpeg_t *handle) { - bool did_work; - void *video_buf = av_malloc(2 * handle->params.fb_width * + void *audio_buf = NULL; + bool did_work = false;; + void *video_buf = av_malloc(2 * handle->params.fb_width * handle->params.fb_height * handle->video.pix_size); size_t audio_buf_size = handle->config.audio_enable ? (handle->audio.codec->frame_size * handle->params.channels * sizeof(int16_t)) : 0; - void *audio_buf = NULL; if (audio_buf_size) audio_buf = av_malloc(audio_buf_size); @@ -1613,7 +1647,7 @@ static void ffmpeg_flush_buffers(ffmpeg_t *handle) did_work = true; } - } while (did_work); + }while(did_work); /* Flush out last audio. */ if (handle->config.audio_enable) From 9c3735626730f648f557bca8517a48a0b6dc70a5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 21:41:29 +0100 Subject: [PATCH 48/75] (record_ffmpeg.c) Start reducing settings_t usage --- record/drivers/record_ffmpeg.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/record/drivers/record_ffmpeg.c b/record/drivers/record_ffmpeg.c index 597209019c..3d2227c779 100644 --- a/record/drivers/record_ffmpeg.c +++ b/record/drivers/record_ffmpeg.c @@ -335,9 +335,8 @@ static void ffmpeg_audio_resolve_sample_rate(ffmpeg_t *handle, } } -static bool ffmpeg_init_audio(ffmpeg_t *handle) +static bool ffmpeg_init_audio(ffmpeg_t *handle, const char *audio_resampler) { - settings_t *settings = config_get_ptr(); struct ff_config_param *params = &handle->config; struct ff_audio_info *audio = &handle->audio; struct record_params *param = &handle->params; @@ -369,9 +368,10 @@ static bool ffmpeg_init_audio(ffmpeg_t *handle) audio->codec->sample_rate = params->sample_rate; audio->codec->time_base = av_d2q(1.0 / params->sample_rate, 1000000); - retro_resampler_realloc(&audio->resampler_data, + retro_resampler_realloc( + &audio->resampler_data, &audio->resampler, - settings->arrays.audio_resampler, + audio_resampler, RESAMPLER_QUALITY_DONTCARE, audio->ratio); } @@ -1080,7 +1080,9 @@ static void *ffmpeg_new(const struct record_params *params) if (!ffmpeg_init_video(handle)) goto error; - if (handle->config.audio_enable && !ffmpeg_init_audio(handle)) + if (handle->config.audio_enable && + !ffmpeg_init_audio(handle, + settings->arrays.audio_resampler)) goto error; if (!ffmpeg_init_muxer_post(handle)) From 950f6bb7524d9ada65e6091ec55f930264033287 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 21:48:52 +0100 Subject: [PATCH 49/75] (record_ffmpeg) No more settings_t dependency --- record/drivers/record_ffmpeg.c | 14 ++++++-------- retroarch.c | 7 +++++++ retroarch.h | 8 ++++++++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/record/drivers/record_ffmpeg.c b/record/drivers/record_ffmpeg.c index 3d2227c779..7a5383d292 100644 --- a/record/drivers/record_ffmpeg.c +++ b/record/drivers/record_ffmpeg.c @@ -65,7 +65,6 @@ extern "C" { } #endif -#include "../../configuration.h" #include "../../retroarch.h" #include "../../verbosity.h" @@ -1042,7 +1041,6 @@ static void ffmpeg_free(void *data) static void *ffmpeg_new(const struct record_params *params) { - settings_t *settings = config_get_ptr(); ffmpeg_t *handle = (ffmpeg_t*)calloc(1, sizeof(*handle)); if (!handle) return NULL; @@ -1065,11 +1063,11 @@ static void *ffmpeg_new(const struct record_params *params) ffmpeg_init_config_common( &handle->config, params->preset, - settings->bools.video_gpu_record, - settings->uints.video_record_scale_factor, - settings->uints.video_stream_scale_factor, - settings->uints.streaming_mode, - settings->uints.video_record_threads + params->video_gpu_record, + params->video_record_scale_factor, + params->video_stream_scale_factor, + params->streaming_mode, + params->video_record_threads ); break; } @@ -1082,7 +1080,7 @@ static void *ffmpeg_new(const struct record_params *params) if (handle->config.audio_enable && !ffmpeg_init_audio(handle, - settings->arrays.audio_resampler)) + params->audio_resampler)) goto error; if (!ffmpeg_init_muxer_post(handle)) diff --git a/retroarch.c b/retroarch.c index 243af30cb5..3c8ff69521 100644 --- a/retroarch.c +++ b/retroarch.c @@ -11988,6 +11988,13 @@ static bool recording_init(void) } } + params.audio_resampler = settings->arrays.audio_resampler; + params.video_gpu_record = settings->bools.video_gpu_record; + params.video_record_scale_factor = settings->uints.video_record_scale_factor; + params.video_stream_scale_factor = settings->uints.video_stream_scale_factor; + params.video_record_threads = settings->uints.video_record_threads; + params.streaming_mode = settings->uints.streaming_mode; + params.out_width = av_info->geometry.base_width; params.out_height = av_info->geometry.base_height; params.fb_width = av_info->geometry.max_width; diff --git a/retroarch.h b/retroarch.h index 52f182b3e5..c193a6f363 100644 --- a/retroarch.h +++ b/retroarch.h @@ -660,6 +660,14 @@ struct record_params /* Path to config. Optional. */ const char *config; + + bool video_gpu_record; + unsigned video_record_scale_factor; + unsigned video_stream_scale_factor; + unsigned video_record_threads; + unsigned streaming_mode; + + const char *audio_resampler; }; struct record_video_data From 59d6ad6b0543db46396d58c81f4a766f1186e66b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 21:53:31 +0100 Subject: [PATCH 50/75] (platform_win32.c) Cleanup --- frontend/drivers/platform_win32.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 3d73175597..53135b65aa 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -206,12 +206,13 @@ static void gfx_set_dwm(void) { HRESULT ret; HRESULT (WINAPI *composition_enable)(UINT); - settings_t *settings = config_get_ptr(); + settings_t *settings = config_get_ptr(); + bool disable_composition = settings->bools.video_disable_composition; if (!gfx_init_dwm()) return; - if (settings->bools.video_disable_composition == dwm_composition_disabled) + if (disable_composition == dwm_composition_disabled) return; #ifdef HAVE_DYNAMIC @@ -225,10 +226,10 @@ static void gfx_set_dwm(void) return; } - ret = composition_enable(!settings->bools.video_disable_composition); + ret = composition_enable(!disable_composition); if (FAILED(ret)) RARCH_ERR("Failed to set composition state ...\n"); - dwm_composition_disabled = settings->bools.video_disable_composition; + dwm_composition_disabled = disable_composition; } static void frontend_win32_get_os(char *s, size_t len, int *major, int *minor) From c9c50f286c7f851253bda2c679f299455ed74a04 Mon Sep 17 00:00:00 2001 From: orbea Date: Thu, 13 Feb 2020 13:20:14 -0800 Subject: [PATCH 51/75] Add CXX_LINKER to the builtin glslang. Fixes https://github.com/libretro/RetroArch/issues/10112. --- Makefile.common | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.common b/Makefile.common index 535cfd9d4b..863807e511 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1543,6 +1543,7 @@ ifeq ($(HAVE_SHADERS_COMMON), 1) endif ifeq ($(HAVE_BUILTINGLSLANG), 1) + NEED_CXX_LINKER = 1 HAVE_GLSLANG_COMMON = 1 ifneq ($(findstring Win32,$(OS)),) From 4467f811e07045749e432883a4bef23b22fc2b28 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 22:33:09 +0100 Subject: [PATCH 52/75] ui_companion_driver_toggle - turn into static function --- retroarch.c | 6 ++++-- ui/ui_companion_driver.h | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/retroarch.c b/retroarch.c index 3c8ff69521..1865ef0bdc 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1191,6 +1191,8 @@ static char current_savestate_dir[PATH_MAX_LENGTH] = {0}; static char dir_savestate[PATH_MAX_LENGTH] = {0}; /* Forward declarations */ +static void ui_companion_driver_toggle(bool force); + static const void *location_driver_find_handle(int idx); static const void *audio_driver_find_handle(int idx); static const void *video_driver_find_handle(int idx); @@ -11532,7 +11534,7 @@ void ui_companion_driver_init_first(void) } } -void ui_companion_driver_toggle(bool force) +static void ui_companion_driver_toggle(bool force) { #ifdef HAVE_QT settings_t *settings = configuration_settings; @@ -11547,7 +11549,7 @@ void ui_companion_driver_toggle(bool force) if ((settings->bools.ui_companion_toggle || force) && !qt_is_inited) { ui_companion_qt_data = ui_companion_qt.init(); - qt_is_inited = true; + qt_is_inited = true; } if (ui_companion_qt.toggle && qt_is_inited) diff --git a/ui/ui_companion_driver.h b/ui/ui_companion_driver.h index f00e9263a7..ba7caaf797 100644 --- a/ui/ui_companion_driver.h +++ b/ui/ui_companion_driver.h @@ -178,8 +178,6 @@ void ui_companion_driver_notify_list_loaded(file_list_t *list, file_list_t *menu void ui_companion_driver_notify_content_loaded(void); -void ui_companion_driver_toggle(bool force); - void ui_companion_driver_free(void); const ui_msg_window_t *ui_companion_driver_get_msg_window_ptr(void); From 310bf3328eb0cfffa66335cd73684c0672f2dc8c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 22:39:29 +0100 Subject: [PATCH 53/75] (UI) Cleanups --- ui/drivers/ui_cocoa.m | 34 ++++++++-------------------------- ui/drivers/ui_cocoatouch.m | 21 +++------------------ ui/drivers/ui_win32.c | 27 ++++----------------------- 3 files changed, 15 insertions(+), 67 deletions(-) diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index c054a58a19..4c7fe308b1 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -120,16 +120,16 @@ static void app_terminate(void) case NSEventTypeMouseMoved: case NSEventTypeLeftMouseDragged: case NSEventTypeRightMouseDragged: - case NSEventTypeOtherMouseDragged: + case NSEventTypeOtherMouseDragged: { NSPoint pos; NSPoint mouse_pos; - apple = (cocoa_input_data_t*)input_driver_get_data(); + apple = (cocoa_input_data_t*)input_driver_get_data(); if (!apple) return; - pos.x = 0; - pos.y = 0; + pos.x = 0; + pos.y = 0; /* Relative */ apple->mouse_rel_x = (int16_t)event.deltaX; @@ -662,17 +662,6 @@ typedef struct ui_companion_cocoa void *empty; } ui_companion_cocoa_t; -static void ui_companion_cocoa_notify_content_loaded(void *data) -{ - (void)data; -} - -static void ui_companion_cocoa_toggle(void *data, bool force) -{ - (void)data; - (void)force; -} - static void ui_companion_cocoa_deinit(void *data) { ui_companion_cocoa_t *handle = (ui_companion_cocoa_t*)data; @@ -693,19 +682,12 @@ static void *ui_companion_cocoa_init(void) return handle; } +static void ui_companion_cocoa_notify_content_loaded(void *data) { } +static void ui_companion_cocoa_toggle(void *data, bool force) { } static void ui_companion_cocoa_event_command(void *data, enum event_command cmd) -{ - (void)data; - (void)cmd; -} - +{ } static void ui_companion_cocoa_notify_list_pushed(void *data, - file_list_t *list, file_list_t *menu_list) -{ - (void)data; - (void)list; - (void)menu_list; -} + file_list_t *list, file_list_t *menu_list) { } static void *ui_companion_cocoa_get_main_window(void *data) { diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 106c9f6eca..27d2e35885 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -45,6 +45,8 @@ static id apple_platform; #endif static CFRunLoopObserverRef iterate_observer; +static size_t old_size = 0; + /* forward declaration */ static void apple_rarch_exited(void); @@ -71,10 +73,7 @@ static void rarch_disable_ui(void) } static void ui_companion_cocoatouch_event_command( - void *data, enum event_command cmd) -{ - (void)data; -} + void *data, enum event_command cmd) { } static void rarch_draw_observer(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *info) @@ -530,18 +529,6 @@ int main(int argc, char *argv[]) } } -#if 0 -static void apple_display_alert(const char *message, const char *title) -{ - UIAlertView* alert = [[UIAlertView alloc] initWithTitle:BOXSTRING(title) - message:BOXSTRING(message) - delegate:nil - cancelButtonTitle:BOXSTRING("OK") - otherButtonTitles:nil]; - [alert show]; -} -#endif - static void apple_rarch_exited(void) { RetroArch_iOS *ap = (RetroArch_iOS *)apple_platform; @@ -599,8 +586,6 @@ static void *ui_companion_cocoatouch_init(void) return handle; } -static size_t old_size = 0; - static void ui_companion_cocoatouch_notify_list_pushed(void *data, file_list_t *list, file_list_t *menu_list) { diff --git a/ui/drivers/ui_win32.c b/ui/drivers/ui_win32.c index 2f17744b13..a29e05bd57 100644 --- a/ui/drivers/ui_win32.c +++ b/ui/drivers/ui_win32.c @@ -106,31 +106,12 @@ static void *ui_companion_win32_init(void) return handle; } -static void ui_companion_win32_notify_content_loaded(void *data) -{ - (void)data; -} - -static void ui_companion_win32_toggle(void *data, bool force) -{ - (void)data; - (void)force; -} - +static void ui_companion_win32_notify_content_loaded(void *data) { } +static void ui_companion_win32_toggle(void *data, bool force) { } static void ui_companion_win32_event_command( - void *data, enum event_command cmd) -{ - (void)data; - (void)cmd; -} - + void *data, enum event_command cmd) { } static void ui_companion_win32_notify_list_pushed(void *data, - file_list_t *list, file_list_t *menu_list) -{ - (void)data; - (void)list; - (void)menu_list; -} + file_list_t *list, file_list_t *menu_list) { } ui_companion_driver_t ui_companion_win32 = { ui_companion_win32_init, From e47b7526bcc57a947521ffedfa39524acd5fb9cd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2020 23:24:51 +0100 Subject: [PATCH 54/75] (gfx) Cleanups --- gfx/drivers/gl.c | 5 +++-- gfx/drivers/vulkan.c | 2 +- gfx/font_driver.c | 8 +++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 08b5b66e78..561bb4e081 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -785,8 +785,9 @@ static void gl2_create_fbo_texture(gl_t *gl, bool fp_fbo = false; bool smooth = false; settings_t *settings = config_get_ptr(); - GLuint base_filt = settings->bools.video_smooth ? GL_LINEAR : GL_NEAREST; - GLuint base_mip_filt = settings->bools.video_smooth ? + bool video_smooth = settings->bools.video_smooth; + GLuint base_filt = video_smooth ? GL_LINEAR : GL_NEAREST; + GLuint base_mip_filt = video_smooth ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST; unsigned mip_level = i + 2; bool mipmapped = gl->shader->mipmap_input(gl->shader_data, mip_level); diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index a28b6178da..04bf20dfd2 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -1118,7 +1118,7 @@ static void vulkan_init_readback(vk_t *vk) * not initialized yet. */ settings_t *settings = config_get_ptr(); - bool recording_enabled = recording_is_enabled(); + bool recording_enabled = recording_is_enabled(); vk->readback.streamed = settings->bools.video_gpu_record && recording_enabled; if (!vk->readback.streamed) diff --git a/gfx/font_driver.c b/gfx/font_driver.c index 54e598a0bb..d7f9dfb9f1 100644 --- a/gfx/font_driver.c +++ b/gfx/font_driver.c @@ -1159,13 +1159,15 @@ void font_driver_init_osd( bool is_threaded, enum font_driver_render_api api) { - settings_t *settings = config_get_ptr(); + settings_t *settings = config_get_ptr(); + const char *path_font = settings->paths.path_font; + float video_font_size = settings->floats.video_font_size; if (video_font_driver) return; video_font_driver = font_driver_init_first(video_data, - *settings->paths.path_font ? settings->paths.path_font : NULL, - settings->floats.video_font_size, threading_hint, is_threaded, api); + *path_font ? path_font : NULL, + video_font_size, threading_hint, is_threaded, api); if (!video_font_driver) RARCH_ERR("[font]: Failed to initialize OSD font.\n"); From 2d274f1369efcacb797ff05a340e4ea41b8a8a03 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 14 Feb 2020 00:17:55 +0100 Subject: [PATCH 55/75] Move accessibility features to platform frontend driver --- frontend/drivers/platform_ctr.c | 2 + frontend/drivers/platform_darwin.m | 145 ++++++++++ frontend/drivers/platform_dos.c | 2 + frontend/drivers/platform_emscripten.c | 2 + frontend/drivers/platform_gx.c | 2 + frontend/drivers/platform_orbis.c | 2 + frontend/drivers/platform_ps2.c | 2 + frontend/drivers/platform_ps3.c | 2 + frontend/drivers/platform_psp.c | 4 + frontend/drivers/platform_qnx.c | 2 + frontend/drivers/platform_switch.c | 2 + frontend/drivers/platform_unix.c | 79 +++++ frontend/drivers/platform_uwp.c | 2 + frontend/drivers/platform_wiiu.c | 2 + frontend/drivers/platform_win32.c | 151 +++++++++- frontend/drivers/platform_xdk.c | 2 + frontend/drivers/platform_xenon.c | 2 + frontend/frontend_driver.c | 10 + frontend/frontend_driver.h | 3 + retroarch.c | 382 +------------------------ 20 files changed, 423 insertions(+), 377 deletions(-) diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index 8af3eb17d7..40b639e103 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -624,5 +624,7 @@ frontend_ctx_driver_t frontend_ctx_ctr = NULL, /* set_sustained_performance_mode */ NULL, /* get_cpu_model_name */ NULL, /* get_user_language */ + NULL, /* is_narrator_running */ + NULL, /* accessibility_speak */ "ctr", }; diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index 05529d2588..bda3c77c0d 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -808,6 +808,144 @@ static const char* frontend_darwin_get_cpu_model_name(void) return darwin_cpu_model_name; } +#if (defined(OSX) && !(defined(__ppc__) || defined(__ppc64__))) +static char* accessibility_mac_language_code(const char* language) +{ + if (string_is_equal(language,"en")) + return "Alex"; + else if (string_is_equal(language,"it")) + return "Alice"; + else if (string_is_equal(language,"sv")) + return "Alva"; + else if (string_is_equal(language,"fr")) + return "Amelie"; + else if (string_is_equal(language,"de")) + return "Anna"; + else if (string_is_equal(language,"he")) + return "Carmit"; + else if (string_is_equal(language,"id")) + return "Damayanti"; + else if (string_is_equal(language,"es")) + return "Diego"; + else if (string_is_equal(language,"nl")) + return "Ellen"; + else if (string_is_equal(language,"ro")) + return "Ioana"; + else if (string_is_equal(language,"pt_pt")) + return "Joana"; + else if (string_is_equal(language,"pt_bt") || string_is_equal(language,"pt")) + return "Luciana"; + else if (string_is_equal(language,"th")) + return "Kanya"; + else if (string_is_equal(language,"ja")) + return "Kyoko"; + else if (string_is_equal(language,"sk")) + return "Laura"; + else if (string_is_equal(language,"hi")) + return "Lekha"; + else if (string_is_equal(language,"ar")) + return "Maged"; + else if (string_is_equal(language,"hu")) + return "Mariska"; + else if (string_is_equal(language,"zh_tw") || string_is_equal(language,"zh")) + return "Mei-Jia"; + else if (string_is_equal(language,"el")) + return "Melina"; + else if (string_is_equal(language,"ru")) + return "Milena"; + else if (string_is_equal(language,"nb")) + return "Nora"; + else if (string_is_equal(language,"da")) + return "Sara"; + else if (string_is_equal(language,"fi")) + return "Satu"; + else if (string_is_equal(language,"zh_hk")) + return "Sin-ji"; + else if (string_is_equal(language,"zh_cn")) + return "Ting-Ting"; + else if (string_is_equal(language,"tr")) + return "Yelda"; + else if (string_is_equal(language,"ko")) + return "Yuna"; + else if (string_is_equal(language,"pl")) + return "Zosia"; + else if (string_is_equal(language,"cs")) + return "Zuzana"; + else + return ""; +} + +static bool is_narrator_running_macos(void) +{ + return (kill(speak_pid, 0) == 0); +} + +static bool accessibility_speak_macos(int speed, + const char* speak_text, int priority) +{ + int pid; + const char *voice = get_user_language_iso639_1(false); + char* language_speaker = accessibility_mac_language_code(voice); + char* speeds[10] = {"80", "100", "125", "150", "170", "210", "260", "310", "380", "450"}; + + if (speed < 1) + speed = 1; + else if (speed > 10) + speed = 10; + + if (priority < 10 && speak_pid > 0) + { + /* check if old pid is running */ + if (is_narrator_running_macos()) + return true; + } + + if (speak_pid > 0) + { + /* Kill the running say */ + kill(speak_pid, SIGTERM); + speak_pid = 0; + } + + pid = fork(); + if (pid < 0) + { + /* error */ + RARCH_LOG("ERROR: could not fork for say command.\n"); + } + else if (pid > 0) + { + /* parent process */ + speak_pid = pid; + + /* Tell the system that we'll ignore the exit status of the child + * process. This prevents zombie processes. */ + signal(SIGCHLD,SIG_IGN); + } + else + { + /* child process: replace process with the say command */ + if (strlen(language_speaker)> 0) + { + char* cmd[] = {"say", "-v", NULL, + NULL, "-r", NULL, NULL}; + cmd[2] = language_speaker; + cmd[3] = (char *) speak_text; + cmd[5] = speeds[speed-1]; + execvp("say", cmd); + } + else + { + char* cmd[] = {"say", NULL, "-r", NULL, NULL}; + cmd[1] = (char*) speak_text; + cmd[3] = speeds[speed-1]; + execvp("say",cmd); + } + } + return true; +} +#endif + frontend_ctx_driver_t frontend_ctx_darwin = { frontend_darwin_get_environment_settings, NULL, /* init */ @@ -841,5 +979,12 @@ frontend_ctx_driver_t frontend_ctx_darwin = { NULL, #endif NULL, /* get_user_language */ +#if (defined(OSX) && !(defined(__ppc__) || defined(__ppc64__))) + is_narrator_running_macos, /* is_narrator_running */ + accessibility_speak_macos, /* accessibility_speak */ +#else + NULL, /* is_narrator_running */ + NULL, /* accessibility_speak */ +#endif "darwin", }; diff --git a/frontend/drivers/platform_dos.c b/frontend/drivers/platform_dos.c index dfce99e2d1..1d49f313cd 100644 --- a/frontend/drivers/platform_dos.c +++ b/frontend/drivers/platform_dos.c @@ -73,5 +73,7 @@ frontend_ctx_driver_t frontend_ctx_dos = { NULL, /* set_sustained_performance_mode */ NULL, /* get_cpu_model_name */ NULL, /* get_user_language */ + NULL, /* is_narrator_running */ + NULL, /* accessibility_speak */ "dos", }; diff --git a/frontend/drivers/platform_emscripten.c b/frontend/drivers/platform_emscripten.c index 02a6252cd4..d6362c90c1 100644 --- a/frontend/drivers/platform_emscripten.c +++ b/frontend/drivers/platform_emscripten.c @@ -240,5 +240,7 @@ frontend_ctx_driver_t frontend_ctx_emscripten = { NULL, /* set_sustained_performance_mode */ NULL, /* get_cpu_model_name */ NULL, /* get_user_language */ + NULL, /* is_narrator_running */ + NULL, /* accessibility_speak */ "emscripten" }; diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index f47f67e757..29a439b49e 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -567,5 +567,7 @@ frontend_ctx_driver_t frontend_ctx_gx = { NULL, /* set_sustained_performance_mode */ NULL, /* get_cpu_model_name */ NULL, /* get_user_language */ + NULL, /* is_narrator_running */ + NULL, /* accessibility_speak */ "gx", }; diff --git a/frontend/drivers/platform_orbis.c b/frontend/drivers/platform_orbis.c index bfd93b3b0a..249dfa819c 100644 --- a/frontend/drivers/platform_orbis.c +++ b/frontend/drivers/platform_orbis.c @@ -374,5 +374,7 @@ frontend_ctx_driver_t frontend_ctx_orbis = { NULL, /* set_sustained_performance_mode */ NULL, /* get_cpu_model_name */ NULL, /* get_user_language */ + NULL, /* is_narrator_running */ + NULL, /* accessibility_speak */ "orbis", }; diff --git a/frontend/drivers/platform_ps2.c b/frontend/drivers/platform_ps2.c index 3ff899d9eb..e45f0b1953 100644 --- a/frontend/drivers/platform_ps2.c +++ b/frontend/drivers/platform_ps2.c @@ -416,5 +416,7 @@ frontend_ctx_driver_t frontend_ctx_ps2 = { NULL, /* set_sustained_performance_mode */ NULL, /* get_cpu_model_name */ NULL, /* get_user_language */ + NULL, /* is_narrator_running */ + NULL, /* accessibility_speak */ "null", }; diff --git a/frontend/drivers/platform_ps3.c b/frontend/drivers/platform_ps3.c index b718c1a40c..f4d63fea6d 100644 --- a/frontend/drivers/platform_ps3.c +++ b/frontend/drivers/platform_ps3.c @@ -645,5 +645,7 @@ frontend_ctx_driver_t frontend_ctx_ps3 = { NULL, /* set_sustained_performance_mode */ NULL, /* get_cpu_model_name */ NULL, /* get_user_language */ + NULL, /* is_narrator_running */ + NULL, /* accessibility_speak */ "ps3", }; diff --git a/frontend/drivers/platform_psp.c b/frontend/drivers/platform_psp.c index 7e7433edaf..6655a261be 100644 --- a/frontend/drivers/platform_psp.c +++ b/frontend/drivers/platform_psp.c @@ -596,9 +596,13 @@ frontend_ctx_driver_t frontend_ctx_psp = { NULL, /* get_cpu_model_name */ #ifdef VITA frontend_psp_get_user_language, + NULL, /* is_narrator_running */ + NULL, /* accessibility_speak */ "vita", #else NULL, /* get_user_language */ + NULL, /* is_narrator_running */ + NULL, /* accessibility_speak */ "psp", #endif }; diff --git a/frontend/drivers/platform_qnx.c b/frontend/drivers/platform_qnx.c index 64da613366..0f249619b0 100644 --- a/frontend/drivers/platform_qnx.c +++ b/frontend/drivers/platform_qnx.c @@ -213,5 +213,7 @@ frontend_ctx_driver_t frontend_ctx_qnx = { NULL, /* set_sustained_performance_mode */ NULL, /* get_cpu_model_name */ NULL, /* get_user_language */ + NULL, /* is_narrator_running */ + NULL, /* accessibility_speak */ "qnx", }; diff --git a/frontend/drivers/platform_switch.c b/frontend/drivers/platform_switch.c index d2affe70d0..d1166a0a50 100644 --- a/frontend/drivers/platform_switch.c +++ b/frontend/drivers/platform_switch.c @@ -923,5 +923,7 @@ frontend_ctx_driver_t frontend_ctx_switch = NULL, /* set_sustained_performance_mode */ NULL, /* get_cpu_model_name */ NULL, /* get_user_language */ + NULL, /* is_narrator_running */ + NULL, /* accessibility_speak */ "switch", }; diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c index 5bc3061c6b..123c8d8ca8 100644 --- a/frontend/drivers/platform_unix.c +++ b/frontend/drivers/platform_unix.c @@ -119,6 +119,10 @@ static const char *proc_acpi_ac_adapter_path = "/proc/acpi/ac_adapter"; static char unix_cpu_model_name[64] = {0}; #endif +#if (defined(__linux__) || defined(__unix__)) && !defined(ANDROID) +static int speak_pid = 0; +#endif + static volatile sig_atomic_t unix_sighandler_quit; #ifndef ANDROID @@ -2431,6 +2435,74 @@ enum retro_language frontend_unix_get_user_language(void) return lang; } +#if (defined(__linux__) || defined(__unix__)) && !defined(ANDROID) +static bool is_narrator_running_unix(void) +{ + return (kill(speak_pid, 0) == 0); +} + +static bool accessibility_speak_unix(int speed, + const char* speak_text, int priority) +{ + int pid; + const char *language = get_user_language_iso639_1(true); + char* voice_out = (char *)malloc(3+strlen(language)); + char* speed_out = (char *)malloc(3+3); + const char* speeds[10] = {"80", "100", "125", "150", "170", "210", "260", "310", "380", "450"}; + + if (speed < 1) + speed = 1; + else if (speed > 10) + speed = 10; + + strlcpy(voice_out, "-v", 3); + strlcat(voice_out, language, 5); + + strlcpy(speed_out, "-s", 3); + strlcat(speed_out, speeds[speed-1], 6); + + if (priority < 10 && speak_pid > 0) + { + /* check if old pid is running */ + if (is_narrator_running_unix()) + return true; + } + + if (speak_pid > 0) + { + /* Kill the running espeak */ + kill(speak_pid, SIGTERM); + speak_pid = 0; + } + + pid = fork(); + if (pid < 0) + { + /* error */ + RARCH_LOG("ERROR: could not fork for espeak.\n"); + } + else if (pid > 0) + { + /* parent process */ + speak_pid = pid; + + /* Tell the system that we'll ignore the exit status of the child + * process. This prevents zombie processes. */ + signal(SIGCHLD,SIG_IGN); + } + else + { + /* child process: replace process with the espeak command */ + char* cmd[] = { (char*) "espeak", NULL, NULL, NULL, NULL}; + cmd[1] = voice_out; + cmd[2] = speed_out; + cmd[3] = (char *) speak_text; + execvp("espeak", cmd); + } + return true; +} +#endif + frontend_ctx_driver_t frontend_ctx_unix = { frontend_unix_get_env, /* environment_get */ frontend_unix_init, /* init */ @@ -2477,6 +2549,13 @@ frontend_ctx_driver_t frontend_ctx_unix = { frontend_unix_set_sustained_performance_mode, frontend_unix_get_cpu_model_name, frontend_unix_get_user_language, +#if (defined(__linux__) || defined(__unix__)) && !defined(ANDROID) + is_narrator_running_unix, + accessibility_speak_unix, +#else + NULL, /* is_narrator_running */ + NULL, /* accessibility_speak */ +#endif #ifdef ANDROID "android" #else diff --git a/frontend/drivers/platform_uwp.c b/frontend/drivers/platform_uwp.c index 8e3a15f9f7..33611cced3 100644 --- a/frontend/drivers/platform_uwp.c +++ b/frontend/drivers/platform_uwp.c @@ -477,5 +477,7 @@ frontend_ctx_driver_t frontend_ctx_uwp = { NULL, /* set_sustained_performance_mode */ frontend_uwp_get_cpu_model_name, frontend_uwp_get_user_language, + NULL, /* is_narrator_running */ + NULL, /* accessibility_speak */ "uwp" }; diff --git a/frontend/drivers/platform_wiiu.c b/frontend/drivers/platform_wiiu.c index 281489fd4f..57c5a8d430 100644 --- a/frontend/drivers/platform_wiiu.c +++ b/frontend/drivers/platform_wiiu.c @@ -326,6 +326,8 @@ frontend_ctx_driver_t frontend_ctx_wiiu = NULL, /* set_sustained_performance_mode */ NULL, /* get_cpu_model_name */ NULL, /* get_user_language */ + NULL, /* is_narrator_running */ + NULL, /* accessibility_speak */ "wiiu", NULL, /* get_video_driver */ }; diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 53135b65aa..d8c35e8ee8 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -71,6 +71,8 @@ VOID (WINAPI *DragAcceptFiles_func)(HWND, BOOL); static bool dwm_composition_disabled = false; static bool console_needs_free = false; +static bool pi_set = false; + #if defined(HAVE_LANGEXTRA) && !defined(_XBOX) #if (defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500) || !defined(_MSC_VER) struct win32_lang_pair @@ -193,10 +195,7 @@ static bool gfx_init_dwm(void) #endif if (mmcss) - { - RARCH_LOG("Setting multimedia scheduling for DWM.\n"); mmcss(TRUE); - } inited = true; return true; @@ -721,6 +720,145 @@ static bool frontend_win32_set_fork(enum frontend_fork fork_mode) } #endif +#if defined(_WIN32) && !defined(_XBOX) +static const char *accessibility_win_language_code(const char* language) +{ + if (string_is_equal(language,"en")) + return "Microsoft David Desktop"; + else if (string_is_equal(language,"it")) + return "Microsoft Cosimo Desktop"; + else if (string_is_equal(language,"sv")) + return "Microsoft Bengt Desktop"; + else if (string_is_equal(language,"fr")) + return "Microsoft Paul Desktop"; + else if (string_is_equal(language,"de")) + return "Microsoft Stefan Desktop"; + else if (string_is_equal(language,"he")) + return "Microsoft Hemant Desktop"; + else if (string_is_equal(language,"id")) + return "Microsoft Asaf Desktop"; + else if (string_is_equal(language,"es")) + return "Microsoft Pablo Desktop"; + else if (string_is_equal(language,"nl")) + return "Microsoft Frank Desktop"; + else if (string_is_equal(language,"ro")) + return "Microsoft Andrei Desktop"; + else if (string_is_equal(language,"pt_pt")) + return "Microsoft Helia Desktop"; + else if (string_is_equal(language,"pt_bt") || string_is_equal(language,"pt")) + return "Microsoft Daniel Desktop"; + else if (string_is_equal(language,"th")) + return "Microsoft Pattara Desktop"; + else if (string_is_equal(language,"ja")) + return "Microsoft Ichiro Desktop"; + else if (string_is_equal(language,"sk")) + return "Microsoft Filip Desktop"; + else if (string_is_equal(language,"hi")) + return "Microsoft Hemant Desktop"; + else if (string_is_equal(language,"ar")) + return "Microsoft Naayf Desktop"; + else if (string_is_equal(language,"hu")) + return "Microsoft Szabolcs Desktop"; + else if (string_is_equal(language,"zh_tw") || string_is_equal(language,"zh")) + return "Microsoft Zhiwei Desktop"; + else if (string_is_equal(language,"el")) + return "Microsoft Stefanos Desktop"; + else if (string_is_equal(language,"ru")) + return "Microsoft Pavel Desktop"; + else if (string_is_equal(language,"nb")) + return "Microsoft Jon Desktop"; + else if (string_is_equal(language,"da")) + return "Microsoft Helle Desktop"; + else if (string_is_equal(language,"fi")) + return "Microsoft Heidi Desktop"; + else if (string_is_equal(language,"zh_hk")) + return "Microsoft Danny Desktop"; + else if (string_is_equal(language,"zh_cn")) + return "Microsoft Kangkang Desktop"; + else if (string_is_equal(language,"tr")) + return "Microsoft Tolga Desktop"; + else if (string_is_equal(language,"ko")) + return "Microsoft Heami Desktop"; + else if (string_is_equal(language,"pl")) + return "Microsoft Adam Desktop"; + else if (string_is_equal(language,"cs")) + return "Microsoft Jakub Desktop"; + else + return ""; +} + +static bool terminate_win32_process(PROCESS_INFORMATION pi) +{ + TerminateProcess(pi.hProcess,0); + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + return true; +} + +static PROCESS_INFORMATION g_pi; + +static bool create_win32_process(char* cmd) +{ + STARTUPINFO si; + memset(&si, 0, sizeof(si)); + si.cb = sizeof(si); + memset(&g_pi, 0, sizeof(g_pi)); + + if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, CREATE_NO_WINDOW, + NULL, NULL, &si, &g_pi)) + return false; + return true; +} + +static bool is_narrator_running_windows(void) +{ + DWORD status = 0; + if (pi_set == false) + return false; + if (GetExitCodeProcess(&g_pi, &status) && status == STILL_ACTIVE) + return true; + return false; +} + +static bool accessibility_speak_windows(int speed, + const char* speak_text, int priority) +{ + char cmd[1200]; + const char *voice = get_user_language_iso639_1(true); + const char *language = accessibility_win_language_code(voice); + bool res = false; + const char* speeds[10] = {"-10", "-7.5", "-5", "-2.5", "0", "2", "4", "6", "8", "10"}; + + if (speed < 1) + speed = 1; + else if (speed > 10) + speed = 10; + + if (priority < 10) + { + if (is_narrator_running_windows()) + return true; + } + + if (strlen(language) > 0) + snprintf(cmd, sizeof(cmd), + "powershell.exe -NoProfile -WindowStyle Hidden -Command \"Add-Type -AssemblyName System.Speech; $synth = New-Object System.Speech.Synthesis.SpeechSynthesizer; $synth.SelectVoice(\\\"%s\\\"); $synth.Rate = %s; $synth.Speak(\\\"%s\\\");\"", language, speeds[speed-1], (char*) speak_text); + else + snprintf(cmd, sizeof(cmd), + "powershell.exe -NoProfile -WindowStyle Hidden -Command \"Add-Type -AssemblyName System.Speech; $synth = New-Object System.Speech.Synthesis.SpeechSynthesizer; $synth.Rate = %s; $synth.Speak(\\\"%s\\\");\"", speeds[speed-1], (char*) speak_text); + if (pi_set) + terminate_win32_process(g_pi); + res = create_win32_process(cmd); + if (!res) + { + pi_set = false; + return true; + } + pi_set = true; + return true; +} +#endif + frontend_ctx_driver_t frontend_ctx_win32 = { frontend_win32_environment_get, frontend_win32_init, @@ -758,5 +896,12 @@ frontend_ctx_driver_t frontend_ctx_win32 = { NULL, /* set_sustained_performance_mode */ frontend_win32_get_cpu_model_name, frontend_win32_get_user_language, +#if defined(_WIN32) && !defined(_XBOX) + is_narrator_running_windows, + accessibility_speak_windows, +#else + NULL, /* is_narrator_running */ + NULL, /* accessibility_speak */ +#endif "win32" }; diff --git a/frontend/drivers/platform_xdk.c b/frontend/drivers/platform_xdk.c index b016b346aa..fb93b440de 100644 --- a/frontend/drivers/platform_xdk.c +++ b/frontend/drivers/platform_xdk.c @@ -440,5 +440,7 @@ frontend_ctx_driver_t frontend_ctx_xdk = { NULL, /* set_sustained_performance_mode */ NULL, /* get_cpu_model_name */ NULL, /* get_user_language */ + NULL, /* is_narrator_running */ + NULL, /* accessibility_speak */ "xdk", }; diff --git a/frontend/drivers/platform_xenon.c b/frontend/drivers/platform_xenon.c index 654b76d92e..a5e3cca662 100644 --- a/frontend/drivers/platform_xenon.c +++ b/frontend/drivers/platform_xenon.c @@ -96,5 +96,7 @@ frontend_ctx_driver_t frontend_ctx_qnx = { NULL, /* set_sustained_performance_mode */ NULL, /* get_cpu_model_name */ NULL, /* get_user_language */ + NULL, /* is_narrator_running */ + NULL, /* accessibility_speak */ "xenon", }; diff --git a/frontend/frontend_driver.c b/frontend/frontend_driver.c index 88f98a8442..cd11e6a0b8 100644 --- a/frontend/frontend_driver.c +++ b/frontend/frontend_driver.c @@ -70,6 +70,8 @@ static frontend_ctx_driver_t frontend_ctx_null = { NULL, /* set_sustained_performance_mode */ NULL, /* get_cpu_model_name */ NULL, /* get_user_language */ + NULL, /* is_narrator_running */ + NULL, /* accessibility_speak */ "null", NULL, /* get_video_driver */ }; @@ -553,4 +555,12 @@ enum retro_language frontend_driver_get_user_language(void) return RETRO_LANGUAGE_ENGLISH; return frontend->get_user_language(); } + +bool frontend_driver_is_narrator_running(void) +{ + frontend_ctx_driver_t *frontend = frontend_get_ptr(); + if (!frontend || !frontend->is_narrator_running) + return false; + return frontend->is_narrator_running(); +} #endif diff --git a/frontend/frontend_driver.h b/frontend/frontend_driver.h index d6b9e809c4..3b98cd9269 100644 --- a/frontend/frontend_driver.h +++ b/frontend/frontend_driver.h @@ -110,6 +110,9 @@ typedef struct frontend_ctx_driver void (*set_sustained_performance_mode)(bool on); const char* (*get_cpu_model_name)(void); enum retro_language (*get_user_language)(void); + bool (*is_narrator_running)(void); + bool (*accessibility_speak)(int speed, + const char* speak_text, int priority); const char *ident; diff --git a/retroarch.c b/retroarch.c index 1865ef0bdc..0203b5d6e9 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2531,10 +2531,7 @@ void dir_check_defaults(void) /* Is text-to-speech accessibility turned on? */ static bool accessibility_enabled = false; -static bool pi_set = false; - /* Accessibility */ -static int speak_pid = 0; bool is_accessibility_enabled(void) { @@ -28588,375 +28585,18 @@ bool is_input_keyboard_display_on(void) #endif } -#if defined(__MACH__) && defined(__APPLE__) -#include -#if TARGET_OS_OSX && !defined(EMSCRIPTEN) -#define _IS_OSX -#endif -#endif - #ifdef HAVE_ACCESSIBILITY - -#if defined(_IS_OSX) -static char* accessibility_mac_language_code(const char* language) -{ - if (string_is_equal(language,"en")) - return "Alex"; - else if (string_is_equal(language,"it")) - return "Alice"; - else if (string_is_equal(language,"sv")) - return "Alva"; - else if (string_is_equal(language,"fr")) - return "Amelie"; - else if (string_is_equal(language,"de")) - return "Anna"; - else if (string_is_equal(language,"he")) - return "Carmit"; - else if (string_is_equal(language,"id")) - return "Damayanti"; - else if (string_is_equal(language,"es")) - return "Diego"; - else if (string_is_equal(language,"nl")) - return "Ellen"; - else if (string_is_equal(language,"ro")) - return "Ioana"; - else if (string_is_equal(language,"pt_pt")) - return "Joana"; - else if (string_is_equal(language,"pt_bt") || string_is_equal(language,"pt")) - return "Luciana"; - else if (string_is_equal(language,"th")) - return "Kanya"; - else if (string_is_equal(language,"ja")) - return "Kyoko"; - else if (string_is_equal(language,"sk")) - return "Laura"; - else if (string_is_equal(language,"hi")) - return "Lekha"; - else if (string_is_equal(language,"ar")) - return "Maged"; - else if (string_is_equal(language,"hu")) - return "Mariska"; - else if (string_is_equal(language,"zh_tw") || string_is_equal(language,"zh")) - return "Mei-Jia"; - else if (string_is_equal(language,"el")) - return "Melina"; - else if (string_is_equal(language,"ru")) - return "Milena"; - else if (string_is_equal(language,"nb")) - return "Nora"; - else if (string_is_equal(language,"da")) - return "Sara"; - else if (string_is_equal(language,"fi")) - return "Satu"; - else if (string_is_equal(language,"zh_hk")) - return "Sin-ji"; - else if (string_is_equal(language,"zh_cn")) - return "Ting-Ting"; - else if (string_is_equal(language,"tr")) - return "Yelda"; - else if (string_is_equal(language,"ko")) - return "Yuna"; - else if (string_is_equal(language,"pl")) - return "Zosia"; - else if (string_is_equal(language,"cs")) - return "Zuzana"; - else - return ""; -} - -static bool is_narrator_running_macos(void) -{ - return (kill(speak_pid, 0) == 0); -} - -static bool accessibility_speak_macos(int speed, - const char* speak_text, const char* voice, int priority) -{ - int pid; - char* language_speaker = accessibility_mac_language_code(voice); - char* speeds[10] = {"80", "100", "125", "150", "170", "210", "260", "310", "380", "450"}; - - if (speed < 1) - speed = 1; - else if (speed > 10) - speed = 10; - - if (priority < 10 && speak_pid > 0) - { - /* check if old pid is running */ - if (is_narrator_running_macos()) - return true; - } - - if (speak_pid > 0) - { - /* Kill the running say */ - kill(speak_pid, SIGTERM); - speak_pid = 0; - } - - pid = fork(); - if (pid < 0) - { - /* error */ - RARCH_LOG("ERROR: could not fork for say command.\n"); - } - else if (pid > 0) - { - /* parent process */ - speak_pid = pid; - - /* Tell the system that we'll ignore the exit status of the child - * process. This prevents zombie processes. */ - signal(SIGCHLD,SIG_IGN); - } - else - { - /* child process: replace process with the say command */ - if (strlen(language_speaker)> 0) - { - char* cmd[] = {"say", "-v", NULL, - NULL, "-r", NULL, NULL}; - cmd[2] = language_speaker; - cmd[3] = (char *) speak_text; - cmd[5] = speeds[speed-1]; - execvp("say", cmd); - } - else - { - char* cmd[] = {"say", NULL, "-r", NULL, NULL}; - cmd[1] = (char*) speak_text; - cmd[3] = speeds[speed-1]; - execvp("say",cmd); - } - } - return true; -} -#endif - -#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__) && !defined(EMSCRIPTEN) -static const char *accessibility_win_language_code(const char* language) -{ - if (string_is_equal(language,"en")) - return "Microsoft David Desktop"; - else if (string_is_equal(language,"it")) - return "Microsoft Cosimo Desktop"; - else if (string_is_equal(language,"sv")) - return "Microsoft Bengt Desktop"; - else if (string_is_equal(language,"fr")) - return "Microsoft Paul Desktop"; - else if (string_is_equal(language,"de")) - return "Microsoft Stefan Desktop"; - else if (string_is_equal(language,"he")) - return "Microsoft Hemant Desktop"; - else if (string_is_equal(language,"id")) - return "Microsoft Asaf Desktop"; - else if (string_is_equal(language,"es")) - return "Microsoft Pablo Desktop"; - else if (string_is_equal(language,"nl")) - return "Microsoft Frank Desktop"; - else if (string_is_equal(language,"ro")) - return "Microsoft Andrei Desktop"; - else if (string_is_equal(language,"pt_pt")) - return "Microsoft Helia Desktop"; - else if (string_is_equal(language,"pt_bt") || string_is_equal(language,"pt")) - return "Microsoft Daniel Desktop"; - else if (string_is_equal(language,"th")) - return "Microsoft Pattara Desktop"; - else if (string_is_equal(language,"ja")) - return "Microsoft Ichiro Desktop"; - else if (string_is_equal(language,"sk")) - return "Microsoft Filip Desktop"; - else if (string_is_equal(language,"hi")) - return "Microsoft Hemant Desktop"; - else if (string_is_equal(language,"ar")) - return "Microsoft Naayf Desktop"; - else if (string_is_equal(language,"hu")) - return "Microsoft Szabolcs Desktop"; - else if (string_is_equal(language,"zh_tw") || string_is_equal(language,"zh")) - return "Microsoft Zhiwei Desktop"; - else if (string_is_equal(language,"el")) - return "Microsoft Stefanos Desktop"; - else if (string_is_equal(language,"ru")) - return "Microsoft Pavel Desktop"; - else if (string_is_equal(language,"nb")) - return "Microsoft Jon Desktop"; - else if (string_is_equal(language,"da")) - return "Microsoft Helle Desktop"; - else if (string_is_equal(language,"fi")) - return "Microsoft Heidi Desktop"; - else if (string_is_equal(language,"zh_hk")) - return "Microsoft Danny Desktop"; - else if (string_is_equal(language,"zh_cn")) - return "Microsoft Kangkang Desktop"; - else if (string_is_equal(language,"tr")) - return "Microsoft Tolga Desktop"; - else if (string_is_equal(language,"ko")) - return "Microsoft Heami Desktop"; - else if (string_is_equal(language,"pl")) - return "Microsoft Adam Desktop"; - else if (string_is_equal(language,"cs")) - return "Microsoft Jakub Desktop"; - else - return ""; -} - -static bool terminate_win32_process(PROCESS_INFORMATION pi) -{ - TerminateProcess(pi.hProcess,0); - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - return true; -} - -static PROCESS_INFORMATION g_pi; - -static bool create_win32_process(char* cmd) -{ - STARTUPINFO si; - memset(&si, 0, sizeof(si)); - si.cb = sizeof(si); - memset(&g_pi, 0, sizeof(g_pi)); - - if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, CREATE_NO_WINDOW, - NULL, NULL, &si, &g_pi)) - return false; - return true; -} - -static bool is_narrator_running_windows(void) -{ - DWORD status = 0; - if (pi_set == false) - return false; - if (GetExitCodeProcess(&g_pi, &status) && status == STILL_ACTIVE) - return true; - return false; -} - -static bool accessibility_speak_windows(int speed, - const char* speak_text, const char* voice, int priority) -{ - char cmd[1200]; - const char *language = accessibility_win_language_code(voice); - bool res = false; - const char* speeds[10] = {"-10", "-7.5", "-5", "-2.5", "0", "2", "4", "6", "8", "10"}; - - if (speed < 1) - speed = 1; - else if (speed > 10) - speed = 10; - - if (priority < 10) - { - if (is_narrator_running_windows()) - return true; - } - - if (strlen(language) > 0) - snprintf(cmd, sizeof(cmd), - "powershell.exe -NoProfile -WindowStyle Hidden -Command \"Add-Type -AssemblyName System.Speech; $synth = New-Object System.Speech.Synthesis.SpeechSynthesizer; $synth.SelectVoice(\\\"%s\\\"); $synth.Rate = %s; $synth.Speak(\\\"%s\\\");\"", language, speeds[speed-1], (char*) speak_text); - else - snprintf(cmd, sizeof(cmd), - "powershell.exe -NoProfile -WindowStyle Hidden -Command \"Add-Type -AssemblyName System.Speech; $synth = New-Object System.Speech.Synthesis.SpeechSynthesizer; $synth.Rate = %s; $synth.Speak(\\\"%s\\\");\"", speeds[speed-1], (char*) speak_text); - if (pi_set) - terminate_win32_process(g_pi); - res = create_win32_process(cmd); - if (!res) - { - RARCH_LOG("Create subprocess failed. Error: %d\n", GetLastError()); - pi_set = false; - return true; - } - pi_set = true; - return true; -} -#endif - -#if (defined(__linux__) || defined(__unix__)) && !defined(EMSCRIPTEN) -static bool is_narrator_running_linux(void) -{ - return (kill(speak_pid, 0) == 0); -} - -static bool accessibility_speak_linux(int speed, - const char* speak_text, const char* language, int priority) -{ - int pid; - char* voice_out = (char *)malloc(3+strlen(language)); - char* speed_out = (char *)malloc(3+3); - const char* speeds[10] = {"80", "100", "125", "150", "170", "210", "260", "310", "380", "450"}; - - if (speed < 1) - speed = 1; - else if (speed > 10) - speed = 10; - - strlcpy(voice_out, "-v", 3); - strlcat(voice_out, language, 5); - - strlcpy(speed_out, "-s", 3); - strlcat(speed_out, speeds[speed-1], 6); - - if (priority < 10 && speak_pid > 0) - { - /* check if old pid is running */ - if (is_narrator_running_linux()) - return true; - } - - if (speak_pid > 0) - { - /* Kill the running espeak */ - kill(speak_pid, SIGTERM); - speak_pid = 0; - } - - pid = fork(); - if (pid < 0) - { - /* error */ - RARCH_LOG("ERROR: could not fork for espeak.\n"); - } - else if (pid > 0) - { - /* parent process */ - speak_pid = pid; - - /* Tell the system that we'll ignore the exit status of the child - * process. This prevents zombie processes. */ - signal(SIGCHLD,SIG_IGN); - } - else - { - /* child process: replace process with the espeak command */ - char* cmd[] = { (char*) "espeak", NULL, NULL, NULL, NULL}; - cmd[1] = voice_out; - cmd[2] = speed_out; - cmd[3] = (char *) speak_text; - execvp("espeak", cmd); - } - return true; -} -#endif - bool accessibility_speak_priority(const char* speak_text, int priority) { RARCH_LOG("Spoke: %s\n", speak_text); if (is_accessibility_enabled()) { - int speed = configuration_settings->uints.accessibility_narrator_speech_speed; -#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__) && !defined(EMSCRIPTEN) - const char *voice = get_user_language_iso639_1(true); - return accessibility_speak_windows(speed, speak_text, voice, priority); -#elif defined(__APPLE__) && defined(_IS_OSX) && !defined(EMSCRIPTEN) - const char *voice = get_user_language_iso639_1(false); - return accessibility_speak_macos(speed, speak_text, voice, priority); -#elif (defined(__linux__) || defined(__unix__)) && !defined(EMSCRIPTEN) - const char *voice = get_user_language_iso639_1(true); - return accessibility_speak_linux(speed, speak_text, voice, priority); -#endif + int speed = configuration_settings->uints.accessibility_narrator_speech_speed; + frontend_ctx_driver_t *frontend = frontend_get_ptr(); + if (frontend && frontend->accessibility_speak) + return frontend->accessibility_speak(speed, speak_text, + priority); RARCH_LOG("Platform not supported for accessibility.\n"); /* The following method is a fallback for other platforms to use the AI Service url to do the TTS. However, since the playback is done @@ -28974,22 +28614,16 @@ bool accessibility_speak_priority(const char* speak_text, int priority) return true; } -#ifdef HAVE_ACCESSIBILITY static bool is_narrator_running(void) { if (is_accessibility_enabled()) { -#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__) && !defined(EMSCRIPTEN) - return is_narrator_running_windows(); -#elif defined(__APPLE__) && defined(_IS_OSX) && !defined(EMSCRIPTEN) - return is_narrator_running_macos(); -#elif (defined(__linux__) || defined(__unix__)) && !defined(EMSCRIPTEN) - return is_narrator_running_linux(); -#endif + frontend_ctx_driver_t *frontend = frontend_get_ptr(); + if (frontend && frontend->is_narrator_running) + return frontend->is_narrator_running(); } return true; } -#endif static bool accessibility_startup_message(void) { From df62b6d78fca34fca318b34452cca51ed1fc29d0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 14 Feb 2020 00:19:54 +0100 Subject: [PATCH 56/75] Buildfix --- frontend/drivers/platform_darwin.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index bda3c77c0d..e3601b4d49 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -111,6 +111,10 @@ typedef enum CFAllDomainsMask = 0x0ffff /* All domains: all of the above and future items */ } CFDomainMask; +#if (defined(OSX) && !(defined(__ppc__) || defined(__ppc64__))) +static int speak_pid = 0; +#endif + static char darwin_cpu_model_name[64] = {0}; static NSSearchPathDirectory NSConvertFlagsCF(unsigned flags) From 172f75e5c00c6ea8be041771647875f62f738dba Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 14 Feb 2020 00:24:03 +0100 Subject: [PATCH 57/75] (OSX) Buildfix --- frontend/drivers/platform_darwin.m | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index e3601b4d49..f93c2e12fc 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -54,6 +54,7 @@ #include #include #include +#include #ifdef HAVE_MENU #include "../../menu/menu_driver.h" From de604a79abe869ef99db3a8e543222e3ec241f10 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 14 Feb 2020 12:12:59 +0100 Subject: [PATCH 58/75] dir_list_new_special - no more dependency on settings_t --- list_special.h | 3 ++- manual_content_scan.c | 4 ++-- manual_content_scan.h | 2 +- menu/cbs/menu_cbs_left.c | 2 +- menu/cbs/menu_cbs_right.c | 7 +++++-- menu/menu_displaylist.c | 10 ++++++---- retroarch.c | 12 +++++++----- tasks/task_autodetect.c | 6 ++++-- tasks/tasks_internal.h | 1 + 9 files changed, 29 insertions(+), 18 deletions(-) diff --git a/list_special.h b/list_special.h index 2e8eea3ce4..a0e4b106a6 100644 --- a/list_special.h +++ b/list_special.h @@ -59,7 +59,8 @@ enum string_list_type }; struct string_list *dir_list_new_special(const char *input_dir, - enum dir_list_type type, const char *filter); + enum dir_list_type type, const char *filter, + bool show_hidden_files); struct string_list *string_list_new_special(enum string_list_type type, void *data, unsigned *len, size_t *list_size); diff --git a/manual_content_scan.c b/manual_content_scan.c index 901c340a0b..3425bad5d4 100644 --- a/manual_content_scan.c +++ b/manual_content_scan.c @@ -548,7 +548,7 @@ bool manual_content_scan_get_menu_core_name(const char **core_name) * > Returns NULL in the event of failure * > Returned string list must be free()'d */ struct string_list *manual_content_scan_get_menu_system_name_list( - const char *path_content_database) + const char *path_content_database, bool show_hidden_files) { union string_list_elem_attr attr; struct string_list *name_list = string_list_new(); @@ -579,7 +579,7 @@ struct string_list *manual_content_scan_get_menu_system_name_list( * or verify file extensions) */ struct string_list *rdb_list = dir_list_new_special( path_content_database, - DIR_LIST_DATABASES, NULL); + DIR_LIST_DATABASES, NULL, show_hidden_files); if (rdb_list && rdb_list->size) { diff --git a/manual_content_scan.h b/manual_content_scan.h index e56c406337..2c8168e8b1 100644 --- a/manual_content_scan.h +++ b/manual_content_scan.h @@ -195,7 +195,7 @@ bool manual_content_scan_get_menu_core_name(const char **core_name); * > Returns NULL in the event of failure * > Returned string list must be free()'d */ struct string_list *manual_content_scan_get_menu_system_name_list( - const char *path_content_database); + const char *path_content_database, bool show_hidden_files); /* Creates a list of all possible 'core name' menu * strings, for use in 'menu_displaylist' drop-down diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 1bf9c16aa7..433c7f8d5a 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -527,7 +527,7 @@ static int manual_content_scan_system_name_left(unsigned type, const char *label #ifdef HAVE_LIBRETRODB settings_t *settings = config_get_ptr(); struct string_list *system_name_list = - manual_content_scan_get_menu_system_name_list(settings->paths.path_content_database); + manual_content_scan_get_menu_system_name_list(settings->paths.path_content_database, settings->bools.show_hidden_files); #else struct string_list *system_name_list = manual_content_scan_get_menu_system_name_list(NULL); diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 85d4a5c3fa..9b28efa7e9 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -614,10 +614,13 @@ static int manual_content_scan_system_name_right(unsigned type, const char *labe #ifdef HAVE_LIBRETRODB settings_t *settings = config_get_ptr(); struct string_list *system_name_list = - manual_content_scan_get_menu_system_name_list(settings->paths.path_content_database); + manual_content_scan_get_menu_system_name_list( + settings->paths.path_content_database, + settings->bools.show_hidden_files); #else struct string_list *system_name_list = - manual_content_scan_get_menu_system_name_list(NULL); + manual_content_scan_get_menu_system_name_list(NULL, + settings->bools.show_hidden_files); #endif const char *current_system_name = NULL; enum manual_content_scan_system_name_type next_system_name_type = diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 64b2d294e2..65b705c673 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2739,7 +2739,8 @@ static unsigned menu_displaylist_parse_playlist_manager_list( /* Add collection playlists */ str_list = dir_list_new_special( settings->paths.directory_playlist, - DIR_LIST_COLLECTIONS, NULL); + DIR_LIST_COLLECTIONS, NULL, + settings->bools.show_hidden_files); if (str_list && str_list->size) { @@ -2942,7 +2943,8 @@ static unsigned menu_displaylist_parse_pl_thumbnail_download_list( str_list = dir_list_new_special( settings->paths.directory_playlist, - DIR_LIST_COLLECTIONS, NULL); + DIR_LIST_COLLECTIONS, NULL, + settings->bools.show_hidden_files); if (str_list && str_list->size) { @@ -5292,10 +5294,10 @@ unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ct #ifdef HAVE_LIBRETRODB settings_t *settings = config_get_ptr(); struct string_list *system_name_list = - manual_content_scan_get_menu_system_name_list(settings->paths.path_content_database); + manual_content_scan_get_menu_system_name_list(settings->paths.path_content_database, settings->bools.show_hidden_files); #else struct string_list *system_name_list = - manual_content_scan_get_menu_system_name_list(NULL); + manual_content_scan_get_menu_system_name_list(NULL, settings->bools.show_hidden_files); #endif if (system_name_list) diff --git a/retroarch.c b/retroarch.c index 0203b5d6e9..ce04f92251 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1229,7 +1229,8 @@ static void rarch_init_core_options( static void bsv_movie_set_path(const char *path); struct string_list *dir_list_new_special(const char *input_dir, - enum dir_list_type type, const char *filter) + enum dir_list_type type, const char *filter, + bool show_hidden_files) { #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) char ext_shaders[255]; @@ -1237,7 +1238,6 @@ struct string_list *dir_list_new_special(const char *input_dir, char ext_name[255]; const char *exts = NULL; bool recursive = false; - settings_t *settings = configuration_settings; switch (type) { @@ -1318,7 +1318,7 @@ struct string_list *dir_list_new_special(const char *input_dir, } return dir_list_new(input_dir, exts, false, - settings->bools.show_hidden_files, + show_hidden_files, type == DIR_LIST_CORE_INFO, recursive); } @@ -2273,8 +2273,9 @@ static bool dir_init_shader(const char *path_dir_shader) { unsigned i; struct rarch_dir_list *dir_list = (struct rarch_dir_list*)&dir_shader_list; + settings_t *settings = configuration_settings; - dir_list->list = dir_list_new_special(path_dir_shader, DIR_LIST_SHADERS, NULL); + dir_list->list = dir_list_new_special(path_dir_shader, DIR_LIST_SHADERS, NULL, settings->bools.show_hidden_files); if (!dir_list->list || dir_list->list->size == 0) { @@ -5673,7 +5674,8 @@ static void command_event_set_savestate_auto_index(void) fill_pathname_basedir(state_dir, global->name.savestate, state_size); - dir_list = dir_list_new_special(state_dir, DIR_LIST_PLAIN, NULL); + dir_list = dir_list_new_special(state_dir, DIR_LIST_PLAIN, NULL, + settings->bools.show_hidden_files); free(state_dir); diff --git a/tasks/task_autodetect.c b/tasks/task_autodetect.c index a242e5d7b0..f89b55d429 100644 --- a/tasks/task_autodetect.c +++ b/tasks/task_autodetect.c @@ -266,7 +266,8 @@ static bool input_autoconfigure_joypad_from_conf_dir( fill_pathname_application_special(path, sizeof(path), APPLICATION_SPECIAL_DIRECTORY_AUTOCONFIG); - list = dir_list_new_special(path, DIR_LIST_AUTOCONFIG, "cfg"); + list = dir_list_new_special(path, DIR_LIST_AUTOCONFIG, "cfg", + params->show_hidden_files); if (!list || !list->size) { @@ -277,7 +278,7 @@ static bool input_autoconfigure_joypad_from_conf_dir( } if (!string_is_empty(params->autoconfig_directory)) list = dir_list_new_special(params->autoconfig_directory, - DIR_LIST_AUTOCONFIG, "cfg"); + DIR_LIST_AUTOCONFIG, "cfg", params->show_hidden_files); } if (!list) @@ -518,6 +519,7 @@ void input_autoconfigure_connect( if (!string_is_empty(dir_autoconf)) state->autoconfig_directory = strdup(dir_autoconf); + state->show_hidden_files = settings->bools.show_hidden_files; state->idx = idx; state->vid = vid; state->pid = pid; diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index 83935d38a3..6e3d667922 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -56,6 +56,7 @@ struct autoconfig_params uint32_t max_users; char *name; char *autoconfig_directory; + bool show_hidden_files; }; From cb0c145e3dfb9f41230640a6ec009891eaa7474b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 14 Feb 2020 12:55:36 +0100 Subject: [PATCH 59/75] Cleanups --- gfx/common/drm_common.c | 2 +- gfx/common/vulkan_common.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gfx/common/drm_common.c b/gfx/common/drm_common.c index 3cc41eedd1..ee1c474bd5 100644 --- a/gfx/common/drm_common.c +++ b/gfx/common/drm_common.c @@ -27,7 +27,7 @@ uint32_t g_connector_id = 0; int g_drm_fd = 0; uint32_t g_crtc_id = 0; -drmModeCrtc *g_orig_crtc = NULL; +drmModeCrtc *g_orig_crtc = NULL; static drmModeRes *g_drm_resources = NULL; drmModeConnector *g_drm_connector = NULL; diff --git a/gfx/common/vulkan_common.c b/gfx/common/vulkan_common.c index f8b410b6cd..169ef25bd1 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.c @@ -1584,6 +1584,7 @@ static bool vulkan_context_init_gpu(gfx_ctx_vulkan_data_t *vk) VkPhysicalDevice *gpus = NULL; union string_list_elem_attr attr = {0}; settings_t *settings = config_get_ptr(); + int gpu_index = settings->ints.vulkan_gpu_index; if (vkEnumeratePhysicalDevices(vk->context.instance, &gpu_count, NULL) != VK_SUCCESS) @@ -1633,14 +1634,14 @@ static bool vulkan_context_init_gpu(gfx_ctx_vulkan_data_t *vk) video_driver_set_gpu_api_devices(GFX_CTX_VULKAN_API, vulkan_gpu_list); - if (0 <= settings->ints.vulkan_gpu_index && settings->ints.vulkan_gpu_index < (int)gpu_count) + if (0 <= gpu_index && gpu_index < (int)gpu_count) { - RARCH_LOG("[Vulkan]: Using GPU index %d.\n", settings->ints.vulkan_gpu_index); - vk->context.gpu = gpus[settings->ints.vulkan_gpu_index]; + RARCH_LOG("[Vulkan]: Using GPU index %d.\n", gpu_index); + vk->context.gpu = gpus[gpu_index]; } else { - RARCH_WARN("[Vulkan]: Invalid GPU index %d, using first device found.\n", settings->ints.vulkan_gpu_index); + RARCH_WARN("[Vulkan]: Invalid GPU index %d, using first device found.\n", gpu_index); vk->context.gpu = gpus[0]; } From 2d946d0d954d96efd8055168c0ad72eff4a45599 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 14 Feb 2020 13:06:56 +0100 Subject: [PATCH 60/75] (PS2 gfx) Cleanups --- gfx/drivers/ps2_gfx.c | 289 ++++++++++++++++++++++-------------------- 1 file changed, 152 insertions(+), 137 deletions(-) diff --git a/gfx/drivers/ps2_gfx.c b/gfx/drivers/ps2_gfx.c index 3722eb8ae2..10b8ad3b51 100644 --- a/gfx/drivers/ps2_gfx.c +++ b/gfx/drivers/ps2_gfx.c @@ -23,10 +23,12 @@ #include "../../libretro-common/include/libretro_gskit_ps2.h" -#define GS_TEXT GS_SETREG_RGBAQ(0x80,0x80,0x80,0x80,0x00) // turn white GS Screen -#define GS_BLACK GS_SETREG_RGBAQ(0x00,0x00,0x00,0x00,0x00) // turn white GS Screen +/* turn white GS Screen */ +#define GS_TEXT GS_SETREG_RGBAQ(0x80,0x80,0x80,0x80,0x00) +/* turn white GS Screen */ +#define GS_BLACK GS_SETREG_RGBAQ(0x00,0x00,0x00,0x00,0x00) -#define NTSC_WIDTH 640 +#define NTSC_WIDTH 640 #define NTSC_HEIGHT 448 typedef struct ps2_video @@ -35,8 +37,11 @@ typedef struct ps2_video GSTEXTURE *menuTexture; GSTEXTURE *coreTexture; bool clearVRAM; - bool clearVRAM_font; /* I need to create this additional field to be used in the font driver*/ - struct retro_hw_render_interface_gskit_ps2 iface; /* Palette in the cores */ + /* I need to create this additional field + * to be used in the font driver*/ + bool clearVRAM_font; + /* Palette in the cores */ + struct retro_hw_render_interface_gskit_ps2 iface; bool menuVisible; bool fullscreen; @@ -49,21 +54,21 @@ typedef struct ps2_video int core_filter; } ps2_video_t; -// PRIVATE METHODS +/* PRIVATE METHODS */ static GSGLOBAL *init_GSGlobal(void) { - GSGLOBAL *gsGlobal = gsKit_init_global(); + GSGLOBAL *gsGlobal = gsKit_init_global(); - gsGlobal->Mode = GS_MODE_NTSC; - gsGlobal->Interlace = GS_INTERLACED; - gsGlobal->Field = GS_FIELD; - gsGlobal->Width = NTSC_WIDTH; - gsGlobal->Height = NTSC_HEIGHT; + gsGlobal->Mode = GS_MODE_NTSC; + gsGlobal->Interlace = GS_INTERLACED; + gsGlobal->Field = GS_FIELD; + gsGlobal->Width = NTSC_WIDTH; + gsGlobal->Height = NTSC_HEIGHT; - gsGlobal->PSM = GS_PSM_CT16; - gsGlobal->PSMZ = GS_PSMZ_16; + gsGlobal->PSM = GS_PSM_CT16; + gsGlobal->PSMZ = GS_PSMZ_16; gsGlobal->DoubleBuffering = GS_SETTING_OFF; - gsGlobal->ZBuffering = GS_SETTING_OFF; + gsGlobal->ZBuffering = GS_SETTING_OFF; gsGlobal->PrimAlphaEnable = GS_SETTING_OFF; dmaKit_init(D_CTRL_RELE_OFF,D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC, @@ -87,70 +92,80 @@ static GSTEXTURE * prepare_new_texture(void) static void init_ps2_video(ps2_video_t *ps2) { - ps2->gsGlobal = init_GSGlobal(); + ps2->gsGlobal = init_GSGlobal(); ps2->menuTexture = prepare_new_texture(); ps2->coreTexture = prepare_new_texture(); /* Used for cores that supports palette */ - ps2->iface.interface_type = RETRO_HW_RENDER_INTERFACE_GSKIT_PS2; + ps2->iface.interface_type = RETRO_HW_RENDER_INTERFACE_GSKIT_PS2; ps2->iface.interface_version = RETRO_HW_RENDER_INTERFACE_GSKIT_PS2_VERSION; - ps2->iface.coreTexture = ps2->coreTexture; + ps2->iface.coreTexture = ps2->coreTexture; } static void deinitTexture(GSTEXTURE *texture) { - texture->Mem = NULL; + texture->Mem = NULL; texture->Clut = NULL; } -static bool texture_need_prepare(GSTEXTURE *texture, int width, int height, int PSM) +static bool texture_need_prepare(GSTEXTURE *texture, + int width, int height, int PSM) { - return texture->Width != width || texture->Height != height || texture->PSM != PSM; + return texture->Width != width || + texture->Height != height || + texture->PSM != PSM; } static void transfer_texture(GSTEXTURE *texture, const void *frame, int width, int height, int PSM, int filter, bool color_correction) { - texture->Width = width; + texture->Width = width; texture->Height = height; - texture->PSM = PSM; + texture->PSM = PSM; texture->Filter = filter; - texture->Mem = (void *)frame; + texture->Mem = (void *)frame; } static void vram_alloc(GSGLOBAL *gsGlobal, GSTEXTURE *texture) { - uint32_t size = gsKit_texture_size(texture->Width, texture->Height, texture->PSM); + uint32_t size = gsKit_texture_size(texture->Width, + texture->Height, texture->PSM); texture->Vram = gsKit_vram_alloc(gsGlobal, size, GSKIT_ALLOC_USERBUFFER); - if(texture->Vram == GSKIT_ALLOC_ERROR) { + + if(texture->Vram == GSKIT_ALLOC_ERROR) + { printf("VRAM Allocation Failed. Will not upload texture.\n"); } - if (texture->Clut) { + if (texture->Clut) + { /* Right now just supporting 16 x 16 = 256 colours */ - size = gsKit_texture_size(16, 16, texture->ClutPSM); + size = gsKit_texture_size(16, 16, texture->ClutPSM); texture->VramClut = gsKit_vram_alloc(gsGlobal, size , GSKIT_ALLOC_USERBUFFER); } } static void prim_texture(GSGLOBAL *gsGlobal, GSTEXTURE *texture, int zPosition, bool force_aspect, struct retro_hw_ps2_insets padding) { - float x1, y1, x2, y2; - float visible_width = texture->Width - padding.left - padding.right; - float visible_height = texture->Height - padding.top - padding.bottom; - if (force_aspect) { - float width_proportion = (float)gsGlobal->Width / (float)visible_width; + float x1, y1, x2, y2; + float visible_width = texture->Width - padding.left - padding.right; + float visible_height = texture->Height - padding.top - padding.bottom; + + if (force_aspect) + { + float width_proportion = (float)gsGlobal->Width / (float)visible_width; float height_proportion = (float)gsGlobal->Height / (float)visible_height; - float delta = MIN(width_proportion, height_proportion); - float newWidth = visible_width * delta; - float newHeight = visible_height * delta; + float delta = MIN(width_proportion, height_proportion); + float newWidth = visible_width * delta; + float newHeight = visible_height * delta; x1 = (gsGlobal->Width - newWidth) / 2.0f; y1 = (gsGlobal->Height - newHeight) / 2.0f; x2 = newWidth + x1; y2 = newHeight + y1; - - } else { + } + else + { x1 = 0.0f; y1 = 0.0f; x2 = gsGlobal->Width; @@ -158,38 +173,44 @@ static void prim_texture(GSGLOBAL *gsGlobal, GSTEXTURE *texture, int zPosition, } gsKit_prim_sprite_texture( gsGlobal, texture, - x1, //X1 - y1, // Y1 - padding.left, // U1 - padding.top, // V1 - x2, // X2 - y2, // Y2 - texture->Width - padding.right, // U2 - texture->Height - padding.bottom, // V2 - zPosition, - GS_TEXT); + x1, /* X1 */ + y1, /* Y1 */ + padding.left, /* U1 */ + padding.top, /* V1 */ + x2, /* X2 */ + y2, /* Y2 */ + texture->Width - padding.right, /* U2 */ + texture->Height - padding.bottom, /* V2 */ + zPosition, + GS_TEXT); } -static void clearVRAMIfNeeded(ps2_video_t *ps2, const void *frame, int width, int height) +static void clearVRAMIfNeeded(ps2_video_t *ps2, + const void *frame, int width, int height) { - if (!ps2->clearVRAM) { - if(frame && frame != RETRO_HW_FRAME_BUFFER_VALID) { - bool coreVRAMClear = false; - coreVRAMClear = texture_need_prepare(ps2->coreTexture, width, height, ps2->PSM); + if (!ps2->clearVRAM) + { + if(frame && frame != RETRO_HW_FRAME_BUFFER_VALID) + { + bool coreVRAMClear = texture_need_prepare( + ps2->coreTexture, width, height, ps2->PSM); ps2->clearVRAM = ps2->clearVRAM || coreVRAMClear; } } - if (ps2->clearVRAM) { + if (ps2->clearVRAM) + { gsKit_vram_clear(ps2->gsGlobal); ps2->iface.updatedPalette = true; - ps2->clearVRAM_font = true; /* we need to upload also palette in the font driver */ + /* we need to upload also palette in the font driver */ + ps2->clearVRAM_font = true; } } static void refreshScreen(ps2_video_t *ps2) { - if (ps2->vsync) { + if (ps2->vsync) + { gsKit_sync_flip(ps2->gsGlobal); } gsKit_queue_exec(ps2->gsGlobal); @@ -199,22 +220,30 @@ static void refreshScreen(ps2_video_t *ps2) ps2->clearVRAM = false; } -static void ps2_texture_upload(GSGLOBAL *gsGlobal, GSTEXTURE *Texture, bool sendPalette) +static void ps2_texture_upload(GSGLOBAL *gsGlobal, GSTEXTURE *Texture, + bool sendPalette) { gsKit_setup_tbw(Texture); - if (Texture->PSM == GS_PSM_T8) { + if (Texture->PSM == GS_PSM_T8) + { gsKit_texture_send(Texture->Mem, Texture->Width, Texture->Height, Texture->Vram, Texture->PSM, Texture->TBW, GS_CLUT_TEXTURE); - if (sendPalette) { + if (sendPalette) + { gsKit_texture_send(Texture->Clut, 16, 16, Texture->VramClut, Texture->ClutPSM, 1, GS_CLUT_PALLETE); } - } else if (Texture->PSM == GS_PSM_T4) { + } + else if (Texture->PSM == GS_PSM_T4) + { gsKit_texture_send(Texture->Mem, Texture->Width, Texture->Height, Texture->Vram, Texture->PSM, Texture->TBW, GS_CLUT_TEXTURE); - if (sendPalette) { + if (sendPalette) + { gsKit_texture_send(Texture->Clut, 8, 2, Texture->VramClut, Texture->ClutPSM, 1, GS_CLUT_PALLETE); } - } else { + } + else + { gsKit_texture_send(Texture->Mem, Texture->Width, Texture->Height, Texture->Vram, Texture->PSM, Texture->TBW, GS_CLUT_NONE); } } @@ -222,31 +251,32 @@ static void ps2_texture_upload(GSGLOBAL *gsGlobal, GSTEXTURE *Texture, bool send static void *ps2_gfx_init(const video_info_t *video, input_driver_t **input, void **input_data) { - void *ps2input = NULL; - *input_data = NULL; - (void)video; - + void *ps2input = NULL; ps2_video_t *ps2 = (ps2_video_t*)calloc(1, sizeof(ps2_video_t)); + *input_data = NULL; + if (!ps2) return NULL; init_ps2_video(ps2); - if (video->font_enable) { + if (video->font_enable) font_driver_init_osd(ps2, false, video->is_threaded, FONT_DRIVER_RENDER_PS2); - } - ps2->PSM = (video->rgb32 ? GS_PSM_CT32 : GS_PSM_CT16); - ps2->fullscreen = video->fullscreen; - ps2->core_filter = video->smooth ? GS_FILTER_LINEAR : GS_FILTER_NEAREST; - ps2->force_aspect = video->force_aspect; - ps2->vsync = video->vsync; - ps2->clearVRAM = true; - if (input && input_data) { + ps2->PSM = (video->rgb32 ? GS_PSM_CT32 : GS_PSM_CT16); + ps2->fullscreen = video->fullscreen; + ps2->core_filter = video->smooth ? GS_FILTER_LINEAR : GS_FILTER_NEAREST; + ps2->force_aspect = video->force_aspect; + ps2->vsync = video->vsync; + ps2->clearVRAM = true; + + if (input && input_data) + { settings_t *settings = config_get_ptr(); - ps2input = input_ps2.init(settings->arrays.input_joypad_driver); - *input = ps2input ? &input_ps2 : NULL; - *input_data = ps2input; + ps2input = input_ps2.init( + settings->arrays.input_joypad_driver); + *input = ps2input ? &input_ps2 : NULL; + *input_data = ps2input; } return ps2; @@ -262,7 +292,8 @@ static bool ps2_gfx_frame(void *data, const void *frame, return false; #if defined(DEBUG) - if (frame_count%60==0) { + if (frame_count%60==0) + { printf("ps2_gfx_frame %lu\n", frame_count); } #endif @@ -270,36 +301,44 @@ static bool ps2_gfx_frame(void *data, const void *frame, clearVRAMIfNeeded(ps2, frame, width, height); gsKit_clear(ps2->gsGlobal, GS_BLACK); - if (frame) { + if (frame) + { bool sendPalette = false; struct retro_hw_ps2_insets padding = empty_ps2_insets; - if (frame != RETRO_HW_FRAME_BUFFER_VALID){ /* Checking if the transfer is done in the core */ + if (frame != RETRO_HW_FRAME_BUFFER_VALID) + { + /* Checking if the transfer is done in the core */ /* calculate proper width based in the pitch */ int bytes_per_pixel = (ps2->PSM == GS_PSM_CT32) ? 4 : 2; - int real_width = pitch / bytes_per_pixel; + int real_width = pitch / bytes_per_pixel; + transfer_texture(ps2->coreTexture, frame, real_width, height, ps2->PSM, ps2->core_filter, 1); - padding.right = real_width - width; - } else { - sendPalette = ps2->iface.updatedPalette; + + padding.right = real_width - width; + } + else + { + sendPalette = ps2->iface.updatedPalette; ps2->iface.updatedPalette = false; padding = ps2->iface.padding; - if (ps2->iface.clearTexture) { + if (ps2->iface.clearTexture) ps2->iface.clearTexture = false; - } } - if(ps2->clearVRAM) { + + if(ps2->clearVRAM) vram_alloc(ps2->gsGlobal, ps2->coreTexture); - } + ps2_texture_upload(ps2->gsGlobal, ps2->coreTexture, sendPalette); prim_texture(ps2->gsGlobal, ps2->coreTexture, 1, ps2->force_aspect, padding); } - if (ps2->menuVisible) { + if (ps2->menuVisible) + { bool texture_empty = !ps2->menuTexture->Width || !ps2->menuTexture->Height; - if (!texture_empty) { - if(ps2->clearVRAM) { + if (!texture_empty) + { + if(ps2->clearVRAM) vram_alloc(ps2->gsGlobal, ps2->menuTexture); - } gsKit_texture_upload(ps2->gsGlobal, ps2->menuTexture); prim_texture(ps2->gsGlobal, ps2->menuTexture, 2, ps2->fullscreen, empty_ps2_insets); } @@ -330,30 +369,10 @@ static void ps2_gfx_set_nonblock_state(void *data, bool toggle) ps2->vsync = !toggle; } -static bool ps2_gfx_alive(void *data) -{ - (void)data; - return true; -} - -static bool ps2_gfx_focus(void *data) -{ - (void)data; - return true; -} - -static bool ps2_gfx_suppress_screensaver(void *data, bool enable) -{ - (void)data; - (void)enable; - return false; -} - -static bool ps2_gfx_has_windowed(void *data) -{ - (void)data; - return true; -} +static bool ps2_gfx_alive(void *data) { return true; } +static bool ps2_gfx_focus(void *data) { return true; } +static bool ps2_gfx_suppress_screensaver(void *data, bool enable) { return false; } +static bool ps2_gfx_has_windowed(void *data) { return false; } static void ps2_gfx_free(void *data) { @@ -376,14 +395,7 @@ static void ps2_gfx_free(void *data) } static bool ps2_gfx_set_shader(void *data, - enum rarch_shader_type type, const char *path) -{ - (void)data; - (void)type; - (void)path; - - return false; -} + enum rarch_shader_type type, const char *path) { return false; } static void ps2_set_filtering(void *data, unsigned index, bool smooth) { @@ -393,13 +405,13 @@ static void ps2_set_filtering(void *data, unsigned index, bool smooth) } static void ps2_set_texture_frame(void *data, const void *frame, bool rgb32, - unsigned width, unsigned height, float alpha) + unsigned width, unsigned height, float alpha) { - ps2_video_t *ps2 = (ps2_video_t*)data; + ps2_video_t *ps2 = (ps2_video_t*)data; bool color_correction = false; - int PSM = (rgb32 ? GS_PSM_CT32 : GS_PSM_CT16); - bool texture_changed = texture_need_prepare(ps2->menuTexture, width, height, PSM); + int PSM = (rgb32 ? GS_PSM_CT32 : GS_PSM_CT16); + bool texture_changed = texture_need_prepare(ps2->menuTexture, width, height, PSM); transfer_texture(ps2->menuTexture, frame, width, height, PSM, ps2->menu_filter, color_correction); ps2->clearVRAM = ps2->clearVRAM || texture_changed; @@ -408,24 +420,27 @@ static void ps2_set_texture_frame(void *data, const void *frame, bool rgb32, static void ps2_set_texture_enable(void *data, bool enable, bool fullscreen) { ps2_video_t *ps2 = (ps2_video_t*)data; - if (ps2->menuVisible != enable) { + + if (ps2->menuVisible != enable) + { /* If Menu change status, CLEAR VRAM */ - ps2->clearVRAM = true; - ps2->iface.clearTexture = true; + ps2->clearVRAM = true; + ps2->iface.clearTexture = true; ps2->iface.updatedPalette = true; } ps2->menuVisible = enable; - ps2->fullscreen = fullscreen; + ps2->fullscreen = fullscreen; } static bool ps2_get_hw_render_interface(void* data, const struct retro_hw_render_interface** iface) { - ps2_video_t* ps2 = (ps2_video_t*)data; - ps2->iface.clearTexture = ps2->clearVRAM; + ps2_video_t *ps2 = (ps2_video_t*)data; + ps2->iface.clearTexture = ps2->clearVRAM; ps2->iface.updatedPalette = true; - ps2->iface.padding = empty_ps2_insets; - *iface = (const struct retro_hw_render_interface*)&ps2->iface; + ps2->iface.padding = empty_ps2_insets; + *iface = + (const struct retro_hw_render_interface*)&ps2->iface; return true; } From ebd3e65f4607158fd033c3fb71ed96df30faf107 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 14 Feb 2020 13:16:21 +0100 Subject: [PATCH 61/75] (ps2 compat files) Cleanups --- ps2/compat_files/compat_ctype.c | 372 ++++++++++++++++-------------- ps2/compat_files/ps2_descriptor.c | 34 ++- ps2/compat_files/ps2_devices.c | 11 +- ps2/compat_files/time.c | 27 +-- 4 files changed, 229 insertions(+), 215 deletions(-) diff --git a/ps2/compat_files/compat_ctype.c b/ps2/compat_files/compat_ctype.c index 3e139a83d9..d7b91d0f17 100644 --- a/ps2/compat_files/compat_ctype.c +++ b/ps2/compat_files/compat_ctype.c @@ -40,10 +40,9 @@ int islower(int c) int tolower(int ch) { - if(ch >= 'A' && ch <= 'Z') - return ('a' + ch - 'A'); - else - return ch; + if(ch >= 'A' && ch <= 'Z') + return ('a' + ch - 'A'); + return ch; } int toupper(int c) @@ -107,16 +106,17 @@ char * strcat(char *dest, const char *src) char *strchr(const char *string, int c) { - while (*string) { - if (*string == c) - return (char *)string; - string++; - } + while (*string) + { + if (*string == c) + return (char *)string; + string++; + } - if (*string == c) - return (char *)string; + if (*string == c) + return (char *)string; - return NULL; + return NULL; } int strcmp(const char *s1, const char *s2) @@ -144,14 +144,16 @@ size_t strcspn(const char *s1, const char *s2) * Stop as soon as we find any character from s2. Note that there * must be a NUL in s2; it suffices to stop when we find that, too. */ - for (p = s1;;) { - c = *p++; - spanp = s2; - do { - if ((sc = *spanp++) == c) - return (p - 1 - s1); - } while (sc != 0); - } + for (p = s1;;) + { + c = *p++; + spanp = s2; + do + { + if ((sc = *spanp++) == c) + return (p - 1 - s1); + }while(sc != 0); + } /* NOTREACHED */ } @@ -166,51 +168,59 @@ size_t strlen(const char *str) char * strncat(char *dst, const char *src, size_t n) { - if (n != 0) { - char *d = dst; - const char *s = src; + if (n != 0) + { + char *d = dst; + const char *s = src; - while (*d != 0) - d++; - do { - if ((*d = *s++) == 0) - break; - d++; - } while (--n != 0); - *d = 0; - } - return (dst); + while (*d != 0) + d++; + do + { + if ((*d = *s++) == 0) + break; + d++; + }while(--n != 0); + *d = 0; + } + return (dst); } int strncmp(const char *s1, const char *s2, size_t n) { if (n == 0) return (0); - do { + + do + { if (*s1 != *s2++) return (*(unsigned char *)s1 - *(unsigned char *)--s2); if (*s1++ == 0) break; - } while (--n != 0); + }while (--n != 0); + return (0); } char * strncpy(char *dst, const char *src, size_t n) { - if (n != 0) { - char *d = dst; - const char *s = src; + if (n != 0) + { + char *d = dst; + const char *s = src; - do { - if ((*d++ = *s++) == 0) { - /* NUL pad the remaining n-1 bytes */ - while (--n != 0) - *d++ = 0; - break; - } - } while (--n != 0); - } - return (dst); + do + { + if ((*d++ = *s++) == 0) + { + /* NUL pad the remaining n-1 bytes */ + while (--n != 0) + *d++ = 0; + break; + } + }while(--n != 0); + } + return (dst); } char * strpbrk(const char *s1, const char *s2) @@ -218,11 +228,12 @@ char * strpbrk(const char *s1, const char *s2) const char *scanp; int c, sc; - while ((c = *s1++) != 0) { - for (scanp = s2; (sc = *scanp++) != 0;) - if (sc == c) - return ((char *)(s1 - 1)); - } + while ((c = *s1++) != 0) + { + for (scanp = s2; (sc = *scanp++) != 0;) + if (sc == c) + return ((char *)(s1 - 1)); + } return (NULL); } @@ -231,13 +242,13 @@ char * strrchr(const char *p, int ch) { char *save; - for (save = NULL;; ++p) { - if (*p == (char) ch) - save = (char *)p; - if (!*p) - return(save); - } - /* NOTREACHED */ + for (save = NULL;; ++p) + { + if (*p == (char) ch) + save = (char *)p; + if (!*p) + return(save); + } } size_t strspn(const char *s1, const char *s2) @@ -268,11 +279,12 @@ char *strstr(const char *string, const char *substring) strpos = (char *)string; - while (*strpos != 0) { - if (strncmp(strpos, substring, strlen(substring)) == 0) - return strpos; + while (*strpos != 0) + { + if (strncmp(strpos, substring, strlen(substring)) == 0) + return strpos; - strpos++; + strpos++; } return 0; @@ -280,123 +292,132 @@ char *strstr(const char *string, const char *substring) size_t strnlen(const char *str, size_t maxlen) { - const char *cp; + const char *cp; - for (cp = str; maxlen != 0 && *cp != '\0'; cp++, maxlen--) - ; + for (cp = str; maxlen != 0 && *cp != '\0'; cp++, maxlen--) + ; - return (size_t)(cp - str); + return (size_t)(cp - str); } char *strtok(char *strToken, const char *strDelimit) { - static char *start; - static char *end; + static char *start; + static char *end; - if (strToken != NULL) - start = strToken; - else { - if (*end == 0) - return 0; + if (strToken) + start = strToken; + else + { + if (*end == 0) + return 0; - start = end; - } + start = end; + } - if (*start == 0) - return 0; + if (*start == 0) + return 0; - // Strip out any leading delimiters - while (strchr(strDelimit, *start)) { - // If a character from the delimiting string - // then skip past it + /* Strip out any leading delimiters */ + while (strchr(strDelimit, *start)) + { + /* If a character from the delimiting string + * then skip past it */ + start++; - start++; + if (*start == 0) + return 0; + } - if (*start == 0) - return 0; - } + if (*start == 0) + return 0; - if (*start == 0) - return 0; + end = start; - end = start; + while (*end != 0) + { + if (strchr(strDelimit, *end)) + { + /* if we find a delimiting character + * before the end of the string, then + * terminate the token and move the end + * pointer to the next character + */ + *end = 0; + end++; + return start; + } + end++; + } - while (*end != 0) { - if (strchr(strDelimit, *end)) { - // if we find a delimiting character - // before the end of the string, then - // terminate the token and move the end - // pointer to the next character - *end = 0; - end++; - return start; - } - end++; - } - - // reached the end of the string before finding a delimiter - // so dont move on to the next character - return start; + /* reached the end of the string before finding a delimiter + * so dont move on to the next character */ + return start; } char * strtok_r (char *s, const char *delim, char **save_ptr) { - char *end; - if (s == NULL) - s = *save_ptr; - if (*s == '\0') - { + char *end; + if (!s) + s = *save_ptr; + if (*s == '\0') + { *save_ptr = s; return NULL; - } - /* Scan leading delimiters. */ - s += strspn (s, delim); - if (*s == '\0') - { + } + /* Scan leading delimiters. */ + s += strspn (s, delim); + if (*s == '\0') + { *save_ptr = s; return NULL; - } - /* Find the end of the token. */ - end = s + strcspn (s, delim); - if (*end == '\0') - { + } + /* Find the end of the token. */ + end = s + strcspn (s, delim); + if (*end == '\0') + { *save_ptr = end; return s; - } - /* Terminate the token and make *SAVE_PTR point past it. */ - *end = '\0'; - *save_ptr = end + 1; - return s; + } + /* Terminate the token and make *SAVE_PTR point past it. */ + *end = '\0'; + *save_ptr = end + 1; + return s; } -unsigned long long strtoull(const char * __restrict nptr, char ** __restrict endptr, int base) +unsigned long long strtoull(const char * __restrict nptr, + char ** __restrict endptr, int base) { - const char *s; - unsigned long long acc; char c; + unsigned long long acc; unsigned long long cutoff; int neg, any, cutlim; - /* * See strtoq for comments as to the logic used. */ - s = nptr; - do { + const char *s = nptr; + + do + { c = *s++; - } while (isspace((unsigned char)c)); - if (c == '-') { + }while(isspace((unsigned char)c)); + if (c == '-') + { neg = 1; - c = *s++; - } else { + c = *s++; + } + else + { neg = 0; if (c == '+') c = *s++; } if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) { - c = s[1]; - s += 2; - base = 16; + c == '0' && (*s == 'x' || *s == 'X')) + { + c = s[1]; + s += 2; + base = 16; } if (base == 0) base = c == '0' ? 8 : 10; @@ -406,34 +427,40 @@ unsigned long long strtoull(const char * __restrict nptr, char ** __restrict end cutoff = ULLONG_MAX / base; cutlim = ULLONG_MAX % base; - for ( ; ; c = *s++) { - if (c >= '0' && c <= '9') - c -= '0'; - else if (c >= 'A' && c <= 'Z') - c -= 'A' - 10; - else if (c >= 'a' && c <= 'z') - c -= 'a' - 10; - else - break; - if (c >= base) - break; - if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) - any = -1; - else { - any = 1; - acc *= base; - acc += c; - } - } - if (any < 0) { - acc = ULLONG_MAX; + for ( ; ; c = *s++) + { + if (c >= '0' && c <= '9') + c -= '0'; + else if (c >= 'A' && c <= 'Z') + c -= 'A' - 10; + else if (c >= 'a' && c <= 'z') + c -= 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) + any = -1; + else + { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) + { + acc = ULLONG_MAX; errno = ERANGE; - } else if (!any) { + } + else if (!any) + { noconv: errno = EINVAL; - } else if (neg) + } + else if (neg) acc = -acc; - if (endptr != NULL) + if (endptr) *endptr = (char *)(any ? s - 1 : nptr); return (acc); } @@ -443,17 +470,6 @@ float strtof(const char* str, char** endptr) return (float) strtod(str, endptr); } -int link(const char *oldpath, const char *newpath) -{ - return fileXioSymlink(oldpath, newpath); -} - -int unlink(const char *path) -{ - return fileXioRemove(path); -} - -int rename(const char *source, const char *dest) -{ - return fileXioRename(source, dest); -} +int link(const char *oldpath, const char *newpath) { return fileXioSymlink(oldpath, newpath); } +int unlink(const char *path) { return fileXioRemove(path); } +int rename(const char *source, const char *dest) { return fileXioRename(source, dest); } diff --git a/ps2/compat_files/ps2_descriptor.c b/ps2/compat_files/ps2_descriptor.c index 7048acf182..e74807ab1e 100644 --- a/ps2/compat_files/ps2_descriptor.c +++ b/ps2/compat_files/ps2_descriptor.c @@ -23,15 +23,9 @@ static DescriptorTranslation *__ps2_fdmap[MAX_OPEN_FILES]; static DescriptorTranslation __ps2_fdmap_pool[MAX_OPEN_FILES]; static int _lock_sema_id = -1; -static inline int _lock(void) -{ - return(WaitSema(_lock_sema_id)); -} +static inline int _lock(void) { return(WaitSema(_lock_sema_id)); } -static inline int _unlock(void) -{ - return(SignalSema(_lock_sema_id)); -} +static inline int _unlock(void) { return(SignalSema(_lock_sema_id)); } static int __ps2_fd_drop(DescriptorTranslation *map) { @@ -45,9 +39,7 @@ static int __ps2_fd_drop(DescriptorTranslation *map) memset(map, 0, sizeof(DescriptorTranslation)); } else - { map->ref_count--; - } _unlock(); return 0; @@ -61,19 +53,21 @@ int is_fd_valid(int fd) return (fd >= 0) && (fd < MAX_OPEN_FILES) && (__ps2_fdmap[fd] != NULL); } -void _init_ps2_io(void) { +void _init_ps2_io(void) +{ ee_sema_t sp; memset(__ps2_fdmap, 0, sizeof(__ps2_fdmap)); memset(__ps2_fdmap_pool, 0, sizeof(__ps2_fdmap_pool)); sp.init_count = 1; - sp.max_count = 1; - sp.option = 0; + sp.max_count = 1; + sp.option = 0; _lock_sema_id = CreateSema(&sp); } -void _free_ps2_io(void) { +void _free_ps2_io(void) +{ _lock(); _unlock(); if(_lock_sema_id >= 0) DeleteSema(_lock_sema_id); @@ -88,17 +82,18 @@ int __ps2_acquire_descriptor(void) /* get free descriptor */ for (fd = 0; fd < MAX_OPEN_FILES; ++fd) { - if (__ps2_fdmap[fd] == NULL) + if (!__ps2_fdmap[fd]) { /* get free pool */ for (i = 0; i < MAX_OPEN_FILES; ++i) { if (__ps2_fdmap_pool[i].ref_count == 0) { - __ps2_fdmap[fd] = &__ps2_fdmap_pool[i]; - __ps2_fdmap[fd]->ref_count = 1; + __ps2_fdmap[fd] = &__ps2_fdmap_pool[i]; + __ps2_fdmap[fd]->ref_count = 1; __ps2_fdmap[fd]->current_folder_position = -1; - __ps2_fdmap[fd]->FileEntry = calloc(sizeof(entries), FILEENTRY_SIZE); + __ps2_fdmap[fd]->FileEntry = + calloc(sizeof(entries), FILEENTRY_SIZE); _unlock(); return MAX_OPEN_FILES - fd; } @@ -115,7 +110,8 @@ int __ps2_release_descriptor(int fd) { int res = -1; - if (is_fd_valid(fd) && __ps2_fd_drop(__ps2_fdmap[MAX_OPEN_FILES - fd]) >= 0) + if (is_fd_valid(fd) && + __ps2_fd_drop(__ps2_fdmap[MAX_OPEN_FILES - fd]) >= 0) { _lock(); /* Correct fd value */ diff --git a/ps2/compat_files/ps2_devices.c b/ps2/compat_files/ps2_devices.c index 2c9c1bf6f5..e9bb2ae405 100644 --- a/ps2/compat_files/ps2_devices.c +++ b/ps2/compat_files/ps2_devices.c @@ -160,8 +160,9 @@ enum BootDeviceIDs getBootDeviceID(char *path) bool waitUntilDeviceIsReady(enum BootDeviceIDs device_id) { - int openFile = - 1; - int retries = 3; /* just in case we tried a unit that is not working/connected */ + int openFile = - 1; + /* just in case we tried a unit that is not working/connected */ + int retries = 3; char *rootDevice = rootDevicePath(device_id); while(openFile < 0 && retries > 0) @@ -178,10 +179,10 @@ bool waitUntilDeviceIsReady(enum BootDeviceIDs device_id) nopdelay(); retries--; - }; - if (openFile > 0) { - fileXioDclose(openFile); } + + if (openFile > 0) + fileXioDclose(openFile); return openFile >= 0; } diff --git a/ps2/compat_files/time.c b/ps2/compat_files/time.c index dff8185edf..47518ff614 100644 --- a/ps2/compat_files/time.c +++ b/ps2/compat_files/time.c @@ -54,15 +54,15 @@ static time_t _gmtotime_t ( long passed_seconds_current_day; time_t seconds_from_1970 = -1; - if ((yr >= MIN_SUPPORTED_YEAR) || (yr <= MAX_SUPPORTED_YEAR)) { + if ((yr >= MIN_SUPPORTED_YEAR) || (yr <= MAX_SUPPORTED_YEAR)) + { passed_years = (long)yr - MIN_SUPPORTED_YEAR; /* Years after 1970 */ /* Calculate days for these years */ passed_days = passed_years * DAYS_YEAR; passed_days += (passed_years >> 2) * (DAYS_YEAR + 1); /* passed leap years */ passed_days += dy + _days[mo - 1]; /* passed days in the year */ - if ( !(yr & 3) && (mo > 2) ) { + if ( !(yr & 3) && (mo > 2) ) passed_days++; /* if current year, is a leap year */ - } passed_seconds_current_day = (((hr * MINS_HOUR) + mn) * SECS_MIN) + sc; seconds_from_1970 = (passed_days * HOURS_DAY * MINS_HOUR * SECS_MIN) + passed_seconds_current_day; } @@ -70,7 +70,8 @@ static time_t _gmtotime_t ( return seconds_from_1970; } -time_t ps2_time(time_t *t) { +time_t ps2_time(time_t *t) +{ time_t tim; sceCdCLOCK clocktime; /* defined in libcdvd.h */ @@ -78,16 +79,16 @@ time_t ps2_time(time_t *t) { configConvertToLocalTime(&clocktime); tim = _gmtotime_t (DEC(clocktime.year)+ STARTING_YEAR, - DEC(clocktime.month), - DEC(clocktime.day), - DEC(clocktime.hour), - DEC(clocktime.minute), - DEC(clocktime.second)); + DEC(clocktime.month), + DEC(clocktime.day), + DEC(clocktime.hour), + DEC(clocktime.minute), + DEC(clocktime.second)); - if(t) - *t = tim; + if (t) + *t = tim; - return tim; + return tim; } /* Protected methods in libc */ @@ -134,4 +135,4 @@ size_t strftime(char *s, size_t max, const char *format, const struct tm *tm) char *setlocale(int category, const char *locale) { return NULL; -} \ No newline at end of file +} From e5674b146d35730087ebe946730a486d08e028a7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 14 Feb 2020 13:33:27 +0100 Subject: [PATCH 62/75] (PSP) Buildfix --- menu/cbs/menu_cbs_left.c | 2 +- menu/cbs/menu_cbs_right.c | 2 +- menu/menu_displaylist.c | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 433c7f8d5a..e640af55dc 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -530,7 +530,7 @@ static int manual_content_scan_system_name_left(unsigned type, const char *label manual_content_scan_get_menu_system_name_list(settings->paths.path_content_database, settings->bools.show_hidden_files); #else struct string_list *system_name_list = - manual_content_scan_get_menu_system_name_list(NULL); + manual_content_scan_get_menu_system_name_list(NULL, settings->bools.show_hidden_files); #endif const char *current_system_name = NULL; enum manual_content_scan_system_name_type next_system_name_type = diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 9b28efa7e9..a19b556dcb 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -611,8 +611,8 @@ static int playlist_left_thumbnail_mode_right(unsigned type, const char *label, static int manual_content_scan_system_name_right(unsigned type, const char *label, bool wraparound) { -#ifdef HAVE_LIBRETRODB settings_t *settings = config_get_ptr(); +#ifdef HAVE_LIBRETRODB struct string_list *system_name_list = manual_content_scan_get_menu_system_name_list( settings->paths.path_content_database, diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 65b705c673..a6fedd0d8b 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -5289,15 +5289,18 @@ unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ct count = populate_playlist_thumbnail_mode_dropdown_list(list, PLAYLIST_THUMBNAIL_LEFT); break; case DISPLAYLIST_DROPDOWN_LIST_MANUAL_CONTENT_SCAN_SYSTEM_NAME: + /* Get system name list */ { - /* Get system name list */ -#ifdef HAVE_LIBRETRODB settings_t *settings = config_get_ptr(); +#ifdef HAVE_LIBRETRODB struct string_list *system_name_list = - manual_content_scan_get_menu_system_name_list(settings->paths.path_content_database, settings->bools.show_hidden_files); + manual_content_scan_get_menu_system_name_list( + settings->paths.path_content_database, + settings->bools.show_hidden_files); #else struct string_list *system_name_list = - manual_content_scan_get_menu_system_name_list(NULL, settings->bools.show_hidden_files); + manual_content_scan_get_menu_system_name_list(NULL, + settings->bools.show_hidden_files); #endif if (system_name_list) From 3b2a3c127720984cc19577c4dc3abce4e3155daf Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 14 Feb 2020 14:05:35 +0100 Subject: [PATCH 63/75] (led_driver) Take out settings_t dependency (menu cbs sublabel) Add HAVE_MATERIALUI ifdefs --- led/led_driver.c | 28 ++++++++++++---------------- led/led_driver.h | 2 +- menu/cbs/menu_cbs_sublabel.c | 24 +++++++++++++++++++++++- retroarch.c | 2 +- 4 files changed, 37 insertions(+), 19 deletions(-) diff --git a/led/led_driver.c b/led/led_driver.c index 8a36927722..bfc84c6585 100644 --- a/led/led_driver.c +++ b/led/led_driver.c @@ -16,7 +16,6 @@ #include #include "led_driver.h" -#include "../configuration.h" #include "../verbosity.h" static const led_driver_t *current_led_driver = NULL; @@ -32,43 +31,40 @@ static const led_driver_t null_led_driver = { "null" }; -bool led_driver_init(void) +void led_driver_init(const char *led_driver) { - settings_t *settings = config_get_ptr(); - char *drivername = settings ? settings->arrays.led_driver : NULL; + const char *drivername = led_driver; - if(!drivername) - drivername = (char*)"null"; + if (!drivername) + drivername = (const char*)"null"; - current_led_driver = &null_led_driver; + current_led_driver = &null_led_driver; #ifdef HAVE_OVERLAY - if(string_is_equal("overlay", drivername)) - current_led_driver = &overlay_led_driver; + if (string_is_equal("overlay", drivername)) + current_led_driver = &overlay_led_driver; #endif #if HAVE_RPILED - if(string_is_equal("rpi", drivername)) - current_led_driver = &rpi_led_driver; + if (string_is_equal("rpi", drivername)) + current_led_driver = &rpi_led_driver; #endif RARCH_LOG("[LED]: LED driver = '%s' %p\n", drivername, current_led_driver); - if(current_led_driver) + if (current_led_driver) (*current_led_driver->init)(); - - return true; } void led_driver_free(void) { - if(current_led_driver) + if (current_led_driver) (*current_led_driver->free)(); } void led_driver_set_led(int led, int value) { - if(current_led_driver) + if (current_led_driver) (*current_led_driver->set_led)(led, value); } diff --git a/led/led_driver.h b/led/led_driver.h index 376199bdac..b91e7db0dc 100644 --- a/led/led_driver.h +++ b/led/led_driver.h @@ -35,7 +35,7 @@ typedef struct led_driver const char *ident; } led_driver_t; -bool led_driver_init(void); +void led_driver_init(const char *led_driver); void led_driver_free(void); diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 88ce152d8f..e67996be22 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -213,11 +213,13 @@ default_sublabel_macro(action_bind_sublabel_statistics_show, MENU_ default_sublabel_macro(action_bind_sublabel_netplay_settings, MENU_ENUM_SUBLABEL_NETPLAY) default_sublabel_macro(action_bind_sublabel_user_bind_settings, MENU_ENUM_SUBLABEL_INPUT_USER_BINDS) default_sublabel_macro(action_bind_sublabel_input_hotkey_settings, MENU_ENUM_SUBLABEL_INPUT_HOTKEY_BINDS) +#ifdef HAVE_MATERIALUI default_sublabel_macro(action_bind_sublabel_materialui_icons_enable, MENU_ENUM_SUBLABEL_MATERIALUI_ICONS_ENABLE) default_sublabel_macro(action_bind_sublabel_materialui_landscape_layout_optimization, MENU_ENUM_SUBLABEL_MATERIALUI_LANDSCAPE_LAYOUT_OPTIMIZATION) default_sublabel_macro(action_bind_sublabel_materialui_auto_rotate_nav_bar, MENU_ENUM_SUBLABEL_MATERIALUI_AUTO_ROTATE_NAV_BAR) default_sublabel_macro(action_bind_sublabel_materialui_dual_thumbnail_list_view_enable, MENU_ENUM_SUBLABEL_MATERIALUI_DUAL_THUMBNAIL_LIST_VIEW_ENABLE) default_sublabel_macro(action_bind_sublabel_materialui_thumbnail_background_enable, MENU_ENUM_SUBLABEL_MATERIALUI_THUMBNAIL_BACKGROUND_ENABLE) +#endif default_sublabel_macro(action_bind_sublabel_add_content_list, MENU_ENUM_SUBLABEL_ADD_CONTENT_LIST) default_sublabel_macro(action_bind_sublabel_video_frame_delay, MENU_ENUM_SUBLABEL_VIDEO_FRAME_DELAY) default_sublabel_macro(action_bind_sublabel_video_shader_delay, MENU_ENUM_SUBLABEL_VIDEO_SHADER_DELAY) @@ -422,11 +424,13 @@ default_sublabel_macro(action_bind_sublabel_mouse_enable, MENU_ default_sublabel_macro(action_bind_sublabel_pointer_enable, MENU_ENUM_SUBLABEL_POINTER_ENABLE) default_sublabel_macro(action_bind_sublabel_thumbnails, MENU_ENUM_SUBLABEL_THUMBNAILS) default_sublabel_macro(action_bind_sublabel_thumbnails_rgui, MENU_ENUM_SUBLABEL_THUMBNAILS_RGUI) +#ifdef HAVE_MATERIALUI default_sublabel_macro(action_bind_sublabel_thumbnails_materialui, MENU_ENUM_SUBLABEL_THUMBNAILS_MATERIALUI) +default_sublabel_macro(action_bind_sublabel_left_thumbnails_materialui, MENU_ENUM_SUBLABEL_LEFT_THUMBNAILS_MATERIALUI) +#endif default_sublabel_macro(action_bind_sublabel_left_thumbnails, MENU_ENUM_SUBLABEL_LEFT_THUMBNAILS) default_sublabel_macro(action_bind_sublabel_left_thumbnails_rgui, MENU_ENUM_SUBLABEL_LEFT_THUMBNAILS_RGUI) default_sublabel_macro(action_bind_sublabel_left_thumbnails_ozone, MENU_ENUM_SUBLABEL_LEFT_THUMBNAILS_OZONE) -default_sublabel_macro(action_bind_sublabel_left_thumbnails_materialui, MENU_ENUM_SUBLABEL_LEFT_THUMBNAILS_MATERIALUI) default_sublabel_macro(action_bind_sublabel_menu_thumbnail_upscale_threshold, MENU_ENUM_SUBLABEL_MENU_THUMBNAIL_UPSCALE_THRESHOLD) default_sublabel_macro(action_bind_sublabel_timedate_enable, MENU_ENUM_SUBLABEL_TIMEDATE_ENABLE) default_sublabel_macro(action_bind_sublabel_timedate_style, MENU_ENUM_SUBLABEL_TIMEDATE_STYLE) @@ -514,9 +518,11 @@ default_sublabel_macro(action_bind_sublabel_xmb_shadows_enable, default_sublabel_macro(action_bind_sublabel_xmb_vertical_thumbnails, MENU_ENUM_SUBLABEL_XMB_VERTICAL_THUMBNAILS) default_sublabel_macro(action_bind_sublabel_menu_xmb_thumbnail_scale_factor, MENU_ENUM_SUBLABEL_MENU_XMB_THUMBNAIL_SCALE_FACTOR) default_sublabel_macro(action_bind_sublabel_menu_color_theme, MENU_ENUM_SUBLABEL_MATERIALUI_MENU_COLOR_THEME) +#ifdef HAVE_MATERIALUI default_sublabel_macro(action_bind_sublabel_materialui_menu_transition_animation, MENU_ENUM_SUBLABEL_MATERIALUI_MENU_TRANSITION_ANIMATION) default_sublabel_macro(action_bind_sublabel_materialui_menu_thumbnail_view_portrait, MENU_ENUM_SUBLABEL_MATERIALUI_MENU_THUMBNAIL_VIEW_PORTRAIT) default_sublabel_macro(action_bind_sublabel_materialui_menu_thumbnail_view_landscape, MENU_ENUM_SUBLABEL_MATERIALUI_MENU_THUMBNAIL_VIEW_LANDSCAPE) +#endif default_sublabel_macro(action_bind_sublabel_ozone_menu_color_theme, MENU_ENUM_SUBLABEL_OZONE_MENU_COLOR_THEME) default_sublabel_macro(action_bind_sublabel_ozone_collapse_sidebar, MENU_ENUM_SUBLABEL_OZONE_COLLAPSE_SIDEBAR) default_sublabel_macro(action_bind_sublabel_ozone_truncate_playlist_name, MENU_ENUM_SUBLABEL_OZONE_TRUNCATE_PLAYLIST_NAME) @@ -1290,19 +1296,29 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_audio_resampler_quality); break; case MENU_ENUM_LABEL_MATERIALUI_ICONS_ENABLE: +#ifdef HAVE_MATERIALUI BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_materialui_icons_enable); +#endif break; case MENU_ENUM_LABEL_MATERIALUI_LANDSCAPE_LAYOUT_OPTIMIZATION: +#ifdef HAVE_MATERIALUI BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_materialui_landscape_layout_optimization); +#endif break; case MENU_ENUM_LABEL_MATERIALUI_AUTO_ROTATE_NAV_BAR: +#ifdef HAVE_MATERIALUI BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_materialui_auto_rotate_nav_bar); +#endif break; case MENU_ENUM_LABEL_MATERIALUI_DUAL_THUMBNAIL_LIST_VIEW_ENABLE: +#ifdef HAVE_MATERIALUI BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_materialui_dual_thumbnail_list_view_enable); +#endif break; case MENU_ENUM_LABEL_MATERIALUI_THUMBNAIL_BACKGROUND_ENABLE: +#ifdef HAVE_MATERIALUI BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_materialui_thumbnail_background_enable); +#endif break; case MENU_ENUM_LABEL_VIDEO_VIEWPORT_CUSTOM_HEIGHT: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_viewport_custom_height); @@ -1765,13 +1781,19 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_color_theme); break; case MENU_ENUM_LABEL_MATERIALUI_MENU_TRANSITION_ANIMATION: +#ifdef HAVE_MATERIALUI BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_materialui_menu_transition_animation); +#endif break; case MENU_ENUM_LABEL_MATERIALUI_MENU_THUMBNAIL_VIEW_PORTRAIT: +#ifdef HAVE_MATERIALUI BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_materialui_menu_thumbnail_view_portrait); +#endif break; case MENU_ENUM_LABEL_MATERIALUI_MENU_THUMBNAIL_VIEW_LANDSCAPE: +#ifdef HAVE_MATERIALUI BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_materialui_menu_thumbnail_view_landscape); +#endif break; case MENU_ENUM_LABEL_XMB_SHADOWS_ENABLE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_xmb_shadows_enable); diff --git a/retroarch.c b/retroarch.c index ce04f92251..ac4af9421c 100644 --- a/retroarch.c +++ b/retroarch.c @@ -23486,7 +23486,7 @@ static void drivers_init(int flags) /* Initialize LED driver */ if (flags & DRIVER_LED_MASK) - led_driver_init(); + led_driver_init(settings->arrays.led_driver); /* Initialize MIDI driver */ if (flags & DRIVER_MIDI_MASK) From dad077adf3ffac3162c3fb74dbda80095608cc06 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 14 Feb 2020 14:11:25 +0100 Subject: [PATCH 64/75] Cleanups --- input/input_remapping.c | 13 +++++-------- input/input_remapping.h | 3 ++- menu/cbs/menu_cbs_ok.c | 4 +++- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/input/input_remapping.c b/input/input_remapping.c index 4c17c0ad82..499f75ddff 100644 --- a/input/input_remapping.c +++ b/input/input_remapping.c @@ -63,7 +63,7 @@ bool input_remapping_load_file(void *data, const char *path) "l3", "r3", "l_x+", "l_x-", "l_y+", "l_y-", "r_x+", "r_x-", "r_y+", "r_y-" }; old_analog_dpad_mode[i] = settings->uints.input_analog_dpad_mode[i]; - old_libretro_device[i] = settings->uints.input_libretro_device[i]; + old_libretro_device[i] = settings->uints.input_libretro_device[i]; s1[0] = '\0'; s2[0] = '\0'; @@ -243,19 +243,16 @@ bool input_remapping_save_file(const char *path) return ret; } -bool input_remapping_remove_file(const char *path) +bool input_remapping_remove_file(const char *path, + const char *dir_input_remapping) { bool ret = false; size_t path_size = PATH_MAX_LENGTH * sizeof(char); char *buf = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); char *remap_file = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - settings_t *settings = config_get_ptr(); - - buf[0] = remap_file[0] = '\0'; - - fill_pathname_join(buf, settings->paths.directory_input_remapping, - path, path_size); + buf[0] = remap_file[0] = '\0'; + fill_pathname_join(buf, dir_input_remapping, path, path_size); fill_pathname_noext(remap_file, buf, ".rmp", path_size); ret = filestream_delete(remap_file) == 0 ? true : false; diff --git a/input/input_remapping.h b/input/input_remapping.h index 65b546f2ff..5a044edee7 100644 --- a/input/input_remapping.h +++ b/input/input_remapping.h @@ -45,7 +45,8 @@ bool input_remapping_load_file(void *data, const char *path); **/ bool input_remapping_save_file(const char *path); -bool input_remapping_remove_file(const char *path); +bool input_remapping_remove_file(const char *path, + const char *dir_input_remapping); void input_remapping_set_defaults(bool deinit); diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index f5a9884800..1f58f978ae 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3074,7 +3074,9 @@ static int generic_action_ok_remap_file_operation(const char *path, } else { - if (input_remapping_remove_file(file)) + if (input_remapping_remove_file(file, + settings->paths.directory_input_remapping + )) { #ifdef HAVE_CONFIGFILE switch (action_type) From 369348ebaf6783790ed9f44d27456bf3d1fe2192 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 14 Feb 2020 14:24:38 +0100 Subject: [PATCH 65/75] (Managers) Get rid of settings_t dependencies --- managers/cheat_manager.c | 33 +++++++++++++++------------------ managers/cheat_manager.h | 7 ++++--- menu/cbs/menu_cbs_ok.c | 9 +++++++-- menu/cbs/menu_cbs_right.c | 5 ++++- retroarch.c | 13 ++++++------- tasks/task_save.c | 4 +++- 6 files changed, 39 insertions(+), 32 deletions(-) diff --git a/managers/cheat_manager.c b/managers/cheat_manager.c index 211f2066f7..a828479f65 100644 --- a/managers/cheat_manager.c +++ b/managers/cheat_manager.c @@ -48,7 +48,6 @@ #include "../dynamic.h" #include "../core.h" #include "../verbosity.h" -#include "../configuration.h" cheat_manager_t cheat_manager_state; @@ -579,19 +578,16 @@ void cheat_manager_update(cheat_manager_t *handle, unsigned handle_idx) RARCH_LOG("%s\n", msg); } -void cheat_manager_toggle_index(unsigned i) +void cheat_manager_toggle_index(bool apply_cheats_after_toggle, + unsigned i) { - settings_t *settings = config_get_ptr(); if (!cheat_manager_state.cheats || cheat_manager_state.size == 0) return; cheat_manager_state.cheats[i].state = !cheat_manager_state.cheats[i].state; cheat_manager_update(&cheat_manager_state, i); - if (!settings) - return; - - if (settings->bools.apply_cheats_after_toggle) + if (apply_cheats_after_toggle) cheat_manager_apply_cheats(); } @@ -650,27 +646,24 @@ bool cheat_manager_get_code_state(unsigned i) static bool cheat_manager_get_game_specific_filename( char *s, size_t len, + const char *path_cheat_database, bool saving) { char s1[PATH_MAX_LENGTH]; struct retro_system_info system_info; - settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); const char *core_name = NULL; const char *game_name = NULL; s1[0] = '\0'; - if (!settings || !global) - return false; - - if (!core_get_system_info(&system_info)) + if (!global || !core_get_system_info(&system_info)) return false; core_name = system_info.library_name; game_name = path_basename(global->name.cheatfile); - if (string_is_empty(settings->paths.path_cheat_database) || + if (string_is_empty(path_cheat_database) || string_is_empty(core_name) || string_is_empty(game_name)) return false; @@ -678,7 +671,7 @@ static bool cheat_manager_get_game_specific_filename( s[0] = '\0'; fill_pathname_join(s1, - settings->paths.path_cheat_database, core_name, + path_cheat_database, core_name, sizeof(s1)); if (saving) @@ -693,24 +686,28 @@ static bool cheat_manager_get_game_specific_filename( return true; } -void cheat_manager_load_game_specific_cheats(void) +void cheat_manager_load_game_specific_cheats(const char *path_cheat_database) { char cheat_file[PATH_MAX_LENGTH]; if (cheat_manager_get_game_specific_filename( - cheat_file, sizeof(cheat_file), false)) + cheat_file, sizeof(cheat_file), + path_cheat_database, + false)) { RARCH_LOG("[Cheats]: Load game-specific cheatfile: %s\n", cheat_file); cheat_manager_load(cheat_file, true); } } -void cheat_manager_save_game_specific_cheats(void) +void cheat_manager_save_game_specific_cheats(const char *path_cheat_database) { char cheat_file[PATH_MAX_LENGTH]; if (cheat_manager_get_game_specific_filename( - cheat_file, sizeof(cheat_file), true)) + cheat_file, sizeof(cheat_file), + path_cheat_database, + true)) { RARCH_LOG("[Cheats]: Save game-specific cheatfile: %s\n", cheat_file); cheat_manager_save(cheat_file, NULL, true); diff --git a/managers/cheat_manager.h b/managers/cheat_manager.h index c3bc5269bd..c999a68a08 100644 --- a/managers/cheat_manager.h +++ b/managers/cheat_manager.h @@ -217,7 +217,8 @@ void cheat_manager_apply_cheats(void); void cheat_manager_update(cheat_manager_t *handle, unsigned handle_idx); -void cheat_manager_toggle_index(unsigned i); +void cheat_manager_toggle_index(bool apply_cheats_after_toggle, + unsigned i); unsigned cheat_manager_get_buf_size(void); @@ -235,9 +236,9 @@ bool cheat_manager_copy_idx_to_working(unsigned idx); bool cheat_manager_copy_working_to_idx(unsigned idx); -void cheat_manager_load_game_specific_cheats(void); +void cheat_manager_load_game_specific_cheats(const char *path_cheat_database); -void cheat_manager_save_game_specific_cheats(void); +void cheat_manager_save_game_specific_cheats(const char *path_cheat_database); int cheat_manager_initialize_memory(rarch_setting_t *setting, bool wraparound); diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 1f58f978ae..ed108ee2c9 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3469,9 +3469,14 @@ int action_ok_core_option_dropdown_list(const char *path, static int action_ok_cheat_reload_cheats(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - bool refresh = false ; + bool refresh = false; + settings_t *settings = config_get_ptr(); + cheat_manager_realloc(0, CHEAT_HANDLER_TYPE_EMU); - cheat_manager_load_game_specific_cheats(); + + cheat_manager_load_game_specific_cheats( + settings->paths.path_cheat_database); + menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL); return 0 ; diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index a19b556dcb..c7c9bcbdcb 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -104,7 +104,10 @@ int shader_action_preset_parameter_right(unsigned type, const char *label, bool int generic_action_cheat_toggle(size_t idx, unsigned type, const char *label, bool wraparound) { - cheat_manager_toggle_index((unsigned)idx); + settings_t *settings = config_get_ptr(); + cheat_manager_toggle_index( + settings->bools.apply_cheats_after_toggle, + (unsigned)idx); return 0; } diff --git a/retroarch.c b/retroarch.c index ac4af9421c..2f9b1473ec 100644 --- a/retroarch.c +++ b/retroarch.c @@ -5584,7 +5584,8 @@ static void command_event_deinit_core(bool reinit) static void command_event_init_cheats(void) { - bool allow_cheats = true; + settings_t *settings = configuration_settings; + bool allow_cheats = true; #ifdef HAVE_NETWORKING allow_cheats &= !netplay_driver_ctl( @@ -5596,13 +5597,11 @@ static void command_event_init_cheats(void) return; cheat_manager_alloc_if_empty(); - cheat_manager_load_game_specific_cheats(); + cheat_manager_load_game_specific_cheats( + settings->paths.path_cheat_database); - { - settings_t *settings = configuration_settings; - if (settings && settings->bools.apply_cheats_after_load) - cheat_manager_apply_cheats(); - } + if (settings->bools.apply_cheats_after_load) + cheat_manager_apply_cheats(); } static void command_event_load_auto_state(void) diff --git a/tasks/task_save.c b/tasks/task_save.c index 773b0aea3f..af5e83bc73 100644 --- a/tasks/task_save.c +++ b/tasks/task_save.c @@ -1556,8 +1556,10 @@ bool content_save_ram_file(unsigned slot) bool event_save_files(bool is_sram_used) { unsigned i; + settings_t *settings = config_get_ptr(); - cheat_manager_save_game_specific_cheats(); + cheat_manager_save_game_specific_cheats( + settings->paths.path_cheat_database); if (!task_save_files || !is_sram_used) return false; From 2be5ffe4e999757ba89a87b0012d1441ec78af77 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 14 Feb 2020 14:31:02 +0100 Subject: [PATCH 66/75] Improve ifdef - should be compiled in only if HAVE_OZONE is defined --- runtime_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime_file.c b/runtime_file.c index d6af1644f5..f6610fa9fa 100644 --- a/runtime_file.c +++ b/runtime_file.c @@ -1013,7 +1013,7 @@ void runtime_update_playlist(playlist_t *playlist, size_t idx) free(runtime_log); } -#ifdef HAVE_MENU +#if defined(HAVE_MENU) && defined(HAVE_OZONE) /* Ozone requires runtime/last played strings to be * populated even when no runtime is recorded */ if (string_is_equal(settings->arrays.menu_driver, "ozone")) From 789db436bbb98be2921561a8d465d92222022729 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 14 Feb 2020 14:38:26 +0100 Subject: [PATCH 67/75] (conmanctl) Cleanups --- wifi/drivers/connmanctl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wifi/drivers/connmanctl.c b/wifi/drivers/connmanctl.c index 16c02ce03f..43f8e40814 100644 --- a/wifi/drivers/connmanctl.c +++ b/wifi/drivers/connmanctl.c @@ -252,6 +252,7 @@ static bool connmanctl_ssid_is_online(unsigned i) static bool connmanctl_connect_ssid(unsigned i, const char* passphrase) { + unsigned i; char ln[512] = {0}; char name[64] = {0}; char service[128] = {0}; @@ -279,7 +280,7 @@ static bool connmanctl_connect_ssid(unsigned i, const char* passphrase) return false; } - for (int i = 0; i < list->size-1; i++) + for (i = 0; i < list->size-1; i++) { strlcat(name, list->elems[i].data, sizeof(name)); strlcat(name, " ", sizeof(name)); @@ -301,7 +302,7 @@ static bool connmanctl_connect_ssid(unsigned i, const char* passphrase) fprintf(settings_file, "Name=%s\n", name); fprintf(settings_file, "SSID="); - for (int i=0; i < strlen(name); i++) + for (i = 0; i < strlen(name); i++) fprintf(settings_file, "%02x", (unsigned int) name[i]); fprintf(settings_file, "\n"); From 3b977c8747c770441b3840e629b89934e1da890a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 14 Feb 2020 16:32:31 +0100 Subject: [PATCH 68/75] Cleanups --- retroarch.c | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/retroarch.c b/retroarch.c index 2f9b1473ec..78f9345138 100644 --- a/retroarch.c +++ b/retroarch.c @@ -11950,30 +11950,34 @@ static bool recording_init(void) strlcpy(output, global->record.path, sizeof(output)); else { + const char *stream_url = settings->paths.path_stream_url; + unsigned video_record_quality = settings->uints.video_record_quality; + unsigned video_stream_port = settings->uints.video_stream_port; if (streaming_enable) - if (!string_is_empty(settings->paths.path_stream_url)) - strlcpy(output, settings->paths.path_stream_url, sizeof(output)); + if (!string_is_empty(stream_url)) + strlcpy(output, stream_url, sizeof(output)); else /* Fallback, stream locally to 127.0.0.1 */ - snprintf(output, sizeof(output), "udp://127.0.0.1:%u", settings->uints.video_stream_port); + snprintf(output, sizeof(output), "udp://127.0.0.1:%u", + video_stream_port); else { const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME)); - if (settings->uints.video_record_quality < RECORD_CONFIG_TYPE_RECORDING_WEBM_FAST) + if (video_record_quality < RECORD_CONFIG_TYPE_RECORDING_WEBM_FAST) { fill_str_dated_filename(buf, game_name, "mkv", sizeof(buf)); fill_pathname_join(output, global->record.output_dir, buf, sizeof(output)); } - else if (settings->uints.video_record_quality >= RECORD_CONFIG_TYPE_RECORDING_WEBM_FAST - && settings->uints.video_record_quality < RECORD_CONFIG_TYPE_RECORDING_GIF) + else if (video_record_quality >= RECORD_CONFIG_TYPE_RECORDING_WEBM_FAST + && video_record_quality < RECORD_CONFIG_TYPE_RECORDING_GIF) { fill_str_dated_filename(buf, game_name, "webm", sizeof(buf)); fill_pathname_join(output, global->record.output_dir, buf, sizeof(output)); } - else if (settings->uints.video_record_quality >= RECORD_CONFIG_TYPE_RECORDING_GIF - && settings->uints.video_record_quality < RECORD_CONFIG_TYPE_RECORDING_APNG) + else if (video_record_quality >= RECORD_CONFIG_TYPE_RECORDING_GIF + && video_record_quality < RECORD_CONFIG_TYPE_RECORDING_APNG) { fill_str_dated_filename(buf, game_name, "gif", sizeof(buf)); @@ -12489,15 +12493,16 @@ static bool runloop_check_movie_init(void) { char msg[16384], path[8192]; settings_t *settings = configuration_settings; + int state_slot = settings->ints.state_slot; msg[0] = path[0] = '\0'; configuration_set_uint(settings, settings->uints.rewind_granularity, 1); - if (settings->ints.state_slot > 0) + if (state_slot > 0) snprintf(path, sizeof(path), "%s%d.bsv", bsv_movie_state.movie_path, - settings->ints.state_slot); + state_slot); else { strlcpy(path, bsv_movie_state.movie_path, sizeof(path)); @@ -14487,14 +14492,14 @@ int16_t menu_input_read_mouse_hw(enum menu_input_mouse_hw_id id) NULL, 0, device, 0, type); } -static void menu_input_get_mouse_hw_state(menu_input_pointer_hw_state_t *hw_state) +static void menu_input_get_mouse_hw_state( + menu_input_pointer_hw_state_t *hw_state) { settings_t *settings = configuration_settings; static int16_t last_x = 0; static int16_t last_y = 0; static bool last_select_pressed = false; static bool last_cancel_pressed = false; - bool overlay_active = false; bool mouse_enabled = settings->bools.menu_mouse_enable; /* Note: RGUI requires special treatment, but we can't just * check settings->arrays.menu_driver because this may change @@ -14505,17 +14510,17 @@ static void menu_input_get_mouse_hw_state(menu_input_pointer_hw_state_t *hw_stat menu_handle_t *menu_data = menu_driver_get_ptr(); bool is_rgui = (menu_data && menu_data->driver_ctx && menu_data->driver_ctx->set_texture); +#ifdef HAVE_OVERLAY + /* Menu pointer controls are ignored when overlays are enabled. */ + bool overlay_active = settings->bools.input_overlay_enable && overlay_ptr && overlay_ptr->alive; + if (overlay_active) + mouse_enabled = false; +#endif /* Easiest to set inactive by default, and toggle * when input is detected */ hw_state->active = false; -#ifdef HAVE_OVERLAY - /* Menu pointer controls are ignored when overlays are enabled. */ - overlay_active = settings->bools.input_overlay_enable && overlay_ptr && overlay_ptr->alive; - if (overlay_active) - mouse_enabled = false; -#endif if (!mouse_enabled) { @@ -14602,7 +14607,8 @@ static void menu_input_get_mouse_hw_state(menu_input_pointer_hw_state_t *hw_stat hw_state->active = true; } -static void menu_input_get_touchscreen_hw_state(menu_input_pointer_hw_state_t *hw_state) +static void menu_input_get_touchscreen_hw_state( + menu_input_pointer_hw_state_t *hw_state) { rarch_joypad_info_t joypad_info; int pointer_x, pointer_y; @@ -14627,7 +14633,7 @@ static void menu_input_get_touchscreen_hw_state(menu_input_pointer_hw_state_t *h /* Easiest to set inactive by default, and toggle * when input is detected */ - hw_state->active = false; + hw_state->active = false; /* Touch screens don't have mouse wheels, so these * are always disabled */ @@ -14638,7 +14644,8 @@ static void menu_input_get_touchscreen_hw_state(menu_input_pointer_hw_state_t *h #ifdef HAVE_OVERLAY /* Menu pointer controls are ignored when overlays are enabled. */ - overlay_active = settings->bools.input_overlay_enable && overlay_ptr && overlay_ptr->alive; + overlay_active = settings->bools.input_overlay_enable + && overlay_ptr && overlay_ptr->alive; if (overlay_active) pointer_enabled = false; #endif From 0278e789893d086d770484a4b8a32b2565574715 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 14 Feb 2020 16:46:09 +0100 Subject: [PATCH 69/75] Replace strcmp with string_is_equal --- retroarch.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/retroarch.c b/retroarch.c index 78f9345138..da1e8c11fd 100644 --- a/retroarch.c +++ b/retroarch.c @@ -3851,26 +3851,26 @@ static bool command_get_config_param(const char* arg) const char* value = "unsupported"; settings_t* settings = configuration_settings; - if (!strcmp(arg, "video_fullscreen")) + if (string_is_equal(arg, "video_fullscreen")) { if (configuration_settings->bools.video_fullscreen) value = "true"; else value = "false"; } - else if (!strcmp(arg, "savefile_directory")) + else if (string_is_equal(arg, "savefile_directory")) value = dir_get(RARCH_DIR_SAVEFILE); - else if (!strcmp(arg, "savestate_directory")) + else if (string_is_equal(arg, "savestate_directory")) value = dir_get(RARCH_DIR_SAVESTATE); - else if (!strcmp(arg, "runtime_log_directory")) + else if (string_is_equal(arg, "runtime_log_directory")) value = settings->paths.directory_runtime_log; - else if (!strcmp(arg, "log_dir")) + else if (string_is_equal(arg, "log_dir")) value = settings->paths.log_dir; - else if (!strcmp(arg, "cache_directory")) + else if (string_is_equal(arg, "cache_directory")) value = settings->paths.directory_cache; - else if (!strcmp(arg, "system_directory")) + else if (string_is_equal(arg, "system_directory")) value = settings->paths.directory_system; - else if (!strcmp(arg, "netplay_nickname")) + else if (string_is_equal(arg, "netplay_nickname")) value = settings->paths.username; /* TODO: query any string */ @@ -9790,11 +9790,12 @@ static bool rarch_environment_cb(unsigned cmd, void *data) if (!settings->bools.driver_switch_enable) return false; - else if (!strcmp(video_driver_name, "glcore")) + + if (string_is_equal(video_driver_name, "glcore")) *cb = RETRO_HW_CONTEXT_OPENGL_CORE; - else if (!strcmp(video_driver_name, "gl")) + else if (string_is_equal(video_driver_name, "gl")) *cb = RETRO_HW_CONTEXT_OPENGL; - else if (!strcmp(video_driver_name, "vulkan")) + else if (string_is_equal(video_driver_name, "vulkan")) *cb = RETRO_HW_CONTEXT_VULKAN; else if (!strncmp(video_driver_name, "d3d", 3)) *cb = RETRO_HW_CONTEXT_DIRECT3D; @@ -16512,13 +16513,12 @@ int16_t input_joypad_analog(const input_device_driver_t *drv, uint32_t y_axis_plus = (bind_y_plus->joyaxis == AXIS_NONE) ? joypad_info.auto_binds[ident_y_plus].joyaxis : bind_y_plus->joyaxis; - float x = 0.0f; - float y = 0.0f; - /* normalized magnitude for radial scaled analog deadzone */ - x = drv->axis(joypad_info.joy_idx, x_axis_plus) + float x = drv->axis( + joypad_info.joy_idx, x_axis_plus) + drv->axis(joypad_info.joy_idx, x_axis_minus); - y = drv->axis(joypad_info.joy_idx, y_axis_plus) + float y = drv->axis( + joypad_info.joy_idx, y_axis_plus) + drv->axis(joypad_info.joy_idx, y_axis_minus); normal_mag = (1.0f / 0x7fff) * sqrt(x * x + y * y); } From 0ea75894c1b4f15cc7bc7aed1c162c217ab5e096 Mon Sep 17 00:00:00 2001 From: orbea Date: Fri, 14 Feb 2020 07:38:51 -0800 Subject: [PATCH 70/75] Fix a segfault when starting the qt menu with the null menu driver. --- menu/menu_driver.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index cfa5f9d14e..f480c8af17 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -1340,6 +1340,8 @@ bool menu_entries_append_enum(file_list_t *list, const char *path, size_t idx; const char *menu_path = NULL; menu_file_list_cbs_t *cbs = NULL; + settings_t *settings = config_get_ptr(); + if (!list || !label) return false; @@ -1377,7 +1379,8 @@ bool menu_entries_append_enum(file_list_t *list, const char *path, && enum_idx != MENU_ENUM_LABEL_RDB_ENTRY) cbs->setting = menu_setting_find_enum(enum_idx); - menu_cbs_init(list, cbs, path, label, type, idx); + if (!string_is_equal(settings->arrays.menu_driver, "null")) + menu_cbs_init(list, cbs, path, label, type, idx); return true; } From c4f69b1eb775546cfe61d2ae9cf8fa0a4964ebcf Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 14 Feb 2020 17:43:00 +0100 Subject: [PATCH 71/75] (PS2) Cleanups --- ps2/compat_files/compat_ctype.c | 205 ++++++++++++++++---------------- ps2/compat_files/fileXio_cdvd.c | 135 +++++++++++---------- ps2/compat_files/time.c | 18 +-- 3 files changed, 181 insertions(+), 177 deletions(-) diff --git a/ps2/compat_files/compat_ctype.c b/ps2/compat_files/compat_ctype.c index d7b91d0f17..1766833c05 100644 --- a/ps2/compat_files/compat_ctype.c +++ b/ps2/compat_files/compat_ctype.c @@ -33,75 +33,76 @@ int islower(int c) if ((c < 'a') || (c > 'z')) return 0; - // passed both criteria, so it - // is a lower case alpha char + /* passed both criteria, so it + * is a lower case alpha char */ return 1; } int tolower(int ch) { - if(ch >= 'A' && ch <= 'Z') + if (ch >= 'A' && ch <= 'Z') return ('a' + ch - 'A'); return ch; } int toupper(int c) { - if (islower(c)) - c -= 32; + if (islower(c)) + c -= 32; - return c; + return c; } int memcmp(const void *s1, const void *s2, unsigned int length) { - const char *a = s1; - const char *b = s2; + const char *a = s1; + const char *b = s2; - while (length--) { - if (*a++ != *b++) - return 1; - } + while (length--) + { + if (*a++ != *b++) + return 1; + } - return 0; + return 0; } void * memcpy (void *dest, const void *src, size_t len) { - char *d = dest; - const char *s = src; - while (len--) - *d++ = *s++; - return dest; + char *d = dest; + const char *s = src; + while (len--) + *d++ = *s++; + return dest; } void * memset (void *dest, int val, size_t len) { - unsigned char *ptr = dest; - while (len-- > 0) - *ptr++ = val; - return dest; + unsigned char *ptr = dest; + while (len-- > 0) + *ptr++ = val; + return dest; } int sprintf (char *s, const char *format, ...) { - va_list arg; - int done; - va_start (arg, format); - done = vsprintf (s, format, arg); - va_end (arg); - return done; + va_list arg; + int done; + va_start (arg, format); + done = vsprintf (s, format, arg); + va_end (arg); + return done; } char * strcat(char *dest, const char *src) { - size_t i,j; - for (i = 0; dest[i] != '\0'; i++) - ; - for (j = 0; src[j] != '\0'; j++) - dest[i+j] = src[j]; - dest[i+j] = '\0'; - return dest; + size_t i,j; + for (i = 0; dest[i] != '\0'; i++) + ; + for (j = 0; src[j] != '\0'; j++) + dest[i+j] = src[j]; + dest[i+j] = '\0'; + return dest; } char *strchr(const char *string, int c) @@ -121,32 +122,32 @@ char *strchr(const char *string, int c) int strcmp(const char *s1, const char *s2) { - while (*s1 == *s2++) - if (*s1++ == 0) - return (0); - return (*(unsigned char *)s1 - *(unsigned char *)--s2); + while (*s1 == *s2++) + if (*s1++ == 0) + return (0); + return (*(unsigned char *)s1 - *(unsigned char *)--s2); } char * strcpy(char *to, const char *from) { - char *save = to; + char *save = to; - for (; (*to = *from) != '\0'; ++from, ++to); - return(save); + for (; (*to = *from) != '\0'; ++from, ++to); + return(save); } size_t strcspn(const char *s1, const char *s2) { - const char *p, *spanp; - char c, sc; + const char *p, *spanp; + char c, sc; - /* - * Stop as soon as we find any character from s2. Note that there - * must be a NUL in s2; it suffices to stop when we find that, too. - */ - for (p = s1;;) + /* + * Stop as soon as we find any character from s2. Note that there + * must be a NUL in s2; it suffices to stop when we find that, too. + */ + for (p = s1;;) { - c = *p++; + c = *p++; spanp = s2; do { @@ -154,16 +155,16 @@ size_t strcspn(const char *s1, const char *s2) return (p - 1 - s1); }while(sc != 0); } - /* NOTREACHED */ + /* NOTREACHED */ } size_t strlen(const char *str) { const char *s; - for (s = str; *s; ++s) - ; - return (s - str); + for (s = str; *s; ++s) + ; + return (s - str); } char * strncat(char *dst, const char *src, size_t n) @@ -206,7 +207,7 @@ char * strncpy(char *dst, const char *src, size_t n) { if (n != 0) { - char *d = dst; + char *d = dst; const char *s = src; do @@ -225,16 +226,16 @@ char * strncpy(char *dst, const char *src, size_t n) char * strpbrk(const char *s1, const char *s2) { - const char *scanp; - int c, sc; + const char *scanp; + int c, sc; - while ((c = *s1++) != 0) + while ((c = *s1++) != 0) { for (scanp = s2; (sc = *scanp++) != 0;) if (sc == c) return ((char *)(s1 - 1)); } - return (NULL); + return (NULL); } /* Do not link to strrchr() from libc */ @@ -388,46 +389,46 @@ char * strtok_r (char *s, const char *delim, char **save_ptr) unsigned long long strtoull(const char * __restrict nptr, char ** __restrict endptr, int base) { - char c; - unsigned long long acc; - unsigned long long cutoff; - int neg, any, cutlim; - /* - * See strtoq for comments as to the logic used. - */ - const char *s = nptr; + char c; + unsigned long long acc; + unsigned long long cutoff; + int neg, any, cutlim; + /* + * See strtoq for comments as to the logic used. + */ + const char *s = nptr; - do + do { - c = *s++; - }while(isspace((unsigned char)c)); - if (c == '-') + c = *s++; + }while(isspace((unsigned char)c)); + if (c == '-') { - neg = 1; - c = *s++; - } + neg = 1; + c = *s++; + } else { - neg = 0; - if (c == '+') - c = *s++; - } - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) + neg = 0; + if (c == '+') + c = *s++; + } + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == '0' ? 8 : 10; - acc = any = 0; - if (base < 2 || base > 36) - goto noconv; + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + acc = any = 0; + if (base < 2 || base > 36) + goto noconv; - cutoff = ULLONG_MAX / base; - cutlim = ULLONG_MAX % base; - for ( ; ; c = *s++) + cutoff = ULLONG_MAX / base; + cutlim = ULLONG_MAX % base; + for ( ; ; c = *s++) { if (c >= '0' && c <= '9') c -= '0'; @@ -448,21 +449,21 @@ unsigned long long strtoull(const char * __restrict nptr, acc += c; } } - if (any < 0) + if (any < 0) { - acc = ULLONG_MAX; - errno = ERANGE; - } + acc = ULLONG_MAX; + errno = ERANGE; + } else if (!any) { noconv: - errno = EINVAL; - } + errno = EINVAL; + } else if (neg) - acc = -acc; - if (endptr) - *endptr = (char *)(any ? s - 1 : nptr); - return (acc); + acc = -acc; + if (endptr) + *endptr = (char *)(any ? s - 1 : nptr); + return (acc); } float strtof(const char* str, char** endptr) diff --git a/ps2/compat_files/fileXio_cdvd.c b/ps2/compat_files/fileXio_cdvd.c index e82b66f10d..66ca035ad2 100644 --- a/ps2/compat_files/fileXio_cdvd.c +++ b/ps2/compat_files/fileXio_cdvd.c @@ -19,29 +19,31 @@ static int comp_entries_by_filename(const void *elem1, const void *elem2) return strcmp(((entries*)elem1)->filename, ((entries*)elem2)->filename); } -static int ps2_cdDiscValid(void) //returns 1 if disc valid, else returns 0 +/* returns 1 if disc valid, else returns 0 */ +static int ps2_cdDiscValid(void) { int cdmode = sceCdGetDiskType(); - switch (cdmode) { - case SCECdPSCD: - case SCECdPSCDDA: - case SCECdPS2CD: - case SCECdPS2CDDA: - case SCECdPS2DVD: - case SCECdCDDA: - case SCECdDVDV: - return 1; - case SCECdNODISC: - case SCECdDETCT: - case SCECdDETCTCD: - case SCECdDETCTDVDS: - case SCECdDETCTDVDD: - case SCECdUNKNOWN: - case SCECdIllegalMedia: - default: - return 0; - } + switch (cdmode) + { + case SCECdPSCD: + case SCECdPSCDDA: + case SCECdPS2CD: + case SCECdPS2CDDA: + case SCECdPS2DVD: + case SCECdCDDA: + case SCECdDVDV: + return 1; + case SCECdNODISC: + case SCECdDETCT: + case SCECdDETCTCD: + case SCECdDETCTDVDS: + case SCECdDETCTDVDD: + case SCECdUNKNOWN: + case SCECdIllegalMedia: + default: + return 0; + } } static u64 cd_Timer(void) @@ -60,15 +62,18 @@ static int prepareCDVD(void) u64 wait_start; int cdmode = sceCdGetDiskType(); - if (sceCdGetDiskType() <= SCECdUNKNOWN) { + if (sceCdGetDiskType() <= SCECdUNKNOWN) + { wait_start = cd_Timer(); - while ((cd_Timer() < wait_start + 500) && !ps2_cdDiscValid()) { + while ((cd_Timer() < wait_start + 500) && !ps2_cdDiscValid()) + { if (cdmode == SCECdNODISC) return 0; } if (cdmode == SCECdNODISC) return 0; - if ((cdmode < SCECdPSCD) || (cdmode > SCECdPS2DVD)) { + if ((cdmode < SCECdPSCD) || (cdmode > SCECdPS2DVD)) + { ps2_cdStop(); return 0; } @@ -86,50 +91,55 @@ static int listcdvd(const char *path, entries *FileEntry) int first_file_index; strcpy(dir, &path[5]); - // Directories first... + + /* Directories first... */ CDVD_FlushCache(); - n = CDVD_GetDir(dir, NULL, CDVD_GET_DIRS_ONLY, TocEntryList, FILEENTRY_SIZE, dir); + n = CDVD_GetDir(dir, NULL, CDVD_GET_DIRS_ONLY, + TocEntryList, FILEENTRY_SIZE, dir); - for (i = 0; i < n; i++) { + for (i = 0; i < n; i++) + { + /* Skip pseudopaths "." and ".." */ if (TocEntryList[i].fileProperties & 0x02 && (!strcmp( - TocEntryList[i].filename, ".") || !strcmp( + TocEntryList[i].filename, ".") || !strcmp( TocEntryList[i].filename, ".."))) - continue; // Skip pseudopaths "." and ".." + continue; FileEntry[t].dircheck = 1; strcpy(FileEntry[t].filename, TocEntryList[i].filename); t++; - if (t >= FILEENTRY_SIZE - 2) { + if (t >= FILEENTRY_SIZE - 2) break; - } } qsort(FileEntry, t, sizeof(entries), comp_entries_by_filename); first_file_index = t; - // Now files only + /* Now files only */ CDVD_FlushCache(); n = CDVD_GetDir(dir, NULL, CDVD_GET_FILES_ONLY, TocEntryList, FILEENTRY_SIZE, dir); - for (i = 0; i < n; i++) { + for (i = 0; i < n; i++) + { + /* Skip pseudopaths "." and ".." */ if (TocEntryList[i].fileProperties & 0x02 && (!strcmp( - TocEntryList[i].filename, ".") || !strcmp( + TocEntryList[i].filename, ".") || !strcmp( TocEntryList[i].filename, ".."))) - continue; // Skip pseudopaths "." and ".." + continue; FileEntry[t].dircheck = 0; strcpy(FileEntry[t].filename, TocEntryList[i].filename); t++; - if (t >= FILEENTRY_SIZE - 2) { + if (t >= FILEENTRY_SIZE - 2) break; - } } - qsort(FileEntry + first_file_index, t - first_file_index, sizeof(entries), comp_entries_by_filename); + qsort(FileEntry + first_file_index, t - first_file_index, + sizeof(entries), comp_entries_by_filename); return t; } @@ -138,15 +148,17 @@ static int fileXioCDDread(int fd, iox_dirent_t *dirent) { DescriptorTranslation *descriptor = __ps2_fd_grab(fd); - if (descriptor && descriptor->current_folder_position < descriptor->items) { + if (descriptor && descriptor->current_folder_position < descriptor->items) + { strcpy(dirent->name, descriptor->FileEntry[descriptor->current_folder_position].filename); - if (descriptor->FileEntry[descriptor->current_folder_position].dircheck) { + if (descriptor->FileEntry[descriptor->current_folder_position].dircheck) dirent->stat.mode = FIO_S_IFDIR; - } else { + else dirent->stat.mode = FIO_S_IFREG; - } descriptor->current_folder_position++; - } else { + } + else + { descriptor->current_folder_position = 0; return 0; } @@ -156,47 +168,38 @@ static int fileXioCDDread(int fd, iox_dirent_t *dirent) static int fileXioCDDopen(const char *name) { - int fd = -1; - if (prepareCDVD()){ - fd = __ps2_acquire_descriptor(); + if (prepareCDVD()) + { + int fd = __ps2_acquire_descriptor(); DescriptorTranslation *descriptor = __ps2_fd_grab(fd); descriptor->current_folder_position = 0; descriptor->items = listcdvd(name, descriptor->FileEntry); + return fd; } - return fd; + return -1; } int ps2fileXioDopen(const char *name) { enum BootDeviceIDs deviceID = getBootDeviceID((char *)name); - int fd = -1; - if (deviceID == BOOT_DEVICE_CDFS) { - fd = fileXioCDDopen(name); - } else { - fd = fileXioDopen(name); - } - - return fd; + if (deviceID == BOOT_DEVICE_CDFS) + return fileXioCDDopen(name); + return fileXioDopen(name); } int ps2fileXioDread(int fd, iox_dirent_t *dirent) { - if (is_fd_valid(fd)) { + if (is_fd_valid(fd)) return fileXioCDDread(fd, dirent); - } else { - return fileXioDread(fd, dirent); - } + return fileXioDread(fd, dirent); } int ps2fileXioDclose(int fd) { - int ret = -19; - if (is_fd_valid(fd)) { - ret = __ps2_release_descriptor(fd); - } else if (fd > 0) { - ret = fileXioDclose(fd); - } - - return ret; + if (is_fd_valid(fd)) + return __ps2_release_descriptor(fd); + else if (fd > 0) + return fileXioDclose(fd); + return -19; } diff --git a/ps2/compat_files/time.c b/ps2/compat_files/time.c index 47518ff614..5bdf1642bf 100644 --- a/ps2/compat_files/time.c +++ b/ps2/compat_files/time.c @@ -49,22 +49,22 @@ static time_t _gmtotime_t ( int sc ) { - int passed_years; - long passed_days; - long passed_seconds_current_day; time_t seconds_from_1970 = -1; if ((yr >= MIN_SUPPORTED_YEAR) || (yr <= MAX_SUPPORTED_YEAR)) { - passed_years = (long)yr - MIN_SUPPORTED_YEAR; /* Years after 1970 */ + long passed_seconds_current_day; + int passed_years = (long)yr - MIN_SUPPORTED_YEAR; /* Years after 1970 */ /* Calculate days for these years */ - passed_days = passed_years * DAYS_YEAR; - passed_days += (passed_years >> 2) * (DAYS_YEAR + 1); /* passed leap years */ - passed_days += dy + _days[mo - 1]; /* passed days in the year */ - if ( !(yr & 3) && (mo > 2) ) + long passed_days = passed_years * DAYS_YEAR; + passed_days += (passed_years >> 2) * (DAYS_YEAR + 1); /* passed leap years */ + passed_days += dy + _days[mo - 1]; /* passed days in the year */ + + if (!(yr & 3) && (mo > 2)) passed_days++; /* if current year, is a leap year */ + passed_seconds_current_day = (((hr * MINS_HOUR) + mn) * SECS_MIN) + sc; - seconds_from_1970 = (passed_days * HOURS_DAY * MINS_HOUR * SECS_MIN) + passed_seconds_current_day; + seconds_from_1970 = (passed_days * HOURS_DAY * MINS_HOUR * SECS_MIN) + passed_seconds_current_day; } return seconds_from_1970; From afb2a4abbfb5b84ed07047e04dd22f08a57e286b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 14 Feb 2020 17:43:58 +0100 Subject: [PATCH 72/75] (Wii) Style nits --- wii/app_booter/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wii/app_booter/main.c b/wii/app_booter/main.c index 571a377b17..a4efadb1fe 100644 --- a/wii/app_booter/main.c +++ b/wii/app_booter/main.c @@ -73,10 +73,10 @@ static uint32_t load_elf_image (void *elfstart) Elf32_Phdr *phdrs = NULL; Elf32_Ehdr *ehdr = (Elf32_Ehdr*) elfstart; - if(ehdr->e_phoff == 0 || ehdr->e_phnum == 0) + if (ehdr->e_phoff == 0 || ehdr->e_phnum == 0) return 0; - if(ehdr->e_phentsize != sizeof(Elf32_Phdr)) + if (ehdr->e_phentsize != sizeof(Elf32_Phdr)) return 0; phdrs = (Elf32_Phdr*)(elfstart + ehdr->e_phoff); @@ -85,16 +85,16 @@ static uint32_t load_elf_image (void *elfstart) { uint8_t *image; - if(phdrs[i].p_type != PT_LOAD) + if (phdrs[i].p_type != PT_LOAD) continue; phdrs[i].p_paddr &= 0x3FFFFFFF; phdrs[i].p_paddr |= 0x80000000; - if(phdrs[i].p_filesz > phdrs[i].p_memsz) + if (phdrs[i].p_filesz > phdrs[i].p_memsz) return 0; - if(!phdrs[i].p_filesz) + if (!phdrs[i].p_filesz) continue; image = (uint8_t*)(elfstart + phdrs[i].p_offset); @@ -111,7 +111,7 @@ static uint32_t load_dol_image(const void *dolstart) uint32_t i; dolheader *dolfile = NULL; - if(!dolstart) + if (!dolstart) return 0; dolfile = (dolheader *) dolstart; From 23c9b86f642e0adf80ab70e49dce51134ac230b5 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Fri, 14 Feb 2020 17:10:39 +0000 Subject: [PATCH 73/75] (Menu Widgets) Enable scaling of widgets independently from menu scale --- config.def.h | 6 + configuration.c | 4 +- configuration.h | 2 + intl/msg_hash_lbl.h | 2 + intl/msg_hash_us.h | 12 +- menu/cbs/menu_cbs_sublabel.c | 17 +- menu/drivers/ozone/ozone.c | 17 +- menu/drivers/ozone/ozone.h | 3 +- menu/drivers/ozone/ozone_display.c | 6 +- menu/drivers/ozone/ozone_entries.c | 6 +- menu/drivers/ozone/ozone_sidebar.c | 2 +- menu/menu_animation.c | 44 +-- menu/menu_animation.h | 1 - menu/menu_displaylist.c | 11 + menu/menu_driver.c | 522 ++++++++++++++++++++--------- menu/menu_driver.h | 17 + menu/menu_setting.c | 59 +++- menu/widgets/menu_widgets.c | 58 ++-- menu/widgets/menu_widgets.h | 2 +- msg_hash.h | 1 + retroarch.c | 4 +- 21 files changed, 531 insertions(+), 265 deletions(-) diff --git a/config.def.h b/config.def.h index 02a5a830de..b7033fa76a 100644 --- a/config.def.h +++ b/config.def.h @@ -970,6 +970,12 @@ static const unsigned playlist_entry_remove_enable = PLAYLIST_ENTRY_REMOVE_ENABL /* Default scale factor for non-frambuffer-based menu * drivers and menu widgets */ #define DEFAULT_MENU_SCALE_FACTOR 1.0f +/* Specifies whether menu widgets should be scaled + * automatically using the default menu scale factor */ +#define DEFAULT_MENU_WIDGET_SCALE_AUTO true +/* Default scale factor for menu widgets when widget + * auto scaling is disabled */ +#define DEFAULT_MENU_WIDGET_SCALE_FACTOR 1.0f /* Log level for the frontend */ #define DEFAULT_FRONTEND_LOG_LEVEL 1 diff --git a/configuration.c b/configuration.c index d604443737..419bceb1a3 100644 --- a/configuration.c +++ b/configuration.c @@ -1423,7 +1423,8 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, SETTING_BOOL("keyboard_gamepad_enable", &settings->bools.input_keyboard_gamepad_enable, true, true, false); SETTING_BOOL("core_set_supports_no_game_enable", &settings->bools.set_supports_no_game_enable, true, true, false); SETTING_BOOL("audio_enable", &settings->bools.audio_enable, true, DEFAULT_AUDIO_ENABLE, false); - SETTING_BOOL("menu_enable_widgets", &settings->bools.menu_enable_widgets, true, DEFAULT_MENU_ENABLE_WIDGETS, false); + SETTING_BOOL("menu_enable_widgets", &settings->bools.menu_enable_widgets, true, DEFAULT_MENU_ENABLE_WIDGETS, false); + SETTING_BOOL("menu_widget_scale_auto", &settings->bools.menu_widget_scale_auto, true, DEFAULT_MENU_WIDGET_SCALE_AUTO, false); SETTING_BOOL("audio_enable_menu", &settings->bools.audio_enable_menu, true, audio_enable_menu, false); SETTING_BOOL("audio_enable_menu_ok", &settings->bools.audio_enable_menu_ok, true, audio_enable_menu_ok, false); SETTING_BOOL("audio_enable_menu_cancel", &settings->bools.audio_enable_menu_cancel, true, audio_enable_menu_cancel, false); @@ -1699,6 +1700,7 @@ static struct config_float_setting *populate_settings_float(settings_t *settings #endif #ifdef HAVE_MENU SETTING_FLOAT("menu_scale_factor", &settings->floats.menu_scale_factor, true, DEFAULT_MENU_SCALE_FACTOR, false); + SETTING_FLOAT("menu_widget_scale_factor", &settings->floats.menu_widget_scale_factor, true, DEFAULT_MENU_WIDGET_SCALE_FACTOR, false); SETTING_FLOAT("menu_wallpaper_opacity", &settings->floats.menu_wallpaper_opacity, true, menu_wallpaper_opacity, false); SETTING_FLOAT("menu_framebuffer_opacity", &settings->floats.menu_framebuffer_opacity, true, menu_framebuffer_opacity, false); SETTING_FLOAT("menu_footer_opacity", &settings->floats.menu_footer_opacity, true, menu_footer_opacity, false); diff --git a/configuration.h b/configuration.h index b425e1c292..07353ce4d7 100644 --- a/configuration.h +++ b/configuration.h @@ -151,6 +151,7 @@ typedef struct settings /* Menu */ bool filter_by_current_core; bool menu_enable_widgets; + bool menu_widget_scale_auto; bool menu_show_start_screen; bool menu_pause_libretro; bool menu_savestate_resume; @@ -405,6 +406,7 @@ typedef struct settings float video_msg_bgcolor_opacity; float menu_scale_factor; + float menu_widget_scale_factor; float menu_wallpaper_opacity; float menu_framebuffer_opacity; float menu_footer_opacity; diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index b56bede3ca..2573de4f4a 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -502,6 +502,8 @@ MSG_HASH(MENU_ENUM_LABEL_CONTENT_DIR, "content_directory") MSG_HASH(MENU_ENUM_LABEL_MENU_SCALE_FACTOR, "menu_scale_factor") +MSG_HASH(MENU_ENUM_LABEL_MENU_WIDGET_SCALE_AUTO, + "menu_widget_scale_auto") MSG_HASH(MENU_ENUM_LABEL_MENU_WIDGET_SCALE_FACTOR, "menu_widget_scale_factor") MSG_HASH(MENU_ENUM_LABEL_DRIVER_SETTINGS, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 2e11fd698d..29749228e2 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -916,13 +916,21 @@ MSG_HASH( MENU_ENUM_SUBLABEL_MENU_SCALE_FACTOR, "Applies a global scaling factor when drawing the menu. Can be used to increase or decrease the size of the user interface." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_MENU_WIDGET_SCALE_AUTO, + "Auto Scale Menu Widgets" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_MENU_WIDGET_SCALE_AUTO, + "Automatically resize decorated notifications, indicators and controls based on current menu scale." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_MENU_WIDGET_SCALE_FACTOR, - "Menu Widget Scale Factor" + "Menu Widget Scale Override" ) MSG_HASH( MENU_ENUM_SUBLABEL_MENU_WIDGET_SCALE_FACTOR, - "Applies a scaling factor when drawing menu widgets. Can be used to increase or decrease the size of decorated notifications, indicators and controls." + "Applies a manual scaling factor override when drawing menu widgets. Only applies when 'Auto Scale Menu Widgets' is disabled. Can be used to increase or decrease the size of decorated notifications, indicators and controls independently from the menu itself." ) MSG_HASH( MENU_ENUM_LABEL_VALUE_DRIVER_SETTINGS, diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index a2c5935906..6efefca82a 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -523,6 +523,7 @@ default_sublabel_macro(action_bind_sublabel_ozone_truncate_playlist_name, default_sublabel_macro(action_bind_sublabel_ozone_scroll_content_metadata, MENU_ENUM_SUBLABEL_OZONE_SCROLL_CONTENT_METADATA) default_sublabel_macro(action_bind_sublabel_menu_use_preferred_system_color_theme, MENU_ENUM_SUBLABEL_MENU_USE_PREFERRED_SYSTEM_COLOR_THEME) default_sublabel_macro(action_bind_sublabel_menu_scale_factor, MENU_ENUM_SUBLABEL_MENU_SCALE_FACTOR) +default_sublabel_macro(action_bind_sublabel_menu_widget_scale_auto, MENU_ENUM_SUBLABEL_MENU_WIDGET_SCALE_AUTO) default_sublabel_macro(action_bind_sublabel_menu_widget_scale_factor, MENU_ENUM_SUBLABEL_MENU_WIDGET_SCALE_FACTOR) default_sublabel_macro(action_bind_sublabel_menu_wallpaper_opacity, MENU_ENUM_SUBLABEL_MENU_WALLPAPER_OPACITY) default_sublabel_macro(action_bind_sublabel_menu_framebuffer_opacity, MENU_ENUM_SUBLABEL_MENU_FRAMEBUFFER_OPACITY) @@ -1741,15 +1742,13 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_xmb_animation_opening_main_menu); break; case MENU_ENUM_LABEL_MENU_SCALE_FACTOR: - settings = config_get_ptr(); - if (string_is_equal(settings->arrays.menu_driver, "rgui")) - { - BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_widget_scale_factor); - } - else - { - BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_scale_factor); - } + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_scale_factor); + break; + case MENU_ENUM_LABEL_MENU_WIDGET_SCALE_AUTO: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_widget_scale_auto); + break; + case MENU_ENUM_LABEL_MENU_WIDGET_SCALE_FACTOR: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_widget_scale_factor); break; case MENU_ENUM_LABEL_MENU_WALLPAPER_OPACITY: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_wallpaper_opacity); diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index d5174e5168..fc13f24c05 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -460,16 +460,7 @@ static void ozone_set_layout(ozone_handle_t *ozone, bool is_threaded) if (!ozone) return; - /* Due to the 'multi-column' menu layout - * (i.e. sidebars + entries), actual scale factor - * must be capped to a sensible upper limit - * > Normal left hand sidebar width must be no - * more than 1/3 of the total screen width, - * otherwise menu becomes unusable */ - ozone->capped_scale_factor = - (SIDEBAR_WIDTH * ozone->last_scale_factor) > (ozone->last_width * 0.3333333f) ? - ((float)ozone->last_width * 0.3333333f / (float)SIDEBAR_WIDTH) : ozone->last_scale_factor; - scale_factor = ozone->capped_scale_factor; + scale_factor = ozone->last_scale_factor; /* Calculate dimensions */ ozone->dimensions.header_height = HEADER_HEIGHT * scale_factor; @@ -1146,7 +1137,7 @@ static void ozone_draw_header(ozone_handle_t *ozone, video_frame_info_t *video_i settings_t *settings = config_get_ptr(); unsigned timedate_offset = 0; bool use_smooth_ticker = settings->bools.menu_ticker_smooth; - float scale_factor = ozone->capped_scale_factor; + float scale_factor = ozone->last_scale_factor; unsigned logo_icon_size = 60 * scale_factor; unsigned status_icon_size = 92 * scale_factor; unsigned seperator_margin = 30 * scale_factor; @@ -1290,7 +1281,7 @@ static void ozone_draw_header(ozone_handle_t *ozone, video_frame_info_t *video_i static void ozone_draw_footer(ozone_handle_t *ozone, video_frame_info_t *video_info, settings_t *settings) { - float scale_factor = ozone->capped_scale_factor; + float scale_factor = ozone->last_scale_factor; unsigned seperator_margin = 30 * scale_factor; /* Separator */ @@ -2196,7 +2187,7 @@ static void ozone_list_cache(void *data, if (!ozone) return; - scale_factor = ozone->capped_scale_factor; + scale_factor = ozone->last_scale_factor; ozone->need_compute = true; ozone->selection_old_list = ozone->selection; ozone->scroll_old = ozone->animations.scroll_y; diff --git a/menu/drivers/ozone/ozone.h b/menu/drivers/ozone/ozone.h index 7350f091ea..b1955ad843 100644 --- a/menu/drivers/ozone/ozone.h +++ b/menu/drivers/ozone/ozone.h @@ -53,7 +53,7 @@ typedef struct ozone_handle ozone_handle_t; #define ENTRY_ICON_PADDING 15 /* > 'SIDEBAR_WIDTH' must be kept in sync with - * menu widgets metrics */ + * menu driver metrics */ #define SIDEBAR_WIDTH 408 #define SIDEBAR_X_PADDING 40 #define SIDEBAR_Y_PADDING 20 @@ -181,7 +181,6 @@ struct ozone_handle unsigned last_width; unsigned last_height; float last_scale_factor; - float capped_scale_factor; bool need_compute; diff --git a/menu/drivers/ozone/ozone_display.c b/menu/drivers/ozone/ozone_display.c index 276987f1c9..6c5ba8f7ff 100644 --- a/menu/drivers/ozone/ozone_display.c +++ b/menu/drivers/ozone/ozone_display.c @@ -118,7 +118,7 @@ static void ozone_draw_cursor_slice(ozone_handle_t *ozone, unsigned width, unsigned height, size_t y, float alpha) { - float scale_factor = ozone->capped_scale_factor; + float scale_factor = ozone->last_scale_factor; int slice_x = x_offset - 14 * scale_factor; int slice_y = (int)y + 8 * scale_factor; unsigned slice_new_w = width + (3 + 28 - 4) * scale_factor; @@ -261,7 +261,7 @@ void ozone_draw_osk(ozone_handle_t *ozone, unsigned text_color; struct string_list *list; - float scale_factor = ozone->capped_scale_factor; + float scale_factor = ozone->last_scale_factor; unsigned margin = 75 * scale_factor; unsigned padding = 10 * scale_factor; unsigned bottom_end = video_info->height/2; @@ -353,7 +353,7 @@ void ozone_draw_messagebox(ozone_handle_t *ozone, unsigned height = video_info->height; struct string_list *list = !string_is_empty(message) ? string_split(message, "\n") : NULL; - float scale_factor = ozone->capped_scale_factor; + float scale_factor = ozone->last_scale_factor; if (!list || !ozone || !ozone->fonts.footer) { diff --git a/menu/drivers/ozone/ozone_entries.c b/menu/drivers/ozone/ozone_entries.c index 52d523a9f9..f949bfdf8c 100644 --- a/menu/drivers/ozone/ozone_entries.c +++ b/menu/drivers/ozone/ozone_entries.c @@ -55,7 +55,7 @@ static void ozone_draw_entry_value(ozone_handle_t *ozone, { bool switch_is_on = true; bool do_draw_text = false; - float scale_factor = ozone->capped_scale_factor; + float scale_factor = ozone->last_scale_factor; if (!entry->checked && string_is_empty(value)) return; @@ -200,7 +200,7 @@ void ozone_compute_entries_position(ozone_handle_t *ozone) file_list_t *selection_buf = NULL; int entry_padding = ozone_get_entries_padding(ozone, false); - float scale_factor = ozone->capped_scale_factor; + float scale_factor = ozone->last_scale_factor; menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i); @@ -364,7 +364,7 @@ void ozone_draw_entries(ozone_handle_t *ozone, video_frame_info_t *video_info, int16_t cursor_x = 0; int16_t cursor_y = 0; - float scale_factor = ozone->capped_scale_factor; + float scale_factor = ozone->last_scale_factor; menu_input_get_pointer_state(&pointer); diff --git a/menu/drivers/ozone/ozone_sidebar.c b/menu/drivers/ozone/ozone_sidebar.c index bdb4205490..48c092dfcc 100644 --- a/menu/drivers/ozone/ozone_sidebar.c +++ b/menu/drivers/ozone/ozone_sidebar.c @@ -116,7 +116,7 @@ void ozone_draw_sidebar(ozone_handle_t *ozone, video_frame_info_t *video_info) settings_t *settings = config_get_ptr(); uint32_t text_alpha = ozone->animations.sidebar_text_alpha * 255.0f; bool use_smooth_ticker = settings->bools.menu_ticker_smooth; - float scale_factor = ozone->capped_scale_factor; + float scale_factor = ozone->last_scale_factor; /* Initial ticker configuration */ if (use_smooth_ticker) diff --git a/menu/menu_animation.c b/menu/menu_animation.c index c9f81dd26d..6578d155fa 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -1186,7 +1186,6 @@ bool menu_animation_push(menu_animation_ctx_entry_t *entry) } static void menu_animation_update_time( - const char *menu_driver, bool timedate_enable, unsigned video_width, unsigned video_height, float menu_ticker_speed) @@ -1255,27 +1254,32 @@ static void menu_animation_update_time( * every 2 frames is optimal, but may be too fast * for some users - so play it safe. Users can always * set ticker speed to 2x if they prefer) - * Note 2: It turns out that resolution adjustment - * also fails for Ozone, because it doesn't implement - * any kind of DPI scaling - i.e. text gets smaller - * as resolution increases. This is annoying. It - * means we have to use a fixed multiplier for - * Ozone as well... - * Note 3: GLUI uses the new DPI scaling system, + * Note 2: GLUI uses the new DPI scaling system, * so scaling multiplier is menu_display_get_dpi_scale() * multiplied by a small correction factor (since the * default 1.0x speed is just a little faster than the - * non-smooth ticker) */ - if (string_is_equal(menu_driver, "rgui")) - ticker_pixel_increment *= 0.25f; - /* TODO/FIXME: Remove this Ozone special case if/when - * Ozone gets proper DPI scaling */ - else if (string_is_equal(menu_driver, "ozone")) - ticker_pixel_increment *= 0.5f; - else if (string_is_equal(menu_driver, "glui")) - ticker_pixel_increment *= (menu_display_get_dpi_scale(video_width, video_height) * 0.8f); - else if (video_width > 0) - ticker_pixel_increment *= ((float)video_width / 1920.0f); + * non-smooth ticker) + * Note 3: Ozone now also uses the new DPI scaling + * system. We therefore take the same approach as GLUI, + * but with a different correction factor (expected + * scroll speed is somewhat lower for Ozone) */ + switch (menu_driver_ident_id()) + { + case MENU_DRIVER_ID_RGUI: + ticker_pixel_increment *= 0.25f; + break; + case MENU_DRIVER_ID_OZONE: + ticker_pixel_increment *= (menu_display_get_dpi_scale(video_width, video_height) * 0.5f); + break; + case MENU_DRIVER_ID_GLUI: + ticker_pixel_increment *= (menu_display_get_dpi_scale(video_width, video_height) * 0.8f); + break; + case MENU_DRIVER_ID_XMB: + default: + if (video_width > 0) + ticker_pixel_increment *= ((float)video_width / 1920.0f); + break; + } /* > Update accumulator */ ticker_pixel_accumulator += ticker_pixel_increment; @@ -1291,7 +1295,6 @@ static void menu_animation_update_time( } bool menu_animation_update( - const char *menu_driver, bool menu_timedate_enable, float menu_ticker_speed, unsigned video_width, @@ -1300,7 +1303,6 @@ bool menu_animation_update( unsigned i; menu_animation_update_time( - menu_driver, menu_timedate_enable, video_width, video_height, menu_ticker_speed); diff --git a/menu/menu_animation.h b/menu/menu_animation.h index 14a1015d84..fc8ba770a8 100644 --- a/menu/menu_animation.h +++ b/menu/menu_animation.h @@ -199,7 +199,6 @@ void menu_timer_start(menu_timer_t *timer, menu_timer_ctx_entry_t *timer_entry); void menu_timer_kill(menu_timer_t *timer); bool menu_animation_update( - const char *menu_driver, bool menu_timedate_enable, float menu_ticker_speed, unsigned video_width, diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 64b2d294e2..545040e370 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -6486,6 +6486,8 @@ unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ct { settings_t *settings = config_get_ptr(); menu_displaylist_build_info_selective_t build_list[] = { + {MENU_ENUM_LABEL_MENU_WIDGET_SCALE_AUTO, PARSE_ONLY_BOOL, false }, + {MENU_ENUM_LABEL_MENU_WIDGET_SCALE_FACTOR, PARSE_ONLY_FLOAT, false }, {MENU_ENUM_LABEL_VIDEO_FONT_ENABLE, PARSE_ONLY_BOOL, true }, {MENU_ENUM_LABEL_FPS_SHOW, PARSE_ONLY_BOOL, false }, {MENU_ENUM_LABEL_FPS_UPDATE_INTERVAL, PARSE_ONLY_UINT, false }, @@ -6523,6 +6525,15 @@ unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ct if (settings->bools.video_msg_bgcolor_enable) build_list[i].checked = true; break; + case MENU_ENUM_LABEL_MENU_WIDGET_SCALE_AUTO: + if (menu_widgets_ready()) + build_list[i].checked = true; + break; + case MENU_ENUM_LABEL_MENU_WIDGET_SCALE_FACTOR: + if (menu_widgets_ready()) + if (!settings->bools.menu_widget_scale_auto) + build_list[i].checked = true; + break; default: if (settings->bools.video_font_enable) build_list[i].checked = true; diff --git a/menu/menu_driver.c b/menu/menu_driver.c index a163e523aa..db3d1aaa3b 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -88,6 +88,10 @@ * DPI-aware menu scaling factors */ #define REFERENCE_DPI 96.0f +/* 'OZONE_SIDEBAR_WIDTH' must be kept in sync + * with ozone menu driver metrics */ +#define OZONE_SIDEBAR_WIDTH 408 + typedef struct menu_ctx_load_image { void *data; @@ -323,6 +327,8 @@ static menu_handle_t *menu_driver_data = NULL; static const menu_ctx_driver_t *menu_driver_ctx = NULL; static void *menu_userdata = NULL; +static enum menu_driver_id_type menu_driver_id = MENU_DRIVER_ID_UNKNOWN; + /* Quick jumping indices with L/R. * Rebuilt when parsing directory. */ static size_t scroll_index_list[SCROLL_INDEX_SIZE]; @@ -2045,13 +2051,42 @@ void menu_display_unset_framebuffer_dirty_flag(void) menu_display_framebuf_dirty = false; } +static float menu_display_get_adjusted_scale_internal(float base_scale, float scale_factor, unsigned width) +{ + /* Apply user-set scaling factor */ + float adjusted_scale = base_scale * scale_factor; + + /* Ozone has a capped scale factor */ + adjusted_scale = (menu_driver_id == MENU_DRIVER_ID_OZONE) ? + (((float)OZONE_SIDEBAR_WIDTH * adjusted_scale) > ((float)width * 0.3333333f) ? + ((float)width * 0.3333333f / (float)OZONE_SIDEBAR_WIDTH) : adjusted_scale) : + adjusted_scale; + + /* Ensure final scale is 'sane' */ + return (adjusted_scale > 0.0001f) ? adjusted_scale : 1.0f; +} + +/* Ugh... Since we must now have independent scale + * factors for menus and widgets, and most of the internal + * scaling variables are cached/static, a huge amount of + * code duplication is required for the pixel_scale and + * dpi_scale functions. A necessary evil, I suppose... */ + float menu_display_get_pixel_scale(unsigned width, unsigned height) { - static unsigned last_width = 0; - static unsigned last_height = 0; - static float scale = 0.0f; - static bool scale_cached = false; - settings_t *settings = config_get_ptr(); + static unsigned last_width = 0; + static unsigned last_height = 0; + static float scale = 0.0f; + static bool scale_cached = false; + bool scale_updated = false; + static float last_menu_scale_factor = 0.0f; + float menu_scale_factor = 1.0f; + static enum menu_driver_id_type last_menu_driver_id = MENU_DRIVER_ID_UNKNOWN; + static float adjusted_scale = 1.0f; + settings_t *settings = config_get_ptr(); + + if (settings) + menu_scale_factor = settings->floats.menu_scale_factor; /* We need to perform a square root here, which * can be slow on some platforms (not *slow*, but @@ -2068,33 +2103,240 @@ float menu_display_get_pixel_scale(unsigned width, unsigned height) sqrt((double)((width * width) + (height * height))) / DIAGONAL_PIXELS_1080P); + scale_cached = true; + scale_updated = true; + last_width = width; + last_height = height; + } + + /* Adjusted scale calculation may also be slow, so + * only update if something changes */ + if (scale_updated || + (menu_scale_factor != last_menu_scale_factor) || + (menu_driver_id != last_menu_driver_id)) + { + adjusted_scale = menu_display_get_adjusted_scale_internal(scale, menu_scale_factor, width); + last_menu_scale_factor = menu_scale_factor; + last_menu_driver_id = menu_driver_id; + } + + return adjusted_scale; +} + +#ifdef HAVE_MENU_WIDGETS +float menu_display_get_widget_pixel_scale(unsigned width, unsigned height) +{ + static unsigned last_width = 0; + static unsigned last_height = 0; + static float scale = 0.0f; + static bool scale_cached = false; + bool scale_updated = false; + static float last_menu_scale_factor = 0.0f; + float menu_scale_factor = 1.0f; + static enum menu_driver_id_type last_menu_driver_id = MENU_DRIVER_ID_UNKNOWN; + static float adjusted_scale = 1.0f; + settings_t *settings = config_get_ptr(); + + /* When using RGUI, settings->floats.menu_scale_factor + * is ignored + * > If we are not using a widget scale factor override, + * just set menu_scale_factor to 1.0 */ + if (settings) + menu_scale_factor = settings->bools.menu_widget_scale_auto ? + ((menu_driver_id == MENU_DRIVER_ID_RGUI) ? + 1.0f : settings->floats.menu_scale_factor) : + settings->floats.menu_widget_scale_factor; + + /* We need to perform a square root here, which + * can be slow on some platforms (not *slow*, but + * it involves enough work that it's worth trying + * to optimise). We therefore cache the pixel scale, + * and only update on first run or when the video + * size changes */ + if (!scale_cached || + (width != last_width) || + (height != last_height)) + { + /* Baseline reference is a 1080p display */ + scale = (float)( + sqrt((double)((width * width) + (height * height))) / + DIAGONAL_PIXELS_1080P); + + scale_cached = true; + scale_updated = true; + last_width = width; + last_height = height; + } + + /* Adjusted scale calculation may also be slow, so + * only update if something changes */ + if (scale_updated || + (menu_scale_factor != last_menu_scale_factor) || + (menu_driver_id != last_menu_driver_id)) + { + adjusted_scale = menu_display_get_adjusted_scale_internal(scale, menu_scale_factor, width); + last_menu_scale_factor = menu_scale_factor; + last_menu_driver_id = menu_driver_id; + } + + return adjusted_scale; +} +#endif + +float menu_display_get_dpi_scale_internal(unsigned width, unsigned height) +{ + static unsigned last_width = 0; + static unsigned last_height = 0; + static float scale = 0.0f; + static bool scale_cached = false; + float diagonal_pixels; + float pixel_scale; + float dpi; + gfx_ctx_metrics_t metrics; + + if (scale_cached && + (width == last_width) && + (height == last_height)) + return scale; + + /* Determine the diagonal 'size' of the display + * (or window) in terms of pixels */ + diagonal_pixels = (float)sqrt( + (double)((width * width) + (height * height))); + + /* TODO/FIXME: On Mac, calling video_context_driver_get_metrics() + * here causes RetroArch to crash (EXC_BAD_ACCESS). This is + * unfortunate, and needs to be fixed at the gfx context driver + * level. Until this is done, all we can do is fallback to using + * the old legacy 'magic number' scaling on Mac platforms. */ +#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL) + if (true) + { + scale = (diagonal_pixels / 6.5f) / 212.0f; scale_cached = true; last_width = width; last_height = height; + return scale; } +#endif - /* Apply user scaling factor */ - if (settings) + /* Get pixel scale relative to baseline 1080p display */ + pixel_scale = diagonal_pixels / DIAGONAL_PIXELS_1080P; + + /* Attempt to get display DPI */ + metrics.type = DISPLAY_METRIC_DPI; + metrics.value = &dpi; + + if (video_context_driver_get_metrics(&metrics) && (dpi > 0.0f)) { - float menu_scale_factor = settings->floats.menu_scale_factor; - return scale * ((menu_scale_factor > 0.0001f) ? - menu_scale_factor : 1.0f); + float display_size; + float dpi_scale; + +#if defined(ANDROID) || defined(HAVE_COCOATOUCH) + /* Android/iOS devices tell complete lies when + * reporting DPI values. From the Android devices + * I've had access to, the DPI is generally + * overestimated by 17%. All we can do is apply + * a blind correction factor... */ + dpi = dpi * 0.83f; +#endif + + /* Note: If we are running in windowed mode, this + * 'display size' is actually the window size - which + * kinda makes a mess of everything. Since we cannot + * get fullscreen resolution when running in windowed + * mode, there is nothing we can do about this. So just + * treat the window as a display, and hope for the best... */ + display_size = diagonal_pixels / dpi; + dpi_scale = dpi / REFERENCE_DPI; + + /* Note: We have tried leveraging every possible metric + * (and numerous studies on TV/monitor/mobile device + * usage habits) to determine an appropriate auto scaling + * factor. *None of these 'smart'/technical methods work + * consistently in the real world* - there is simply too + * much variance. + * So instead we have implemented a very fuzzy/loose + * method which is crude as can be, but actually has + * some semblance of usability... */ + + if (display_size > 24.0f) + { + /* DPI scaling fails miserably when using large + * displays. Having a UI element that's 1 inch high + * on all screens might seem like a good idea - until + * you realise that a HTPC user is probably sitting + * several metres from their TV, which makes something + * 1 inch high virtually invisible. + * So we make some assumptions: + * - Normal size displays <= 24 inches are probably + * PC monitors, with an eye-to-screen distance of + * 1 arm length. Under these conditions, fixed size + * (DPI scaled) UI elements should be visible for most + * users + * - Large displays > 24 inches start to encroach on + * TV territory. Once we start working with TVs, we + * have to consider users sitting on a couch - and + * in this situation, we fall back to the age-old + * standard of UI elements occupying a fixed fraction + * of the display size (i.e. just look at the menu of + * any console system for the past decade) + * - 24 -> 32 inches is a grey area, where the display + * might be a monitor or a TV. Above 32 inches, a TV + * is almost a certainty. So we simply lerp between + * dpi scaling and pixel scaling as the display size + * increases from 24 to 32 */ + float fraction = (display_size > 32.0f) ? 32.0f : display_size; + fraction = fraction - 24.0f; + fraction = fraction / (32.0f - 24.0f); + + scale = ((1.0f - fraction) * dpi_scale) + (fraction * pixel_scale); + } + else if (display_size < 12.0f) + { + /* DPI scaling also fails when using very small + * displays - i.e. mobile devices (tablets/phones). + * That 1 inch UI element is going to look pretty + * dumb on a 5 inch screen in landscape orientation... + * We're essentially in the opposite situation to the + * TV case above, and it turns out that a similar + * solution provides relief: as screen size reduces + * from 12 inches to zero, we lerp from dpi scaling + * to pixel scaling */ + float fraction = display_size / 12.0f; + + scale = ((1.0f - fraction) * pixel_scale) + (fraction * dpi_scale); + } + else + scale = dpi_scale; } + /* If DPI retrieval is unsupported, all we can do + * is use the raw pixel scale */ + else + scale = pixel_scale; + + scale_cached = true; + last_width = width; + last_height = height; return scale; } float menu_display_get_dpi_scale(unsigned width, unsigned height) { - static unsigned last_width = 0; - static unsigned last_height = 0; - static float scale = 0.0f; - static bool scale_cached = false; - float menu_scale_factor = 0.0f; - settings_t *settings = config_get_ptr(); + static unsigned last_width = 0; + static unsigned last_height = 0; + static float scale = 0.0f; + static bool scale_cached = false; + bool scale_updated = false; + static float last_menu_scale_factor = 0.0f; + float menu_scale_factor = 1.0f; + static enum menu_driver_id_type last_menu_driver_id = MENU_DRIVER_ID_UNKNOWN; + static float adjusted_scale = 1.0f; + settings_t *settings = config_get_ptr(); if (settings) - menu_scale_factor = settings->floats.menu_scale_factor; + menu_scale_factor = settings->floats.menu_scale_factor; /* Scale is based on display metrics - these are a fixed * hardware property. To minimise performance overheads @@ -2104,148 +2346,81 @@ float menu_display_get_dpi_scale(unsigned width, unsigned height) (width != last_width) || (height != last_height)) { - float diagonal_pixels; - float pixel_scale; - float dpi; - gfx_ctx_metrics_t metrics; - - /* Determine the diagonal 'size' of the display - * (or window) in terms of pixels */ - diagonal_pixels = (float)sqrt( - (double)((width * width) + (height * height))); - - /* TODO/FIXME: On Mac, calling video_context_driver_get_metrics() - * here causes RetroArch to crash (EXC_BAD_ACCESS). This is - * unfortunate, and needs to be fixed at the gfx context driver - * level. Until this is done, all we can do is fallback to using - * the old legacy 'magic number' scaling on Mac platforms. - * Note: We use a rather ugly construct here so the 'Mac hack' - * can be added in one place, without polluting the rest of - * the code. */ -#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL) - if (true) - { - scale = (diagonal_pixels / 6.5f) / 212.0f; - scale_cached = true; - last_width = width; - last_height = height; - - if (settings) - return scale * ((menu_scale_factor > 0.0001f) ? - menu_scale_factor : 1.0f); - - return scale; - } -#endif - - /* Get pixel scale relative to baseline 1080p display */ - pixel_scale = diagonal_pixels / DIAGONAL_PIXELS_1080P; - - /* Attempt to get display DPI */ - metrics.type = DISPLAY_METRIC_DPI; - metrics.value = &dpi; - - if (video_context_driver_get_metrics(&metrics) && (dpi > 0.0f)) - { - float display_size; - float dpi_scale; - -#if defined(ANDROID) || defined(HAVE_COCOATOUCH) - /* Android/iOS devices tell complete lies when - * reporting DPI values. From the Android devices - * I've had access to, the DPI is generally - * overestimated by 17%. All we can do is apply - * a blind correction factor... */ - dpi = dpi * 0.83f; -#endif - - /* Note: If we are running in windowed mode, this - * 'display size' is actually the window size - which - * kinda makes a mess of everything. Since we cannot - * get fullscreen resolution when running in windowed - * mode, there is nothing we can do about this. So just - * treat the window as a display, and hope for the best... */ - display_size = diagonal_pixels / dpi; - dpi_scale = dpi / REFERENCE_DPI; - - /* Note: We have tried leveraging every possible metric - * (and numerous studies on TV/monitor/mobile device - * usage habits) to determine an appropriate auto scaling - * factor. *None of these 'smart'/technical methods work - * consistently in the real world* - there is simply too - * much variance. - * So instead we have implemented a very fuzzy/loose - * method which is crude as can be, but actually has - * some semblance of usability... */ - - if (display_size > 24.0f) - { - /* DPI scaling fails miserably when using large - * displays. Having a UI element that's 1 inch high - * on all screens might seem like a good idea - until - * you realise that a HTPC user is probably sitting - * several metres from their TV, which makes something - * 1 inch high virtually invisible. - * So we make some assumptions: - * - Normal size displays <= 24 inches are probably - * PC monitors, with an eye-to-screen distance of - * 1 arm length. Under these conditions, fixed size - * (DPI scaled) UI elements should be visible for most - * users - * - Large displays > 24 inches start to encroach on - * TV territory. Once we start working with TVs, we - * have to consider users sitting on a couch - and - * in this situation, we fall back to the age-old - * standard of UI elements occupying a fixed fraction - * of the display size (i.e. just look at the menu of - * any console system for the past decade) - * - 24 -> 32 inches is a grey area, where the display - * might be a monitor or a TV. Above 32 inches, a TV - * is almost a certainty. So we simply lerp between - * dpi scaling and pixel scaling as the display size - * increases from 24 to 32 */ - float fraction = (display_size > 32.0f) ? 32.0f : display_size; - fraction = fraction - 24.0f; - fraction = fraction / (32.0f - 24.0f); - - scale = ((1.0f - fraction) * dpi_scale) + (fraction * pixel_scale); - } - else if (display_size < 12.0f) - { - /* DPI scaling also fails when using very small - * displays - i.e. mobile devices (tablets/phones). - * That 1 inch UI element is going to look pretty - * dumb on a 5 inch screen in landscape orientation... - * We're essentially in the opposite situation to the - * TV case above, and it turns out that a similar - * solution provides relief: as screen size reduces - * from 12 inches to zero, we lerp from dpi scaling - * to pixel scaling */ - float fraction = display_size / 12.0f; - - scale = ((1.0f - fraction) * pixel_scale) + (fraction * dpi_scale); - } - else - scale = dpi_scale; - } - /* If DPI retrieval is unsupported, all we can do - * is use the raw pixel scale */ - else - scale = pixel_scale; - - scale_cached = true; - last_width = width; - last_height = height; + scale = menu_display_get_dpi_scale_internal(width, height); + scale_cached = true; + scale_updated = true; + last_width = width; + last_height = height; } - /* Apply user scaling factor */ - if (settings) - return scale * ((menu_scale_factor > 0.0001f) ? - menu_scale_factor : 1.0f); + /* Adjusted scale calculation may also be slow, so + * only update if something changes */ + if (scale_updated || + (menu_scale_factor != last_menu_scale_factor) || + (menu_driver_id != last_menu_driver_id)) + { + adjusted_scale = menu_display_get_adjusted_scale_internal(scale, menu_scale_factor, width); + last_menu_scale_factor = menu_scale_factor; + last_menu_driver_id = menu_driver_id; + } - return scale; + return adjusted_scale; } +#ifdef HAVE_MENU_WIDGETS +float menu_display_get_widget_dpi_scale(unsigned width, unsigned height) +{ + static unsigned last_width = 0; + static unsigned last_height = 0; + static float scale = 0.0f; + static bool scale_cached = false; + bool scale_updated = false; + static float last_menu_scale_factor = 0.0f; + float menu_scale_factor = 1.0f; + static enum menu_driver_id_type last_menu_driver_id = MENU_DRIVER_ID_UNKNOWN; + static float adjusted_scale = 1.0f; + settings_t *settings = config_get_ptr(); + + /* When using RGUI, settings->floats.menu_scale_factor + * is ignored + * > If we are not using a widget scale factor override, + * just set menu_scale_factor to 1.0 */ + if (settings) + menu_scale_factor = settings->bools.menu_widget_scale_auto ? + ((menu_driver_id == MENU_DRIVER_ID_RGUI) ? + 1.0f : settings->floats.menu_scale_factor) : + settings->floats.menu_widget_scale_factor; + + /* Scale is based on display metrics - these are a fixed + * hardware property. To minimise performance overheads + * we therefore only call video_context_driver_get_metrics() + * on first run, or when the current video resolution changes */ + if (!scale_cached || + (width != last_width) || + (height != last_height)) + { + scale = menu_display_get_dpi_scale_internal(width, height); + scale_cached = true; + scale_updated = true; + last_width = width; + last_height = height; + } + + /* Adjusted scale calculation may also be slow, so + * only update if something changes */ + if (scale_updated || + (menu_scale_factor != last_menu_scale_factor) || + (menu_driver_id != last_menu_driver_id)) + { + adjusted_scale = menu_display_get_adjusted_scale_internal(scale, menu_scale_factor, width); + last_menu_scale_factor = menu_scale_factor; + last_menu_driver_id = menu_driver_id; + } + + return adjusted_scale; +} +#endif + bool menu_display_driver_exists(const char *s) { unsigned i; @@ -3401,6 +3576,11 @@ const char *menu_driver_ident(void) return menu_driver_ctx->ident; } +enum menu_driver_id_type menu_driver_ident_id(void) +{ + return menu_driver_id; +} + void menu_driver_frame(video_frame_info_t *video_info) { if (video_info->menu_is_alive && menu_driver_ctx->frame) @@ -3491,8 +3671,38 @@ bool menu_driver_list_set_selection(file_list_t *list) return true; } +static void menu_driver_set_id(void) +{ + const char *driver_name = NULL; + + menu_driver_id = MENU_DRIVER_ID_UNKNOWN; + + if (!menu_driver_ctx || !menu_driver_ctx->ident) + return; + + driver_name = menu_driver_ctx->ident; + + if (string_is_empty(driver_name)) + return; + + if (string_is_equal(driver_name, "rgui")) + menu_driver_id = MENU_DRIVER_ID_RGUI; + else if (string_is_equal(driver_name, "ozone")) + menu_driver_id = MENU_DRIVER_ID_OZONE; + else if (string_is_equal(driver_name, "glui")) + menu_driver_id = MENU_DRIVER_ID_GLUI; + else if (string_is_equal(driver_name, "xmb")) + menu_driver_id = MENU_DRIVER_ID_XMB; + else if (string_is_equal(driver_name, "xui")) + menu_driver_id = MENU_DRIVER_ID_XUI; + else if (string_is_equal(driver_name, "stripes")) + menu_driver_id = MENU_DRIVER_ID_STRIPES; +} + static bool menu_driver_init_internal(bool video_is_threaded) { + menu_driver_id = MENU_DRIVER_ID_UNKNOWN; + if (menu_driver_ctx->init) { menu_driver_data = (menu_handle_t*) @@ -3514,6 +3724,8 @@ static bool menu_driver_init_internal(bool video_is_threaded) if (!menu_driver_ctx->lists_init(menu_driver_data)) return false; + menu_driver_set_id(); + return true; } @@ -3720,6 +3932,8 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) free(menu_userdata); menu_userdata = NULL; + menu_driver_id = MENU_DRIVER_ID_UNKNOWN; + #ifndef HAVE_DYNAMIC if (frontend_driver_has_fork()) #endif diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 1537ecf636..aae03b9c80 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -224,6 +224,17 @@ enum menu_settings_type MENU_SETTINGS_LAST }; +enum menu_driver_id_type +{ + MENU_DRIVER_ID_UNKNOWN = 0, + MENU_DRIVER_ID_RGUI, + MENU_DRIVER_ID_OZONE, + MENU_DRIVER_ID_GLUI, + MENU_DRIVER_ID_XMB, + MENU_DRIVER_ID_XUI, + MENU_DRIVER_ID_STRIPES +}; + typedef struct menu_display_ctx_driver { /* Draw graphics to the screen. */ @@ -526,6 +537,8 @@ const char* config_get_menu_driver_options(void); const char *menu_driver_ident(void); +enum menu_driver_id_type menu_driver_ident_id(void); + bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data); void menu_driver_frame(video_frame_info_t *video_info); @@ -596,6 +609,10 @@ void menu_display_set_framebuffer_dirty_flag(void); void menu_display_unset_framebuffer_dirty_flag(void); float menu_display_get_pixel_scale(unsigned width, unsigned height); float menu_display_get_dpi_scale(unsigned width, unsigned height); +#ifdef HAVE_MENU_WIDGETS +float menu_display_get_widget_pixel_scale(unsigned width, unsigned height); +float menu_display_get_widget_dpi_scale(unsigned width, unsigned height); +#endif bool menu_display_init_first_driver(bool video_is_threaded); bool menu_display_restore_clear_color(void); void menu_display_clear_color(menu_display_ctx_clearcolor_t *color, diff --git a/menu/menu_setting.c b/menu/menu_setting.c index fa48f8edbc..70883dd782 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -11761,6 +11761,48 @@ static bool setting_append_list( &subgroup_info, parent_group); + /* This is the SETTINGS_LIST_FONT category, but the + * parent group is ONSCREEN_DISPLAY_SETTINGS. + * Menu widget settings don't belong in the SETTINGS_LIST_FONT + * category, but they *do* belong in the ONSCREEN_DISPLAY_SETTINGS + * group. I don't want to refactor these names, so we'll assume + * group trumps category, and just place the widget settings here */ +#ifdef HAVE_MENU_WIDGETS + CONFIG_BOOL( + list, list_info, + &settings->bools.menu_widget_scale_auto, + MENU_ENUM_LABEL_MENU_WIDGET_SCALE_AUTO, + MENU_ENUM_LABEL_VALUE_MENU_WIDGET_SCALE_AUTO, + DEFAULT_MENU_WIDGET_SCALE_AUTO, + MENU_ENUM_LABEL_VALUE_OFF, + MENU_ENUM_LABEL_VALUE_ON, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler, + SD_FLAG_NONE + ); + (*list)[list_info->index - 1].action_ok = &setting_bool_action_left_with_refresh; + (*list)[list_info->index - 1].action_left = &setting_bool_action_left_with_refresh; + (*list)[list_info->index - 1].action_right = &setting_bool_action_right_with_refresh; + + CONFIG_FLOAT( + list, list_info, + &settings->floats.menu_widget_scale_factor, + MENU_ENUM_LABEL_MENU_WIDGET_SCALE_FACTOR, + MENU_ENUM_LABEL_VALUE_MENU_WIDGET_SCALE_FACTOR, + DEFAULT_MENU_WIDGET_SCALE_FACTOR, + "%.2fx", + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); + (*list)[list_info->index - 1].action_ok = &setting_action_ok_uint; + menu_settings_list_current_add_range(list, list_info, 0.2, 5.0, 0.01, true, true); +#endif + CONFIG_BOOL( list, list_info, &settings->bools.video_font_enable, @@ -12844,29 +12886,16 @@ static bool setting_append_list( START_SUB_GROUP(list, list_info, "Display", &group_info, &subgroup_info, parent_group); - /* > MaterialUI, XMB and Ozone all support menu scaling - * > RGUI does not, but since scale factor is also used - * for menu widgets, show the setting if widgets are - * enabled */ + /* > MaterialUI, XMB and Ozone all support menu scaling */ if (string_is_equal(settings->arrays.menu_driver, "glui") || string_is_equal(settings->arrays.menu_driver, "xmb") || -#ifdef HAVE_MENU_WIDGETS - string_is_equal(settings->arrays.menu_driver, "ozone") || - (string_is_equal(settings->arrays.menu_driver, "rgui") && - settings->bools.menu_enable_widgets)) -#else string_is_equal(settings->arrays.menu_driver, "ozone")) -#endif { - enum msg_hash_enums menu_scale_factor_label_value = - string_is_equal(settings->arrays.menu_driver, "rgui") ? - MENU_ENUM_LABEL_VALUE_MENU_WIDGET_SCALE_FACTOR : MENU_ENUM_LABEL_VALUE_MENU_SCALE_FACTOR; - CONFIG_FLOAT( list, list_info, &settings->floats.menu_scale_factor, MENU_ENUM_LABEL_MENU_SCALE_FACTOR, - menu_scale_factor_label_value, + MENU_ENUM_LABEL_VALUE_MENU_SCALE_FACTOR, DEFAULT_MENU_SCALE_FACTOR, "%.2fx", &group_info, diff --git a/menu/widgets/menu_widgets.c b/menu/widgets/menu_widgets.c index d9c79461fc..4fca9735c0 100644 --- a/menu/widgets/menu_widgets.c +++ b/menu/widgets/menu_widgets.c @@ -290,12 +290,6 @@ static char libretro_message[LIBRETRO_MESSAGE_SIZE] = {'\0'}; /* Metrics */ #define BASE_FONT_SIZE 32.0f -/* > 'OZONE_SIDEBAR_WIDTH' must be kept in sync - * with ozone menu driver metrics */ -#define OZONE_SIDEBAR_WIDTH 408 - -static bool is_ozone; -static bool is_xmb; static float widget_font_size; static unsigned simple_widget_padding = 0; @@ -332,7 +326,6 @@ static unsigned divider_width_1px; static unsigned last_video_width; static unsigned last_video_height; static float last_scale_factor; -static float capped_scale_factor; static void msg_widget_msg_transition_animation_done(void *userdata) { @@ -892,9 +885,9 @@ void menu_widgets_iterate( /* Check whether screen dimensions or menu scale * factor have changed */ - float scale_factor = is_xmb ? - menu_display_get_pixel_scale(width, height) : - menu_display_get_dpi_scale(width, height); + float scale_factor = (menu_driver_ident_id() == MENU_DRIVER_ID_XMB) ? + menu_display_get_widget_pixel_scale(width, height) : + menu_display_get_widget_dpi_scale(width, height); if ((scale_factor != last_scale_factor) || (width != last_video_width) || @@ -1343,7 +1336,7 @@ static void menu_widgets_draw_load_content_animation(video_frame_info_t *video_i int icon_size = (int) load_content_animation_icon_size; uint32_t text_alpha = load_content_animation_fade_alpha * 255.0f; uint32_t text_color = COLOR_TEXT_ALPHA(0xB8B8B800, text_alpha); - unsigned text_offset = -25 * capped_scale_factor * load_content_animation_fade_alpha; + unsigned text_offset = -25 * last_scale_factor * load_content_animation_fade_alpha; float *icon_color = load_content_animation_icon_color; /* Fade out */ @@ -1366,7 +1359,7 @@ static void menu_widgets_draw_load_content_animation(video_frame_info_t *video_i menu_display_draw_text(font_bold, load_content_animation_content_name, video_info->width/2, - video_info->height/2 + (175 + 25) * capped_scale_factor + text_offset, + video_info->height/2 + (175 + 25) * last_scale_factor + text_offset, video_info->width, video_info->height, text_color, @@ -1804,6 +1797,11 @@ void menu_widgets_frame(void *data) int text_width = font_driver_get_message_width(font_regular, text, (unsigned)strlen(text), 1.0f); int total_width = text_width + simple_widget_padding * 2; + int fps_text_x = top_right_x_advance - simple_widget_padding - text_width; + /* Ensure that left hand side of text does + * not bleed off the edge of the screen */ + fps_text_x = (fps_text_x < 0) ? 0 : fps_text_x; + menu_display_set_alpha(menu_widgets_backdrop_orig, DEFAULT_BACKDROP); menu_display_draw_quad(video_info, @@ -1815,7 +1813,7 @@ void menu_widgets_frame(void *data) menu_display_draw_text(font_regular, text, - top_right_x_advance - simple_widget_padding - text_width, widget_font_size + simple_widget_padding/4, + fps_text_x, widget_font_size + simple_widget_padding/4, video_info->width, video_info->height, 0xFFFFFFFF, TEXT_ALIGN_LEFT, @@ -1871,7 +1869,7 @@ void menu_widgets_frame(void *data) menu_display_unset_viewport(video_info->width, video_info->height); } -bool menu_widgets_init(bool video_is_threaded, const char *menu_driver) +bool menu_widgets_init(bool video_is_threaded) { if (!menu_display_init_first_driver(video_is_threaded)) goto error; @@ -1896,13 +1894,10 @@ bool menu_widgets_init(bool video_is_threaded, const char *menu_driver) * > Ozone has a capped scale factor * > XMB uses pixel based scaling - all other drivers * use DPI based scaling */ - is_ozone = string_is_equal(menu_driver, "ozone"); - is_xmb = string_is_equal(menu_driver, "xmb"); - video_driver_get_size(&last_video_width, &last_video_height); - last_scale_factor = is_xmb ? - menu_display_get_pixel_scale(last_video_width, last_video_height) : - menu_display_get_dpi_scale(last_video_width, last_video_height); + last_scale_factor = (menu_driver_ident_id() == MENU_DRIVER_ID_XMB) ? + menu_display_get_widget_pixel_scale(last_video_width, last_video_height) : + menu_display_get_widget_dpi_scale(last_video_width, last_video_height); return true; @@ -1917,17 +1912,8 @@ static void menu_widgets_layout( { int font_height = 0; - /* Ozone is a unique case, in that it has a capped - * scale factor */ - if (is_ozone) - capped_scale_factor = - (OZONE_SIDEBAR_WIDTH * last_scale_factor) > (last_video_width * 0.3333333f) ? - ((float)last_video_width * 0.3333333f / (float)OZONE_SIDEBAR_WIDTH) : last_scale_factor; - else - capped_scale_factor = last_scale_factor; - /* Base font size must be determined first */ - widget_font_size = BASE_FONT_SIZE * capped_scale_factor; + widget_font_size = BASE_FONT_SIZE * last_scale_factor; /* Initialise fonts */ @@ -2024,10 +2010,10 @@ static void menu_widgets_layout( msg_queue_default_rect_width_menu_alive = msg_queue_glyph_width * 40; msg_queue_default_rect_width = last_video_width - msg_queue_regular_text_start - (2 * simple_widget_padding); - load_content_animation_icon_size_initial = LOAD_CONTENT_ANIMATION_INITIAL_ICON_SIZE * capped_scale_factor; - load_content_animation_icon_size_target = LOAD_CONTENT_ANIMATION_TARGET_ICON_SIZE * capped_scale_factor; + load_content_animation_icon_size_initial = LOAD_CONTENT_ANIMATION_INITIAL_ICON_SIZE * last_scale_factor; + load_content_animation_icon_size_target = LOAD_CONTENT_ANIMATION_TARGET_ICON_SIZE * last_scale_factor; - divider_width_1px = (capped_scale_factor > 1.0f) ? (unsigned)(capped_scale_factor + 0.5f) : 1; + divider_width_1px = (last_scale_factor > 1.0f) ? (unsigned)(last_scale_factor + 0.5f) : 1; } void menu_widgets_context_reset(bool is_threaded, @@ -2092,9 +2078,9 @@ void menu_widgets_context_reset(bool is_threaded, /* Update scaling/dimensions */ last_video_width = width; last_video_height = height; - last_scale_factor = is_xmb ? - menu_display_get_pixel_scale(last_video_width, last_video_height) : - menu_display_get_dpi_scale(last_video_width, last_video_height); + last_scale_factor = (menu_driver_ident_id() == MENU_DRIVER_ID_XMB) ? + menu_display_get_widget_pixel_scale(last_video_width, last_video_height) : + menu_display_get_widget_dpi_scale(last_video_width, last_video_height); menu_widgets_layout(is_threaded, dir_assets, font_path); video_driver_monitor_reset(); diff --git a/menu/widgets/menu_widgets.h b/menu/widgets/menu_widgets.h index d1ad1758e7..b52fa9f67c 100644 --- a/menu/widgets/menu_widgets.h +++ b/menu/widgets/menu_widgets.h @@ -36,7 +36,7 @@ #define HOURGLASS_DURATION 1000 #define GENERIC_MESSAGE_DURATION 3000 -bool menu_widgets_init(bool video_is_threaded, const char *menu_driver); +bool menu_widgets_init(bool video_is_threaded); void menu_widgets_free(void); diff --git a/msg_hash.h b/msg_hash.h index 6e80ce675c..d0230d0047 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -517,6 +517,7 @@ enum msg_hash_enums MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_END = MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_BEGIN + RARCH_BIND_LIST_END, MENU_LABEL(MENU_SCALE_FACTOR), + MENU_LABEL(MENU_WIDGET_SCALE_AUTO), MENU_LABEL(MENU_WIDGET_SCALE_FACTOR), MENU_LABEL(MENU_WALLPAPER_OPACITY), MENU_LABEL(MENU_FRAMEBUFFER_OPACITY), diff --git a/retroarch.c b/retroarch.c index 3748731396..c485d63341 100644 --- a/retroarch.c +++ b/retroarch.c @@ -23435,8 +23435,7 @@ static void drivers_init(int flags) && video_driver_has_widgets()) { if (!menu_widgets_inited) - menu_widgets_inited = menu_widgets_init( - video_is_threaded, settings->arrays.menu_driver); + menu_widgets_inited = menu_widgets_init(video_is_threaded); if (menu_widgets_inited) menu_widgets_context_reset(video_is_threaded, @@ -27268,7 +27267,6 @@ static enum runloop_state runloop_check_state(void) #if defined(HAVE_MENU) menu_animation_update( - settings->arrays.menu_driver, settings->bools.menu_timedate_enable, settings->floats.menu_ticker_speed, video_driver_width, video_driver_height); From 9d5d7edf9a69dfa12a5e70045fd7a6a7c789aedc Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 14 Feb 2020 19:00:59 +0100 Subject: [PATCH 74/75] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index d6e7fdf33d..23e8d23204 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,7 @@ - LOCALIZATION: Update Polish translation - LOCALIZATION: Update Spanish translation - MENU/WIDGETS: Allow notifications to use full screen width when not displaying menu +- MENU/WIDGETS: DPI-based scaling - MENU/OZONE: Add DPI-based scaling - NETPLAY/MENU/BUGFIX: Fix Netplay Stateless Mode doesn't save. Affects other netplay settings which can be overridden by commandline option - NETPLAY/ROOMS/BUGFIX: Prevent out-of-bounds array indexing when displaying/selecting netplay rooms in menus From 8040e7d168f80091e671f9f227e3fd8a3a355f8e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 14 Feb 2020 19:04:12 +0100 Subject: [PATCH 75/75] (PS2) Buildfix --- menu/cbs/menu_cbs_left.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index e640af55dc..f1bbb1150f 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -524,8 +524,8 @@ static int playlist_left_thumbnail_mode_left(unsigned type, const char *label, static int manual_content_scan_system_name_left(unsigned type, const char *label, bool wraparound) { -#ifdef HAVE_LIBRETRODB settings_t *settings = config_get_ptr(); +#ifdef HAVE_LIBRETRODB struct string_list *system_name_list = manual_content_scan_get_menu_system_name_list(settings->paths.path_content_database, settings->bools.show_hidden_files); #else