mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 21:15:43 +00:00
fix(input): look up the Nintendo layout under the key the settings screen writes for direct launches
This commit is contained in:
1 parent
df60ba5c96
commit
9960c07010
3 files changed
+57
-3
No files matched your search
@@ -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<com.droiddeck.launcher.session.SteamImportPrompt.Ask?>(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() {
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user