fix: keep held Steam Touch controls pressed across action-set and layer changes (#1143)

This commit is contained in:
Resul Övür authored and GitHub committed 2026-10-19 23:50:29 -04:00
1 parent 6b8ce9e675
commit 68b4c87d9a
3 files changed
+38 -3

No files matched your search

@@ -65,4 +65,27 @@ class SteamTouchConfigTest {
val config = SteamTouchConfig.Config(null, null, null, emptyMap(), kv)
assertEquals(listOf(1 to "Desktop", 2 to "Gamepad"), SteamTouchConfig.actionSets(config))
}
@Test
fun remapHeldKeepsSurvivingControlsAndDropsRemovedOrNullOnes() {
val layouts = SteamTouchConfig.decodeLayouts(SteamTouchConfig.hexToBytes(saved))
val baseConfig = SteamTouchConfig.Config(null, null, layouts, mapOf(0 to setOf(SteamTouchConfig.A, SteamTouchConfig.JOYSTICK_LEFT)))
val layerConfig = SteamTouchConfig.Config(null, null, layouts, mapOf(0 to setOf(SteamTouchConfig.A), 1 to setOf(SteamTouchConfig.B)))
val after = SteamTouchConfig.elementsFor(layerConfig, 0, listOf(2))
val remapped = SteamTouchConfig.remapHeld(
mapOf(
7 to SteamTouchConfig.A,
8 to SteamTouchConfig.JOYSTICK_LEFT,
9 to null,
10 to SteamTouchConfig.B,
),
after,
)
assertEquals(setOf(7, 10), remapped.keys)
assertEquals(after.first { it.type == SteamTouchConfig.A }, remapped[7])
assertEquals(after.first { it.type == SteamTouchConfig.B }, remapped[10])
assertFalse(baseConfig.availableFor(0, emptyList()).isEmpty())
}
}