diff options
62 files changed, 977 insertions, 458 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/input/model/PlayerInput.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/input/model/PlayerInput.kt index d35de80c4..a84ac77a2 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/input/model/PlayerInput.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/input/model/PlayerInput.kt | |||
| @@ -64,17 +64,17 @@ data class PlayerInput( | |||
| 64 | fun hasMapping(): Boolean { | 64 | fun hasMapping(): Boolean { |
| 65 | var hasMapping = false | 65 | var hasMapping = false |
| 66 | buttons.forEach { | 66 | buttons.forEach { |
| 67 | if (it != "[empty]") { | 67 | if (it != "[empty]" && it.isNotEmpty()) { |
| 68 | hasMapping = true | 68 | hasMapping = true |
| 69 | } | 69 | } |
| 70 | } | 70 | } |
| 71 | analogs.forEach { | 71 | analogs.forEach { |
| 72 | if (it != "[empty]") { | 72 | if (it != "[empty]" && it.isNotEmpty()) { |
| 73 | hasMapping = true | 73 | hasMapping = true |
| 74 | } | 74 | } |
| 75 | } | 75 | } |
| 76 | motions.forEach { | 76 | motions.forEach { |
| 77 | if (it != "[empty]") { | 77 | if (it != "[empty]" && it.isNotEmpty()) { |
| 78 | hasMapping = true | 78 | hasMapping = true |
| 79 | } | 79 | } |
| 80 | } | 80 | } |
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 a0d8cfede..6f16cf5b1 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 | |||
| @@ -6,7 +6,8 @@ package org.yuzu.yuzu_emu.features.settings.model | |||
| 6 | import org.yuzu.yuzu_emu.utils.NativeConfig | 6 | import org.yuzu.yuzu_emu.utils.NativeConfig |
| 7 | 7 | ||
| 8 | enum class StringSetting(override val key: String) : AbstractStringSetting { | 8 | enum class StringSetting(override val key: String) : AbstractStringSetting { |
| 9 | DRIVER_PATH("driver_path"); | 9 | DRIVER_PATH("driver_path"), |
| 10 | DEVICE_NAME("device_name"); | ||
| 10 | 11 | ||
| 11 | override fun getString(needsGlobal: Boolean): String = NativeConfig.getString(key, needsGlobal) | 12 | override fun getString(needsGlobal: Boolean): String = NativeConfig.getString(key, needsGlobal) |
| 12 | 13 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt index 8f724835e..5fdf98318 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt | |||
| @@ -16,6 +16,7 @@ import org.yuzu.yuzu_emu.features.settings.model.ByteSetting | |||
| 16 | import org.yuzu.yuzu_emu.features.settings.model.IntSetting | 16 | import org.yuzu.yuzu_emu.features.settings.model.IntSetting |
| 17 | import org.yuzu.yuzu_emu.features.settings.model.LongSetting | 17 | import org.yuzu.yuzu_emu.features.settings.model.LongSetting |
| 18 | import org.yuzu.yuzu_emu.features.settings.model.ShortSetting | 18 | import org.yuzu.yuzu_emu.features.settings.model.ShortSetting |
| 19 | import org.yuzu.yuzu_emu.features.settings.model.StringSetting | ||
| 19 | import org.yuzu.yuzu_emu.utils.NativeConfig | 20 | import org.yuzu.yuzu_emu.utils.NativeConfig |
| 20 | 21 | ||
| 21 | /** | 22 | /** |
| @@ -75,6 +76,9 @@ abstract class SettingsItem( | |||
| 75 | get() = NativeLibrary.isRunning() && !setting.global && | 76 | get() = NativeLibrary.isRunning() && !setting.global && |
| 76 | !NativeConfig.isPerGameConfigLoaded() | 77 | !NativeConfig.isPerGameConfigLoaded() |
| 77 | 78 | ||
| 79 | val clearable: Boolean | ||
| 80 | get() = !setting.global && NativeConfig.isPerGameConfigLoaded() | ||
| 81 | |||
| 78 | companion object { | 82 | companion object { |
| 79 | const val TYPE_HEADER = 0 | 83 | const val TYPE_HEADER = 0 |
| 80 | const val TYPE_SWITCH = 1 | 84 | const val TYPE_SWITCH = 1 |
| @@ -87,6 +91,7 @@ abstract class SettingsItem( | |||
| 87 | const val TYPE_INPUT = 8 | 91 | const val TYPE_INPUT = 8 |
| 88 | const val TYPE_INT_SINGLE_CHOICE = 9 | 92 | const val TYPE_INT_SINGLE_CHOICE = 9 |
| 89 | const val TYPE_INPUT_PROFILE = 10 | 93 | const val TYPE_INPUT_PROFILE = 10 |
| 94 | const val TYPE_STRING_INPUT = 11 | ||
| 90 | 95 | ||
| 91 | const val FASTMEM_COMBINED = "fastmem_combined" | 96 | const val FASTMEM_COMBINED = "fastmem_combined" |
| 92 | 97 | ||
| @@ -105,6 +110,7 @@ abstract class SettingsItem( | |||
| 105 | 110 | ||
| 106 | // List of all general | 111 | // List of all general |
| 107 | val settingsItems = HashMap<String, SettingsItem>().apply { | 112 | val settingsItems = HashMap<String, SettingsItem>().apply { |
| 113 | put(StringInputSetting(StringSetting.DEVICE_NAME, titleId = R.string.device_name)) | ||
| 108 | put( | 114 | put( |
| 109 | SwitchSetting( | 115 | SwitchSetting( |
| 110 | BooleanSetting.RENDERER_USE_SPEED_LIMIT, | 116 | BooleanSetting.RENDERER_USE_SPEED_LIMIT, |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/StringInputSetting.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/StringInputSetting.kt new file mode 100644 index 000000000..1eb999416 --- /dev/null +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/StringInputSetting.kt | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | // SPDX-FileCopyrightText: 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | package org.yuzu.yuzu_emu.features.settings.model.view | ||
| 5 | |||
| 6 | import androidx.annotation.StringRes | ||
| 7 | import org.yuzu.yuzu_emu.features.settings.model.AbstractStringSetting | ||
| 8 | |||
| 9 | class StringInputSetting( | ||
| 10 | setting: AbstractStringSetting, | ||
| 11 | @StringRes titleId: Int = 0, | ||
| 12 | titleString: String = "", | ||
| 13 | @StringRes descriptionId: Int = 0, | ||
| 14 | descriptionString: String = "" | ||
| 15 | ) : SettingsItem(setting, titleId, titleString, descriptionId, descriptionString) { | ||
| 16 | override val type = TYPE_STRING_INPUT | ||
| 17 | |||
| 18 | fun getSelectedValue(needsGlobal: Boolean = false) = setting.getValueAsString(needsGlobal) | ||
| 19 | |||
| 20 | fun setSelectedValue(selection: String) = | ||
| 21 | (setting as AbstractStringSetting).setString(selection) | ||
| 22 | } | ||
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 45c8faa10..500ac6e66 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 | |||
| @@ -85,6 +85,10 @@ class SettingsAdapter( | |||
| 85 | InputProfileViewHolder(ListItemSettingBinding.inflate(inflater), this) | 85 | InputProfileViewHolder(ListItemSettingBinding.inflate(inflater), this) |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | SettingsItem.TYPE_STRING_INPUT -> { | ||
| 89 | StringInputViewHolder(ListItemSettingBinding.inflate(inflater), this) | ||
| 90 | } | ||
| 91 | |||
| 88 | else -> { | 92 | else -> { |
| 89 | HeaderViewHolder(ListItemSettingsHeaderBinding.inflate(inflater), this) | 93 | HeaderViewHolder(ListItemSettingsHeaderBinding.inflate(inflater), this) |
| 90 | } | 94 | } |
| @@ -392,6 +396,15 @@ class SettingsAdapter( | |||
| 392 | popup.show() | 396 | popup.show() |
| 393 | } | 397 | } |
| 394 | 398 | ||
| 399 | fun onStringInputClick(item: StringInputSetting, position: Int) { | ||
| 400 | SettingsDialogFragment.newInstance( | ||
| 401 | settingsViewModel, | ||
| 402 | item, | ||
| 403 | SettingsItem.TYPE_STRING_INPUT, | ||
| 404 | position | ||
| 405 | ).show(fragment.childFragmentManager, SettingsDialogFragment.TAG) | ||
| 406 | } | ||
| 407 | |||
| 395 | fun onLongClick(item: SettingsItem, position: Int): Boolean { | 408 | fun onLongClick(item: SettingsItem, position: Int): Boolean { |
| 396 | SettingsDialogFragment.newInstance( | 409 | SettingsDialogFragment.newInstance( |
| 397 | settingsViewModel, | 410 | settingsViewModel, |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsDialogFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsDialogFragment.kt index a81ff6b1a..7f562a1f4 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsDialogFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsDialogFragment.kt | |||
| @@ -14,6 +14,7 @@ import androidx.fragment.app.activityViewModels | |||
| 14 | import com.google.android.material.dialog.MaterialAlertDialogBuilder | 14 | import com.google.android.material.dialog.MaterialAlertDialogBuilder |
| 15 | import com.google.android.material.slider.Slider | 15 | import com.google.android.material.slider.Slider |
| 16 | import org.yuzu.yuzu_emu.R | 16 | import org.yuzu.yuzu_emu.R |
| 17 | import org.yuzu.yuzu_emu.databinding.DialogEditTextBinding | ||
| 17 | import org.yuzu.yuzu_emu.databinding.DialogSliderBinding | 18 | import org.yuzu.yuzu_emu.databinding.DialogSliderBinding |
| 18 | import org.yuzu.yuzu_emu.features.input.NativeInput | 19 | import org.yuzu.yuzu_emu.features.input.NativeInput |
| 19 | import org.yuzu.yuzu_emu.features.input.model.AnalogDirection | 20 | import org.yuzu.yuzu_emu.features.input.model.AnalogDirection |
| @@ -23,6 +24,7 @@ import org.yuzu.yuzu_emu.features.settings.model.view.IntSingleChoiceSetting | |||
| 23 | import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem | 24 | import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem |
| 24 | import org.yuzu.yuzu_emu.features.settings.model.view.SingleChoiceSetting | 25 | import org.yuzu.yuzu_emu.features.settings.model.view.SingleChoiceSetting |
| 25 | import org.yuzu.yuzu_emu.features.settings.model.view.SliderSetting | 26 | import org.yuzu.yuzu_emu.features.settings.model.view.SliderSetting |
| 27 | import org.yuzu.yuzu_emu.features.settings.model.view.StringInputSetting | ||
| 26 | import org.yuzu.yuzu_emu.features.settings.model.view.StringSingleChoiceSetting | 28 | import org.yuzu.yuzu_emu.features.settings.model.view.StringSingleChoiceSetting |
| 27 | import org.yuzu.yuzu_emu.utils.ParamPackage | 29 | import org.yuzu.yuzu_emu.utils.ParamPackage |
| 28 | import org.yuzu.yuzu_emu.utils.collect | 30 | import org.yuzu.yuzu_emu.utils.collect |
| @@ -37,6 +39,7 @@ class SettingsDialogFragment : DialogFragment(), DialogInterface.OnClickListener | |||
| 37 | private val settingsViewModel: SettingsViewModel by activityViewModels() | 39 | private val settingsViewModel: SettingsViewModel by activityViewModels() |
| 38 | 40 | ||
| 39 | private lateinit var sliderBinding: DialogSliderBinding | 41 | private lateinit var sliderBinding: DialogSliderBinding |
| 42 | private lateinit var stringInputBinding: DialogEditTextBinding | ||
| 40 | 43 | ||
| 41 | override fun onCreate(savedInstanceState: Bundle?) { | 44 | override fun onCreate(savedInstanceState: Bundle?) { |
| 42 | super.onCreate(savedInstanceState) | 45 | super.onCreate(savedInstanceState) |
| @@ -131,6 +134,18 @@ class SettingsDialogFragment : DialogFragment(), DialogInterface.OnClickListener | |||
| 131 | .create() | 134 | .create() |
| 132 | } | 135 | } |
| 133 | 136 | ||
| 137 | SettingsItem.TYPE_STRING_INPUT -> { | ||
| 138 | stringInputBinding = DialogEditTextBinding.inflate(layoutInflater) | ||
| 139 | val item = settingsViewModel.clickedItem as StringInputSetting | ||
| 140 | stringInputBinding.editText.setText(item.getSelectedValue()) | ||
| 141 | MaterialAlertDialogBuilder(requireContext()) | ||
| 142 | .setTitle(item.title) | ||
| 143 | .setView(stringInputBinding.root) | ||
| 144 | .setPositiveButton(android.R.string.ok, this) | ||
| 145 | .setNegativeButton(android.R.string.cancel, defaultCancelListener) | ||
| 146 | .create() | ||
| 147 | } | ||
| 148 | |||
| 134 | SettingsItem.TYPE_STRING_SINGLE_CHOICE -> { | 149 | SettingsItem.TYPE_STRING_SINGLE_CHOICE -> { |
| 135 | val item = settingsViewModel.clickedItem as StringSingleChoiceSetting | 150 | val item = settingsViewModel.clickedItem as StringSingleChoiceSetting |
| 136 | MaterialAlertDialogBuilder(requireContext()) | 151 | MaterialAlertDialogBuilder(requireContext()) |
| @@ -158,6 +173,7 @@ class SettingsDialogFragment : DialogFragment(), DialogInterface.OnClickListener | |||
| 158 | ): View? { | 173 | ): View? { |
| 159 | return when (type) { | 174 | return when (type) { |
| 160 | SettingsItem.TYPE_SLIDER -> sliderBinding.root | 175 | SettingsItem.TYPE_SLIDER -> sliderBinding.root |
| 176 | SettingsItem.TYPE_STRING_INPUT -> stringInputBinding.root | ||
| 161 | else -> super.onCreateView(inflater, container, savedInstanceState) | 177 | else -> super.onCreateView(inflater, container, savedInstanceState) |
| 162 | } | 178 | } |
| 163 | } | 179 | } |
| @@ -200,6 +216,13 @@ class SettingsDialogFragment : DialogFragment(), DialogInterface.OnClickListener | |||
| 200 | val sliderSetting = settingsViewModel.clickedItem as SliderSetting | 216 | val sliderSetting = settingsViewModel.clickedItem as SliderSetting |
| 201 | sliderSetting.setSelectedValue(settingsViewModel.sliderProgress.value) | 217 | sliderSetting.setSelectedValue(settingsViewModel.sliderProgress.value) |
| 202 | } | 218 | } |
| 219 | |||
| 220 | is StringInputSetting -> { | ||
| 221 | val stringInputSetting = settingsViewModel.clickedItem as StringInputSetting | ||
| 222 | stringInputSetting.setSelectedValue( | ||
| 223 | (stringInputBinding.editText.text ?: "").toString() | ||
| 224 | ) | ||
| 225 | } | ||
| 203 | } | 226 | } |
| 204 | closeDialog() | 227 | closeDialog() |
| 205 | } | 228 | } |
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 e491c29a2..3ea5f5008 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 | |||
| @@ -23,6 +23,7 @@ import org.yuzu.yuzu_emu.features.settings.model.LongSetting | |||
| 23 | import org.yuzu.yuzu_emu.features.settings.model.Settings | 23 | import org.yuzu.yuzu_emu.features.settings.model.Settings |
| 24 | import org.yuzu.yuzu_emu.features.settings.model.Settings.MenuTag | 24 | import org.yuzu.yuzu_emu.features.settings.model.Settings.MenuTag |
| 25 | import org.yuzu.yuzu_emu.features.settings.model.ShortSetting | 25 | import org.yuzu.yuzu_emu.features.settings.model.ShortSetting |
| 26 | import org.yuzu.yuzu_emu.features.settings.model.StringSetting | ||
| 26 | import org.yuzu.yuzu_emu.features.settings.model.view.* | 27 | import org.yuzu.yuzu_emu.features.settings.model.view.* |
| 27 | import org.yuzu.yuzu_emu.utils.InputHandler | 28 | import org.yuzu.yuzu_emu.utils.InputHandler |
| 28 | import org.yuzu.yuzu_emu.utils.NativeConfig | 29 | import org.yuzu.yuzu_emu.utils.NativeConfig |
| @@ -153,6 +154,7 @@ class SettingsFragmentPresenter( | |||
| 153 | 154 | ||
| 154 | private fun addSystemSettings(sl: ArrayList<SettingsItem>) { | 155 | private fun addSystemSettings(sl: ArrayList<SettingsItem>) { |
| 155 | sl.apply { | 156 | sl.apply { |
| 157 | add(StringSetting.DEVICE_NAME.key) | ||
| 156 | add(BooleanSetting.RENDERER_USE_SPEED_LIMIT.key) | 158 | add(BooleanSetting.RENDERER_USE_SPEED_LIMIT.key) |
| 157 | add(ShortSetting.RENDERER_SPEED_LIMIT.key) | 159 | add(ShortSetting.RENDERER_SPEED_LIMIT.key) |
| 158 | add(BooleanSetting.USE_DOCKED_MODE.key) | 160 | add(BooleanSetting.USE_DOCKED_MODE.key) |
| @@ -778,7 +780,7 @@ class SettingsFragmentPresenter( | |||
| 778 | playerIndex: Int, | 780 | playerIndex: Int, |
| 779 | paramName: String, | 781 | paramName: String, |
| 780 | stick: NativeAnalog, | 782 | stick: NativeAnalog, |
| 781 | defaultValue: Int | 783 | defaultValue: Float |
| 782 | ): AbstractIntSetting = | 784 | ): AbstractIntSetting = |
| 783 | object : AbstractIntSetting { | 785 | object : AbstractIntSetting { |
| 784 | val params get() = NativeInput.getStickParam(playerIndex, stick) | 786 | val params get() = NativeInput.getStickParam(playerIndex, stick) |
| @@ -786,7 +788,7 @@ class SettingsFragmentPresenter( | |||
| 786 | override val key = "" | 788 | override val key = "" |
| 787 | 789 | ||
| 788 | override fun getInt(needsGlobal: Boolean): Int = | 790 | override fun getInt(needsGlobal: Boolean): Int = |
| 789 | (params.get(paramName, 0.15f) * 100).toInt() | 791 | (params.get(paramName, defaultValue) * 100).toInt() |
| 790 | 792 | ||
| 791 | override fun setInt(value: Int) { | 793 | override fun setInt(value: Int) { |
| 792 | val tempParams = params | 794 | val tempParams = params |
| @@ -794,12 +796,12 @@ class SettingsFragmentPresenter( | |||
| 794 | NativeInput.setStickParam(playerIndex, stick, tempParams) | 796 | NativeInput.setStickParam(playerIndex, stick, tempParams) |
| 795 | } | 797 | } |
| 796 | 798 | ||
| 797 | override val defaultValue = defaultValue | 799 | override val defaultValue = (defaultValue * 100).toInt() |
| 798 | 800 | ||
| 799 | override fun getValueAsString(needsGlobal: Boolean): String = | 801 | override fun getValueAsString(needsGlobal: Boolean): String = |
| 800 | getInt(needsGlobal).toString() | 802 | getInt(needsGlobal).toString() |
| 801 | 803 | ||
| 802 | override fun reset() = setInt(defaultValue) | 804 | override fun reset() = setInt(this.defaultValue) |
| 803 | } | 805 | } |
| 804 | 806 | ||
| 805 | private fun getExtraStickSettings( | 807 | private fun getExtraStickSettings( |
| @@ -809,11 +811,11 @@ class SettingsFragmentPresenter( | |||
| 809 | val stickIsController = | 811 | val stickIsController = |
| 810 | NativeInput.isController(NativeInput.getStickParam(playerIndex, nativeAnalog)) | 812 | NativeInput.isController(NativeInput.getStickParam(playerIndex, nativeAnalog)) |
| 811 | val modifierRangeSetting = | 813 | val modifierRangeSetting = |
| 812 | getStickIntSettingFromParam(playerIndex, "modifier_scale", nativeAnalog, 50) | 814 | getStickIntSettingFromParam(playerIndex, "modifier_scale", nativeAnalog, 0.5f) |
| 813 | val stickRangeSetting = | 815 | val stickRangeSetting = |
| 814 | getStickIntSettingFromParam(playerIndex, "range", nativeAnalog, 95) | 816 | getStickIntSettingFromParam(playerIndex, "range", nativeAnalog, 0.95f) |
| 815 | val stickDeadzoneSetting = | 817 | val stickDeadzoneSetting = |
| 816 | getStickIntSettingFromParam(playerIndex, "deadzone", nativeAnalog, 15) | 818 | getStickIntSettingFromParam(playerIndex, "deadzone", nativeAnalog, 0.15f) |
| 817 | 819 | ||
| 818 | val out = mutableListOf<SettingsItem>().apply { | 820 | val out = mutableListOf<SettingsItem>().apply { |
| 819 | if (stickIsController) { | 821 | if (stickIsController) { |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/DateTimeViewHolder.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/DateTimeViewHolder.kt index 367db7fd2..0309fad59 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/DateTimeViewHolder.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/DateTimeViewHolder.kt | |||
| @@ -13,7 +13,6 @@ import org.yuzu.yuzu_emu.databinding.ListItemSettingBinding | |||
| 13 | import org.yuzu.yuzu_emu.features.settings.model.view.DateTimeSetting | 13 | import org.yuzu.yuzu_emu.features.settings.model.view.DateTimeSetting |
| 14 | import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem | 14 | import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem |
| 15 | import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter | 15 | import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter |
| 16 | import org.yuzu.yuzu_emu.utils.NativeConfig | ||
| 17 | import org.yuzu.yuzu_emu.utils.ViewUtils.setVisible | 16 | import org.yuzu.yuzu_emu.utils.ViewUtils.setVisible |
| 18 | 17 | ||
| 19 | class DateTimeViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAdapter) : | 18 | class DateTimeViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAdapter) : |
| @@ -32,9 +31,7 @@ class DateTimeViewHolder(val binding: ListItemSettingBinding, adapter: SettingsA | |||
| 32 | val dateFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM) | 31 | val dateFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM) |
| 33 | binding.textSettingValue.text = dateFormatter.format(zonedTime) | 32 | binding.textSettingValue.text = dateFormatter.format(zonedTime) |
| 34 | 33 | ||
| 35 | binding.buttonClear.setVisible( | 34 | binding.buttonClear.setVisible(setting.clearable) |
| 36 | !setting.setting.global || NativeConfig.isPerGameConfigLoaded() | ||
| 37 | ) | ||
| 38 | binding.buttonClear.setOnClickListener { | 35 | binding.buttonClear.setOnClickListener { |
| 39 | adapter.onClearClick(setting, bindingAdapterPosition) | 36 | adapter.onClearClick(setting, bindingAdapterPosition) |
| 40 | } | 37 | } |
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 e2fe0b072..489f55455 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 | |||
| @@ -10,7 +10,6 @@ import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem | |||
| 10 | import org.yuzu.yuzu_emu.features.settings.model.view.SingleChoiceSetting | 10 | import org.yuzu.yuzu_emu.features.settings.model.view.SingleChoiceSetting |
| 11 | import org.yuzu.yuzu_emu.features.settings.model.view.StringSingleChoiceSetting | 11 | import org.yuzu.yuzu_emu.features.settings.model.view.StringSingleChoiceSetting |
| 12 | import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter | 12 | import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter |
| 13 | import org.yuzu.yuzu_emu.utils.NativeConfig | ||
| 14 | import org.yuzu.yuzu_emu.utils.ViewUtils.setVisible | 13 | import org.yuzu.yuzu_emu.utils.ViewUtils.setVisible |
| 15 | 14 | ||
| 16 | class SingleChoiceViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAdapter) : | 15 | class SingleChoiceViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAdapter) : |
| @@ -48,9 +47,7 @@ class SingleChoiceViewHolder(val binding: ListItemSettingBinding, adapter: Setti | |||
| 48 | binding.textSettingValue.setVisible(false) | 47 | binding.textSettingValue.setVisible(false) |
| 49 | } | 48 | } |
| 50 | 49 | ||
| 51 | binding.buttonClear.setVisible( | 50 | binding.buttonClear.setVisible(setting.clearable) |
| 52 | !setting.setting.global || NativeConfig.isPerGameConfigLoaded() | ||
| 53 | ) | ||
| 54 | binding.buttonClear.setOnClickListener { | 51 | binding.buttonClear.setOnClickListener { |
| 55 | adapter.onClearClick(setting, bindingAdapterPosition) | 52 | adapter.onClearClick(setting, bindingAdapterPosition) |
| 56 | } | 53 | } |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SliderViewHolder.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SliderViewHolder.kt index a37b59b44..90a7138cb 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SliderViewHolder.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SliderViewHolder.kt | |||
| @@ -9,7 +9,6 @@ import org.yuzu.yuzu_emu.databinding.ListItemSettingBinding | |||
| 9 | import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem | 9 | import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem |
| 10 | import org.yuzu.yuzu_emu.features.settings.model.view.SliderSetting | 10 | import org.yuzu.yuzu_emu.features.settings.model.view.SliderSetting |
| 11 | import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter | 11 | import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter |
| 12 | import org.yuzu.yuzu_emu.utils.NativeConfig | ||
| 13 | import org.yuzu.yuzu_emu.utils.ViewUtils.setVisible | 12 | import org.yuzu.yuzu_emu.utils.ViewUtils.setVisible |
| 14 | 13 | ||
| 15 | class SliderViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAdapter) : | 14 | class SliderViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAdapter) : |
| @@ -28,9 +27,7 @@ class SliderViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAda | |||
| 28 | setting.units | 27 | setting.units |
| 29 | ) | 28 | ) |
| 30 | 29 | ||
| 31 | binding.buttonClear.setVisible( | 30 | binding.buttonClear.setVisible(setting.clearable) |
| 32 | !setting.setting.global || NativeConfig.isPerGameConfigLoaded() | ||
| 33 | ) | ||
| 34 | binding.buttonClear.setOnClickListener { | 31 | binding.buttonClear.setOnClickListener { |
| 35 | adapter.onClearClick(setting, bindingAdapterPosition) | 32 | adapter.onClearClick(setting, bindingAdapterPosition) |
| 36 | } | 33 | } |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/StringInputViewHolder.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/StringInputViewHolder.kt new file mode 100644 index 000000000..a4fd36f62 --- /dev/null +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/StringInputViewHolder.kt | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | // SPDX-FileCopyrightText: 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | package org.yuzu.yuzu_emu.features.settings.ui.viewholder | ||
| 5 | |||
| 6 | import android.view.View | ||
| 7 | import org.yuzu.yuzu_emu.databinding.ListItemSettingBinding | ||
| 8 | import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem | ||
| 9 | import org.yuzu.yuzu_emu.features.settings.model.view.StringInputSetting | ||
| 10 | import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter | ||
| 11 | import org.yuzu.yuzu_emu.utils.ViewUtils.setVisible | ||
| 12 | |||
| 13 | class StringInputViewHolder(val binding: ListItemSettingBinding, adapter: SettingsAdapter) : | ||
| 14 | SettingViewHolder(binding.root, adapter) { | ||
| 15 | private lateinit var setting: StringInputSetting | ||
| 16 | |||
| 17 | override fun bind(item: SettingsItem) { | ||
| 18 | setting = item as StringInputSetting | ||
| 19 | binding.textSettingName.text = setting.title | ||
| 20 | binding.textSettingDescription.setVisible(setting.description.isNotEmpty()) | ||
| 21 | binding.textSettingDescription.text = setting.description | ||
| 22 | binding.textSettingValue.setVisible(true) | ||
| 23 | binding.textSettingValue.text = setting.getSelectedValue() | ||
| 24 | |||
| 25 | binding.buttonClear.setVisible(setting.clearable) | ||
| 26 | binding.buttonClear.setOnClickListener { | ||
| 27 | adapter.onClearClick(setting, bindingAdapterPosition) | ||
| 28 | } | ||
| 29 | |||
| 30 | setStyle(setting.isEditable, binding) | ||
| 31 | } | ||
| 32 | |||
| 33 | override fun onClick(clicked: View) { | ||
| 34 | if (setting.isEditable) { | ||
| 35 | adapter.onStringInputClick(setting, bindingAdapterPosition) | ||
| 36 | } | ||
| 37 | } | ||
| 38 | |||
| 39 | override fun onLongClick(clicked: View): Boolean { | ||
| 40 | if (setting.isEditable) { | ||
| 41 | return adapter.onLongClick(setting, bindingAdapterPosition) | ||
| 42 | } | ||
| 43 | return false | ||
| 44 | } | ||
| 45 | } | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SwitchSettingViewHolder.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SwitchSettingViewHolder.kt index 53f7b301f..e5763264a 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SwitchSettingViewHolder.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/viewholder/SwitchSettingViewHolder.kt | |||
| @@ -9,7 +9,6 @@ import org.yuzu.yuzu_emu.databinding.ListItemSettingSwitchBinding | |||
| 9 | import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem | 9 | import org.yuzu.yuzu_emu.features.settings.model.view.SettingsItem |
| 10 | import org.yuzu.yuzu_emu.features.settings.model.view.SwitchSetting | 10 | import org.yuzu.yuzu_emu.features.settings.model.view.SwitchSetting |
| 11 | import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter | 11 | import org.yuzu.yuzu_emu.features.settings.ui.SettingsAdapter |
| 12 | import org.yuzu.yuzu_emu.utils.NativeConfig | ||
| 13 | import org.yuzu.yuzu_emu.utils.ViewUtils.setVisible | 12 | import org.yuzu.yuzu_emu.utils.ViewUtils.setVisible |
| 14 | 13 | ||
| 15 | class SwitchSettingViewHolder(val binding: ListItemSettingSwitchBinding, adapter: SettingsAdapter) : | 14 | class SwitchSettingViewHolder(val binding: ListItemSettingSwitchBinding, adapter: SettingsAdapter) : |
| @@ -29,9 +28,7 @@ class SwitchSettingViewHolder(val binding: ListItemSettingSwitchBinding, adapter | |||
| 29 | adapter.onBooleanClick(setting, binding.switchWidget.isChecked, bindingAdapterPosition) | 28 | adapter.onBooleanClick(setting, binding.switchWidget.isChecked, bindingAdapterPosition) |
| 30 | } | 29 | } |
| 31 | 30 | ||
| 32 | binding.buttonClear.setVisible( | 31 | binding.buttonClear.setVisible(setting.clearable) |
| 33 | !setting.setting.global || NativeConfig.isPerGameConfigLoaded() | ||
| 34 | ) | ||
| 35 | binding.buttonClear.setOnClickListener { | 32 | binding.buttonClear.setOnClickListener { |
| 36 | adapter.onClearClick(setting, bindingAdapterPosition) | 33 | adapter.onClearClick(setting, bindingAdapterPosition) |
| 37 | } | 34 | } |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt index c3b2b11f8..bcc880e17 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt | |||
| @@ -810,7 +810,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 810 | } | 810 | } |
| 811 | } | 811 | } |
| 812 | } | 812 | } |
| 813 | binding.doneControlConfig.setVisible(false) | 813 | binding.doneControlConfig.setVisible(true) |
| 814 | binding.surfaceInputOverlay.setIsInEditMode(true) | 814 | binding.surfaceInputOverlay.setIsInEditMode(true) |
| 815 | } | 815 | } |
| 816 | 816 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlay.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlay.kt index 66907085a..737e03584 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlay.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlay.kt | |||
| @@ -28,6 +28,7 @@ import org.yuzu.yuzu_emu.features.input.NativeInput | |||
| 28 | import org.yuzu.yuzu_emu.R | 28 | import org.yuzu.yuzu_emu.R |
| 29 | import org.yuzu.yuzu_emu.features.input.model.NativeAnalog | 29 | import org.yuzu.yuzu_emu.features.input.model.NativeAnalog |
| 30 | import org.yuzu.yuzu_emu.features.input.model.NativeButton | 30 | import org.yuzu.yuzu_emu.features.input.model.NativeButton |
| 31 | import org.yuzu.yuzu_emu.features.input.model.NpadStyleIndex | ||
| 31 | import org.yuzu.yuzu_emu.features.settings.model.BooleanSetting | 32 | import org.yuzu.yuzu_emu.features.settings.model.BooleanSetting |
| 32 | import org.yuzu.yuzu_emu.features.settings.model.IntSetting | 33 | import org.yuzu.yuzu_emu.features.settings.model.IntSetting |
| 33 | import org.yuzu.yuzu_emu.overlay.model.OverlayControl | 34 | import org.yuzu.yuzu_emu.overlay.model.OverlayControl |
| @@ -99,12 +100,10 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : | |||
| 99 | } | 100 | } |
| 100 | 101 | ||
| 101 | var shouldUpdateView = false | 102 | var shouldUpdateView = false |
| 102 | val playerIndex = | 103 | val playerIndex = when (NativeInput.getStyleIndex(0)) { |
| 103 | if (NativeInput.isHandheldOnly()) { | 104 | NpadStyleIndex.Handheld -> 8 |
| 104 | NativeInput.ConsoleDevice | 105 | else -> 0 |
| 105 | } else { | 106 | } |
| 106 | NativeInput.Player1Device | ||
| 107 | } | ||
| 108 | 107 | ||
| 109 | for (button in overlayButtons) { | 108 | for (button in overlayButtons) { |
| 110 | if (!button.updateStatus(event)) { | 109 | if (!button.updateStatus(event)) { |
| @@ -664,7 +663,7 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : | |||
| 664 | 663 | ||
| 665 | val overlayControlData = NativeConfig.getOverlayControlData() | 664 | val overlayControlData = NativeConfig.getOverlayControlData() |
| 666 | overlayControlData.forEach { | 665 | overlayControlData.forEach { |
| 667 | it.enabled = OverlayControl.from(it.id)?.defaultVisibility == false | 666 | it.enabled = OverlayControl.from(it.id)?.defaultVisibility == true |
| 668 | } | 667 | } |
| 669 | NativeConfig.setOverlayControlData(overlayControlData) | 668 | NativeConfig.setOverlayControlData(overlayControlData) |
| 670 | 669 | ||
diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 4ea82e217..1226219ad 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp | |||
| @@ -292,6 +292,9 @@ void EmulationSession::ShutdownEmulation() { | |||
| 292 | // Unload user input. | 292 | // Unload user input. |
| 293 | m_system.HIDCore().UnloadInputDevices(); | 293 | m_system.HIDCore().UnloadInputDevices(); |
| 294 | 294 | ||
| 295 | // Enable all controllers | ||
| 296 | m_system.HIDCore().SetSupportedStyleTag({Core::HID::NpadStyleSet::All}); | ||
| 297 | |||
| 295 | // Shutdown the main emulated process | 298 | // Shutdown the main emulated process |
| 296 | if (m_load_result == Core::SystemResultStatus::Success) { | 299 | if (m_load_result == Core::SystemResultStatus::Success) { |
| 297 | m_system.DetachDebugger(); | 300 | m_system.DetachDebugger(); |
diff --git a/src/android/app/src/main/jni/native_input.cpp b/src/android/app/src/main/jni/native_input.cpp index 37a65f2b8..4935a4607 100644 --- a/src/android/app/src/main/jni/native_input.cpp +++ b/src/android/app/src/main/jni/native_input.cpp | |||
| @@ -102,8 +102,50 @@ void ApplyControllerConfig(size_t player_index, | |||
| 102 | } | 102 | } |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | std::vector<s32> GetSupportedStyles(int player_index) { | ||
| 106 | auto& hid_core = EmulationSession::GetInstance().System().HIDCore(); | ||
| 107 | const auto npad_style_set = hid_core.GetSupportedStyleTag(); | ||
| 108 | std::vector<s32> supported_indexes; | ||
| 109 | if (npad_style_set.fullkey == 1) { | ||
| 110 | supported_indexes.push_back(static_cast<s32>(Core::HID::NpadStyleIndex::Fullkey)); | ||
| 111 | } | ||
| 112 | |||
| 113 | if (npad_style_set.joycon_dual == 1) { | ||
| 114 | supported_indexes.push_back(static_cast<s32>(Core::HID::NpadStyleIndex::JoyconDual)); | ||
| 115 | } | ||
| 116 | |||
| 117 | if (npad_style_set.joycon_left == 1) { | ||
| 118 | supported_indexes.push_back(static_cast<s32>(Core::HID::NpadStyleIndex::JoyconLeft)); | ||
| 119 | } | ||
| 120 | |||
| 121 | if (npad_style_set.joycon_right == 1) { | ||
| 122 | supported_indexes.push_back(static_cast<s32>(Core::HID::NpadStyleIndex::JoyconRight)); | ||
| 123 | } | ||
| 124 | |||
| 125 | if (player_index == 0 && npad_style_set.handheld == 1) { | ||
| 126 | supported_indexes.push_back(static_cast<s32>(Core::HID::NpadStyleIndex::Handheld)); | ||
| 127 | } | ||
| 128 | |||
| 129 | if (npad_style_set.gamecube == 1) { | ||
| 130 | supported_indexes.push_back(static_cast<s32>(Core::HID::NpadStyleIndex::GameCube)); | ||
| 131 | } | ||
| 132 | |||
| 133 | return supported_indexes; | ||
| 134 | } | ||
| 135 | |||
| 105 | void ConnectController(size_t player_index, bool connected) { | 136 | void ConnectController(size_t player_index, bool connected) { |
| 106 | auto& hid_core = EmulationSession::GetInstance().System().HIDCore(); | 137 | auto& hid_core = EmulationSession::GetInstance().System().HIDCore(); |
| 138 | ApplyControllerConfig(player_index, [&](Core::HID::EmulatedController* controller) { | ||
| 139 | auto supported_styles = GetSupportedStyles(player_index); | ||
| 140 | auto controller_style = controller->GetNpadStyleIndex(true); | ||
| 141 | auto style = std::find(supported_styles.begin(), supported_styles.end(), | ||
| 142 | static_cast<int>(controller_style)); | ||
| 143 | if (style == supported_styles.end() && !supported_styles.empty()) { | ||
| 144 | controller->SetNpadStyleIndex( | ||
| 145 | static_cast<Core::HID::NpadStyleIndex>(supported_styles[0])); | ||
| 146 | } | ||
| 147 | }); | ||
| 148 | |||
| 107 | if (player_index == 0) { | 149 | if (player_index == 0) { |
| 108 | auto* handheld = hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld); | 150 | auto* handheld = hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld); |
| 109 | auto* player_one = hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1); | 151 | auto* player_one = hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1); |
| @@ -522,36 +564,10 @@ jint Java_org_yuzu_yuzu_1emu_features_input_NativeInput_getButtonNameImpl(JNIEnv | |||
| 522 | 564 | ||
| 523 | jintArray Java_org_yuzu_yuzu_1emu_features_input_NativeInput_getSupportedStyleTagsImpl( | 565 | jintArray Java_org_yuzu_yuzu_1emu_features_input_NativeInput_getSupportedStyleTagsImpl( |
| 524 | JNIEnv* env, jobject j_obj, jint j_player_index) { | 566 | JNIEnv* env, jobject j_obj, jint j_player_index) { |
| 525 | auto& hid_core = EmulationSession::GetInstance().System().HIDCore(); | 567 | auto supported_styles = GetSupportedStyles(j_player_index); |
| 526 | const auto npad_style_set = hid_core.GetSupportedStyleTag(); | 568 | jintArray j_supported_indexes = env->NewIntArray(supported_styles.size()); |
| 527 | std::vector<s32> supported_indexes; | 569 | env->SetIntArrayRegion(j_supported_indexes, 0, supported_styles.size(), |
| 528 | if (npad_style_set.fullkey == 1) { | 570 | supported_styles.data()); |
| 529 | supported_indexes.push_back(static_cast<u32>(Core::HID::NpadStyleIndex::Fullkey)); | ||
| 530 | } | ||
| 531 | |||
| 532 | if (npad_style_set.joycon_dual == 1) { | ||
| 533 | supported_indexes.push_back(static_cast<u32>(Core::HID::NpadStyleIndex::JoyconDual)); | ||
| 534 | } | ||
| 535 | |||
| 536 | if (npad_style_set.joycon_left == 1) { | ||
| 537 | supported_indexes.push_back(static_cast<u32>(Core::HID::NpadStyleIndex::JoyconLeft)); | ||
| 538 | } | ||
| 539 | |||
| 540 | if (npad_style_set.joycon_right == 1) { | ||
| 541 | supported_indexes.push_back(static_cast<u32>(Core::HID::NpadStyleIndex::JoyconRight)); | ||
| 542 | } | ||
| 543 | |||
| 544 | if (j_player_index == 0 && npad_style_set.handheld == 1) { | ||
| 545 | supported_indexes.push_back(static_cast<u32>(Core::HID::NpadStyleIndex::Handheld)); | ||
| 546 | } | ||
| 547 | |||
| 548 | if (npad_style_set.gamecube == 1) { | ||
| 549 | supported_indexes.push_back(static_cast<u32>(Core::HID::NpadStyleIndex::GameCube)); | ||
| 550 | } | ||
| 551 | |||
| 552 | jintArray j_supported_indexes = env->NewIntArray(supported_indexes.size()); | ||
| 553 | env->SetIntArrayRegion(j_supported_indexes, 0, supported_indexes.size(), | ||
| 554 | supported_indexes.data()); | ||
| 555 | return j_supported_indexes; | 571 | return j_supported_indexes; |
| 556 | } | 572 | } |
| 557 | 573 | ||
diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index 6a631f664..f7f19cdad 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml | |||
| @@ -209,6 +209,7 @@ | |||
| 209 | <string name="value_with_units">%1$s%2$s</string> | 209 | <string name="value_with_units">%1$s%2$s</string> |
| 210 | 210 | ||
| 211 | <!-- System settings strings --> | 211 | <!-- System settings strings --> |
| 212 | <string name="device_name">Device name</string> | ||
| 212 | <string name="use_docked_mode">Docked Mode</string> | 213 | <string name="use_docked_mode">Docked Mode</string> |
| 213 | <string name="use_docked_mode_description">Increases resolution, decreasing performance. Handheld Mode is used when disabled, lowering resolution and increasing performance.</string> | 214 | <string name="use_docked_mode_description">Increases resolution, decreasing performance. Handheld Mode is used when disabled, lowering resolution and increasing performance.</string> |
| 214 | <string name="emulated_region">Emulated region</string> | 215 | <string name="emulated_region">Emulated region</string> |
diff --git a/src/common/settings.h b/src/common/settings.h index aa054dc24..b2b071e7e 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -384,6 +384,12 @@ struct Values { | |||
| 384 | AstcRecompression::Bc3, | 384 | AstcRecompression::Bc3, |
| 385 | "astc_recompression", | 385 | "astc_recompression", |
| 386 | Category::RendererAdvanced}; | 386 | Category::RendererAdvanced}; |
| 387 | SwitchableSetting<VramUsageMode, true> vram_usage_mode{linkage, | ||
| 388 | VramUsageMode::Conservative, | ||
| 389 | VramUsageMode::Conservative, | ||
| 390 | VramUsageMode::Aggressive, | ||
| 391 | "vram_usage_mode", | ||
| 392 | Category::RendererAdvanced}; | ||
| 387 | SwitchableSetting<bool> async_presentation{linkage, | 393 | SwitchableSetting<bool> async_presentation{linkage, |
| 388 | #ifdef ANDROID | 394 | #ifdef ANDROID |
| 389 | true, | 395 | true, |
diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index f42367e67..6e247e930 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h | |||
| @@ -122,6 +122,8 @@ ENUM(AstcRecompression, Uncompressed, Bc1, Bc3); | |||
| 122 | 122 | ||
| 123 | ENUM(VSyncMode, Immediate, Mailbox, Fifo, FifoRelaxed); | 123 | ENUM(VSyncMode, Immediate, Mailbox, Fifo, FifoRelaxed); |
| 124 | 124 | ||
| 125 | ENUM(VramUsageMode, Conservative, Aggressive); | ||
| 126 | |||
| 125 | ENUM(RendererBackend, OpenGL, Vulkan, Null); | 127 | ENUM(RendererBackend, OpenGL, Vulkan, Null); |
| 126 | 128 | ||
| 127 | ENUM(ShaderBackend, Glsl, Glasm, SpirV); | 129 | ENUM(ShaderBackend, Glsl, Glasm, SpirV); |
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 24dcc405f..cfce352c9 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -547,6 +547,16 @@ add_library(core STATIC | |||
| 547 | hle/service/btdrv/btdrv.h | 547 | hle/service/btdrv/btdrv.h |
| 548 | hle/service/btm/btm.cpp | 548 | hle/service/btm/btm.cpp |
| 549 | hle/service/btm/btm.h | 549 | hle/service/btm/btm.h |
| 550 | hle/service/btm/btm_debug.cpp | ||
| 551 | hle/service/btm/btm_debug.h | ||
| 552 | hle/service/btm/btm_system.cpp | ||
| 553 | hle/service/btm/btm_system.h | ||
| 554 | hle/service/btm/btm_system_core.cpp | ||
| 555 | hle/service/btm/btm_system_core.h | ||
| 556 | hle/service/btm/btm_user.cpp | ||
| 557 | hle/service/btm/btm_user.h | ||
| 558 | hle/service/btm/btm_user_core.cpp | ||
| 559 | hle/service/btm/btm_user_core.h | ||
| 550 | hle/service/caps/caps.cpp | 560 | hle/service/caps/caps.cpp |
| 551 | hle/service/caps/caps.h | 561 | hle/service/caps/caps.h |
| 552 | hle/service/caps/caps_a.cpp | 562 | hle/service/caps/caps_a.cpp |
diff --git a/src/core/device_memory_manager.inc b/src/core/device_memory_manager.inc index 37c1e69c3..f104d495b 100644 --- a/src/core/device_memory_manager.inc +++ b/src/core/device_memory_manager.inc | |||
| @@ -522,13 +522,17 @@ void DeviceMemoryManager<Traits>::UpdatePagesCachedCount(DAddr addr, size_t size | |||
| 522 | auto* memory_device_inter = registered_processes[asid.id]; | 522 | auto* memory_device_inter = registered_processes[asid.id]; |
| 523 | const auto release_pending = [&] { | 523 | const auto release_pending = [&] { |
| 524 | if (uncache_bytes > 0) { | 524 | if (uncache_bytes > 0) { |
| 525 | MarkRegionCaching(memory_device_inter, uncache_begin << Memory::YUZU_PAGEBITS, | 525 | if (memory_device_inter != nullptr) { |
| 526 | uncache_bytes, false); | 526 | MarkRegionCaching(memory_device_inter, uncache_begin << Memory::YUZU_PAGEBITS, |
| 527 | uncache_bytes, false); | ||
| 528 | } | ||
| 527 | uncache_bytes = 0; | 529 | uncache_bytes = 0; |
| 528 | } | 530 | } |
| 529 | if (cache_bytes > 0) { | 531 | if (cache_bytes > 0) { |
| 530 | MarkRegionCaching(memory_device_inter, cache_begin << Memory::YUZU_PAGEBITS, | 532 | if (memory_device_inter != nullptr) { |
| 531 | cache_bytes, true); | 533 | MarkRegionCaching(memory_device_inter, cache_begin << Memory::YUZU_PAGEBITS, |
| 534 | cache_bytes, true); | ||
| 535 | } | ||
| 532 | cache_bytes = 0; | 536 | cache_bytes = 0; |
| 533 | } | 537 | } |
| 534 | }; | 538 | }; |
diff --git a/src/core/file_sys/fssystem/fssystem_aes_xts_storage.h b/src/core/file_sys/fssystem/fssystem_aes_xts_storage.h index f342efb57..0e83ca1b9 100644 --- a/src/core/file_sys/fssystem/fssystem_aes_xts_storage.h +++ b/src/core/file_sys/fssystem/fssystem_aes_xts_storage.h | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <mutex> | ||
| 6 | #include <optional> | 7 | #include <optional> |
| 7 | 8 | ||
| 8 | #include "core/crypto/aes_util.h" | 9 | #include "core/crypto/aes_util.h" |
diff --git a/src/core/hle/service/btm/btm.cpp b/src/core/hle/service/btm/btm.cpp index 2dc23e674..d120dade8 100644 --- a/src/core/hle/service/btm/btm.cpp +++ b/src/core/hle/service/btm/btm.cpp | |||
| @@ -3,141 +3,18 @@ | |||
| 3 | 3 | ||
| 4 | #include <memory> | 4 | #include <memory> |
| 5 | 5 | ||
| 6 | #include "common/logging/log.h" | ||
| 7 | #include "core/core.h" | ||
| 8 | #include "core/hle/kernel/k_event.h" | ||
| 9 | #include "core/hle/service/btm/btm.h" | 6 | #include "core/hle/service/btm/btm.h" |
| 10 | #include "core/hle/service/ipc_helpers.h" | 7 | #include "core/hle/service/btm/btm_debug.h" |
| 11 | #include "core/hle/service/kernel_helpers.h" | 8 | #include "core/hle/service/btm/btm_system.h" |
| 9 | #include "core/hle/service/btm/btm_user.h" | ||
| 12 | #include "core/hle/service/server_manager.h" | 10 | #include "core/hle/service/server_manager.h" |
| 13 | #include "core/hle/service/service.h" | 11 | #include "core/hle/service/service.h" |
| 14 | 12 | ||
| 15 | namespace Service::BTM { | 13 | namespace Service::BTM { |
| 16 | 14 | ||
| 17 | class IBtmUserCore final : public ServiceFramework<IBtmUserCore> { | 15 | class IBtm final : public ServiceFramework<IBtm> { |
| 18 | public: | 16 | public: |
| 19 | explicit IBtmUserCore(Core::System& system_) | 17 | explicit IBtm(Core::System& system_) : ServiceFramework{system_, "btm"} { |
| 20 | : ServiceFramework{system_, "IBtmUserCore"}, service_context{system_, "IBtmUserCore"} { | ||
| 21 | // clang-format off | ||
| 22 | static const FunctionInfo functions[] = { | ||
| 23 | {0, &IBtmUserCore::AcquireBleScanEvent, "AcquireBleScanEvent"}, | ||
| 24 | {1, nullptr, "GetBleScanFilterParameter"}, | ||
| 25 | {2, nullptr, "GetBleScanFilterParameter2"}, | ||
| 26 | {3, nullptr, "StartBleScanForGeneral"}, | ||
| 27 | {4, nullptr, "StopBleScanForGeneral"}, | ||
| 28 | {5, nullptr, "GetBleScanResultsForGeneral"}, | ||
| 29 | {6, nullptr, "StartBleScanForPaired"}, | ||
| 30 | {7, nullptr, "StopBleScanForPaired"}, | ||
| 31 | {8, nullptr, "StartBleScanForSmartDevice"}, | ||
| 32 | {9, nullptr, "StopBleScanForSmartDevice"}, | ||
| 33 | {10, nullptr, "GetBleScanResultsForSmartDevice"}, | ||
| 34 | {17, &IBtmUserCore::AcquireBleConnectionEvent, "AcquireBleConnectionEvent"}, | ||
| 35 | {18, nullptr, "BleConnect"}, | ||
| 36 | {19, nullptr, "BleDisconnect"}, | ||
| 37 | {20, nullptr, "BleGetConnectionState"}, | ||
| 38 | {21, nullptr, "AcquireBlePairingEvent"}, | ||
| 39 | {22, nullptr, "BlePairDevice"}, | ||
| 40 | {23, nullptr, "BleUnPairDevice"}, | ||
| 41 | {24, nullptr, "BleUnPairDevice2"}, | ||
| 42 | {25, nullptr, "BleGetPairedDevices"}, | ||
| 43 | {26, &IBtmUserCore::AcquireBleServiceDiscoveryEvent, "AcquireBleServiceDiscoveryEvent"}, | ||
| 44 | {27, nullptr, "GetGattServices"}, | ||
| 45 | {28, nullptr, "GetGattService"}, | ||
| 46 | {29, nullptr, "GetGattIncludedServices"}, | ||
| 47 | {30, nullptr, "GetBelongingGattService"}, | ||
| 48 | {31, nullptr, "GetGattCharacteristics"}, | ||
| 49 | {32, nullptr, "GetGattDescriptors"}, | ||
| 50 | {33, &IBtmUserCore::AcquireBleMtuConfigEvent, "AcquireBleMtuConfigEvent"}, | ||
| 51 | {34, nullptr, "ConfigureBleMtu"}, | ||
| 52 | {35, nullptr, "GetBleMtu"}, | ||
| 53 | {36, nullptr, "RegisterBleGattDataPath"}, | ||
| 54 | {37, nullptr, "UnregisterBleGattDataPath"}, | ||
| 55 | }; | ||
| 56 | // clang-format on | ||
| 57 | RegisterHandlers(functions); | ||
| 58 | |||
| 59 | scan_event = service_context.CreateEvent("IBtmUserCore:ScanEvent"); | ||
| 60 | connection_event = service_context.CreateEvent("IBtmUserCore:ConnectionEvent"); | ||
| 61 | service_discovery_event = service_context.CreateEvent("IBtmUserCore:DiscoveryEvent"); | ||
| 62 | config_event = service_context.CreateEvent("IBtmUserCore:ConfigEvent"); | ||
| 63 | } | ||
| 64 | |||
| 65 | ~IBtmUserCore() override { | ||
| 66 | service_context.CloseEvent(scan_event); | ||
| 67 | service_context.CloseEvent(connection_event); | ||
| 68 | service_context.CloseEvent(service_discovery_event); | ||
| 69 | service_context.CloseEvent(config_event); | ||
| 70 | } | ||
| 71 | |||
| 72 | private: | ||
| 73 | void AcquireBleScanEvent(HLERequestContext& ctx) { | ||
| 74 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 75 | |||
| 76 | IPC::ResponseBuilder rb{ctx, 3, 1}; | ||
| 77 | rb.Push(ResultSuccess); | ||
| 78 | rb.Push(true); | ||
| 79 | rb.PushCopyObjects(scan_event->GetReadableEvent()); | ||
| 80 | } | ||
| 81 | |||
| 82 | void AcquireBleConnectionEvent(HLERequestContext& ctx) { | ||
| 83 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 84 | |||
| 85 | IPC::ResponseBuilder rb{ctx, 3, 1}; | ||
| 86 | rb.Push(ResultSuccess); | ||
| 87 | rb.Push(true); | ||
| 88 | rb.PushCopyObjects(connection_event->GetReadableEvent()); | ||
| 89 | } | ||
| 90 | |||
| 91 | void AcquireBleServiceDiscoveryEvent(HLERequestContext& ctx) { | ||
| 92 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 93 | |||
| 94 | IPC::ResponseBuilder rb{ctx, 3, 1}; | ||
| 95 | rb.Push(ResultSuccess); | ||
| 96 | rb.Push(true); | ||
| 97 | rb.PushCopyObjects(service_discovery_event->GetReadableEvent()); | ||
| 98 | } | ||
| 99 | |||
| 100 | void AcquireBleMtuConfigEvent(HLERequestContext& ctx) { | ||
| 101 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 102 | |||
| 103 | IPC::ResponseBuilder rb{ctx, 3, 1}; | ||
| 104 | rb.Push(ResultSuccess); | ||
| 105 | rb.Push(true); | ||
| 106 | rb.PushCopyObjects(config_event->GetReadableEvent()); | ||
| 107 | } | ||
| 108 | |||
| 109 | KernelHelpers::ServiceContext service_context; | ||
| 110 | |||
| 111 | Kernel::KEvent* scan_event; | ||
| 112 | Kernel::KEvent* connection_event; | ||
| 113 | Kernel::KEvent* service_discovery_event; | ||
| 114 | Kernel::KEvent* config_event; | ||
| 115 | }; | ||
| 116 | |||
| 117 | class BTM_USR final : public ServiceFramework<BTM_USR> { | ||
| 118 | public: | ||
| 119 | explicit BTM_USR(Core::System& system_) : ServiceFramework{system_, "btm:u"} { | ||
| 120 | // clang-format off | ||
| 121 | static const FunctionInfo functions[] = { | ||
| 122 | {0, &BTM_USR::GetCore, "GetCore"}, | ||
| 123 | }; | ||
| 124 | // clang-format on | ||
| 125 | RegisterHandlers(functions); | ||
| 126 | } | ||
| 127 | |||
| 128 | private: | ||
| 129 | void GetCore(HLERequestContext& ctx) { | ||
| 130 | LOG_WARNING(Service_BTM, "called"); | ||
| 131 | |||
| 132 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | ||
| 133 | rb.Push(ResultSuccess); | ||
| 134 | rb.PushIpcInterface<IBtmUserCore>(system); | ||
| 135 | } | ||
| 136 | }; | ||
| 137 | |||
| 138 | class BTM final : public ServiceFramework<BTM> { | ||
| 139 | public: | ||
| 140 | explicit BTM(Core::System& system_) : ServiceFramework{system_, "btm"} { | ||
| 141 | // clang-format off | 18 | // clang-format off |
| 142 | static const FunctionInfo functions[] = { | 19 | static const FunctionInfo functions[] = { |
| 143 | {0, nullptr, "GetState"}, | 20 | {0, nullptr, "GetState"}, |
| @@ -232,144 +109,13 @@ public: | |||
| 232 | } | 109 | } |
| 233 | }; | 110 | }; |
| 234 | 111 | ||
| 235 | class BTM_DBG final : public ServiceFramework<BTM_DBG> { | ||
| 236 | public: | ||
| 237 | explicit BTM_DBG(Core::System& system_) : ServiceFramework{system_, "btm:dbg"} { | ||
| 238 | // clang-format off | ||
| 239 | static const FunctionInfo functions[] = { | ||
| 240 | {0, nullptr, "AcquireDiscoveryEvent"}, | ||
| 241 | {1, nullptr, "StartDiscovery"}, | ||
| 242 | {2, nullptr, "CancelDiscovery"}, | ||
| 243 | {3, nullptr, "GetDeviceProperty"}, | ||
| 244 | {4, nullptr, "CreateBond"}, | ||
| 245 | {5, nullptr, "CancelBond"}, | ||
| 246 | {6, nullptr, "SetTsiMode"}, | ||
| 247 | {7, nullptr, "GeneralTest"}, | ||
| 248 | {8, nullptr, "HidConnect"}, | ||
| 249 | {9, nullptr, "GeneralGet"}, | ||
| 250 | {10, nullptr, "GetGattClientDisconnectionReason"}, | ||
| 251 | {11, nullptr, "GetBleConnectionParameter"}, | ||
| 252 | {12, nullptr, "GetBleConnectionParameterRequest"}, | ||
| 253 | {13, nullptr, "Unknown13"}, | ||
| 254 | }; | ||
| 255 | // clang-format on | ||
| 256 | |||
| 257 | RegisterHandlers(functions); | ||
| 258 | } | ||
| 259 | }; | ||
| 260 | |||
| 261 | class IBtmSystemCore final : public ServiceFramework<IBtmSystemCore> { | ||
| 262 | public: | ||
| 263 | explicit IBtmSystemCore(Core::System& system_) : ServiceFramework{system_, "IBtmSystemCore"} { | ||
| 264 | // clang-format off | ||
| 265 | static const FunctionInfo functions[] = { | ||
| 266 | {0, &IBtmSystemCore::StartGamepadPairing, "StartGamepadPairing"}, | ||
| 267 | {1, &IBtmSystemCore::CancelGamepadPairing, "CancelGamepadPairing"}, | ||
| 268 | {2, nullptr, "ClearGamepadPairingDatabase"}, | ||
| 269 | {3, nullptr, "GetPairedGamepadCount"}, | ||
| 270 | {4, nullptr, "EnableRadio"}, | ||
| 271 | {5, nullptr, "DisableRadio"}, | ||
| 272 | {6, &IBtmSystemCore::IsRadioEnabled, "IsRadioEnabled"}, | ||
| 273 | {7, nullptr, "AcquireRadioEvent"}, | ||
| 274 | {8, nullptr, "AcquireGamepadPairingEvent"}, | ||
| 275 | {9, nullptr, "IsGamepadPairingStarted"}, | ||
| 276 | {10, nullptr, "StartAudioDeviceDiscovery"}, | ||
| 277 | {11, nullptr, "StopAudioDeviceDiscovery"}, | ||
| 278 | {12, nullptr, "IsDiscoveryingAudioDevice"}, | ||
| 279 | {13, nullptr, "GetDiscoveredAudioDevice"}, | ||
| 280 | {14, nullptr, "AcquireAudioDeviceConnectionEvent"}, | ||
| 281 | {15, nullptr, "ConnectAudioDevice"}, | ||
| 282 | {16, nullptr, "IsConnectingAudioDevice"}, | ||
| 283 | {17, &IBtmSystemCore::GetConnectedAudioDevices, "GetConnectedAudioDevices"}, | ||
| 284 | {18, nullptr, "DisconnectAudioDevice"}, | ||
| 285 | {19, nullptr, "AcquirePairedAudioDeviceInfoChangedEvent"}, | ||
| 286 | {20, &IBtmSystemCore::GetPairedAudioDevices, "GetPairedAudioDevices"}, | ||
| 287 | {21, nullptr, "RemoveAudioDevicePairing"}, | ||
| 288 | {22, &IBtmSystemCore::RequestAudioDeviceConnectionRejection, "RequestAudioDeviceConnectionRejection"}, | ||
| 289 | {23, &IBtmSystemCore::CancelAudioDeviceConnectionRejection, "CancelAudioDeviceConnectionRejection"} | ||
| 290 | }; | ||
| 291 | // clang-format on | ||
| 292 | |||
| 293 | RegisterHandlers(functions); | ||
| 294 | } | ||
| 295 | |||
| 296 | private: | ||
| 297 | void IsRadioEnabled(HLERequestContext& ctx) { | ||
| 298 | LOG_DEBUG(Service_BTM, "(STUBBED) called"); // Spams a lot when controller applet is running | ||
| 299 | |||
| 300 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 301 | rb.Push(ResultSuccess); | ||
| 302 | rb.Push(true); | ||
| 303 | } | ||
| 304 | |||
| 305 | void StartGamepadPairing(HLERequestContext& ctx) { | ||
| 306 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 307 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 308 | rb.Push(ResultSuccess); | ||
| 309 | } | ||
| 310 | |||
| 311 | void CancelGamepadPairing(HLERequestContext& ctx) { | ||
| 312 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 313 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 314 | rb.Push(ResultSuccess); | ||
| 315 | } | ||
| 316 | |||
| 317 | void CancelAudioDeviceConnectionRejection(HLERequestContext& ctx) { | ||
| 318 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 319 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 320 | rb.Push(ResultSuccess); | ||
| 321 | } | ||
| 322 | |||
| 323 | void GetConnectedAudioDevices(HLERequestContext& ctx) { | ||
| 324 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 325 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 326 | rb.Push(ResultSuccess); | ||
| 327 | rb.Push<u32>(0); | ||
| 328 | } | ||
| 329 | |||
| 330 | void GetPairedAudioDevices(HLERequestContext& ctx) { | ||
| 331 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 332 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 333 | rb.Push(ResultSuccess); | ||
| 334 | rb.Push<u32>(0); | ||
| 335 | } | ||
| 336 | |||
| 337 | void RequestAudioDeviceConnectionRejection(HLERequestContext& ctx) { | ||
| 338 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 339 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 340 | rb.Push(ResultSuccess); | ||
| 341 | } | ||
| 342 | }; | ||
| 343 | |||
| 344 | class BTM_SYS final : public ServiceFramework<BTM_SYS> { | ||
| 345 | public: | ||
| 346 | explicit BTM_SYS(Core::System& system_) : ServiceFramework{system_, "btm:sys"} { | ||
| 347 | // clang-format off | ||
| 348 | static const FunctionInfo functions[] = { | ||
| 349 | {0, &BTM_SYS::GetCore, "GetCore"}, | ||
| 350 | }; | ||
| 351 | // clang-format on | ||
| 352 | |||
| 353 | RegisterHandlers(functions); | ||
| 354 | } | ||
| 355 | |||
| 356 | private: | ||
| 357 | void GetCore(HLERequestContext& ctx) { | ||
| 358 | LOG_WARNING(Service_BTM, "called"); | ||
| 359 | |||
| 360 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | ||
| 361 | rb.Push(ResultSuccess); | ||
| 362 | rb.PushIpcInterface<IBtmSystemCore>(system); | ||
| 363 | } | ||
| 364 | }; | ||
| 365 | |||
| 366 | void LoopProcess(Core::System& system) { | 112 | void LoopProcess(Core::System& system) { |
| 367 | auto server_manager = std::make_unique<ServerManager>(system); | 113 | auto server_manager = std::make_unique<ServerManager>(system); |
| 368 | 114 | ||
| 369 | server_manager->RegisterNamedService("btm", std::make_shared<BTM>(system)); | 115 | server_manager->RegisterNamedService("btm", std::make_shared<IBtm>(system)); |
| 370 | server_manager->RegisterNamedService("btm:dbg", std::make_shared<BTM_DBG>(system)); | 116 | server_manager->RegisterNamedService("btm:dbg", std::make_shared<IBtmDebug>(system)); |
| 371 | server_manager->RegisterNamedService("btm:sys", std::make_shared<BTM_SYS>(system)); | 117 | server_manager->RegisterNamedService("btm:sys", std::make_shared<IBtmSystem>(system)); |
| 372 | server_manager->RegisterNamedService("btm:u", std::make_shared<BTM_USR>(system)); | 118 | server_manager->RegisterNamedService("btm:u", std::make_shared<IBtmUser>(system)); |
| 373 | ServerManager::RunServer(std::move(server_manager)); | 119 | ServerManager::RunServer(std::move(server_manager)); |
| 374 | } | 120 | } |
| 375 | 121 | ||
diff --git a/src/core/hle/service/btm/btm.h b/src/core/hle/service/btm/btm.h index a99b34364..0bf77d053 100644 --- a/src/core/hle/service/btm/btm.h +++ b/src/core/hle/service/btm/btm.h | |||
| @@ -3,10 +3,6 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | namespace Service::SM { | ||
| 7 | class ServiceManager; | ||
| 8 | } | ||
| 9 | |||
| 10 | namespace Core { | 6 | namespace Core { |
| 11 | class System; | 7 | class System; |
| 12 | }; | 8 | }; |
diff --git a/src/core/hle/service/btm/btm_debug.cpp b/src/core/hle/service/btm/btm_debug.cpp new file mode 100644 index 000000000..4d61d2641 --- /dev/null +++ b/src/core/hle/service/btm/btm_debug.cpp | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #include "core/hle/service/btm/btm_debug.h" | ||
| 5 | |||
| 6 | namespace Service::BTM { | ||
| 7 | |||
| 8 | IBtmDebug::IBtmDebug(Core::System& system_) : ServiceFramework{system_, "btm:dbg"} { | ||
| 9 | // clang-format off | ||
| 10 | static const FunctionInfo functions[] = { | ||
| 11 | {0, nullptr, "AcquireDiscoveryEvent"}, | ||
| 12 | {1, nullptr, "StartDiscovery"}, | ||
| 13 | {2, nullptr, "CancelDiscovery"}, | ||
| 14 | {3, nullptr, "GetDeviceProperty"}, | ||
| 15 | {4, nullptr, "CreateBond"}, | ||
| 16 | {5, nullptr, "CancelBond"}, | ||
| 17 | {6, nullptr, "SetTsiMode"}, | ||
| 18 | {7, nullptr, "GeneralTest"}, | ||
| 19 | {8, nullptr, "HidConnect"}, | ||
| 20 | {9, nullptr, "GeneralGet"}, | ||
| 21 | {10, nullptr, "GetGattClientDisconnectionReason"}, | ||
| 22 | {11, nullptr, "GetBleConnectionParameter"}, | ||
| 23 | {12, nullptr, "GetBleConnectionParameterRequest"}, | ||
| 24 | {13, nullptr, "Unknown13"}, | ||
| 25 | }; | ||
| 26 | // clang-format on | ||
| 27 | |||
| 28 | RegisterHandlers(functions); | ||
| 29 | } | ||
| 30 | |||
| 31 | IBtmDebug::~IBtmDebug() = default; | ||
| 32 | |||
| 33 | } // namespace Service::BTM | ||
diff --git a/src/core/hle/service/btm/btm_debug.h b/src/core/hle/service/btm/btm_debug.h new file mode 100644 index 000000000..bf4f7e14f --- /dev/null +++ b/src/core/hle/service/btm/btm_debug.h | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "core/hle/service/cmif_types.h" | ||
| 7 | #include "core/hle/service/service.h" | ||
| 8 | |||
| 9 | namespace Core { | ||
| 10 | class System; | ||
| 11 | } | ||
| 12 | |||
| 13 | namespace Service::BTM { | ||
| 14 | |||
| 15 | class IBtmDebug final : public ServiceFramework<IBtmDebug> { | ||
| 16 | public: | ||
| 17 | explicit IBtmDebug(Core::System& system_); | ||
| 18 | ~IBtmDebug() override; | ||
| 19 | }; | ||
| 20 | |||
| 21 | } // namespace Service::BTM | ||
diff --git a/src/core/hle/service/btm/btm_system.cpp b/src/core/hle/service/btm/btm_system.cpp new file mode 100644 index 000000000..99718a7b0 --- /dev/null +++ b/src/core/hle/service/btm/btm_system.cpp | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #include "common/logging/log.h" | ||
| 5 | #include "core/hle/service/btm/btm_system.h" | ||
| 6 | #include "core/hle/service/btm/btm_system_core.h" | ||
| 7 | #include "core/hle/service/cmif_serialization.h" | ||
| 8 | #include "core/hle/service/service.h" | ||
| 9 | |||
| 10 | namespace Service::BTM { | ||
| 11 | |||
| 12 | IBtmSystem::IBtmSystem(Core::System& system_) : ServiceFramework{system_, "btm:sys"} { | ||
| 13 | // clang-format off | ||
| 14 | static const FunctionInfo functions[] = { | ||
| 15 | {0, C<&IBtmSystem::GetCore>, "GetCore"}, | ||
| 16 | }; | ||
| 17 | // clang-format on | ||
| 18 | |||
| 19 | RegisterHandlers(functions); | ||
| 20 | } | ||
| 21 | |||
| 22 | IBtmSystem::~IBtmSystem() = default; | ||
| 23 | |||
| 24 | Result IBtmSystem::GetCore(OutInterface<IBtmSystemCore> out_interface) { | ||
| 25 | LOG_WARNING(Service_BTM, "called"); | ||
| 26 | |||
| 27 | *out_interface = std::make_shared<IBtmSystemCore>(system); | ||
| 28 | R_SUCCEED(); | ||
| 29 | } | ||
| 30 | |||
| 31 | } // namespace Service::BTM | ||
diff --git a/src/core/hle/service/btm/btm_system.h b/src/core/hle/service/btm/btm_system.h new file mode 100644 index 000000000..fe1c6dbd7 --- /dev/null +++ b/src/core/hle/service/btm/btm_system.h | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "core/hle/service/cmif_types.h" | ||
| 7 | #include "core/hle/service/service.h" | ||
| 8 | |||
| 9 | namespace Core { | ||
| 10 | class System; | ||
| 11 | } | ||
| 12 | |||
| 13 | namespace Service::BTM { | ||
| 14 | class IBtmSystemCore; | ||
| 15 | |||
| 16 | class IBtmSystem final : public ServiceFramework<IBtmSystem> { | ||
| 17 | public: | ||
| 18 | explicit IBtmSystem(Core::System& system_); | ||
| 19 | ~IBtmSystem() override; | ||
| 20 | |||
| 21 | private: | ||
| 22 | Result GetCore(OutInterface<IBtmSystemCore> out_interface); | ||
| 23 | }; | ||
| 24 | |||
| 25 | } // namespace Service::BTM | ||
diff --git a/src/core/hle/service/btm/btm_system_core.cpp b/src/core/hle/service/btm/btm_system_core.cpp new file mode 100644 index 000000000..4bc8a9e8b --- /dev/null +++ b/src/core/hle/service/btm/btm_system_core.cpp | |||
| @@ -0,0 +1,127 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #include "common/logging/log.h" | ||
| 5 | #include "core/hle/service/btm/btm_system_core.h" | ||
| 6 | #include "core/hle/service/cmif_serialization.h" | ||
| 7 | #include "core/hle/service/set/system_settings_server.h" | ||
| 8 | #include "core/hle/service/sm/sm.h" | ||
| 9 | |||
| 10 | namespace Service::BTM { | ||
| 11 | |||
| 12 | IBtmSystemCore::IBtmSystemCore(Core::System& system_) | ||
| 13 | : ServiceFramework{system_, "IBtmSystemCore"}, service_context{system_, "IBtmSystemCore"} { | ||
| 14 | // clang-format off | ||
| 15 | static const FunctionInfo functions[] = { | ||
| 16 | {0, C<&IBtmSystemCore::StartGamepadPairing>, "StartGamepadPairing"}, | ||
| 17 | {1, C<&IBtmSystemCore::CancelGamepadPairing>, "CancelGamepadPairing"}, | ||
| 18 | {2, nullptr, "ClearGamepadPairingDatabase"}, | ||
| 19 | {3, nullptr, "GetPairedGamepadCount"}, | ||
| 20 | {4, C<&IBtmSystemCore::EnableRadio>, "EnableRadio"}, | ||
| 21 | {5, C<&IBtmSystemCore::DisableRadio>, "DisableRadio"}, | ||
| 22 | {6, C<&IBtmSystemCore::IsRadioEnabled>, "IsRadioEnabled"}, | ||
| 23 | {7, C<&IBtmSystemCore::AcquireRadioEvent>, "AcquireRadioEvent"}, | ||
| 24 | {8, nullptr, "AcquireGamepadPairingEvent"}, | ||
| 25 | {9, nullptr, "IsGamepadPairingStarted"}, | ||
| 26 | {10, nullptr, "StartAudioDeviceDiscovery"}, | ||
| 27 | {11, nullptr, "StopAudioDeviceDiscovery"}, | ||
| 28 | {12, nullptr, "IsDiscoveryingAudioDevice"}, | ||
| 29 | {13, nullptr, "GetDiscoveredAudioDevice"}, | ||
| 30 | {14, C<&IBtmSystemCore::AcquireAudioDeviceConnectionEvent>, "AcquireAudioDeviceConnectionEvent"}, | ||
| 31 | {15, nullptr, "ConnectAudioDevice"}, | ||
| 32 | {16, nullptr, "IsConnectingAudioDevice"}, | ||
| 33 | {17, C<&IBtmSystemCore::GetConnectedAudioDevices>, "GetConnectedAudioDevices"}, | ||
| 34 | {18, nullptr, "DisconnectAudioDevice"}, | ||
| 35 | {19, nullptr, "AcquirePairedAudioDeviceInfoChangedEvent"}, | ||
| 36 | {20, C<&IBtmSystemCore::GetPairedAudioDevices>, "GetPairedAudioDevices"}, | ||
| 37 | {21, nullptr, "RemoveAudioDevicePairing"}, | ||
| 38 | {22, C<&IBtmSystemCore::RequestAudioDeviceConnectionRejection>, "RequestAudioDeviceConnectionRejection"}, | ||
| 39 | {23, C<&IBtmSystemCore::CancelAudioDeviceConnectionRejection>, "CancelAudioDeviceConnectionRejection"} | ||
| 40 | }; | ||
| 41 | // clang-format on | ||
| 42 | |||
| 43 | RegisterHandlers(functions); | ||
| 44 | radio_event = service_context.CreateEvent("IBtmSystemCore::RadioEvent"); | ||
| 45 | audio_device_connection_event = | ||
| 46 | service_context.CreateEvent("IBtmSystemCore::AudioDeviceConnectionEvent"); | ||
| 47 | |||
| 48 | m_set_sys = | ||
| 49 | system.ServiceManager().GetService<Service::Set::ISystemSettingsServer>("set:sys", true); | ||
| 50 | } | ||
| 51 | |||
| 52 | IBtmSystemCore::~IBtmSystemCore() { | ||
| 53 | service_context.CloseEvent(radio_event); | ||
| 54 | service_context.CloseEvent(audio_device_connection_event); | ||
| 55 | } | ||
| 56 | |||
| 57 | Result IBtmSystemCore::StartGamepadPairing() { | ||
| 58 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 59 | R_SUCCEED(); | ||
| 60 | } | ||
| 61 | |||
| 62 | Result IBtmSystemCore::CancelGamepadPairing() { | ||
| 63 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 64 | R_SUCCEED(); | ||
| 65 | } | ||
| 66 | |||
| 67 | Result IBtmSystemCore::EnableRadio() { | ||
| 68 | LOG_DEBUG(Service_BTM, "called"); | ||
| 69 | |||
| 70 | R_RETURN(m_set_sys->SetBluetoothEnableFlag(true)); | ||
| 71 | } | ||
| 72 | Result IBtmSystemCore::DisableRadio() { | ||
| 73 | LOG_DEBUG(Service_BTM, "called"); | ||
| 74 | |||
| 75 | R_RETURN(m_set_sys->SetBluetoothEnableFlag(false)); | ||
| 76 | } | ||
| 77 | |||
| 78 | Result IBtmSystemCore::IsRadioEnabled(Out<bool> out_is_enabled) { | ||
| 79 | LOG_DEBUG(Service_BTM, "called"); | ||
| 80 | |||
| 81 | R_RETURN(m_set_sys->GetBluetoothEnableFlag(out_is_enabled)); | ||
| 82 | } | ||
| 83 | |||
| 84 | Result IBtmSystemCore::AcquireRadioEvent(Out<bool> out_is_valid, | ||
| 85 | OutCopyHandle<Kernel::KReadableEvent> out_event) { | ||
| 86 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 87 | |||
| 88 | *out_is_valid = true; | ||
| 89 | *out_event = &radio_event->GetReadableEvent(); | ||
| 90 | R_SUCCEED(); | ||
| 91 | } | ||
| 92 | |||
| 93 | Result IBtmSystemCore::AcquireAudioDeviceConnectionEvent( | ||
| 94 | OutCopyHandle<Kernel::KReadableEvent> out_event) { | ||
| 95 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 96 | |||
| 97 | *out_event = &audio_device_connection_event->GetReadableEvent(); | ||
| 98 | R_SUCCEED(); | ||
| 99 | } | ||
| 100 | |||
| 101 | Result IBtmSystemCore::GetConnectedAudioDevices( | ||
| 102 | Out<s32> out_count, OutArray<std::array<u8, 0xFF>, BufferAttr_HipcPointer> out_audio_devices) { | ||
| 103 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 104 | |||
| 105 | *out_count = 0; | ||
| 106 | R_SUCCEED(); | ||
| 107 | } | ||
| 108 | |||
| 109 | Result IBtmSystemCore::GetPairedAudioDevices( | ||
| 110 | Out<s32> out_count, OutArray<std::array<u8, 0xFF>, BufferAttr_HipcPointer> out_audio_devices) { | ||
| 111 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 112 | |||
| 113 | *out_count = 0; | ||
| 114 | R_SUCCEED(); | ||
| 115 | } | ||
| 116 | |||
| 117 | Result IBtmSystemCore::RequestAudioDeviceConnectionRejection(ClientAppletResourceUserId aruid) { | ||
| 118 | LOG_WARNING(Service_BTM, "(STUBBED) called, applet_resource_user_id={}", aruid.pid); | ||
| 119 | R_SUCCEED(); | ||
| 120 | } | ||
| 121 | |||
| 122 | Result IBtmSystemCore::CancelAudioDeviceConnectionRejection(ClientAppletResourceUserId aruid) { | ||
| 123 | LOG_WARNING(Service_BTM, "(STUBBED) called, applet_resource_user_id={}", aruid.pid); | ||
| 124 | R_SUCCEED(); | ||
| 125 | } | ||
| 126 | |||
| 127 | } // namespace Service::BTM | ||
diff --git a/src/core/hle/service/btm/btm_system_core.h b/src/core/hle/service/btm/btm_system_core.h new file mode 100644 index 000000000..06498b21e --- /dev/null +++ b/src/core/hle/service/btm/btm_system_core.h | |||
| @@ -0,0 +1,60 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "core/hle/service/cmif_types.h" | ||
| 7 | #include "core/hle/service/kernel_helpers.h" | ||
| 8 | #include "core/hle/service/service.h" | ||
| 9 | |||
| 10 | namespace Kernel { | ||
| 11 | class KEvent; | ||
| 12 | class KReadableEvent; | ||
| 13 | } // namespace Kernel | ||
| 14 | |||
| 15 | namespace Core { | ||
| 16 | class System; | ||
| 17 | } | ||
| 18 | |||
| 19 | namespace Service::Set { | ||
| 20 | class ISystemSettingsServer; | ||
| 21 | } | ||
| 22 | |||
| 23 | namespace Service::BTM { | ||
| 24 | |||
| 25 | class IBtmSystemCore final : public ServiceFramework<IBtmSystemCore> { | ||
| 26 | public: | ||
| 27 | explicit IBtmSystemCore(Core::System& system_); | ||
| 28 | ~IBtmSystemCore() override; | ||
| 29 | |||
| 30 | private: | ||
| 31 | Result StartGamepadPairing(); | ||
| 32 | Result CancelGamepadPairing(); | ||
| 33 | Result EnableRadio(); | ||
| 34 | Result DisableRadio(); | ||
| 35 | Result IsRadioEnabled(Out<bool> out_is_enabled); | ||
| 36 | |||
| 37 | Result AcquireRadioEvent(Out<bool> out_is_valid, | ||
| 38 | OutCopyHandle<Kernel::KReadableEvent> out_event); | ||
| 39 | |||
| 40 | Result AcquireAudioDeviceConnectionEvent(OutCopyHandle<Kernel::KReadableEvent> out_event); | ||
| 41 | |||
| 42 | Result GetConnectedAudioDevices( | ||
| 43 | Out<s32> out_count, | ||
| 44 | OutArray<std::array<u8, 0xFF>, BufferAttr_HipcPointer> out_audio_devices); | ||
| 45 | |||
| 46 | Result GetPairedAudioDevices( | ||
| 47 | Out<s32> out_count, | ||
| 48 | OutArray<std::array<u8, 0xFF>, BufferAttr_HipcPointer> out_audio_devices); | ||
| 49 | |||
| 50 | Result RequestAudioDeviceConnectionRejection(ClientAppletResourceUserId aruid); | ||
| 51 | Result CancelAudioDeviceConnectionRejection(ClientAppletResourceUserId aruid); | ||
| 52 | |||
| 53 | KernelHelpers::ServiceContext service_context; | ||
| 54 | |||
| 55 | Kernel::KEvent* radio_event; | ||
| 56 | Kernel::KEvent* audio_device_connection_event; | ||
| 57 | std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys; | ||
| 58 | }; | ||
| 59 | |||
| 60 | } // namespace Service::BTM | ||
diff --git a/src/core/hle/service/btm/btm_user.cpp b/src/core/hle/service/btm/btm_user.cpp new file mode 100644 index 000000000..d2e228f8d --- /dev/null +++ b/src/core/hle/service/btm/btm_user.cpp | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #include "common/logging/log.h" | ||
| 5 | #include "core/hle/service/btm/btm_user.h" | ||
| 6 | #include "core/hle/service/btm/btm_user_core.h" | ||
| 7 | #include "core/hle/service/cmif_serialization.h" | ||
| 8 | |||
| 9 | namespace Service::BTM { | ||
| 10 | |||
| 11 | IBtmUser::IBtmUser(Core::System& system_) : ServiceFramework{system_, "btm:u"} { | ||
| 12 | // clang-format off | ||
| 13 | static const FunctionInfo functions[] = { | ||
| 14 | {0, C<&IBtmUser::GetCore>, "GetCore"}, | ||
| 15 | }; | ||
| 16 | // clang-format on | ||
| 17 | |||
| 18 | RegisterHandlers(functions); | ||
| 19 | } | ||
| 20 | |||
| 21 | IBtmUser::~IBtmUser() = default; | ||
| 22 | |||
| 23 | Result IBtmUser::GetCore(OutInterface<IBtmUserCore> out_interface) { | ||
| 24 | LOG_WARNING(Service_BTM, "called"); | ||
| 25 | |||
| 26 | *out_interface = std::make_shared<IBtmUserCore>(system); | ||
| 27 | R_SUCCEED(); | ||
| 28 | } | ||
| 29 | |||
| 30 | } // namespace Service::BTM | ||
diff --git a/src/core/hle/service/btm/btm_user.h b/src/core/hle/service/btm/btm_user.h new file mode 100644 index 000000000..d9ee5db45 --- /dev/null +++ b/src/core/hle/service/btm/btm_user.h | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "core/hle/service/cmif_types.h" | ||
| 7 | #include "core/hle/service/service.h" | ||
| 8 | |||
| 9 | namespace Core { | ||
| 10 | class System; | ||
| 11 | } | ||
| 12 | |||
| 13 | namespace Service::BTM { | ||
| 14 | class IBtmUserCore; | ||
| 15 | |||
| 16 | class IBtmUser final : public ServiceFramework<IBtmUser> { | ||
| 17 | public: | ||
| 18 | explicit IBtmUser(Core::System& system_); | ||
| 19 | ~IBtmUser() override; | ||
| 20 | |||
| 21 | private: | ||
| 22 | Result GetCore(OutInterface<IBtmUserCore> out_interface); | ||
| 23 | }; | ||
| 24 | |||
| 25 | } // namespace Service::BTM | ||
diff --git a/src/core/hle/service/btm/btm_user_core.cpp b/src/core/hle/service/btm/btm_user_core.cpp new file mode 100644 index 000000000..6f9fa589b --- /dev/null +++ b/src/core/hle/service/btm/btm_user_core.cpp | |||
| @@ -0,0 +1,103 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #include <memory> | ||
| 5 | |||
| 6 | #include "common/logging/log.h" | ||
| 7 | #include "core/core.h" | ||
| 8 | #include "core/hle/kernel/k_event.h" | ||
| 9 | #include "core/hle/service/btm/btm_user_core.h" | ||
| 10 | #include "core/hle/service/cmif_serialization.h" | ||
| 11 | |||
| 12 | namespace Service::BTM { | ||
| 13 | |||
| 14 | IBtmUserCore::IBtmUserCore(Core::System& system_) | ||
| 15 | : ServiceFramework{system_, "IBtmUserCore"}, service_context{system_, "IBtmUserCore"} { | ||
| 16 | // clang-format off | ||
| 17 | static const FunctionInfo functions[] = { | ||
| 18 | {0, C<&IBtmUserCore::AcquireBleScanEvent>, "AcquireBleScanEvent"}, | ||
| 19 | {1, nullptr, "GetBleScanFilterParameter"}, | ||
| 20 | {2, nullptr, "GetBleScanFilterParameter2"}, | ||
| 21 | {3, nullptr, "StartBleScanForGeneral"}, | ||
| 22 | {4, nullptr, "StopBleScanForGeneral"}, | ||
| 23 | {5, nullptr, "GetBleScanResultsForGeneral"}, | ||
| 24 | {6, nullptr, "StartBleScanForPaired"}, | ||
| 25 | {7, nullptr, "StopBleScanForPaired"}, | ||
| 26 | {8, nullptr, "StartBleScanForSmartDevice"}, | ||
| 27 | {9, nullptr, "StopBleScanForSmartDevice"}, | ||
| 28 | {10, nullptr, "GetBleScanResultsForSmartDevice"}, | ||
| 29 | {17, C<&IBtmUserCore::AcquireBleConnectionEvent>, "AcquireBleConnectionEvent"}, | ||
| 30 | {18, nullptr, "BleConnect"}, | ||
| 31 | {19, nullptr, "BleDisconnect"}, | ||
| 32 | {20, nullptr, "BleGetConnectionState"}, | ||
| 33 | {21, nullptr, "AcquireBlePairingEvent"}, | ||
| 34 | {22, nullptr, "BlePairDevice"}, | ||
| 35 | {23, nullptr, "BleUnPairDevice"}, | ||
| 36 | {24, nullptr, "BleUnPairDevice2"}, | ||
| 37 | {25, nullptr, "BleGetPairedDevices"}, | ||
| 38 | {26, C<&IBtmUserCore::AcquireBleServiceDiscoveryEvent>, "AcquireBleServiceDiscoveryEvent"}, | ||
| 39 | {27, nullptr, "GetGattServices"}, | ||
| 40 | {28, nullptr, "GetGattService"}, | ||
| 41 | {29, nullptr, "GetGattIncludedServices"}, | ||
| 42 | {30, nullptr, "GetBelongingGattService"}, | ||
| 43 | {31, nullptr, "GetGattCharacteristics"}, | ||
| 44 | {32, nullptr, "GetGattDescriptors"}, | ||
| 45 | {33, C<&IBtmUserCore::AcquireBleMtuConfigEvent>, "AcquireBleMtuConfigEvent"}, | ||
| 46 | {34, nullptr, "ConfigureBleMtu"}, | ||
| 47 | {35, nullptr, "GetBleMtu"}, | ||
| 48 | {36, nullptr, "RegisterBleGattDataPath"}, | ||
| 49 | {37, nullptr, "UnregisterBleGattDataPath"}, | ||
| 50 | }; | ||
| 51 | // clang-format on | ||
| 52 | RegisterHandlers(functions); | ||
| 53 | |||
| 54 | scan_event = service_context.CreateEvent("IBtmUserCore:ScanEvent"); | ||
| 55 | connection_event = service_context.CreateEvent("IBtmUserCore:ConnectionEvent"); | ||
| 56 | service_discovery_event = service_context.CreateEvent("IBtmUserCore:DiscoveryEvent"); | ||
| 57 | config_event = service_context.CreateEvent("IBtmUserCore:ConfigEvent"); | ||
| 58 | } | ||
| 59 | |||
| 60 | IBtmUserCore::~IBtmUserCore() { | ||
| 61 | service_context.CloseEvent(scan_event); | ||
| 62 | service_context.CloseEvent(connection_event); | ||
| 63 | service_context.CloseEvent(service_discovery_event); | ||
| 64 | service_context.CloseEvent(config_event); | ||
| 65 | } | ||
| 66 | |||
| 67 | Result IBtmUserCore::AcquireBleScanEvent(Out<bool> out_is_valid, | ||
| 68 | OutCopyHandle<Kernel::KReadableEvent> out_event) { | ||
| 69 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 70 | |||
| 71 | *out_is_valid = true; | ||
| 72 | *out_event = &scan_event->GetReadableEvent(); | ||
| 73 | R_SUCCEED(); | ||
| 74 | } | ||
| 75 | |||
| 76 | Result IBtmUserCore::AcquireBleConnectionEvent(Out<bool> out_is_valid, | ||
| 77 | OutCopyHandle<Kernel::KReadableEvent> out_event) { | ||
| 78 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 79 | |||
| 80 | *out_is_valid = true; | ||
| 81 | *out_event = &connection_event->GetReadableEvent(); | ||
| 82 | R_SUCCEED(); | ||
| 83 | } | ||
| 84 | |||
| 85 | Result IBtmUserCore::AcquireBleServiceDiscoveryEvent( | ||
| 86 | Out<bool> out_is_valid, OutCopyHandle<Kernel::KReadableEvent> out_event) { | ||
| 87 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 88 | |||
| 89 | *out_is_valid = true; | ||
| 90 | *out_event = &service_discovery_event->GetReadableEvent(); | ||
| 91 | R_SUCCEED(); | ||
| 92 | } | ||
| 93 | |||
| 94 | Result IBtmUserCore::AcquireBleMtuConfigEvent(Out<bool> out_is_valid, | ||
| 95 | OutCopyHandle<Kernel::KReadableEvent> out_event) { | ||
| 96 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 97 | |||
| 98 | *out_is_valid = true; | ||
| 99 | *out_event = &config_event->GetReadableEvent(); | ||
| 100 | R_SUCCEED(); | ||
| 101 | } | ||
| 102 | |||
| 103 | } // namespace Service::BTM | ||
diff --git a/src/core/hle/service/btm/btm_user_core.h b/src/core/hle/service/btm/btm_user_core.h new file mode 100644 index 000000000..dc0a22e81 --- /dev/null +++ b/src/core/hle/service/btm/btm_user_core.h | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "core/hle/service/cmif_types.h" | ||
| 7 | #include "core/hle/service/kernel_helpers.h" | ||
| 8 | #include "core/hle/service/service.h" | ||
| 9 | |||
| 10 | namespace Kernel { | ||
| 11 | class KEvent; | ||
| 12 | class KReadableEvent; | ||
| 13 | } // namespace Kernel | ||
| 14 | |||
| 15 | namespace Core { | ||
| 16 | class System; | ||
| 17 | } | ||
| 18 | |||
| 19 | namespace Service::BTM { | ||
| 20 | |||
| 21 | class IBtmUserCore final : public ServiceFramework<IBtmUserCore> { | ||
| 22 | public: | ||
| 23 | explicit IBtmUserCore(Core::System& system_); | ||
| 24 | ~IBtmUserCore() override; | ||
| 25 | |||
| 26 | private: | ||
| 27 | Result AcquireBleScanEvent(Out<bool> out_is_valid, | ||
| 28 | OutCopyHandle<Kernel::KReadableEvent> out_event); | ||
| 29 | |||
| 30 | Result AcquireBleConnectionEvent(Out<bool> out_is_valid, | ||
| 31 | OutCopyHandle<Kernel::KReadableEvent> out_event); | ||
| 32 | |||
| 33 | Result AcquireBleServiceDiscoveryEvent(Out<bool> out_is_valid, | ||
| 34 | OutCopyHandle<Kernel::KReadableEvent> out_event); | ||
| 35 | |||
| 36 | Result AcquireBleMtuConfigEvent(Out<bool> out_is_valid, | ||
| 37 | OutCopyHandle<Kernel::KReadableEvent> out_event); | ||
| 38 | |||
| 39 | KernelHelpers::ServiceContext service_context; | ||
| 40 | |||
| 41 | Kernel::KEvent* scan_event; | ||
| 42 | Kernel::KEvent* connection_event; | ||
| 43 | Kernel::KEvent* service_discovery_event; | ||
| 44 | Kernel::KEvent* config_event; | ||
| 45 | }; | ||
| 46 | |||
| 47 | } // namespace Service::BTM | ||
diff --git a/src/core/hle/service/ns/application_manager_interface.cpp b/src/core/hle/service/ns/application_manager_interface.cpp index 2e3a44c0d..7a91727f9 100644 --- a/src/core/hle/service/ns/application_manager_interface.cpp +++ b/src/core/hle/service/ns/application_manager_interface.cpp | |||
| @@ -436,14 +436,14 @@ Result IApplicationManagerInterface::GetApplicationViewWithPromotionInfo( | |||
| 436 | 436 | ||
| 437 | Result IApplicationManagerInterface::GetApplicationRightsOnClient( | 437 | Result IApplicationManagerInterface::GetApplicationRightsOnClient( |
| 438 | OutArray<ApplicationRightsOnClient, BufferAttr_HipcMapAlias> out_rights, Out<u32> out_count, | 438 | OutArray<ApplicationRightsOnClient, BufferAttr_HipcMapAlias> out_rights, Out<u32> out_count, |
| 439 | Common::UUID account_id, u32 flags, u64 application_id) { | 439 | u32 flags, u64 application_id, Uid account_id) { |
| 440 | LOG_WARNING(Service_NS, "(STUBBED) called, flags={}, application_id={:016X}, account_id={}", | 440 | LOG_WARNING(Service_NS, "(STUBBED) called, flags={}, application_id={:016X}, account_id={}", |
| 441 | flags, application_id, account_id.FormattedString()); | 441 | flags, application_id, account_id.uuid.FormattedString()); |
| 442 | 442 | ||
| 443 | if (!out_rights.empty()) { | 443 | if (!out_rights.empty()) { |
| 444 | ApplicationRightsOnClient rights{}; | 444 | ApplicationRightsOnClient rights{}; |
| 445 | rights.application_id = application_id; | 445 | rights.application_id = application_id; |
| 446 | rights.uid = account_id; | 446 | rights.uid = account_id.uuid; |
| 447 | rights.flags = 0; | 447 | rights.flags = 0; |
| 448 | rights.flags2 = 0; | 448 | rights.flags2 = 0; |
| 449 | 449 | ||
diff --git a/src/core/hle/service/ns/application_manager_interface.h b/src/core/hle/service/ns/application_manager_interface.h index 350ec37ce..f33d269b3 100644 --- a/src/core/hle/service/ns/application_manager_interface.h +++ b/src/core/hle/service/ns/application_manager_interface.h | |||
| @@ -37,7 +37,7 @@ public: | |||
| 37 | InArray<u64, BufferAttr_HipcMapAlias> application_ids); | 37 | InArray<u64, BufferAttr_HipcMapAlias> application_ids); |
| 38 | Result GetApplicationRightsOnClient( | 38 | Result GetApplicationRightsOnClient( |
| 39 | OutArray<ApplicationRightsOnClient, BufferAttr_HipcMapAlias> out_rights, Out<u32> out_count, | 39 | OutArray<ApplicationRightsOnClient, BufferAttr_HipcMapAlias> out_rights, Out<u32> out_count, |
| 40 | Common::UUID account_id, u32 flags, u64 application_id); | 40 | u32 flags, u64 application_id, Uid account_id); |
| 41 | Result CheckSdCardMountStatus(); | 41 | Result CheckSdCardMountStatus(); |
| 42 | Result GetSdCardMountStatusChangedEvent(OutCopyHandle<Kernel::KReadableEvent> out_event); | 42 | Result GetSdCardMountStatusChangedEvent(OutCopyHandle<Kernel::KReadableEvent> out_event); |
| 43 | Result GetFreeSpaceSize(Out<s64> out_free_space_size, FileSys::StorageId storage_id); | 43 | Result GetFreeSpaceSize(Out<s64> out_free_space_size, FileSys::StorageId storage_id); |
diff --git a/src/core/hle/service/ns/ns_types.h b/src/core/hle/service/ns/ns_types.h index 38421b0f4..2dd664c4e 100644 --- a/src/core/hle/service/ns/ns_types.h +++ b/src/core/hle/service/ns/ns_types.h | |||
| @@ -108,4 +108,9 @@ struct ContentPath { | |||
| 108 | }; | 108 | }; |
| 109 | static_assert(sizeof(ContentPath) == 0x10, "ContentPath has incorrect size."); | 109 | static_assert(sizeof(ContentPath) == 0x10, "ContentPath has incorrect size."); |
| 110 | 110 | ||
| 111 | struct Uid { | ||
| 112 | alignas(8) Common::UUID uuid; | ||
| 113 | }; | ||
| 114 | static_assert(sizeof(Uid) == 0x10, "Uid has incorrect size."); | ||
| 115 | |||
| 111 | } // namespace Service::NS | 116 | } // namespace Service::NS |
diff --git a/src/core/hle/service/ns/query_service.cpp b/src/core/hle/service/ns/query_service.cpp index 946b7fa23..138400541 100644 --- a/src/core/hle/service/ns/query_service.cpp +++ b/src/core/hle/service/ns/query_service.cpp | |||
| @@ -41,8 +41,7 @@ IQueryService::IQueryService(Core::System& system_) : ServiceFramework{system_, | |||
| 41 | IQueryService::~IQueryService() = default; | 41 | IQueryService::~IQueryService() = default; |
| 42 | 42 | ||
| 43 | Result IQueryService::QueryPlayStatisticsByApplicationIdAndUserAccountId( | 43 | Result IQueryService::QueryPlayStatisticsByApplicationIdAndUserAccountId( |
| 44 | Out<PlayStatistics> out_play_statistics, bool unknown, Common::UUID account_id, | 44 | Out<PlayStatistics> out_play_statistics, bool unknown, u64 application_id, Uid account_id) { |
| 45 | u64 application_id) { | ||
| 46 | // TODO(German77): Read statistics of the game | 45 | // TODO(German77): Read statistics of the game |
| 47 | *out_play_statistics = { | 46 | *out_play_statistics = { |
| 48 | .application_id = application_id, | 47 | .application_id = application_id, |
| @@ -50,7 +49,7 @@ Result IQueryService::QueryPlayStatisticsByApplicationIdAndUserAccountId( | |||
| 50 | }; | 49 | }; |
| 51 | 50 | ||
| 52 | LOG_WARNING(Service_NS, "(STUBBED) called. unknown={}. application_id={:016X}, account_id={}", | 51 | LOG_WARNING(Service_NS, "(STUBBED) called. unknown={}. application_id={:016X}, account_id={}", |
| 53 | unknown, application_id, account_id.FormattedString()); | 52 | unknown, application_id, account_id.uuid.FormattedString()); |
| 54 | R_SUCCEED(); | 53 | R_SUCCEED(); |
| 55 | } | 54 | } |
| 56 | 55 | ||
diff --git a/src/core/hle/service/ns/query_service.h b/src/core/hle/service/ns/query_service.h index 6cdbfa277..c4c82b752 100644 --- a/src/core/hle/service/ns/query_service.h +++ b/src/core/hle/service/ns/query_service.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #include "common/uuid.h" | 6 | #include "common/uuid.h" |
| 7 | #include "core/hle/service/cmif_types.h" | 7 | #include "core/hle/service/cmif_types.h" |
| 8 | #include "core/hle/service/ns/ns_types.h" | ||
| 8 | #include "core/hle/service/service.h" | 9 | #include "core/hle/service/service.h" |
| 9 | 10 | ||
| 10 | namespace Service::NS { | 11 | namespace Service::NS { |
| @@ -29,8 +30,7 @@ public: | |||
| 29 | 30 | ||
| 30 | private: | 31 | private: |
| 31 | Result QueryPlayStatisticsByApplicationIdAndUserAccountId( | 32 | Result QueryPlayStatisticsByApplicationIdAndUserAccountId( |
| 32 | Out<PlayStatistics> out_play_statistics, bool unknown, Common::UUID account_id, | 33 | Out<PlayStatistics> out_play_statistics, bool unknown, u64 application_id, Uid account_id); |
| 33 | u64 application_id); | ||
| 34 | }; | 34 | }; |
| 35 | 35 | ||
| 36 | } // namespace Service::NS | 36 | } // namespace Service::NS |
diff --git a/src/core/hle/service/nvnflinger/display.h b/src/core/hle/service/nvnflinger/display.h index f27cbf144..40aa59787 100644 --- a/src/core/hle/service/nvnflinger/display.h +++ b/src/core/hle/service/nvnflinger/display.h | |||
| @@ -3,8 +3,6 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <list> | ||
| 7 | |||
| 8 | #include "core/hle/service/nvnflinger/buffer_item_consumer.h" | 6 | #include "core/hle/service/nvnflinger/buffer_item_consumer.h" |
| 9 | #include "core/hle/service/nvnflinger/hwc_layer.h" | 7 | #include "core/hle/service/nvnflinger/hwc_layer.h" |
| 10 | 8 | ||
| @@ -26,18 +24,12 @@ struct Layer { | |||
| 26 | }; | 24 | }; |
| 27 | 25 | ||
| 28 | struct LayerStack { | 26 | struct LayerStack { |
| 29 | std::list<Layer> layers; | 27 | std::vector<std::shared_ptr<Layer>> layers; |
| 30 | }; | ||
| 31 | |||
| 32 | struct Display { | ||
| 33 | explicit Display(u64 id_) { | ||
| 34 | id = id_; | ||
| 35 | } | ||
| 36 | 28 | ||
| 37 | Layer* FindLayer(s32 consumer_id) { | 29 | std::shared_ptr<Layer> FindLayer(s32 consumer_id) { |
| 38 | for (auto& layer : stack.layers) { | 30 | for (auto& layer : layers) { |
| 39 | if (layer.consumer_id == consumer_id) { | 31 | if (layer->consumer_id == consumer_id) { |
| 40 | return &layer; | 32 | return layer; |
| 41 | } | 33 | } |
| 42 | } | 34 | } |
| 43 | 35 | ||
| @@ -45,7 +37,13 @@ struct Display { | |||
| 45 | } | 37 | } |
| 46 | 38 | ||
| 47 | bool HasLayers() { | 39 | bool HasLayers() { |
| 48 | return !stack.layers.empty(); | 40 | return !layers.empty(); |
| 41 | } | ||
| 42 | }; | ||
| 43 | |||
| 44 | struct Display { | ||
| 45 | explicit Display(u64 id_) { | ||
| 46 | id = id_; | ||
| 49 | } | 47 | } |
| 50 | 48 | ||
| 51 | u64 id; | 49 | u64 id; |
diff --git a/src/core/hle/service/nvnflinger/hardware_composer.cpp b/src/core/hle/service/nvnflinger/hardware_composer.cpp index 02215a786..f2dfe85a9 100644 --- a/src/core/hle/service/nvnflinger/hardware_composer.cpp +++ b/src/core/hle/service/nvnflinger/hardware_composer.cpp | |||
| @@ -55,10 +55,10 @@ u32 HardwareComposer::ComposeLocked(f32* out_speed_scale, Display& display, | |||
| 55 | 55 | ||
| 56 | // Acquire all necessary framebuffers. | 56 | // Acquire all necessary framebuffers. |
| 57 | for (auto& layer : display.stack.layers) { | 57 | for (auto& layer : display.stack.layers) { |
| 58 | auto consumer_id = layer.consumer_id; | 58 | auto consumer_id = layer->consumer_id; |
| 59 | 59 | ||
| 60 | // Try to fetch the framebuffer (either new or stale). | 60 | // Try to fetch the framebuffer (either new or stale). |
| 61 | const auto result = this->CacheFramebufferLocked(layer, consumer_id); | 61 | const auto result = this->CacheFramebufferLocked(*layer, consumer_id); |
| 62 | 62 | ||
| 63 | // If we failed, skip this layer. | 63 | // If we failed, skip this layer. |
| 64 | if (result == CacheStatus::NoBufferAvailable) { | 64 | if (result == CacheStatus::NoBufferAvailable) { |
| @@ -75,7 +75,7 @@ u32 HardwareComposer::ComposeLocked(f32* out_speed_scale, Display& display, | |||
| 75 | const auto& igbp_buffer = *item.graphic_buffer; | 75 | const auto& igbp_buffer = *item.graphic_buffer; |
| 76 | 76 | ||
| 77 | // TODO: get proper Z-index from layer | 77 | // TODO: get proper Z-index from layer |
| 78 | if (layer.visible) { | 78 | if (layer->visible) { |
| 79 | composition_stack.emplace_back(HwcLayer{ | 79 | composition_stack.emplace_back(HwcLayer{ |
| 80 | .buffer_handle = igbp_buffer.BufferId(), | 80 | .buffer_handle = igbp_buffer.BufferId(), |
| 81 | .offset = igbp_buffer.Offset(), | 81 | .offset = igbp_buffer.Offset(), |
| @@ -84,7 +84,7 @@ u32 HardwareComposer::ComposeLocked(f32* out_speed_scale, Display& display, | |||
| 84 | .height = igbp_buffer.Height(), | 84 | .height = igbp_buffer.Height(), |
| 85 | .stride = igbp_buffer.Stride(), | 85 | .stride = igbp_buffer.Stride(), |
| 86 | .z_index = 0, | 86 | .z_index = 0, |
| 87 | .blending = layer.blending, | 87 | .blending = layer->blending, |
| 88 | .transform = static_cast<android::BufferTransformFlags>(item.transform), | 88 | .transform = static_cast<android::BufferTransformFlags>(item.transform), |
| 89 | .crop_rect = item.crop, | 89 | .crop_rect = item.crop, |
| 90 | .acquire_fence = item.fence, | 90 | .acquire_fence = item.fence, |
| @@ -134,7 +134,7 @@ u32 HardwareComposer::ComposeLocked(f32* out_speed_scale, Display& display, | |||
| 134 | continue; | 134 | continue; |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | if (auto* layer = display.FindLayer(layer_id); layer != nullptr) { | 137 | if (const auto layer = display.stack.FindLayer(layer_id); layer != nullptr) { |
| 138 | // TODO: support release fence | 138 | // TODO: support release fence |
| 139 | // This is needed to prevent screen tearing | 139 | // This is needed to prevent screen tearing |
| 140 | layer->buffer_item_consumer->ReleaseBuffer(framebuffer.item, android::Fence::NoFence()); | 140 | layer->buffer_item_consumer->ReleaseBuffer(framebuffer.item, android::Fence::NoFence()); |
| @@ -153,7 +153,7 @@ void HardwareComposer::RemoveLayerLocked(Display& display, ConsumerId consumer_i | |||
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | // Try to release the buffer item. | 155 | // Try to release the buffer item. |
| 156 | auto* const layer = display.FindLayer(consumer_id); | 156 | const auto layer = display.stack.FindLayer(consumer_id); |
| 157 | if (layer && it->second.is_acquired) { | 157 | if (layer && it->second.is_acquired) { |
| 158 | layer->buffer_item_consumer->ReleaseBuffer(it->second.item, android::Fence::NoFence()); | 158 | layer->buffer_item_consumer->ReleaseBuffer(it->second.item, android::Fence::NoFence()); |
| 159 | } | 159 | } |
diff --git a/src/core/hle/service/nvnflinger/surface_flinger.cpp b/src/core/hle/service/nvnflinger/surface_flinger.cpp index 41a705717..8362b65e5 100644 --- a/src/core/hle/service/nvnflinger/surface_flinger.cpp +++ b/src/core/hle/service/nvnflinger/surface_flinger.cpp | |||
| @@ -36,7 +36,7 @@ void SurfaceFlinger::RemoveDisplay(u64 display_id) { | |||
| 36 | bool SurfaceFlinger::ComposeDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, | 36 | bool SurfaceFlinger::ComposeDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, |
| 37 | u64 display_id) { | 37 | u64 display_id) { |
| 38 | auto* const display = this->FindDisplay(display_id); | 38 | auto* const display = this->FindDisplay(display_id); |
| 39 | if (!display || !display->HasLayers()) { | 39 | if (!display || !display->stack.HasLayers()) { |
| 40 | return false; | 40 | return false; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| @@ -46,19 +46,34 @@ bool SurfaceFlinger::ComposeDisplay(s32* out_swap_interval, f32* out_compose_spe | |||
| 46 | return true; | 46 | return true; |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | void SurfaceFlinger::AddLayerToDisplayStack(u64 display_id, s32 consumer_binder_id) { | 49 | void SurfaceFlinger::CreateLayer(s32 consumer_binder_id) { |
| 50 | auto* const display = this->FindDisplay(display_id); | ||
| 51 | auto binder = std::static_pointer_cast<android::BufferQueueConsumer>( | 50 | auto binder = std::static_pointer_cast<android::BufferQueueConsumer>( |
| 52 | m_server.TryGetBinder(consumer_binder_id)); | 51 | m_server.TryGetBinder(consumer_binder_id)); |
| 53 | 52 | if (!binder) { | |
| 54 | if (!display || !binder) { | ||
| 55 | return; | 53 | return; |
| 56 | } | 54 | } |
| 57 | 55 | ||
| 58 | auto buffer_item_consumer = std::make_shared<android::BufferItemConsumer>(std::move(binder)); | 56 | auto buffer_item_consumer = std::make_shared<android::BufferItemConsumer>(std::move(binder)); |
| 59 | buffer_item_consumer->Connect(false); | 57 | buffer_item_consumer->Connect(false); |
| 60 | 58 | ||
| 61 | display->stack.layers.emplace_back(std::move(buffer_item_consumer), consumer_binder_id); | 59 | m_layers.layers.emplace_back( |
| 60 | std::make_shared<Layer>(std::move(buffer_item_consumer), consumer_binder_id)); | ||
| 61 | } | ||
| 62 | |||
| 63 | void SurfaceFlinger::DestroyLayer(s32 consumer_binder_id) { | ||
| 64 | std::erase_if(m_layers.layers, | ||
| 65 | [&](auto& layer) { return layer->consumer_id == consumer_binder_id; }); | ||
| 66 | } | ||
| 67 | |||
| 68 | void SurfaceFlinger::AddLayerToDisplayStack(u64 display_id, s32 consumer_binder_id) { | ||
| 69 | auto* const display = this->FindDisplay(display_id); | ||
| 70 | auto layer = this->FindLayer(consumer_binder_id); | ||
| 71 | |||
| 72 | if (!display || !layer) { | ||
| 73 | return; | ||
| 74 | } | ||
| 75 | |||
| 76 | display->stack.layers.emplace_back(std::move(layer)); | ||
| 62 | } | 77 | } |
| 63 | 78 | ||
| 64 | void SurfaceFlinger::RemoveLayerFromDisplayStack(u64 display_id, s32 consumer_binder_id) { | 79 | void SurfaceFlinger::RemoveLayerFromDisplayStack(u64 display_id, s32 consumer_binder_id) { |
| @@ -69,18 +84,18 @@ void SurfaceFlinger::RemoveLayerFromDisplayStack(u64 display_id, s32 consumer_bi | |||
| 69 | 84 | ||
| 70 | m_composer.RemoveLayerLocked(*display, consumer_binder_id); | 85 | m_composer.RemoveLayerLocked(*display, consumer_binder_id); |
| 71 | std::erase_if(display->stack.layers, | 86 | std::erase_if(display->stack.layers, |
| 72 | [&](auto& layer) { return layer.consumer_id == consumer_binder_id; }); | 87 | [&](auto& layer) { return layer->consumer_id == consumer_binder_id; }); |
| 73 | } | 88 | } |
| 74 | 89 | ||
| 75 | void SurfaceFlinger::SetLayerVisibility(s32 consumer_binder_id, bool visible) { | 90 | void SurfaceFlinger::SetLayerVisibility(s32 consumer_binder_id, bool visible) { |
| 76 | if (auto* layer = this->FindLayer(consumer_binder_id); layer != nullptr) { | 91 | if (const auto layer = this->FindLayer(consumer_binder_id); layer != nullptr) { |
| 77 | layer->visible = visible; | 92 | layer->visible = visible; |
| 78 | return; | 93 | return; |
| 79 | } | 94 | } |
| 80 | } | 95 | } |
| 81 | 96 | ||
| 82 | void SurfaceFlinger::SetLayerBlending(s32 consumer_binder_id, LayerBlending blending) { | 97 | void SurfaceFlinger::SetLayerBlending(s32 consumer_binder_id, LayerBlending blending) { |
| 83 | if (auto* layer = this->FindLayer(consumer_binder_id); layer != nullptr) { | 98 | if (const auto layer = this->FindLayer(consumer_binder_id); layer != nullptr) { |
| 84 | layer->blending = blending; | 99 | layer->blending = blending; |
| 85 | return; | 100 | return; |
| 86 | } | 101 | } |
| @@ -96,9 +111,9 @@ Display* SurfaceFlinger::FindDisplay(u64 display_id) { | |||
| 96 | return nullptr; | 111 | return nullptr; |
| 97 | } | 112 | } |
| 98 | 113 | ||
| 99 | Layer* SurfaceFlinger::FindLayer(s32 consumer_binder_id) { | 114 | std::shared_ptr<Layer> SurfaceFlinger::FindLayer(s32 consumer_binder_id) { |
| 100 | for (auto& display : m_displays) { | 115 | for (auto& layer : m_layers.layers) { |
| 101 | if (auto* layer = display.FindLayer(consumer_binder_id); layer != nullptr) { | 116 | if (layer->consumer_id == consumer_binder_id) { |
| 102 | return layer; | 117 | return layer; |
| 103 | } | 118 | } |
| 104 | } | 119 | } |
diff --git a/src/core/hle/service/nvnflinger/surface_flinger.h b/src/core/hle/service/nvnflinger/surface_flinger.h index d8c53fbda..406281c83 100644 --- a/src/core/hle/service/nvnflinger/surface_flinger.h +++ b/src/core/hle/service/nvnflinger/surface_flinger.h | |||
| @@ -36,6 +36,9 @@ public: | |||
| 36 | void RemoveDisplay(u64 display_id); | 36 | void RemoveDisplay(u64 display_id); |
| 37 | bool ComposeDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, u64 display_id); | 37 | bool ComposeDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, u64 display_id); |
| 38 | 38 | ||
| 39 | void CreateLayer(s32 consumer_binder_id); | ||
| 40 | void DestroyLayer(s32 consumer_binder_id); | ||
| 41 | |||
| 39 | void AddLayerToDisplayStack(u64 display_id, s32 consumer_binder_id); | 42 | void AddLayerToDisplayStack(u64 display_id, s32 consumer_binder_id); |
| 40 | void RemoveLayerFromDisplayStack(u64 display_id, s32 consumer_binder_id); | 43 | void RemoveLayerFromDisplayStack(u64 display_id, s32 consumer_binder_id); |
| 41 | 44 | ||
| @@ -44,7 +47,7 @@ public: | |||
| 44 | 47 | ||
| 45 | private: | 48 | private: |
| 46 | Display* FindDisplay(u64 display_id); | 49 | Display* FindDisplay(u64 display_id); |
| 47 | Layer* FindLayer(s32 consumer_binder_id); | 50 | std::shared_ptr<Layer> FindLayer(s32 consumer_binder_id); |
| 48 | 51 | ||
| 49 | public: | 52 | public: |
| 50 | // TODO: these don't belong here | 53 | // TODO: these don't belong here |
| @@ -57,6 +60,7 @@ private: | |||
| 57 | KernelHelpers::ServiceContext m_context; | 60 | KernelHelpers::ServiceContext m_context; |
| 58 | 61 | ||
| 59 | std::vector<Display> m_displays; | 62 | std::vector<Display> m_displays; |
| 63 | LayerStack m_layers; | ||
| 60 | std::shared_ptr<Nvidia::Module> nvdrv; | 64 | std::shared_ptr<Nvidia::Module> nvdrv; |
| 61 | s32 disp_fd; | 65 | s32 disp_fd; |
| 62 | HardwareComposer m_composer; | 66 | HardwareComposer m_composer; |
diff --git a/src/core/hle/service/vi/container.cpp b/src/core/hle/service/vi/container.cpp index 310a207f1..9074f4ae0 100644 --- a/src/core/hle/service/vi/container.cpp +++ b/src/core/hle/service/vi/container.cpp | |||
| @@ -43,11 +43,7 @@ void Container::OnTerminate() { | |||
| 43 | 43 | ||
| 44 | m_is_shut_down = true; | 44 | m_is_shut_down = true; |
| 45 | 45 | ||
| 46 | m_layers.ForEachLayer([&](auto& layer) { | 46 | m_layers.ForEachLayer([&](auto& layer) { this->DestroyLayerLocked(layer.GetId()); }); |
| 47 | if (layer.IsOpen()) { | ||
| 48 | this->DestroyBufferQueueLocked(&layer); | ||
| 49 | } | ||
| 50 | }); | ||
| 51 | 47 | ||
| 52 | m_displays.ForEachDisplay( | 48 | m_displays.ForEachDisplay( |
| 53 | [&](auto& display) { m_surface_flinger->RemoveDisplay(display.GetId()); }); | 49 | [&](auto& display) { m_surface_flinger->RemoveDisplay(display.GetId()); }); |
| @@ -161,16 +157,29 @@ Result Container::CreateLayerLocked(u64* out_layer_id, u64 display_id, u64 owner | |||
| 161 | auto* const display = m_displays.GetDisplayById(display_id); | 157 | auto* const display = m_displays.GetDisplayById(display_id); |
| 162 | R_UNLESS(display != nullptr, VI::ResultNotFound); | 158 | R_UNLESS(display != nullptr, VI::ResultNotFound); |
| 163 | 159 | ||
| 164 | auto* const layer = m_layers.CreateLayer(owner_aruid, display); | 160 | s32 consumer_binder_id, producer_binder_id; |
| 161 | m_surface_flinger->CreateBufferQueue(&consumer_binder_id, &producer_binder_id); | ||
| 162 | |||
| 163 | auto* const layer = | ||
| 164 | m_layers.CreateLayer(owner_aruid, display, consumer_binder_id, producer_binder_id); | ||
| 165 | R_UNLESS(layer != nullptr, VI::ResultNotFound); | 165 | R_UNLESS(layer != nullptr, VI::ResultNotFound); |
| 166 | 166 | ||
| 167 | m_surface_flinger->CreateLayer(consumer_binder_id); | ||
| 168 | |||
| 167 | *out_layer_id = layer->GetId(); | 169 | *out_layer_id = layer->GetId(); |
| 168 | R_SUCCEED(); | 170 | R_SUCCEED(); |
| 169 | } | 171 | } |
| 170 | 172 | ||
| 171 | Result Container::DestroyLayerLocked(u64 layer_id) { | 173 | Result Container::DestroyLayerLocked(u64 layer_id) { |
| 172 | R_SUCCEED_IF(m_layers.DestroyLayer(layer_id)); | 174 | auto* const layer = m_layers.GetLayerById(layer_id); |
| 173 | R_THROW(VI::ResultNotFound); | 175 | R_UNLESS(layer != nullptr, VI::ResultNotFound); |
| 176 | |||
| 177 | m_surface_flinger->DestroyLayer(layer->GetConsumerBinderId()); | ||
| 178 | m_surface_flinger->DestroyBufferQueue(layer->GetConsumerBinderId(), | ||
| 179 | layer->GetProducerBinderId()); | ||
| 180 | m_layers.DestroyLayer(layer_id); | ||
| 181 | |||
| 182 | R_SUCCEED(); | ||
| 174 | } | 183 | } |
| 175 | 184 | ||
| 176 | Result Container::OpenLayerLocked(s32* out_producer_binder_id, u64 layer_id, u64 aruid) { | 185 | Result Container::OpenLayerLocked(s32* out_producer_binder_id, u64 layer_id, u64 aruid) { |
| @@ -181,7 +190,12 @@ Result Container::OpenLayerLocked(s32* out_producer_binder_id, u64 layer_id, u64 | |||
| 181 | R_UNLESS(!layer->IsOpen(), VI::ResultOperationFailed); | 190 | R_UNLESS(!layer->IsOpen(), VI::ResultOperationFailed); |
| 182 | R_UNLESS(layer->GetOwnerAruid() == aruid, VI::ResultPermissionDenied); | 191 | R_UNLESS(layer->GetOwnerAruid() == aruid, VI::ResultPermissionDenied); |
| 183 | 192 | ||
| 184 | this->CreateBufferQueueLocked(layer); | 193 | layer->Open(); |
| 194 | |||
| 195 | if (auto* display = layer->GetDisplay(); display != nullptr) { | ||
| 196 | m_surface_flinger->AddLayerToDisplayStack(display->GetId(), layer->GetConsumerBinderId()); | ||
| 197 | } | ||
| 198 | |||
| 185 | *out_producer_binder_id = layer->GetProducerBinderId(); | 199 | *out_producer_binder_id = layer->GetProducerBinderId(); |
| 186 | 200 | ||
| 187 | R_SUCCEED(); | 201 | R_SUCCEED(); |
| @@ -192,30 +206,14 @@ Result Container::CloseLayerLocked(u64 layer_id) { | |||
| 192 | R_UNLESS(layer != nullptr, VI::ResultNotFound); | 206 | R_UNLESS(layer != nullptr, VI::ResultNotFound); |
| 193 | R_UNLESS(layer->IsOpen(), VI::ResultOperationFailed); | 207 | R_UNLESS(layer->IsOpen(), VI::ResultOperationFailed); |
| 194 | 208 | ||
| 195 | this->DestroyBufferQueueLocked(layer); | ||
| 196 | |||
| 197 | R_SUCCEED(); | ||
| 198 | } | ||
| 199 | |||
| 200 | void Container::CreateBufferQueueLocked(Layer* layer) { | ||
| 201 | s32 consumer_binder_id, producer_binder_id; | ||
| 202 | m_surface_flinger->CreateBufferQueue(&consumer_binder_id, &producer_binder_id); | ||
| 203 | layer->Open(consumer_binder_id, producer_binder_id); | ||
| 204 | |||
| 205 | if (auto* display = layer->GetDisplay(); display != nullptr) { | ||
| 206 | m_surface_flinger->AddLayerToDisplayStack(display->GetId(), consumer_binder_id); | ||
| 207 | } | ||
| 208 | } | ||
| 209 | |||
| 210 | void Container::DestroyBufferQueueLocked(Layer* layer) { | ||
| 211 | if (auto* display = layer->GetDisplay(); display != nullptr) { | 209 | if (auto* display = layer->GetDisplay(); display != nullptr) { |
| 212 | m_surface_flinger->RemoveLayerFromDisplayStack(display->GetId(), | 210 | m_surface_flinger->RemoveLayerFromDisplayStack(display->GetId(), |
| 213 | layer->GetConsumerBinderId()); | 211 | layer->GetConsumerBinderId()); |
| 214 | } | 212 | } |
| 215 | 213 | ||
| 216 | layer->Close(); | 214 | layer->Close(); |
| 217 | m_surface_flinger->DestroyBufferQueue(layer->GetConsumerBinderId(), | 215 | |
| 218 | layer->GetProducerBinderId()); | 216 | R_SUCCEED(); |
| 219 | } | 217 | } |
| 220 | 218 | ||
| 221 | bool Container::ComposeOnDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, | 219 | bool Container::ComposeOnDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, |
diff --git a/src/core/hle/service/vi/container.h b/src/core/hle/service/vi/container.h index cd0d2ca86..5eac4d77d 100644 --- a/src/core/hle/service/vi/container.h +++ b/src/core/hle/service/vi/container.h | |||
| @@ -72,9 +72,6 @@ private: | |||
| 72 | Result OpenLayerLocked(s32* out_producer_binder_id, u64 layer_id, u64 aruid); | 72 | Result OpenLayerLocked(s32* out_producer_binder_id, u64 layer_id, u64 aruid); |
| 73 | Result CloseLayerLocked(u64 layer_id); | 73 | Result CloseLayerLocked(u64 layer_id); |
| 74 | 74 | ||
| 75 | void CreateBufferQueueLocked(Layer* layer); | ||
| 76 | void DestroyBufferQueueLocked(Layer* layer); | ||
| 77 | |||
| 78 | public: | 75 | public: |
| 79 | bool ComposeOnDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, u64 display_id); | 76 | bool ComposeOnDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, u64 display_id); |
| 80 | 77 | ||
diff --git a/src/core/hle/service/vi/layer.h b/src/core/hle/service/vi/layer.h index b85c8df61..e4c9c9864 100644 --- a/src/core/hle/service/vi/layer.h +++ b/src/core/hle/service/vi/layer.h | |||
| @@ -13,29 +13,31 @@ class Layer { | |||
| 13 | public: | 13 | public: |
| 14 | constexpr Layer() = default; | 14 | constexpr Layer() = default; |
| 15 | 15 | ||
| 16 | void Initialize(u64 id, u64 owner_aruid, Display* display) { | 16 | void Initialize(u64 id, u64 owner_aruid, Display* display, s32 consumer_binder_id, |
| 17 | s32 producer_binder_id) { | ||
| 17 | m_id = id; | 18 | m_id = id; |
| 18 | m_owner_aruid = owner_aruid; | 19 | m_owner_aruid = owner_aruid; |
| 19 | m_display = display; | 20 | m_display = display; |
| 21 | m_consumer_binder_id = consumer_binder_id; | ||
| 22 | m_producer_binder_id = producer_binder_id; | ||
| 20 | m_is_initialized = true; | 23 | m_is_initialized = true; |
| 21 | } | 24 | } |
| 22 | 25 | ||
| 23 | void Finalize() { | 26 | void Finalize() { |
| 24 | m_id = {}; | 27 | m_id = {}; |
| 28 | m_owner_aruid = {}; | ||
| 25 | m_display = {}; | 29 | m_display = {}; |
| 30 | m_consumer_binder_id = {}; | ||
| 31 | m_producer_binder_id = {}; | ||
| 26 | m_is_initialized = {}; | 32 | m_is_initialized = {}; |
| 27 | } | 33 | } |
| 28 | 34 | ||
| 29 | void Open(s32 consumer_binder_id, s32 producer_binder_id) { | 35 | void Open() { |
| 30 | m_consumer_binder_id = consumer_binder_id; | ||
| 31 | m_producer_binder_id = producer_binder_id; | ||
| 32 | m_is_open = true; | 36 | m_is_open = true; |
| 33 | } | 37 | } |
| 34 | 38 | ||
| 35 | void Close() { | 39 | void Close() { |
| 36 | m_producer_binder_id = {}; | 40 | m_is_open = false; |
| 37 | m_consumer_binder_id = {}; | ||
| 38 | m_is_open = {}; | ||
| 39 | } | 41 | } |
| 40 | 42 | ||
| 41 | u64 GetId() const { | 43 | u64 GetId() const { |
diff --git a/src/core/hle/service/vi/layer_list.h b/src/core/hle/service/vi/layer_list.h index 1738ede9a..4afca6f40 100644 --- a/src/core/hle/service/vi/layer_list.h +++ b/src/core/hle/service/vi/layer_list.h | |||
| @@ -11,13 +11,15 @@ class LayerList { | |||
| 11 | public: | 11 | public: |
| 12 | constexpr LayerList() = default; | 12 | constexpr LayerList() = default; |
| 13 | 13 | ||
| 14 | Layer* CreateLayer(u64 owner_aruid, Display* display) { | 14 | Layer* CreateLayer(u64 owner_aruid, Display* display, s32 consumer_binder_id, |
| 15 | s32 producer_binder_id) { | ||
| 15 | Layer* const layer = GetFreeLayer(); | 16 | Layer* const layer = GetFreeLayer(); |
| 16 | if (!layer) { | 17 | if (!layer) { |
| 17 | return nullptr; | 18 | return nullptr; |
| 18 | } | 19 | } |
| 19 | 20 | ||
| 20 | layer->Initialize(++m_next_id, owner_aruid, display); | 21 | layer->Initialize(++m_next_id, owner_aruid, display, consumer_binder_id, |
| 22 | producer_binder_id); | ||
| 21 | return layer; | 23 | return layer; |
| 22 | } | 24 | } |
| 23 | 25 | ||
diff --git a/src/core/hle/service/vi/shared_buffer_manager.cpp b/src/core/hle/service/vi/shared_buffer_manager.cpp index 869b18961..12cba16fa 100644 --- a/src/core/hle/service/vi/shared_buffer_manager.cpp +++ b/src/core/hle/service/vi/shared_buffer_manager.cpp | |||
| @@ -285,7 +285,7 @@ void SharedBufferManager::DestroySession(Kernel::KProcess* owner_process) { | |||
| 285 | auto& session = it->second; | 285 | auto& session = it->second; |
| 286 | 286 | ||
| 287 | // Destroy the layer. | 287 | // Destroy the layer. |
| 288 | R_ASSERT(m_container.DestroyStrayLayer(session.layer_id)); | 288 | m_container.DestroyStrayLayer(session.layer_id); |
| 289 | 289 | ||
| 290 | // Close nvmap handle. | 290 | // Close nvmap handle. |
| 291 | FreeHandle(session.buffer_nvmap_handle, *m_nvdrv, session.nvmap_fd); | 291 | FreeHandle(session.buffer_nvmap_handle, *m_nvdrv, session.nvmap_fd); |
| @@ -322,8 +322,6 @@ Result SharedBufferManager::GetSharedBufferMemoryHandleId(u64* out_buffer_size, | |||
| 322 | Result SharedBufferManager::AcquireSharedFrameBuffer(android::Fence* out_fence, | 322 | Result SharedBufferManager::AcquireSharedFrameBuffer(android::Fence* out_fence, |
| 323 | std::array<s32, 4>& out_slot_indexes, | 323 | std::array<s32, 4>& out_slot_indexes, |
| 324 | s64* out_target_slot, u64 layer_id) { | 324 | s64* out_target_slot, u64 layer_id) { |
| 325 | std::scoped_lock lk{m_guard}; | ||
| 326 | |||
| 327 | // Get the producer. | 325 | // Get the producer. |
| 328 | std::shared_ptr<android::BufferQueueProducer> producer; | 326 | std::shared_ptr<android::BufferQueueProducer> producer; |
| 329 | R_TRY(m_container.GetLayerProducerHandle(std::addressof(producer), layer_id)); | 327 | R_TRY(m_container.GetLayerProducerHandle(std::addressof(producer), layer_id)); |
| @@ -347,8 +345,6 @@ Result SharedBufferManager::PresentSharedFrameBuffer(android::Fence fence, | |||
| 347 | Common::Rectangle<s32> crop_region, | 345 | Common::Rectangle<s32> crop_region, |
| 348 | u32 transform, s32 swap_interval, u64 layer_id, | 346 | u32 transform, s32 swap_interval, u64 layer_id, |
| 349 | s64 slot) { | 347 | s64 slot) { |
| 350 | std::scoped_lock lk{m_guard}; | ||
| 351 | |||
| 352 | // Get the producer. | 348 | // Get the producer. |
| 353 | std::shared_ptr<android::BufferQueueProducer> producer; | 349 | std::shared_ptr<android::BufferQueueProducer> producer; |
| 354 | R_TRY(m_container.GetLayerProducerHandle(std::addressof(producer), layer_id)); | 350 | R_TRY(m_container.GetLayerProducerHandle(std::addressof(producer), layer_id)); |
| @@ -379,8 +375,6 @@ Result SharedBufferManager::PresentSharedFrameBuffer(android::Fence fence, | |||
| 379 | } | 375 | } |
| 380 | 376 | ||
| 381 | Result SharedBufferManager::CancelSharedFrameBuffer(u64 layer_id, s64 slot) { | 377 | Result SharedBufferManager::CancelSharedFrameBuffer(u64 layer_id, s64 slot) { |
| 382 | std::scoped_lock lk{m_guard}; | ||
| 383 | |||
| 384 | // Get the producer. | 378 | // Get the producer. |
| 385 | std::shared_ptr<android::BufferQueueProducer> producer; | 379 | std::shared_ptr<android::BufferQueueProducer> producer; |
| 386 | R_TRY(m_container.GetLayerProducerHandle(std::addressof(producer), layer_id)); | 380 | R_TRY(m_container.GetLayerProducerHandle(std::addressof(producer), layer_id)); |
| @@ -394,8 +388,6 @@ Result SharedBufferManager::CancelSharedFrameBuffer(u64 layer_id, s64 slot) { | |||
| 394 | 388 | ||
| 395 | Result SharedBufferManager::GetSharedFrameBufferAcquirableEvent(Kernel::KReadableEvent** out_event, | 389 | Result SharedBufferManager::GetSharedFrameBufferAcquirableEvent(Kernel::KReadableEvent** out_event, |
| 396 | u64 layer_id) { | 390 | u64 layer_id) { |
| 397 | std::scoped_lock lk{m_guard}; | ||
| 398 | |||
| 399 | // Get the producer. | 391 | // Get the producer. |
| 400 | std::shared_ptr<android::BufferQueueProducer> producer; | 392 | std::shared_ptr<android::BufferQueueProducer> producer; |
| 401 | R_TRY(m_container.GetLayerProducerHandle(std::addressof(producer), layer_id)); | 393 | R_TRY(m_container.GetLayerProducerHandle(std::addressof(producer), layer_id)); |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv.cpp b/src/shader_recompiler/backend/spirv/emit_spirv.cpp index 0031fa5fb..3f9698d6b 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv.cpp | |||
| @@ -261,7 +261,9 @@ void DefineEntryPoint(const IR::Program& program, EmitContext& ctx, Id main) { | |||
| 261 | case Stage::Geometry: | 261 | case Stage::Geometry: |
| 262 | execution_model = spv::ExecutionModel::Geometry; | 262 | execution_model = spv::ExecutionModel::Geometry; |
| 263 | ctx.AddCapability(spv::Capability::Geometry); | 263 | ctx.AddCapability(spv::Capability::Geometry); |
| 264 | ctx.AddCapability(spv::Capability::GeometryStreams); | 264 | if (ctx.profile.support_geometry_streams) { |
| 265 | ctx.AddCapability(spv::Capability::GeometryStreams); | ||
| 266 | } | ||
| 265 | switch (ctx.runtime_info.input_topology) { | 267 | switch (ctx.runtime_info.input_topology) { |
| 266 | case InputTopology::Points: | 268 | case InputTopology::Points: |
| 267 | ctx.AddExecutionMode(main, spv::ExecutionMode::InputPoints); | 269 | ctx.AddExecutionMode(main, spv::ExecutionMode::InputPoints); |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_special.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_special.cpp index 9f7b6bb4b..f60da758e 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_special.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_special.cpp | |||
| @@ -129,7 +129,9 @@ void EmitEmitVertex(EmitContext& ctx, const IR::Value& stream) { | |||
| 129 | if (ctx.runtime_info.convert_depth_mode && !ctx.profile.support_native_ndc) { | 129 | if (ctx.runtime_info.convert_depth_mode && !ctx.profile.support_native_ndc) { |
| 130 | ConvertDepthMode(ctx); | 130 | ConvertDepthMode(ctx); |
| 131 | } | 131 | } |
| 132 | if (stream.IsImmediate()) { | 132 | if (!ctx.profile.support_geometry_streams) { |
| 133 | throw NotImplementedException("Geometry streams"); | ||
| 134 | } else if (stream.IsImmediate()) { | ||
| 133 | ctx.OpEmitStreamVertex(ctx.Def(stream)); | 135 | ctx.OpEmitStreamVertex(ctx.Def(stream)); |
| 134 | } else { | 136 | } else { |
| 135 | LOG_WARNING(Shader_SPIRV, "Stream is not immediate"); | 137 | LOG_WARNING(Shader_SPIRV, "Stream is not immediate"); |
| @@ -140,7 +142,9 @@ void EmitEmitVertex(EmitContext& ctx, const IR::Value& stream) { | |||
| 140 | } | 142 | } |
| 141 | 143 | ||
| 142 | void EmitEndPrimitive(EmitContext& ctx, const IR::Value& stream) { | 144 | void EmitEndPrimitive(EmitContext& ctx, const IR::Value& stream) { |
| 143 | if (stream.IsImmediate()) { | 145 | if (!ctx.profile.support_geometry_streams) { |
| 146 | throw NotImplementedException("Geometry streams"); | ||
| 147 | } else if (stream.IsImmediate()) { | ||
| 144 | ctx.OpEndStreamPrimitive(ctx.Def(stream)); | 148 | ctx.OpEndStreamPrimitive(ctx.Def(stream)); |
| 145 | } else { | 149 | } else { |
| 146 | LOG_WARNING(Shader_SPIRV, "Stream is not immediate"); | 150 | LOG_WARNING(Shader_SPIRV, "Stream is not immediate"); |
diff --git a/src/shader_recompiler/profile.h b/src/shader_recompiler/profile.h index 7578d41cc..90e46bb1b 100644 --- a/src/shader_recompiler/profile.h +++ b/src/shader_recompiler/profile.h | |||
| @@ -44,6 +44,7 @@ struct Profile { | |||
| 44 | bool support_gl_derivative_control{}; | 44 | bool support_gl_derivative_control{}; |
| 45 | bool support_scaled_attributes{}; | 45 | bool support_scaled_attributes{}; |
| 46 | bool support_multi_viewport{}; | 46 | bool support_multi_viewport{}; |
| 47 | bool support_geometry_streams{}; | ||
| 47 | 48 | ||
| 48 | bool warp_size_potentially_larger_than_guest{}; | 49 | bool warp_size_potentially_larger_than_guest{}; |
| 49 | 50 | ||
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 296c90e85..ed7a5b27e 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h | |||
| @@ -35,7 +35,7 @@ BufferCache<P>::BufferCache(Tegra::MaxwellDeviceMemoryManager& device_memory_, R | |||
| 35 | const s64 min_spacing_critical = device_local_memory - 512_MiB; | 35 | const s64 min_spacing_critical = device_local_memory - 512_MiB; |
| 36 | const s64 mem_threshold = std::min(device_local_memory, TARGET_THRESHOLD); | 36 | const s64 mem_threshold = std::min(device_local_memory, TARGET_THRESHOLD); |
| 37 | const s64 min_vacancy_expected = (6 * mem_threshold) / 10; | 37 | const s64 min_vacancy_expected = (6 * mem_threshold) / 10; |
| 38 | const s64 min_vacancy_critical = (3 * mem_threshold) / 10; | 38 | const s64 min_vacancy_critical = (2 * mem_threshold) / 10; |
| 39 | minimum_memory = static_cast<u64>( | 39 | minimum_memory = static_cast<u64>( |
| 40 | std::max(std::min(device_local_memory - min_vacancy_expected, min_spacing_expected), | 40 | std::max(std::min(device_local_memory - min_vacancy_expected, min_spacing_expected), |
| 41 | DEFAULT_EXPECTED_MEMORY)); | 41 | DEFAULT_EXPECTED_MEMORY)); |
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 20f7a9702..d34b585d6 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | |||
| @@ -352,6 +352,7 @@ PipelineCache::PipelineCache(Tegra::MaxwellDeviceMemoryManager& device_memory_, | |||
| 352 | .support_native_ndc = device.IsExtDepthClipControlSupported(), | 352 | .support_native_ndc = device.IsExtDepthClipControlSupported(), |
| 353 | .support_scaled_attributes = !device.MustEmulateScaledFormats(), | 353 | .support_scaled_attributes = !device.MustEmulateScaledFormats(), |
| 354 | .support_multi_viewport = device.SupportsMultiViewport(), | 354 | .support_multi_viewport = device.SupportsMultiViewport(), |
| 355 | .support_geometry_streams = device.AreTransformFeedbackGeometryStreamsSupported(), | ||
| 355 | 356 | ||
| 356 | .warp_size_potentially_larger_than_guest = device.IsWarpSizePotentiallyBiggerThanGuest(), | 357 | .warp_size_potentially_larger_than_guest = device.IsWarpSizePotentiallyBiggerThanGuest(), |
| 357 | 358 | ||
diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp index 5b3c7aa5a..9055b1b92 100644 --- a/src/video_core/surface.cpp +++ b/src/video_core/surface.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #include "common/common_types.h" | 4 | #include "common/common_types.h" |
| 5 | #include "common/math_util.h" | 5 | #include "common/math_util.h" |
| 6 | #include "common/settings.h" | ||
| 6 | #include "video_core/surface.h" | 7 | #include "video_core/surface.h" |
| 7 | 8 | ||
| 8 | namespace VideoCore::Surface { | 9 | namespace VideoCore::Surface { |
| @@ -400,11 +401,20 @@ std::pair<u32, u32> GetASTCBlockSize(PixelFormat format) { | |||
| 400 | return {DefaultBlockWidth(format), DefaultBlockHeight(format)}; | 401 | return {DefaultBlockWidth(format), DefaultBlockHeight(format)}; |
| 401 | } | 402 | } |
| 402 | 403 | ||
| 403 | u64 EstimatedDecompressedSize(u64 base_size, PixelFormat format) { | 404 | u64 TranscodedAstcSize(u64 base_size, PixelFormat format) { |
| 404 | constexpr u64 RGBA8_PIXEL_SIZE = 4; | 405 | constexpr u64 RGBA8_PIXEL_SIZE = 4; |
| 405 | const u64 base_block_size = static_cast<u64>(DefaultBlockWidth(format)) * | 406 | const u64 base_block_size = static_cast<u64>(DefaultBlockWidth(format)) * |
| 406 | static_cast<u64>(DefaultBlockHeight(format)) * RGBA8_PIXEL_SIZE; | 407 | static_cast<u64>(DefaultBlockHeight(format)) * RGBA8_PIXEL_SIZE; |
| 407 | return (base_size * base_block_size) / BytesPerBlock(format); | 408 | const u64 uncompressed_size = (base_size * base_block_size) / BytesPerBlock(format); |
| 409 | |||
| 410 | switch (Settings::values.astc_recompression.GetValue()) { | ||
| 411 | case Settings::AstcRecompression::Bc1: | ||
| 412 | return uncompressed_size / 8; | ||
| 413 | case Settings::AstcRecompression::Bc3: | ||
| 414 | return uncompressed_size / 4; | ||
| 415 | default: | ||
| 416 | return uncompressed_size; | ||
| 417 | } | ||
| 408 | } | 418 | } |
| 409 | 419 | ||
| 410 | } // namespace VideoCore::Surface | 420 | } // namespace VideoCore::Surface |
diff --git a/src/video_core/surface.h b/src/video_core/surface.h index a5e8e2f62..ec9cd2fbf 100644 --- a/src/video_core/surface.h +++ b/src/video_core/surface.h | |||
| @@ -517,6 +517,6 @@ size_t PixelComponentSizeBitsInteger(PixelFormat format); | |||
| 517 | 517 | ||
| 518 | std::pair<u32, u32> GetASTCBlockSize(PixelFormat format); | 518 | std::pair<u32, u32> GetASTCBlockSize(PixelFormat format); |
| 519 | 519 | ||
| 520 | u64 EstimatedDecompressedSize(u64 base_size, PixelFormat format); | 520 | u64 TranscodedAstcSize(u64 base_size, PixelFormat format); |
| 521 | 521 | ||
| 522 | } // namespace VideoCore::Surface | 522 | } // namespace VideoCore::Surface |
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 01c3561c9..53b4876f2 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -55,7 +55,7 @@ TextureCache<P>::TextureCache(Runtime& runtime_, Tegra::MaxwellDeviceMemoryManag | |||
| 55 | const s64 min_spacing_critical = device_local_memory - 512_MiB; | 55 | const s64 min_spacing_critical = device_local_memory - 512_MiB; |
| 56 | const s64 mem_threshold = std::min(device_local_memory, TARGET_THRESHOLD); | 56 | const s64 mem_threshold = std::min(device_local_memory, TARGET_THRESHOLD); |
| 57 | const s64 min_vacancy_expected = (6 * mem_threshold) / 10; | 57 | const s64 min_vacancy_expected = (6 * mem_threshold) / 10; |
| 58 | const s64 min_vacancy_critical = (3 * mem_threshold) / 10; | 58 | const s64 min_vacancy_critical = (2 * mem_threshold) / 10; |
| 59 | expected_memory = static_cast<u64>( | 59 | expected_memory = static_cast<u64>( |
| 60 | std::max(std::min(device_local_memory - min_vacancy_expected, min_spacing_expected), | 60 | std::max(std::min(device_local_memory - min_vacancy_expected, min_spacing_expected), |
| 61 | DEFAULT_EXPECTED_MEMORY)); | 61 | DEFAULT_EXPECTED_MEMORY)); |
| @@ -1979,7 +1979,7 @@ void TextureCache<P>::RegisterImage(ImageId image_id) { | |||
| 1979 | if ((IsPixelFormatASTC(image.info.format) && | 1979 | if ((IsPixelFormatASTC(image.info.format) && |
| 1980 | True(image.flags & ImageFlagBits::AcceleratedUpload)) || | 1980 | True(image.flags & ImageFlagBits::AcceleratedUpload)) || |
| 1981 | True(image.flags & ImageFlagBits::Converted)) { | 1981 | True(image.flags & ImageFlagBits::Converted)) { |
| 1982 | tentative_size = EstimatedDecompressedSize(tentative_size, image.info.format); | 1982 | tentative_size = TranscodedAstcSize(tentative_size, image.info.format); |
| 1983 | } | 1983 | } |
| 1984 | total_used_memory += Common::AlignUp(tentative_size, 1024); | 1984 | total_used_memory += Common::AlignUp(tentative_size, 1024); |
| 1985 | image.lru_index = lru_cache.Insert(image_id, frame_tick); | 1985 | image.lru_index = lru_cache.Insert(image_id, frame_tick); |
| @@ -2149,7 +2149,7 @@ void TextureCache<P>::DeleteImage(ImageId image_id, bool immediate_delete) { | |||
| 2149 | if ((IsPixelFormatASTC(image.info.format) && | 2149 | if ((IsPixelFormatASTC(image.info.format) && |
| 2150 | True(image.flags & ImageFlagBits::AcceleratedUpload)) || | 2150 | True(image.flags & ImageFlagBits::AcceleratedUpload)) || |
| 2151 | True(image.flags & ImageFlagBits::Converted)) { | 2151 | True(image.flags & ImageFlagBits::Converted)) { |
| 2152 | tentative_size = EstimatedDecompressedSize(tentative_size, image.info.format); | 2152 | tentative_size = TranscodedAstcSize(tentative_size, image.info.format); |
| 2153 | } | 2153 | } |
| 2154 | total_used_memory -= Common::AlignUp(tentative_size, 1024); | 2154 | total_used_memory -= Common::AlignUp(tentative_size, 1024); |
| 2155 | const GPUVAddr gpu_addr = image.gpu_addr; | 2155 | const GPUVAddr gpu_addr = image.gpu_addr; |
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index d7216d349..b94924a58 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp | |||
| @@ -1297,10 +1297,6 @@ u64 Device::GetDeviceMemoryUsage() const { | |||
| 1297 | } | 1297 | } |
| 1298 | 1298 | ||
| 1299 | void Device::CollectPhysicalMemoryInfo() { | 1299 | void Device::CollectPhysicalMemoryInfo() { |
| 1300 | // Account for resolution scaling in memory limits | ||
| 1301 | const size_t normal_memory = 6_GiB; | ||
| 1302 | const size_t scaler_memory = 1_GiB * Settings::values.resolution_info.ScaleUp(1); | ||
| 1303 | |||
| 1304 | // Calculate limits using memory budget | 1300 | // Calculate limits using memory budget |
| 1305 | VkPhysicalDeviceMemoryBudgetPropertiesEXT budget{}; | 1301 | VkPhysicalDeviceMemoryBudgetPropertiesEXT budget{}; |
| 1306 | budget.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT; | 1302 | budget.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT; |
| @@ -1331,7 +1327,15 @@ void Device::CollectPhysicalMemoryInfo() { | |||
| 1331 | if (!is_integrated) { | 1327 | if (!is_integrated) { |
| 1332 | const u64 reserve_memory = std::min<u64>(device_access_memory / 8, 1_GiB); | 1328 | const u64 reserve_memory = std::min<u64>(device_access_memory / 8, 1_GiB); |
| 1333 | device_access_memory -= reserve_memory; | 1329 | device_access_memory -= reserve_memory; |
| 1334 | device_access_memory = std::min<u64>(device_access_memory, normal_memory + scaler_memory); | 1330 | |
| 1331 | if (Settings::values.vram_usage_mode.GetValue() != Settings::VramUsageMode::Aggressive) { | ||
| 1332 | // Account for resolution scaling in memory limits | ||
| 1333 | const size_t normal_memory = 6_GiB; | ||
| 1334 | const size_t scaler_memory = 1_GiB * Settings::values.resolution_info.ScaleUp(1); | ||
| 1335 | device_access_memory = | ||
| 1336 | std::min<u64>(device_access_memory, normal_memory + scaler_memory); | ||
| 1337 | } | ||
| 1338 | |||
| 1335 | return; | 1339 | return; |
| 1336 | } | 1340 | } |
| 1337 | const s64 available_memory = static_cast<s64>(device_access_memory - device_initial_usage); | 1341 | const s64 available_memory = static_cast<s64>(device_access_memory - device_initial_usage); |
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index a2ec26697..e3abe8ddf 100644 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h | |||
| @@ -499,6 +499,11 @@ public: | |||
| 499 | return extensions.transform_feedback; | 499 | return extensions.transform_feedback; |
| 500 | } | 500 | } |
| 501 | 501 | ||
| 502 | /// Returns true if the device supports VK_EXT_transform_feedback properly. | ||
| 503 | bool AreTransformFeedbackGeometryStreamsSupported() const { | ||
| 504 | return features.transform_feedback.geometryStreams; | ||
| 505 | } | ||
| 506 | |||
| 502 | /// Returns true if the device supports VK_EXT_custom_border_color. | 507 | /// Returns true if the device supports VK_EXT_custom_border_color. |
| 503 | bool IsExtCustomBorderColorSupported() const { | 508 | bool IsExtCustomBorderColorSupported() const { |
| 504 | return extensions.custom_border_color; | 509 | return extensions.custom_border_color; |
diff --git a/src/yuzu/configuration/shared_translation.cpp b/src/yuzu/configuration/shared_translation.cpp index d138b53c8..0549e8ae4 100644 --- a/src/yuzu/configuration/shared_translation.cpp +++ b/src/yuzu/configuration/shared_translation.cpp | |||
| @@ -164,6 +164,11 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) { | |||
| 164 | "the emulator to decompress to an intermediate format any card supports, RGBA8.\n" | 164 | "the emulator to decompress to an intermediate format any card supports, RGBA8.\n" |
| 165 | "This option recompresses RGBA8 to either the BC1 or BC3 format, saving VRAM but " | 165 | "This option recompresses RGBA8 to either the BC1 or BC3 format, saving VRAM but " |
| 166 | "negatively affecting image quality.")); | 166 | "negatively affecting image quality.")); |
| 167 | INSERT(Settings, vram_usage_mode, tr("VRAM Usage Mode:"), | ||
| 168 | tr("Selects whether the emulator should prefer to conserve memory or make maximum usage " | ||
| 169 | "of available video memory for performance. Has no effect on integrated graphics. " | ||
| 170 | "Aggressive mode may severely impact the performance of other applications such as " | ||
| 171 | "recording software.")); | ||
| 167 | INSERT( | 172 | INSERT( |
| 168 | Settings, vsync_mode, tr("VSync Mode:"), | 173 | Settings, vsync_mode, tr("VSync Mode:"), |
| 169 | tr("FIFO (VSync) does not drop frames or exhibit tearing but is limited by the screen " | 174 | tr("FIFO (VSync) does not drop frames or exhibit tearing but is limited by the screen " |
| @@ -315,6 +320,11 @@ std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent) { | |||
| 315 | PAIR(AstcRecompression, Bc1, tr("BC1 (Low quality)")), | 320 | PAIR(AstcRecompression, Bc1, tr("BC1 (Low quality)")), |
| 316 | PAIR(AstcRecompression, Bc3, tr("BC3 (Medium quality)")), | 321 | PAIR(AstcRecompression, Bc3, tr("BC3 (Medium quality)")), |
| 317 | }}); | 322 | }}); |
| 323 | translations->insert({Settings::EnumMetadata<Settings::VramUsageMode>::Index(), | ||
| 324 | { | ||
| 325 | PAIR(VramUsageMode, Conservative, tr("Conservative")), | ||
| 326 | PAIR(VramUsageMode, Aggressive, tr("Aggressive")), | ||
| 327 | }}); | ||
| 318 | translations->insert({Settings::EnumMetadata<Settings::RendererBackend>::Index(), | 328 | translations->insert({Settings::EnumMetadata<Settings::RendererBackend>::Index(), |
| 319 | { | 329 | { |
| 320 | #ifdef HAS_OPENGL | 330 | #ifdef HAS_OPENGL |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 236642fb9..b2ae3db52 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -1604,6 +1604,7 @@ void GMainWindow::ConnectMenuEvents() { | |||
| 1604 | connect_menu(ui->action_Open_yuzu_Folder, &GMainWindow::OnOpenYuzuFolder); | 1604 | connect_menu(ui->action_Open_yuzu_Folder, &GMainWindow::OnOpenYuzuFolder); |
| 1605 | connect_menu(ui->action_Verify_installed_contents, &GMainWindow::OnVerifyInstalledContents); | 1605 | connect_menu(ui->action_Verify_installed_contents, &GMainWindow::OnVerifyInstalledContents); |
| 1606 | connect_menu(ui->action_Install_Firmware, &GMainWindow::OnInstallFirmware); | 1606 | connect_menu(ui->action_Install_Firmware, &GMainWindow::OnInstallFirmware); |
| 1607 | connect_menu(ui->action_Install_Keys, &GMainWindow::OnInstallDecryptionKeys); | ||
| 1607 | connect_menu(ui->action_About, &GMainWindow::OnAbout); | 1608 | connect_menu(ui->action_About, &GMainWindow::OnAbout); |
| 1608 | } | 1609 | } |
| 1609 | 1610 | ||
| @@ -1633,6 +1634,7 @@ void GMainWindow::UpdateMenuState() { | |||
| 1633 | } | 1634 | } |
| 1634 | 1635 | ||
| 1635 | ui->action_Install_Firmware->setEnabled(!emulation_running); | 1636 | ui->action_Install_Firmware->setEnabled(!emulation_running); |
| 1637 | ui->action_Install_Keys->setEnabled(!emulation_running); | ||
| 1636 | 1638 | ||
| 1637 | for (QAction* action : applet_actions) { | 1639 | for (QAction* action : applet_actions) { |
| 1638 | action->setEnabled(is_firmware_available && !emulation_running); | 1640 | action->setEnabled(is_firmware_available && !emulation_running); |
| @@ -4169,9 +4171,8 @@ void GMainWindow::OnInstallFirmware() { | |||
| 4169 | return; | 4171 | return; |
| 4170 | } | 4172 | } |
| 4171 | 4173 | ||
| 4172 | QString firmware_source_location = | 4174 | const QString firmware_source_location = QFileDialog::getExistingDirectory( |
| 4173 | QFileDialog::getExistingDirectory(this, tr("Select Dumped Firmware Source Location"), | 4175 | this, tr("Select Dumped Firmware Source Location"), {}, QFileDialog::ShowDirsOnly); |
| 4174 | QString::fromStdString(""), QFileDialog::ShowDirsOnly); | ||
| 4175 | if (firmware_source_location.isEmpty()) { | 4176 | if (firmware_source_location.isEmpty()) { |
| 4176 | return; | 4177 | return; |
| 4177 | } | 4178 | } |
| @@ -4202,8 +4203,9 @@ void GMainWindow::OnInstallFirmware() { | |||
| 4202 | std::vector<std::filesystem::path> out; | 4203 | std::vector<std::filesystem::path> out; |
| 4203 | const Common::FS::DirEntryCallable callback = | 4204 | const Common::FS::DirEntryCallable callback = |
| 4204 | [&out](const std::filesystem::directory_entry& entry) { | 4205 | [&out](const std::filesystem::directory_entry& entry) { |
| 4205 | if (entry.path().has_extension() && entry.path().extension() == ".nca") | 4206 | if (entry.path().has_extension() && entry.path().extension() == ".nca") { |
| 4206 | out.emplace_back(entry.path()); | 4207 | out.emplace_back(entry.path()); |
| 4208 | } | ||
| 4207 | 4209 | ||
| 4208 | return true; | 4210 | return true; |
| 4209 | }; | 4211 | }; |
| @@ -4235,7 +4237,6 @@ void GMainWindow::OnInstallFirmware() { | |||
| 4235 | auto firmware_vdir = sysnand_content_vdir->GetDirectoryRelative("registered"); | 4237 | auto firmware_vdir = sysnand_content_vdir->GetDirectoryRelative("registered"); |
| 4236 | 4238 | ||
| 4237 | bool success = true; | 4239 | bool success = true; |
| 4238 | bool cancelled = false; | ||
| 4239 | int i = 0; | 4240 | int i = 0; |
| 4240 | for (const auto& firmware_src_path : out) { | 4241 | for (const auto& firmware_src_path : out) { |
| 4241 | i++; | 4242 | i++; |
| @@ -4250,24 +4251,22 @@ void GMainWindow::OnInstallFirmware() { | |||
| 4250 | success = false; | 4251 | success = false; |
| 4251 | } | 4252 | } |
| 4252 | 4253 | ||
| 4253 | if (QtProgressCallback(100, 20 + (int)(((float)(i) / (float)out.size()) * 70.0))) { | 4254 | if (QtProgressCallback( |
| 4254 | success = false; | 4255 | 100, 20 + static_cast<int>(((i) / static_cast<float>(out.size())) * 70.0))) { |
| 4255 | cancelled = true; | 4256 | progress.close(); |
| 4256 | break; | 4257 | QMessageBox::warning( |
| 4258 | this, tr("Firmware install failed"), | ||
| 4259 | tr("Firmware installation cancelled, firmware may be in bad state, " | ||
| 4260 | "restart yuzu or re-install firmware.")); | ||
| 4261 | return; | ||
| 4257 | } | 4262 | } |
| 4258 | } | 4263 | } |
| 4259 | 4264 | ||
| 4260 | if (!success && !cancelled) { | 4265 | if (!success) { |
| 4261 | progress.close(); | 4266 | progress.close(); |
| 4262 | QMessageBox::critical(this, tr("Firmware install failed"), | 4267 | QMessageBox::critical(this, tr("Firmware install failed"), |
| 4263 | tr("One or more firmware files failed to copy into NAND.")); | 4268 | tr("One or more firmware files failed to copy into NAND.")); |
| 4264 | return; | 4269 | return; |
| 4265 | } else if (cancelled) { | ||
| 4266 | progress.close(); | ||
| 4267 | QMessageBox::warning(this, tr("Firmware install failed"), | ||
| 4268 | tr("Firmware installation cancelled, firmware may be in bad state, " | ||
| 4269 | "restart yuzu or re-install firmware.")); | ||
| 4270 | return; | ||
| 4271 | } | 4270 | } |
| 4272 | 4271 | ||
| 4273 | // Re-scan VFS for the newly placed firmware files. | 4272 | // Re-scan VFS for the newly placed firmware files. |
| @@ -4295,6 +4294,84 @@ void GMainWindow::OnInstallFirmware() { | |||
| 4295 | OnCheckFirmwareDecryption(); | 4294 | OnCheckFirmwareDecryption(); |
| 4296 | } | 4295 | } |
| 4297 | 4296 | ||
| 4297 | void GMainWindow::OnInstallDecryptionKeys() { | ||
| 4298 | // Don't do this while emulation is running. | ||
| 4299 | if (emu_thread != nullptr && emu_thread->IsRunning()) { | ||
| 4300 | return; | ||
| 4301 | } | ||
| 4302 | |||
| 4303 | const QString key_source_location = QFileDialog::getOpenFileName( | ||
| 4304 | this, tr("Select Dumped Keys Location"), {}, QStringLiteral("prod.keys (prod.keys)"), {}, | ||
| 4305 | QFileDialog::ReadOnly); | ||
| 4306 | if (key_source_location.isEmpty()) { | ||
| 4307 | return; | ||
| 4308 | } | ||
| 4309 | |||
| 4310 | // Verify that it contains prod.keys, title.keys and optionally, key_retail.bin | ||
| 4311 | LOG_INFO(Frontend, "Installing key files from {}", key_source_location.toStdString()); | ||
| 4312 | |||
| 4313 | const std::filesystem::path prod_key_path = key_source_location.toStdString(); | ||
| 4314 | const std::filesystem::path key_source_path = prod_key_path.parent_path(); | ||
| 4315 | if (!Common::FS::IsDir(key_source_path)) { | ||
| 4316 | return; | ||
| 4317 | } | ||
| 4318 | |||
| 4319 | bool prod_keys_found = false; | ||
| 4320 | std::vector<std::filesystem::path> source_key_files; | ||
| 4321 | |||
| 4322 | if (Common::FS::Exists(prod_key_path)) { | ||
| 4323 | prod_keys_found = true; | ||
| 4324 | source_key_files.emplace_back(prod_key_path); | ||
| 4325 | } | ||
| 4326 | |||
| 4327 | if (Common::FS::Exists(key_source_path / "title.keys")) { | ||
| 4328 | source_key_files.emplace_back(key_source_path / "title.keys"); | ||
| 4329 | } | ||
| 4330 | |||
| 4331 | if (Common::FS::Exists(key_source_path / "key_retail.bin")) { | ||
| 4332 | source_key_files.emplace_back(key_source_path / "key_retail.bin"); | ||
| 4333 | } | ||
| 4334 | |||
| 4335 | // There should be at least prod.keys. | ||
| 4336 | if (source_key_files.empty() || !prod_keys_found) { | ||
| 4337 | QMessageBox::warning(this, tr("Decryption Keys install failed"), | ||
| 4338 | tr("prod.keys is a required decryption key file.")); | ||
| 4339 | return; | ||
| 4340 | } | ||
| 4341 | |||
| 4342 | const auto yuzu_keys_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::KeysDir); | ||
| 4343 | for (auto key_file : source_key_files) { | ||
| 4344 | std::filesystem::path destination_key_file = yuzu_keys_dir / key_file.filename(); | ||
| 4345 | if (!std::filesystem::copy_file(key_file, destination_key_file, | ||
| 4346 | std::filesystem::copy_options::overwrite_existing)) { | ||
| 4347 | LOG_ERROR(Frontend, "Failed to copy file {} to {}", key_file.string(), | ||
| 4348 | destination_key_file.string()); | ||
| 4349 | QMessageBox::critical(this, tr("Decryption Keys install failed"), | ||
| 4350 | tr("One or more keys failed to copy.")); | ||
| 4351 | return; | ||
| 4352 | } | ||
| 4353 | } | ||
| 4354 | |||
| 4355 | // Reinitialize the key manager, re-read the vfs (for update/dlc files), | ||
| 4356 | // and re-populate the game list in the UI if the user has already added | ||
| 4357 | // game folders. | ||
| 4358 | Core::Crypto::KeyManager::Instance().ReloadKeys(); | ||
| 4359 | system->GetFileSystemController().CreateFactories(*vfs); | ||
| 4360 | game_list->PopulateAsync(UISettings::values.game_dirs); | ||
| 4361 | |||
| 4362 | if (ContentManager::AreKeysPresent()) { | ||
| 4363 | QMessageBox::information(this, tr("Decryption Keys install succeeded"), | ||
| 4364 | tr("Decryption Keys were successfully installed")); | ||
| 4365 | } else { | ||
| 4366 | QMessageBox::critical( | ||
| 4367 | this, tr("Decryption Keys install failed"), | ||
| 4368 | tr("Decryption Keys failed to initialize. Check that your dumping tools are " | ||
| 4369 | "up to date and re-dump keys.")); | ||
| 4370 | } | ||
| 4371 | |||
| 4372 | OnCheckFirmwareDecryption(); | ||
| 4373 | } | ||
| 4374 | |||
| 4298 | void GMainWindow::OnAbout() { | 4375 | void GMainWindow::OnAbout() { |
| 4299 | AboutDialog aboutDialog(this); | 4376 | AboutDialog aboutDialog(this); |
| 4300 | aboutDialog.exec(); | 4377 | aboutDialog.exec(); |
diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 1f0e35c67..fce643f3f 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h | |||
| @@ -381,6 +381,7 @@ private slots: | |||
| 381 | void OnOpenYuzuFolder(); | 381 | void OnOpenYuzuFolder(); |
| 382 | void OnVerifyInstalledContents(); | 382 | void OnVerifyInstalledContents(); |
| 383 | void OnInstallFirmware(); | 383 | void OnInstallFirmware(); |
| 384 | void OnInstallDecryptionKeys(); | ||
| 384 | void OnAbout(); | 385 | void OnAbout(); |
| 385 | void OnToggleFilterBar(); | 386 | void OnToggleFilterBar(); |
| 386 | void OnToggleStatusBar(); | 387 | void OnToggleStatusBar(); |
diff --git a/src/yuzu/main.ui b/src/yuzu/main.ui index 6ff444a22..85dc1f2f6 100644 --- a/src/yuzu/main.ui +++ b/src/yuzu/main.ui | |||
| @@ -165,8 +165,9 @@ | |||
| 165 | <addaction name="separator"/> | 165 | <addaction name="separator"/> |
| 166 | <addaction name="action_Configure_Tas"/> | 166 | <addaction name="action_Configure_Tas"/> |
| 167 | </widget> | 167 | </widget> |
| 168 | <addaction name="action_Verify_installed_contents"/> | 168 | <addaction name="action_Install_Keys"/> |
| 169 | <addaction name="action_Install_Firmware"/> | 169 | <addaction name="action_Install_Firmware"/> |
| 170 | <addaction name="action_Verify_installed_contents"/> | ||
| 170 | <addaction name="separator"/> | 171 | <addaction name="separator"/> |
| 171 | <addaction name="menu_cabinet_applet"/> | 172 | <addaction name="menu_cabinet_applet"/> |
| 172 | <addaction name="action_Load_Album"/> | 173 | <addaction name="action_Load_Album"/> |
| @@ -469,6 +470,11 @@ | |||
| 469 | <string>Install Firmware</string> | 470 | <string>Install Firmware</string> |
| 470 | </property> | 471 | </property> |
| 471 | </action> | 472 | </action> |
| 473 | <action name="action_Install_Keys"> | ||
| 474 | <property name="text"> | ||
| 475 | <string>Install Decryption Keys</string> | ||
| 476 | </property> | ||
| 477 | </action> | ||
| 472 | </widget> | 478 | </widget> |
| 473 | <resources> | 479 | <resources> |
| 474 | <include location="yuzu.qrc"/> | 480 | <include location="yuzu.qrc"/> |