feat(input): full-size portrait pad, one top row and sticks for every non-Steam kit

This commit is contained in:
Kurt Himebauch committed 2026-11-18 19:40:27 -05:00
1 parent ceb0360cd8
commit 695ae21f93
4 files changed
+127 -59

No files matched your search

@@ -176,8 +176,9 @@ class KitLayoutTest {
val face = listOf("legacy:y", "legacy:x", "legacy:b", "legacy:a").map { centre(e.getValue(it), w, h) }
val cx = face.map { it.first }.average().toFloat(); val cy = face.map { it.second }.average().toFloat()
val radius = e.getValue("legacy:a").height * h / 2
for ((x, y) in face) assertEquals("$kit $w x $h", radius * ratio.getValue(kit), hypot(x - cx, y - cy), 1f)
if (kit == PadKit.XBOX) {
val spread = if (h > w) .3f / .17f else ratio.getValue(kit)
for ((x, y) in face) assertEquals("$kit $w x $h", radius * spread, hypot(x - cx, y - cy), 1f)
if (kit == PadKit.XBOX && h <= w) {
val (lx, ly) = centre(e.getValue("legacy:ls"), w, h); val (cx3, cy3) = centre(e.getValue("legacy:l3"), w, h)
val unit = e.getValue("legacy:ls").height * h / 208f
assertEquals("$w x $h", hypot(150f, 110f) * unit, hypot(cx3 - lx, cy3 - ly), 1f)
@@ -207,18 +208,19 @@ class KitLayoutTest {
}
}
@Test fun portraitSurfacesKeepEveryControlInTheBottomBlock() {
for (kit in PadKit.entries) for ((w, h) in listOf(1080 to 1920, 1200 to 2000)) {
@Test fun portraitSurfacesPutTheWholePadInTheLowerPartAboveABottomRow() {
val density = context.resources.displayMetrics.density
for (kit in PadKit.entries) for ((w, h) in listOf(1080 to 1920, 1200 to 2000, 1080 to 2400)) {
val elements = KitLayout.elements(context, kit, w, h)
val unit = w / 1200f
val top = elements.minOf { it.y } * h
assertTrue("$kit $w x $h top $top", top >= h - 900 * unit - .5f)
assertEquals("$kit $w x $h", h.toFloat(), elements.maxOf { (it.y + it.height) * h }, 900 * unit * .1f)
val tall = KitLayout.elements(context, kit, w, h + 100).associateBy { it.id }
for (e in elements.filter { it.height > .031f && tall.getValue(it.id).height > .031f }) {
val t = tall.getValue(e.id)
assertEquals("$kit ${e.id}", (1 - e.y - e.height / 2) * h, (1 - t.y - t.height / 2) * (h + 100), 1f)
}
val row = 60 * density
val area = minOf(h * .6f, w * 1.15f)
assertTrue("$kit $w x $h", elements.minOf { it.y } * h >= h - row - area - .5f)
assertTrue("$kit $w x $h", elements.maxOf { (it.y + it.height) * h } <= h + .5f)
val bottomRow = elements.filter { (it.y + it.height / 2) * h > h - row }
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)
}
}
@@ -238,4 +240,12 @@ class KitLayoutTest {
assertTrue(placed.none { it.floating })
}
}
@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)
}
}
}
@@ -94,7 +94,7 @@ class GamepadGeometryTest {
@Test fun portraitDockPlacesAllControlsWithinThePanel() {
for (panel in portraitPanels) {
val b = portraitBoxes(panel)
assertEquals(panel.name, Slot.values().toSet(), b.keys)
assertEquals(panel.name, Slot.values().toSet() - setOf(Slot.STEAM, Slot.QAM, Slot.PANELS), b.keys)
for ((slot, box) in b) {
val where = "${panel.name}: $slot $box"
assertTrue(where, box.left >= 0f && box.top >= 0f)
@@ -126,16 +126,35 @@ class GamepadGeometryTest {
}
}
@Test fun portraitDockMovesUtilitiesAndGripsAboveTheGamepad() {
@Test fun portraitDockPutsShouldersAndMenusInOneRowAboveTheGripsAndTheGamepad() {
for (panel in portraitPanels) {
val b = portraitBoxes(panel)
assertEquals(panel.name, 8 * panel.density, b.getValue(Slot.VIEW).top, 0.5f)
val row = listOf(Slot.LEFT_OUTER_SHOULDER, Slot.LEFT_INNER_SHOULDER, Slot.VIEW, Slot.MENU, Slot.RIGHT_INNER_SHOULDER, Slot.RIGHT_OUTER_SHOULDER)
for (slot in row) assertEquals("${panel.name}: $slot", 8 * panel.density, b.getValue(slot).top, 0.5f)
assertEquals(panel.name, row, row.sortedBy { b.getValue(it).cx })
assertTrue(panel.name, b.getValue(Slot.MENU).bottom < b.getValue(Slot.L4).top)
assertTrue(panel.name, b.getValue(Slot.L4).bottom < b.getValue(Slot.LEFT_OUTER_SHOULDER).top)
assertTrue(panel.name, b.getValue(Slot.LEFT_OUTER_SHOULDER).bottom < b.getValue(Slot.LEFT_SECOND).top)
assertTrue(panel.name, b.getValue(Slot.L4).bottom < b.getValue(Slot.LEFT_SECOND).top)
assertTrue(panel.name, b.getValue(Slot.LEFT_SECOND).bottom < b.getValue(Slot.LEFT_MAIN).top)
}
}
@Test fun aPortraitDockWithoutGripsGivesTheirRowToTheGamepad() {
for (panel in portraitPanels) {
val with = portraitBoxes(panel)
val without = GamepadGeometry.layout(panel.width.toFloat(), panel.controlsHeight.toFloat(), panel.density, portraitDock = true, grips = false)
assertTrue(panel.name, grips.none { it in without })
assertTrue(panel.name, without.getValue(Slot.LEFT_SECOND).top < with.getValue(Slot.LEFT_SECOND).top)
assertTrue(panel.name, without.getValue(Slot.LEFT_SECOND).width >= with.getValue(Slot.LEFT_SECOND).width)
}
}
@Test fun aShorterPortraitDockStillGetsTheUprightLayout() {
val (w, h, density) = Triple(1080f, 1010f, 369 / 160f)
val b = GamepadGeometry.layout(w, h, density, portraitDock = true, grips = false)
assertEquals(8 * density, b.getValue(Slot.VIEW).top, 0.5f)
assertTrue(b.getValue(Slot.RIGHT_SECOND).width >= w * 0.3f)
}
@Test fun shortPanelsKeepTheExistingLayoutEvenWhenPortraitDockIsRequested() {
for ((width, height, density) in listOf(Triple(1920f, 1080f, 2f), Triple(720f, 600f, 2.3f))) {
assertEquals(GamepadGeometry.layout(width, height, density),