diff --git a/configuration.c b/configuration.c index 0b371d4283..bdda77d593 100644 --- a/configuration.c +++ b/configuration.c @@ -81,7 +81,6 @@ * cannot preprocess. */ void android_app_set_window_settings(bool notch_write_over, bool auto_mouse_grab); -void android_apply_first_run_defaults(settings_t *settings); #endif #include "list_special.h" @@ -8712,7 +8711,7 @@ static void config_parse_file(void) * that exists but would not open is not one, and keeps the * built-in defaults. */ if (config_path && *config_path && !path_is_valid(config_path)) - android_apply_first_run_defaults(config_st); + android_apply_device_defaults(config_st); #endif } } diff --git a/configuration.h b/configuration.h index de4000a31c..a4efbe1e7a 100644 --- a/configuration.h +++ b/configuration.h @@ -1771,6 +1771,14 @@ void config_set_video_menu_xr(const struct video_screen_xr *values); void config_set_defaults(settings_t *target); +#ifdef ANDROID +/* Defined in frontend/drivers/platform_unix.c. Sets the drivers and + * audio latency the device is best served by, as the settings' own + * values over the built-in defaults: on a fresh install's first start, + * and on "Reset to Default Configuration". */ +void android_apply_device_defaults(settings_t *settings); +#endif + void config_load(void); #if !defined(HAVE_DYNAMIC) diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c index f5d3d15376..9e119381d5 100644 --- a/frontend/drivers/platform_unix.c +++ b/frontend/drivers/platform_unix.c @@ -4553,13 +4553,16 @@ static bool android_has_vulkan_1_1(JNIEnv *env, jobject activity) } #endif -/* First start: no config file exists yet. The built-in defaults stay - * what they always were (OpenGL ES, OpenSL ES, 128 ms), since a config - * saved with "save minimal" leaves out every key that matches them and - * changing them would change those installs on update. A fresh - * install instead gets the modern drivers set as its own values when - * the device has them, and they are saved with the rest of its - * config. Nothing here runs again once a config exists. +/* The drivers and audio latency this device is best served by, set as + * the settings' own values. Applied on a fresh install's first start, + * when no config file exists yet, and on "Reset to Default + * Configuration"; never to a config that is only being loaded. + * + * The built-in defaults stay what they always were (OpenGL ES, OpenSL + * ES, 128 ms): a config saved with "save minimal" leaves out every key + * that matches them, so changing them would move those installs to new + * drivers on update. Set as values, these are saved with the rest of + * the config whatever the save mode. * * - Vulkan when the device declares Vulkan 1.1. Devices with only a * 1.0 driver, or none, keep OpenGL ES, as before. @@ -4567,7 +4570,7 @@ static bool android_has_vulkan_1_1(JNIEnv *env, jobject activity) * bugs that make Oboe use OpenSL ES there; older releases keep * OpenSL ES, as before. With AAudio the latency drops to 64 ms, * unless a device quirk above chose one. */ -void android_apply_first_run_defaults(settings_t *settings) +void android_apply_device_defaults(settings_t *settings) { int32_t sdk = 0; @@ -4587,7 +4590,7 @@ void android_apply_first_run_defaults(settings_t *settings) { configuration_set_string(settings, settings->arrays.video_driver, "vulkan"); - RARCH_LOG("[Config] First start: device has Vulkan 1.1, " + RARCH_LOG("[Config] Device defaults: Vulkan 1.1, " "video driver \"vulkan\".\n"); } } @@ -4602,7 +4605,7 @@ void android_apply_first_run_defaults(settings_t *settings) if (!(g_platform_android_flags & PLAT_ANDROID_FLAG_LATENCY_QUIRK)) configuration_set_uint(settings, settings->uints.audio_latency, 64); - RARCH_LOG("[Config] First start: Android API %d, audio driver " + RARCH_LOG("[Config] Device defaults: Android API %d, audio driver " "\"aaudio\", latency %u ms.\n", (int)sdk, settings->uints.audio_latency); } diff --git a/retroarch.c b/retroarch.c index 7d566fe249..400fa2025f 100644 --- a/retroarch.c +++ b/retroarch.c @@ -5641,6 +5641,11 @@ bool command_event(enum event_command cmd, void *data) #endif case CMD_EVENT_MENU_RESET_TO_DEFAULT_CONFIG: config_set_defaults(config_get_ptr()); +#ifdef ANDROID + /* The same drivers a fresh install on this device gets, not + * the built-in ones the oldest devices need. */ + android_apply_device_defaults(config_get_ptr()); +#endif /* a reset forgets the controllers too, which they get back * when the joypad driver next starts */ input_config_forget_controllers();