summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Abandoned Cart2023-06-14 07:14:43 -0400
committerGravatar Abandoned Cart2023-06-14 16:35:58 -0400
commite20c4fbbd46afd94e708da214904052015b35776 (patch)
treee41a00adfe79a7177e7bd0e2b87befe077536e9e
parentandroid: Display FPS with emulation on hinge (diff)
downloadyuzu-e20c4fbbd46afd94e708da214904052015b35776.tar.gz
yuzu-e20c4fbbd46afd94e708da214904052015b35776.tar.xz
yuzu-e20c4fbbd46afd94e708da214904052015b35776.zip
android: Initialize defaults for each orientations
Diffstat (limited to '')
-rw-r--r--.gitignore2
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt42
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt6
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt7
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt32
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlay.kt153
-rw-r--r--src/android/app/src/main/res/values/integers.xml120
7 files changed, 189 insertions, 173 deletions
diff --git a/.gitignore b/.gitignore
index a5f7248c7..fbadb208b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,6 +26,8 @@ CMakeSettings.json
26# OSX global filetypes 26# OSX global filetypes
27# Created by Finder or Spotlight in directories for various OS functionality (indexing, etc) 27# Created by Finder or Spotlight in directories for various OS functionality (indexing, etc)
28.DS_Store 28.DS_Store
29.DS_Store?
30._*
29.AppleDouble 31.AppleDouble
30.LSOverride 32.LSOverride
31.Spotlight-V100 33.Spotlight-V100
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt
index 36cc27a05..5ca519f0a 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt
@@ -256,34 +256,50 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
256 } 256 }
257 } 257 }
258 258
259 private fun PictureInPictureParams.Builder.getPictureInPictureAspectBuilder() : PictureInPictureParams.Builder { 259 private fun PictureInPictureParams.Builder.getPictureInPictureAspectBuilder(): PictureInPictureParams.Builder {
260 val aspectRatio = when (IntSetting.RENDERER_ASPECT_RATIO.int) { 260 val aspectRatio = when (IntSetting.RENDERER_ASPECT_RATIO.int) {
261 0 -> Rational(16, 9) 261 0 -> Rational(16, 9)
262 1 -> Rational(4, 3) 262 1 -> Rational(4, 3)
263 2 -> Rational(21, 9) 263 2 -> Rational(21, 9)
264 3 -> Rational(16, 10) 264 3 -> Rational(16, 10)
265 else -> null 265 else -> null // Best fit
266 } 266 }
267 return this.apply { aspectRatio?.let { setAspectRatio(it) } } 267 return this.apply { aspectRatio?.let { setAspectRatio(it) } }
268 } 268 }
269 269
270 private fun PictureInPictureParams.Builder.getPictureInPictureActionsBuilder() : PictureInPictureParams.Builder { 270 private fun PictureInPictureParams.Builder.getPictureInPictureActionsBuilder(): PictureInPictureParams.Builder {
271 val pictureInPictureActions : MutableList<RemoteAction> = mutableListOf() 271 val pictureInPictureActions: MutableList<RemoteAction> = mutableListOf()
272 val pendingFlags = PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE 272 val pendingFlags = PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
273 273
274 if (NativeLibrary.isPaused()) { 274 if (NativeLibrary.isPaused()) {
275 val playIcon = Icon.createWithResource(this@EmulationActivity, R.drawable.ic_pip_play) 275 val playIcon = Icon.createWithResource(this@EmulationActivity, R.drawable.ic_pip_play)
276 val playPendingIntent = PendingIntent.getBroadcast( 276 val playPendingIntent = PendingIntent.getBroadcast(
277 this@EmulationActivity, R.drawable.ic_pip_play, Intent(actionPlay), pendingFlags 277 this@EmulationActivity,
278 R.drawable.ic_pip_play,
279 Intent(actionPlay),
280 pendingFlags
281 )
282 val playRemoteAction = RemoteAction(
283 playIcon,
284 getString(R.string.play),
285 getString(R.string.play),
286 playPendingIntent
278 ) 287 )
279 val playRemoteAction = RemoteAction(playIcon, getString(R.string.play), getString(R.string.play), playPendingIntent)
280 pictureInPictureActions.add(playRemoteAction) 288 pictureInPictureActions.add(playRemoteAction)
281 } else { 289 } else {
282 val pauseIcon = Icon.createWithResource(this@EmulationActivity, R.drawable.ic_pip_pause) 290 val pauseIcon = Icon.createWithResource(this@EmulationActivity, R.drawable.ic_pip_pause)
283 val pausePendingIntent = PendingIntent.getBroadcast( 291 val pausePendingIntent = PendingIntent.getBroadcast(
284 this@EmulationActivity, R.drawable.ic_pip_pause, Intent(actionPause), pendingFlags 292 this@EmulationActivity,
293 R.drawable.ic_pip_pause,
294 Intent(actionPause),
295 pendingFlags
296 )
297 val pauseRemoteAction = RemoteAction(
298 pauseIcon,
299 getString(R.string.pause),
300 getString(R.string.pause),
301 pausePendingIntent
285 ) 302 )
286 val pauseRemoteAction = RemoteAction(pauseIcon, getString(R.string.pause), getString(R.string.pause), pausePendingIntent)
287 pictureInPictureActions.add(pauseRemoteAction) 303 pictureInPictureActions.add(pauseRemoteAction)
288 } 304 }
289 305
@@ -300,7 +316,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
300 } 316 }
301 317
302 private var pictureInPictureReceiver = object : BroadcastReceiver() { 318 private var pictureInPictureReceiver = object : BroadcastReceiver() {
303 override fun onReceive(context : Context?, intent : Intent) { 319 override fun onReceive(context: Context?, intent: Intent) {
304 if (intent.action == actionPlay) { 320 if (intent.action == actionPlay) {
305 if (NativeLibrary.isPaused()) NativeLibrary.unPauseEmulation() 321 if (NativeLibrary.isPaused()) NativeLibrary.unPauseEmulation()
306 } else if (intent.action == actionPause) { 322 } else if (intent.action == actionPause) {
@@ -310,7 +326,10 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
310 } 326 }
311 } 327 }
312 328
313 override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration) { 329 override fun onPictureInPictureModeChanged(
330 isInPictureInPictureMode: Boolean,
331 newConfig: Configuration
332 ) {
314 super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig) 333 super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
315 if (isInPictureInPictureMode) { 334 if (isInPictureInPictureMode) {
316 IntentFilter().apply { 335 IntentFilter().apply {
@@ -322,7 +341,8 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
322 } else { 341 } else {
323 try { 342 try {
324 unregisterReceiver(pictureInPictureReceiver) 343 unregisterReceiver(pictureInPictureReceiver)
325 } catch (ignored : Exception) { } 344 } catch (ignored : Exception) {
345 }
326 } 346 }
327 } 347 }
328 348
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 4f753955b..6bcb7bee0 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
@@ -143,11 +143,7 @@ class Settings {
143 143
144 private val configFileSectionsMap: MutableMap<String, List<String>> = HashMap() 144 private val configFileSectionsMap: MutableMap<String, List<String>> = HashMap()
145 145
146 // These must match what is defined in src/core/settings.h 146 const val LayoutOption_Unspecified = 0
147 const val LayoutOption_Default = 0
148 const val LayoutOption_SingleScreen = 1
149 const val LayoutOption_LargeScreen = 2
150 const val LayoutOption_SideScreen = 3
151 const val LayoutOption_MobilePortrait = 4 147 const val LayoutOption_MobilePortrait = 4
152 const val LayoutOption_MobileLandscape = 5 148 const val LayoutOption_MobileLandscape = 5
153 149
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt
index 3853845ce..da7062b87 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt
@@ -241,7 +241,12 @@ class SettingsActivity : AppCompatActivity(), SettingsActivityView {
241 context.startActivity(settings) 241 context.startActivity(settings)
242 } 242 }
243 243
244 fun launch(context: Context, launcher: ActivityResultLauncher<Intent>, menuTag: String?, gameId: String?) { 244 fun launch(
245 context: Context,
246 launcher: ActivityResultLauncher<Intent>,
247 menuTag: String?,
248 gameId: String?
249 ) {
245 val settings = Intent(context, SettingsActivity::class.java) 250 val settings = Intent(context, SettingsActivity::class.java)
246 settings.putExtra(ARG_MENU_TAG, menuTag) 251 settings.putExtra(ARG_MENU_TAG, menuTag)
247 settings.putExtra(ARG_GAME_ID, gameId) 252 settings.putExtra(ARG_GAME_ID, gameId)
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 7db89aef0..d5725abe7 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
@@ -34,7 +34,6 @@ import androidx.fragment.app.Fragment
34import androidx.lifecycle.Lifecycle 34import androidx.lifecycle.Lifecycle
35import androidx.lifecycle.lifecycleScope 35import androidx.lifecycle.lifecycleScope
36import androidx.lifecycle.repeatOnLifecycle 36import androidx.lifecycle.repeatOnLifecycle
37import androidx.navigation.fragment.navArgs
38import androidx.preference.PreferenceManager 37import androidx.preference.PreferenceManager
39import androidx.window.layout.FoldingFeature 38import androidx.window.layout.FoldingFeature
40import androidx.window.layout.WindowInfoTracker 39import androidx.window.layout.WindowInfoTracker
@@ -165,7 +164,10 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
165 164
166 R.id.menu_settings -> { 165 R.id.menu_settings -> {
167 SettingsActivity.launch( 166 SettingsActivity.launch(
168 requireContext(), onReturnFromSettings, SettingsFile.FILE_NAME_CONFIG, "" 167 requireContext(),
168 onReturnFromSettings,
169 SettingsFile.FILE_NAME_CONFIG,
170 ""
169 ) 171 )
170 true 172 true
171 } 173 }
@@ -219,9 +221,9 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
219 } 221 }
220 if (!isInFoldableLayout) { 222 if (!isInFoldableLayout) {
221 if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { 223 if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
222 binding.surfaceInputOverlay.setOrientation(InputOverlay.PORTRAIT) 224 binding.surfaceInputOverlay.orientation = InputOverlay.PORTRAIT
223 } else { 225 } else {
224 binding.surfaceInputOverlay.setOrientation(InputOverlay.LANDSCAPE) 226 binding.surfaceInputOverlay.orientation = InputOverlay.LANDSCAPE
225 } 227 }
226 } 228 }
227 if (!binding.surfaceInputOverlay.isInEditMode) { 229 if (!binding.surfaceInputOverlay.isInEditMode) {
@@ -311,17 +313,11 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
311 @SuppressLint("SourceLockedOrientationActivity") 313 @SuppressLint("SourceLockedOrientationActivity")
312 private fun updateScreenLayout() { 314 private fun updateScreenLayout() {
313 emulationActivity?.let { 315 emulationActivity?.let {
314 when (IntSetting.RENDERER_SCREEN_LAYOUT.int) { 316 it.requestedOrientation = when (IntSetting.RENDERER_SCREEN_LAYOUT.int) {
315 Settings.LayoutOption_MobileLandscape -> { 317 Settings.LayoutOption_MobileLandscape -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
316 it.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE 318 Settings.LayoutOption_MobilePortrait -> ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
317 } 319 Settings.LayoutOption_Unspecified -> ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
318 Settings.LayoutOption_MobilePortrait -> { 320 else -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
319 it.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
320 }
321 Settings.LayoutOption_Default -> {
322 it.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
323 }
324 else -> { it.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE }
325 } 321 }
326 } 322 }
327 onConfigurationChanged(resources.configuration) 323 onConfigurationChanged(resources.configuration)
@@ -337,7 +333,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
337 binding.overlayContainer.layoutParams.height = it.bounds.bottom 333 binding.overlayContainer.layoutParams.height = it.bounds.bottom
338 binding.inGameMenu.layoutParams.height = it.bounds.bottom 334 binding.inGameMenu.layoutParams.height = it.bounds.bottom
339 isInFoldableLayout = true 335 isInFoldableLayout = true
340 binding.surfaceInputOverlay.setOrientation(InputOverlay.FOLDABLE) 336 binding.surfaceInputOverlay.orientation = InputOverlay.FOLDABLE
341 refreshInputOverlay() 337 refreshInputOverlay()
342 } 338 }
343 } 339 }
@@ -485,7 +481,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
485 @SuppressLint("SourceLockedOrientationActivity") 481 @SuppressLint("SourceLockedOrientationActivity")
486 private fun startConfiguringControls() { 482 private fun startConfiguringControls() {
487 // Lock the current orientation to prevent editing inconsistencies 483 // Lock the current orientation to prevent editing inconsistencies
488 if (IntSetting.RENDERER_SCREEN_LAYOUT.int == Settings.LayoutOption_Default) { 484 if (IntSetting.RENDERER_SCREEN_LAYOUT.int == Settings.LayoutOption_Unspecified) {
489 emulationActivity?.let { 485 emulationActivity?.let {
490 it.requestedOrientation = 486 it.requestedOrientation =
491 if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) { 487 if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
@@ -503,7 +499,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
503 binding.doneControlConfig.visibility = View.GONE 499 binding.doneControlConfig.visibility = View.GONE
504 binding.surfaceInputOverlay.setIsInEditMode(false) 500 binding.surfaceInputOverlay.setIsInEditMode(false)
505 // Unlock the orientation if it was locked for editing 501 // Unlock the orientation if it was locked for editing
506 if (IntSetting.RENDERER_SCREEN_LAYOUT.int == Settings.LayoutOption_Default) { 502 if (IntSetting.RENDERER_SCREEN_LAYOUT.int == Settings.LayoutOption_Unspecified) {
507 emulationActivity?.let { 503 emulationActivity?.let {
508 it.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED 504 it.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
509 } 505 }
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 9b3054f0b..aeef7731b 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
@@ -51,12 +51,14 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context
51 51
52 private lateinit var windowInsets: WindowInsets 52 private lateinit var windowInsets: WindowInsets
53 53
54 var orientation = LANDSCAPE
55
54 override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) { 56 override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
55 super.onLayout(changed, left, top, right, bottom) 57 super.onLayout(changed, left, top, right, bottom)
56 58
57 windowInsets = rootWindowInsets 59 windowInsets = rootWindowInsets
58 60
59 if (!preferences.getBoolean(Settings.PREF_OVERLAY_INIT, false)) { 61 if (!preferences.getBoolean("${Settings.PREF_OVERLAY_INIT}$orientation", false)) {
60 defaultOverlay() 62 defaultOverlay()
61 } 63 }
62 64
@@ -542,8 +544,8 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context
542 val min = windowSize.first 544 val min = windowSize.first
543 val max = windowSize.second 545 val max = windowSize.second
544 PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext).edit() 546 PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext).edit()
545 .putFloat("$sharedPrefsId$orientation-X", (x - min.x).toFloat() / max.x) 547 .putFloat("$sharedPrefsId-X$orientation", (x - min.x).toFloat() / max.x)
546 .putFloat("$sharedPrefsId$orientation-Y", (y - min.y).toFloat() / max.y) 548 .putFloat("$sharedPrefsId-Y$orientation", (y - min.y).toFloat() / max.y)
547 .apply() 549 .apply()
548 } 550 }
549 551
@@ -552,13 +554,13 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context
552 } 554 }
553 555
554 private fun defaultOverlay() { 556 private fun defaultOverlay() {
555 if (!preferences.getBoolean(Settings.PREF_OVERLAY_INIT, false)) { 557 if (!preferences.getBoolean("${Settings.PREF_OVERLAY_INIT}$orientation", false)) {
556 defaultOverlayByLayout(orientation) 558 defaultOverlayByLayout(orientation)
557 } 559 }
558 560
559 resetButtonPlacement() 561 resetButtonPlacement()
560 preferences.edit() 562 preferences.edit()
561 .putBoolean(Settings.PREF_OVERLAY_INIT, true) 563 .putBoolean("${Settings.PREF_OVERLAY_INIT}$orientation", true)
562 .apply() 564 .apply()
563 } 565 }
564 566
@@ -601,69 +603,69 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context
601 ) 603 )
602 604
603 private val portraitResources = arrayOf( 605 private val portraitResources = arrayOf(
604 R.integer.SWITCH_BUTTON_A_PORTRAIT_X, 606 R.integer.SWITCH_BUTTON_A_X_PORTRAIT,
605 R.integer.SWITCH_BUTTON_A_PORTRAIT_Y, 607 R.integer.SWITCH_BUTTON_A_Y_PORTRAIT,
606 R.integer.SWITCH_BUTTON_B_PORTRAIT_X, 608 R.integer.SWITCH_BUTTON_B_X_PORTRAIT,
607 R.integer.SWITCH_BUTTON_B_PORTRAIT_Y, 609 R.integer.SWITCH_BUTTON_B_Y_PORTRAIT,
608 R.integer.SWITCH_BUTTON_X_PORTRAIT_X, 610 R.integer.SWITCH_BUTTON_X_X_PORTRAIT,
609 R.integer.SWITCH_BUTTON_X_PORTRAIT_Y, 611 R.integer.SWITCH_BUTTON_X_Y_PORTRAIT,
610 R.integer.SWITCH_BUTTON_Y_PORTRAIT_X, 612 R.integer.SWITCH_BUTTON_Y_X_PORTRAIT,
611 R.integer.SWITCH_BUTTON_Y_PORTRAIT_Y, 613 R.integer.SWITCH_BUTTON_Y_Y_PORTRAIT,
612 R.integer.SWITCH_TRIGGER_ZL_PORTRAIT_X, 614 R.integer.SWITCH_TRIGGER_ZL_X_PORTRAIT,
613 R.integer.SWITCH_TRIGGER_ZL_PORTRAIT_Y, 615 R.integer.SWITCH_TRIGGER_ZL_Y_PORTRAIT,
614 R.integer.SWITCH_TRIGGER_ZR_PORTRAIT_X, 616 R.integer.SWITCH_TRIGGER_ZR_X_PORTRAIT,
615 R.integer.SWITCH_TRIGGER_ZR_PORTRAIT_Y, 617 R.integer.SWITCH_TRIGGER_ZR_Y_PORTRAIT,
616 R.integer.SWITCH_BUTTON_DPAD_PORTRAIT_X, 618 R.integer.SWITCH_BUTTON_DPAD_X_PORTRAIT,
617 R.integer.SWITCH_BUTTON_DPAD_PORTRAIT_Y, 619 R.integer.SWITCH_BUTTON_DPAD_Y_PORTRAIT,
618 R.integer.SWITCH_TRIGGER_L_PORTRAIT_X, 620 R.integer.SWITCH_TRIGGER_L_X_PORTRAIT,
619 R.integer.SWITCH_TRIGGER_L_PORTRAIT_Y, 621 R.integer.SWITCH_TRIGGER_L_Y_PORTRAIT,
620 R.integer.SWITCH_TRIGGER_R_PORTRAIT_X, 622 R.integer.SWITCH_TRIGGER_R_X_PORTRAIT,
621 R.integer.SWITCH_TRIGGER_R_PORTRAIT_Y, 623 R.integer.SWITCH_TRIGGER_R_Y_PORTRAIT,
622 R.integer.SWITCH_BUTTON_PLUS_PORTRAIT_X, 624 R.integer.SWITCH_BUTTON_PLUS_X_PORTRAIT,
623 R.integer.SWITCH_BUTTON_PLUS_PORTRAIT_Y, 625 R.integer.SWITCH_BUTTON_PLUS_Y_PORTRAIT,
624 R.integer.SWITCH_BUTTON_MINUS_PORTRAIT_X, 626 R.integer.SWITCH_BUTTON_MINUS_X_PORTRAIT,
625 R.integer.SWITCH_BUTTON_MINUS_PORTRAIT_Y, 627 R.integer.SWITCH_BUTTON_MINUS_Y_PORTRAIT,
626 R.integer.SWITCH_BUTTON_HOME_PORTRAIT_X, 628 R.integer.SWITCH_BUTTON_HOME_X_PORTRAIT,
627 R.integer.SWITCH_BUTTON_HOME_PORTRAIT_Y, 629 R.integer.SWITCH_BUTTON_HOME_Y_PORTRAIT,
628 R.integer.SWITCH_BUTTON_CAPTURE_PORTRAIT_X, 630 R.integer.SWITCH_BUTTON_CAPTURE_X_PORTRAIT,
629 R.integer.SWITCH_BUTTON_CAPTURE_PORTRAIT_Y, 631 R.integer.SWITCH_BUTTON_CAPTURE_Y_PORTRAIT,
630 R.integer.SWITCH_STICK_R_PORTRAIT_X, 632 R.integer.SWITCH_STICK_R_X_PORTRAIT,
631 R.integer.SWITCH_STICK_R_PORTRAIT_Y, 633 R.integer.SWITCH_STICK_R_Y_PORTRAIT,
632 R.integer.SWITCH_STICK_L_PORTRAIT_X, 634 R.integer.SWITCH_STICK_L_X_PORTRAIT,
633 R.integer.SWITCH_STICK_L_PORTRAIT_Y 635 R.integer.SWITCH_STICK_L_Y_PORTRAIT
634 ) 636 )
635 637
636 private val foldableResources = arrayOf( 638 private val foldableResources = arrayOf(
637 R.integer.SWITCH_BUTTON_A_FOLDABLE_X, 639 R.integer.SWITCH_BUTTON_A_X_FOLDABLE,
638 R.integer.SWITCH_BUTTON_A_FOLDABLE_Y, 640 R.integer.SWITCH_BUTTON_A_Y_FOLDABLE,
639 R.integer.SWITCH_BUTTON_B_FOLDABLE_X, 641 R.integer.SWITCH_BUTTON_B_X_FOLDABLE,
640 R.integer.SWITCH_BUTTON_B_FOLDABLE_Y, 642 R.integer.SWITCH_BUTTON_B_Y_FOLDABLE,
641 R.integer.SWITCH_BUTTON_X_FOLDABLE_X, 643 R.integer.SWITCH_BUTTON_X_X_FOLDABLE,
642 R.integer.SWITCH_BUTTON_X_FOLDABLE_Y, 644 R.integer.SWITCH_BUTTON_X_Y_FOLDABLE,
643 R.integer.SWITCH_BUTTON_Y_FOLDABLE_X, 645 R.integer.SWITCH_BUTTON_Y_X_FOLDABLE,
644 R.integer.SWITCH_BUTTON_Y_FOLDABLE_Y, 646 R.integer.SWITCH_BUTTON_Y_Y_FOLDABLE,
645 R.integer.SWITCH_TRIGGER_ZL_FOLDABLE_X, 647 R.integer.SWITCH_TRIGGER_ZL_X_FOLDABLE,
646 R.integer.SWITCH_TRIGGER_ZL_FOLDABLE_Y, 648 R.integer.SWITCH_TRIGGER_ZL_Y_FOLDABLE,
647 R.integer.SWITCH_TRIGGER_ZR_FOLDABLE_X, 649 R.integer.SWITCH_TRIGGER_ZR_X_FOLDABLE,
648 R.integer.SWITCH_TRIGGER_ZR_FOLDABLE_Y, 650 R.integer.SWITCH_TRIGGER_ZR_Y_FOLDABLE,
649 R.integer.SWITCH_BUTTON_DPAD_FOLDABLE_X, 651 R.integer.SWITCH_BUTTON_DPAD_X_FOLDABLE,
650 R.integer.SWITCH_BUTTON_DPAD_FOLDABLE_Y, 652 R.integer.SWITCH_BUTTON_DPAD_Y_FOLDABLE,
651 R.integer.SWITCH_TRIGGER_L_FOLDABLE_X, 653 R.integer.SWITCH_TRIGGER_L_X_FOLDABLE,
652 R.integer.SWITCH_TRIGGER_L_FOLDABLE_Y, 654 R.integer.SWITCH_TRIGGER_L_Y_FOLDABLE,
653 R.integer.SWITCH_TRIGGER_R_FOLDABLE_X, 655 R.integer.SWITCH_TRIGGER_R_X_FOLDABLE,
654 R.integer.SWITCH_TRIGGER_R_FOLDABLE_Y, 656 R.integer.SWITCH_TRIGGER_R_Y_FOLDABLE,
655 R.integer.SWITCH_BUTTON_PLUS_FOLDABLE_X, 657 R.integer.SWITCH_BUTTON_PLUS_X_FOLDABLE,
656 R.integer.SWITCH_BUTTON_PLUS_FOLDABLE_Y, 658 R.integer.SWITCH_BUTTON_PLUS_Y_FOLDABLE,
657 R.integer.SWITCH_BUTTON_MINUS_FOLDABLE_X, 659 R.integer.SWITCH_BUTTON_MINUS_X_FOLDABLE,
658 R.integer.SWITCH_BUTTON_MINUS_FOLDABLE_Y, 660 R.integer.SWITCH_BUTTON_MINUS_Y_FOLDABLE,
659 R.integer.SWITCH_BUTTON_HOME_FOLDABLE_X, 661 R.integer.SWITCH_BUTTON_HOME_X_FOLDABLE,
660 R.integer.SWITCH_BUTTON_HOME_FOLDABLE_Y, 662 R.integer.SWITCH_BUTTON_HOME_Y_FOLDABLE,
661 R.integer.SWITCH_BUTTON_CAPTURE_FOLDABLE_X, 663 R.integer.SWITCH_BUTTON_CAPTURE_X_FOLDABLE,
662 R.integer.SWITCH_BUTTON_CAPTURE_FOLDABLE_Y, 664 R.integer.SWITCH_BUTTON_CAPTURE_Y_FOLDABLE,
663 R.integer.SWITCH_STICK_R_FOLDABLE_X, 665 R.integer.SWITCH_STICK_R_X_FOLDABLE,
664 R.integer.SWITCH_STICK_R_FOLDABLE_Y, 666 R.integer.SWITCH_STICK_R_Y_FOLDABLE,
665 R.integer.SWITCH_STICK_L_FOLDABLE_X, 667 R.integer.SWITCH_STICK_L_X_FOLDABLE,
666 R.integer.SWITCH_STICK_L_FOLDABLE_Y 668 R.integer.SWITCH_STICK_L_Y_FOLDABLE
667 ) 669 )
668 670
669 private fun getResourceValue(descriptor: String, position: Int) : Float { 671 private fun getResourceValue(descriptor: String, position: Int) : Float {
@@ -804,18 +806,13 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context
804 return inEditMode 806 return inEditMode
805 } 807 }
806 808
807 fun setOrientation(descriptor: String) {
808 orientation = descriptor
809 }
810
811 companion object { 809 companion object {
812 private val preferences: SharedPreferences = 810 private val preferences: SharedPreferences =
813 PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext) 811 PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext)
814 812
815 const val LANDSCAPE = "" 813 const val LANDSCAPE = ""
816 const val PORTRAIT = "-Portrait" 814 const val PORTRAIT = "_Portrait"
817 const val FOLDABLE = "-Foldable" 815 const val FOLDABLE = "_Foldable"
818 private var orientation = LANDSCAPE
819 816
820 /** 817 /**
821 * Resizes a [Bitmap] by a given scale factor 818 * Resizes a [Bitmap] by a given scale factor
@@ -985,8 +982,8 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context
985 982
986 // The X and Y coordinates of the InputOverlayDrawableButton on the InputOverlay. 983 // The X and Y coordinates of the InputOverlayDrawableButton on the InputOverlay.
987 // These were set in the input overlay configuration menu. 984 // These were set in the input overlay configuration menu.
988 val xKey = "$buttonId$orientation-X" 985 val xKey = "$buttonId-X$orientation"
989 val yKey = "$buttonId$orientation-Y" 986 val yKey = "$buttonId-Y$orientation"
990 val drawableXPercent = sPrefs.getFloat(xKey, 0f) 987 val drawableXPercent = sPrefs.getFloat(xKey, 0f)
991 val drawableYPercent = sPrefs.getFloat(yKey, 0f) 988 val drawableYPercent = sPrefs.getFloat(yKey, 0f)
992 val drawableX = (drawableXPercent * max.x + min.x).toInt() 989 val drawableX = (drawableXPercent * max.x + min.x).toInt()
@@ -1066,8 +1063,8 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context
1066 1063
1067 // The X and Y coordinates of the InputOverlayDrawableDpad on the InputOverlay. 1064 // The X and Y coordinates of the InputOverlayDrawableDpad on the InputOverlay.
1068 // These were set in the input overlay configuration menu. 1065 // These were set in the input overlay configuration menu.
1069 val drawableXPercent = sPrefs.getFloat("${ButtonType.DPAD_UP}$orientation-X", 0f) 1066 val drawableXPercent = sPrefs.getFloat("${ButtonType.DPAD_UP}-X$orientation", 0f)
1070 val drawableYPercent = sPrefs.getFloat("${ButtonType.DPAD_UP}$orientation-Y", 0f) 1067 val drawableYPercent = sPrefs.getFloat("${ButtonType.DPAD_UP}-Y$orientation", 0f)
1071 val drawableX = (drawableXPercent * max.x + min.x).toInt() 1068 val drawableX = (drawableXPercent * max.x + min.x).toInt()
1072 val drawableY = (drawableYPercent * max.y + min.y).toInt() 1069 val drawableY = (drawableYPercent * max.y + min.y).toInt()
1073 val width = overlayDrawable.width 1070 val width = overlayDrawable.width
@@ -1133,8 +1130,8 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context
1133 1130
1134 // The X and Y coordinates of the InputOverlayDrawableButton on the InputOverlay. 1131 // The X and Y coordinates of the InputOverlayDrawableButton on the InputOverlay.
1135 // These were set in the input overlay configuration menu. 1132 // These were set in the input overlay configuration menu.
1136 val drawableXPercent = sPrefs.getFloat("$button$orientation-X", 0f) 1133 val drawableXPercent = sPrefs.getFloat("$button-X$orientation", 0f)
1137 val drawableYPercent = sPrefs.getFloat("$button$orientation-Y", 0f) 1134 val drawableYPercent = sPrefs.getFloat("$button-Y$orientation", 0f)
1138 val drawableX = (drawableXPercent * max.x + min.x).toInt() 1135 val drawableX = (drawableXPercent * max.x + min.x).toInt()
1139 val drawableY = (drawableYPercent * max.y + min.y).toInt() 1136 val drawableY = (drawableYPercent * max.y + min.y).toInt()
1140 val outerScale = 1.66f 1137 val outerScale = 1.66f
diff --git a/src/android/app/src/main/res/values/integers.xml b/src/android/app/src/main/res/values/integers.xml
index 2dbe881e3..a149002a0 100644
--- a/src/android/app/src/main/res/values/integers.xml
+++ b/src/android/app/src/main/res/values/integers.xml
@@ -35,67 +35,67 @@
35 <integer name="SWITCH_BUTTON_DPAD_Y">790</integer> 35 <integer name="SWITCH_BUTTON_DPAD_Y">790</integer>
36 36
37 <!-- Default SWITCH portrait layout --> 37 <!-- Default SWITCH portrait layout -->
38 <integer name="SWITCH_BUTTON_A_PORTRAIT_X">840</integer> 38 <integer name="SWITCH_BUTTON_A_X_PORTRAIT">840</integer>
39 <integer name="SWITCH_BUTTON_A_PORTRAIT_Y">820</integer> 39 <integer name="SWITCH_BUTTON_A_Y_PORTRAIT">820</integer>
40 <integer name="SWITCH_BUTTON_B_PORTRAIT_X">740</integer> 40 <integer name="SWITCH_BUTTON_B_X_PORTRAIT">740</integer>
41 <integer name="SWITCH_BUTTON_B_PORTRAIT_Y">860</integer> 41 <integer name="SWITCH_BUTTON_B_Y_PORTRAIT">860</integer>
42 <integer name="SWITCH_BUTTON_X_PORTRAIT_X">740</integer> 42 <integer name="SWITCH_BUTTON_X_X_PORTRAIT">740</integer>
43 <integer name="SWITCH_BUTTON_X_PORTRAIT_Y">780</integer> 43 <integer name="SWITCH_BUTTON_X_Y_PORTRAIT">780</integer>
44 <integer name="SWITCH_BUTTON_Y_PORTRAIT_X">640</integer> 44 <integer name="SWITCH_BUTTON_Y_X_PORTRAIT">640</integer>
45 <integer name="SWITCH_BUTTON_Y_PORTRAIT_Y">820</integer> 45 <integer name="SWITCH_BUTTON_Y_Y_PORTRAIT">820</integer>
46 <integer name="SWITCH_STICK_L_PORTRAIT_X">180</integer> 46 <integer name="SWITCH_STICK_L_X_PORTRAIT">180</integer>
47 <integer name="SWITCH_STICK_L_PORTRAIT_Y">640</integer> 47 <integer name="SWITCH_STICK_L_Y_PORTRAIT">640</integer>
48 <integer name="SWITCH_STICK_R_PORTRAIT_X">820</integer> 48 <integer name="SWITCH_STICK_R_X_PORTRAIT">820</integer>
49 <integer name="SWITCH_STICK_R_PORTRAIT_Y">640</integer> 49 <integer name="SWITCH_STICK_R_Y_PORTRAIT">640</integer>
50 <integer name="SWITCH_TRIGGER_L_PORTRAIT_X">140</integer> 50 <integer name="SWITCH_TRIGGER_L_X_PORTRAIT">140</integer>
51 <integer name="SWITCH_TRIGGER_L_PORTRAIT_Y">240</integer> 51 <integer name="SWITCH_TRIGGER_L_Y_PORTRAIT">240</integer>
52 <integer name="SWITCH_TRIGGER_R_PORTRAIT_X">860</integer> 52 <integer name="SWITCH_TRIGGER_R_X_PORTRAIT">860</integer>
53 <integer name="SWITCH_TRIGGER_R_PORTRAIT_Y">240</integer> 53 <integer name="SWITCH_TRIGGER_R_Y_PORTRAIT">240</integer>
54 <integer name="SWITCH_TRIGGER_ZL_PORTRAIT_X">140</integer> 54 <integer name="SWITCH_TRIGGER_ZL_X_PORTRAIT">140</integer>
55 <integer name="SWITCH_TRIGGER_ZL_PORTRAIT_Y">180</integer> 55 <integer name="SWITCH_TRIGGER_ZL_Y_PORTRAIT">180</integer>
56 <integer name="SWITCH_TRIGGER_ZR_PORTRAIT_X">860</integer> 56 <integer name="SWITCH_TRIGGER_ZR_X_PORTRAIT">860</integer>
57 <integer name="SWITCH_TRIGGER_ZR_PORTRAIT_Y">180</integer> 57 <integer name="SWITCH_TRIGGER_ZR_Y_PORTRAIT">180</integer>
58 <integer name="SWITCH_BUTTON_MINUS_PORTRAIT_X">440</integer> 58 <integer name="SWITCH_BUTTON_MINUS_X_PORTRAIT">440</integer>
59 <integer name="SWITCH_BUTTON_MINUS_PORTRAIT_Y">950</integer> 59 <integer name="SWITCH_BUTTON_MINUS_Y_PORTRAIT">950</integer>
60 <integer name="SWITCH_BUTTON_PLUS_PORTRAIT_X">560</integer> 60 <integer name="SWITCH_BUTTON_PLUS_X_PORTRAIT">560</integer>
61 <integer name="SWITCH_BUTTON_PLUS_PORTRAIT_Y">950</integer> 61 <integer name="SWITCH_BUTTON_PLUS_Y_PORTRAIT">950</integer>
62 <integer name="SWITCH_BUTTON_HOME_PORTRAIT_X">660</integer> 62 <integer name="SWITCH_BUTTON_HOME_X_PORTRAIT">680</integer>
63 <integer name="SWITCH_BUTTON_HOME_PORTRAIT_Y">950</integer> 63 <integer name="SWITCH_BUTTON_HOME_Y_PORTRAIT">950</integer>
64 <integer name="SWITCH_BUTTON_CAPTURE_PORTRAIT_X">320</integer> 64 <integer name="SWITCH_BUTTON_CAPTURE_X_PORTRAIT">320</integer>
65 <integer name="SWITCH_BUTTON_CAPTURE_PORTRAIT_Y">950</integer> 65 <integer name="SWITCH_BUTTON_CAPTURE_Y_PORTRAIT">950</integer>
66 <integer name="SWITCH_BUTTON_DPAD_PORTRAIT_X">240</integer> 66 <integer name="SWITCH_BUTTON_DPAD_X_PORTRAIT">240</integer>
67 <integer name="SWITCH_BUTTON_DPAD_PORTRAIT_Y">820</integer> 67 <integer name="SWITCH_BUTTON_DPAD_Y_PORTRAIT">820</integer>
68 68
69 <!-- Default SWITCH foldable layout --> 69 <!-- Default SWITCH foldable layout -->
70 <integer name="SWITCH_BUTTON_A_FOLDABLE_X">840</integer> 70 <integer name="SWITCH_BUTTON_A_X_FOLDABLE">840</integer>
71 <integer name="SWITCH_BUTTON_A_FOLDABLE_Y">340</integer> 71 <integer name="SWITCH_BUTTON_A_Y_FOLDABLE">340</integer>
72 <integer name="SWITCH_BUTTON_B_FOLDABLE_X">740</integer> 72 <integer name="SWITCH_BUTTON_B_X_FOLDABLE">740</integer>
73 <integer name="SWITCH_BUTTON_B_FOLDABLE_Y">380</integer> 73 <integer name="SWITCH_BUTTON_B_Y_FOLDABLE">380</integer>
74 <integer name="SWITCH_BUTTON_X_FOLDABLE_X">740</integer> 74 <integer name="SWITCH_BUTTON_X_X_FOLDABLE">740</integer>
75 <integer name="SWITCH_BUTTON_X_FOLDABLE_Y">300</integer> 75 <integer name="SWITCH_BUTTON_X_Y_FOLDABLE">300</integer>
76 <integer name="SWITCH_BUTTON_Y_FOLDABLE_X">640</integer> 76 <integer name="SWITCH_BUTTON_Y_X_FOLDABLE">640</integer>
77 <integer name="SWITCH_BUTTON_Y_FOLDABLE_Y">340</integer> 77 <integer name="SWITCH_BUTTON_Y_Y_FOLDABLE">340</integer>
78 <integer name="SWITCH_STICK_L_FOLDABLE_X">180</integer> 78 <integer name="SWITCH_STICK_L_X_FOLDABLE">180</integer>
79 <integer name="SWITCH_STICK_L_FOLDABLE_Y">200</integer> 79 <integer name="SWITCH_STICK_L_Y_FOLDABLE">200</integer>
80 <integer name="SWITCH_STICK_R_FOLDABLE_X">820</integer> 80 <integer name="SWITCH_STICK_R_X_FOLDABLE">820</integer>
81 <integer name="SWITCH_STICK_R_FOLDABLE_Y">200</integer> 81 <integer name="SWITCH_STICK_R_Y_FOLDABLE">200</integer>
82 <integer name="SWITCH_TRIGGER_L_FOLDABLE_X">140</integer> 82 <integer name="SWITCH_TRIGGER_L_X_FOLDABLE">140</integer>
83 <integer name="SWITCH_TRIGGER_L_FOLDABLE_Y">80</integer> 83 <integer name="SWITCH_TRIGGER_L_Y_FOLDABLE">80</integer>
84 <integer name="SWITCH_TRIGGER_R_FOLDABLE_X">860</integer> 84 <integer name="SWITCH_TRIGGER_R_X_FOLDABLE">860</integer>
85 <integer name="SWITCH_TRIGGER_R_FOLDABLE_Y">80</integer> 85 <integer name="SWITCH_TRIGGER_R_Y_FOLDABLE">80</integer>
86 <integer name="SWITCH_TRIGGER_ZL_FOLDABLE_X">140</integer> 86 <integer name="SWITCH_TRIGGER_ZL_X_FOLDABLE">140</integer>
87 <integer name="SWITCH_TRIGGER_ZL_FOLDABLE_Y">20</integer> 87 <integer name="SWITCH_TRIGGER_ZL_Y_FOLDABLE">20</integer>
88 <integer name="SWITCH_TRIGGER_ZR_FOLDABLE_X">860</integer> 88 <integer name="SWITCH_TRIGGER_ZR_X_FOLDABLE">860</integer>
89 <integer name="SWITCH_TRIGGER_ZR_FOLDABLE_Y">20</integer> 89 <integer name="SWITCH_TRIGGER_ZR_Y_FOLDABLE">20</integer>
90 <integer name="SWITCH_BUTTON_MINUS_FOLDABLE_X">440</integer> 90 <integer name="SWITCH_BUTTON_MINUS_X_FOLDABLE">440</integer>
91 <integer name="SWITCH_BUTTON_MINUS_FOLDABLE_Y">420</integer> 91 <integer name="SWITCH_BUTTON_MINUS_Y_FOLDABLE">420</integer>
92 <integer name="SWITCH_BUTTON_PLUS_FOLDABLE_X">560</integer> 92 <integer name="SWITCH_BUTTON_PLUS_X_FOLDABLE">560</integer>
93 <integer name="SWITCH_BUTTON_PLUS_FOLDABLE_Y">420</integer> 93 <integer name="SWITCH_BUTTON_PLUS_Y_FOLDABLE">420</integer>
94 <integer name="SWITCH_BUTTON_HOME_FOLDABLE_X">680</integer> 94 <integer name="SWITCH_BUTTON_HOME_X_FOLDABLE">680</integer>
95 <integer name="SWITCH_BUTTON_HOME_FOLDABLE_Y">420</integer> 95 <integer name="SWITCH_BUTTON_HOME_Y_FOLDABLE">420</integer>
96 <integer name="SWITCH_BUTTON_CAPTURE_FOLDABLE_X">320</integer> 96 <integer name="SWITCH_BUTTON_CAPTURE_X_FOLDABLE">320</integer>
97 <integer name="SWITCH_BUTTON_CAPTURE_FOLDABLE_Y">420</integer> 97 <integer name="SWITCH_BUTTON_CAPTURE_Y_FOLDABLE">420</integer>
98 <integer name="SWITCH_BUTTON_DPAD_FOLDABLE_X">240</integer> 98 <integer name="SWITCH_BUTTON_DPAD_X_FOLDABLE">240</integer>
99 <integer name="SWITCH_BUTTON_DPAD_FOLDABLE_Y">340</integer> 99 <integer name="SWITCH_BUTTON_DPAD_Y_FOLDABLE">340</integer>
100 100
101</resources> 101</resources>