fix(input): restore Steam and Quick Access shortcuts (#2948)

This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-20 14:42:52 -05:00
1 parent 3c0d25d83b
commit cb8e70b940
17 files changed
+145 -37

No files matched your search

@@ -58,6 +58,15 @@ class ControlsPresenterTest {
assertEquals(Place.MAIN, ControlsPresenter.plan(playing.copy(desktop = true, mode = SessionPrefs.OSC_ALWAYS)).place)
}
@Test fun steamShortcutsOverrideTheSteamLayoutAndFollowTheGameDisplay() {
val state = playing.copy(mode = SessionPrefs.OSC_STEAM_QAM, steamLayout = true, controllerInUse = true)
assertEquals(ControlsPresenter.Plan(Place.MAIN, shortcutsOnly = true), ControlsPresenter.plan(state))
assertEquals(ControlsPresenter.Plan(Place.BOTTOM, shortcutsOnly = true), ControlsPresenter.plan(state.copy(bottomScreen = true)))
assertEquals(ControlsPresenter.Plan(Place.MAIN, Hidden.BY_TAP, shortcutsOnly = true),
ControlsPresenter.plan(state.copy(hiddenByTap = true)))
assertEquals(ControlsPresenter.Plan(Place.NONE), ControlsPresenter.plan(state.copy(covered = true)))
}
@Test fun aCoveringPanelOrNoVirtualPadRemovesTheControls() {
assertEquals(Place.NONE, ControlsPresenter.plan(playing.copy(covered = true)).place)
assertEquals(Place.NONE, ControlsPresenter.plan(playing.copy(virtualPad = false, mode = SessionPrefs.OSC_ALWAYS)).place)
@@ -22,14 +22,17 @@ class OnScreenControlPrefsTest {
for (name in listOf("session", "game-controls", "input-profiles", "input-surfaces", "controller")) context.getSharedPreferences(name, Context.MODE_PRIVATE).edit().clear().commit()
}
@Test fun oldShowModesMapOntoAutoAlwaysAndNever() {
@Test fun oldShowModesKeepTheirMeaning() {
assertEquals(SessionPrefs.OSC_AUTO, SessionPrefs.oscMode(context))
for ((saved, mode) in listOf(SessionPrefs.OSC_AUTO to SessionPrefs.OSC_AUTO, SessionPrefs.OSC_ALWAYS to SessionPrefs.OSC_ALWAYS,
SessionPrefs.OSC_NEVER to SessionPrefs.OSC_NEVER, SessionPrefs.OSC_STEAM_QAM to SessionPrefs.OSC_ALWAYS,
SessionPrefs.OSC_NEVER to SessionPrefs.OSC_NEVER, SessionPrefs.OSC_STEAM_QAM to SessionPrefs.OSC_STEAM_QAM,
SessionPrefs.OSC_STEAM_TOUCH to SessionPrefs.OSC_AUTO, "buttons" to SessionPrefs.OSC_AUTO)) {
session.edit().putString("osc", saved).commit()
assertEquals(saved, mode, SessionPrefs.oscMode(context))
}
session.edit().putString("osc", SessionPrefs.OSC_STEAM_QAM).commit()
assertEquals(SessionPrefs.OSC_STEAM_QAM, SessionPrefs.oscMode(context, steamSession = true))
assertEquals(SessionPrefs.OSC_AUTO, SessionPrefs.oscMode(context, steamSession = false))
session.edit().putString("osc", SessionPrefs.OSC_STEAM_TOUCH).commit()
assertEquals(SessionPrefs.OSC_ALWAYS, SessionPrefs.oscMode(context, steamSession = true))
SessionPrefs.setOscMode(context, SessionPrefs.OSC_AUTO)
@@ -231,7 +231,7 @@ class OnScreenControlsTest {
@Test fun aControllerHideReleasesHeldControlsAndATapBringsThemBack() {
touch(MotionEvent.ACTION_DOWN, 4 to (800f to 250f))
view.setHidden(OnScreenControls.Hidden.BY_CONTROLLER)
view.setPresentation(OnScreenControls.Hidden.BY_CONTROLLER)
measure(view)
assertFalse(state().isDown(PadState.A))
assertFalse(view.takesTouchAt(800f, 250f))
@@ -241,6 +241,18 @@ class OnScreenControlsTest {
assertTrue(view.takesTouchAt(800f, 250f))
}
@Test fun tappingTheCornerKeepsTheShortcutsMode() {
fun shownIds() = view.inputSurface.shownElements.map { it.id }
view.setPresentation(null, shortcuts = true)
measure(view)
val shortcuts = listOf(OnScreenLayout.STEAM_SHORTCUT_ID, OnScreenLayout.QAM_SHORTCUT_ID)
assertEquals(shortcuts, shownIds())
tapCorner()
assertTrue(shownIds().isEmpty())
tapCorner()
assertEquals(shortcuts, shownIds())
}
@Test fun theCornerIsGoneWithoutALayoutAndOnTheDockedStrip() {
val (x, y) = corner
view.updateLayout(null)
@@ -39,6 +39,27 @@ class OnScreenLayoutTest {
}
}
@Test fun steamShortcutsClearPinnedControlsAndStayInsideTheSafeArea() {
val safe = Rect(20, 10, 30, 25)
val pin = InputSurfaceElement(InputControl.A, .05f, .8f, .2f, .15f, "pin")
val shortcuts = OnScreenLayout.steamShortcuts(1000, 600, safe, 2f, listOf(pin))
val (steam, qam) = shortcuts
assertEquals(OnScreenLayout.STEAM_SHORTCUT_ID, steam.id)
assertEquals(OnScreenLayout.QAM_SHORTCUT_ID, qam.id)
assertTrue(steam.y + steam.height < pin.y)
assertEquals(OnScreenLayout.steamShortcuts(1000, 600, safe, 2f).last().y, qam.y)
assertInside(shortcuts, 1000, 600, safe)
val tall = pin.copy(y = .1f, height = .85f)
val beside = OnScreenLayout.steamShortcuts(1000, 600, safe, 2f, listOf(tall))
assertEquals(2, beside.size)
assertTrue(beside.first().x > tall.x + tall.width)
assertInside(beside, 1000, 600, safe)
val cover = pin.copy(x = 0f, y = 0f, width = 1f, height = 1f)
assertTrue(OnScreenLayout.steamShortcuts(1000, 600, safe, 2f, listOf(cover)).isEmpty())
}
@Test fun savingTheEditorFrameKeepsEveryControlWhereTheEditorShowsIt() {
val w = 2608
val h = 1200
@@ -152,7 +152,11 @@ class InputSettingsTest {
for (removed in listOf(R.string.input_default_profiles, R.string.input_profiles, R.string.input_new_profile))
compose.onNodeWithText(context.getString(removed)).assertDoesNotExist()
compose.onNodeWithTag("input-profile-game").assertDoesNotExist()
compose.onNodeWithTag("osc-${SessionPrefs.OSC_NEVER}").performScrollTo().performClick()
compose.onNodeWithTag("setting-osc-show").performScrollTo().performClick()
compose.onNodeWithText(context.getString(R.string.osc_steam_shortcuts_only)).performClick()
compose.runOnIdle { assertEquals(SessionPrefs.OSC_STEAM_QAM, SessionPrefs.oscMode(context)) }
compose.onNodeWithTag("setting-osc-show").performClick()
compose.onNodeWithText(context.getString(R.string.common_never)).performClick()
compose.runOnIdle { assertEquals(SessionPrefs.OSC_NEVER, SessionPrefs.oscMode(context)) }
}
@@ -147,7 +147,7 @@ class InputSurfaceTouchTest {
touch(MotionEvent.ACTION_UP, 1 to (600f to 510f))
assertTrue(events.isEmpty())
show(a, b, stick)
view.setHidden(OnScreenControls.Hidden.BY_TAP)
view.setPresentation(OnScreenControls.Hidden.BY_TAP)
measure(view)
assertFalse(view.takesTouchAt(450f, 510f))
assertFalse(touch(MotionEvent.ACTION_DOWN, 1 to (450f to 510f)))
@@ -155,11 +155,11 @@ class InputSurfaceTouchTest {
}
@Test fun hiddenControlsHideTheKeyboardShortcutUntilShownAgain() {
view.setHidden(OnScreenControls.Hidden.BY_CONTROLLER)
view.setPresentation(OnScreenControls.Hidden.BY_CONTROLLER)
measure(view)
assertFalse(view.takesTouchAt(800f, 240f))
assertFalse(view.takesTouchAt(450f, 510f))
view.setHidden(null)
view.setPresentation(null)
measure(view)
touch(MotionEvent.ACTION_DOWN, 1 to (450f to 510f))
touch(MotionEvent.ACTION_UP, 1 to (450f to 510f))