mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
fix: ignore uinput-* system virtual input devices in controller detection (#954)
This commit is contained in:
1 parent
87763976d8
commit
e032f25114
2 files changed
+22
-4
No files matched your search
@@ -71,6 +71,17 @@ class PadBridgeRoutingTest {
|
||||
InputDevice.KEYBOARD_TYPE_NONE, id = -1)
|
||||
assertTrue(virtual.isVirtual)
|
||||
assertFalse(PadBridge.isFromController(virtual))
|
||||
for (uinputName in listOf("uinput-xiaomi", "uinput-fpc", "uinput_nav")) {
|
||||
val phantom = device(
|
||||
InputDevice.SOURCE_GAMEPAD or InputDevice.SOURCE_JOYSTICK,
|
||||
InputDevice.KEYBOARD_TYPE_NONE,
|
||||
name = uinputName,
|
||||
)
|
||||
assertFalse(phantom.isVirtual)
|
||||
assertFalse(PadBridge.isFromController(phantom))
|
||||
assertFalse(PadBridge.isControllerKeyEvent(key(phantom, KeyEvent.KEYCODE_BUTTON_A, KeyEvent.ACTION_DOWN)))
|
||||
}
|
||||
assertFalse(PadBridge.anyControllerConnected())
|
||||
}
|
||||
|
||||
@Test fun keyAndMotionOwnershipDoesNotFollowEverySourceOnTheDevice() {
|
||||
@@ -146,8 +157,8 @@ class PadBridgeRoutingTest {
|
||||
private var nextId = 10
|
||||
|
||||
private fun device(sources: Int, type: Int, keys: IntArray = intArrayOf(KeyEvent.KEYCODE_A, KeyEvent.KEYCODE_DPAD_UP),
|
||||
rangeSource: Int? = null, axis: Int = MotionEvent.AXIS_X, id: Int = nextId++): InputDevice {
|
||||
val builder = InputDeviceBuilder.newBuilder().setId(id).setName("routing fixture $id")
|
||||
rangeSource: Int? = null, axis: Int = MotionEvent.AXIS_X, id: Int = nextId++, name: String = "routing fixture $id"): InputDevice {
|
||||
val builder = InputDeviceBuilder.newBuilder().setId(id).setName(name)
|
||||
.setDescriptor("routing-$id").setExternal(true).setSources(sources).setKeyboardType(type)
|
||||
.setKeyCharacterMap(KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD))
|
||||
if (rangeSource != null) builder.addMotionRange(axis, rangeSource, -1f, 1f, 0f, 0f, 0f)
|
||||
|
||||
Reference in new issue
Block a user