diff options
4 files changed, 48 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..8cc26e518 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 |
| @@ -458,13 +459,23 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 458 | @SuppressLint("SourceLockedOrientationActivity") | 459 | @SuppressLint("SourceLockedOrientationActivity") |
| 459 | private fun updateOrientation() { | 460 | private fun updateOrientation() { |
| 460 | emulationActivity?.let { | 461 | emulationActivity?.let { |
| 461 | it.requestedOrientation = when (IntSetting.RENDERER_SCREEN_LAYOUT.getInt()) { | 462 | val orientationSetting = |
| 462 | Settings.LayoutOption_MobileLandscape -> | 463 | EmulationOrientation.from(IntSetting.RENDERER_SCREEN_LAYOUT.getInt()) |
| 464 | it.requestedOrientation = when (orientationSetting) { | ||
| 465 | EmulationOrientation.Unspecified -> ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED | ||
| 466 | EmulationOrientation.SensorLandscape -> | ||
| 463 | ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE | 467 | ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE |
| 464 | Settings.LayoutOption_MobilePortrait -> | 468 | |
| 465 | ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT | 469 | EmulationOrientation.Landscape -> ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE |
| 466 | Settings.LayoutOption_Unspecified -> ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED | 470 | EmulationOrientation.ReverseLandscape -> |
| 467 | else -> ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE | 471 | ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE |
| 472 | |||
| 473 | EmulationOrientation.SensorPortrait -> | ||
| 474 | ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT | ||
| 475 | |||
| 476 | EmulationOrientation.Portrait -> ActivityInfo.SCREEN_ORIENTATION_PORTRAIT | ||
| 477 | EmulationOrientation.ReversePortrait -> | ||
| 478 | ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT | ||
| 468 | } | 479 | } |
| 469 | } | 480 | } |
| 470 | } | 481 | } |
| @@ -651,7 +662,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 651 | @SuppressLint("SourceLockedOrientationActivity") | 662 | @SuppressLint("SourceLockedOrientationActivity") |
| 652 | private fun startConfiguringControls() { | 663 | private fun startConfiguringControls() { |
| 653 | // Lock the current orientation to prevent editing inconsistencies | 664 | // Lock the current orientation to prevent editing inconsistencies |
| 654 | if (IntSetting.RENDERER_SCREEN_LAYOUT.getInt() == Settings.LayoutOption_Unspecified) { | 665 | if (IntSetting.RENDERER_SCREEN_LAYOUT.getInt() == EmulationOrientation.Unspecified.int) { |
| 655 | emulationActivity?.let { | 666 | emulationActivity?.let { |
| 656 | it.requestedOrientation = | 667 | it.requestedOrientation = |
| 657 | if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) { | 668 | if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) { |
| @@ -669,7 +680,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 669 | binding.doneControlConfig.visibility = View.GONE | 680 | binding.doneControlConfig.visibility = View.GONE |
| 670 | binding.surfaceInputOverlay.setIsInEditMode(false) | 681 | binding.surfaceInputOverlay.setIsInEditMode(false) |
| 671 | // Unlock the orientation if it was locked for editing | 682 | // Unlock the orientation if it was locked for editing |
| 672 | if (IntSetting.RENDERER_SCREEN_LAYOUT.getInt() == Settings.LayoutOption_Unspecified) { | 683 | if (IntSetting.RENDERER_SCREEN_LAYOUT.getInt() == EmulationOrientation.Unspecified.int) { |
| 673 | emulationActivity?.let { | 684 | emulationActivity?.let { |
| 674 | it.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED | 685 | it.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED |
| 675 | } | 686 | } |
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> |