fix(input): release a held mouse Back only when its own device disconnects

This commit is contained in:
Omar Al Taki authored and Kurt Himebauch committed 2026-11-05 12:13:51 -05:00
1 parent aad60fef5b
commit 3d1f0f63b9
3 files changed
+28 -1

No files matched your search

@@ -588,7 +588,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
Log.i(TAG, "input device $deviceId disconnected")
dropMouseCursor()
backQamInput.onDeviceRemoved(deviceId)
mouseBackInput.cancel()
mouseBackInput.onDeviceRemoved(deviceId)
joyConVr?.refresh()
padBridge?.onDeviceRemoved(deviceId)
if (::padMouse.isInitialized) padMouse.reset()
@@ -37,6 +37,13 @@ class MouseBackInput(private val sendRight: (Boolean) -> Unit, private val mouse
sendRight(false)
}
fun onDeviceRemoved(deviceId: Int) {
if (held.isEmpty()) return
held.remove(deviceId)
if (!mouseAttached()) held.remove(KeyCharacterMap.VIRTUAL_KEYBOARD)
if (held.isEmpty()) sendRight(false)
}
companion object {
fun isFromMouse(event: KeyEvent): Boolean =
event.isFromSource(InputDevice.SOURCE_MOUSE) || event.isFromSource(InputDevice.SOURCE_MOUSE_RELATIVE)