mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
fix(input): release a mouse Back right click on focus loss and pass nav Back through
Address review: a navigation-bar Back that arrives while an injected mouse Back is held now stays Back instead of releasing the right button early. A held right button is released on pause, focus loss and input-device removal, like the other held Back handling. While the session is suspended or still loading, Back is no longer sent to the guest.
This commit is contained in:
1 parent
57b3623a9a
commit
abb28792e8
3 files changed
+32
-3
No files matched your search
@@ -588,6 +588,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
Log.i(TAG, "input device $deviceId disconnected")
|
||||
dropMouseCursor()
|
||||
backQamInput.onDeviceRemoved(deviceId)
|
||||
mouseBackInput.cancel()
|
||||
joyConVr?.refresh()
|
||||
padBridge?.onDeviceRemoved(deviceId)
|
||||
if (::padMouse.isInitialized) padMouse.reset()
|
||||
@@ -2584,7 +2585,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
event.deviceId, event.device?.name, event.source, event.flags))
|
||||
}
|
||||
val mouseToGuest = !pipUi && !drawerOpen && !pcKeyboardOpen && !achievementsOpen && !gestureSettingsOpen &&
|
||||
!(::loading.isInitialized && loading.ended)
|
||||
!SessionState.suspended && !(::loading.isInitialized && (loading.visible || loading.ended))
|
||||
if (mouseBackInput.onKeyEvent(event, mouseToGuest)) return true
|
||||
val backToQam = !pipUi && !screenKeyTextFocus && !drawerOpen && !pcKeyboardOpen && !achievementsOpen &&
|
||||
SessionState.mode == SessionService.MODE_STEAM && SessionState.running && SessionState.firstFrameSeen &&
|
||||
@@ -4372,6 +4373,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
if (runtimeRemovalBlocked) { super.onPause(); return }
|
||||
physicalShortcuts.clear()
|
||||
backQamInput.cancel()
|
||||
mouseBackInput.cancel()
|
||||
capturePausedFrame()
|
||||
sessionClipboard.stop()
|
||||
if (::touchscreenGestures.isInitialized) touchscreenGestures.cancel()
|
||||
@@ -4933,6 +4935,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
super.onWindowFocusChanged(hasFocus)
|
||||
if (!hasFocus) com.droiddeck.launcher.input.HomeButtonShortcuts.cancel(this)
|
||||
if (!hasFocus) backQamInput.cancel()
|
||||
if (!hasFocus) mouseBackInput.cancel()
|
||||
if (!hasFocus && ::padMouse.isInitialized) padMouse.reset()
|
||||
if (runtimeRemovalBlocked) return
|
||||
if (!hasFocus) {
|
||||
|
||||
@@ -15,7 +15,9 @@ class MouseBackInput(private val sendRight: (Boolean) -> Unit, private val mouse
|
||||
fun onKeyEvent(event: KeyEvent, toGuest: Boolean): Boolean {
|
||||
if (event.keyCode != KeyEvent.KEYCODE_BACK) return false
|
||||
val device = event.deviceId
|
||||
if (device in held) {
|
||||
val fromMouse = isFromMouse(event)
|
||||
val injected = isInjectedBack(event)
|
||||
if (device in held && (fromMouse || injected)) {
|
||||
if (event.action == KeyEvent.ACTION_UP) {
|
||||
held.remove(device)
|
||||
sendRight(false)
|
||||
@@ -23,12 +25,18 @@ class MouseBackInput(private val sendRight: (Boolean) -> Unit, private val mouse
|
||||
return true
|
||||
}
|
||||
if (event.action != KeyEvent.ACTION_DOWN || event.repeatCount > 0 || !toGuest) return false
|
||||
if (!isFromMouse(event) && !(isInjectedBack(event) && mouseAttached())) return false
|
||||
if (!fromMouse && !(injected && mouseAttached())) return false
|
||||
held.add(device)
|
||||
sendRight(true)
|
||||
return true
|
||||
}
|
||||
|
||||
fun cancel() {
|
||||
if (held.isEmpty()) return
|
||||
held.clear()
|
||||
sendRight(false)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun isFromMouse(event: KeyEvent): Boolean =
|
||||
event.isFromSource(InputDevice.SOURCE_MOUSE) || event.isFromSource(InputDevice.SOURCE_MOUSE_RELATIVE)
|
||||
|
||||
Reference in new issue
Block a user