summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAbandoned Cart <twistedumbrella@gmail.com>2023-06-14 14:54:34 +0200
committerAbandoned Cart <twistedumbrella@gmail.com>2023-06-14 22:43:24 +0200
commit0e957c2e35fb7547e3fdb04dc9f1afb336e6c9b7 (patch)
tree23b153100905c92177d845f21db40c6362a37fd2
parentandroid: Initialize defaults for each orientations (diff)
downloadyuzu-0e957c2e35fb7547e3fdb04dc9f1afb336e6c9b7.tar
yuzu-0e957c2e35fb7547e3fdb04dc9f1afb336e6c9b7.tar.gz
yuzu-0e957c2e35fb7547e3fdb04dc9f1afb336e6c9b7.tar.bz2
yuzu-0e957c2e35fb7547e3fdb04dc9f1afb336e6c9b7.tar.lz
yuzu-0e957c2e35fb7547e3fdb04dc9f1afb336e6c9b7.tar.xz
yuzu-0e957c2e35fb7547e3fdb04dc9f1afb336e6c9b7.tar.zst
yuzu-0e957c2e35fb7547e3fdb04dc9f1afb336e6c9b7.zip
-rw-r--r--src/android/app/src/main/AndroidManifest.xml1
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt13
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlay.kt126
-rw-r--r--src/android/app/src/main/res/layout/fragment_emulation.xml33
-rw-r--r--src/android/app/src/main/res/values/integers.xml52
5 files changed, 117 insertions, 108 deletions
diff --git a/src/android/app/src/main/AndroidManifest.xml b/src/android/app/src/main/AndroidManifest.xml
index e31ad69e2..a6f87fc2e 100644
--- a/src/android/app/src/main/AndroidManifest.xml
+++ b/src/android/app/src/main/AndroidManifest.xml
@@ -53,7 +53,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
<activity
android:name="org.yuzu.yuzu_emu.activities.EmulationActivity"
android:theme="@style/Theme.Yuzu.Main"
- android:screenOrientation="userLandscape"
android:supportsPictureInPicture="true"
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|uiMode"
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 d5725abe7..4b2305892 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
@@ -11,13 +11,11 @@ import android.content.Intent
import android.content.SharedPreferences
import android.content.pm.ActivityInfo
import android.content.res.Configuration
-import android.content.res.Resources
import android.graphics.Color
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Rational
-import android.util.TypedValue
import android.view.*
import android.widget.TextView
import androidx.activity.OnBackPressedCallback
@@ -29,11 +27,11 @@ import androidx.core.graphics.Insets
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.isVisible
-import androidx.core.view.updatePadding
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
@@ -328,10 +326,13 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
if (it.isSeparating) {
emulationActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
if (it.orientation == FoldingFeature.Orientation.HORIZONTAL) {
+ // Restrict emulation and overlays to the top of the screen
binding.emulationContainer.layoutParams.height = it.bounds.top
- // Prevent touch regions from being displayed in the hinge
- binding.overlayContainer.layoutParams.height = it.bounds.bottom
+ binding.overlayContainer.layoutParams.height = it.bounds.top
+ // Restrict input and menu drawer to the bottom of the screen
+ binding.inputContainer.layoutParams.height = it.bounds.bottom
binding.inGameMenu.layoutParams.height = it.bounds.bottom
+
isInFoldableLayout = true
binding.surfaceInputOverlay.orientation = InputOverlay.FOLDABLE
refreshInputOverlay()
@@ -341,12 +342,14 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
} ?: false
if (!isFolding) {
binding.emulationContainer.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
+ binding.inputContainer.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
binding.overlayContainer.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
binding.inGameMenu.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
isInFoldableLayout = false
updateScreenLayout()
}
binding.emulationContainer.requestLayout()
+ binding.inputContainer.requestLayout()
binding.overlayContainer.requestLayout()
binding.inGameMenu.requestLayout()
}
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 aeef7731b..d12d08e9f 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
@@ -668,136 +668,136 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context
R.integer.SWITCH_STICK_L_Y_FOLDABLE
)
- private fun getResourceValue(descriptor: String, position: Int) : Float {
- return when (descriptor) {
+ private fun getResourceValue(orientation: String, position: Int) : Float {
+ return when (orientation) {
PORTRAIT -> resources.getInteger(portraitResources[position]).toFloat() / 1000
FOLDABLE -> resources.getInteger(foldableResources[position]).toFloat() / 1000
else -> resources.getInteger(landscapeResources[position]).toFloat() / 1000
}
}
- private fun defaultOverlayByLayout(descriptor: String) {
+ private fun defaultOverlayByLayout(orientation: String) {
// Each value represents the position of the button in relation to the screen size without insets.
preferences.edit()
.putFloat(
- ButtonType.BUTTON_A.toString() + "$descriptor-X",
- getResourceValue(descriptor, 0)
+ ButtonType.BUTTON_A.toString() + "-X$orientation",
+ getResourceValue(orientation, 0)
)
.putFloat(
- ButtonType.BUTTON_A.toString() + "$descriptor-Y",
- getResourceValue(descriptor, 1)
+ ButtonType.BUTTON_A.toString() + "-Y$orientation",
+ getResourceValue(orientation, 1)
)
.putFloat(
- ButtonType.BUTTON_B.toString() + "$descriptor-X",
- getResourceValue(descriptor, 2)
+ ButtonType.BUTTON_B.toString() + "-X$orientation",
+ getResourceValue(orientation, 2)
)
.putFloat(
- ButtonType.BUTTON_B.toString() + "$descriptor-Y",
- getResourceValue(descriptor, 3)
+ ButtonType.BUTTON_B.toString() + "-Y$orientation",
+ getResourceValue(orientation, 3)
)
.putFloat(
- ButtonType.BUTTON_X.toString() + "$descriptor-X",
- getResourceValue(descriptor, 4)
+ ButtonType.BUTTON_X.toString() + "-X$orientation",
+ getResourceValue(orientation, 4)
)
.putFloat(
- ButtonType.BUTTON_X.toString() + "$descriptor-Y",
- getResourceValue(descriptor, 5)
+ ButtonType.BUTTON_X.toString() + "-Y$orientation",
+ getResourceValue(orientation, 5)
)
.putFloat(
- ButtonType.BUTTON_Y.toString() + "$descriptor-X",
- getResourceValue(descriptor, 6)
+ ButtonType.BUTTON_Y.toString() + "-X$orientation",
+ getResourceValue(orientation, 6)
)
.putFloat(
- ButtonType.BUTTON_Y.toString() + "$descriptor-Y",
- getResourceValue(descriptor, 7)
+ ButtonType.BUTTON_Y.toString() + "-Y$orientation",
+ getResourceValue(orientation, 7)
)
.putFloat(
- ButtonType.TRIGGER_ZL.toString() + "$descriptor-X",
- getResourceValue(descriptor, 8)
+ ButtonType.TRIGGER_ZL.toString() + "-X$orientation",
+ getResourceValue(orientation, 8)
)
.putFloat(
- ButtonType.TRIGGER_ZL.toString() + "$descriptor-Y",
- getResourceValue(descriptor, 9)
+ ButtonType.TRIGGER_ZL.toString() + "-Y$orientation",
+ getResourceValue(orientation, 9)
)
.putFloat(
- ButtonType.TRIGGER_ZR.toString() + "$descriptor-X",
- getResourceValue(descriptor, 10)
+ ButtonType.TRIGGER_ZR.toString() + "-X$orientation",
+ getResourceValue(orientation, 10)
)
.putFloat(
- ButtonType.TRIGGER_ZR.toString() + "$descriptor-Y",
- getResourceValue(descriptor, 11)
+ ButtonType.TRIGGER_ZR.toString() + "-Y$orientation",
+ getResourceValue(orientation, 11)
)
.putFloat(
- ButtonType.DPAD_UP.toString() + "$descriptor-X",
- getResourceValue(descriptor, 12)
+ ButtonType.DPAD_UP.toString() + "-X$orientation",
+ getResourceValue(orientation, 12)
)
.putFloat(
- ButtonType.DPAD_UP.toString() + "$descriptor-Y",
- getResourceValue(descriptor, 13)
+ ButtonType.DPAD_UP.toString() + "-Y$orientation",
+ getResourceValue(orientation, 13)
)
.putFloat(
- ButtonType.TRIGGER_L.toString() + "$descriptor-X",
- getResourceValue(descriptor, 14)
+ ButtonType.TRIGGER_L.toString() + "-X$orientation",
+ getResourceValue(orientation, 14)
)
.putFloat(
- ButtonType.TRIGGER_L.toString() + "$descriptor-Y",
- getResourceValue(descriptor, 15)
+ ButtonType.TRIGGER_L.toString() + "-Y$orientation",
+ getResourceValue(orientation, 15)
)
.putFloat(
- ButtonType.TRIGGER_R.toString() + "$descriptor-X",
- getResourceValue(descriptor, 16)
+ ButtonType.TRIGGER_R.toString() + "-X$orientation",
+ getResourceValue(orientation, 16)
)
.putFloat(
- ButtonType.TRIGGER_R.toString() + "$descriptor-Y",
- getResourceValue(descriptor, 17)
+ ButtonType.TRIGGER_R.toString() + "-Y$orientation",
+ getResourceValue(orientation, 17)
)
.putFloat(
- ButtonType.BUTTON_PLUS.toString() + "$descriptor-X",
- getResourceValue(descriptor, 18)
+ ButtonType.BUTTON_PLUS.toString() + "-X$orientation",
+ getResourceValue(orientation, 18)
)
.putFloat(
- ButtonType.BUTTON_PLUS.toString() + "$descriptor-Y",
- getResourceValue(descriptor, 19)
+ ButtonType.BUTTON_PLUS.toString() + "-Y$orientation",
+ getResourceValue(orientation, 19)
)
.putFloat(
- ButtonType.BUTTON_MINUS.toString() + "$descriptor-X",
- getResourceValue(descriptor, 20)
+ ButtonType.BUTTON_MINUS.toString() + "-X$orientation",
+ getResourceValue(orientation, 20)
)
.putFloat(
- ButtonType.BUTTON_MINUS.toString() + "$descriptor-Y",
- getResourceValue(descriptor, 21)
+ ButtonType.BUTTON_MINUS.toString() + "-Y$orientation",
+ getResourceValue(orientation, 21)
)
.putFloat(
- ButtonType.BUTTON_HOME.toString() + "$descriptor-X",
- getResourceValue(descriptor, 22)
+ ButtonType.BUTTON_HOME.toString() + "-X$orientation",
+ getResourceValue(orientation, 22)
)
.putFloat(
- ButtonType.BUTTON_HOME.toString() + "$descriptor-Y",
- getResourceValue(descriptor, 23)
+ ButtonType.BUTTON_HOME.toString() + "-Y$orientation",
+ getResourceValue(orientation, 23)
)
.putFloat(
- ButtonType.BUTTON_CAPTURE.toString() + "$descriptor-X",
- getResourceValue(descriptor, 24)
+ ButtonType.BUTTON_CAPTURE.toString() + "-X$orientation",
+ getResourceValue(orientation, 24)
)
.putFloat(
- ButtonType.BUTTON_CAPTURE.toString() + "$descriptor-Y",
- getResourceValue(descriptor, 25)
+ ButtonType.BUTTON_CAPTURE.toString() + "-Y$orientation",
+ getResourceValue(orientation, 25)
)
.putFloat(
- ButtonType.STICK_R.toString() + "$descriptor-X",
- getResourceValue(descriptor, 26)
+ ButtonType.STICK_R.toString() + "-X$orientation",
+ getResourceValue(orientation, 26)
)
.putFloat(
- ButtonType.STICK_R.toString() + "$descriptor-Y",
- getResourceValue(descriptor, 27)
+ ButtonType.STICK_R.toString() + "-Y$orientation",
+ getResourceValue(orientation, 27)
)
.putFloat(
- ButtonType.STICK_L.toString() + "$descriptor-X",
- getResourceValue(descriptor, 28)
+ ButtonType.STICK_L.toString() + "-X$orientation",
+ getResourceValue(orientation, 28)
)
.putFloat(
- ButtonType.STICK_L.toString() + "$descriptor-Y",
- getResourceValue(descriptor, 29)
+ ButtonType.STICK_L.toString() + "-Y$orientation",
+ getResourceValue(orientation, 29)
)
.apply()
}
diff --git a/src/android/app/src/main/res/layout/fragment_emulation.xml b/src/android/app/src/main/res/layout/fragment_emulation.xml
index ffe5f4882..e54a10e8f 100644
--- a/src/android/app/src/main/res/layout/fragment_emulation.xml
+++ b/src/android/app/src/main/res/layout/fragment_emulation.xml
@@ -26,22 +26,10 @@
android:focusable="false"
android:focusableInTouchMode="false" />
- <TextView
- android:id="@+id/show_fps_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="left"
- android:clickable="false"
- android:focusable="false"
- android:shadowColor="@android:color/black"
- android:textColor="@android:color/white"
- android:textSize="12sp"
- tools:ignore="RtlHardcoded" />
-
</FrameLayout>
<FrameLayout
- android:id="@+id/overlay_container"
+ android:id="@+id/input_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom">
@@ -66,6 +54,25 @@
</FrameLayout>
+ <FrameLayout
+ android:id="@+id/overlay_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <TextView
+ android:id="@+id/show_fps_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="left"
+ android:clickable="false"
+ android:focusable="false"
+ android:shadowColor="@android:color/black"
+ android:textColor="@android:color/white"
+ android:textSize="12sp"
+ tools:ignore="RtlHardcoded" />
+
+ </FrameLayout>
+
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.navigation.NavigationView
diff --git a/src/android/app/src/main/res/values/integers.xml b/src/android/app/src/main/res/values/integers.xml
index a149002a0..2e93b408c 100644
--- a/src/android/app/src/main/res/values/integers.xml
+++ b/src/android/app/src/main/res/values/integers.xml
@@ -36,25 +36,25 @@
<!-- Default SWITCH portrait layout -->
<integer name="SWITCH_BUTTON_A_X_PORTRAIT">840</integer>
- <integer name="SWITCH_BUTTON_A_Y_PORTRAIT">820</integer>
+ <integer name="SWITCH_BUTTON_A_Y_PORTRAIT">840</integer>
<integer name="SWITCH_BUTTON_B_X_PORTRAIT">740</integer>
- <integer name="SWITCH_BUTTON_B_Y_PORTRAIT">860</integer>
+ <integer name="SWITCH_BUTTON_B_Y_PORTRAIT">880</integer>
<integer name="SWITCH_BUTTON_X_X_PORTRAIT">740</integer>
- <integer name="SWITCH_BUTTON_X_Y_PORTRAIT">780</integer>
+ <integer name="SWITCH_BUTTON_X_Y_PORTRAIT">800</integer>
<integer name="SWITCH_BUTTON_Y_X_PORTRAIT">640</integer>
- <integer name="SWITCH_BUTTON_Y_Y_PORTRAIT">820</integer>
+ <integer name="SWITCH_BUTTON_Y_Y_PORTRAIT">840</integer>
<integer name="SWITCH_STICK_L_X_PORTRAIT">180</integer>
- <integer name="SWITCH_STICK_L_Y_PORTRAIT">640</integer>
+ <integer name="SWITCH_STICK_L_Y_PORTRAIT">660</integer>
<integer name="SWITCH_STICK_R_X_PORTRAIT">820</integer>
- <integer name="SWITCH_STICK_R_Y_PORTRAIT">640</integer>
+ <integer name="SWITCH_STICK_R_Y_PORTRAIT">660</integer>
<integer name="SWITCH_TRIGGER_L_X_PORTRAIT">140</integer>
- <integer name="SWITCH_TRIGGER_L_Y_PORTRAIT">240</integer>
+ <integer name="SWITCH_TRIGGER_L_Y_PORTRAIT">260</integer>
<integer name="SWITCH_TRIGGER_R_X_PORTRAIT">860</integer>
- <integer name="SWITCH_TRIGGER_R_Y_PORTRAIT">240</integer>
+ <integer name="SWITCH_TRIGGER_R_Y_PORTRAIT">260</integer>
<integer name="SWITCH_TRIGGER_ZL_X_PORTRAIT">140</integer>
- <integer name="SWITCH_TRIGGER_ZL_Y_PORTRAIT">180</integer>
+ <integer name="SWITCH_TRIGGER_ZL_Y_PORTRAIT">200</integer>
<integer name="SWITCH_TRIGGER_ZR_X_PORTRAIT">860</integer>
- <integer name="SWITCH_TRIGGER_ZR_Y_PORTRAIT">180</integer>
+ <integer name="SWITCH_TRIGGER_ZR_Y_PORTRAIT">200</integer>
<integer name="SWITCH_BUTTON_MINUS_X_PORTRAIT">440</integer>
<integer name="SWITCH_BUTTON_MINUS_Y_PORTRAIT">950</integer>
<integer name="SWITCH_BUTTON_PLUS_X_PORTRAIT">560</integer>
@@ -64,38 +64,38 @@
<integer name="SWITCH_BUTTON_CAPTURE_X_PORTRAIT">320</integer>
<integer name="SWITCH_BUTTON_CAPTURE_Y_PORTRAIT">950</integer>
<integer name="SWITCH_BUTTON_DPAD_X_PORTRAIT">240</integer>
- <integer name="SWITCH_BUTTON_DPAD_Y_PORTRAIT">820</integer>
+ <integer name="SWITCH_BUTTON_DPAD_Y_PORTRAIT">840</integer>
<!-- Default SWITCH foldable layout -->
<integer name="SWITCH_BUTTON_A_X_FOLDABLE">840</integer>
- <integer name="SWITCH_BUTTON_A_Y_FOLDABLE">340</integer>
+ <integer name="SWITCH_BUTTON_A_Y_FOLDABLE">390</integer>
<integer name="SWITCH_BUTTON_B_X_FOLDABLE">740</integer>
- <integer name="SWITCH_BUTTON_B_Y_FOLDABLE">380</integer>
+ <integer name="SWITCH_BUTTON_B_Y_FOLDABLE">430</integer>
<integer name="SWITCH_BUTTON_X_X_FOLDABLE">740</integer>
- <integer name="SWITCH_BUTTON_X_Y_FOLDABLE">300</integer>
+ <integer name="SWITCH_BUTTON_X_Y_FOLDABLE">350</integer>
<integer name="SWITCH_BUTTON_Y_X_FOLDABLE">640</integer>
- <integer name="SWITCH_BUTTON_Y_Y_FOLDABLE">340</integer>
+ <integer name="SWITCH_BUTTON_Y_Y_FOLDABLE">390</integer>
<integer name="SWITCH_STICK_L_X_FOLDABLE">180</integer>
- <integer name="SWITCH_STICK_L_Y_FOLDABLE">200</integer>
+ <integer name="SWITCH_STICK_L_Y_FOLDABLE">250</integer>
<integer name="SWITCH_STICK_R_X_FOLDABLE">820</integer>
- <integer name="SWITCH_STICK_R_Y_FOLDABLE">200</integer>
+ <integer name="SWITCH_STICK_R_Y_FOLDABLE">250</integer>
<integer name="SWITCH_TRIGGER_L_X_FOLDABLE">140</integer>
- <integer name="SWITCH_TRIGGER_L_Y_FOLDABLE">80</integer>
+ <integer name="SWITCH_TRIGGER_L_Y_FOLDABLE">130</integer>
<integer name="SWITCH_TRIGGER_R_X_FOLDABLE">860</integer>
- <integer name="SWITCH_TRIGGER_R_Y_FOLDABLE">80</integer>
+ <integer name="SWITCH_TRIGGER_R_Y_FOLDABLE">130</integer>
<integer name="SWITCH_TRIGGER_ZL_X_FOLDABLE">140</integer>
- <integer name="SWITCH_TRIGGER_ZL_Y_FOLDABLE">20</integer>
+ <integer name="SWITCH_TRIGGER_ZL_Y_FOLDABLE">70</integer>
<integer name="SWITCH_TRIGGER_ZR_X_FOLDABLE">860</integer>
- <integer name="SWITCH_TRIGGER_ZR_Y_FOLDABLE">20</integer>
+ <integer name="SWITCH_TRIGGER_ZR_Y_FOLDABLE">70</integer>
<integer name="SWITCH_BUTTON_MINUS_X_FOLDABLE">440</integer>
- <integer name="SWITCH_BUTTON_MINUS_Y_FOLDABLE">420</integer>
+ <integer name="SWITCH_BUTTON_MINUS_Y_FOLDABLE">470</integer>
<integer name="SWITCH_BUTTON_PLUS_X_FOLDABLE">560</integer>
- <integer name="SWITCH_BUTTON_PLUS_Y_FOLDABLE">420</integer>
+ <integer name="SWITCH_BUTTON_PLUS_Y_FOLDABLE">470</integer>
<integer name="SWITCH_BUTTON_HOME_X_FOLDABLE">680</integer>
- <integer name="SWITCH_BUTTON_HOME_Y_FOLDABLE">420</integer>
+ <integer name="SWITCH_BUTTON_HOME_Y_FOLDABLE">470</integer>
<integer name="SWITCH_BUTTON_CAPTURE_X_FOLDABLE">320</integer>
- <integer name="SWITCH_BUTTON_CAPTURE_Y_FOLDABLE">420</integer>
+ <integer name="SWITCH_BUTTON_CAPTURE_Y_FOLDABLE">470</integer>
<integer name="SWITCH_BUTTON_DPAD_X_FOLDABLE">240</integer>
- <integer name="SWITCH_BUTTON_DPAD_Y_FOLDABLE">340</integer>
+ <integer name="SWITCH_BUTTON_DPAD_Y_FOLDABLE">390</integer>
</resources>