diff options
| author | 2024-01-04 15:51:08 -0500 | |
|---|---|---|
| committer | 2024-01-04 15:51:08 -0500 | |
| commit | 519904e8a88184855003a55c6305abf7bebdb2bc (patch) | |
| tree | 51919520a8b250e09aa9a9c2a2be9581e1007241 | |
| parent | Merge pull request #12570 from t895/generic-config-pain (diff) | |
| parent | android: Update orientation on emulation fragment start (diff) | |
| download | yuzu-519904e8a88184855003a55c6305abf7bebdb2bc.tar.gz yuzu-519904e8a88184855003a55c6305abf7bebdb2bc.tar.xz yuzu-519904e8a88184855003a55c6305abf7bebdb2bc.zip | |
Merge pull request #12571 from t895/apply-orientation-on-start
android: Expose more orientation options
4 files changed, 49 insertions, 14 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt index 43caac989..fee80bb21 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt | |||
| @@ -79,7 +79,18 @@ object Settings { | |||
| 79 | const val PREF_THEME_MODE = "ThemeMode" | 79 | const val PREF_THEME_MODE = "ThemeMode" |
| 80 | const val PREF_BLACK_BACKGROUNDS = "BlackBackgrounds" | 80 | const val PREF_BLACK_BACKGROUNDS = "BlackBackgrounds" |
| 81 | 81 | ||
| 82 | const val LayoutOption_Unspecified = 0 | 82 | enum class EmulationOrientation(val int: Int) { |
| 83 | const val LayoutOption_MobilePortrait = 4 | 83 | Unspecified(0), |
| 84 | const val LayoutOption_MobileLandscape = 5 | 84 | SensorLandscape(5), |
| 85 | Landscape(1), | ||
| 86 | ReverseLandscape(2), | ||
| 87 | SensorPortrait(6), | ||
| 88 | Portrait(4), | ||
| 89 | ReversePortrait(3); | ||
| 90 | |||
| 91 | companion object { | ||
| 92 | fun from(int: Int): EmulationOrientation = | ||
| 93 | entries.firstOrNull { it.int == int } ?: Unspecified | ||
| 94 | } | ||
| 95 | } | ||
| 85 | } | 96 | } |
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 510b2b5eb..9efc1705d 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 | |||
| @@ -50,6 +50,7 @@ import org.yuzu.yuzu_emu.databinding.FragmentEmulationBinding | |||
| 50 | import org.yuzu.yuzu_emu.features.settings.model.BooleanSetting | 50 | import org.yuzu.yuzu_emu.features.settings.model.BooleanSetting |
| 51 | import org.yuzu.yuzu_emu.features.settings.model.IntSetting | 51 | import org.yuzu.yuzu_emu.features.settings.model.IntSetting |
| 52 | import org.yuzu.yuzu_emu.features.settings.model.Settings | 52 | import org.yuzu.yuzu_emu.features.settings.model.Settings |
| 53 | import org.yuzu.yuzu_emu.features.settings.model.Settings.EmulationOrientation | ||
| 53 | import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile | 54 | import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile |
| 54 | import org.yuzu.yuzu_emu.model.DriverViewModel | 55 | import org.yuzu.yuzu_emu.model.DriverViewModel |
| 55 | import org.yuzu.yuzu_emu.model.Game | 56 | import org.yuzu.yuzu_emu.model.Game |
| @@ -99,6 +100,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 99 | */ | 100 | */ |
| 100 | override fun onCreate(savedInstanceState: Bundle?) { | 101 | override fun onCreate(savedInstanceState: Bundle?) { |
| 101 | super.onCreate(savedInstanceState) | 102 | super.onCreate(savedInstanceState) |
| 103 | updateOrientation() | ||
| 102 | 104 | ||
| 103 | val intentUri: Uri? = requireActivity().intent.data | 105 | val intentUri: Uri? = requireActivity().intent.data |
| 104 | var intentGame: Game? = null | 106 | var intentGame: Game? = null |
| @@ -458,13 +460,23 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 458 | @SuppressLint("SourceLockedOrientationActivity") | 460 | @SuppressLint("SourceLockedOrientationActivity") |
| 459 | private fun updateOrientation() { | 461 | private fun updateOrientation() { |
| 460 | emulationActivity?.let { | 462 | emulationActivity?.let { |
| 461 | it.requestedOrientation = when (IntSetting.RENDERER_SCREEN_LAYOUT.getInt()) { | 463 | val orientationSetting = |
| 462 | Settings.LayoutOption_MobileLandscape -> | 464 | EmulationOrientation.from(IntSetting.RENDERER_SCREEN_LAYOUT.getInt()) |
| 465 | it.requestedOrientation = when (orientationSetting) { | ||
| 466 | EmulationOrientation.Unspecified -> ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED | ||
| 467 | EmulationOrientation.SensorLandscape -> | ||
| 463 | ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE | 468 | ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE |
| 464 | Settings.LayoutOption_MobilePortrait -> | 469 | |
| 465 | ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT | 470 | EmulationOrientation.Landscape -> ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE |
| 466 | Settings.LayoutOption_Unspecified -> ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED | 471 | EmulationOrientation.ReverseLandscape -> |
| 467 | else -> ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE | 472 | ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE |
| 473 | |||
| 474 | EmulationOrientation.SensorPortrait -> | ||
| 475 | ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT | ||
| 476 | |||
| 477 | EmulationOrientation.Portrait -> ActivityInfo.SCREEN_ORIENTATION_PORTRAIT | ||
| 478 | EmulationOrientation.ReversePortrait -> | ||
| 479 | ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT | ||
| 468 | } | 480 | } |
| 469 | } | 481 | } |
| 470 | } | 482 | } |
| @@ -651,7 +663,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 651 | @SuppressLint("SourceLockedOrientationActivity") | 663 | @SuppressLint("SourceLockedOrientationActivity") |
| 652 | private fun startConfiguringControls() { | 664 | private fun startConfiguringControls() { |
| 653 | // Lock the current orientation to prevent editing inconsistencies | 665 | // Lock the current orientation to prevent editing inconsistencies |
| 654 | if (IntSetting.RENDERER_SCREEN_LAYOUT.getInt() == Settings.LayoutOption_Unspecified) { | 666 | if (IntSetting.RENDERER_SCREEN_LAYOUT.getInt() == EmulationOrientation.Unspecified.int) { |
| 655 | emulationActivity?.let { | 667 | emulationActivity?.let { |
| 656 | it.requestedOrientation = | 668 | it.requestedOrientation = |
| 657 | if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) { | 669 | if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) { |
| @@ -669,7 +681,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 669 | binding.doneControlConfig.visibility = View.GONE | 681 | binding.doneControlConfig.visibility = View.GONE |
| 670 | binding.surfaceInputOverlay.setIsInEditMode(false) | 682 | binding.surfaceInputOverlay.setIsInEditMode(false) |
| 671 | // Unlock the orientation if it was locked for editing | 683 | // Unlock the orientation if it was locked for editing |
| 672 | if (IntSetting.RENDERER_SCREEN_LAYOUT.getInt() == Settings.LayoutOption_Unspecified) { | 684 | if (IntSetting.RENDERER_SCREEN_LAYOUT.getInt() == EmulationOrientation.Unspecified.int) { |
| 673 | emulationActivity?.let { | 685 | emulationActivity?.let { |
| 674 | it.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED | 686 | it.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED |
| 675 | } | 687 | } |
diff --git a/src/android/app/src/main/res/values/arrays.xml b/src/android/app/src/main/res/values/arrays.xml index 45d57c3ea..0363ff3b6 100644 --- a/src/android/app/src/main/res/values/arrays.xml +++ b/src/android/app/src/main/res/values/arrays.xml | |||
| @@ -118,15 +118,23 @@ | |||
| 118 | </integer-array> | 118 | </integer-array> |
| 119 | 119 | ||
| 120 | <string-array name="rendererScreenLayoutNames"> | 120 | <string-array name="rendererScreenLayoutNames"> |
| 121 | <item>@string/screen_layout_auto</item> | ||
| 122 | <item>@string/screen_layout_sensor_landscape</item> | ||
| 121 | <item>@string/screen_layout_landscape</item> | 123 | <item>@string/screen_layout_landscape</item> |
| 124 | <item>@string/screen_layout_reverse_landscape</item> | ||
| 125 | <item>@string/screen_layout_sensor_portrait</item> | ||
| 122 | <item>@string/screen_layout_portrait</item> | 126 | <item>@string/screen_layout_portrait</item> |
| 123 | <item>@string/screen_layout_auto</item> | 127 | <item>@string/screen_layout_reverse_portrait</item> |
| 124 | </string-array> | 128 | </string-array> |
| 125 | 129 | ||
| 126 | <integer-array name="rendererScreenLayoutValues"> | 130 | <integer-array name="rendererScreenLayoutValues"> |
| 131 | <item>0</item> | ||
| 127 | <item>5</item> | 132 | <item>5</item> |
| 133 | <item>1</item> | ||
| 134 | <item>2</item> | ||
| 135 | <item>6</item> | ||
| 128 | <item>4</item> | 136 | <item>4</item> |
| 129 | <item>0</item> | 137 | <item>3</item> |
| 130 | </integer-array> | 138 | </integer-array> |
| 131 | 139 | ||
| 132 | <string-array name="rendererAspectRatioNames"> | 140 | <string-array name="rendererAspectRatioNames"> |
diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index 1bedcb1ef..83aa1b781 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml | |||
| @@ -463,9 +463,13 @@ | |||
| 463 | <string name="anti_aliasing_smaa">SMAA</string> | 463 | <string name="anti_aliasing_smaa">SMAA</string> |
| 464 | 464 | ||
| 465 | <!-- Screen Layouts --> | 465 | <!-- Screen Layouts --> |
| 466 | <string name="screen_layout_auto">Auto</string> | ||
| 467 | <string name="screen_layout_sensor_landscape">Sensor landscape</string> | ||
| 466 | <string name="screen_layout_landscape">Landscape</string> | 468 | <string name="screen_layout_landscape">Landscape</string> |
| 469 | <string name="screen_layout_reverse_landscape">Reverse landscape</string> | ||
| 470 | <string name="screen_layout_sensor_portrait">Sensor portrait</string> | ||
| 467 | <string name="screen_layout_portrait">Portrait</string> | 471 | <string name="screen_layout_portrait">Portrait</string> |
| 468 | <string name="screen_layout_auto">Auto</string> | 472 | <string name="screen_layout_reverse_portrait">Reverse portrait</string> |
| 469 | 473 | ||
| 470 | <!-- Aspect Ratios --> | 474 | <!-- Aspect Ratios --> |
| 471 | <string name="ratio_default">Default (16:9)</string> | 475 | <string name="ratio_default">Default (16:9)</string> |