mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 04:55:44 +00:00
Reset direct-run and Steam controller overrides together
This commit is contained in:
1 parent
8290837584
commit
ea0f796bcd
2 files changed
+21
-2
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in new issue
Block a user