mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
feat: Epic Games Launcher for Linux (#928)
* feat: Epic Games Launcher for Linux Install Epic's official Linux launcher (EGLv2) from Epic's CDN with Valve's Steam Runtime 4 and run it under FEX, signed in with the linked Epic account. Epic games launch through a hidden launcher instance so they get the launcher's own arguments, with the exchange-code launch as the fallback, and DroidDeck installs show up in the launcher as installed. In the launcher, touch scrolls like a phone app and the gamepad drives the UI: D-pad and left stick move the selection, A opens, B goes back, the right stick and triggers scroll proportionally, X opens the options menu, Y the keyboard and LB/RB switch tabs. * feat: Epic Games Launcher for Linux Install Epic's official Linux launcher (EGLv2) from Epic's CDN with Valve's Steam Runtime 4 and run it under FEX, signed in with the linked Epic account. Epic games launch through a hidden launcher instance so they get the launcher's own arguments, with the exchange-code launch as the fallback, and DroidDeck installs show up in the launcher as installed. In the launcher, touch scrolls like a phone app and the gamepad drives the UI: D-pad and left stick move the selection, A opens, B goes back, the right stick and triggers scroll proportionally, X opens the options menu, Y the keyboard and LB/RB switch tabs. * Route Epic games through Steam, import launcher installs, offer the second library - Every Epic launch goes Steam -> Epic Games Launcher -> game; Play inside the open launcher hands the game to Steam - Games installed from inside the launcher get a Games-tab entry and launch through Steam; the launcher installs to the last Stores target - Stores install picker offers the Steam second library, with side-by-side choices - uruntime xattr-only failures no longer fail the launcher unpack (app-extract) * Hand launcher Play and Steam links to Steam, wait for FEX on first run Play on a game the launcher just installed is matched to its install record and handed to Steam. Steam games listed in the launcher open steam://rungameid links, which now start the game in a Steam session. Opening the launcher before Steam has downloaded FEX asks Steam for it and starts Steam instead of failing with no-fex. * Address review: FEX check, play-in-Steam action, touch route thread, scroll scale fexReady needs a FEX binary in Steam's FEX tool, not just its folder. The play-in-Steam action stays until the link is handled, so Run Steam at startup can't start a session first. The pad touch route reads the mouse mode without side effects off the main thread and posts the pad update there. Vertical scroll uses the output height. A status-2 unpack counts only when AppRun is there. The xdg-open command is tested end to end for Steam links. * Open the launcher through Steam, recover dropped shortcuts, sign out of both The Epic Games Launcher now runs as its own Steam shortcut, so opening it starts Steam, which opens the launcher, and Play inside it goes to the running Steam. Steam dropped a running shortcut from its library when the game exited after a sleep/wake replay or a server re-logon, and launching it then waited forever at ShowInterstitials. login1 only replays sleep/wake when Steam is asleep. The session restarts Steam when a requested shortcut is missing, and when a game exits with its shortcut gone and nothing else runs. Resuming after a long pause no longer reports failure while traced processes are still waking, so "Steam is paused" goes away on the first tap. Signing out of the launcher signs DroidDeck's Epic store out, and signing out in DroidDeck restarts the launcher signed out and clears the Epic web cookies. * Address review: one session-switch poll, Epic setup can't block a session A new switch confirmation replaces the pending poll instead of adding a second one that could start the session again. Epic library sync and install-folder setup at session start are each guarded, so a bad preference no longer stops the guest from launching. * Uninstall the Epic Games Launcher from the Games tab An Uninstall button next to Launch asks first, closes a running session, and removes the launcher and its runtime. The launcher's sign-in and install records stay, so its games keep their Games-tab entries and a reinstall comes back signed in. Its Steam shortcut goes away on the next Steam start. * Address review: uninstall only after the session has ended The launcher's files are removed only once the session is not running and its phase has ended; a shutdown still in progress after the wait reports failure instead. The confirmation reads the session state from the front-end state. * Find FEX that Steam installed on the second library Steam's tools on a second library live in DroidDeck's private copy, which the session binds over the library. The launcher's FEX check only looked on the shared storage, so with FEX there it always asked Steam for FEX and only Steam opened. It now checks the private copy too. * Start games without Steam, per-game Settings menu with Wine sync "Start without Steam" now really leaves the Steam client out: the game runs in its own Proton/FEX through droiddeck-proton-run in a run session, and the Epic Games Launcher opens on its own with its games playing in it. Run sessions for these games are not pinned to the big cores and get DirectAudio and the added-games list like Steam. The Games tab card is now "Settings", titled "<game> Settings": Start without Steam, FEX preset, Wine sync (ntsync, fsync, esync, wineserver or the app default) and Default, which puts everything changed for the game back to the app's settings. The app-wide Wine sync choice is shown in the Steam settings Session tab. * Address review: uninstall guard, routed games, shortcut matching Opening or reinstalling the Epic Games Launcher waits while it is being uninstalled. Added games that are Steam installs keep their Start without Steam setting under their Steam app id and start as that Steam game. Live shortcut lookups wait for Steam's library to load and match a same-name shortcut by its executable, so no duplicate is added. The session treats the open launcher as itself even when it could not tell its Steam app id. * Address review: drop a queued launcher switch when it is uninstalled A confirmed switch to the Epic Games Launcher that is still waiting for the old session to end is cancelled when the launcher is uninstalled, and never starts while the uninstall runs. The launcher id test sets its environment for its own runs only.
This commit is contained in:
1 parent
83eda433c8
commit
97f976ef6c
107 files changed
+8860
-371
No files matched your search
@@ -109,6 +109,10 @@ class MainActivity : ComponentActivity() {
|
||||
private var frameGenLabel by mutableStateOf("")
|
||||
private var lossless by mutableStateOf(Lossless.State.NONE)
|
||||
private var showRemove by mutableStateOf(false)
|
||||
private var pendingSwitch by mutableStateOf<Intent?>(null)
|
||||
private var switchingTo: Intent? = null
|
||||
private var switchPoll: Runnable? = null
|
||||
private var switchDeadline = 0L
|
||||
private var showResetSettings by mutableStateOf(false)
|
||||
private var lowSpace by mutableStateOf<Long?>(null)
|
||||
private var showNonAdreno by mutableStateOf<LinuxRuntimeInstaller.Release?>(null)
|
||||
@@ -506,6 +510,7 @@ class MainActivity : ComponentActivity() {
|
||||
android.widget.Toast.makeText(this, R.string.main_wait_install_game, android.widget.Toast.LENGTH_SHORT).show()
|
||||
return false
|
||||
}
|
||||
if (com.droiddeck.launcher.session.NoSteamLaunch.enabled(this, game)) return launchWithoutSteam(game, returnHome)
|
||||
if (SessionState.running) {
|
||||
if (SessionState.mode != SessionService.MODE_STEAM || SessionState.stopRequested) {
|
||||
android.widget.Toast.makeText(this, R.string.game_link_session_busy, android.widget.Toast.LENGTH_LONG).show()
|
||||
@@ -534,6 +539,159 @@ class MainActivity : ComponentActivity() {
|
||||
}, steamSession = true)
|
||||
}
|
||||
|
||||
private fun launchWithoutSteam(game: Library.SteamGame, returnHome: Boolean): Boolean {
|
||||
val app = applicationContext
|
||||
Thread({
|
||||
val added = if (game.library == Library.ADDED) runCatching { com.droiddeck.launcher.session.NoSteamLaunch.addedGame(app, game) }.getOrNull() else null
|
||||
val command = com.droiddeck.launcher.session.NoSteamLaunch.command(game, added)
|
||||
ui.post {
|
||||
if (isDestroyed) return@post
|
||||
if (command == null) {
|
||||
android.widget.Toast.makeText(this, R.string.game_link_failed, android.widget.Toast.LENGTH_LONG).show()
|
||||
return@post
|
||||
}
|
||||
com.droiddeck.launcher.session.NoSteamLaunch.remember(command)
|
||||
val next = Intent(this, SessionActivity::class.java)
|
||||
.putExtra(SessionActivity.EXTRA_RETURN_HOME, returnHome)
|
||||
.putExtra(SessionService.EXTRA_MODE, SessionService.MODE_RUN)
|
||||
.putExtra(SessionService.EXTRA_PROGRAM, command.program)
|
||||
.putExtra(SessionService.EXTRA_PROGRAM_ARGS, command.args.toTypedArray())
|
||||
when {
|
||||
!SessionState.running -> startSessionOrWait(next)
|
||||
SessionState.stopRequested -> android.widget.Toast.makeText(this, R.string.game_link_session_busy, android.widget.Toast.LENGTH_LONG).show()
|
||||
SessionState.mode == SessionService.MODE_RUN && SessionState.program == command.program && SessionState.programArgs == command.args ->
|
||||
startActivity(Intent(this, SessionActivity::class.java).setAction(SessionService.ACTION_RESUME)
|
||||
.putExtra(SessionActivity.EXTRA_RETURN_HOME, returnHome)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP))
|
||||
else -> pendingSwitch = next
|
||||
}
|
||||
}
|
||||
}, "no-steam-launch").start()
|
||||
return true
|
||||
}
|
||||
|
||||
private fun opensEpicLauncher(next: Intent): Boolean =
|
||||
next.getStringExtra(SessionService.EXTRA_PROGRAM) == com.droiddeck.launcher.session.NoSteamLaunch.EPIC ||
|
||||
next.getStringExtra(SessionService.EXTRA_STEAM_URL) == com.droiddeck.launcher.frontend.GameLaunchLink.steamUrl(
|
||||
com.droiddeck.launcher.stores.epic.EpicClient.gameId(com.droiddeck.launcher.stores.epic.EpicClient.shortcutAppId))
|
||||
|
||||
private fun uninstallEpicLauncher() {
|
||||
if (com.droiddeck.launcher.stores.epic.EpicClient.uninstalling) return
|
||||
com.droiddeck.launcher.stores.epic.EpicClient.uninstalling = true
|
||||
pendingSwitch?.takeIf(::opensEpicLauncher)?.let { pendingSwitch = null }
|
||||
switchingTo?.takeIf(::opensEpicLauncher)?.let {
|
||||
switchPoll?.let { poll -> ui.removeCallbacks(poll) }
|
||||
switchPoll = null
|
||||
switchingTo = null
|
||||
}
|
||||
if (SessionState.running) SessionService.stop(this)
|
||||
val app = applicationContext
|
||||
val deadline = android.os.SystemClock.uptimeMillis() + SESSION_SWITCH_WAIT_MS
|
||||
Thread({
|
||||
while ((SessionState.running || SessionState.phase !in SESSION_ENDED) && android.os.SystemClock.uptimeMillis() < deadline) {
|
||||
Thread.sleep(SESSION_SWITCH_POLL_MS)
|
||||
}
|
||||
val ended = !SessionState.running && SessionState.phase in SESSION_ENDED
|
||||
val done = try {
|
||||
ended && com.droiddeck.launcher.stores.epic.EpicClient.uninstall(app)
|
||||
} finally {
|
||||
com.droiddeck.launcher.stores.epic.EpicClient.uninstalling = false
|
||||
}
|
||||
ui.post {
|
||||
if (!isDestroyed) refresh()
|
||||
android.widget.Toast.makeText(app, if (done) R.string.epic_client_uninstalled else R.string.epic_client_uninstall_failed,
|
||||
android.widget.Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}, "epic-uninstall").start()
|
||||
}
|
||||
|
||||
private fun openEpicLauncher(): Boolean {
|
||||
if (com.droiddeck.launcher.stores.epic.EpicClient.uninstalling) {
|
||||
android.widget.Toast.makeText(this, R.string.epic_client_uninstalling, android.widget.Toast.LENGTH_SHORT).show()
|
||||
return false
|
||||
}
|
||||
if (protons.protonBusyId != null || ProtonExtras.installInProgress || pkgStage != null) {
|
||||
android.widget.Toast.makeText(this, R.string.main_wait_install_game, android.widget.Toast.LENGTH_SHORT).show()
|
||||
return false
|
||||
}
|
||||
if (!com.droiddeck.launcher.stores.epic.EpicClient.launcherRunning(this) && !com.droiddeck.launcher.stores.epic.EpicClient.fexReady(this)) {
|
||||
com.droiddeck.launcher.stores.epic.EpicClient.requestFex(this)
|
||||
android.widget.Toast.makeText(this, R.string.epic_client_needs_fex, android.widget.Toast.LENGTH_LONG).show()
|
||||
if (!SessionState.running) startSteamSession()
|
||||
else if (SessionState.mode == SessionService.MODE_STEAM) startActivity(Intent(this, SessionActivity::class.java)
|
||||
.setAction(SessionService.ACTION_RESUME).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP))
|
||||
return true
|
||||
}
|
||||
if (com.droiddeck.launcher.session.NoSteamLaunch.enabled(this, com.droiddeck.launcher.stores.epic.EpicClient.shortcutAppId)) {
|
||||
com.droiddeck.launcher.stores.epic.EpicClient.launcherEntry(this, Library.EPIC_LAUNCHER_NAME)?.let { return launchWithoutSteam(it, false) }
|
||||
}
|
||||
val launcher = Intent(this, SessionActivity::class.java)
|
||||
.putExtra(SessionActivity.EXTRA_RETURN_HOME, false)
|
||||
.putExtra(SessionService.EXTRA_STEAM_URL, com.droiddeck.launcher.frontend.GameLaunchLink.steamUrl(
|
||||
com.droiddeck.launcher.stores.epic.EpicClient.gameId(com.droiddeck.launcher.stores.epic.EpicClient.shortcutAppId)))
|
||||
if (SessionState.running && SessionState.mode == SessionService.MODE_STEAM && !SessionState.stopRequested) {
|
||||
val app = applicationContext
|
||||
val shortcut = com.droiddeck.launcher.stores.epic.EpicClient.shortcutAppId
|
||||
val listed = com.droiddeck.launcher.frontend.AddedGames.inSteam(app, shortcut)
|
||||
if (listed && !SessionService.launchGame(this, com.droiddeck.launcher.stores.epic.EpicClient.gameId(shortcut))) {
|
||||
android.widget.Toast.makeText(this, R.string.game_link_failed, android.widget.Toast.LENGTH_LONG).show()
|
||||
return false
|
||||
}
|
||||
startActivity(Intent(this, SessionActivity::class.java).setAction(SessionService.ACTION_RESUME)
|
||||
.putExtra(SessionActivity.EXTRA_RETURN_HOME, false)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP))
|
||||
if (!listed) Thread({
|
||||
com.droiddeck.launcher.frontend.AddedGamesPublisher.republish(app)
|
||||
val id = com.droiddeck.launcher.stores.epic.EpicClient.steamLauncherId(app) ?: shortcut
|
||||
ui.post { SessionService.launchGame(app, com.droiddeck.launcher.stores.epic.EpicClient.gameId(id)) }
|
||||
}, "epic-launcher-open").start()
|
||||
return true
|
||||
}
|
||||
if (SessionState.running) {
|
||||
if (SessionState.stopRequested) android.widget.Toast.makeText(this, R.string.game_link_session_busy, android.widget.Toast.LENGTH_LONG).show()
|
||||
else pendingSwitch = launcher
|
||||
return true
|
||||
}
|
||||
return startSessionOrWait(launcher)
|
||||
}
|
||||
|
||||
private fun startSessionOrWait(next: Intent): Boolean {
|
||||
val started = startSession(next, steamSession = next.hasExtra(SessionService.EXTRA_STEAM_URL))
|
||||
if (!started && (busy || LinuxRuntimeInstaller.isBusy())) android.widget.Toast.makeText(this, R.string.main_wait_install_game, android.widget.Toast.LENGTH_SHORT).show()
|
||||
return started
|
||||
}
|
||||
|
||||
private fun startAfterSession(next: Intent) {
|
||||
SessionService.stop(this)
|
||||
awaitSessionEnd(next, android.os.SystemClock.uptimeMillis() + SESSION_SWITCH_WAIT_MS)
|
||||
}
|
||||
|
||||
private fun awaitSessionEnd(next: Intent, deadline: Long) {
|
||||
switchingTo = next
|
||||
switchDeadline = deadline
|
||||
switchPoll?.let { ui.removeCallbacks(it) }
|
||||
val poll = object : Runnable {
|
||||
override fun run() {
|
||||
if (isDestroyed) return
|
||||
if (SessionState.running || SessionState.phase !in SESSION_ENDED) {
|
||||
if (android.os.SystemClock.uptimeMillis() < deadline) ui.postDelayed(this, SESSION_SWITCH_POLL_MS)
|
||||
else {
|
||||
switchPoll = null
|
||||
switchingTo = null
|
||||
android.widget.Toast.makeText(this@MainActivity, R.string.game_link_session_busy, android.widget.Toast.LENGTH_LONG).show()
|
||||
}
|
||||
return
|
||||
}
|
||||
switchPoll = null
|
||||
switchingTo = null
|
||||
if (com.droiddeck.launcher.stores.epic.EpicClient.uninstalling && opensEpicLauncher(next)) return
|
||||
startSessionOrWait(next)
|
||||
}
|
||||
}
|
||||
switchPoll = poll
|
||||
ui.postDelayed(poll, SESSION_SWITCH_POLL_MS)
|
||||
}
|
||||
|
||||
private fun handleGameLink(games: List<Library.SteamGame>) {
|
||||
if (!lifecycle.currentState.isAtLeast(androidx.lifecycle.Lifecycle.State.RESUMED)) return
|
||||
val id = pendingGameLink ?: return
|
||||
@@ -666,6 +824,8 @@ class MainActivity : ComponentActivity() {
|
||||
com.droiddeck.launcher.stores.StoreLaunch.prepare(this, g) { launchGame(g) }
|
||||
}
|
||||
},
|
||||
onEpicLauncher = { openEpicLauncher() },
|
||||
onUninstallEpicLauncher = { uninstallEpicLauncher() },
|
||||
onGameShortcut = { g -> com.droiddeck.launcher.frontend.GameShortcuts.pin(this, g) },
|
||||
onExportGameFile = { g -> pickGameExport(g) },
|
||||
onSyncGameFiles = { pickGameExport(null) },
|
||||
@@ -927,6 +1087,15 @@ class MainActivity : ComponentActivity() {
|
||||
onDismiss = { showNonAdreno = null },
|
||||
)
|
||||
}
|
||||
pendingSwitch?.let { next ->
|
||||
ConfirmDialog(
|
||||
title = androidx.compose.ui.res.stringResource(R.string.drawer_stop_title),
|
||||
text = runningLabel ?: "",
|
||||
confirm = androidx.compose.ui.res.stringResource(R.string.drawer_stop),
|
||||
onConfirm = { pendingSwitch = null; startAfterSession(next) },
|
||||
onDismiss = { pendingSwitch = null },
|
||||
)
|
||||
}
|
||||
if (showRemove) ConfirmDialog(
|
||||
title = androidx.compose.ui.res.stringResource(R.string.main_remove_runtime_title),
|
||||
text = androidx.compose.ui.res.stringResource(R.string.main_remove_runtime_text),
|
||||
@@ -965,6 +1134,10 @@ class MainActivity : ComponentActivity() {
|
||||
}
|
||||
|
||||
if (savedInstanceState == null) ui.post { startSteamAtStartupIfEnabled() }
|
||||
else {
|
||||
pendingSwitch = savedIntent(savedInstanceState, KEY_PENDING_SWITCH)
|
||||
savedIntent(savedInstanceState, KEY_SWITCHING_TO)?.let { awaitSessionEnd(it, savedInstanceState.getLong(KEY_SWITCH_DEADLINE)) }
|
||||
}
|
||||
|
||||
val wanted = ArrayList<String>()
|
||||
if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
@@ -1111,6 +1284,19 @@ class MainActivity : ComponentActivity() {
|
||||
refreshSecondScreenDisplays()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
pendingSwitch?.let { outState.putParcelable(KEY_PENDING_SWITCH, it) }
|
||||
switchingTo?.let {
|
||||
outState.putParcelable(KEY_SWITCHING_TO, it)
|
||||
outState.putLong(KEY_SWITCH_DEADLINE, switchDeadline)
|
||||
}
|
||||
}
|
||||
|
||||
private fun savedIntent(state: Bundle, key: String): Intent? =
|
||||
if (Build.VERSION.SDK_INT >= 33) state.getParcelable(key, Intent::class.java)
|
||||
else @Suppress("DEPRECATION") state.getParcelable(key)
|
||||
|
||||
override fun onDestroy() {
|
||||
updates.unregister()
|
||||
super.onDestroy()
|
||||
@@ -1877,6 +2063,12 @@ class MainActivity : ComponentActivity() {
|
||||
companion object {
|
||||
private const val TAG = "MainActivity"
|
||||
private const val MEDIA_SETTLE_MS = 1500L
|
||||
private const val SESSION_SWITCH_WAIT_MS = 30_000L
|
||||
private const val SESSION_SWITCH_POLL_MS = 250L
|
||||
private const val KEY_PENDING_SWITCH = "pending_switch"
|
||||
private const val KEY_SWITCHING_TO = "switching_to"
|
||||
private const val KEY_SWITCH_DEADLINE = "switch_deadline"
|
||||
private val SESSION_ENDED = setOf(SessionPhase.IDLE, SessionPhase.FAILED)
|
||||
private val ZIP_EXT = listOf("zip")
|
||||
private val WCP_EXT = listOf("wcp")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user