diff --git a/app/src/main/java/com/droiddeck/launcher/session/GameProfileManager.kt b/app/src/main/java/com/droiddeck/launcher/session/GameProfileManager.kt index e43173eae1..adf4f48f19 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/GameProfileManager.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/GameProfileManager.kt @@ -1,6 +1,7 @@ package com.droiddeck.launcher.session import android.content.Context +import com.droiddeck.launcher.input.InputLibraries import com.droiddeck.launcher.core.GameEnvironment object GameProfileManager { @@ -24,8 +25,12 @@ object GameProfileManager { clear("Windows components") { WinComponents.setPicks(context, scope, emptyList()) } clear("bottom screen") { SessionPrefs.clearGameBottomScreen(context, scope) } clear("controls") { - if (com.droiddeck.launcher.input.InputLibraries.read(context).games.containsKey(scope)) - com.droiddeck.launcher.input.InputLibraries.update(context) { it.resetGame(scope) } + val keys = listOf(scope, "game:$scope") + if (InputLibraries.read(context).games.keys.any { it in keys }) { + InputLibraries.update(context) { library -> + keys.fold(library) { current, key -> current.resetGame(key) } + } + } } clear("guides") { SteamGuides.clear(context, scope) 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 77b2895c30..fcc45fb9fc 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/GameProfileManagerTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/GameProfileManagerTest.kt @@ -2,6 +2,8 @@ package com.droiddeck.launcher.session import android.content.Context import com.droiddeck.launcher.core.GameEnvironment +import com.droiddeck.launcher.input.InputLibraries +import com.droiddeck.launcher.input.InputProfile import com.droiddeck.launcher.runtime.LinuxRuntime import org.json.JSONObject import org.junit.Assert.assertEquals @@ -67,6 +69,18 @@ class GameProfileManagerTest { assertEquals(listOf("dotnet48"), WinComponents.picks(context, other)) } + @Test + fun resetClearsSteamAndDirectRunControlsForTheSameGameOnly() { + InputLibraries.update(context) { library -> + library.withGameProfile("42", "Steam", InputProfile.GAME) + .withGameProfile("game:42", "Direct", InputProfile.DESKTOP) + .withGameProfile("game:43", "Other", InputProfile.GAME) + .withGameProfile("program:/tmp/game.exe", "Ad hoc", InputProfile.GAME) + } + GameProfileManager.reset(context, "42") + assertEquals(setOf("game:43", "program:/tmp/game.exe"), InputLibraries.read(context).games.keys) + } + @Test fun resetRejectsEmptyScopeWithoutChangingSharedSettings() { GameEnvironmentStore.save(