mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +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
@@ -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