mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 23:36:04 +00:00
fix(input): removed kit controls keep their actions in gamepad layouts
This commit is contained in:
1 parent
cd5e824c1b
commit
dcebdac765
4 files changed
+46
-7
No files matched your search
@@ -176,7 +176,23 @@ class OnScreenControlPrefsTest {
|
||||
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"])
|
||||
assertEquals(InputAction.Keys(listOf(103)), noDpad.preset(bindings.id).elements["legacy:up"])
|
||||
}
|
||||
|
||||
@Test fun removingAKitControlFromAGamepadLayoutKeepsItsActionForReset() {
|
||||
val library = InputLibraries.read(context)
|
||||
val overlay = library.layouts.single { it.id == InputLibraries.OVERLAY }
|
||||
val kit = KitLayout.elements(context, PadKit.XBOX, 1920, 1080)
|
||||
val bindings = library.preset(library.activePart(false, InputRole.PRIMARY).bindings)
|
||||
val withA = library.withLayout(overlay.copy(elements = kit, aspect = 16f / 9))
|
||||
.withPreset(bindings.copy(elements = bindings.elements + ("legacy:a" to InputAction.Keys(listOf(30)))))
|
||||
val noA = withA.withLayout(overlay.copy(elements = kit.filterNot { it.id == "legacy:a" }, aspect = 16f / 9)).validate()
|
||||
assertEquals(InputAction.Keys(listOf(30)), noA.preset(bindings.id).elements["legacy:a"])
|
||||
val kitless = noA.withLayout(overlay.copy(elements = emptyList(), kitless = true)).validate()
|
||||
assertEquals(InputAction.Keys(listOf(30)), kitless.preset(bindings.id).elements["legacy:a"])
|
||||
val custom = SavedInputLayout("custom", "Custom", listOf(InputSurfaceElement(InputControl.B, .1f, .1f, .1f, .1f, "legacy:b")))
|
||||
assertNull(custom.element("legacy:a"))
|
||||
assertNull(overlay.element("imported:404"))
|
||||
}
|
||||
|
||||
@Test fun aFailedRecoverySaveLeavesTheStoredLibraryAsItWas() {
|
||||
|
||||
@@ -272,6 +272,20 @@ class InputSettingsTest {
|
||||
compose.runOnIdle { assertTrue(OnScreenLayout.generated(InputLibraries.read(context).layouts.first { it.id == layout.id })) }
|
||||
}
|
||||
|
||||
@Test @Config(qualifiers = "w833dp-h468dp-land-369dpi")
|
||||
fun removingAndRestoringAKitButtonKeepsItsAction() {
|
||||
val library = InputLibraries.read(context)
|
||||
val layout = library.layout("game", InputRole.PRIMARY)!!
|
||||
val bindingsId = library.profile("game").binding(InputRole.PRIMARY)
|
||||
InputLibraries.update(context) { lib -> lib.preset(bindingsId).let { b -> lib.withPreset(b.copy(elements = b.elements + ("legacy:a" to InputAction.Keys(listOf(30))))) } }
|
||||
val a = InputLibraries.defaultPositions(context, library, layout)!!.first.single { it.id == "legacy:a" }
|
||||
compose.setContent { DroidDeckTheme { InputSurfaceDialog("game", {}, {}, role = InputRole.PRIMARY, layoutId = layout.id, bindingsId = bindingsId) } }
|
||||
compose.onNodeWithTag("input-layout-canvas").performTouchInput { click(percentOffset(a.x + a.width / 2, a.y + a.height / 2)) }
|
||||
compose.onNodeWithText(context.getString(R.string.input_remove_element)).performClick()
|
||||
compose.onNodeWithText(context.getString(R.string.input_editor_done)).performScrollTo().performClick()
|
||||
compose.runOnIdle { assertEquals(InputAction.Keys(listOf(30)), InputLibraries.read(context).preset(bindingsId).elements["legacy:a"]) }
|
||||
}
|
||||
|
||||
@Test fun resetAndSaveKeepTheDpadDirectionOverrides() {
|
||||
val library = InputLibraries.read(context)
|
||||
val layout = library.layout("game", InputRole.PRIMARY)!!
|
||||
|
||||
Reference in new issue
Block a user