From 4ef3bc92de3594def04e901d584ea15483cb9e95 Mon Sep 17 00:00:00 2001 From: The412Banner Date: Thu, 24 Sep 2026 04:29:57 -0400 Subject: [PATCH] ARMSX2 like RPCS3: front-end launches, first-time setup, PCSX2 settings, 16K pages; on-screen controls everywhere - From the rail ARMSX2 starts the game in its full-screen, controller-driven UI and exits with it (-batch -bigpicture -fullscreen). - bannerlator-pad-defaults: a PCSX2 player's settings and memory cards are copied into ARMSX2 once; a new player starts on ARMSX2's first-time setup with the BIOS folder in the ROMs folder (ps2/bios, created, or ps2/firmware), the ps2 folder as the game list and the controller on Player 1; the guide button opens the pause menu (how a rail game is left) instead of toggling analog. Users bring their own BIOS and games. - The catalog can name a file per memory page size ("pages"); the device's own size picks it (ARMSX2 has 4K and 16K builds). - On-screen controls: Auto keeps them off the desktop (the screen is a touchpad there) and shows them for rail games and Steam when no controller is connected; the drawer offers the setting in every session. --- .../com/droiddeck/launcher/SessionActivity.kt | 5 +- .../droiddeck/launcher/frontend/Library.kt | 3 + .../launcher/runtime/DesktopCatalog.kt | 10 ++- .../droiddeck/launcher/ui/SessionOverlay.kt | 6 +- .../usr/local/bin/bannerlator-pad-defaults | 84 +++++++++++++++++-- 5 files changed, 96 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index 6c83cddba0..e66c43f492 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -885,7 +885,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { SessionPrefs.OSC_ALWAYS -> true SessionPrefs.OSC_STEAM_QAM -> true SessionPrefs.OSC_NEVER -> false - else -> !PadBridge.anyControllerConnected() + // Auto: the touch pad when there is no controller - except on the desktop, where the + // screen is a touchpad for the pointer and a pad over it would be in the way. A game + // started from the rail, or Steam, gets it; the drawer turns it on anywhere. + else -> !PadBridge.anyControllerConnected() && SessionState.mode != SessionService.MODE_DESKTOP } if (show == (controls.visibility == View.VISIBLE)) return if (!show) controls.releaseAll() 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 c56971aae3..76f8c29ddb 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt @@ -170,6 +170,9 @@ object Library { /** How the emulator is told which game to boot, on its command line. */ fun launchArgs(emulatorId: String, guestPath: String): List = when (emulatorId) { "rpcs3" -> listOf("--no-gui", guestPath) + // Straight into the game in its controller-driven full-screen UI (first-time setup there + // too), and gone when the game is quit from its pause menu (guide button): -batch. + "armsx2" -> listOf("-batch", "-bigpicture", "-fullscreen", "--", guestPath) "dolphin" -> listOf("-e", guestPath) "cemu" -> listOf("-g", guestPath) else -> listOf(guestPath) diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/DesktopCatalog.kt b/app/src/main/java/com/droiddeck/launcher/runtime/DesktopCatalog.kt index 7654917e98..2de78f99c6 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/DesktopCatalog.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/DesktopCatalog.kt @@ -31,12 +31,18 @@ object DesktopCatalog { return try { val json = JSONObject(body) val arr = json.getJSONArray("packages") + // A package built per memory page size (ARMSX2: 4K and 16K kernels) names the others + // under "pages"; the device's own size picks one, and the top-level file is the 4K one. + val pageSize = try { + android.system.Os.sysconf(android.system.OsConstants._SC_PAGESIZE).toString() + } catch (e: Exception) { "4096" } (0 until arr.length()).map { i -> val o = arr.getJSONObject(i) + val file = o.optJSONObject("pages")?.optJSONObject(pageSize) ?: o Entry( o.getString("id"), o.getString("name"), o.optInt("tier", 1), o.optString("version", ""), - o.optString("kind", "tar"), o.getString("url"), o.optString("sha256", ""), - o.optLong("size", 0L), o.optString("notes", ""), + o.optString("kind", "tar"), file.getString("url"), file.optString("sha256", ""), + file.optLong("size", 0L), o.optString("notes", ""), o.optString("icon", "applications-games"), o.optString("category", "Game"), ) } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt b/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt index 0aaf1fc7d6..e5685f0314 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt @@ -318,9 +318,11 @@ fun SessionDrawer(open: Boolean, a: DrawerActions) { listOf(SessionPrefs.TOUCH_AUTO to "Auto (${a.touchAuto})", SessionPrefs.TOUCH_PAD to "Touchpad", SessionPrefs.TOUCH_DIRECT to "Direct"), a.touchMode, onPick = a.onTouch, ) - if (a.steam) ChoiceRow( + ChoiceRow( host, "osc", "On-screen controls", null, - listOf(SessionPrefs.OSC_AUTO to "Auto", SessionPrefs.OSC_ALWAYS to "Always", SessionPrefs.OSC_STEAM_QAM to "Steam + QAM", SessionPrefs.OSC_NEVER to "Never"), a.oscMode, + if (a.steam) listOf(SessionPrefs.OSC_AUTO to "Auto", SessionPrefs.OSC_ALWAYS to "Always", SessionPrefs.OSC_STEAM_QAM to "Steam + QAM", SessionPrefs.OSC_NEVER to "Never") + else listOf(SessionPrefs.OSC_AUTO to "Auto", SessionPrefs.OSC_ALWAYS to "Always", SessionPrefs.OSC_NEVER to "Never"), + a.oscMode, onPick = a.onOsc, ) SettingsRow("Keyboard", null) { diff --git a/tools/linuxfs/overlay/usr/local/bin/bannerlator-pad-defaults b/tools/linuxfs/overlay/usr/local/bin/bannerlator-pad-defaults index 01b9f593f4..f402ac4dd0 100755 --- a/tools/linuxfs/overlay/usr/local/bin/bannerlator-pad-defaults +++ b/tools/linuxfs/overlay/usr/local/bin/bannerlator-pad-defaults @@ -116,7 +116,7 @@ def ini_section(lines, name): return (start, len(lines)) if start is not None else None -def patch_ini_section(path, section, body, what, needle="SDL-", require=None): +def patch_ini_section(path, section, body, what, needle="SDL-", require=None, done="Player 1 on the controller"): """Add body's lines to [section] of an ini the emulator wrote itself, unless the section already binds a controller (needle). Missing file: nothing - the emulator writes its own defaults on first run and this runs again.""" @@ -144,7 +144,7 @@ def patch_ini_section(path, section, body, what, needle="SDL-", require=None): with open(path + ".tmp", "w", encoding="utf-8") as f: f.write("\n".join(lines) + "\n") os.replace(path + ".tmp", path) - print(f"bannerlator-pad-defaults: {what}: Player 1 on the controller ({path})") + print(f"bannerlator-pad-defaults: {what}: {done} ({path})") # DuckStation: SDL-/, axes signed (src/util/sdl_input_source.cpp); Pad1 keys from @@ -221,10 +221,7 @@ SmallMotor = SDL-0/SmallMotor def pcsx2(): patch_ini_section(os.path.join(CONFIG, "PCSX2/inis/PCSX2.ini"), "Pad1", PCSX2_PAD1, "PCSX2", require="SettingsVersion") - # ARMSX2 (PCSX2 with ARM64 recompilers): the same ini and binding names under its own folder - # (pcsx2/Pcsx2Config.cpp: $XDG_CONFIG_HOME/ARMSX2/inis/PCSX2.ini). - patch_ini_section(os.path.join(CONFIG, "ARMSX2/inis/PCSX2.ini"), "Pad1", PCSX2_PAD1, "ARMSX2", - require="SettingsVersion") + # Dolphin: SDL//; control names from InputCommon/.../SDL/SDLGamepad.h (Left Y+ @@ -287,6 +284,79 @@ Nunchuk/Stick/Right = `Left X+` """ +# ARMSX2 - the PS2 emulator (PCSX2 with ARM64 recompilers; upstream PCSX2 interprets on ARM64). Its +# files are PCSX2's under $XDG_CONFIG_HOME/ARMSX2 (pcsx2/Pcsx2Config.cpp). The user supplies the BIOS +# and the games; they live in the ROMs folder (/root/ROMs). The guide button opens the pause menu +# (Hotkeys OpenPauseMenu) - the way out of a game started from the front end, which runs ARMSX2 +# without its window (-batch -bigpicture) - so it is not also the analog toggle here. +ARMSX2_PAD1 = "\n".join(l for l in PCSX2_PAD1.splitlines() if not l.startswith("Analog ")) + "\n" +ROMS = "/root/ROMs" + + +def ps2_folder(): + for name in ("ps2", "PS2"): + d = os.path.join(ROMS, name) + if os.path.isdir(d): + return d + return os.path.join(ROMS, "ps2") + + +def ps2_bios_folder(): + base = ps2_folder() + for name in ("bios", "BIOS", "firmware"): + d = os.path.join(base, name) + if os.path.isdir(d): + return d + d = os.path.join(base, "bios") + if os.path.isdir(ROMS): + try: + os.makedirs(d, exist_ok=True) # where the user is told to put their BIOS + except OSError: + pass + return d + + +def armsx2(): + root = os.path.join(CONFIG, "ARMSX2") + ini = os.path.join(root, "inis/PCSX2.ini") + old = os.path.join(CONFIG, "PCSX2") + if not os.path.isfile(ini) and os.path.isfile(os.path.join(old, "inis/PCSX2.ini")): + # Someone who played on PCSX2 here: the same settings, BIOS choice and memory cards (the + # saves), copied once. PCSX2's own folder is left as it was. + import shutil + for sub in ("inis", "memcards", "bios", "gamesettings", "cheats", "patches", "covers", + "inputprofiles", "textures"): + src = os.path.join(old, sub) + if os.path.isdir(src): + shutil.copytree(src, os.path.join(root, sub), dirs_exist_ok=True) + print(f"bannerlator-pad-defaults: ARMSX2: settings and memory cards copied from PCSX2 ({root})") + elif not os.path.isfile(ini): + # A new player: ARMSX2's own first-time setup still runs (SetupWizardIncomplete) to pick the + # BIOS, but looking in the ROMs folder, with the ps2 folder as its game list and the + # controller already on Player 1. + bios, games = ps2_bios_folder(), ps2_folder() + seed(ini, "[UI]\nSettingsVersion = 1\nSetupWizardIncomplete = true\n\n" + f"[Folders]\nBios = {bios}\n\n" + f"[GameList]\nRecursivePaths = {games}\n\n" + "[Hotkeys]\nOpenPauseMenu = Keyboard/Escape\nOpenPauseMenu = SDL-0/Guide\n\n" + "[Pad1]\n" + ARMSX2_PAD1, "ARMSX2", "first-time setup, BIOS from " + bios) + return + patch_ini_section(ini, "Pad1", ARMSX2_PAD1, "ARMSX2", require="SettingsVersion") + # The guide button is the pause menu here; PCSX2's profile (ours, copied over) had it as the + # analog toggle as well. + with open(ini, encoding="utf-8", errors="replace") as f: + lines = f.read().splitlines() + kept = [l for l in lines if l.replace(" ", "") != "Analog=SDL-0/Guide"] + if len(kept) != len(lines): + with open(ini + ".tmp", "w", encoding="utf-8") as f: + f.write("\n".join(kept) + "\n") + os.replace(ini + ".tmp", ini) + patch_ini_section(ini, "Hotkeys", "OpenPauseMenu = SDL-0/Guide\n", "ARMSX2", needle="SDL-0/Guide", + require="SettingsVersion", done="the guide button opens the pause menu") + patch_ini_section(ini, "GameList", f"RecursivePaths = {ps2_folder()}\n", "ARMSX2", needle=ROMS, + require="SettingsVersion", done="games listed from the ROMs folder") + + def dolphin(): d = os.path.join(CONFIG, "dolphin-emu") seed(os.path.join(d, "GCPadNew.ini"), DOLPHIN_GC, "Dolphin (GameCube)") @@ -454,7 +524,7 @@ def retroarch(): print(f"bannerlator-pad-defaults: RetroArch: joypad driver udev -> sdl2 ({cfg})") -for step in (rpcs3, duckstation, pcsx2, dolphin, cemu, melonds, ppsspp, retroarch): +for step in (rpcs3, duckstation, pcsx2, armsx2, dolphin, cemu, melonds, ppsspp, retroarch): try: step() except Exception as e: