mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 23:36:04 +00:00
fix(input): D-pad keeps direction overrides, kit bindings survive layout edits and an emptied gamepad stays empty
This commit is contained in:
1 parent
fdcb7eb3c4
commit
952f363b45
11 files changed
+50
-11
No files matched your search
@@ -27,7 +27,7 @@ class ControlsPresenterTest {
|
||||
assertFalse(plan.shown)
|
||||
continue
|
||||
}
|
||||
val place = if (state.steamLayout) Place.STEAM else if (state.bottomScreen) Place.BOTTOM else Place.MAIN
|
||||
val place = if (state.bottomScreen) Place.BOTTOM else if (state.steamLayout) Place.STEAM else Place.MAIN
|
||||
val hidden = if (state.hiddenByTap) Hidden.BY_TAP else if (state.mode == SessionPrefs.OSC_AUTO && state.controllerInUse) Hidden.BY_CONTROLLER else null
|
||||
assertEquals(state.toString(), ControlsPresenter.Plan(place, hidden), plan)
|
||||
assertEquals(state.toString(), hidden == null, plan.shown)
|
||||
@@ -49,7 +49,7 @@ class ControlsPresenterTest {
|
||||
}
|
||||
|
||||
@Test fun theSteamLayoutWinsOverTheBottomScreen() {
|
||||
assertEquals(Place.STEAM, ControlsPresenter.plan(playing.copy(steamLayout = true, bottomScreen = true)).place)
|
||||
assertEquals(Place.BOTTOM, ControlsPresenter.plan(playing.copy(steamLayout = true, bottomScreen = true)).place)
|
||||
assertEquals(Place.BOTTOM, ControlsPresenter.plan(playing.copy(bottomScreen = true)).place)
|
||||
}
|
||||
|
||||
|
||||
@@ -198,4 +198,19 @@ class InputSurfaceSourceTest {
|
||||
assertEquals(0, physical)
|
||||
assertTrue(player > 0)
|
||||
}
|
||||
|
||||
@Test fun theKitDpadUsesSavedDirectionButtonsAndCancellingNeverRunsADirectionCommand() {
|
||||
val dpad = InputSurfaceElement(InputControl.LS, .1f, .1f, .3f, .3f, KitLayout.DPAD_ID, InputElementKind.DPAD)
|
||||
bridge.setInputProfile(InputProfile("test", elements = mapOf(InputRole.SECONDARY to mapOf("legacy:up" to InputAction.Keys(listOf(103)),
|
||||
"legacy:down" to InputAction.Command(InputCommand.KEYBOARD)))))
|
||||
val pad = source(dpad)
|
||||
pad.update(0f, -1f)
|
||||
assertEquals("key:103:true", events.last())
|
||||
pad.update(0f, 0f)
|
||||
assertEquals("key:103:false", events.last())
|
||||
events.clear()
|
||||
pad.update(0f, 1f)
|
||||
pad.cancel()
|
||||
assertTrue(events.none { it.startsWith("KEYBOARD") })
|
||||
}
|
||||
}
|
||||
@@ -149,4 +149,21 @@ class OnScreenControlPrefsTest {
|
||||
assertEquals(SessionPrefs.OSC_ALWAYS, SessionPrefs.oscMode(context))
|
||||
assertTrue(SessionPrefs.steamTouchLayout(context))
|
||||
}
|
||||
|
||||
@Test fun aGamepadWithEveryKitControlRemovedStaysEmptyAndKeepsKitBindingsOnOtherEdits() {
|
||||
val library = InputLibraries.read(context)
|
||||
val overlay = library.layouts.single { it.id == InputLibraries.OVERLAY }
|
||||
val key = InputSurfaceElement(InputControl.A, .4f, .4f, .1f, .1f, "imported:9", name = "Key")
|
||||
val emptied = overlay.copy(elements = listOf(key), aspect = 16f / 9, kitless = true)
|
||||
InputLibraries.update(context) { it.withLayout(emptied) }
|
||||
val stored = InputLibraries.read(context).layouts.single { it.id == InputLibraries.OVERLAY }
|
||||
assertFalse(OnScreenLayout.generated(stored))
|
||||
assertEquals(listOf("imported:9"), OnScreenLayout.elements(context, stored, 1920, 1080, android.graphics.Rect()).map { it.id })
|
||||
val bindings = library.preset(library.activePart(false, InputRole.PRIMARY).bindings)
|
||||
val withKey = InputLibraries.update(context) { lib ->
|
||||
lib.withLayout(overlay).withPreset(bindings.copy(elements = bindings.elements + ("legacy:a" to InputAction.Keys(listOf(30)))))
|
||||
}
|
||||
val dimmed = withKey.withLayout(overlay.copy(style = overlay.style.copy(opacity = 50)))
|
||||
assertEquals(InputAction.Keys(listOf(30)), dimmed.preset(bindings.id).elements["legacy:a"])
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user