[android] Adjustments on FSR use, values and UI interactions inside global/ per-game config + quick settings interactions

This commit is contained in:
CamilleLaVey 2026-04-06 20:13:57 -04:00
parent 0af3cf7463
commit 67ba161540
5 changed files with 65 additions and 15 deletions

View file

@ -57,7 +57,8 @@ class QuickSettings(val emulationFragment: EmulationFragment) {
container: ViewGroup,
setting: IntSetting,
namesArrayId: Int,
valuesArrayId: Int
valuesArrayId: Int,
onValueChanged: ((Int) -> Unit)? = null
) {
val inflater = LayoutInflater.from(emulationFragment.requireContext())
val itemView = inflater.inflate(R.layout.item_quick_settings_menu, container, false)
@ -89,6 +90,7 @@ class QuickSettings(val emulationFragment: EmulationFragment) {
setting.setInt(values[index])
saveSettings()
valueView.text = name
onValueChanged?.invoke(values[index])
}
}
radioGroup.addView(radioButton)

View file

@ -29,6 +29,7 @@ import org.yuzu.yuzu_emu.databinding.DialogSliderBinding
import org.yuzu.yuzu_emu.databinding.DialogSpinboxBinding
import org.yuzu.yuzu_emu.features.input.NativeInput
import org.yuzu.yuzu_emu.features.input.model.AnalogDirection
import org.yuzu.yuzu_emu.features.settings.model.IntSetting
import org.yuzu.yuzu_emu.features.settings.model.view.AnalogInputSetting
import org.yuzu.yuzu_emu.features.settings.model.view.ButtonInputSetting
import org.yuzu.yuzu_emu.features.settings.model.view.IntSingleChoiceSetting
@ -381,6 +382,10 @@ class SettingsDialogFragment : DialogFragment(), DialogInterface.OnClickListener
}
scSetting.setSelectedValue(value)
if (scSetting.setting.key == IntSetting.RENDERER_SCALING_FILTER.key) {
settingsViewModel.setShouldReloadSettingsList(true)
}
if (scSetting.setting.key == "app_language") {
settingsViewModel.setShouldRecreateForLanguageChange(true)
// recreate page apply language change instantly

View file

@ -58,19 +58,38 @@ class SettingsFragmentPresenter(
val pairedSettingKey = item.setting.pairedSettingKey
if (pairedSettingKey.isNotEmpty()) {
val needsGlobal = getNeedsGlobalForKey(pairedSettingKey)
val pairedSettingValue = NativeConfig.getBoolean(
pairedSettingKey,
if (NativeLibrary.isRunning() && !NativeConfig.isPerGameConfigLoaded()) {
!NativeConfig.usingGlobal(pairedSettingKey)
} else {
NativeConfig.usingGlobal(pairedSettingKey)
}
needsGlobal
)
if (!pairedSettingValue) return
}
add(item)
}
private fun getNeedsGlobalForKey(key: String): Boolean {
return if (NativeLibrary.isRunning() && !NativeConfig.isPerGameConfigLoaded()) {
!NativeConfig.usingGlobal(key)
} else {
NativeConfig.usingGlobal(key)
}
}
private fun isFsrScalingFilterSelected(): Boolean {
val fsrFilterValue = resolveFsrScalingFilterValue() ?: return false
val needsGlobal = getNeedsGlobalForKey(IntSetting.RENDERER_SCALING_FILTER.key)
val selectedFilter = IntSetting.RENDERER_SCALING_FILTER.getInt(needsGlobal)
return selectedFilter == fsrFilterValue
}
private fun resolveFsrScalingFilterValue(): Int? {
val names = context.resources.getStringArray(R.array.rendererScalingFilterNames)
val values = context.resources.getIntArray(R.array.rendererScalingFilterValues)
val fsrIndex = names.indexOf(context.getString(R.string.scaling_filter_fsr))
return if (fsrIndex in values.indices) values[fsrIndex] else null
}
// Allows you to show/hide abstract settings based on the paired setting key
private fun ArrayList<SettingsItem>.addAbstract(item: SettingsItem) {
val pairedSettingKey = item.setting.pairedSettingKey
@ -248,7 +267,9 @@ class SettingsFragmentPresenter(
add(IntSetting.RENDERER_RESOLUTION.key)
add(IntSetting.RENDERER_VSYNC.key)
add(IntSetting.RENDERER_SCALING_FILTER.key)
add(IntSetting.FSR_SHARPENING_SLIDER.key)
if (isFsrScalingFilterSelected()) {
add(IntSetting.FSR_SHARPENING_SLIDER.key)
}
add(IntSetting.RENDERER_ANTI_ALIASING.key)
add(IntSetting.RENDERER_OPTIMIZE_SPIRV_OUTPUT.key)

View file

@ -1078,6 +1078,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
private fun addQuickSettings() {
binding.quickSettingsSheet.apply {
val container = binding.quickSettingsSheet.findViewById<ViewGroup>(R.id.quick_settings_container)
val isFsrSelected = isFsrScalingFilterSelected()
container.removeAllViews()
@ -1159,16 +1160,20 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
IntSetting.RENDERER_SCALING_FILTER,
R.array.rendererScalingFilterNames,
R.array.rendererScalingFilterValues
) {
addQuickSettings()
)
quickSettings.addSliderSetting(
R.string.fsr_sharpness,
container,
IntSetting.FSR_SHARPENING_SLIDER,
minValue = 0,
maxValue = 100,
units = "%"
)
if (isFsrSelected) {
quickSettings.addSliderSetting(
R.string.fsr_sharpness,
container,
IntSetting.FSR_SHARPENING_SLIDER,
minValue = 0,
maxValue = 100,
units = "%"
)
}
quickSettings.addIntSetting(
R.string.renderer_anti_aliasing,
@ -1180,6 +1185,19 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
}
}
private fun isFsrScalingFilterSelected(): Boolean {
val fsrFilterValue = resolveFsrScalingFilterValue() ?: return false
val selectedFilter = IntSetting.RENDERER_SCALING_FILTER.getInt(needsGlobal = false)
return selectedFilter == fsrFilterValue
}
private fun resolveFsrScalingFilterValue(): Int? {
val names = resources.getStringArray(R.array.rendererScalingFilterNames)
val values = resources.getIntArray(R.array.rendererScalingFilterValues)
val fsrIndex = names.indexOf(getString(R.string.scaling_filter_fsr))
return if (fsrIndex in values.indices) values[fsrIndex] else null
}
private fun openQuickSettingsMenu() {
binding.drawerLayout.closeDrawer(binding.inGameMenu)
binding.drawerLayout.openDrawer(binding.quickSettingsSheet)

View file

@ -359,7 +359,11 @@ struct Values {
true,
true};
SwitchableSetting<int, true> fsr_sharpening_slider{linkage,
#ifdef ANDROID
0,
#else
25,
#endif
0,
200,
"fsr_sharpening_slider",