summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authort895 <clombardo169@gmail.com>2024-01-26 02:39:52 +0100
committert895 <clombardo169@gmail.com>2024-01-26 02:39:52 +0100
commit68cbf67f4c852d0dc3745dcacc8f0a40e4595f1d (patch)
tree91e5f930f8f26b64e76fd7effbfec7e5051d7118 /src
parentMerge pull request #12759 from liamwhite/mp-misc (diff)
downloadyuzu-68cbf67f4c852d0dc3745dcacc8f0a40e4595f1d.tar
yuzu-68cbf67f4c852d0dc3745dcacc8f0a40e4595f1d.tar.gz
yuzu-68cbf67f4c852d0dc3745dcacc8f0a40e4595f1d.tar.bz2
yuzu-68cbf67f4c852d0dc3745dcacc8f0a40e4595f1d.tar.lz
yuzu-68cbf67f4c852d0dc3745dcacc8f0a40e4595f1d.tar.xz
yuzu-68cbf67f4c852d0dc3745dcacc8f0a40e4595f1d.tar.zst
yuzu-68cbf67f4c852d0dc3745dcacc8f0a40e4595f1d.zip
Diffstat (limited to 'src')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt8
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt29
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/model/EmulationViewModel.kt8
-rw-r--r--src/android/app/src/main/res/layout/fragment_emulation.xml1
4 files changed, 39 insertions, 7 deletions
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 9b08f008d..26cddecf4 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
@@ -193,6 +193,10 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
return super.dispatchKeyEvent(event)
}
+ if (emulationViewModel.drawerOpen.value) {
+ return super.dispatchKeyEvent(event)
+ }
+
return InputHandler.dispatchKeyEvent(event)
}
@@ -203,6 +207,10 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
return super.dispatchGenericMotionEvent(event)
}
+ if (emulationViewModel.drawerOpen.value) {
+ return super.dispatchGenericMotionEvent(event)
+ }
+
// Don't attempt to do anything if we are disconnecting a device.
if (event.actionMasked == MotionEvent.ACTION_CANCEL) {
return 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 d17e087fe..22da1d0e5 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
@@ -38,6 +38,7 @@ import androidx.window.layout.WindowLayoutInfo
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.slider.Slider
import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
import org.yuzu.yuzu_emu.HomeNavigationDirections
@@ -184,10 +185,13 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
override fun onDrawerOpened(drawerView: View) {
binding.drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED)
+ binding.inGameMenu.requestFocus()
+ emulationViewModel.setDrawerOpen(true)
}
override fun onDrawerClosed(drawerView: View) {
binding.drawerLayout.setDrawerLockMode(IntSetting.LOCK_DRAWER.getInt())
+ emulationViewModel.setDrawerOpen(false)
}
override fun onDrawerStateChanged(newState: Int) {
@@ -239,6 +243,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
requireContext().theme
)
}
+ binding.inGameMenu.requestFocus()
true
}
@@ -247,6 +252,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
null,
Settings.MenuTag.SECTION_ROOT
)
+ binding.inGameMenu.requestFocus()
binding.root.findNavController().navigate(action)
true
}
@@ -256,6 +262,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
args.game,
Settings.MenuTag.SECTION_ROOT
)
+ binding.inGameMenu.requestFocus()
binding.root.findNavController().navigate(action)
true
}
@@ -287,6 +294,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
)
}
}
+ binding.inGameMenu.requestFocus()
NativeConfig.saveGlobalConfig()
true
}
@@ -295,7 +303,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
emulationState.stop()
emulationViewModel.setIsEmulationStopping(true)
binding.drawerLayout.close()
- binding.drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
+ binding.inGameMenu.requestFocus()
true
}
@@ -312,12 +320,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
if (!NativeLibrary.isRunning()) {
return
}
-
- if (binding.drawerLayout.isOpen) {
- binding.drawerLayout.close()
- } else {
- binding.drawerLayout.open()
- }
+ emulationViewModel.setDrawerOpen(!binding.drawerLayout.isOpen)
}
}
)
@@ -408,6 +411,18 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
}
}
}
+ launch {
+ repeatOnLifecycle(Lifecycle.State.CREATED) {
+ emulationViewModel.drawerOpen.collect {
+ if (it) {
+ binding.drawerLayout.open()
+ binding.inGameMenu.requestFocus()
+ } else {
+ binding.drawerLayout.close()
+ }
+ }
+ }
+ }
}
}
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/EmulationViewModel.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/EmulationViewModel.kt
index f34870c2d..b66f47fe7 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/EmulationViewModel.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/EmulationViewModel.kt
@@ -6,6 +6,7 @@ package org.yuzu.yuzu_emu.model
import androidx.lifecycle.ViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.asStateFlow
class EmulationViewModel : ViewModel() {
val emulationStarted: StateFlow<Boolean> get() = _emulationStarted
@@ -23,6 +24,9 @@ class EmulationViewModel : ViewModel() {
val shaderMessage: StateFlow<String> get() = _shaderMessage
private val _shaderMessage = MutableStateFlow("")
+ private val _drawerOpen = MutableStateFlow(false)
+ val drawerOpen = _drawerOpen.asStateFlow()
+
fun setEmulationStarted(started: Boolean) {
_emulationStarted.value = started
}
@@ -49,6 +53,10 @@ class EmulationViewModel : ViewModel() {
setTotalShaders(max)
}
+ fun setDrawerOpen(value: Boolean) {
+ _drawerOpen.value = value
+ }
+
fun clear() {
setEmulationStarted(false)
setIsEmulationStopping(false)
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 5252adf54..988bbb373 100644
--- a/src/android/app/src/main/res/layout/fragment_emulation.xml
+++ b/src/android/app/src/main/res/layout/fragment_emulation.xml
@@ -160,6 +160,7 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
+ android:focusedByDefault="true"
app:headerLayout="@layout/header_in_game"
app:menu="@menu/menu_in_game"
tools:visibility="gone" />