feat(input): both sticks and both trackpads for Steam kits in portrait

This commit is contained in:
Kurt Himebauch committed 2026-11-18 20:19:02 -05:00
1 parent 0364792111
commit b29a5ef8aa
5 files changed
+50 -13

No files matched your search

@@ -220,7 +220,8 @@ class KitLayoutTest {
assertTrue("$kit $w x $h", bottomRow.any { it.id == KitLayout.KEYBOARD_ID } && bottomRow.any { it.control == InputControl.QAM })
assertTrue("$kit $w x $h", bottomRow.minOf { it.x } * w >= 52 * density - .5f)
val stick = elements.first { it.id == "legacy:ls" }
assertTrue("$kit $w x $h", stick.width * w >= w * .3f)
assertTrue("$kit $w x $h", stick.width * w >= w * if (kit.steam) .2f else .3f)
assertTrue("$kit $w x $h", elements.any { it.id == "legacy:rs" })
}
}
@@ -244,8 +245,8 @@ class KitLayoutTest {
@Test fun onlySteamKitsPutTrackpadsInTheDockedStrip() {
for (kit in PadKit.entries) {
val placed = KitLayout.dock(context, kit, 1080, 1300, true, InputControl.LS, InputControl.RIGHT_PAD).map { it.control }
assertEquals(kit.toString(), kit.steam, InputControl.RIGHT_PAD in placed)
assertEquals(kit.toString(), !kit.steam, InputControl.RS in placed)
assertEquals(kit.toString(), kit.steam, InputControl.RIGHT_PAD in placed && InputControl.LEFT_PAD in placed)
assertTrue(kit.toString(), InputControl.RS in placed && InputControl.LS in placed)
}
}
@@ -141,7 +141,8 @@ class OnScreenLayoutTest {
for ((size, portrait) in listOf((2208 to 800) to false, (1080 to 1300) to true)) {
val (w, h) = size
val placed = OnScreenLayout.elements(context, gamepad(), w, h, Rect(), dock = OnScreenLayout.Dock(portrait, grips = true))
val boxes = GamepadGeometry.layout(w.toFloat(), h.toFloat(), density, portrait)
val steam = PadKit.current(context).steam
val boxes = GamepadGeometry.layout(w.toFloat(), h.toFloat(), density, portrait, grips = steam, trackpads = steam)
val ls = placed.first { it.id == "legacy:ls" }
val box = boxes.getValue(GamepadGeometry.Slot.LEFT_MAIN)
assertEquals(box.left, ls.x * w, 1f)
@@ -38,7 +38,7 @@ class GamepadGeometryTest {
@Test fun everyControlIsPlacedAndPanelsOnlyWhenUpright() {
for (panel in panels) {
val upright = panel.height > panel.width
val expected = Slot.values().toSet() - grips - if (upright) emptySet() else setOf(Slot.PANELS)
val expected = Slot.values().toSet() - grips - setOf(Slot.LEFT_TOUCH, Slot.RIGHT_TOUCH) - if (upright) emptySet() else setOf(Slot.PANELS)
assertEquals(panel.name, expected, boxes(panel).keys)
}
}
@@ -94,7 +94,7 @@ class GamepadGeometryTest {
@Test fun portraitDockPlacesAllControlsWithinThePanel() {
for (panel in portraitPanels) {
val b = portraitBoxes(panel)
assertEquals(panel.name, Slot.values().toSet() - setOf(Slot.STEAM, Slot.QAM, Slot.PANELS), b.keys)
assertEquals(panel.name, Slot.values().toSet() - setOf(Slot.STEAM, Slot.QAM, Slot.PANELS, Slot.LEFT_TOUCH, Slot.RIGHT_TOUCH), b.keys)
for ((slot, box) in b) {
val where = "${panel.name}: $slot $box"
assertTrue(where, box.left >= 0f && box.top >= 0f)
@@ -161,4 +161,16 @@ class GamepadGeometryTest {
GamepadGeometry.layout(width, height, density, portraitDock = true))
}
}
@Test fun aPortraitDockWithTrackpadsPutsThemOutsideBothSticksWithoutOverlap() {
for (panel in portraitPanels) {
val b = GamepadGeometry.layout(panel.width.toFloat(), panel.controlsHeight.toFloat(), panel.density, portraitDock = true, trackpads = true)
val row = listOf(Slot.LEFT_TOUCH, Slot.LEFT_MAIN, Slot.RIGHT_MAIN, Slot.RIGHT_TOUCH)
assertEquals(panel.name, row, row.sortedBy { b.getValue(it).cx })
val placed = b.entries.toList()
for (i in placed.indices) for (j in i + 1 until placed.size)
assertFalse("${panel.name}: ${placed[i].key} overlaps ${placed[j].key}", placed[i].value.overlaps(placed[j].value))
for ((slot, box) in b) assertTrue("${panel.name}: $slot", box.bottom <= panel.controlsHeight + .5f && box.right <= panel.width + .5f)
}
}
}