From fa254517662973a46d1ddd142c0891b70eb3a159 Mon Sep 17 00:00:00 2001 From: The412Banner Date: Tue, 22 Sep 2026 08:18:20 -0400 Subject: [PATCH] Game storage: a second Steam library on an SD card or a chosen folder The runtime already knew how to register /mnt/bannerlator-sd with the client; the app never bound anything there, so the client only ever saw internal storage. The Steam cog's Game storage section offers every removable volume (through the app's own folder on it, the one place a card lets a targetSdk-28 app write) and any folder from the File Manager, proven writable first. The session binds the choice and names it (BL_LIBRARY_LABEL); bannerlator-steam-library registers it, or forgets it when nothing is bound. The client does the rest: asks where to install, shows both on Storage, moves games between them. device.txt records the choice. --- README.md | 12 ++++ .../com/steamdeck/launcher/MainActivity.kt | 27 +++++++++ .../steamdeck/launcher/core/DeviceReport.kt | 1 + .../steamdeck/launcher/session/GameStorage.kt | 60 +++++++++++++++++++ .../launcher/session/SessionPrefs.kt | 15 +++++ .../launcher/session/SessionService.kt | 15 +++++ .../launcher/ui/ModeSettingsDialog.kt | 32 ++++++++++ .../usr/local/bin/bannerlator-steam-library | 12 +++- 8 files changed, 171 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/com/steamdeck/launcher/session/GameStorage.kt diff --git a/README.md b/README.md index 761bdd632c..b7ec226fff 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ ledger rather than a feature list — where something has not been run on hardwa | The drawer's "Steam menu" (Guide) | ⚠️ built; not yet tried | | Emulators launched under gamescope (▶ in Desktop & apps) | ⚠️ built; not yet seen with a game | | The device's volume keys during a session | ⚠️ fixed (they were swallowed); not yet re-tried | +| Game storage: a second Steam library on a card or a folder | ⚠️ built; not yet seen installing to it | | Stopping a competing Steam client | ⚠️ it is asked to stop and says so, but one that restarts itself from boot wins the race — uninstall it | | DirectAudio for games, and the microphone | ⚠️ wired and the modules load; voice not yet confirmed in Steam's tester | | Client and game core masks | ⚠️ applied and logged; no measured difference yet | @@ -171,6 +172,17 @@ themselves through Vulkan and Turnip — it is the desktop's own compositing tha Programs whose child processes sandbox themselves with seccomp and namespaces cannot set those up under proot; Firefox's are turned off in the session's environment, without which its tabs crash. +### Game storage: internal, an SD card, or a folder + +The client's own library is internal storage and always there. **Game storage** in the Steam cog +registers one more: an SD card (through the app's own folder on it, the one place a card lets +this app write) or any folder chosen in the File Manager. The session binds it at +`/mnt/bannerlator-sd` and `bannerlator-steam-library` registers it with the client under the name +the app gives it; the client then asks where to install every game, lists both on its Storage +page and moves games between them itself. Set to internal only, the entry is removed again. A +card and shared storage are FUSE-backed and stream slowly - keep games that stream video or big +assets internal. ⚠️ Built; not yet seen installing to a card. + ### Running an emulator with the GPU The desktop composites in software (labwc on pixman) and so offers its programs no dma-buf: a diff --git a/app/src/main/java/com/steamdeck/launcher/MainActivity.kt b/app/src/main/java/com/steamdeck/launcher/MainActivity.kt index 262eeefdbb..59a2bb5345 100644 --- a/app/src/main/java/com/steamdeck/launcher/MainActivity.kt +++ b/app/src/main/java/com/steamdeck/launcher/MainActivity.kt @@ -50,6 +50,7 @@ import com.steamdeck.launcher.ui.RomsDialog import com.steamdeck.launcher.files.InAppFilePicker import com.steamdeck.launcher.session.SessionArtifacts import com.steamdeck.launcher.session.SessionState +import com.steamdeck.launcher.session.GameStorage /** * The whole app outside a session: is the runtime installed, is there a newer one, frame @@ -121,6 +122,11 @@ class MainActivity : ComponentActivity() { private var touchMode by mutableStateOf(SessionPrefs.TOUCH_AUTO) private var oscMode by mutableStateOf(SessionPrefs.OSC_AUTO) private var renderer by mutableStateOf("pixman") + private var gameStorage by mutableStateOf("") + private var storageOptions by mutableStateOf>>(emptyList()) + private val pickGameStorage = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { r -> + if (r.resultCode == RESULT_OK) InAppFilePicker.pickedPath(r.data)?.let { path -> setGameStorage(path, GameStorage.labelFor(this, path)) } + } private var emulators by mutableStateOf>>(emptyList()) private var showEmulatorHelp by mutableStateOf(false) private var romsDir by mutableStateOf(null) @@ -204,6 +210,8 @@ class MainActivity : ComponentActivity() { directAudio = if (mode == SessionService.MODE_STEAM) directAudio else null, mic = if (mode == SessionService.MODE_STEAM) mic else null, renderer = if (mode == SessionService.MODE_DESKTOP) renderer else null, + gameStorage = if (mode == SessionService.MODE_STEAM) gameStorage else null, + storageOptions = storageOptions, ), ModeSettingsActions( onResolution = { cap -> SessionPrefs.setResolutionCap(this, mode, cap); resolutionCap = cap }, @@ -228,6 +236,10 @@ class MainActivity : ComponentActivity() { } }, onRenderer = { r -> SessionPrefs.setDesktopRenderer(this, r); renderer = r }, + onGameStorage = { path, label -> setGameStorage(path, label) }, + onPickGameStorageFolder = { + pickGameStorage.launch(InAppFilePicker.buildDirIntent(this, "Choose the game storage folder", gameStorage.ifEmpty { null })) + }, onDismiss = { settingsMode = null }, ), ) @@ -367,9 +379,24 @@ class MainActivity : ComponentActivity() { directAudio = SessionPrefs.directAudio(this) mic = SessionPrefs.micEnabled(this) renderer = SessionPrefs.desktopRenderer(this) + gameStorage = SessionPrefs.gameStorage(this) + storageOptions = GameStorage.options(this).map { it.label to it.path } settingsMode = mode } + /** A second Steam library, proven writable first; "" = internal only. */ + private fun setGameStorage(path: String, label: String) { + if (path.isNotEmpty()) { + val problem = GameStorage.prepare(path) + if (problem != null) { + android.widget.Toast.makeText(this, "Not usable: $problem", android.widget.Toast.LENGTH_LONG).show() + return + } + } + SessionPrefs.setGameStorage(this, path, label) + gameStorage = path + } + private fun refreshDrivers() { val lm = LinuxVulkanDriverManager(this) linuxRows = LinuxVulkanDriver.optionValues(this).map { id -> diff --git a/app/src/main/java/com/steamdeck/launcher/core/DeviceReport.kt b/app/src/main/java/com/steamdeck/launcher/core/DeviceReport.kt index 2fbae38590..fd757ac61f 100644 --- a/app/src/main/java/com/steamdeck/launcher/core/DeviceReport.kt +++ b/app/src/main/java/com/steamdeck/launcher/core/DeviceReport.kt @@ -147,6 +147,7 @@ object DeviceReport { k("On-screen controls", SessionPrefs.oscMode(context)) k("Touch mode", SessionPrefs.touchMode(context)) k("Performance HUD", SessionPrefs.hudEnabled(context)) + k("Game storage", SessionPrefs.gameStorage(context).ifEmpty { "internal only" }) h("Android process limits") // Android 12 kills "phantom" processes - the children an app forks itself rather than diff --git a/app/src/main/java/com/steamdeck/launcher/session/GameStorage.kt b/app/src/main/java/com/steamdeck/launcher/session/GameStorage.kt new file mode 100644 index 0000000000..488ef20ff5 --- /dev/null +++ b/app/src/main/java/com/steamdeck/launcher/session/GameStorage.kt @@ -0,0 +1,60 @@ +package com.steamdeck.launcher.session + +import android.content.Context +import android.os.Environment +import android.os.StatFs +import android.os.storage.StorageManager +import com.steamdeck.launcher.core.FileUtils +import java.io.File + +/** + * Where a second Steam library can live on this device. + * + * An SD card is offered through the app's own folder on it ({@code Android/data//files/steam}): + * the one place on a card a targetSdk-28 app may write without a permission prompt, and a real + * filesystem path the session can bind. Any other folder comes from the File Manager's pick mode + * and is checked for writing before it is accepted. Both are FUSE-backed on Android and stream + * slowly (intro movies, big asset loads); internal stays the default and the dialog says so. + */ +object GameStorage { + class Option(val label: String, val path: String) + + /** Every removable volume, as its app folder, with the free space it has. */ + fun options(context: Context): List