From c0506d53c93c7c6bd6090062e7a271064cdd735e Mon Sep 17 00:00:00 2001 From: MaxsTechReview Date: Fri, 27 Nov 2026 04:40:57 -0500 Subject: [PATCH] fix(input): edited on-screen layouts keep their places and a 100% size leaves docked controls unchanged (#3322) --- .../com/droiddeck/launcher/input/OnScreenLayout.kt | 7 +++---- .../com/droiddeck/launcher/input/OnScreenLayoutTest.kt | 10 ++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/input/OnScreenLayout.kt b/app/src/main/java/com/droiddeck/launcher/input/OnScreenLayout.kt index 6fd7b40923..e8490f624f 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/OnScreenLayout.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/OnScreenLayout.kt @@ -45,9 +45,8 @@ object OnScreenLayout { if (buttonsOnly && dock == null) return generator.buttonsOnly(stored) + fit(stored.filter { it.alwaysShown }, reference.first, reference.second, width, height, safe) if (dock?.portrait == true && !dock.grips && !matched && layout.aspect > 0f && layout.aspect < 1f && stored.any(::isGamepad)) return scaleDocked(context, cluster(stored.filterNot { it.alwaysShown || isGamepad(it) && (it.id == KEYBOARD_ID || it.control in BAR) }, layout.aspect, width, height, safe), ControllerPrefs.read(context).size / 100f, width, height, safe) - val oppositeOrientation = layout.aspect > 0f && ((layout.aspect < 1f) != (height > width)) - val generated = matched || - dock == null && oppositeOrientation && stored.any(::isGamepad) + val generated = matched || PadKit.forOverlay(context, layout) != null && stored.any(::isGamepad) && + (dock != null || height > width && layout.aspect >= 1f || height <= width && layout.aspect > 0f && layout.aspect < 1f) val gamepad = if (generated) stored.filter(::isGamepad) else emptyList() val others = fit(stored.filterNot { generated && isGamepad(it) || dock != null && it.alwaysShown }, reference.first, reference.second, width, height, safe) val regenerated = when { @@ -96,7 +95,7 @@ object OnScreenLayout { .coerceIn(leftBound, (rightBound - w).coerceAtLeast(leftBound)) val y = (element.y + element.height / 2f - h / 2f) .coerceIn(topBound, (bottomBound - h).coerceAtLeast(topBound)) - element.copy(x = x, y = y, width = w, height = h).bounded() + element.copy(x = x, y = y, width = w, height = h) }.toMutableList() if (scale > 1f) { val gap = 4f / width diff --git a/app/src/test/java/com/droiddeck/launcher/input/OnScreenLayoutTest.kt b/app/src/test/java/com/droiddeck/launcher/input/OnScreenLayoutTest.kt index b0fd6f04bd..3b02f4db38 100644 --- a/app/src/test/java/com/droiddeck/launcher/input/OnScreenLayoutTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/input/OnScreenLayoutTest.kt @@ -336,6 +336,16 @@ class OnScreenLayoutTest { } } + @Test fun dockedControlsStayInsideTheSafeAreaAtTheDefaultSizeWithoutAControllerKit() { + SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_NONE) + ControllerPrefs.setSize(context, 100) + val safe = Rect(40, 0, 60, 24) + for ((w, h) in listOf(1080 to 200, 1200 to 540, 2208 to 800)) { + val placed = OnScreenLayout.elements(context, gamepad(), w, h, safe, dock = OnScreenLayout.Dock(false, false)) + assertInside(placed.filter { it.id.startsWith("legacy:") }, w, h, safe) + } + } + @Test fun anEditedLayoutKeepsItsAspectAndCornersWhenTheScreenRotates() { val corner = InputSurfaceElement(InputControl.A, .85f, .7f, .1f, .2f) val left = InputSurfaceElement(InputControl.LS, .05f, .5f, .2f, .4f)