From e20c4fbbd46afd94e708da214904052015b35776 Mon Sep 17 00:00:00 2001 From: Abandoned Cart Date: Wed, 14 Jun 2023 07:14:43 -0400 Subject: android: Initialize defaults for each orientations --- .gitignore | 2 + .../yuzu/yuzu_emu/activities/EmulationActivity.kt | 42 ++++-- .../yuzu_emu/features/settings/model/Settings.kt | 6 +- .../features/settings/ui/SettingsActivity.kt | 7 +- .../yuzu/yuzu_emu/fragments/EmulationFragment.kt | 32 ++--- .../java/org/yuzu/yuzu_emu/overlay/InputOverlay.kt | 153 ++++++++++----------- src/android/app/src/main/res/values/integers.xml | 120 ++++++++-------- 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 # OSX global filetypes # Created by Finder or Spotlight in directories for various OS functionality (indexing, etc) .DS_Store +.DS_Store? +._* .AppleDouble .LSOverride .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 { } } - private fun PictureInPictureParams.Builder.getPictureInPictureAspectBuilder() : PictureInPictureParams.Builder { + private fun PictureInPictureParams.Builder.getPictureInPictureAspectBuilder(): PictureInPictureParams.Builder { val aspectRatio = when (IntSetting.RENDERER_ASPECT_RATIO.int) { 0 -> Rational(16, 9) 1 -> Rational(4, 3) 2 -> Rational(21, 9) 3 -> Rational(16, 10) - else -> null + else -> null // Best fit } return this.apply { aspectRatio?.let { setAspectRatio(it) } } } - private fun PictureInPictureParams.Builder.getPictureInPictureActionsBuilder() : PictureInPictureParams.Builder { - val pictureInPictureActions : MutableList = mutableListOf() + private fun PictureInPictureParams.Builder.getPictureInPictureActionsBuilder(): PictureInPictureParams.Builder { + val pictureInPictureActions: MutableList = mutableListOf() val pendingFlags = PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE if (NativeLibrary.isPaused()) { val playIcon = Icon.createWithResource(this@EmulationActivity, R.drawable.ic_pip_play) val playPendingIntent = PendingIntent.getBroadcast( - this@EmulationActivity, R.drawable.ic_pip_play, Intent(actionPlay), pendingFlags + this@EmulationActivity, + R.drawable.ic_pip_play, + Intent(actionPlay), + pendingFlags + ) + val playRemoteAction = RemoteAction( + playIcon, + getString(R.string.play), + getString(R.string.play), + playPendingIntent ) - val playRemoteAction = RemoteAction(playIcon, getString(R.string.play), getString(R.string.play), playPendingIntent) pictureInPictureActions.add(playRemoteAction) } else { val pauseIcon = Icon.createWithResource(this@EmulationActivity, R.drawable.ic_pip_pause) val pausePendingIntent = PendingIntent.getBroadcast( - this@EmulationActivity, R.drawable.ic_pip_pause, Intent(actionPause), pendingFlags + this@EmulationActivity, + R.drawable.ic_pip_pause, + Intent(actionPause), + pendingFlags + ) + val pauseRemoteAction = RemoteAction( + pauseIcon, + getString(R.string.pause), + getString(R.string.pause), + pausePendingIntent ) - val pauseRemoteAction = RemoteAction(pauseIcon, getString(R.string.pause), getString(R.string.pause), pausePendingIntent) pictureInPictureActions.add(pauseRemoteAction) } @@ -300,7 +316,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { } private var pictureInPictureReceiver = object : BroadcastReceiver() { - override fun onReceive(context : Context?, intent : Intent) { + override fun onReceive(context: Context?, intent: Intent) { if (intent.action == actionPlay) { if (NativeLibrary.isPaused()) NativeLibrary.unPauseEmulation() } else if (intent.action == actionPause) { @@ -310,7 +326,10 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { } } - override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration) { + override fun onPictureInPictureModeChanged( + isInPictureInPictureMode: Boolean, + newConfig: Configuration + ) { super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig) if (isInPictureInPictureMode) { IntentFilter().apply { @@ -322,7 +341,8 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { } else { try { unregisterReceiver(pictureInPictureReceiver) - } catch (ignored : Exception) { } + } catch (ignored : Exception) { + } } } 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 { private val configFileSectionsMap: MutableMap> = HashMap() - // These must match what is defined in src/core/settings.h - const val LayoutOption_Default = 0 - const val LayoutOption_SingleScreen = 1 - const val LayoutOption_LargeScreen = 2 - const val LayoutOption_SideScreen = 3 + const val LayoutOption_Unspecified = 0 const val LayoutOption_MobilePortrait = 4 const val LayoutOption_MobileLandscape = 5 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 { context.startActivity(settings) } - fun launch(context: Context, launcher: ActivityResultLauncher, menuTag: String?, gameId: String?) { + fun launch( + context: Context, + launcher: ActivityResultLauncher, + menuTag: String?, + gameId: String? + ) { val settings = Intent(context, SettingsActivity::class.java) settings.putExtra(ARG_MENU_TAG, menuTag) 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 import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle -import androidx.navigation.fragment.navArgs import androidx.preference.PreferenceManager import androidx.window.layout.FoldingFeature import androidx.window.layout.WindowInfoTracker @@ -165,7 +164,10 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { R.id.menu_settings -> { SettingsActivity.launch( - requireContext(), onReturnFromSettings, SettingsFile.FILE_NAME_CONFIG, "" + requireContext(), + onReturnFromSettings, + SettingsFile.FILE_NAME_CONFIG, + "" ) true } @@ -219,9 +221,9 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { } if (!isInFoldableLayout) { if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { - binding.surfaceInputOverlay.setOrientation(InputOverlay.PORTRAIT) + binding.surfaceInputOverlay.orientation = InputOverlay.PORTRAIT } else { - binding.surfaceInputOverlay.setOrientation(InputOverlay.LANDSCAPE) + binding.surfaceInputOverlay.orientation = InputOverlay.LANDSCAPE } } if (!binding.surfaceInputOverlay.isInEditMode) { @@ -311,17 +313,11 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { @SuppressLint("SourceLockedOrientationActivity") private fun updateScreenLayout() { emulationActivity?.let { - when (IntSetting.RENDERER_SCREEN_LAYOUT.int) { - Settings.LayoutOption_MobileLandscape -> { - it.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE - } - Settings.LayoutOption_MobilePortrait -> { - it.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT - } - Settings.LayoutOption_Default -> { - it.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED - } - else -> { it.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE } + it.requestedOrientation = when (IntSetting.RENDERER_SCREEN_LAYOUT.int) { + Settings.LayoutOption_MobileLandscape -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE + Settings.LayoutOption_MobilePortrait -> ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT + Settings.LayoutOption_Unspecified -> ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED + else -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE } } onConfigurationChanged(resources.configuration) @@ -337,7 +333,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { binding.overlayContainer.layoutParams.height = it.bounds.bottom binding.inGameMenu.layoutParams.height = it.bounds.bottom isInFoldableLayout = true - binding.surfaceInputOverlay.setOrientation(InputOverlay.FOLDABLE) + binding.surfaceInputOverlay.orientation = InputOverlay.FOLDABLE refreshInputOverlay() } } @@ -485,7 +481,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { @SuppressLint("SourceLockedOrientationActivity") private fun startConfiguringControls() { // Lock the current orientation to prevent editing inconsistencies - if (IntSetting.RENDERER_SCREEN_LAYOUT.int == Settings.LayoutOption_Default) { + if (IntSetting.RENDERER_SCREEN_LAYOUT.int == Settings.LayoutOption_Unspecified) { emulationActivity?.let { it.requestedOrientation = if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) { @@ -503,7 +499,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { binding.doneControlConfig.visibility = View.GONE binding.surfaceInputOverlay.setIsInEditMode(false) // Unlock the orientation if it was locked for editing - if (IntSetting.RENDERER_SCREEN_LAYOUT.int == Settings.LayoutOption_Default) { + if (IntSetting.RENDERER_SCREEN_LAYOUT.int == Settings.LayoutOption_Unspecified) { emulationActivity?.let { it.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED } 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 private lateinit var windowInsets: WindowInsets + var orientation = LANDSCAPE + override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) { super.onLayout(changed, left, top, right, bottom) windowInsets = rootWindowInsets - if (!preferences.getBoolean(Settings.PREF_OVERLAY_INIT, false)) { + if (!preferences.getBoolean("${Settings.PREF_OVERLAY_INIT}$orientation", false)) { defaultOverlay() } @@ -542,8 +544,8 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context val min = windowSize.first val max = windowSize.second PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext).edit() - .putFloat("$sharedPrefsId$orientation-X", (x - min.x).toFloat() / max.x) - .putFloat("$sharedPrefsId$orientation-Y", (y - min.y).toFloat() / max.y) + .putFloat("$sharedPrefsId-X$orientation", (x - min.x).toFloat() / max.x) + .putFloat("$sharedPrefsId-Y$orientation", (y - min.y).toFloat() / max.y) .apply() } @@ -552,13 +554,13 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context } private fun defaultOverlay() { - if (!preferences.getBoolean(Settings.PREF_OVERLAY_INIT, false)) { + if (!preferences.getBoolean("${Settings.PREF_OVERLAY_INIT}$orientation", false)) { defaultOverlayByLayout(orientation) } resetButtonPlacement() preferences.edit() - .putBoolean(Settings.PREF_OVERLAY_INIT, true) + .putBoolean("${Settings.PREF_OVERLAY_INIT}$orientation", true) .apply() } @@ -601,69 +603,69 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context ) private val portraitResources = arrayOf( - R.integer.SWITCH_BUTTON_A_PORTRAIT_X, - R.integer.SWITCH_BUTTON_A_PORTRAIT_Y, - R.integer.SWITCH_BUTTON_B_PORTRAIT_X, - R.integer.SWITCH_BUTTON_B_PORTRAIT_Y, - R.integer.SWITCH_BUTTON_X_PORTRAIT_X, - R.integer.SWITCH_BUTTON_X_PORTRAIT_Y, - R.integer.SWITCH_BUTTON_Y_PORTRAIT_X, - R.integer.SWITCH_BUTTON_Y_PORTRAIT_Y, - R.integer.SWITCH_TRIGGER_ZL_PORTRAIT_X, - R.integer.SWITCH_TRIGGER_ZL_PORTRAIT_Y, - R.integer.SWITCH_TRIGGER_ZR_PORTRAIT_X, - R.integer.SWITCH_TRIGGER_ZR_PORTRAIT_Y, - R.integer.SWITCH_BUTTON_DPAD_PORTRAIT_X, - R.integer.SWITCH_BUTTON_DPAD_PORTRAIT_Y, - R.integer.SWITCH_TRIGGER_L_PORTRAIT_X, - R.integer.SWITCH_TRIGGER_L_PORTRAIT_Y, - R.integer.SWITCH_TRIGGER_R_PORTRAIT_X, - R.integer.SWITCH_TRIGGER_R_PORTRAIT_Y, - R.integer.SWITCH_BUTTON_PLUS_PORTRAIT_X, - R.integer.SWITCH_BUTTON_PLUS_PORTRAIT_Y, - R.integer.SWITCH_BUTTON_MINUS_PORTRAIT_X, - R.integer.SWITCH_BUTTON_MINUS_PORTRAIT_Y, - R.integer.SWITCH_BUTTON_HOME_PORTRAIT_X, - R.integer.SWITCH_BUTTON_HOME_PORTRAIT_Y, - R.integer.SWITCH_BUTTON_CAPTURE_PORTRAIT_X, - R.integer.SWITCH_BUTTON_CAPTURE_PORTRAIT_Y, - R.integer.SWITCH_STICK_R_PORTRAIT_X, - R.integer.SWITCH_STICK_R_PORTRAIT_Y, - R.integer.SWITCH_STICK_L_PORTRAIT_X, - R.integer.SWITCH_STICK_L_PORTRAIT_Y + R.integer.SWITCH_BUTTON_A_X_PORTRAIT, + R.integer.SWITCH_BUTTON_A_Y_PORTRAIT, + R.integer.SWITCH_BUTTON_B_X_PORTRAIT, + R.integer.SWITCH_BUTTON_B_Y_PORTRAIT, + R.integer.SWITCH_BUTTON_X_X_PORTRAIT, + R.integer.SWITCH_BUTTON_X_Y_PORTRAIT, + R.integer.SWITCH_BUTTON_Y_X_PORTRAIT, + R.integer.SWITCH_BUTTON_Y_Y_PORTRAIT, + R.integer.SWITCH_TRIGGER_ZL_X_PORTRAIT, + R.integer.SWITCH_TRIGGER_ZL_Y_PORTRAIT, + R.integer.SWITCH_TRIGGER_ZR_X_PORTRAIT, + R.integer.SWITCH_TRIGGER_ZR_Y_PORTRAIT, + R.integer.SWITCH_BUTTON_DPAD_X_PORTRAIT, + R.integer.SWITCH_BUTTON_DPAD_Y_PORTRAIT, + R.integer.SWITCH_TRIGGER_L_X_PORTRAIT, + R.integer.SWITCH_TRIGGER_L_Y_PORTRAIT, + R.integer.SWITCH_TRIGGER_R_X_PORTRAIT, + R.integer.SWITCH_TRIGGER_R_Y_PORTRAIT, + R.integer.SWITCH_BUTTON_PLUS_X_PORTRAIT, + R.integer.SWITCH_BUTTON_PLUS_Y_PORTRAIT, + R.integer.SWITCH_BUTTON_MINUS_X_PORTRAIT, + R.integer.SWITCH_BUTTON_MINUS_Y_PORTRAIT, + R.integer.SWITCH_BUTTON_HOME_X_PORTRAIT, + R.integer.SWITCH_BUTTON_HOME_Y_PORTRAIT, + R.integer.SWITCH_BUTTON_CAPTURE_X_PORTRAIT, + R.integer.SWITCH_BUTTON_CAPTURE_Y_PORTRAIT, + R.integer.SWITCH_STICK_R_X_PORTRAIT, + R.integer.SWITCH_STICK_R_Y_PORTRAIT, + R.integer.SWITCH_STICK_L_X_PORTRAIT, + R.integer.SWITCH_STICK_L_Y_PORTRAIT ) private val foldableResources = arrayOf( - R.integer.SWITCH_BUTTON_A_FOLDABLE_X, - R.integer.SWITCH_BUTTON_A_FOLDABLE_Y, - R.integer.SWITCH_BUTTON_B_FOLDABLE_X, - R.integer.SWITCH_BUTTON_B_FOLDABLE_Y, - R.integer.SWITCH_BUTTON_X_FOLDABLE_X, - R.integer.SWITCH_BUTTON_X_FOLDABLE_Y, - R.integer.SWITCH_BUTTON_Y_FOLDABLE_X, - R.integer.SWITCH_BUTTON_Y_FOLDABLE_Y, - R.integer.SWITCH_TRIGGER_ZL_FOLDABLE_X, - R.integer.SWITCH_TRIGGER_ZL_FOLDABLE_Y, - R.integer.SWITCH_TRIGGER_ZR_FOLDABLE_X, - R.integer.SWITCH_TRIGGER_ZR_FOLDABLE_Y, - R.integer.SWITCH_BUTTON_DPAD_FOLDABLE_X, - R.integer.SWITCH_BUTTON_DPAD_FOLDABLE_Y, - R.integer.SWITCH_TRIGGER_L_FOLDABLE_X, - R.integer.SWITCH_TRIGGER_L_FOLDABLE_Y, - R.integer.SWITCH_TRIGGER_R_FOLDABLE_X, - R.integer.SWITCH_TRIGGER_R_FOLDABLE_Y, - R.integer.SWITCH_BUTTON_PLUS_FOLDABLE_X, - R.integer.SWITCH_BUTTON_PLUS_FOLDABLE_Y, - R.integer.SWITCH_BUTTON_MINUS_FOLDABLE_X, - R.integer.SWITCH_BUTTON_MINUS_FOLDABLE_Y, - R.integer.SWITCH_BUTTON_HOME_FOLDABLE_X, - R.integer.SWITCH_BUTTON_HOME_FOLDABLE_Y, - R.integer.SWITCH_BUTTON_CAPTURE_FOLDABLE_X, - R.integer.SWITCH_BUTTON_CAPTURE_FOLDABLE_Y, - R.integer.SWITCH_STICK_R_FOLDABLE_X, - R.integer.SWITCH_STICK_R_FOLDABLE_Y, - R.integer.SWITCH_STICK_L_FOLDABLE_X, - R.integer.SWITCH_STICK_L_FOLDABLE_Y + R.integer.SWITCH_BUTTON_A_X_FOLDABLE, + R.integer.SWITCH_BUTTON_A_Y_FOLDABLE, + R.integer.SWITCH_BUTTON_B_X_FOLDABLE, + R.integer.SWITCH_BUTTON_B_Y_FOLDABLE, + R.integer.SWITCH_BUTTON_X_X_FOLDABLE, + R.integer.SWITCH_BUTTON_X_Y_FOLDABLE, + R.integer.SWITCH_BUTTON_Y_X_FOLDABLE, + R.integer.SWITCH_BUTTON_Y_Y_FOLDABLE, + R.integer.SWITCH_TRIGGER_ZL_X_FOLDABLE, + R.integer.SWITCH_TRIGGER_ZL_Y_FOLDABLE, + R.integer.SWITCH_TRIGGER_ZR_X_FOLDABLE, + R.integer.SWITCH_TRIGGER_ZR_Y_FOLDABLE, + R.integer.SWITCH_BUTTON_DPAD_X_FOLDABLE, + R.integer.SWITCH_BUTTON_DPAD_Y_FOLDABLE, + R.integer.SWITCH_TRIGGER_L_X_FOLDABLE, + R.integer.SWITCH_TRIGGER_L_Y_FOLDABLE, + R.integer.SWITCH_TRIGGER_R_X_FOLDABLE, + R.integer.SWITCH_TRIGGER_R_Y_FOLDABLE, + R.integer.SWITCH_BUTTON_PLUS_X_FOLDABLE, + R.integer.SWITCH_BUTTON_PLUS_Y_FOLDABLE, + R.integer.SWITCH_BUTTON_MINUS_X_FOLDABLE, + R.integer.SWITCH_BUTTON_MINUS_Y_FOLDABLE, + R.integer.SWITCH_BUTTON_HOME_X_FOLDABLE, + R.integer.SWITCH_BUTTON_HOME_Y_FOLDABLE, + R.integer.SWITCH_BUTTON_CAPTURE_X_FOLDABLE, + R.integer.SWITCH_BUTTON_CAPTURE_Y_FOLDABLE, + R.integer.SWITCH_STICK_R_X_FOLDABLE, + R.integer.SWITCH_STICK_R_Y_FOLDABLE, + R.integer.SWITCH_STICK_L_X_FOLDABLE, + R.integer.SWITCH_STICK_L_Y_FOLDABLE ) private fun getResourceValue(descriptor: String, position: Int) : Float { @@ -804,18 +806,13 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context return inEditMode } - fun setOrientation(descriptor: String) { - orientation = descriptor - } - companion object { private val preferences: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext) const val LANDSCAPE = "" - const val PORTRAIT = "-Portrait" - const val FOLDABLE = "-Foldable" - private var orientation = LANDSCAPE + const val PORTRAIT = "_Portrait" + const val FOLDABLE = "_Foldable" /** * Resizes a [Bitmap] by a given scale factor @@ -985,8 +982,8 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context // The X and Y coordinates of the InputOverlayDrawableButton on the InputOverlay. // These were set in the input overlay configuration menu. - val xKey = "$buttonId$orientation-X" - val yKey = "$buttonId$orientation-Y" + val xKey = "$buttonId-X$orientation" + val yKey = "$buttonId-Y$orientation" val drawableXPercent = sPrefs.getFloat(xKey, 0f) val drawableYPercent = sPrefs.getFloat(yKey, 0f) val drawableX = (drawableXPercent * max.x + min.x).toInt() @@ -1066,8 +1063,8 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context // The X and Y coordinates of the InputOverlayDrawableDpad on the InputOverlay. // These were set in the input overlay configuration menu. - val drawableXPercent = sPrefs.getFloat("${ButtonType.DPAD_UP}$orientation-X", 0f) - val drawableYPercent = sPrefs.getFloat("${ButtonType.DPAD_UP}$orientation-Y", 0f) + val drawableXPercent = sPrefs.getFloat("${ButtonType.DPAD_UP}-X$orientation", 0f) + val drawableYPercent = sPrefs.getFloat("${ButtonType.DPAD_UP}-Y$orientation", 0f) val drawableX = (drawableXPercent * max.x + min.x).toInt() val drawableY = (drawableYPercent * max.y + min.y).toInt() val width = overlayDrawable.width @@ -1133,8 +1130,8 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context // The X and Y coordinates of the InputOverlayDrawableButton on the InputOverlay. // These were set in the input overlay configuration menu. - val drawableXPercent = sPrefs.getFloat("$button$orientation-X", 0f) - val drawableYPercent = sPrefs.getFloat("$button$orientation-Y", 0f) + val drawableXPercent = sPrefs.getFloat("$button-X$orientation", 0f) + val drawableYPercent = sPrefs.getFloat("$button-Y$orientation", 0f) val drawableX = (drawableXPercent * max.x + min.x).toInt() val drawableY = (drawableYPercent * max.y + min.y).toInt() 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 @@ 790 - 840 - 820 - 740 - 860 - 740 - 780 - 640 - 820 - 180 - 640 - 820 - 640 - 140 - 240 - 860 - 240 - 140 - 180 - 860 - 180 - 440 - 950 - 560 - 950 - 660 - 950 - 320 - 950 - 240 - 820 + 840 + 820 + 740 + 860 + 740 + 780 + 640 + 820 + 180 + 640 + 820 + 640 + 140 + 240 + 860 + 240 + 140 + 180 + 860 + 180 + 440 + 950 + 560 + 950 + 680 + 950 + 320 + 950 + 240 + 820 - 840 - 340 - 740 - 380 - 740 - 300 - 640 - 340 - 180 - 200 - 820 - 200 - 140 - 80 - 860 - 80 - 140 - 20 - 860 - 20 - 440 - 420 - 560 - 420 - 680 - 420 - 320 - 420 - 240 - 340 + 840 + 340 + 740 + 380 + 740 + 300 + 640 + 340 + 180 + 200 + 820 + 200 + 140 + 80 + 860 + 80 + 140 + 20 + 860 + 20 + 440 + 420 + 560 + 420 + 680 + 420 + 320 + 420 + 240 + 340 -- cgit v1.2.3