mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-01 18:45:42 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03d16e5c58 |
No files matched your search
@@ -283,7 +283,8 @@ public final class PadBridge {
|
||||
int sources = device.getSources();
|
||||
if ((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) return true;
|
||||
if ((sources & InputDevice.SOURCE_JOYSTICK) != InputDevice.SOURCE_JOYSTICK) return false;
|
||||
if (device.getKeyboardType() != InputDevice.KEYBOARD_TYPE_ALPHABETIC) return true;
|
||||
if (device.getKeyboardType() != InputDevice.KEYBOARD_TYPE_ALPHABETIC
|
||||
&& !device.supportsSource(InputDevice.SOURCE_MOUSE)) return true;
|
||||
for (int axis : JOYSTICK_AXES) {
|
||||
InputDevice.MotionRange range = device.getMotionRange(axis, InputDevice.SOURCE_JOYSTICK);
|
||||
if (range != null && range.getMax() > range.getMin()) return true;
|
||||
|
||||
@@ -2640,7 +2640,8 @@ class SessionService : Service() {
|
||||
for (id in android.view.InputDevice.getDeviceIds()) {
|
||||
val d = android.view.InputDevice.getDevice(id) ?: continue
|
||||
if (!com.droiddeck.launcher.input.PadBridge.isFromController(d)) continue
|
||||
pads.add(String.format(java.util.Locale.ROOT, "\"%s\" (%04x:%04x)", d.name, d.vendorId, d.productId))
|
||||
pads.add(String.format(java.util.Locale.ROOT, "\"%s\" (%04x:%04x, sources 0x%x, keyboard type %d)",
|
||||
d.name, d.vendorId, d.productId, d.sources, d.keyboardType))
|
||||
}
|
||||
Log.i(TAG, "controllers at start: " + (if (pads.isEmpty()) "none" else pads.joinToString(", ")) +
|
||||
"; presented to the guest as " + if (SessionState.deckPad) "switchable, starting as " + SessionPrefs.steamController(this)
|
||||
|
||||
@@ -47,7 +47,31 @@ class PadBridgeRoutingTest {
|
||||
|
||||
@Test fun aJoystickWithoutKeyboardCapabilitiesRemainsAController() {
|
||||
assertTrue(PadBridge.isFromController(device(InputDevice.SOURCE_JOYSTICK, InputDevice.KEYBOARD_TYPE_NONE)))
|
||||
assertTrue(PadBridge.isFromController(device(COMPOSITE, InputDevice.KEYBOARD_TYPE_NON_ALPHABETIC)))
|
||||
assertTrue(PadBridge.isFromController(device(InputDevice.SOURCE_JOYSTICK or InputDevice.SOURCE_KEYBOARD or InputDevice.SOURCE_DPAD,
|
||||
InputDevice.KEYBOARD_TYPE_NON_ALPHABETIC)))
|
||||
}
|
||||
|
||||
@Test fun aMouseReceiverWithIncidentalJoystickBitsIsNotAController() {
|
||||
for (type in listOf(InputDevice.KEYBOARD_TYPE_NON_ALPHABETIC, InputDevice.KEYBOARD_TYPE_NONE)) {
|
||||
val receiver = device(COMPOSITE, type, keys = intArrayOf(KeyEvent.KEYCODE_BACK, KeyEvent.KEYCODE_VOLUME_UP),
|
||||
name = "CX Wireless mouse -1k dongle Mouse")
|
||||
assertFalse(PadBridge.isFromController(receiver))
|
||||
assertTrue(MouseBackInput.isExternalMouse(receiver))
|
||||
for (action in listOf(KeyEvent.ACTION_DOWN, KeyEvent.ACTION_UP)) {
|
||||
assertFalse(PadBridge.isControllerKeyEvent(key(receiver, KeyEvent.KEYCODE_BACK, action)))
|
||||
}
|
||||
}
|
||||
assertFalse(PadBridge.anyControllerConnected())
|
||||
}
|
||||
|
||||
@Test fun aControllerWithAPointerInterfaceRemainsAController() {
|
||||
val type = InputDevice.KEYBOARD_TYPE_NON_ALPHABETIC
|
||||
for (axis in listOf(MotionEvent.AXIS_X, MotionEvent.AXIS_RZ, MotionEvent.AXIS_HAT_X, MotionEvent.AXIS_LTRIGGER)) {
|
||||
assertTrue(PadBridge.isFromController(device(COMPOSITE, type, rangeSource = InputDevice.SOURCE_JOYSTICK, axis = axis)))
|
||||
}
|
||||
assertTrue(PadBridge.isFromController(device(COMPOSITE, type, keys = intArrayOf(KeyEvent.KEYCODE_BUTTON_A))))
|
||||
assertTrue(PadBridge.isFromController(device(COMPOSITE or InputDevice.SOURCE_GAMEPAD, type)))
|
||||
assertTrue(PadBridge.isFromController(device(InputDevice.SOURCE_GAMEPAD or InputDevice.SOURCE_MOUSE, InputDevice.KEYBOARD_TYPE_NONE)))
|
||||
}
|
||||
|
||||
@Test fun joystickRangesDistinguishAHybridFromIncidentalSourceBits() {
|
||||
|
||||
Reference in new issue
Block a user