mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 21:35:59 +00:00
fix(input): the Xbox and PS buttons move to the bottom row of the floating gamepad (#2944)
The Steam kits keep their Steam and Quick Access buttons on the bottom row, and Start and Select moved there too, but the Xbox kit's Guide button still sat at the top centre of the screen and the PlayStation kits' PS button over the middle of the game. Both now sit between Select and Start, where the real pads have them, centred on the safe area like Select and Start.
This commit is contained in:
1 parent
d7f43c26cd
commit
42133bec0b
2 files changed
+14
-8
No files matched your search
@@ -86,10 +86,10 @@ object KitLayout {
|
||||
Spec(InputControl.LS, 565f, 690f, 100f), Spec(InputControl.RS, 1035f, 690f, 100f),
|
||||
Spec(InputControl.L3, 430f, 590f, 42f, ax = 565f, ay = 690f), Spec(InputControl.R3, 1170f, 590f, 42f, ax = 1035f, ay = 690f),
|
||||
Spec(InputControl.SELECT, 640f, 850f, 50f, 30f, shape = InputButtonShape.PILL), Spec(InputControl.START, 960f, 850f, 50f, 30f, shape = InputButtonShape.PILL),
|
||||
Spec(InputControl.GUIDE, 800f, 250f, 46f), Spec(InputControl.QAM, 220f, 848f, 46f), keyboard(136f))
|
||||
Spec(InputControl.GUIDE, 800f, 850f, 46f), Spec(InputControl.QAM, 220f, 848f, 46f), keyboard(136f))
|
||||
else -> shoulders() + listOf(Spec(InputControl.LS, 235f, 400f, 104f), dpad(470f, 675f, 118f)) + face(1375f, 400f, 58f, 94f) + listOf(
|
||||
Spec(InputControl.RS, 1130f, 690f, 104f), Spec(InputControl.L3, 385f, 290f, 42f, ax = 235f, ay = 400f), Spec(InputControl.R3, 1290f, 790f, 42f, ax = 1130f, ay = 690f),
|
||||
Spec(InputControl.SELECT, 690f, 850f, 38f), Spec(InputControl.GUIDE, 800f, 162f, 54f), Spec(InputControl.START, 910f, 850f, 38f),
|
||||
Spec(InputControl.SELECT, 690f, 850f, 38f), Spec(InputControl.GUIDE, 800f, 850f, 46f), Spec(InputControl.START, 910f, 850f, 38f),
|
||||
Spec(InputControl.QAM, 220f, 848f, 46f), keyboard(136f))
|
||||
}
|
||||
|
||||
@@ -151,10 +151,8 @@ object KitLayout {
|
||||
max(x(s.cx), edge + hw).also { edge = it + hw + GAP_DP * density }
|
||||
}
|
||||
return controls.map { s ->
|
||||
val cx = when (s.control) {
|
||||
InputControl.START, InputControl.SELECT -> (w + safe.left - safe.right) / 2f + (s.cx - REF_W / 2f) * unit
|
||||
else -> row[s] ?: (x(s.ax) + (s.cx - s.ax) * unit)
|
||||
}
|
||||
val cx = if (s.cy > REF_H * .88f && s.cx > REF_W / 3f && s.cx < REF_W * 2f / 3f) (w + safe.left - safe.right) / 2f + (s.cx - REF_W / 2f) * unit
|
||||
else row[s] ?: (x(s.ax) + (s.cx - s.ax) * unit)
|
||||
val cy = y(s.ay) + (s.cy - s.ay) * unit; val hw = s.hw * unit; val hh = s.hh * unit
|
||||
InputSurfaceElement(s.control, (cx - hw) / w, (cy - hh) / h, 2 * hw / w, 2 * hh / h, s.id, s.kind, if (s.name == s.control.label) kit.name(s.control) else s.name,
|
||||
floating = s.kind == InputElementKind.STICK, buttonShape = s.shape, icon = s.icon).bounded()
|
||||
|
||||
@@ -153,16 +153,24 @@ class KitLayoutTest {
|
||||
assertTrue(overlapping(placed, w, h).isEmpty())
|
||||
}
|
||||
|
||||
@Test fun startAndSelectAreOnTheFloatingOverlayBottomRow() {
|
||||
@Test fun startSelectAndHomeAreOnTheFloatingOverlayBottomRow() {
|
||||
for (kit in PadKit.entries) for ((w, h) in sizes) {
|
||||
val buttons = KitLayout.elements(context, kit, w, h)
|
||||
val keyboard = buttons.single { it.id == KitLayout.KEYBOARD_ID }
|
||||
for (button in buttons.filter { it.control == InputControl.SELECT || it.control == InputControl.START }) {
|
||||
for (button in buttons.filter { it.control == InputControl.SELECT || it.control == InputControl.START || it.control == InputControl.GUIDE }) {
|
||||
assertTrue("$kit $w x $h ${button.id}", button.y + button.height / 2 in keyboard.y..(keyboard.y + keyboard.height))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun theXboxAndPlayStationHomeButtonSitsBetweenSelectAndStart() {
|
||||
for (kit in PadKit.entries.filterNot { it.steam }) for ((w, h) in sizes.filter { it.first > it.second }) {
|
||||
val buttons = KitLayout.elements(context, kit, w, h).associateBy { it.control }
|
||||
val select = buttons.getValue(InputControl.SELECT); val start = buttons.getValue(InputControl.START); val home = buttons.getValue(InputControl.GUIDE)
|
||||
assertTrue("$kit $w x $h", select.x + select.width < home.x && home.x + home.width < start.x)
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun widerScreensSpreadTheControlsInsteadOfStretchingThem() {
|
||||
for (kit in PadKit.entries) {
|
||||
val narrow = KitLayout.elements(context, kit, 1920, 1080).associateBy { it.id }
|
||||
|
||||
Reference in new issue
Block a user