From 9960c070107f4a3b864248254df15f8d7014be08 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Mon, 16 Nov 2026 02:49:15 +0000 Subject: [PATCH] fix(input): look up the Nintendo layout under the key the settings screen writes for direct launches --- .../com/droiddeck/launcher/SessionActivity.kt | 15 +++++-- .../launcher/input/NintendoLayoutTest.kt | 41 +++++++++++++++++++ .../session/GameProfileManagerTest.kt | 4 ++ 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index c8fb47a30e..f376abdb9a 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -295,6 +295,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private lateinit var touchscreenGestures: TouchscreenGestures private var gestureConfig = com.droiddeck.launcher.input.TouchGestureConfig() private var gestureGame: String? = null + private var nintendoScope: String? = null private var gameStarts by mutableIntStateOf(0) private var gestureSettingsOpen by mutableStateOf(false) private var steamImportAsk by mutableStateOf(null) @@ -1195,9 +1196,17 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } frameGenActiveGameName = target.second?.name } - if (nextGame != gestureGame) { - if (nextGame != null) gameStarts++ + val nextNintendoScope = if (SessionState.mode == SessionService.MODE_RUN) { + kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) { + com.droiddeck.launcher.session.NoSteamLaunch.scopeOf(SessionState.program, SessionState.programArgs) { + com.droiddeck.launcher.session.NoSteamLaunch.battleNetTitleScope(this@SessionActivity, it) + } + } + } else nextGame + if (nextGame != gestureGame || nextNintendoScope != nintendoScope) { + if (nextGame != null && nextGame != gestureGame) gameStarts++ gestureGame = nextGame + nintendoScope = nextNintendoScope refreshGestureConfig() applyNintendoLayout() } @@ -3689,7 +3698,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } private fun applyNintendoLayout() { - padBridge?.setNintendoLayout(ControllerPrefs.nintendoLayout(this, gestureGame)) + padBridge?.setNintendoLayout(ControllerPrefs.nintendoLayout(this, nintendoScope)) } private fun refreshGestureConfig() { diff --git a/app/src/test/java/com/droiddeck/launcher/input/NintendoLayoutTest.kt b/app/src/test/java/com/droiddeck/launcher/input/NintendoLayoutTest.kt index f637e80536..6f621b948f 100644 --- a/app/src/test/java/com/droiddeck/launcher/input/NintendoLayoutTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/input/NintendoLayoutTest.kt @@ -2,6 +2,9 @@ package com.droiddeck.launcher.input import android.content.Context import android.view.KeyEvent +import com.droiddeck.launcher.frontend.Library +import com.droiddeck.launcher.session.NoSteamLaunch +import com.droiddeck.launcher.stores.epic.EpicClient import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue @@ -68,4 +71,42 @@ class NintendoLayoutTest { assertFalse(ControllerPrefs.nintendoLayout(context, "42")) assertFalse(ControllerPrefs.prefs(context).contains("nintendo.42")) } + + @Test fun aDirectLaunchLooksUpTheKeyTheSettingsScreenWrites() { + val epic = Library.SteamGame(EpicClient.LAUNCHER_APP_ID, Library.EPIC_LAUNCHER_NAME, null, Library.EPIC_LAUNCHER, source = "epic") + val added = Library.SteamGame((2733369024L).toInt(), "Added", null, Library.ADDED, source = "epic") + val proton = Library.SteamGame(413150, "Proton", null, "internal") + val launches = listOf( + epic to NoSteamLaunch.scopeOf(NoSteamLaunch.EPIC, listOf("run")), + added to NoSteamLaunch.scopeOf(NoSteamLaunch.PROTON_RUN, listOf("--app", "2733369024")), + proton to NoSteamLaunch.scopeOf(NoSteamLaunch.PROTON_RUN, listOf("--app", "413150")), + ) + for ((game, lookup) in launches) { + val written = NoSteamLaunch.scope(game)!! + assertEquals(written, lookup) + ControllerPrefs.setNintendoLayout(context, written, true) + assertTrue(ControllerPrefs.nintendoLayout(context, lookup)) + ControllerPrefs.setNintendoLayout(context, written, false) + } + ControllerPrefs.setNintendoLayout(context, NoSteamLaunch.scope(proton)!!, true) + assertFalse(ControllerPrefs.nintendoLayout(context, NoSteamLaunch.scope(added))) + assertFalse(ControllerPrefs.nintendoLayout(context, NoSteamLaunch.scope(epic))) + assertFalse(ControllerPrefs.nintendoLayout(context, "program:${NoSteamLaunch.PROTON_RUN}")) + } + + @Test fun otherControllerPreferencesSurviveEnablingAndResettingTheLayout() { + ControllerPrefs.setDeadZone(context, 25) + ControllerPrefs.setJoyConVr(context, false) + val before = ControllerPrefs.prefs(context).all.toMap() + ControllerPrefs.setNintendoLayout(context, "42", true) + ControllerPrefs.setNintendoLayout(context, "43", true) + assertEquals(25, ControllerPrefs.read(context).deadZone) + assertFalse(ControllerPrefs.joyConVr(context)) + ControllerPrefs.setNintendoLayout(context, "42", false) + assertEquals(25, ControllerPrefs.read(context).deadZone) + assertFalse(ControllerPrefs.joyConVr(context)) + assertTrue(ControllerPrefs.nintendoLayout(context, "43")) + ControllerPrefs.setNintendoLayout(context, "43", false) + assertEquals(before, ControllerPrefs.prefs(context).all.toMap()) + } } diff --git a/app/src/test/java/com/droiddeck/launcher/session/GameProfileManagerTest.kt b/app/src/test/java/com/droiddeck/launcher/session/GameProfileManagerTest.kt index 936a9485d2..93242fc049 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/GameProfileManagerTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/GameProfileManagerTest.kt @@ -54,6 +54,8 @@ class GameProfileManagerTest { SessionPrefs.setGameTextureAnisotropy(context, other, 8) WinComponents.setPicks(context, game, listOf("vcrun2022")) WinComponents.setPicks(context, other, listOf("dotnet48")) + ControllerPrefs.setDeadZone(context, 25) + ControllerPrefs.setJoyConVr(context, false) ControllerPrefs.setNintendoLayout(context, game, true) ControllerPrefs.setNintendoLayout(context, other, true) @@ -72,6 +74,8 @@ class GameProfileManagerTest { assertEquals(listOf("dotnet48"), WinComponents.picks(context, other)) assertFalse(ControllerPrefs.nintendoLayout(context, game)) assertTrue(ControllerPrefs.nintendoLayout(context, other)) + assertEquals(25, ControllerPrefs.deadZone(context)) + assertFalse(ControllerPrefs.joyConVr(context)) } @Test