From e4e93c5f4a9ae60805420e794a5530740a9f26ce Mon Sep 17 00:00:00 2001 From: The412Banner Date: Thu, 24 Sep 2026 04:55:01 -0400 Subject: [PATCH] Front end: Back steps out of a game or emulator page; PS2 and other games found deeper in their folder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Back / B on an emulator page went back to Android (the app closed); it now returns to Desktop, a game page to its emulator, a Steam game to Steam - the same as each page's '‹' link. - Games are looked for up to three folders inside the system folder (ROMs/ps2/games//.iso showed ARMSX2 with 0 games), and the loose-file pass over the ROMs root no longer walks into other systems' folders. --- .../com/droiddeck/launcher/frontend/Library.kt | 17 ++++++++++------- .../com/droiddeck/launcher/ui/FrontEndScreen.kt | 12 ++++++++++++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt b/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt index 4bf6b414d3..56334a3f4c 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt @@ -71,6 +71,8 @@ object Library { Spec("ppsspp", "PPSSPP", "PSP", "/usr/bin/PPSSPPSDL", listOf("psp"), setOf("iso", "cso", "pbp", "chd")), Spec("retroarch", "RetroArch", "many systems", "/usr/bin/retroarch", emptyList(), emptySet()), ) + /** Every system folder name the specs claim, so a loose-file scan of the root skips them. */ + private val systemFolders: Set by lazy { specs.flatMap { it.folders }.toSet() } private val installedIds = mapOf( "rpcs3" to "rpcs3", "armsx2" to "armsx2", "dolphin" to "dolphin", "duckstation" to "duckstation", "melonds" to "melonds", "cemu" to "cemu", "ppsspp" to "emulators", "retroarch" to "emulators", @@ -88,15 +90,16 @@ object Library { return specs.map { spec -> val games = ArrayList() if (romsRoot != null && spec.exts.isNotEmpty()) { - // The system's folder(s), matched without regard to case, then the root itself for - // a file left loose there - and one folder deeper, since a dump usually comes as a - // folder named for the game with the image inside it. + // The system's folder(s), matched without regard to case, and up to three folders + // inside them - a dump usually comes as a folder named for the game with the image + // inside it, and people sort those into folders of their own (ps2/games//). + // The root itself only one deep, for a file left loose there. val systemDirs = romsRoot.listFiles { f -> f.isDirectory && f.name.lowercase() in spec.folders }.orEmpty().toList() val dirs = LinkedHashSet() - for (top in systemDirs + romsRoot) { - dirs.add(top) - top.listFiles { f -> f.isDirectory }?.forEach { dirs.add(it) } - } + for (top in systemDirs) top.walkTopDown().maxDepth(3).filter { it.isDirectory }.forEach { dirs.add(it) } + dirs.add(romsRoot) + // ...and not into another system's folder: a PS3 .iso in ps3/ is not a PS2 game. + romsRoot.listFiles { f -> f.isDirectory && f.name.lowercase() !in systemFolders }?.forEach { dirs.add(it) } for (dir in dirs) { // A PS3 disc dump is a folder with PS3_GAME in it; RPCS3 boots the folder. if (spec.id == "rpcs3" && File(dir, "PS3_GAME").isDirectory) { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt index 052630cc78..bc5c9ca45d 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt @@ -233,6 +233,18 @@ fun FrontEndScreen(s: FrontEndState, a: FrontEndActions, page: (@Composable () - val colors = MaterialTheme.colorScheme val ctx = LocalContext.current BackHandler(enabled = s.pageKey != null && page != null) { a.onPageBack() } + // Back (and B) from a game or an emulator steps out one level, as its "‹" link does, instead + // of leaving the app: a game -> its emulator (or Steam), an emulator -> Desktop. + BackHandler( + enabled = (s.pageKey == null || page == null) && + (selected.startsWith("app:") || selected.startsWith("emu:") || selected.startsWith("rom:")), + ) { + selected = when { + selected.startsWith("app:") -> "steam" + selected.startsWith("emu:") -> "desktop" + else -> "emu:" + selected.removePrefix("rom:").substringBefore(':') + } + } LaunchedEffect(s.isHomeApp) { if (!s.isHomeApp && selected == "android-apps") selected = "steam" } remember { Motion.scale = Settings.Global.getFloat(ctx.contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, 1f); true }