mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
fix(input): Back gesture opens the menu when a controller exposes its own mouse (#2666)
The 8BitDo Ultimate Mobile registers a mouse interface next to its gamepad. On REDMAGIC the back gesture has no virtual-hard-key flag, so with that mouse attached it was sent to the game as a right-click. A mouse that shares its USB id with an attached controller no longer counts.
This commit is contained in:
1 parent
c2663ebee8
commit
9c349e185e
3 files changed
+24
-2
No files matched your search
@@ -4786,8 +4786,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
|
||||
private fun externalMouseAttached(): Boolean {
|
||||
lastExternalMouse = InputDevice.getDeviceIds().map { InputDevice.getDevice(it) }
|
||||
.firstOrNull { device -> device != null && com.droiddeck.launcher.input.MouseBackInput.isExternalMouse(device) }
|
||||
lastExternalMouse = com.droiddeck.launcher.input.MouseBackInput.externalMouse(
|
||||
InputDevice.getDeviceIds().map { InputDevice.getDevice(it) })
|
||||
return lastExternalMouse != null
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,16 @@ class MouseBackInput(private val sendRight: (Boolean) -> Unit, private val mouse
|
||||
!device.supportsSource(InputDevice.SOURCE_TOUCHSCREEN)
|
||||
}
|
||||
|
||||
/** A controller's own mouse interface (8BitDo Ultimate Mobile) is not a mouse the user right-clicks with. */
|
||||
fun externalMouse(devices: List<InputDevice?>): InputDevice? {
|
||||
val controllers = devices.filterNotNull().filter { PadBridge.isFromController(it) }
|
||||
return devices.filterNotNull().firstOrNull { mouse ->
|
||||
isExternalMouse(mouse) && controllers.none {
|
||||
it.vendorId != 0 && it.vendorId == mouse.vendorId && it.productId == mouse.productId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val VIRTUAL_NAME = Regex("\\bvirtual\\b", RegexOption.IGNORE_CASE)
|
||||
|
||||
fun declaresVirtual(name: String?): Boolean = name != null && VIRTUAL_NAME.containsMatchIn(name)
|
||||
|
||||
Reference in new issue
Block a user