mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 23:36:04 +00:00
fix(input): choosing the Gamepad layout in Steam mode keeps its gamepad actions (#2954)
Choosing a layout from the layout menu took the first actions saved for it. Desktop and Steam mode both draw the stock Gamepad, and Desktop's actions (stick moves the pointer, face buttons click and press Enter and Esc, D-pad sends arrow keys) could come first, so Steam mode's on-screen pad became a mouse and keyboard. A choice now takes the mode's own actions, or any the other mode doesn't use, and a Steam-mode selection already holding Desktop's actions is dropped on upgrade.
This commit is contained in:
1 parent
089c18b49d
commit
33761c30ab
3 files changed
+46
-2
No files matched your search
@@ -198,4 +198,35 @@ class ControlsChoiceTest {
|
||||
assertEquals(InputLibraries.OVERLAY, library.profile(InputProfile.GAME).parts.getValue(InputRole.PRIMARY).layout)
|
||||
assertEquals(InputLibraries.OVERLAY, ControlsChoice.current(context, null, steamMode = true))
|
||||
}
|
||||
|
||||
private fun desktopMouseFirst(): String {
|
||||
val mouse = SavedInputBindings("desktop.mouse", "Desktop / primary", false, InputLibraries.OVERLAY,
|
||||
controls = mapOf(InputControl.A to InputAction.MouseButton(272), InputControl.LS to InputAction.Pointer()))
|
||||
InputLibraries.update(context) { it.copy(bindings = listOf(mouse) + it.bindings).chooseBindings(InputProfile.DESKTOP, InputRole.PRIMARY, mouse.id) }
|
||||
return mouse.id
|
||||
}
|
||||
|
||||
@Test fun choosingTheGamepadKeepsEachModesOwnActions() {
|
||||
val mouse = desktopMouseFirst()
|
||||
val game = InputLibraries.read(context).profile(InputProfile.GAME).parts.getValue(InputRole.PRIMARY).bindings
|
||||
ControlsChoice.choose(context, null, InputLibraries.OVERLAY, desktop = false)
|
||||
ControlsChoice.choose(context, null, InputLibraries.OVERLAY, desktop = true)
|
||||
val library = InputLibraries.read(context)
|
||||
assertNotEquals(mouse, library.activePart(false, InputRole.PRIMARY).bindings)
|
||||
assertEquals(game, library.activePart(false, InputRole.PRIMARY).bindings)
|
||||
assertEquals(mouse, library.activePart(true, InputRole.PRIMARY).bindings)
|
||||
ControlsChoice.choose(context, 7, InputLibraries.OVERLAY, desktop = false)
|
||||
assertNotEquals(mouse, GameControls.bindings(context, 7))
|
||||
}
|
||||
|
||||
@Test fun aGameSelectionHoldingDesktopActionsIsDroppedOnUpgrade() {
|
||||
val mouse = desktopMouseFirst()
|
||||
val broken = InputLibraries.read(context).selectPart(false, InputRole.PRIMARY, mouse)
|
||||
val raw = org.json.JSONObject(InputLibraries.encode(broken)).put("version", 15).toString()
|
||||
context.getSharedPreferences("input-profiles", Context.MODE_PRIVATE).edit().putString("library", raw).commit()
|
||||
val library = InputLibraries.read(context)
|
||||
assertNull(library.selection(false).parts[InputRole.PRIMARY])
|
||||
assertEquals(mouse, library.activePart(true, InputRole.PRIMARY).bindings)
|
||||
assertEquals(InputLibraries.OVERLAY, ControlsChoice.current(context, null, steamMode = true))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user