diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/StringSetting.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/StringSetting.kt index 63f95690c7..6621289fd5 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/StringSetting.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/StringSetting.kt @@ -8,6 +8,7 @@ enum class StringSetting( override val section: String, override val defaultValue: String ) : AbstractStringSetting { + AUDIO_OUTPUT_ENGINE("output_engine", Settings.SECTION_AUDIO, "auto"), CUSTOM_RTC("custom_rtc", Settings.SECTION_SYSTEM, "0"); override var string: String = defaultValue diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/StringSingleChoiceSetting.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/StringSingleChoiceSetting.kt index bad34fd88e..3b6731dcd5 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/StringSingleChoiceSetting.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/StringSingleChoiceSetting.kt @@ -7,20 +7,20 @@ import org.yuzu.yuzu_emu.features.settings.model.AbstractSetting import org.yuzu.yuzu_emu.features.settings.model.AbstractStringSetting class StringSingleChoiceSetting( - val key: String? = null, setting: AbstractSetting?, titleId: Int, descriptionId: Int, - val choicesId: Array, - private val valuesId: Array?, + val choices: Array, + val values: Array?, + val key: String? = null, private val defaultValue: String? = null ) : SettingsItem(setting, titleId, descriptionId) { override val type = TYPE_STRING_SINGLE_CHOICE fun getValueAt(index: Int): String? { - if (valuesId == null) return null - return if (index >= 0 && index < valuesId.size) { - valuesId[index] + if (values == null) return null + return if (index >= 0 && index < values.size) { + values[index] } else { "" } @@ -36,8 +36,8 @@ class StringSingleChoiceSetting( val selectValueIndex: Int get() { val selectedValue = selectedValue - for (i in valuesId!!.indices) { - if (valuesId[i] == selectedValue) { + for (i in values!!.indices) { + if (values[i] == selectedValue) { return i } } diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsAdapter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsAdapter.kt index eac6a134bb..ce0b92c90e 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsAdapter.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsAdapter.kt @@ -138,7 +138,7 @@ class SettingsAdapter( clickedItem = item dialog = MaterialAlertDialogBuilder(context) .setTitle(item.nameId) - .setSingleChoiceItems(item.choicesId, item.selectValueIndex, this) + .setSingleChoiceItems(item.choices, item.selectValueIndex, this) .show() } diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt index 8215a08eb9..59c1d9d545 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt @@ -353,18 +353,31 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView) private fun addAudioSettings(sl: ArrayList) { settingsActivity.setToolbarTitle(settingsActivity.getString(R.string.preferences_audio)) - sl.add( - SliderSetting( - IntSetting.AUDIO_VOLUME, - R.string.audio_volume, - R.string.audio_volume_description, - 0, - 100, - "%", - IntSetting.AUDIO_VOLUME.key, - IntSetting.AUDIO_VOLUME.defaultValue + sl.apply { + add( + StringSingleChoiceSetting( + StringSetting.AUDIO_OUTPUT_ENGINE, + R.string.audio_output_engine, + 0, + settingsActivity.resources.getStringArray(R.array.outputEngineEntries), + settingsActivity.resources.getStringArray(R.array.outputEngineValues), + StringSetting.AUDIO_OUTPUT_ENGINE.key, + StringSetting.AUDIO_OUTPUT_ENGINE.defaultValue + ) ) - ) + add( + SliderSetting( + IntSetting.AUDIO_VOLUME, + R.string.audio_volume, + R.string.audio_volume_description, + 0, + 100, + "%", + IntSetting.AUDIO_VOLUME.key, + IntSetting.AUDIO_VOLUME.defaultValue + ) + ) + } } private fun addThemeSettings(sl: ArrayList) { diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SingleChoiceViewHolder.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SingleChoiceViewHolder.kt index de764a27f4..e4e321bd36 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SingleChoiceViewHolder.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SingleChoiceViewHolder.kt @@ -26,6 +26,14 @@ class SingleChoiceViewHolder(val binding: ListItemSettingBinding, adapter: Setti for (i in values.indices) { if (values[i] == item.selectedValue) { binding.textSettingDescription.text = resMgr.getStringArray(item.choicesId)[i] + return + } + } + } else if (item is StringSingleChoiceSetting) { + for (i in item.values!!.indices) { + if (item.values[i] == item.selectedValue) { + binding.textSettingDescription.text = item.choices[i] + return } } } else { diff --git a/src/android/app/src/main/res/values/arrays.xml b/src/android/app/src/main/res/values/arrays.xml index 7f7b1938c3..6d092f7a94 100644 --- a/src/android/app/src/main/res/values/arrays.xml +++ b/src/android/app/src/main/res/values/arrays.xml @@ -236,4 +236,15 @@ 2 + + @string/auto + @string/cubeb + @string/string_null + + + auto + cubeb + null + + diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index a7ea01b554..cc1d8c39d9 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -185,6 +185,7 @@ Fastmem + Output engine Volume Specifies the volume of audio output. @@ -203,6 +204,7 @@ Learn more Auto Submit + Null Select GPU driver @@ -373,6 +375,9 @@ Light Dark + + cubeb + Black backgrounds When using the dark theme, apply black backgrounds.