mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 23:36:04 +00:00
fix(input): saved D-pad keeps direction overrides, held directions wait for neutral and Reset regenerates an emptied gamepad
This commit is contained in:
1 parent
952f363b45
commit
bf75dfb9c0
7 files changed
+39
-5
No files matched your search
@@ -213,4 +213,18 @@ class InputSurfaceSourceTest {
|
||||
pad.cancel()
|
||||
assertTrue(events.none { it.startsWith("KEYBOARD") })
|
||||
}
|
||||
|
||||
@Test fun aDirectionHeldAcrossAProfileChangeWaitsForNeutral() {
|
||||
val dpad = InputSurfaceElement(InputControl.LS, .1f, .1f, .3f, .3f, KitLayout.DPAD_ID, InputElementKind.DPAD)
|
||||
bridge.setInputProfile(InputProfile("first", elements = mapOf(InputRole.SECONDARY to mapOf(KitLayout.DPAD_ID to InputAction.Directions(17, 32, 31, 30)))))
|
||||
val pad = source(dpad)
|
||||
pad.update(0f, -1f)
|
||||
bridge.setInputProfile(InputProfile("second", elements = mapOf(InputRole.SECONDARY to mapOf("legacy:up" to InputAction.Keys(listOf(103))))))
|
||||
events.clear()
|
||||
pad.update(0f, -1f)
|
||||
assertTrue(events.none { it == "key:103:true" })
|
||||
pad.update(0f, 0f)
|
||||
pad.update(0f, -1f)
|
||||
assertEquals("key:103:true", events.last())
|
||||
}
|
||||
}
|
||||
@@ -166,4 +166,16 @@ class OnScreenControlPrefsTest {
|
||||
val dimmed = withKey.withLayout(overlay.copy(style = overlay.style.copy(opacity = 50)))
|
||||
assertEquals(InputAction.Keys(listOf(30)), dimmed.preset(bindings.id).elements["legacy:a"])
|
||||
}
|
||||
|
||||
@Test fun aSavedKitDpadKeepsItsDirectionOverrides() {
|
||||
val library = InputLibraries.read(context)
|
||||
val overlay = library.layouts.single { it.id == InputLibraries.OVERLAY }
|
||||
val saved = overlay.copy(elements = KitLayout.elements(context, PadKit.XBOX, 1920, 1080), aspect = 16f / 9)
|
||||
val bindings = library.preset(library.activePart(false, InputRole.PRIMARY).bindings)
|
||||
val withUp = library.withLayout(saved).withPreset(bindings.copy(elements = bindings.elements + ("legacy:up" to InputAction.Keys(listOf(103)))))
|
||||
val edited = withUp.withLayout(saved.copy(style = saved.style.copy(opacity = 60))).validate()
|
||||
assertEquals(InputAction.Keys(listOf(103)), edited.preset(bindings.id).elements["legacy:up"])
|
||||
val noDpad = edited.withLayout(saved.copy(elements = saved.elements.filterNot { it.id == KitLayout.DPAD_ID }))
|
||||
assertNull(noDpad.preset(bindings.id).elements["legacy:up"])
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user