diff options
| author | 2023-06-16 11:45:32 -0700 | |
|---|---|---|
| committer | 2023-06-16 11:45:32 -0700 | |
| commit | 4112031c81a7bd3d80c541a85e8e7dc717820aeb (patch) | |
| tree | 22feb8b7a4e18e7b3e2672f58a714d00307b850b /src | |
| parent | Merge pull request #10739 from zeltermann/sdl-cpuinfo (diff) | |
| parent | android: Fix aspect ratio when rotating screen (diff) | |
| download | yuzu-4112031c81a7bd3d80c541a85e8e7dc717820aeb.tar.gz yuzu-4112031c81a7bd3d80c541a85e8e7dc717820aeb.tar.xz yuzu-4112031c81a7bd3d80c541a85e8e7dc717820aeb.zip | |
Merge pull request #10801 from 8bitDream/fix_aspect
android: Fix aspect ratio when rotating screen
Diffstat (limited to 'src')
| -rw-r--r-- | src/android/app/src/main/AndroidManifest.xml | 1 | ||||
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt | 47 |
2 files changed, 20 insertions, 28 deletions
diff --git a/src/android/app/src/main/AndroidManifest.xml b/src/android/app/src/main/AndroidManifest.xml index a6f87fc2e..e31ad69e2 100644 --- a/src/android/app/src/main/AndroidManifest.xml +++ b/src/android/app/src/main/AndroidManifest.xml | |||
| @@ -53,6 +53,7 @@ SPDX-License-Identifier: GPL-3.0-or-later | |||
| 53 | <activity | 53 | <activity |
| 54 | android:name="org.yuzu.yuzu_emu.activities.EmulationActivity" | 54 | android:name="org.yuzu.yuzu_emu.activities.EmulationActivity" |
| 55 | android:theme="@style/Theme.Yuzu.Main" | 55 | android:theme="@style/Theme.Yuzu.Main" |
| 56 | android:screenOrientation="userLandscape" | ||
| 56 | android:supportsPictureInPicture="true" | 57 | android:supportsPictureInPicture="true" |
| 57 | android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|uiMode" | 58 | android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|uiMode" |
| 58 | android:exported="true"> | 59 | android:exported="true"> |
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 42e2e5b75..4643418c1 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 | |||
| @@ -85,20 +85,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 85 | onReturnFromSettings = context.activityResultRegistry.register( | 85 | onReturnFromSettings = context.activityResultRegistry.register( |
| 86 | "SettingsResult", | 86 | "SettingsResult", |
| 87 | ActivityResultContracts.StartActivityForResult() | 87 | ActivityResultContracts.StartActivityForResult() |
| 88 | ) { | 88 | ) { updateScreenLayout() } |
| 89 | binding.surfaceEmulation.setAspectRatio( | ||
| 90 | when (IntSetting.RENDERER_ASPECT_RATIO.int) { | ||
| 91 | 0 -> Rational(16, 9) | ||
| 92 | 1 -> Rational(4, 3) | ||
| 93 | 2 -> Rational(21, 9) | ||
| 94 | 3 -> Rational(16, 10) | ||
| 95 | 4 -> null // Stretch | ||
| 96 | else -> Rational(16, 9) | ||
| 97 | } | ||
| 98 | ) | ||
| 99 | emulationActivity?.buildPictureInPictureParams() | ||
| 100 | updateScreenLayout() | ||
| 101 | } | ||
| 102 | } else { | 89 | } else { |
| 103 | throw IllegalStateException("EmulationFragment must have EmulationActivity parent") | 90 | throw IllegalStateException("EmulationFragment must have EmulationActivity parent") |
| 104 | } | 91 | } |
| @@ -242,17 +229,6 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 242 | DirectoryInitialization.start(requireContext()) | 229 | DirectoryInitialization.start(requireContext()) |
| 243 | } | 230 | } |
| 244 | 231 | ||
| 245 | binding.surfaceEmulation.setAspectRatio( | ||
| 246 | when (IntSetting.RENDERER_ASPECT_RATIO.int) { | ||
| 247 | 0 -> Rational(16, 9) | ||
| 248 | 1 -> Rational(4, 3) | ||
| 249 | 2 -> Rational(21, 9) | ||
| 250 | 3 -> Rational(16, 10) | ||
| 251 | 4 -> null // Stretch | ||
| 252 | else -> Rational(16, 9) | ||
| 253 | } | ||
| 254 | ) | ||
| 255 | |||
| 256 | updateScreenLayout() | 232 | updateScreenLayout() |
| 257 | 233 | ||
| 258 | emulationState.run(emulationActivity!!.isActivityRecreated) | 234 | emulationState.run(emulationActivity!!.isActivityRecreated) |
| @@ -315,7 +291,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 315 | } | 291 | } |
| 316 | 292 | ||
| 317 | @SuppressLint("SourceLockedOrientationActivity") | 293 | @SuppressLint("SourceLockedOrientationActivity") |
| 318 | private fun updateScreenLayout() { | 294 | private fun updateOrientation() { |
| 319 | emulationActivity?.let { | 295 | emulationActivity?.let { |
| 320 | it.requestedOrientation = when (IntSetting.RENDERER_SCREEN_LAYOUT.int) { | 296 | it.requestedOrientation = when (IntSetting.RENDERER_SCREEN_LAYOUT.int) { |
| 321 | Settings.LayoutOption_MobileLandscape -> | 297 | Settings.LayoutOption_MobileLandscape -> |
| @@ -326,7 +302,21 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 326 | else -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE | 302 | else -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE |
| 327 | } | 303 | } |
| 328 | } | 304 | } |
| 329 | onConfigurationChanged(resources.configuration) | 305 | } |
| 306 | |||
| 307 | private fun updateScreenLayout() { | ||
| 308 | binding.surfaceEmulation.setAspectRatio( | ||
| 309 | when (IntSetting.RENDERER_ASPECT_RATIO.int) { | ||
| 310 | 0 -> Rational(16, 9) | ||
| 311 | 1 -> Rational(4, 3) | ||
| 312 | 2 -> Rational(21, 9) | ||
| 313 | 3 -> Rational(16, 10) | ||
| 314 | 4 -> null // Stretch | ||
| 315 | else -> Rational(16, 9) | ||
| 316 | } | ||
| 317 | ) | ||
| 318 | emulationActivity?.buildPictureInPictureParams() | ||
| 319 | updateOrientation() | ||
| 330 | } | 320 | } |
| 331 | 321 | ||
| 332 | private fun updateFoldableLayout( | 322 | private fun updateFoldableLayout( |
| @@ -359,7 +349,8 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 359 | binding.overlayContainer.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT | 349 | binding.overlayContainer.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT |
| 360 | binding.inGameMenu.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT | 350 | binding.inGameMenu.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT |
| 361 | isInFoldableLayout = false | 351 | isInFoldableLayout = false |
| 362 | updateScreenLayout() | 352 | updateOrientation() |
| 353 | onConfigurationChanged(resources.configuration) | ||
| 363 | } | 354 | } |
| 364 | binding.emulationContainer.requestLayout() | 355 | binding.emulationContainer.requestLayout() |
| 365 | binding.inputContainer.requestLayout() | 356 | binding.inputContainer.requestLayout() |