diff --git a/app/src/main/java/com/droiddeck/launcher/session/NoSteamLaunch.kt b/app/src/main/java/com/droiddeck/launcher/session/NoSteamLaunch.kt index 5541507a10..3147003960 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/NoSteamLaunch.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/NoSteamLaunch.kt @@ -13,6 +13,12 @@ object NoSteamLaunch { class Command(val program: String, val args: List, val name: String) + fun running(mode: String, program: String?): Boolean = + mode == SessionService.MODE_RUN && program in setOf(PROTON_RUN, EPIC, BATTLENET) + + fun windowsGames(mode: String, program: String?): Boolean = + mode == SessionService.MODE_STEAM || mode == SessionService.MODE_DESKTOP || running(mode, program) + fun scope(game: Library.SteamGame): String? = when { game.library == Library.EPIC_LAUNCHER -> EpicClient.shortcutAppId.toString() game.library == Library.BATTLENET_LAUNCHER -> com.droiddeck.launcher.runtime.BattleNet.APP_ID.toString() diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt index b9e7215dc0..bd8291ef6b 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt @@ -598,7 +598,7 @@ class SessionService : Service() { runCatching { SessionEvents.step("components-republish") { ComponentsManager.republish(this) } } .onSuccess { if (it) Log.i(TAG, "component selections published for the installed Proton builds") } .onFailure { Log.w(TAG, "component selections", it) } - if (steamHere) { + if (windowsGames()) { runCatching { SessionEvents.step("components-forced") { ComponentsManager.ensureForcedPackages(this) } } .onSuccess { if (it != null) Log.i(TAG, it) } .onFailure { Log.w(TAG, "forced components", it) } @@ -1074,12 +1074,13 @@ class SessionService : Service() { } Log.i(TAG, "vkbridge: on (${com.droiddeck.launcher.core.DeviceSupport.gpuName(this)}, ${SessionPrefs.vkBridgeMode(this)} mode), socket $socket") } - private fun noSteamGame(): Boolean = - SessionState.mode == MODE_RUN && SessionState.program in setOf(NoSteamLaunch.PROTON_RUN, NoSteamLaunch.EPIC, NoSteamLaunch.BATTLENET) + private fun noSteamGame(): Boolean = NoSteamLaunch.running(SessionState.mode, SessionState.program) + + private fun windowsGames(): Boolean = NoSteamLaunch.windowsGames(SessionState.mode, SessionState.program) private fun startAudio(guest: MutableList, sessionDir: File, directAudioPack: Boolean): PulseAudioComponent { val wantsDirectAudio = directAudioPack && - (SessionState.mode == MODE_STEAM || SessionState.mode == MODE_DESKTOP || noSteamGame()) && + windowsGames() && SessionPrefs.directAudio(this) val wantsMic = SessionPrefs.micEnabled(this) && checkSelfPermission(android.Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED diff --git a/app/src/test/java/com/droiddeck/launcher/session/NoSteamLaunchTest.kt b/app/src/test/java/com/droiddeck/launcher/session/NoSteamLaunchTest.kt index 9800990e9d..de73c3e320 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/NoSteamLaunchTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/NoSteamLaunchTest.kt @@ -101,4 +101,22 @@ class NoSteamLaunchTest { assertNull(NoSteamLaunch.nameFor("/usr/bin/retroarch", emptyList())) assertNull(NoSteamLaunch.nameFor(NoSteamLaunch.PROTON_RUN, listOf("/x/a.exe"))) } + + @Test fun windowsGameSessionsAreSteamTheDesktopAndProtonLaunchesFromTheLibrary() { + assertTrue(NoSteamLaunch.windowsGames(SessionService.MODE_STEAM, null)) + assertTrue(NoSteamLaunch.windowsGames(SessionService.MODE_DESKTOP, null)) + for (program in listOf(NoSteamLaunch.PROTON_RUN, NoSteamLaunch.EPIC, NoSteamLaunch.BATTLENET)) { + assertTrue(program, NoSteamLaunch.running(SessionService.MODE_RUN, program)) + assertTrue(program, NoSteamLaunch.windowsGames(SessionService.MODE_RUN, program)) + } + } + + @Test fun otherProgramsAreNotWindowsGameSessions() { + for (program in listOf("/usr/bin/retroarch", "/usr/local/bin/droiddeck-session", null)) { + assertFalse("$program", NoSteamLaunch.running(SessionService.MODE_RUN, program)) + assertFalse("$program", NoSteamLaunch.windowsGames(SessionService.MODE_RUN, program)) + } + assertFalse(NoSteamLaunch.running(SessionService.MODE_STEAM, NoSteamLaunch.PROTON_RUN)) + assertFalse(NoSteamLaunch.running(SessionService.MODE_DESKTOP, null)) + } }