diff --git a/src/android/app/src/main/AndroidManifest.xml b/src/android/app/src/main/AndroidManifest.xml index e31ad69e20..a6f87fc2ec 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 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 d5725abe77..4b23058928 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 aeef7731b3..d12d08e9fe 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 ffe5f48822..e54a10e8ff 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" /> - - @@ -66,6 +54,25 @@ + + + + + + 840 - 820 + 840 740 - 860 + 880 740 - 780 + 800 640 - 820 + 840 180 - 640 + 660 820 - 640 + 660 140 - 240 + 260 860 - 240 + 260 140 - 180 + 200 860 - 180 + 200 440 950 560 @@ -64,38 +64,38 @@ 320 950 240 - 820 + 840 840 - 340 + 390 740 - 380 + 430 740 - 300 + 350 640 - 340 + 390 180 - 200 + 250 820 - 200 + 250 140 - 80 + 130 860 - 80 + 130 140 - 20 + 70 860 - 20 + 70 440 - 420 + 470 560 - 420 + 470 680 - 420 + 470 320 - 420 + 470 240 - 340 + 390