From 92990c62248f9109ece7b47b7f5802ebe724a44d Mon Sep 17 00:00:00 2001 From: MonkeyX Date: Mon, 9 Sep 2024 14:38:42 +0100 Subject: [PATCH 01/23] On branch feat/godot (#941) Changes to be committed: modified: tools/configurator/main.tscn modified: tools/configurator/res/pixel_ui_theme/RetroDECKTheme.tres modified: tools/configurator/scripts/SystemTab.gd Co-authored-by: Rekku From 12eff056768fadad7d97b91533e0d456bf0a57a6 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Tue, 10 Sep 2024 10:36:13 +0900 Subject: [PATCH 02/23] DEVELOPER_TOOL: dd features.json linter [skip ci] --- developer_toolbox/lint_features.json.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 developer_toolbox/lint_features.json.sh diff --git a/developer_toolbox/lint_features.json.sh b/developer_toolbox/lint_features.json.sh new file mode 100755 index 00000000..22140f06 --- /dev/null +++ b/developer_toolbox/lint_features.json.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +features=config/retrodeck/reference_lists/features.json + +jq . $features > $features.tmp && mv -f $features.tmp $features \ No newline at end of file From 570a810dc69157d442ade2f48ab7d644a0e5518f Mon Sep 17 00:00:00 2001 From: XargonWan Date: Tue, 10 Sep 2024 10:38:05 +0900 Subject: [PATCH 03/23] FEATURES: fmt [skip ci] --- .../retrodeck/reference_lists/features.json | 2273 ++++++++--------- 1 file changed, 1136 insertions(+), 1137 deletions(-) diff --git a/config/retrodeck/reference_lists/features.json b/config/retrodeck/reference_lists/features.json index 24f0ec09..f9cd535e 100644 --- a/config/retrodeck/reference_lists/features.json +++ b/config/retrodeck/reference_lists/features.json @@ -1,1139 +1,1138 @@ { - "about_links": { - "rd_changelog": { - "description": "Opens the RetroDECK change log in your default browser", - "name": "Changelog", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_rd_versions/version-history/", - "icon": "res://assets/icons/pixelitos/128/internet-web-browser.png" - }, - "rd_contactus": { - "description": "Opens the RetroDECK contact us section in your default browser", - "name": "Contact us", - "url": "https://github.com/XargonWan/RetroDECK", - "icon": "res://assets/icons/pixelitos/128/internet-web-browser.png" - }, - "rd_credits": { - "description": "Opens the RetroDECK Credits in your default browser", - "name": "Credits", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_credits/donations-licenses/", - "icon": "res://assets/icons/pixelitos/128/internet-web-browser.png" - }, - "rd_donate": { - "description": "Opens Donations page in your default browser", - "name": "Donate", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_credits/donations-licenses/", - "icon": "res://assets/icons/pixelitos/128/internet-web-browser.png" - }, - "rd_licenses": { - "description": "Opens the RetroDECK licenses in your default browser", - "name": "Licences", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_credits/donations-licenses/", - "icon": "res://assets/icons/pixelitos/128/internet-web-browser.png" - }, - "rd_web": { - "description": "Opens the RetroDECK Website in your default browser", - "name": "Website", - "url": "https://retrodeck.net/", - "icon": "res://assets/icons/pixelitos/128/internet-web-browser.png" - }, - "rd_wiki": { - "description": "Opens the RetroDECK Wiki in your default browser", - "name": "Wiki", - "url": "https://retrodeck.readthedocs.io/en/latest/", - "icon": "res://assets/icons/pixelitos/128/internet-web-browser.png" - } - }, - "finit_default_options": { - "rd_controller_profile": { - "name": "RetroDECK Steam Controller Profiles Install", - "description": "Install RetroDECK Steam Input profiles to Steam - Recommended", - "enabled": true - }, - "rpcs3_firmware": { - "name": "RPCS3 Firmware Install", - "description": "Install firmware needed for PS3 emulation", - "enabled": false - }, - "vita3k_firmware": { - "name": "Vita3K Firmware Install", - "description": "Install firmware needed for Vita3K emulation", - "enabled": false - } - }, - "splash_screens": { - "xmas": { - "start_date": "1201", - "end_date": "1231", - "start_time": "0000", - "end_time": "2359", - "filename": "rd-xmas-splash.svg" - }, - "lunar_dragon": { - "start_date": "0209", - "end_date": "0212", - "start_time": "0000", - "end_time": "2359", - "filename": "rd-lunar-dragon-splash.svg" - }, - "valentines_day": { - "start_date": "0214", - "end_date": "0214", - "start_time": "0001", - "end_time": "2359", - "filename": "rd-valentines-splash.svg" - }, - "retrodeck_birthday": { - "start_date": "0304", - "end_date": "0304", - "start_time": "0000", - "end_time": "2359", - "filename": "rd-gm-bday-splash.svg" - }, - "st_patricks_day": { - "start_date": "0317", - "end_date": "0317", - "start_time": "0000", - "end_time": "2359", - "filename": "rd-stpatricks-splash.svg" - }, - "kodomo_golden_week": { - "start_date": "0429", - "end_date": "0505", - "start_time": "0000", - "end_time": "2359", - "filename": "rd-kodomo-golden.svg" - }, - "tanabata": { - "start_date": "0707", - "end_date": "0707", - "start_time": "0000", - "end_time": "2359", - "filename": "tanabata.svg" - }, - "mountain_day": { - "start_date": "0811", - "end_date": "0811", - "start_time": "0000", - "end_time": "2359", - "filename": "placeholder.svg" - }, - "obon": { - "start_date": "0813", - "end_date": "0816", - "start_time": "0000", - "end_time": "2359", - "filename": "placeholder.svg" - } - }, - "incompatible_presets": { - "borders": "widescreen" - }, - "helper_files": { - "dolphin_mods": { - "filename": "how-to-install-dolphin-mods.txt", - "location": "$mods_folder/Dolphin" - }, - "primehack_mods": { - "filename": "how-to-install-primehack-mods.txt", - "location": "$mods_folder/Primehack" - }, - "mesen_textures": { - "filename": "how-to-install-Mesen-textures.txt", - "location": "$texture_packs_folder/RetroArch-Mesen" - }, - "ppsspp_textures": { - "filename": "how-to-install-PPSSPP-textures.txt", - "location": "$texture_packs_folder/PPSSPP" - }, - "pcsx2_textures": { - "filename": "how-to-install-PCSX2-textures.txt", - "location": "$texture_packs_folder/PCSX2" - }, - "mupen64plus_cache_textures": { - "filename": "how-to-install-Mupen64Plus-textures.txt", - "location": "$texture_packs_folder/RetroArch-Mupen64Plus/cache" - }, - "mupen64plus_hires_textures": { - "filename": "how-to-install-Mupen64Plus-textures.txt", - "location": "$texture_packs_folder/RetroArch-Mupen64Plus/hires_texture" - }, - "duckstation_textures": { - "filename": "how-to-install-Duckstation-textures.txt", - "location": "$texture_packs_folder/Duckstation" - }, - "psvita_games": { - "filename": "how-to-install-psvita-games.txt", - "location": "$roms_folder/psvita" - }, - "ryujinx_firmware": { - "filename": "Install-firmware-through-Ryujinx.txt", - "location": "$bios_folder/switch/firmware" - } - }, - "compression_targets": { - "chd": [ - "3do", - "amigacd32", - "dreamcast", - "megacd", - "neogeocd", - "pcenginecd", - "pcfx", - "psp", - "psx", - "ps2", - "saturn", - "saturnjp", - "segacd", - "tg-cd" - ], - "rvz": [ - "gc", - "wii" - ], - "zip": [ - "atari2600", - "atari5200", - "atari7800", - "atari800", - "atarijaguar", - "atarilynx", - "atarist", - "gamegear", - "gb", - "gba", - "gbc", - "genesis", - "mastersystem", - "n64", - "nds", - "nes", - "ngp", - "ngpc", - "sega32x", - "sega32xjp", - "sega32xna", - "snes", - "snesna", - "tg16" - ] - }, - "zip_compressable_extensions": [ - ".32x", - ".68k", - ".NDS", - ".a26", - ".a52", - ".a78", - ".abs", - ".agb", - ".atr", - ".atx", - ".bin", - ".bml", - ".bms", - ".bs", - ".bsx", - ".cas", - ".cdm", - ".cgb", - ".cof", - ".col", - ".dim", - ".dmg", - ".dx2", - ".fds", - ".fig", - ".gb", - ".gba", - ".gbc", - ".gd3", - ".gd7", - ".gen", - ".gg", - ".ipf", - ".j64", - ".jag", - ".lnx", - ".md", - ".mdx", - ".mgd", - ".msa", - ".nds", - ".nes", - ".ngc", - ".o", - ".pce", - ".prg", - ".rom", - ".sfc", - ".sg", - ".sgb", - ".sgd", - ".smc", - ".smd", - ".sms", - ".st", - ".st", - ".stx", - ".swc", - ".unf", - ".unif", - ".xex", - ".xfd", - ".z64" - ], - "system": { - "3do": { - "name": "3DO Interactive Multiplayer" - }, - "adam": { - "name": "Coleco Adam" - }, - "amiga": { - "name": "Commodore Amiga" - }, - "amiga1200": { - "name": "Commodore Amiga 1200" - }, - "amiga600": { - "name": "Commodore Amiga 600" - }, - "amigacd32": { - "name": "Commodore Amiga CD32" - }, - "amstradcpc": { - "name": "Amstrad CPC" - }, - "apple2": { - "name": "Apple II" - }, - "apple2gs": { - "name": "Apple IIGS" - }, - "arcade": { - "name": "Arcade" - }, - "arcadia": { - "name": "Emerson Arcadia 2001" - }, - "archimedes": { - "name": "Acorn Archimedes" - }, - "arduboy": { - "name": "Arduboy Miniature Game System" - }, - "astrocde": { - "name": "Bally Astrocade" - }, - "atari2600": { - "name": "Atari 2600" - }, - "atari5200": { - "name": "Atari 5200" - }, - "atari7800": { - "name": "Atari 7800 ProSystem" - }, - "atari800": { - "name": "Atari 800" - }, - "atarijaguar": { - "name": "Atari Jaguar" - }, - "atarilynx": { - "name": "Atari Lynx" - }, - "atarist": { - "name": "Atari ST" - }, - "atarixe": { - "name": "Atari XE" - }, - "atomiswave": { - "name": "Sammy Corporation Atomiswave" - }, - "bbcmicro": { - "name": "Acorn Computers BBC Micro" - }, - "c64": { - "name": "Commodore 64" - }, - "cdimono1": { - "name": "Philips CD-i" - }, - "cdtv": { - "name": "Commodore CDTV" - }, - "chailove": { - "name": "ChaiLove Game Engine" - }, - "channelf": { - "name": "Fairchild Channel F" - }, - "colecovision": { - "name": "Coleco ColecoVision" - }, - "consolearcade": { - "name": "Console Arcade Systems" - }, - "cps": { - "name": "Capcom Play System" - }, - "cps1": { - "name": "Capcom Play System I" - }, - "cps2": { - "name": "Capcom Play System II" - }, - "cps3": { - "name": "Capcom Play System III" - }, - "crvision": { - "name": "VTech CreatiVision" - }, - "daphne": { - "name": "Daphne Arcade LaserDisc Emulator" - }, - "desktop": { - "name": "Desktop Applications" - }, - "doom": { - "name": "Doom" - }, - "dos": { - "name": "DOS (PC)" - }, - "dreamcast": { - "name": "Sega Dreamcast" - }, - "dc": { - "name": "Sega Dreamcast" - }, - "easyrpg": { - "name": "EasyRPG Game Engine" - }, - "electron": { - "name": "Acorn Electron" - }, - "emulators": { - "name": "Emulators" - }, - "famicom": { - "name": "Nintendo Family Computer" - }, - "fba": { - "name": "FinalBurn Alpha" - }, - "fbneo": { - "name": "FinalBurn Neo" - }, - "fds": { - "name": "Nintendo Famicom Disk System" - }, - "fm7": { - "name": "Fujitsu FM-7" - }, - "fmtowns": { - "name": "Fujitsu FM Towns" - }, - "gamate": { - "name": "Bit Corporation Gamate" - }, - "gameandwatch": { - "name": "Nintendo Game and Watch" - }, - "gamecom": { - "name": "Tiger Electronics Game.com" - }, - "gamegear": { - "name": "Sega Game Gear" - }, - "gg": { - "name": "Sega Game Gear" - }, - "gb": { - "name": "Nintendo Game Boy" - }, - "gba": { - "name": "Nintendo Game Boy Advance" - }, - "gbc": { - "name": "Nintendo Game Boy Color" - }, - "gc": { - "name": "Nintendo GameCube" - }, - "genesis": { - "name": "Sega Genesis" - }, - "gmaster": { - "name": "Hartung Game Master" - }, - "gx4000": { - "name": "Amstrad GX4000" - }, - "intellivision": { - "name": "Mattel Electronics Intellivision" - }, - "j2me": { - "name": "Java 2 Micro Edition (J2ME)" - }, - "laserdisc": { - "name": "LaserDisc Games" - }, - "lcdgames": { - "name": "LCD Handheld Games" - }, - "lowresnx": { - "name": "LowRes NX Fantasy Console" - }, - "lutris": { - "name": "Lutris Open Gaming Platform" - }, - "lutro": { - "name": "Lutro Game Engine" - }, - "macintosh": { - "name": "Apple Macintosh" - }, - "mame": { - "name": "Multiple Arcade Machine Emulator" - }, - "mastersystem": { - "name": "Sega Master System" - }, - "megacd": { - "name": "Sega Mega-CD" - }, - "megacdjp": { - "name": "Sega Mega-CD (Japan)" - }, - "megadrive": { - "name": "Sega Mega Drive" - }, - "megaduck": { - "name": "Creatronic Mega Duck" - }, - "mess": { - "name": "Multi Emulator Super System" - }, - "model2": { - "name": "Sega Model 2" - }, - "moto": { - "name": "Thomson MO/TO Series" - }, - "msx": { - "name": "MSX" - }, - "msx1": { - "name": "MSX1" - }, - "msx2": { - "name": "MSX2" - }, - "msxturbor": { - "name": "MSX Turbo R" - }, - "mugen": { - "name": "M.U.G.E.N Game Engine" - }, - "multivision": { - "name": "Othello Multivision" - }, - "n3ds": { - "name": "Nintendo 3DS" - }, - "n64": { - "name": "Nintendo 64" - }, - "n64dd": { - "name": "Nintendo 64DD" - }, - "naomi": { - "name": "Sega NAOMI" - }, - "naomi2": { - "name": "Sega NAOMI 2" - }, - "naomigd": { - "name": "Sega NAOMI GD-ROM" - }, - "nds": { - "name": "Nintendo DS" - }, - "neogeo": { - "name": "SNK Neo Geo" - }, - "neogeocd": { - "name": "SNK Neo Geo CD" - }, - "neogeocdjp": { - "name": "SNK Neo Geo CD (Japan)" - }, - "nes": { - "name": "Nintendo Entertainment System" - }, - "ngp": { - "name": "SNK Neo Geo Pocket" - }, - "ngpc": { - "name": "SNK Neo Geo Pocket Color" - }, - "odyssey2": { - "name": "Magnavox Odyssey 2" - }, - "openbor": { - "name": "OpenBOR Game Engine" - }, - "palm": { - "name": "Palm OS" - }, - "pc": { - "name": "IBM PC" - }, - "pc88": { - "name": "NEC PC-8800 Series" - }, - "pc98": { - "name": "NEC PC-9800 Series" - }, - "pcarcade": { - "name": "PC Arcade Systems" - }, - "pcengine": { - "name": "NEC PC Engine" - }, - "pcenginecd": { - "name": "NEC PC Engine CD" - }, - "pcfx": { - "name": "NEC PC-FX" - }, - "pico8": { - "name": "PICO-8 Fantasy Console" - }, - "plus4": { - "name": "Commodore Plus/4" - }, - "pokemini": { - "name": "Nintendo Pokémon Mini" - }, - "ports": { - "name": "Ports" - }, - "ps2": { - "name": "Sony PlayStation 2" - }, - "ps3": { - "name": "Sony PlayStation 3" - }, - "psp": { - "name": "Sony PlayStation Portable" - }, - "psvita": { - "name": "Sony PlayStation Vita" - }, - "psx": { - "name": "Sony PlayStation" - }, - "pv1000": { - "name": "Casio PV-1000" - }, - "quake": { - "name": "Quake" - }, - "satellaview": { - "name": "Nintendo Satellaview" - }, - "saturn": { - "name": "Sega Saturn" - }, - "saturnjp": { - "name": "Sega Saturn (Japan)" - }, - "scummvm": { - "name": "ScummVM Game Engine" - }, - "scv": { - "name": "Epoch Super Cassette Vision" - }, - "sega32x": { - "name": "Sega Mega Drive 32X" - }, - "sega32xjp": { - "name": "Sega Super 32X (Japan)" - }, - "sega32xna": { - "name": "Sega Genesis 32X" - }, - "segacd": { - "name": "Sega CD" - }, - "sfc": { - "name": "Nintendo SFC (Super Famicom)" - }, - "sg-1000": { - "name": "Sega SG-1000" - }, - "sgb": { - "name": "Nintendo Super Game Boy" - }, - "snes": { - "name": "Nintendo SNES (Super Nintendo)" - }, - "snesna": { - "name": "Nintendo SNES (Super Nintendo)" - }, - "solarus": { - "name": "Solarus Game Engine" - }, - "spectravideo": { - "name": "Spectravideo" - }, - "stv": { - "name": "Sega Titan Video Game System" - }, - "sufami": { - "name": "Bandai SuFami Turbo" - }, - "supergrafx": { - "name": "NEC SuperGrafx" - }, - "supervision": { - "name": "Watara Supervision" - }, - "supracan": { - "name": "Funtech Super A'Can" - }, - "switch": { - "name": "Nintendo Switch" - }, - "tg-cd": { - "name": "NEC TurboGrafx-CD" - }, - "tg16": { - "name": "NEC TurboGrafx-16" - }, - "ti99": { - "name": "Texas Instruments TI-99" - }, - "tic80": { - "name": "TIC-80 Fantasy Computer" - }, - "to8": { - "name": "Thomson TO8" - }, - "uzebox": { - "name": "Uzebox Open Source Console" - }, - "vectrex": { - "name": "GCE Vectrex" - }, - "vic20": { - "name": "Commodore VIC-20" - }, - "videopac": { - "name": "Philips Videopac G7000" - }, - "virtualboy": { - "name": "Nintendo Virtual Boy" - }, - "vsmile": { - "name": "VTech V.Smile" - }, - "wasm4": { - "name": "WASM-4 Fantasy Console" - }, - "wii": { - "name": "Nintendo Wii" - }, - "wiiu": { - "name": "Nintendo Wii U" - }, - "windows": { - "name": "Microsoft Windows" - }, - "windows3x": { - "name": "Microsoft Windows 3.x" - }, - "windows9x": { - "name": "Microsoft Windows 9x" - }, - "wonderswan": { - "name": "Bandai WonderSwan" - }, - "wonderswancolor": { - "name": "Bandai WonderSwan Color" - }, - "x1": { - "name": "Sharp X1" - }, - "x68000": { - "name": "Sharp X68000" - }, - "xbox": { - "name": "Microsoft Xbox" - }, - "zx81": { - "name": "Sinclair ZX81" - }, - "zxspectrum": { - "name": "Sinclair ZX Spectrum" - } - }, - "emulator": { - "retroarch": { - "description": "RetroArch (Multi-emulator Frontend)", - "name": "RetroArch", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/retroarch/retroarch-guide/", - "launch": "retroarch", - "system": "retroarch", - "properties": [ - { - "cheevos": true, - "cheevos_hardcore": true, - "quick_resume": true - } - ], - "cores": { - "citra_libretro": { - "description": "Nintendo 3DS Libretro Core", - "name": "Citra", - "system": "n3ds", - "properties": [ - { - "abxy_button": true - } - ] - }, - "mame_libretro": { - "description": "MAME: Multiple Arcade Machine Libretro Core", - "name": "MAME", - "system": "arcade", - "properties": [ - { - "tate_mode": true - } - ] - }, - "desmume_libretro": { - "description": "DeSmuME Nintendo DS Libretro Core", - "name": "desmume", - "system": "nds", - "properties": [ - { - "abxy_button": true - } - ] - }, - "melonds_libretro": { - "description": "MelonDS Nintendo DS Libretro Core", - "name": "melonds", - "system": "nds", - "properties": [ - { - "abxy_button": true - } - ] - }, - "swanstation_libretro": { - "name": "SwanStation", - "description": "Swanstation Libretro Core", - "system": "psx", - "properties": [ - { - "widescreen": true, - "borders": true - } - ] - }, - "picodrive_libretro": { - "name": "PicoDrive", - "description": "SEGA MS/MD/CD/32X Libretro Core", - "system": [ - "ms", - "md", - "cd", - "32x" - ], - "properties": [ - { - "widescreen": true, - "borders": true, - "rewind": true - } - ] - }, - "genesisplusgx_libretro": { - "name": "Genesis Plus GX", - "description": "SEGA MS/GG/MD/CD Libretro Core", - "system": [ - "ms", - "gg", - "mc", - "cd" - ], - "properties": [ - { - "widescreen": true, - "borders": true, - "rewind": true - } - ] - }, - "genesisplusgxwide_libretro": { - "name": "Genesis Plus GX Wide", - "description": "SEGA MS/GG/MD/CD Libretro Core for Wide Screen", - "system": [ - "ms", - "gg", - "mc", - "cd" - ], - "properties": [ - { - "widescreen": true, - "rewind": true - } - ] - }, - "mupen64plus-next_libretro": { - "name": "Mupen64Plus-Next", - "description": "Nintendo 64 Libretro Core", - "system": "n64", - "properties": [ - { - "widescreen": true, - "borders": true, - "abxy_button": true - } - ] - }, - "snes9x-current_libretro": { - "name": "Snes9x - Current", - "description": "Super Nintendo Libretro Core", - "system": "snes", - "properties": [ - { - "widescreen": true, - "borders": true, - "rewind": true, - "abxy_button": true - } - ] - }, - "gambatte_libretro": { - "name": "Gambatte", - "description": "Game Boy/Color Libretro Core", - "system": [ - "gb", - "gbc" - ], - "properties": [ - { - "borders": true, - "rewind": true, - "abxy_button": true - } - ] - }, - "mgba_libretro": { - "name": "mGBA", - "description": "Game Boy Advance Libretro Core", - "system": "gba", - "properties": [ - { - "borders": true, - "rewind": true, - "abxy_button": true - } - ] - } - } - }, - "mame": { - "description": "MAME: Multiple Arcade Machine Emulator", - "name": "MAME", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/mame/mame-guide/", - "system": [ - "arcade" - ], - "launch": "mame", - "launch-args": "-inipath /var/config/mame/ini -rompath $(dirname \"$game\") $game" - }, - "citra": { - "description": "Citra Nintendo 3DS Emulator (via Ponzu)", - "name": "Citra (via Ponzu)", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_about/what-is-retrodeck/", - "system": "n3ds", - "ponzu": true, - "launch": "citra-qt", - "properties": [ - { - "abxy_button": true, - "ask_to_exit": true - } - ] - }, - "ruffle": { - "description": "Flash Games emulator", - "name" : "Ruffle", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_about/what-is-retrodeck/", - "system" : "flash", - "launch": "ruffle-rd-wrapper.sh" - }, - "melonds": { - "description": "MelonDS Nintendo DS Emulator", - "name": "melonds", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/melonds/melonds-guide/", - "system": "nds", - "launch": "melonDS" - }, - "pcsx2": { - "name": "pcsx2", - "description": "PCSX2 Play Station 2 Emulator", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/pcsx2/pcsx2-guide/", - "system": "ps2", - "launch": "pcsx2-qt", - "launch-args": "-batch $game", - "properties": [ - { - "ask_to_exit": true, - "cheevos": true - } - ] - }, - "duckstation": { - "name": "Duckstation", - "description": "PlayStation Emulator", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/duckstation/duckstation-guide/", - "launch": "duckstation-qt", - "launch-args": "-batch $game", - "system": "psx", - "properties": [ - { - "ask_to_exit": true, - "cheevos": true - } - ] - }, - "ppsspp": { - "name": "PPSSPP", - "description": "PPSSPP: PlayStation Portable Emulator", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/ppsspp/ppsspp-guide/", - "launch": "PPSSPPSDL", - "system": "psp", - "properties": [ - { - "cheevos": true, - "cheevos_hardcore": true - } - ] - }, - "vita3k": { - "name": "Vita3k", - "description": "Vita3K PSVita Emulator", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/vita3k/vita3k-guide/", - "system": "psvita", - "launch": "Vita3K", - "launch-args": "-r $game.psvita" - }, - "rpcs3": { - "name": "RPCS3", - "description": "RPCS3 PlayStation 3 Emulator", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/rpcs3/rpcs3-guide/", - "system": "ps3", - "launch": "rpcs3", - "launch-override": "cd $(dirname $game) && rpcs3 $game", - "properties": [ - { - "ask_to_exit": true - } - ] - }, - "ryujinx": { - "name": "Ryujinx", - "description": "Ryujinx Nintendo Switch Emulator", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/ryujinx/ryujinx-guide/", - "system": "switch", - "launch": "Ryujinx.sh" - }, - "yuzu": { - "name": "Yuzu (via Ponzu)", - "description": "Yuzu Nintendo Switch Emulator (via Ponzu)", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_about/what-is-retrodeck/", - "launch": "Yuzu", - "system": "switch", - "launch-args": "-f -g $game", - "ponzu": true, - "abxy_button": true - }, - "dolphin": { - "name": "Dolphin", - "description": "Dolphin Wii and GameCube Emulator", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/dolphin-primehack/dolphin-primehack-guide/", - "launch": "dolphin-emu-wrapper", - "launch-args": "-e $game", - "system": [ - "gc", - "wii" - ], - "properties": [ - { - "abxy_button": true, - "ask_to_exit": true, - "cheevos": true, - "cheevos_hardcore": true, - "universal_dyn_input": true - } - ] - }, - "primehack": { - "name": "PrimeHack", - "description": "A fork of Dolphiin to enhance Metroid Prime experience", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/dolphin-primehack/dolphin-primehack-guide/", - "launch": "primehack-wrapper", - "launch-args": "-e $game", - "system": [ - "wii" - ], - "properties": [ - { - "ask_to_exit": true, - "universal_dyn_input": true - } - ] - }, - "cemu": { - "description": "Wii U emulator", - "name": "Cemu", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/cemu/cemu-guide/", - "system": "wiiu", - "launch": "Cemu-wrapper", - "launch-args": "-g $game", - "properties": [ - { - "abxy_button": true, - "multi_user_config_dir": "Cemu" - } - ] - }, - "xemu": { - "description": "xemu Xbox Emulator", - "name": "xemu", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/xemu/xemu-guide/", - "system": "xbox", - "launch": "xemu", - "launch-args": "-dvd_path $game" - }, - "es-de": { - "description": "ES-DE Emulation Frontend", - "name": "ES-DE", - "url": "https://retrodeck.readthedocs.io/en/latest/wiki_es_de/esde-guide/." -, "launch": "es-de" - } - } + "about_links": { + "rd_changelog": { + "description": "Opens the RetroDECK change log in your default browser", + "name": "Changelog", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_rd_versions/version-history/", + "icon": "res://assets/icons/pixelitos/128/internet-web-browser.png" + }, + "rd_contactus": { + "description": "Opens the RetroDECK contact us section in your default browser", + "name": "Contact us", + "url": "https://github.com/XargonWan/RetroDECK", + "icon": "res://assets/icons/pixelitos/128/internet-web-browser.png" + }, + "rd_credits": { + "description": "Opens the RetroDECK Credits in your default browser", + "name": "Credits", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_credits/donations-licenses/", + "icon": "res://assets/icons/pixelitos/128/internet-web-browser.png" + }, + "rd_donate": { + "description": "Opens Donations page in your default browser", + "name": "Donate", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_credits/donations-licenses/", + "icon": "res://assets/icons/pixelitos/128/internet-web-browser.png" + }, + "rd_licenses": { + "description": "Opens the RetroDECK licenses in your default browser", + "name": "Licences", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_credits/donations-licenses/", + "icon": "res://assets/icons/pixelitos/128/internet-web-browser.png" + }, + "rd_web": { + "description": "Opens the RetroDECK Website in your default browser", + "name": "Website", + "url": "https://retrodeck.net/", + "icon": "res://assets/icons/pixelitos/128/internet-web-browser.png" + }, + "rd_wiki": { + "description": "Opens the RetroDECK Wiki in your default browser", + "name": "Wiki", + "url": "https://retrodeck.readthedocs.io/en/latest/", + "icon": "res://assets/icons/pixelitos/128/internet-web-browser.png" + } + }, + "finit_default_options": { + "rd_controller_profile": { + "name": "RetroDECK Steam Controller Profiles Install", + "description": "Install RetroDECK Steam Input profiles to Steam - Recommended", + "enabled": true + }, + "rpcs3_firmware": { + "name": "RPCS3 Firmware Install", + "description": "Install firmware needed for PS3 emulation", + "enabled": false + }, + "vita3k_firmware": { + "name": "Vita3K Firmware Install", + "description": "Install firmware needed for Vita3K emulation", + "enabled": false + } + }, + "splash_screens": { + "xmas": { + "start_date": "1201", + "end_date": "1231", + "start_time": "0000", + "end_time": "2359", + "filename": "rd-xmas-splash.svg" + }, + "lunar_dragon": { + "start_date": "0209", + "end_date": "0212", + "start_time": "0000", + "end_time": "2359", + "filename": "rd-lunar-dragon-splash.svg" + }, + "valentines_day": { + "start_date": "0214", + "end_date": "0214", + "start_time": "0001", + "end_time": "2359", + "filename": "rd-valentines-splash.svg" + }, + "retrodeck_birthday": { + "start_date": "0304", + "end_date": "0304", + "start_time": "0000", + "end_time": "2359", + "filename": "rd-gm-bday-splash.svg" + }, + "st_patricks_day": { + "start_date": "0317", + "end_date": "0317", + "start_time": "0000", + "end_time": "2359", + "filename": "rd-stpatricks-splash.svg" + }, + "kodomo_golden_week": { + "start_date": "0429", + "end_date": "0505", + "start_time": "0000", + "end_time": "2359", + "filename": "rd-kodomo-golden.svg" + }, + "tanabata": { + "start_date": "0707", + "end_date": "0707", + "start_time": "0000", + "end_time": "2359", + "filename": "tanabata.svg" + }, + "mountain_day": { + "start_date": "0811", + "end_date": "0811", + "start_time": "0000", + "end_time": "2359", + "filename": "placeholder.svg" + }, + "obon": { + "start_date": "0813", + "end_date": "0816", + "start_time": "0000", + "end_time": "2359", + "filename": "placeholder.svg" + } + }, + "incompatible_presets": { + "borders": "widescreen" + }, + "helper_files": { + "dolphin_mods": { + "filename": "how-to-install-dolphin-mods.txt", + "location": "$mods_folder/Dolphin" + }, + "primehack_mods": { + "filename": "how-to-install-primehack-mods.txt", + "location": "$mods_folder/Primehack" + }, + "mesen_textures": { + "filename": "how-to-install-Mesen-textures.txt", + "location": "$texture_packs_folder/RetroArch-Mesen" + }, + "ppsspp_textures": { + "filename": "how-to-install-PPSSPP-textures.txt", + "location": "$texture_packs_folder/PPSSPP" + }, + "pcsx2_textures": { + "filename": "how-to-install-PCSX2-textures.txt", + "location": "$texture_packs_folder/PCSX2" + }, + "mupen64plus_cache_textures": { + "filename": "how-to-install-Mupen64Plus-textures.txt", + "location": "$texture_packs_folder/RetroArch-Mupen64Plus/cache" + }, + "mupen64plus_hires_textures": { + "filename": "how-to-install-Mupen64Plus-textures.txt", + "location": "$texture_packs_folder/RetroArch-Mupen64Plus/hires_texture" + }, + "duckstation_textures": { + "filename": "how-to-install-Duckstation-textures.txt", + "location": "$texture_packs_folder/Duckstation" + }, + "psvita_games": { + "filename": "how-to-install-psvita-games.txt", + "location": "$roms_folder/psvita" + }, + "ryujinx_firmware": { + "filename": "Install-firmware-through-Ryujinx.txt", + "location": "$bios_folder/switch/firmware" + } + }, + "compression_targets": { + "chd": [ + "3do", + "amigacd32", + "dreamcast", + "megacd", + "neogeocd", + "pcenginecd", + "pcfx", + "psp", + "psx", + "ps2", + "saturn", + "saturnjp", + "segacd", + "tg-cd" + ], + "rvz": [ + "gc", + "wii" + ], + "zip": [ + "atari2600", + "atari5200", + "atari7800", + "atari800", + "atarijaguar", + "atarilynx", + "atarist", + "gamegear", + "gb", + "gba", + "gbc", + "genesis", + "mastersystem", + "n64", + "nds", + "nes", + "ngp", + "ngpc", + "sega32x", + "sega32xjp", + "sega32xna", + "snes", + "snesna", + "tg16" + ] + }, + "zip_compressable_extensions": [ + ".32x", + ".68k", + ".NDS", + ".a26", + ".a52", + ".a78", + ".abs", + ".agb", + ".atr", + ".atx", + ".bin", + ".bml", + ".bms", + ".bs", + ".bsx", + ".cas", + ".cdm", + ".cgb", + ".cof", + ".col", + ".dim", + ".dmg", + ".dx2", + ".fds", + ".fig", + ".gb", + ".gba", + ".gbc", + ".gd3", + ".gd7", + ".gen", + ".gg", + ".ipf", + ".j64", + ".jag", + ".lnx", + ".md", + ".mdx", + ".mgd", + ".msa", + ".nds", + ".nes", + ".ngc", + ".o", + ".pce", + ".prg", + ".rom", + ".sfc", + ".sg", + ".sgb", + ".sgd", + ".smc", + ".smd", + ".sms", + ".st", + ".st", + ".stx", + ".swc", + ".unf", + ".unif", + ".xex", + ".xfd", + ".z64" + ], + "system": { + "3do": { + "name": "3DO Interactive Multiplayer" + }, + "adam": { + "name": "Coleco Adam" + }, + "amiga": { + "name": "Commodore Amiga" + }, + "amiga1200": { + "name": "Commodore Amiga 1200" + }, + "amiga600": { + "name": "Commodore Amiga 600" + }, + "amigacd32": { + "name": "Commodore Amiga CD32" + }, + "amstradcpc": { + "name": "Amstrad CPC" + }, + "apple2": { + "name": "Apple II" + }, + "apple2gs": { + "name": "Apple IIGS" + }, + "arcade": { + "name": "Arcade" + }, + "arcadia": { + "name": "Emerson Arcadia 2001" + }, + "archimedes": { + "name": "Acorn Archimedes" + }, + "arduboy": { + "name": "Arduboy Miniature Game System" + }, + "astrocde": { + "name": "Bally Astrocade" + }, + "atari2600": { + "name": "Atari 2600" + }, + "atari5200": { + "name": "Atari 5200" + }, + "atari7800": { + "name": "Atari 7800 ProSystem" + }, + "atari800": { + "name": "Atari 800" + }, + "atarijaguar": { + "name": "Atari Jaguar" + }, + "atarilynx": { + "name": "Atari Lynx" + }, + "atarist": { + "name": "Atari ST" + }, + "atarixe": { + "name": "Atari XE" + }, + "atomiswave": { + "name": "Sammy Corporation Atomiswave" + }, + "bbcmicro": { + "name": "Acorn Computers BBC Micro" + }, + "c64": { + "name": "Commodore 64" + }, + "cdimono1": { + "name": "Philips CD-i" + }, + "cdtv": { + "name": "Commodore CDTV" + }, + "chailove": { + "name": "ChaiLove Game Engine" + }, + "channelf": { + "name": "Fairchild Channel F" + }, + "colecovision": { + "name": "Coleco ColecoVision" + }, + "consolearcade": { + "name": "Console Arcade Systems" + }, + "cps": { + "name": "Capcom Play System" + }, + "cps1": { + "name": "Capcom Play System I" + }, + "cps2": { + "name": "Capcom Play System II" + }, + "cps3": { + "name": "Capcom Play System III" + }, + "crvision": { + "name": "VTech CreatiVision" + }, + "daphne": { + "name": "Daphne Arcade LaserDisc Emulator" + }, + "desktop": { + "name": "Desktop Applications" + }, + "doom": { + "name": "Doom" + }, + "dos": { + "name": "DOS (PC)" + }, + "dreamcast": { + "name": "Sega Dreamcast" + }, + "dc": { + "name": "Sega Dreamcast" + }, + "easyrpg": { + "name": "EasyRPG Game Engine" + }, + "electron": { + "name": "Acorn Electron" + }, + "emulators": { + "name": "Emulators" + }, + "famicom": { + "name": "Nintendo Family Computer" + }, + "fba": { + "name": "FinalBurn Alpha" + }, + "fbneo": { + "name": "FinalBurn Neo" + }, + "fds": { + "name": "Nintendo Famicom Disk System" + }, + "fm7": { + "name": "Fujitsu FM-7" + }, + "fmtowns": { + "name": "Fujitsu FM Towns" + }, + "gamate": { + "name": "Bit Corporation Gamate" + }, + "gameandwatch": { + "name": "Nintendo Game and Watch" + }, + "gamecom": { + "name": "Tiger Electronics Game.com" + }, + "gamegear": { + "name": "Sega Game Gear" + }, + "gg": { + "name": "Sega Game Gear" + }, + "gb": { + "name": "Nintendo Game Boy" + }, + "gba": { + "name": "Nintendo Game Boy Advance" + }, + "gbc": { + "name": "Nintendo Game Boy Color" + }, + "gc": { + "name": "Nintendo GameCube" + }, + "genesis": { + "name": "Sega Genesis" + }, + "gmaster": { + "name": "Hartung Game Master" + }, + "gx4000": { + "name": "Amstrad GX4000" + }, + "intellivision": { + "name": "Mattel Electronics Intellivision" + }, + "j2me": { + "name": "Java 2 Micro Edition (J2ME)" + }, + "laserdisc": { + "name": "LaserDisc Games" + }, + "lcdgames": { + "name": "LCD Handheld Games" + }, + "lowresnx": { + "name": "LowRes NX Fantasy Console" + }, + "lutris": { + "name": "Lutris Open Gaming Platform" + }, + "lutro": { + "name": "Lutro Game Engine" + }, + "macintosh": { + "name": "Apple Macintosh" + }, + "mame": { + "name": "Multiple Arcade Machine Emulator" + }, + "mastersystem": { + "name": "Sega Master System" + }, + "megacd": { + "name": "Sega Mega-CD" + }, + "megacdjp": { + "name": "Sega Mega-CD (Japan)" + }, + "megadrive": { + "name": "Sega Mega Drive" + }, + "megaduck": { + "name": "Creatronic Mega Duck" + }, + "mess": { + "name": "Multi Emulator Super System" + }, + "model2": { + "name": "Sega Model 2" + }, + "moto": { + "name": "Thomson MO/TO Series" + }, + "msx": { + "name": "MSX" + }, + "msx1": { + "name": "MSX1" + }, + "msx2": { + "name": "MSX2" + }, + "msxturbor": { + "name": "MSX Turbo R" + }, + "mugen": { + "name": "M.U.G.E.N Game Engine" + }, + "multivision": { + "name": "Othello Multivision" + }, + "n3ds": { + "name": "Nintendo 3DS" + }, + "n64": { + "name": "Nintendo 64" + }, + "n64dd": { + "name": "Nintendo 64DD" + }, + "naomi": { + "name": "Sega NAOMI" + }, + "naomi2": { + "name": "Sega NAOMI 2" + }, + "naomigd": { + "name": "Sega NAOMI GD-ROM" + }, + "nds": { + "name": "Nintendo DS" + }, + "neogeo": { + "name": "SNK Neo Geo" + }, + "neogeocd": { + "name": "SNK Neo Geo CD" + }, + "neogeocdjp": { + "name": "SNK Neo Geo CD (Japan)" + }, + "nes": { + "name": "Nintendo Entertainment System" + }, + "ngp": { + "name": "SNK Neo Geo Pocket" + }, + "ngpc": { + "name": "SNK Neo Geo Pocket Color" + }, + "odyssey2": { + "name": "Magnavox Odyssey 2" + }, + "openbor": { + "name": "OpenBOR Game Engine" + }, + "palm": { + "name": "Palm OS" + }, + "pc": { + "name": "IBM PC" + }, + "pc88": { + "name": "NEC PC-8800 Series" + }, + "pc98": { + "name": "NEC PC-9800 Series" + }, + "pcarcade": { + "name": "PC Arcade Systems" + }, + "pcengine": { + "name": "NEC PC Engine" + }, + "pcenginecd": { + "name": "NEC PC Engine CD" + }, + "pcfx": { + "name": "NEC PC-FX" + }, + "pico8": { + "name": "PICO-8 Fantasy Console" + }, + "plus4": { + "name": "Commodore Plus/4" + }, + "pokemini": { + "name": "Nintendo Pokémon Mini" + }, + "ports": { + "name": "Ports" + }, + "ps2": { + "name": "Sony PlayStation 2" + }, + "ps3": { + "name": "Sony PlayStation 3" + }, + "psp": { + "name": "Sony PlayStation Portable" + }, + "psvita": { + "name": "Sony PlayStation Vita" + }, + "psx": { + "name": "Sony PlayStation" + }, + "pv1000": { + "name": "Casio PV-1000" + }, + "quake": { + "name": "Quake" + }, + "satellaview": { + "name": "Nintendo Satellaview" + }, + "saturn": { + "name": "Sega Saturn" + }, + "saturnjp": { + "name": "Sega Saturn (Japan)" + }, + "scummvm": { + "name": "ScummVM Game Engine" + }, + "scv": { + "name": "Epoch Super Cassette Vision" + }, + "sega32x": { + "name": "Sega Mega Drive 32X" + }, + "sega32xjp": { + "name": "Sega Super 32X (Japan)" + }, + "sega32xna": { + "name": "Sega Genesis 32X" + }, + "segacd": { + "name": "Sega CD" + }, + "sfc": { + "name": "Nintendo SFC (Super Famicom)" + }, + "sg-1000": { + "name": "Sega SG-1000" + }, + "sgb": { + "name": "Nintendo Super Game Boy" + }, + "snes": { + "name": "Nintendo SNES (Super Nintendo)" + }, + "snesna": { + "name": "Nintendo SNES (Super Nintendo)" + }, + "solarus": { + "name": "Solarus Game Engine" + }, + "spectravideo": { + "name": "Spectravideo" + }, + "stv": { + "name": "Sega Titan Video Game System" + }, + "sufami": { + "name": "Bandai SuFami Turbo" + }, + "supergrafx": { + "name": "NEC SuperGrafx" + }, + "supervision": { + "name": "Watara Supervision" + }, + "supracan": { + "name": "Funtech Super A'Can" + }, + "switch": { + "name": "Nintendo Switch" + }, + "tg-cd": { + "name": "NEC TurboGrafx-CD" + }, + "tg16": { + "name": "NEC TurboGrafx-16" + }, + "ti99": { + "name": "Texas Instruments TI-99" + }, + "tic80": { + "name": "TIC-80 Fantasy Computer" + }, + "to8": { + "name": "Thomson TO8" + }, + "uzebox": { + "name": "Uzebox Open Source Console" + }, + "vectrex": { + "name": "GCE Vectrex" + }, + "vic20": { + "name": "Commodore VIC-20" + }, + "videopac": { + "name": "Philips Videopac G7000" + }, + "virtualboy": { + "name": "Nintendo Virtual Boy" + }, + "vsmile": { + "name": "VTech V.Smile" + }, + "wasm4": { + "name": "WASM-4 Fantasy Console" + }, + "wii": { + "name": "Nintendo Wii" + }, + "wiiu": { + "name": "Nintendo Wii U" + }, + "windows": { + "name": "Microsoft Windows" + }, + "windows3x": { + "name": "Microsoft Windows 3.x" + }, + "windows9x": { + "name": "Microsoft Windows 9x" + }, + "wonderswan": { + "name": "Bandai WonderSwan" + }, + "wonderswancolor": { + "name": "Bandai WonderSwan Color" + }, + "x1": { + "name": "Sharp X1" + }, + "x68000": { + "name": "Sharp X68000" + }, + "xbox": { + "name": "Microsoft Xbox" + }, + "zx81": { + "name": "Sinclair ZX81" + }, + "zxspectrum": { + "name": "Sinclair ZX Spectrum" + } + }, + "emulator": { + "retroarch": { + "description": "RetroArch (Multi-emulator Frontend)", + "name": "RetroArch", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/retroarch/retroarch-guide/", + "launch": "retroarch", + "system": "retroarch", + "properties": [ + { + "cheevos": true, + "cheevos_hardcore": true, + "quick_resume": true + } + ], + "cores": { + "citra_libretro": { + "description": "Nintendo 3DS Libretro Core", + "name": "Citra", + "system": "n3ds", + "properties": [ + { + "abxy_button": true + } + ] + }, + "mame_libretro": { + "description": "MAME: Multiple Arcade Machine Libretro Core", + "name": "MAME", + "system": "arcade", + "properties": [ + { + "tate_mode": true + } + ] + }, + "desmume_libretro": { + "description": "DeSmuME Nintendo DS Libretro Core", + "name": "desmume", + "system": "nds", + "properties": [ + { + "abxy_button": true + } + ] + }, + "melonds_libretro": { + "description": "MelonDS Nintendo DS Libretro Core", + "name": "melonds", + "system": "nds", + "properties": [ + { + "abxy_button": true + } + ] + }, + "swanstation_libretro": { + "name": "SwanStation", + "description": "Swanstation Libretro Core", + "system": "psx", + "properties": [ + { + "widescreen": true, + "borders": true + } + ] + }, + "picodrive_libretro": { + "name": "PicoDrive", + "description": "SEGA MS/MD/CD/32X Libretro Core", + "system": [ + "ms", + "md", + "cd", + "32x" + ], + "properties": [ + { + "widescreen": true, + "borders": true, + "rewind": true + } + ] + }, + "genesisplusgx_libretro": { + "name": "Genesis Plus GX", + "description": "SEGA MS/GG/MD/CD Libretro Core", + "system": [ + "ms", + "gg", + "mc", + "cd" + ], + "properties": [ + { + "widescreen": true, + "borders": true, + "rewind": true + } + ] + }, + "genesisplusgxwide_libretro": { + "name": "Genesis Plus GX Wide", + "description": "SEGA MS/GG/MD/CD Libretro Core for Wide Screen", + "system": [ + "ms", + "gg", + "mc", + "cd" + ], + "properties": [ + { + "widescreen": true, + "rewind": true + } + ] + }, + "mupen64plus-next_libretro": { + "name": "Mupen64Plus-Next", + "description": "Nintendo 64 Libretro Core", + "system": "n64", + "properties": [ + { + "widescreen": true, + "borders": true, + "abxy_button": true + } + ] + }, + "snes9x-current_libretro": { + "name": "Snes9x - Current", + "description": "Super Nintendo Libretro Core", + "system": "snes", + "properties": [ + { + "widescreen": true, + "borders": true, + "rewind": true, + "abxy_button": true + } + ] + }, + "gambatte_libretro": { + "name": "Gambatte", + "description": "Game Boy/Color Libretro Core", + "system": [ + "gb", + "gbc" + ], + "properties": [ + { + "borders": true, + "rewind": true, + "abxy_button": true + } + ] + }, + "mgba_libretro": { + "name": "mGBA", + "description": "Game Boy Advance Libretro Core", + "system": "gba", + "properties": [ + { + "borders": true, + "rewind": true, + "abxy_button": true + } + ] + } + } + }, + "mame": { + "description": "MAME: Multiple Arcade Machine Emulator", + "name": "MAME", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/mame/mame-guide/", + "system": [ + "arcade" + ], + "launch": "mame", + "launch-args": "-inipath /var/config/mame/ini -rompath $(dirname \"$game\") $game" + }, + "citra": { + "description": "Citra Nintendo 3DS Emulator (via Ponzu)", + "name": "Citra (via Ponzu)", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_about/what-is-retrodeck/", + "system": "n3ds", + "ponzu": true, + "launch": "citra-qt", + "properties": [ + { + "abxy_button": true, + "ask_to_exit": true + } + ] + }, + "ruffle": { + "description": "Flash Games emulator", + "name": "Ruffle", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_about/what-is-retrodeck/", + "system": "flash", + "launch": "ruffle-rd-wrapper.sh" + }, + "melonds": { + "description": "MelonDS Nintendo DS Emulator", + "name": "melonds", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/melonds/melonds-guide/", + "system": "nds", + "launch": "melonDS" + }, + "pcsx2": { + "name": "pcsx2", + "description": "PCSX2 Play Station 2 Emulator", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/pcsx2/pcsx2-guide/", + "system": "ps2", + "launch": "pcsx2-qt", + "launch-args": "-batch $game", + "properties": [ + { + "ask_to_exit": true, + "cheevos": true + } + ] + }, + "duckstation": { + "name": "Duckstation", + "description": "PlayStation Emulator", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/duckstation/duckstation-guide/", + "launch": "duckstation-qt", + "launch-args": "-batch $game", + "system": "psx", + "properties": [ + { + "ask_to_exit": true, + "cheevos": true + } + ] + }, + "ppsspp": { + "name": "PPSSPP", + "description": "PPSSPP: PlayStation Portable Emulator", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/ppsspp/ppsspp-guide/", + "launch": "PPSSPPSDL", + "system": "psp", + "properties": [ + { + "cheevos": true, + "cheevos_hardcore": true + } + ] + }, + "vita3k": { + "name": "Vita3k", + "description": "Vita3K PSVita Emulator", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/vita3k/vita3k-guide/", + "system": "psvita", + "launch": "Vita3K", + "launch-args": "-r $game.psvita" + }, + "rpcs3": { + "name": "RPCS3", + "description": "RPCS3 PlayStation 3 Emulator", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/rpcs3/rpcs3-guide/", + "system": "ps3", + "launch": "rpcs3", + "launch-override": "cd $(dirname $game) && rpcs3 $game", + "properties": [ + { + "ask_to_exit": true + } + ] + }, + "ryujinx": { + "name": "Ryujinx", + "description": "Ryujinx Nintendo Switch Emulator", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/ryujinx/ryujinx-guide/", + "system": "switch", + "launch": "Ryujinx.sh" + }, + "yuzu": { + "name": "Yuzu (via Ponzu)", + "description": "Yuzu Nintendo Switch Emulator (via Ponzu)", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_about/what-is-retrodeck/", + "launch": "Yuzu", + "system": "switch", + "launch-args": "-f -g $game", + "ponzu": true, + "abxy_button": true + }, + "dolphin": { + "name": "Dolphin", + "description": "Dolphin Wii and GameCube Emulator", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/dolphin-primehack/dolphin-primehack-guide/", + "launch": "dolphin-emu-wrapper", + "launch-args": "-e $game", + "system": [ + "gc", + "wii" + ], + "properties": [ + { + "abxy_button": true, + "ask_to_exit": true, + "cheevos": true, + "cheevos_hardcore": true, + "universal_dyn_input": true + } + ] + }, + "primehack": { + "name": "PrimeHack", + "description": "A fork of Dolphiin to enhance Metroid Prime experience", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/dolphin-primehack/dolphin-primehack-guide/", + "launch": "primehack-wrapper", + "launch-args": "-e $game", + "system": [ + "wii" + ], + "properties": [ + { + "ask_to_exit": true, + "universal_dyn_input": true + } + ] + }, + "cemu": { + "description": "Wii U emulator", + "name": "Cemu", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/cemu/cemu-guide/", + "system": "wiiu", + "launch": "Cemu-wrapper", + "launch-args": "-g $game", + "properties": [ + { + "abxy_button": true, + "multi_user_config_dir": "Cemu" + } + ] + }, + "xemu": { + "description": "xemu Xbox Emulator", + "name": "xemu", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/xemu/xemu-guide/", + "system": "xbox", + "launch": "xemu", + "launch-args": "-dvd_path $game" + }, + "es-de": { + "description": "ES-DE Emulation Frontend", + "name": "ES-DE", + "url": "https://retrodeck.readthedocs.io/en/latest/wiki_es_de/esde-guide/.", + "launch": "es-de" + } } - \ No newline at end of file +} From 73e22267ecb346c056061fc7d94ecad20484f731 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Tue, 10 Sep 2024 14:40:30 +0900 Subject: [PATCH 04/23] REPO: added lint hooks and hooks installer [skip ci] --- developer_toolbox/hooks/pre-commit | 15 +++++++++++++++ developer_toolbox/install_hooks.sh | 4 ++++ 2 files changed, 19 insertions(+) create mode 100755 developer_toolbox/hooks/pre-commit create mode 100755 developer_toolbox/install_hooks.sh diff --git a/developer_toolbox/hooks/pre-commit b/developer_toolbox/hooks/pre-commit new file mode 100755 index 00000000..9cb4b48f --- /dev/null +++ b/developer_toolbox/hooks/pre-commit @@ -0,0 +1,15 @@ +#!/bin/bash +# A pre-commit hook to lint features.json if it is edited + +# Check if any path contains 'features.json' +if git diff --cached --name-only | grep -q 'config/retrodeck/reference_lists/features.json'; then + # Run the linting script + echo "Linting config/retrodeck/reference_lists/features.json..." + if ! bash developer_toolbox/lint_features.json.sh; then + echo "Linting failed. Please fix the issues and try again." + exit 1 # Exit with a non-zero status to block the commit + fi +fi + +# Continue with the commit if all checks passed +exit 0 diff --git a/developer_toolbox/install_hooks.sh b/developer_toolbox/install_hooks.sh new file mode 100755 index 00000000..d2510ce0 --- /dev/null +++ b/developer_toolbox/install_hooks.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +mkdir -p .git/hooks +cp -f developer_toolbox/hooks/* .git/hooks \ No newline at end of file From 1e84103059b7b2a3c13bdb397fb9cbd2561a9cde Mon Sep 17 00:00:00 2001 From: XargonWan Date: Tue, 10 Sep 2024 14:50:14 +0900 Subject: [PATCH 05/23] REPO: added lint manifest POC [skip ci] --- developer_toolbox/hooks/pre-commit | 10 ++++++++++ developer_toolbox/lint_manifest.sh | 3 +++ 2 files changed, 13 insertions(+) create mode 100755 developer_toolbox/lint_manifest.sh diff --git a/developer_toolbox/hooks/pre-commit b/developer_toolbox/hooks/pre-commit index 9cb4b48f..31210b0a 100755 --- a/developer_toolbox/hooks/pre-commit +++ b/developer_toolbox/hooks/pre-commit @@ -11,5 +11,15 @@ if git diff --cached --name-only | grep -q 'config/retrodeck/reference_lists/fea fi fi +# Lint Manifest +# if git diff --cached --name-only | grep -q 'net.retrodeck.retrodeck.yml'; then +# # Run the linting script +# echo "Linting net.retrodeck.retrodeck.yml..." +# if ! bash developer_toolbox/lint_manifest.sh; then +# echo "Linting failed. Please fix the issues and try again." +# exit 1 # Exit with a non-zero status to block the commit +# fi +# fi + # Continue with the commit if all checks passed exit 0 diff --git a/developer_toolbox/lint_manifest.sh b/developer_toolbox/lint_manifest.sh new file mode 100755 index 00000000..9147e142 --- /dev/null +++ b/developer_toolbox/lint_manifest.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +yamllint net.retrodeck.retrodeck.yml From e2ef2e8823b9eee29025e51de6b428860936b71b Mon Sep 17 00:00:00 2001 From: XargonWan Date: Tue, 10 Sep 2024 18:41:40 +0900 Subject: [PATCH 06/23] RUN_GAME: now it's scraping the commands from es_systems and es_find_rules --- functions/other_functions.sh | 201 ++++++++++++++++++++++------------- 1 file changed, 128 insertions(+), 73 deletions(-) diff --git a/functions/other_functions.sh b/functions/other_functions.sh index 53ebf2d4..7b6fe033 100644 --- a/functions/other_functions.sh +++ b/functions/other_functions.sh @@ -892,12 +892,56 @@ start_retrodeck() { es-de } +find_emulator() { + local emulator_name=$1 + local found_path="" + + # Search the es_find_rules.xml file for the emulator + emulator_section=$(xmllint --xpath "//emulator[@name='$emulator_name']" "/app/share/es-de/resources/systems/linux/es_find_rules.xml" 2>/dev/null) + + if [ -z "$emulator_section" ]; then + echo "Emulator not found: $emulator_name" + return 1 + fi + + # Search systempath entries + while IFS= read -r line; do + command_path=$(echo "$line" | sed -n 's/.*\(.*\)<\/entry>.*/\1/p') + if [ -x "$(command -v $command_path)" ]; then + found_path=$command_path + break + fi + done <<< "$(echo "$emulator_section" | xmllint --xpath "//rule[@type='systempath']/entry" - 2>/dev/null)" + + # If not found, search staticpath entries + if [ -z "$found_path" ]; then + while IFS= read -r line; do + command_path=$(eval echo "$line" | sed -n 's/.*\(.*\)<\/entry>.*/\1/p') + if [ -x "$command_path" ]; then + found_path=$command_path + break + fi + done <<< "$(echo "$emulator_section" | xmllint --xpath "//rule[@type='staticpath']/entry" - 2>/dev/null)" + fi + + if [ -z "$found_path" ]; then + echo "No valid path found for emulator: $emulator_name" + return 1 + else + echo "$found_path" + return 0 + fi +} + run_game() { # Initialize variables emulator="" system="" + # Percorso al file XML es_systems.xml + xml_file="/app/share/es-de/resources/systems/linux/es_systems.xml" + # Parse options while getopts ":e:s:" opt; do case ${opt} in @@ -929,87 +973,98 @@ run_game() { system=$(echo "$game" | grep -oP '(?<=roms/)[^/]+') fi - log d "Emulator: $emulator" - log d "System: $system" - log d "Game: $game" + # Funzione per sostituire i placeholder + substitute_placeholders() { + local cmd="$1" + local rom_path="$game" + local rom_dir=$(dirname "$rom_path") + local base_name=$(basename "$rom_path" .ext) + local file_name=$(basename "$rom_path") + local rom_raw="$rom_path" + local rom_dir_raw="$rom_dir" + local es_path="/path/dell/emulatore" + local emulator_path="/path/dell/emulatore/bin" - # Query the features JSON for emulators that support the system - local emulators=$(jq -r --arg system "$system" ' - .emulator | to_entries[] | - select( - (.value.system == $system) or - (.value.system[]? == $system) - ) | .key' "$features") + # Function to replace %EMULATOR_SOMETHING% with the actual path of the emulator + replace_emulator_placeholder() { + local placeholder=$1 + local emulator_name=${placeholder//"%EMULATOR_"/} # Extract emulator name from placeholder + emulator_name=${emulator_name//"%"/} # Remove the ending "%" + local emulator_exec=$(find_emulator "$emulator_name") + + if [[ -z "$emulator_exec" ]]; then + echo "Error: Emulator '$emulator_name' not found." + exit 1 + fi - # Check if the system is handled by RetroArch cores - local retroarch_cores=$(jq -r --arg system "$system" ' - .emulator.retroarch.cores | to_entries[] | - select( - .value.system == $system or - (.value.system[]? == $system) - ) | .key' "$features") + echo "$emulator_exec" + } - # if the emulator is given and it's a retroarch core just execute it - if [[ "$emulator" == *"_libretro" ]]; then - local core_path="/var/config/retroarch/cores/$emulator.so" - log d "Running RetroArch core: $core_path" - log d "Command: retroarch -L $core_path \"$game\"" - eval "retroarch -L $core_path \"$game\"" - return 1 - fi + # Use sed to find %EMULATOR_*% and replace with actual emulator executable by calling find_emulator + cmd=$(echo "$cmd" | sed -r 's/%EMULATOR_[A-Z0-9_]+%/$(replace_emulator_placeholder "&")/g') - # If the system is handled by RetroArch cores, add them to the list of emulators - if [[ -n "$retroarch_cores" ]]; then - emulators=$(echo -e "$emulators\n$retroarch_cores") - fi + # Sourcing the emulator command to ensure immediate execution of placeholders + cmd=$(eval echo "$cmd") - local pretty_system=$(jq -r --arg system "$system" '.system[$system].name' "$features") + # Ensure that paths with spaces are properly quoted + cmd="${cmd//"%ROM%"/"\"$rom_path\""}" + cmd="${cmd//"%BASENAME%"/"\"$base_name\""}" + cmd="${cmd//"%FILENAME%"/"\"$file_name\""}" + cmd="${cmd//"%ROMRAW%"/"\"$rom_raw\""}" + cmd="${cmd//"%ROMPATH%"/"\"$rom_dir\""}" + cmd="${cmd//"%ESPATH%"/"\"$es_path\""}" + cmd="${cmd//"%EMUDIR%"/"\"$emulator_path\""}" + cmd="${cmd//"%GAMEDIR%"/"\"$rom_dir\""}" + cmd="${cmd//"%GAMEDIRRAW%"/"\"$rom_dir_raw\""}" + cmd="${cmd//"%CORE_RETROARCH%"/"\"/var/config/retroarch/cores\""}" - # Check if multiple emulators are found and prompt the user to select one with zenity - if [[ $(echo "$emulators" | wc -l) -gt 1 ]]; then - emulator=$(echo "$emulators" | zenity --list --title="Select Emulator" --text="Multiple emulators found for $pretty_system. Select one to run." --column="Emulator") - else - emulator="$emulators" - fi + echo "$cmd" +} - # If no emulator was selected, exit - if [[ -z "$emulator" ]]; then - log e "No emulator selected. Exiting." - return 1 - fi - log d "Run game: selected emulator $emulator" - - # Handle RetroArch core separately - if [[ "$emulator" == *"_libretro" ]]; then - local core_path="/var/config/retroarch/cores/$emulator.so" - log d "Running RetroArch core: $core_path" - log d "Command: retroarch -L $core_path \"$game\"" - eval "retroarch -L $core_path \"$game\"" - else - # Check if launch-override exists - local launch_override=$(jq -r ".emulator.$emulator.\"launch-override\"" "$features") - if [[ "$launch_override" != "null" ]]; then - # Use launch-override - launch_override=${launch_override//\$game/\"$game\"} - log d "Using launch-override: $launch_override" - eval "$launch_override" - else - # Use standard launch and launch-args - local launch_command=$(jq -r ".emulator.$emulator.launch" "$features") - local launch_args=$(jq -r ".emulator.$emulator.\"launch-args\"" "$features") - log d "launch args: $launch_args" - - # Only add launch_args if they are not null - if [[ "$launch_args" != "null" ]]; then - # Replace $game in launch_args with the actual game path, quoting it to handle spaces - launch_args=${launch_args//\$game/\"$game\"} - log d "Command: \"$launch_command $launch_args\"" - eval "$launch_command $launch_args" - else - log d "Command: \"$launch_command\"" - eval "$launch_command \"$game\"" - fi + # Estrazione dei comandi da es_systems.xml per il sistema selezionato +find_system_commands() { + local system_name=$system + # Use xmllint to extract the system commands from the XML + system_section=$(xmllint --xpath "//system[name='$system_name']" "$xml_file" 2>/dev/null) + + if [ -z "$system_section" ]; then + echo "System not found: $system_name" + exit 1 fi + + # Extract commands and labels + commands=$(echo "$system_section" | xmllint --xpath "//command" - 2>/dev/null) + + # Prepare Zenity command list + command_list=() + while IFS= read -r line; do + label=$(echo "$line" | sed -n 's/.*label="\([^"]*\)".*/\1/p') + command=$(echo "$line" | sed -n 's/.*]*>\(.*\)<\/command>.*/\1/p') + + # Substitute placeholders in the command + command=$(substitute_placeholders "$command") + + # Add label and command to Zenity list (label first, command second) + command_list+=("$label" "$command") + done <<< "$commands" + + # Show the list with Zenity and return the **command** (second column) selected + selected_command=$(zenity --list --title="Select an emulator for $system_name" --column="Emulator" --column="Command" "${command_list[@]}" --width=800 --height=400 --print-column=2) + + echo "$selected_command" +} + + # Se l'emulatore non è specificato, chiedi all'utente di selezionarlo o prendilo dal file XML + if [[ -z "$emulator" ]]; then + emulator=$(find_system_commands) + fi + + if [[ -n "$emulator" ]]; then + log d "Running selected emulator: $emulator" + eval "$emulator" + else + log e "No emulator found or selected. Exiting." + return 1 fi } \ No newline at end of file From 21984292c0c7e024b07e5718dfd5468ae7f9f6d0 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Tue, 10 Sep 2024 20:41:54 +0900 Subject: [PATCH 07/23] RUN_GAME: hiding full commands in zenity list --- functions/other_functions.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/functions/other_functions.sh b/functions/other_functions.sh index 7b6fe033..8543f5bd 100644 --- a/functions/other_functions.sh +++ b/functions/other_functions.sh @@ -933,6 +933,10 @@ find_emulator() { fi } + +# TODO: %INJECT% is not yet working (Dolphin, rpcs3, vita3k) +# TODO: add the logic of alt emulator and default emulator + run_game() { # Initialize variables @@ -1050,7 +1054,10 @@ find_system_commands() { done <<< "$commands" # Show the list with Zenity and return the **command** (second column) selected - selected_command=$(zenity --list --title="Select an emulator for $system_name" --column="Emulator" --column="Command" "${command_list[@]}" --width=800 --height=400 --print-column=2) + selected_command=$(zenity --list \ + --title="Select an emulator for $system_name" \ + --column="Emulator" --column="Hidden Command" "${command_list[@]}" \ + --width=800 --height=400 --print-column=2 --hide-column=2) echo "$selected_command" } From c4a80119af93afc101c756c6fe2104f3a582d8b7 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Tue, 10 Sep 2024 21:36:28 +0900 Subject: [PATCH 08/23] RUN_GAME: adding %INJECT% logic --- functions/other_functions.sh | 152 ++++++++++++++++++++--------------- 1 file changed, 89 insertions(+), 63 deletions(-) diff --git a/functions/other_functions.sh b/functions/other_functions.sh index 8543f5bd..6dc58a4c 100644 --- a/functions/other_functions.sh +++ b/functions/other_functions.sh @@ -900,7 +900,7 @@ find_emulator() { emulator_section=$(xmllint --xpath "//emulator[@name='$emulator_name']" "/app/share/es-de/resources/systems/linux/es_find_rules.xml" 2>/dev/null) if [ -z "$emulator_section" ]; then - echo "Emulator not found: $emulator_name" + log e "Emulator not found: $emulator_name" return 1 fi @@ -925,16 +925,16 @@ find_emulator() { fi if [ -z "$found_path" ]; then - echo "No valid path found for emulator: $emulator_name" + log e "No valid path found for emulator: $emulator_name" return 1 else + log d "Found emulator: \"$found_path\"" echo "$found_path" return 0 fi } -# TODO: %INJECT% is not yet working (Dolphin, rpcs3, vita3k) # TODO: add the logic of alt emulator and default emulator run_game() { @@ -943,7 +943,7 @@ run_game() { emulator="" system="" - # Percorso al file XML es_systems.xml + # Path to the es_systems.xml file xml_file="/app/share/es-de/resources/systems/linux/es_systems.xml" # Parse options @@ -977,42 +977,68 @@ run_game() { system=$(echo "$game" | grep -oP '(?<=roms/)[^/]+') fi - # Funzione per sostituire i placeholder + log d "Game: \"$game\"" + log d "System: \"$system\"" + + # Function to handle the %INJECT% placeholder + handle_inject_placeholder() { + local cmd="$1" + + # Check if .esprefix file exists + local inject_file="${game}.esprefix" + + log d "Checking if \"${game}.esprefix\" exists" + + if [[ ! -f "$inject_file" ]]; then + # If the inject file does not exist, strip all forms of %INJECT% from the command + + log d "\"${game}.esprefix\" not existing" + + # This handles cases where %INJECT% might be in different forms: + # Strip %INJECT%="value", %INJECT%="", or just %INJECT%= + cmd="${cmd//%INJECT%=\"*\"/}" + cmd="${cmd//%INJECT%=/}" + cmd="${cmd//%INJECT%/}" + + cmd="${cmd//%BASENAME%.esprefix=\"*\"/}" + cmd="${cmd//%BASENAME%.esprefix=/}" + cmd="${cmd//%BASENAME%.esprefix/}" + + log d "Returning the following command:$cmd" + + echo "$cmd" + return + fi + + # If the .esprefix file exists, process its content + inject_content=$(head -c 4096 "$inject_file") + log i ".esprefix file found, injecting \"$inject_content\"" + cmd="${cmd//%INJECT%=\"$inject_file\"/$inject_content}" + echo "$cmd" + } + + + # Function to substitute the placeholders substitute_placeholders() { local cmd="$1" local rom_path="$game" local rom_dir=$(dirname "$rom_path") - local base_name=$(basename "$rom_path" .ext) + local base_name=$(basename "$rom_path" .psvita) # Ensure the .psvita extension is stripped local file_name=$(basename "$rom_path") local rom_raw="$rom_path" local rom_dir_raw="$rom_dir" - local es_path="/path/dell/emulatore" - local emulator_path="/path/dell/emulatore/bin" + local es_path="" + local emulator_path="" - # Function to replace %EMULATOR_SOMETHING% with the actual path of the emulator - replace_emulator_placeholder() { - local placeholder=$1 - local emulator_name=${placeholder//"%EMULATOR_"/} # Extract emulator name from placeholder - emulator_name=${emulator_name//"%"/} # Remove the ending "%" - local emulator_exec=$(find_emulator "$emulator_name") - - if [[ -z "$emulator_exec" ]]; then - echo "Error: Emulator '$emulator_name' not found." - exit 1 - fi + # Handle %INJECT% placeholder if present + cmd=$(handle_inject_placeholder "$cmd") - echo "$emulator_exec" - } - - # Use sed to find %EMULATOR_*% and replace with actual emulator executable by calling find_emulator + # Substitute emulator path cmd=$(echo "$cmd" | sed -r 's/%EMULATOR_[A-Z0-9_]+%/$(replace_emulator_placeholder "&")/g') - # Sourcing the emulator command to ensure immediate execution of placeholders - cmd=$(eval echo "$cmd") - - # Ensure that paths with spaces are properly quoted + # Ensure that paths with spaces are properly quoted and substitute other placeholders cmd="${cmd//"%ROM%"/"\"$rom_path\""}" - cmd="${cmd//"%BASENAME%"/"\"$base_name\""}" + cmd="${cmd//"%BASENAME%"/"\"$base_name\""}" # Proper base name without extra .psvita cmd="${cmd//"%FILENAME%"/"\"$file_name\""}" cmd="${cmd//"%ROMRAW%"/"\"$rom_raw\""}" cmd="${cmd//"%ROMPATH%"/"\"$rom_dir\""}" @@ -1020,55 +1046,55 @@ run_game() { cmd="${cmd//"%EMUDIR%"/"\"$emulator_path\""}" cmd="${cmd//"%GAMEDIR%"/"\"$rom_dir\""}" cmd="${cmd//"%GAMEDIRRAW%"/"\"$rom_dir_raw\""}" - cmd="${cmd//"%CORE_RETROARCH%"/"\"/var/config/retroarch/cores\""}" + cmd="${cmd//"%CORE_RETROARCH%"/"/var/config/retroarch/cores"}" + log d "Final command: $cmd" # Log the final command for debugging echo "$cmd" } + # Extracting the commands from es_systems.xml for the selected system + find_system_commands() { + local system_name=$system + # Use xmllint to extract the system commands from the XML + system_section=$(xmllint --xpath "//system[name='$system_name']" "$xml_file" 2>/dev/null) + + if [ -z "$system_section" ]; then + log e "System not found: $system_name" + exit 1 + fi - # Estrazione dei comandi da es_systems.xml per il sistema selezionato -find_system_commands() { - local system_name=$system - # Use xmllint to extract the system commands from the XML - system_section=$(xmllint --xpath "//system[name='$system_name']" "$xml_file" 2>/dev/null) - - if [ -z "$system_section" ]; then - echo "System not found: $system_name" - exit 1 - fi + # Extract commands and labels + commands=$(echo "$system_section" | xmllint --xpath "//command" - 2>/dev/null) - # Extract commands and labels - commands=$(echo "$system_section" | xmllint --xpath "//command" - 2>/dev/null) + # Prepare Zenity command list + command_list=() + while IFS= read -r line; do + label=$(echo "$line" | sed -n 's/.*label="\([^"]*\)".*/\1/p') + command=$(echo "$line" | sed -n 's/.*]*>\(.*\)<\/command>.*/\1/p') + + # Substitute placeholders in the command + command=$(substitute_placeholders "$command") + + # Add label and command to Zenity list (label first, command second) + command_list+=("$label" "$command") + done <<< "$commands" - # Prepare Zenity command list - command_list=() - while IFS= read -r line; do - label=$(echo "$line" | sed -n 's/.*label="\([^"]*\)".*/\1/p') - command=$(echo "$line" | sed -n 's/.*]*>\(.*\)<\/command>.*/\1/p') - - # Substitute placeholders in the command - command=$(substitute_placeholders "$command") - - # Add label and command to Zenity list (label first, command second) - command_list+=("$label" "$command") - done <<< "$commands" + # Show the list with Zenity and return the **command** (second column) selected + selected_command=$(zenity --list \ + --title="Select an emulator for $system_name" \ + --column="Emulator" --column="Hidden Command" "${command_list[@]}" \ + --width=800 --height=400 --print-column=2 --hide-column=2) - # Show the list with Zenity and return the **command** (second column) selected - selected_command=$(zenity --list \ - --title="Select an emulator for $system_name" \ - --column="Emulator" --column="Hidden Command" "${command_list[@]}" \ - --width=800 --height=400 --print-column=2 --hide-column=2) + echo "$selected_command" + } - echo "$selected_command" -} - - # Se l'emulatore non è specificato, chiedi all'utente di selezionarlo o prendilo dal file XML + # If the emulator is not specified, ask the user to select it or get it from the XML file if [[ -z "$emulator" ]]; then emulator=$(find_system_commands) fi if [[ -n "$emulator" ]]; then - log d "Running selected emulator: $emulator" + log d "Running: $emulator" eval "$emulator" else log e "No emulator found or selected. Exiting." From 38806dabc1d1d5ec52bfe344aeaa225ead54588a Mon Sep 17 00:00:00 2001 From: XargonWan Date: Tue, 10 Sep 2024 22:13:26 +0900 Subject: [PATCH 09/23] RUN_GAME: working but looping --- functions/other_functions.sh | 183 +++++++++++++++++++---------------- 1 file changed, 102 insertions(+), 81 deletions(-) diff --git a/functions/other_functions.sh b/functions/other_functions.sh index 6dc58a4c..2330dcb5 100644 --- a/functions/other_functions.sh +++ b/functions/other_functions.sh @@ -936,6 +936,7 @@ find_emulator() { # TODO: add the logic of alt emulator and default emulator +# TODO: if the emulator is only one just skip the zenity and run it run_game() { @@ -983,109 +984,129 @@ run_game() { # Function to handle the %INJECT% placeholder handle_inject_placeholder() { local cmd="$1" - - # Check if .esprefix file exists - local inject_file="${game}.esprefix" - log d "Checking if \"${game}.esprefix\" exists" - - if [[ ! -f "$inject_file" ]]; then - # If the inject file does not exist, strip all forms of %INJECT% from the command - - log d "\"${game}.esprefix\" not existing" + # Find all occurrences of %INJECT%=something + while [[ "$cmd" =~ %INJECT%=(.*) ]]; do + inject_file="${BASH_REMATCH[1]}" # Extract the file name - # This handles cases where %INJECT% might be in different forms: - # Strip %INJECT%="value", %INJECT%="", or just %INJECT%= - cmd="${cmd//%INJECT%=\"*\"/}" - cmd="${cmd//%INJECT%=/}" - cmd="${cmd//%INJECT%/}" + # Prepend the directory path to ensure we have the full path to the file + inject_file_full_path="$rom_dir/$inject_file" - cmd="${cmd//%BASENAME%.esprefix=\"*\"/}" - cmd="${cmd//%BASENAME%.esprefix=/}" - cmd="${cmd//%BASENAME%.esprefix/}" + log d "Found %INJECT% pointing to file \"$inject_file_full_path\"" - log d "Returning the following command:$cmd" - - echo "$cmd" - return - fi + # Check if the file exists + if [[ -f "$inject_file_full_path" ]]; then + # Read the content of the file + inject_content=$(cat "$inject_file_full_path") + log i "File \"$inject_file_full_path\" found, injecting content \"$inject_content\"" + + # Replace the %INJECT% placeholder with the content of the file + cmd="${cmd//%INJECT%=$inject_file/$inject_content}" + else + log e "File \"$inject_file_full_path\" not found. Removing %INJECT% placeholder." + # If the file does not exist, just remove the placeholder + cmd="${cmd//%INJECT%=$inject_file/}" + fi + done - # If the .esprefix file exists, process its content - inject_content=$(head -c 4096 "$inject_file") - log i ".esprefix file found, injecting \"$inject_content\"" - cmd="${cmd//%INJECT%=\"$inject_file\"/$inject_content}" + log d "Returning the command with injected content: $cmd" echo "$cmd" } +# Function to replace %EMULATOR_SOMETHING% with the actual path of the emulator +replace_emulator_placeholder() { + local placeholder=$1 + # Extract emulator name from placeholder without changing case + local emulator_name="${placeholder//"%EMULATOR_"/}" # Extract emulator name after %EMULATOR_ + emulator_name="${emulator_name//"%"/}" # Remove the trailing % + + # Use the find_emulator function to get the emulator path using the correct casing + local emulator_exec=$(find_emulator "$emulator_name") + + if [[ -z "$emulator_exec" ]]; then + log e "Emulator '$emulator_name' not found." + exit 1 + fi + echo "$emulator_exec" +} # Function to substitute the placeholders substitute_placeholders() { - local cmd="$1" - local rom_path="$game" - local rom_dir=$(dirname "$rom_path") - local base_name=$(basename "$rom_path" .psvita) # Ensure the .psvita extension is stripped - local file_name=$(basename "$rom_path") - local rom_raw="$rom_path" - local rom_dir_raw="$rom_dir" - local es_path="" - local emulator_path="" + local cmd="$1" + local rom_path="$game" + local rom_dir=$(dirname "$rom_path") + + # Strip all file extensions from the base name + local base_name=$(basename "$rom_path") + base_name="${base_name%%.*}" - # Handle %INJECT% placeholder if present - cmd=$(handle_inject_placeholder "$cmd") + local file_name=$(basename "$rom_path") + local rom_raw="$rom_path" + local rom_dir_raw="$rom_dir" + local es_path="" + local emulator_path="" - # Substitute emulator path - cmd=$(echo "$cmd" | sed -r 's/%EMULATOR_[A-Z0-9_]+%/$(replace_emulator_placeholder "&")/g') + # Manually replace %EMULATOR_*% placeholders + while [[ "$cmd" =~ (%EMULATOR_[A-Z0-9_]+%) ]]; do + placeholder="${BASH_REMATCH[1]}" + emulator_path=$(replace_emulator_placeholder "$placeholder") + cmd="${cmd//$placeholder/$emulator_path}" + done - # Ensure that paths with spaces are properly quoted and substitute other placeholders - cmd="${cmd//"%ROM%"/"\"$rom_path\""}" - cmd="${cmd//"%BASENAME%"/"\"$base_name\""}" # Proper base name without extra .psvita - cmd="${cmd//"%FILENAME%"/"\"$file_name\""}" - cmd="${cmd//"%ROMRAW%"/"\"$rom_raw\""}" - cmd="${cmd//"%ROMPATH%"/"\"$rom_dir\""}" - cmd="${cmd//"%ESPATH%"/"\"$es_path\""}" - cmd="${cmd//"%EMUDIR%"/"\"$emulator_path\""}" - cmd="${cmd//"%GAMEDIR%"/"\"$rom_dir\""}" - cmd="${cmd//"%GAMEDIRRAW%"/"\"$rom_dir_raw\""}" - cmd="${cmd//"%CORE_RETROARCH%"/"/var/config/retroarch/cores"}" + # Substitute %BASENAME% and other placeholders + cmd="${cmd//"%BASENAME%"/"$base_name"}" + cmd="${cmd//"%FILENAME%"/"$file_name"}" + cmd="${cmd//"%ROMRAW%"/"$rom_raw"}" + cmd="${cmd//"%ROMPATH%"/"$rom_dir"}" + + # Ensure paths are quoted correctly + cmd="${cmd//"%ROM%"/"\"$rom_path\""}" + cmd="${cmd//"%GAMEDIR%"/"\"$rom_dir\""}" + cmd="${cmd//"%GAMEDIRRAW%"/"\"$rom_dir_raw\""}" + cmd="${cmd//"%CORE_RETROARCH%"/"/var/config/retroarch/cores"}" - log d "Final command: $cmd" # Log the final command for debugging - echo "$cmd" -} + log d "Command after %BASENAME% and other substitutions: $cmd" + + # Now handle %INJECT% after %BASENAME% has been substituted + cmd=$(handle_inject_placeholder "$cmd") + + echo "$cmd" + } # Extracting the commands from es_systems.xml for the selected system find_system_commands() { - local system_name=$system - # Use xmllint to extract the system commands from the XML - system_section=$(xmllint --xpath "//system[name='$system_name']" "$xml_file" 2>/dev/null) - - if [ -z "$system_section" ]; then - log e "System not found: $system_name" - exit 1 - fi + local system_name=$system + # Use xmllint to extract the system commands from the XML + system_section=$(xmllint --xpath "//system[name='$system_name']" "$xml_file" 2>/dev/null) + + if [ -z "$system_section" ]; then + log e "System not found: $system_name" + exit 1 + fi - # Extract commands and labels - commands=$(echo "$system_section" | xmllint --xpath "//command" - 2>/dev/null) + # Extract commands and labels + commands=$(echo "$system_section" | xmllint --xpath "//command" - 2>/dev/null) - # Prepare Zenity command list - command_list=() - while IFS= read -r line; do - label=$(echo "$line" | sed -n 's/.*label="\([^"]*\)".*/\1/p') - command=$(echo "$line" | sed -n 's/.*]*>\(.*\)<\/command>.*/\1/p') - - # Substitute placeholders in the command - command=$(substitute_placeholders "$command") - - # Add label and command to Zenity list (label first, command second) - command_list+=("$label" "$command") - done <<< "$commands" + # Prepare Zenity command list + command_list=() + while IFS= read -r line; do + label=$(echo "$line" | sed -n 's/.*label="\([^"]*\)".*/\1/p') + command=$(echo "$line" | sed -n 's/.*]*>\(.*\)<\/command>.*/\1/p') + + # Substitute placeholders in the command + command=$(substitute_placeholders "$command") + + # Add label and command to Zenity list (label first, command second) + command_list+=("$label" "$command") + done <<< "$commands" - # Show the list with Zenity and return the **command** (second column) selected - selected_command=$(zenity --list \ - --title="Select an emulator for $system_name" \ - --column="Emulator" --column="Hidden Command" "${command_list[@]}" \ - --width=800 --height=400 --print-column=2 --hide-column=2) + # Show the list with Zenity and return the **command** (second column) selected + selected_command=$(zenity --list \ + --title="Select an emulator for $system_name" \ + --column="Emulator" --column="Hidden Command" "${command_list[@]}" \ + --width=800 --height=400 --print-column=2 --hide-column=2) - echo "$selected_command" + echo "$selected_command" } # If the emulator is not specified, ask the user to select it or get it from the XML file From d0644c82e600722aab5cc7ca724516ddef1b8579 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Tue, 10 Sep 2024 22:22:30 +0900 Subject: [PATCH 10/23] RUN_GAME: working but looping - fix --- functions/other_functions.sh | 57 ++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/functions/other_functions.sh b/functions/other_functions.sh index 2330dcb5..9826868a 100644 --- a/functions/other_functions.sh +++ b/functions/other_functions.sh @@ -981,37 +981,42 @@ run_game() { log d "Game: \"$game\"" log d "System: \"$system\"" - # Function to handle the %INJECT% placeholder - handle_inject_placeholder() { - local cmd="$1" +# Function to handle the %INJECT% placeholder +handle_inject_placeholder() { + local cmd="$1" + local rom_dir=$(dirname "$game") # Define rom_dir based on the game path - # Find all occurrences of %INJECT%=something - while [[ "$cmd" =~ %INJECT%=(.*) ]]; do - inject_file="${BASH_REMATCH[1]}" # Extract the file name + # Find all occurrences of %INJECT%=something + while [[ "$cmd" =~ %INJECT%=(.*) ]]; do + inject_file="${BASH_REMATCH[1]}" # Extract the file name + + # Prepend the directory path to ensure we have the full path to the file + inject_file_full_path="$rom_dir/$inject_file" + + log d "Found %INJECT% pointing to file \"$inject_file_full_path\"" + + # Check if the file exists (no escaping needed, just quotes) + if [[ -f "$inject_file_full_path" ]]; then + # Read the content of the file + inject_content=$(cat "$inject_file_full_path") + log i "File \"$inject_file_full_path\" found, injecting content \"$inject_content\"" + + # Replace the %INJECT% placeholder with the content of the file + cmd="${cmd//%INJECT%=$inject_file/$inject_content}" + else + log e "File \"$inject_file_full_path\" not found. Removing %INJECT% placeholder." + # If the file does not exist, just remove the placeholder + cmd="${cmd//%INJECT%=$inject_file/}" + fi + done + + log d "Returning the command with injected content: $cmd" + echo "$cmd" +} - # Prepend the directory path to ensure we have the full path to the file - inject_file_full_path="$rom_dir/$inject_file" - log d "Found %INJECT% pointing to file \"$inject_file_full_path\"" - # Check if the file exists - if [[ -f "$inject_file_full_path" ]]; then - # Read the content of the file - inject_content=$(cat "$inject_file_full_path") - log i "File \"$inject_file_full_path\" found, injecting content \"$inject_content\"" - - # Replace the %INJECT% placeholder with the content of the file - cmd="${cmd//%INJECT%=$inject_file/$inject_content}" - else - log e "File \"$inject_file_full_path\" not found. Removing %INJECT% placeholder." - # If the file does not exist, just remove the placeholder - cmd="${cmd//%INJECT%=$inject_file/}" - fi - done - log d "Returning the command with injected content: $cmd" - echo "$cmd" - } # Function to replace %EMULATOR_SOMETHING% with the actual path of the emulator replace_emulator_placeholder() { From 6496e1f051ad222df7987cd6d805000c86cfd816 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Wed, 11 Sep 2024 10:18:03 +0900 Subject: [PATCH 11/23] RUN_GAME: fixed %INJECT% placeholder in both of the cases --- functions/other_functions.sh | 59 +++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/functions/other_functions.sh b/functions/other_functions.sh index 9826868a..42fe9701 100644 --- a/functions/other_functions.sh +++ b/functions/other_functions.sh @@ -984,29 +984,37 @@ run_game() { # Function to handle the %INJECT% placeholder handle_inject_placeholder() { local cmd="$1" - local rom_dir=$(dirname "$game") # Define rom_dir based on the game path + local rom_dir=$(dirname "$game") # Get the ROM directory based on the game path - # Find all occurrences of %INJECT%=something - while [[ "$cmd" =~ %INJECT%=(.*) ]]; do - inject_file="${BASH_REMATCH[1]}" # Extract the file name + # Find and process all occurrences of %INJECT%='something'.extension + while [[ "$cmd" =~ (%INJECT%=\'([^\']+)\')(.[^ ]+)? ]]; do + inject_file="${BASH_REMATCH[2]}" # Extract the quoted file name + extension="${BASH_REMATCH[3]}" # Extract the extension (if any) + inject_file_full_path="$rom_dir/$inject_file$extension" # Form the full path - # Prepend the directory path to ensure we have the full path to the file - inject_file_full_path="$rom_dir/$inject_file" + log d "Found inject part: %INJECT%='$inject_file'$extension" - log d "Found %INJECT% pointing to file \"$inject_file_full_path\"" - - # Check if the file exists (no escaping needed, just quotes) + # Check if the file exists if [[ -f "$inject_file_full_path" ]]; then - # Read the content of the file - inject_content=$(cat "$inject_file_full_path") - log i "File \"$inject_file_full_path\" found, injecting content \"$inject_content\"" - - # Replace the %INJECT% placeholder with the content of the file - cmd="${cmd//%INJECT%=$inject_file/$inject_content}" + # Read the content of the file and replace newlines with spaces + inject_content=$(cat "$inject_file_full_path" | tr '\n' ' ') + log i "File \"$inject_file_full_path\" found. Replacing %INJECT% with content." + + # Escape special characters in the inject part for the replacement + escaped_inject_part=$(printf '%s' "%INJECT%='$inject_file'$extension" | sed 's/[]\/$*.^[]/\\&/g') + + # Replace the entire %INJECT%=...'something'.extension part with the file content + cmd=$(echo "$cmd" | sed "s|$escaped_inject_part|$inject_content|g") + + log d "Replaced cmd: $cmd" else log e "File \"$inject_file_full_path\" not found. Removing %INJECT% placeholder." - # If the file does not exist, just remove the placeholder - cmd="${cmd//%INJECT%=$inject_file/}" + + # Use sed to remove the entire %INJECT%=...'something'.extension + escaped_inject_part=$(printf '%s' "%INJECT%='$inject_file'$extension" | sed 's/[]\/$*.^[]/\\&/g') + cmd=$(echo "$cmd" | sed "s|$escaped_inject_part||g") + + log d "sedded cmd: $cmd" fi done @@ -1015,9 +1023,6 @@ handle_inject_placeholder() { } - - - # Function to replace %EMULATOR_SOMETHING% with the actual path of the emulator replace_emulator_placeholder() { local placeholder=$1 @@ -1059,15 +1064,15 @@ replace_emulator_placeholder() { done # Substitute %BASENAME% and other placeholders - cmd="${cmd//"%BASENAME%"/"$base_name"}" - cmd="${cmd//"%FILENAME%"/"$file_name"}" - cmd="${cmd//"%ROMRAW%"/"$rom_raw"}" - cmd="${cmd//"%ROMPATH%"/"$rom_dir"}" + cmd="${cmd//"%BASENAME%"/"'$base_name'"}" + cmd="${cmd//"%FILENAME%"/"'$file_name'"}" + cmd="${cmd//"%ROMRAW%"/"'$rom_raw'"}" + cmd="${cmd//"%ROMPATH%"/"'$rom_dir'"}" # Ensure paths are quoted correctly - cmd="${cmd//"%ROM%"/"\"$rom_path\""}" - cmd="${cmd//"%GAMEDIR%"/"\"$rom_dir\""}" - cmd="${cmd//"%GAMEDIRRAW%"/"\"$rom_dir_raw\""}" + cmd="${cmd//"%ROM%"/"'$rom_path'"}" + cmd="${cmd//"%GAMEDIR%"/"'$rom_dir'"}" + cmd="${cmd//"%GAMEDIRRAW%"/"'$rom_dir_raw'"}" cmd="${cmd//"%CORE_RETROARCH%"/"/var/config/retroarch/cores"}" log d "Command after %BASENAME% and other substitutions: $cmd" From e80c30a1d9bdab49e3a78db686ab79f54b32f687 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Wed, 11 Sep 2024 10:20:28 +0900 Subject: [PATCH 12/23] RUN_GAME: if the emulator is only one just skip the zenity and run it --- functions/other_functions.sh | 63 +++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/functions/other_functions.sh b/functions/other_functions.sh index 42fe9701..760b81ad 100644 --- a/functions/other_functions.sh +++ b/functions/other_functions.sh @@ -936,7 +936,6 @@ find_emulator() { # TODO: add the logic of alt emulator and default emulator -# TODO: if the emulator is only one just skip the zenity and run it run_game() { @@ -1085,38 +1084,44 @@ replace_emulator_placeholder() { # Extracting the commands from es_systems.xml for the selected system find_system_commands() { - local system_name=$system - # Use xmllint to extract the system commands from the XML - system_section=$(xmllint --xpath "//system[name='$system_name']" "$xml_file" 2>/dev/null) - - if [ -z "$system_section" ]; then - log e "System not found: $system_name" - exit 1 - fi + local system_name=$system + # Use xmllint to extract the system commands from the XML + system_section=$(xmllint --xpath "//system[name='$system_name']" "$xml_file" 2>/dev/null) + + if [ -z "$system_section" ]; then + log e "System not found: $system_name" + exit 1 + fi - # Extract commands and labels - commands=$(echo "$system_section" | xmllint --xpath "//command" - 2>/dev/null) + # Extract commands and labels + commands=$(echo "$system_section" | xmllint --xpath "//command" - 2>/dev/null) - # Prepare Zenity command list - command_list=() - while IFS= read -r line; do - label=$(echo "$line" | sed -n 's/.*label="\([^"]*\)".*/\1/p') - command=$(echo "$line" | sed -n 's/.*]*>\(.*\)<\/command>.*/\1/p') - - # Substitute placeholders in the command - command=$(substitute_placeholders "$command") - - # Add label and command to Zenity list (label first, command second) - command_list+=("$label" "$command") - done <<< "$commands" + # Prepare Zenity command list + command_list=() + while IFS= read -r line; do + label=$(echo "$line" | sed -n 's/.*label="\([^"]*\)".*/\1/p') + command=$(echo "$line" | sed -n 's/.*]*>\(.*\)<\/command>.*/\1/p') + + # Substitute placeholders in the command + command=$(substitute_placeholders "$command") + + # Add label and command to Zenity list (label first, command second) + command_list+=("$label" "$command") + done <<< "$commands" - # Show the list with Zenity and return the **command** (second column) selected - selected_command=$(zenity --list \ - --title="Select an emulator for $system_name" \ - --column="Emulator" --column="Hidden Command" "${command_list[@]}" \ - --width=800 --height=400 --print-column=2 --hide-column=2) + # Check if there's only one command + if [ ${#command_list[@]} -eq 2 ]; then + log d "Only one command found for $system_name, running it directly: ${command_list[1]}" + selected_command="${command_list[1]}" + else + # Show the list with Zenity and return the **command** (second column) selected + selected_command=$(zenity --list \ + --title="Select an emulator for $system_name" \ + --column="Emulator" --column="Hidden Command" "${command_list[@]}" \ + --width=800 --height=400 --print-column=2 --hide-column=2) + fi - echo "$selected_command" + echo "$selected_command" } # If the emulator is not specified, ask the user to select it or get it from the XML file From 32c6a2009bffbc86fbb71de360150807acf40281 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Wed, 11 Sep 2024 13:35:45 +0900 Subject: [PATCH 13/23] FEATURES: removed launch-args as they are no more useful for the scope of RUN_GAME --- config/retrodeck/reference_lists/features.json | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/config/retrodeck/reference_lists/features.json b/config/retrodeck/reference_lists/features.json index f9cd535e..977383b3 100644 --- a/config/retrodeck/reference_lists/features.json +++ b/config/retrodeck/reference_lists/features.json @@ -960,8 +960,7 @@ "system": [ "arcade" ], - "launch": "mame", - "launch-args": "-inipath /var/config/mame/ini -rompath $(dirname \"$game\") $game" + "launch": "mame" }, "citra": { "description": "Citra Nintendo 3DS Emulator (via Ponzu)", @@ -997,7 +996,6 @@ "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/pcsx2/pcsx2-guide/", "system": "ps2", "launch": "pcsx2-qt", - "launch-args": "-batch $game", "properties": [ { "ask_to_exit": true, @@ -1010,7 +1008,6 @@ "description": "PlayStation Emulator", "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/duckstation/duckstation-guide/", "launch": "duckstation-qt", - "launch-args": "-batch $game", "system": "psx", "properties": [ { @@ -1037,8 +1034,7 @@ "description": "Vita3K PSVita Emulator", "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/vita3k/vita3k-guide/", "system": "psvita", - "launch": "Vita3K", - "launch-args": "-r $game.psvita" + "launch": "Vita3K" }, "rpcs3": { "name": "RPCS3", @@ -1066,7 +1062,6 @@ "url": "https://retrodeck.readthedocs.io/en/latest/wiki_about/what-is-retrodeck/", "launch": "Yuzu", "system": "switch", - "launch-args": "-f -g $game", "ponzu": true, "abxy_button": true }, @@ -1075,7 +1070,6 @@ "description": "Dolphin Wii and GameCube Emulator", "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/dolphin-primehack/dolphin-primehack-guide/", "launch": "dolphin-emu-wrapper", - "launch-args": "-e $game", "system": [ "gc", "wii" @@ -1095,7 +1089,6 @@ "description": "A fork of Dolphiin to enhance Metroid Prime experience", "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/dolphin-primehack/dolphin-primehack-guide/", "launch": "primehack-wrapper", - "launch-args": "-e $game", "system": [ "wii" ], @@ -1112,7 +1105,6 @@ "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/cemu/cemu-guide/", "system": "wiiu", "launch": "Cemu-wrapper", - "launch-args": "-g $game", "properties": [ { "abxy_button": true, @@ -1125,8 +1117,7 @@ "name": "xemu", "url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/xemu/xemu-guide/", "system": "xbox", - "launch": "xemu", - "launch-args": "-dvd_path $game" + "launch": "xemu" }, "es-de": { "description": "ES-DE Emulation Frontend", From 24b35b7175cd319aee8053a1016fafa87d9f60c7 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Wed, 11 Sep 2024 13:38:32 +0900 Subject: [PATCH 14/23] RUN_GAME: replaced --run with "start" --- retrodeck.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/retrodeck.sh b/retrodeck.sh index e76f8df0..94be9b78 100644 --- a/retrodeck.sh +++ b/retrodeck.sh @@ -32,7 +32,7 @@ Arguments: --reset-component \t Reset one or more component or emulator configs to the default values --reset-retrodeck \t Starts the initial RetroDECK installer (backup your data first!) - --run [-s ] [-e ] \t Run a game from cli, if no system is defined it will deducted from the path.\n\t\t\t\t\t\t For example --run ~/retrodeck/roms/system/game.ext will be run with the system "system".\n\t\t\t\t\t\t Optionally -e (emulator) and -s (system) can be passed as arguments. + start [-s ] [-e ] \t Start a game from cli, if no system is defined it will deducted from the path.\n\t\t\t\t\t\t For example flatpak run net.retrodeck.retrodeck start ~/retrodeck/roms/system/game.ext will be run with the system "system".\n\t\t\t\t\t\t Optionally -e (emulator) and -s (system) can be passed as arguments. For flatpak run specific options please run: flatpak run -h @@ -44,8 +44,8 @@ https://retrodeck.net echo "RetroDECK v$version" exit ;; - --run*) - shift # Remove --run + start*) + shift # Remove "start" run_game "$@" exit ;; From 51485497ae14116cc321eec4016493d7c866bea6 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Wed, 11 Sep 2024 13:55:04 +0900 Subject: [PATCH 15/23] RUN_GAME: code prettyfication --- functions/other_functions.sh | 111 ++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 53 deletions(-) diff --git a/functions/other_functions.sh b/functions/other_functions.sh index 760b81ad..b9c7f74a 100644 --- a/functions/other_functions.sh +++ b/functions/other_functions.sh @@ -895,9 +895,10 @@ start_retrodeck() { find_emulator() { local emulator_name=$1 local found_path="" + local es_find_rules="/app/share/es-de/resources/systems/linux/es_find_rules.xml" # Search the es_find_rules.xml file for the emulator - emulator_section=$(xmllint --xpath "//emulator[@name='$emulator_name']" "/app/share/es-de/resources/systems/linux/es_find_rules.xml" 2>/dev/null) + emulator_section=$(xmllint --xpath "//emulator[@name='$emulator_name']" "$es_find_rules" 2>/dev/null) if [ -z "$emulator_section" ]; then log e "Emulator not found: $emulator_name" @@ -938,13 +939,15 @@ find_emulator() { # TODO: add the logic of alt emulator and default emulator run_game() { + # call me with (-e emulator) (-s system) game/path, examples: + # run_game -e gambatte_libretro ~/retrodeck/roms/gb/Capumon.gb + # run_game ~/retrodeck/roms/gb/Capumon.gb + # run_game -s gbc ~/retrodeck/roms/gb/Capumon.gb # Initialize variables emulator="" system="" - - # Path to the es_systems.xml file - xml_file="/app/share/es-de/resources/systems/linux/es_systems.xml" + es_systems="/app/share/es-de/resources/systems/linux/es_systems.xml" # Parse options while getopts ":e:s:" opt; do @@ -965,8 +968,8 @@ run_game() { # Check for game argument if [[ -z "$1" ]]; then - echo "Error: Game file is required." - echo "Usage: $0 --run [-e emulator] [-s system] game" + log e "Game path is required." + log i "Usage: $0 start [-e emulator] [-s system] game" exit 1 fi @@ -980,64 +983,66 @@ run_game() { log d "Game: \"$game\"" log d "System: \"$system\"" -# Function to handle the %INJECT% placeholder -handle_inject_placeholder() { - local cmd="$1" - local rom_dir=$(dirname "$game") # Get the ROM directory based on the game path + # Function to handle the %INJECT% placeholder + # When %INJECT%=filename is found in the game command it will check for the existence of the file + # If the file is found the "%INJECT%=file" will be replaced with the contents of the found file + handle_inject_placeholder() { + local cmd="$1" + local rom_dir=$(dirname "$game") # Get the ROM directory based on the game path - # Find and process all occurrences of %INJECT%='something'.extension - while [[ "$cmd" =~ (%INJECT%=\'([^\']+)\')(.[^ ]+)? ]]; do - inject_file="${BASH_REMATCH[2]}" # Extract the quoted file name - extension="${BASH_REMATCH[3]}" # Extract the extension (if any) - inject_file_full_path="$rom_dir/$inject_file$extension" # Form the full path + # Find and process all occurrences of %INJECT%='something'.extension + while [[ "$cmd" =~ (%INJECT%=\'([^\']+)\')(.[^ ]+)? ]]; do + inject_file="${BASH_REMATCH[2]}" # Extract the quoted file name + extension="${BASH_REMATCH[3]}" # Extract the extension (if any) + inject_file_full_path="$rom_dir/$inject_file$extension" # Form the full path - log d "Found inject part: %INJECT%='$inject_file'$extension" + log d "Found inject part: %INJECT%='$inject_file'$extension" - # Check if the file exists - if [[ -f "$inject_file_full_path" ]]; then - # Read the content of the file and replace newlines with spaces - inject_content=$(cat "$inject_file_full_path" | tr '\n' ' ') - log i "File \"$inject_file_full_path\" found. Replacing %INJECT% with content." + # Check if the file exists + if [[ -f "$inject_file_full_path" ]]; then + # Read the content of the file and replace newlines with spaces + inject_content=$(cat "$inject_file_full_path" | tr '\n' ' ') + log i "File \"$inject_file_full_path\" found. Replacing %INJECT% with content." - # Escape special characters in the inject part for the replacement - escaped_inject_part=$(printf '%s' "%INJECT%='$inject_file'$extension" | sed 's/[]\/$*.^[]/\\&/g') + # Escape special characters in the inject part for the replacement + escaped_inject_part=$(printf '%s' "%INJECT%='$inject_file'$extension" | sed 's/[]\/$*.^[]/\\&/g') - # Replace the entire %INJECT%=...'something'.extension part with the file content - cmd=$(echo "$cmd" | sed "s|$escaped_inject_part|$inject_content|g") + # Replace the entire %INJECT%=...'something'.extension part with the file content + cmd=$(echo "$cmd" | sed "s|$escaped_inject_part|$inject_content|g") - log d "Replaced cmd: $cmd" - else - log e "File \"$inject_file_full_path\" not found. Removing %INJECT% placeholder." + log d "Replaced cmd: $cmd" + else + log e "File \"$inject_file_full_path\" not found. Removing %INJECT% placeholder." - # Use sed to remove the entire %INJECT%=...'something'.extension - escaped_inject_part=$(printf '%s' "%INJECT%='$inject_file'$extension" | sed 's/[]\/$*.^[]/\\&/g') - cmd=$(echo "$cmd" | sed "s|$escaped_inject_part||g") + # Use sed to remove the entire %INJECT%=...'something'.extension + escaped_inject_part=$(printf '%s' "%INJECT%='$inject_file'$extension" | sed 's/[]\/$*.^[]/\\&/g') + cmd=$(echo "$cmd" | sed "s|$escaped_inject_part||g") - log d "sedded cmd: $cmd" - fi - done + log d "sedded cmd: $cmd" + fi + done - log d "Returning the command with injected content: $cmd" - echo "$cmd" -} + log d "Returning the command with injected content: $cmd" + echo "$cmd" + } -# Function to replace %EMULATOR_SOMETHING% with the actual path of the emulator -replace_emulator_placeholder() { - local placeholder=$1 - # Extract emulator name from placeholder without changing case - local emulator_name="${placeholder//"%EMULATOR_"/}" # Extract emulator name after %EMULATOR_ - emulator_name="${emulator_name//"%"/}" # Remove the trailing % + # Function to replace %EMULATOR_SOMETHING% with the actual path of the emulator + replace_emulator_placeholder() { + local placeholder=$1 + # Extract emulator name from placeholder without changing case + local emulator_name="${placeholder//"%EMULATOR_"/}" # Extract emulator name after %EMULATOR_ + emulator_name="${emulator_name//"%"/}" # Remove the trailing % - # Use the find_emulator function to get the emulator path using the correct casing - local emulator_exec=$(find_emulator "$emulator_name") - - if [[ -z "$emulator_exec" ]]; then - log e "Emulator '$emulator_name' not found." - exit 1 - fi - echo "$emulator_exec" -} + # Use the find_emulator function to get the emulator path using the correct casing + local emulator_exec=$(find_emulator "$emulator_name") + + if [[ -z "$emulator_exec" ]]; then + log e "Emulator '$emulator_name' not found." + exit 1 + fi + echo "$emulator_exec" + } # Function to substitute the placeholders substitute_placeholders() { @@ -1086,7 +1091,7 @@ replace_emulator_placeholder() { find_system_commands() { local system_name=$system # Use xmllint to extract the system commands from the XML - system_section=$(xmllint --xpath "//system[name='$system_name']" "$xml_file" 2>/dev/null) + system_section=$(xmllint --xpath "//system[name='$system_name']" "$es_systems" 2>/dev/null) if [ -z "$system_section" ]; then log e "System not found: $system_name" From ad10c9d535e451fb5d967fa12a060cd4ec4b9231 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Thu, 12 Sep 2024 00:56:20 +0900 Subject: [PATCH 16/23] RUN_GAME: checkpoint but BROKEN --- functions/other_functions.sh | 496 ++++++++++++++++++++--------------- 1 file changed, 290 insertions(+), 206 deletions(-) diff --git a/functions/other_functions.sh b/functions/other_functions.sh index b9c7f74a..4e58ebcf 100644 --- a/functions/other_functions.sh +++ b/functions/other_functions.sh @@ -892,6 +892,282 @@ start_retrodeck() { es-de } +run_game() { + # Initialize variables + emulator="" + system="" + manual_mode=false + es_systems="/app/share/es-de/resources/systems/linux/es_systems.xml" + + # Parse options + while getopts ":e:s:m" opt; do # Use `m` for manual mode flag + case ${opt} in + e ) + emulator=$OPTARG + ;; + s ) + system=$OPTARG + ;; + m ) + manual_mode=true + log i "Run game: manual mode enabled" + ;; + \? ) + echo "Usage: $0 --run [-e emulator] [-s system] [-m manual] game" + exit 1 + ;; + esac + done + shift $((OPTIND -1)) + + # Check for game argument + if [[ -z "$1" ]]; then + log e "Game path is required." + log i "Usage: $0 start [-e emulator] [-s system] [-m manual] game" + exit 1 + fi + + game=$1 + + # If no system is provided, extract it from the game path + if [[ -z "$system" ]]; then + system=$(echo "$game" | grep -oP '(?<=roms/)[^/]+') + fi + + log d "Game: \"$game\"" + log d "System: \"$system\"" + + # Try finding the inside the specific game block + altemulator=$(xmllint --recover --xpath "string(//game[path='$game']/altemulator)" "$rdhome/ES-DE/gamelists/$system/gamelist.xml" 2>/dev/null) + + if [[ -n "$altemulator" ]]; then + log d "Alternate emulator found in : $altemulator" + emulator_name=$(echo "$altemulator" | sed -e 's/ (Standalone)//') # Strip " (Standalone)" from name + emulator=$(find_emulator "$emulator_name") + + if [[ -n "$emulator" ]]; then + log d "Using alternate emulator: $emulator" + else + log e "No valid path found for emulator: $altemulator" + exit 1 + fi + else + # Try to fetch from anywhere in the document + alternative_emulator=$(xmllint --recover --xpath 'string(//alternativeEmulator/label)' "$rdhome/ES-DE/gamelists/$system/gamelist.xml" 2>/dev/null) + + if [[ -n "$alternative_emulator" ]]; then + log d "Alternate emulator found in header: $alternative_emulator" + + # Find the emulator name from the label in es_systems.xml + emulator_name=$(find_emulator_name_from_label "$alternative_emulator") + + if [[ -n "$emulator_name" ]]; then + # Pass the extracted emulator name to find_emulator function + emulator=$(find_emulator "$emulator_name") + fi + + if [[ -n "$emulator" ]]; then + log d "Using alternate emulator from : $emulator" + else + log e "No valid path found for emulator: $alternative_emulator" + exit 1 + fi + else + log i "No alternate emulator found in game block or header, proceeding to auto mode." + fi + fi + + # If an emulator is found, substitute placeholders in the command before running + if [[ -n "$emulator" ]]; then + # Ensure command substitution + find_system_commands "$emulator" + # TODO: almost there, we need just to start the emulator without Zenity: maybe we have to edit THAT function to pass the emulator to run + log d "Final command: $command" + eval "$command" + else + log e "No emulator found or selected. Exiting." + return 1 + fi + + # If the emulator is not specified or manual mode is set, ask the user to select it via Zenity + if [[ -z "$emulator" && "$manual_mode" == true ]]; then + emulator=$(find_system_commands) + fi + + # If emulator is still not set, fall back to the first available emulator + if [[ -z "$emulator" ]]; then + emulator=$(get_first_emulator) + fi + +} + +# Function to extract commands from es_systems.xml and present them in Zenity +find_system_commands() { + local system_name=$system + # Use xmllint to extract the system commands from the XML + system_section=$(xmllint --xpath "//system[name='$system_name']" "$es_systems" 2>/dev/null) + + if [ -z "$system_section" ]; then + log e "System not found: $system_name" + exit 1 + fi + + # Extract commands and labels + commands=$(echo "$system_section" | xmllint --xpath "//command" - 2>/dev/null) + + # Prepare Zenity command list + command_list=() + while IFS= read -r line; do + label=$(echo "$line" | sed -n 's/.*label="\([^"]*\)".*/\1/p') + command=$(echo "$line" | sed -n 's/.*]*>\(.*\)<\/command>.*/\1/p') + + # Substitute placeholders in the command + command=$(substitute_placeholders "$command") + + # Add label and command to Zenity list (label first, command second) + command_list+=("$label" "$command") + done <<< "$commands" + + # Check if there's only one command + if [ ${#command_list[@]} -eq 2 ]; then + log d "Only one command found for $system_name, running it directly: ${command_list[1]}" + selected_command="${command_list[1]}" + else + # Show the list with Zenity and return the **command** (second column) selected + selected_command=$(zenity --list \ + --title="Select an emulator for $system_name" \ + --column="Emulator" --column="Hidden Command" "${command_list[@]}" \ + --width=800 --height=400 --print-column=2 --hide-column=2) + fi + + echo "$selected_command" +} + +# Function to substitute placeholders in the command +substitute_placeholders() { + local cmd="$1" + local rom_path="$game" + local rom_dir=$(dirname "$rom_path") + + # Strip all file extensions from the base name + local base_name=$(basename "$rom_path") + base_name="${base_name%%.*}" + + local file_name=$(basename "$rom_path") + local rom_raw="$rom_path" + local rom_dir_raw="$rom_dir" + local es_path="" + local emulator_path="" + + # Manually replace %EMULATOR_*% placeholders + while [[ "$cmd" =~ (%EMULATOR_[A-Z0-9_]+%) ]]; do + placeholder="${BASH_REMATCH[1]}" + emulator_path=$(replace_emulator_placeholder "$placeholder") + cmd="${cmd//$placeholder/$emulator_path}" + done + + # Substitute %BASENAME% and other placeholders + cmd="${cmd//"%BASENAME%"/"'$base_name'"}" + cmd="${cmd//"%FILENAME%"/"'$file_name'"}" + cmd="${cmd//"%ROMRAW%"/"'$rom_raw'"}" + cmd="${cmd//"%ROMPATH%"/"'$rom_dir'"}" + + # Ensure paths are quoted correctly + cmd="${cmd//"%ROM%"/"'$rom_path'"}" + cmd="${cmd//"%GAMEDIR%"/"'$rom_dir'"}" + cmd="${cmd//"%GAMEDIRRAW%"/"'$rom_dir_raw'"}" + cmd="${cmd//"%CORE_RETROARCH%"/"/var/config/retroarch/cores"}" + + log d "Command after %BASENAME% and other substitutions: $cmd" + + # Now handle %INJECT% after %BASENAME% has been substituted + cmd=$(handle_inject_placeholder "$cmd") + + echo "$cmd" +} + +# Function to replace %EMULATOR_SOMETHING% with the actual path of the emulator +replace_emulator_placeholder() { + local placeholder=$1 + # Extract emulator name from placeholder without changing case + local emulator_name="${placeholder//"%EMULATOR_"/}" # Extract emulator name after %EMULATOR_ + emulator_name="${emulator_name//"%"/}" # Remove the trailing % + + # Use the find_emulator function to get the emulator path using the correct casing + local emulator_exec=$(find_emulator "$emulator_name") + + if [[ -z "$emulator_exec" ]]; then + log e "Emulator '$emulator_name' not found." + exit 1 + fi + echo "$emulator_exec" +} + +# Function to handle the %INJECT% placeholder +handle_inject_placeholder() { + local cmd="$1" + local rom_dir=$(dirname "$game") # Get the ROM directory based on the game path + + # Find and process all occurrences of %INJECT%='something'.extension + while [[ "$cmd" =~ (%INJECT%=\'([^\']+)\')(.[^ ]+)? ]]; do + inject_file="${BASH_REMATCH[2]}" # Extract the quoted file name + extension="${BASH_REMATCH[3]}" # Extract the extension (if any) + inject_file_full_path="$rom_dir/$inject_file$extension" # Form the full path + + log d "Found inject part: %INJECT%='$inject_file'$extension" + + # Check if the file exists + if [[ -f "$inject_file_full_path" ]]; then + # Read the content of the file and replace newlines with spaces + inject_content=$(cat "$inject_file_full_path" | tr '\n' ' ') + log i "File \"$inject_file_full_path\" found. Replacing %INJECT% with content." + + # Escape special characters in the inject part for the replacement + escaped_inject_part=$(printf '%s' "%INJECT%='$inject_file'$extension" | sed 's/[]\/$*.^[]/\\&/g') + + # Replace the entire %INJECT%=...'something'.extension part with the file content + cmd=$(echo "$cmd" | sed "s|$escaped_inject_part|$inject_content|g") + + log d "Replaced cmd: $cmd" + else + log e "File \"$inject_file_full_path\" not found. Removing %INJECT% placeholder." + + # Use sed to remove the entire %INJECT%=...'something'.extension + escaped_inject_part=$(printf '%s' "%INJECT%='$inject_file'$extension" | sed 's/[]\/$*.^[]/\\&/g') + cmd=$(echo "$cmd" | sed "s|$escaped_inject_part||g") + + log d "sedded cmd: $cmd" + fi + done + + log d "Returning the command with injected content: $cmd" + echo "$cmd" +} + +# Function to get the first available emulator in the list +get_first_emulator() { + local system_name=$system + system_section=$(xmllint --xpath "//system[name='$system_name']" "$es_systems" 2>/dev/null) + + if [ -z "$system_section" ]; then + log e "System not found: $system_name" + exit 1 + fi + + # Extract the first command and use it as the selected emulator + first_command=$(echo "$system_section" | xmllint --xpath "string(//command[1])" - 2>/dev/null) + + if [[ -n "$first_command" ]]; then + # Substitute placeholders in the command + first_command=$(substitute_placeholders "$first_command") + log d "Automatically selected the first emulator: $first_command" + echo "$first_command" + else + log e "No command found for the system: $system_name" + return 1 + fi +} + find_emulator() { local emulator_name=$1 local found_path="" @@ -935,210 +1211,18 @@ find_emulator() { fi } +# Function to find the emulator name from the label in es_systems.xml +find_emulator_name_from_label() { + local label="$1" + + # Search for the emulator matching the label in the es_systems.xml file + extracted_emulator_name=$(xmllint --recover --xpath "string(//system[name='$system']/command[@label='$label']/text())" "$es_systems" 2>/dev/null | sed 's/%//g' | sed 's/EMULATOR_//g' | cut -d' ' -f1) -# TODO: add the logic of alt emulator and default emulator - -run_game() { - # call me with (-e emulator) (-s system) game/path, examples: - # run_game -e gambatte_libretro ~/retrodeck/roms/gb/Capumon.gb - # run_game ~/retrodeck/roms/gb/Capumon.gb - # run_game -s gbc ~/retrodeck/roms/gb/Capumon.gb - - # Initialize variables - emulator="" - system="" - es_systems="/app/share/es-de/resources/systems/linux/es_systems.xml" - - # Parse options - while getopts ":e:s:" opt; do - case ${opt} in - e ) - emulator=$OPTARG - ;; - s ) - system=$OPTARG - ;; - \? ) - echo "Usage: $0 --run [-e emulator] [-s system] game" - exit 1 - ;; - esac - done - shift $((OPTIND -1)) - - # Check for game argument - if [[ -z "$1" ]]; then - log e "Game path is required." - log i "Usage: $0 start [-e emulator] [-s system] game" - exit 1 - fi - - game=$1 - - # If no system is provided, extract it from the game path - if [[ -z "$system" ]]; then - system=$(echo "$game" | grep -oP '(?<=roms/)[^/]+') - fi - - log d "Game: \"$game\"" - log d "System: \"$system\"" - - # Function to handle the %INJECT% placeholder - # When %INJECT%=filename is found in the game command it will check for the existence of the file - # If the file is found the "%INJECT%=file" will be replaced with the contents of the found file - handle_inject_placeholder() { - local cmd="$1" - local rom_dir=$(dirname "$game") # Get the ROM directory based on the game path - - # Find and process all occurrences of %INJECT%='something'.extension - while [[ "$cmd" =~ (%INJECT%=\'([^\']+)\')(.[^ ]+)? ]]; do - inject_file="${BASH_REMATCH[2]}" # Extract the quoted file name - extension="${BASH_REMATCH[3]}" # Extract the extension (if any) - inject_file_full_path="$rom_dir/$inject_file$extension" # Form the full path - - log d "Found inject part: %INJECT%='$inject_file'$extension" - - # Check if the file exists - if [[ -f "$inject_file_full_path" ]]; then - # Read the content of the file and replace newlines with spaces - inject_content=$(cat "$inject_file_full_path" | tr '\n' ' ') - log i "File \"$inject_file_full_path\" found. Replacing %INJECT% with content." - - # Escape special characters in the inject part for the replacement - escaped_inject_part=$(printf '%s' "%INJECT%='$inject_file'$extension" | sed 's/[]\/$*.^[]/\\&/g') - - # Replace the entire %INJECT%=...'something'.extension part with the file content - cmd=$(echo "$cmd" | sed "s|$escaped_inject_part|$inject_content|g") - - log d "Replaced cmd: $cmd" - else - log e "File \"$inject_file_full_path\" not found. Removing %INJECT% placeholder." - - # Use sed to remove the entire %INJECT%=...'something'.extension - escaped_inject_part=$(printf '%s' "%INJECT%='$inject_file'$extension" | sed 's/[]\/$*.^[]/\\&/g') - cmd=$(echo "$cmd" | sed "s|$escaped_inject_part||g") - - log d "sedded cmd: $cmd" - fi - done - - log d "Returning the command with injected content: $cmd" - echo "$cmd" - } - - - # Function to replace %EMULATOR_SOMETHING% with the actual path of the emulator - replace_emulator_placeholder() { - local placeholder=$1 - # Extract emulator name from placeholder without changing case - local emulator_name="${placeholder//"%EMULATOR_"/}" # Extract emulator name after %EMULATOR_ - emulator_name="${emulator_name//"%"/}" # Remove the trailing % - - # Use the find_emulator function to get the emulator path using the correct casing - local emulator_exec=$(find_emulator "$emulator_name") - - if [[ -z "$emulator_exec" ]]; then - log e "Emulator '$emulator_name' not found." - exit 1 - fi - echo "$emulator_exec" - } - - # Function to substitute the placeholders - substitute_placeholders() { - local cmd="$1" - local rom_path="$game" - local rom_dir=$(dirname "$rom_path") - - # Strip all file extensions from the base name - local base_name=$(basename "$rom_path") - base_name="${base_name%%.*}" - - local file_name=$(basename "$rom_path") - local rom_raw="$rom_path" - local rom_dir_raw="$rom_dir" - local es_path="" - local emulator_path="" - - # Manually replace %EMULATOR_*% placeholders - while [[ "$cmd" =~ (%EMULATOR_[A-Z0-9_]+%) ]]; do - placeholder="${BASH_REMATCH[1]}" - emulator_path=$(replace_emulator_placeholder "$placeholder") - cmd="${cmd//$placeholder/$emulator_path}" - done - - # Substitute %BASENAME% and other placeholders - cmd="${cmd//"%BASENAME%"/"'$base_name'"}" - cmd="${cmd//"%FILENAME%"/"'$file_name'"}" - cmd="${cmd//"%ROMRAW%"/"'$rom_raw'"}" - cmd="${cmd//"%ROMPATH%"/"'$rom_dir'"}" - - # Ensure paths are quoted correctly - cmd="${cmd//"%ROM%"/"'$rom_path'"}" - cmd="${cmd//"%GAMEDIR%"/"'$rom_dir'"}" - cmd="${cmd//"%GAMEDIRRAW%"/"'$rom_dir_raw'"}" - cmd="${cmd//"%CORE_RETROARCH%"/"/var/config/retroarch/cores"}" - - log d "Command after %BASENAME% and other substitutions: $cmd" - - # Now handle %INJECT% after %BASENAME% has been substituted - cmd=$(handle_inject_placeholder "$cmd") - - echo "$cmd" - } - - # Extracting the commands from es_systems.xml for the selected system - find_system_commands() { - local system_name=$system - # Use xmllint to extract the system commands from the XML - system_section=$(xmllint --xpath "//system[name='$system_name']" "$es_systems" 2>/dev/null) - - if [ -z "$system_section" ]; then - log e "System not found: $system_name" - exit 1 - fi - - # Extract commands and labels - commands=$(echo "$system_section" | xmllint --xpath "//command" - 2>/dev/null) - - # Prepare Zenity command list - command_list=() - while IFS= read -r line; do - label=$(echo "$line" | sed -n 's/.*label="\([^"]*\)".*/\1/p') - command=$(echo "$line" | sed -n 's/.*]*>\(.*\)<\/command>.*/\1/p') - - # Substitute placeholders in the command - command=$(substitute_placeholders "$command") - - # Add label and command to Zenity list (label first, command second) - command_list+=("$label" "$command") - done <<< "$commands" - - # Check if there's only one command - if [ ${#command_list[@]} -eq 2 ]; then - log d "Only one command found for $system_name, running it directly: ${command_list[1]}" - selected_command="${command_list[1]}" - else - # Show the list with Zenity and return the **command** (second column) selected - selected_command=$(zenity --list \ - --title="Select an emulator for $system_name" \ - --column="Emulator" --column="Hidden Command" "${command_list[@]}" \ - --width=800 --height=400 --print-column=2 --hide-column=2) - fi - - echo "$selected_command" - } - - # If the emulator is not specified, ask the user to select it or get it from the XML file - if [[ -z "$emulator" ]]; then - emulator=$(find_system_commands) - fi - - if [[ -n "$emulator" ]]; then - log d "Running: $emulator" - eval "$emulator" - else - log e "No emulator found or selected. Exiting." - return 1 - fi -} \ No newline at end of file + if [[ -n "$extracted_emulator_name" ]]; then + log d "Found emulator by label: $extracted_emulator_name" + echo "$extracted_emulator_name" + else + log e "Emulator name not found for label: $label" + return 1 + fi +} From 6b92f8c187641df26db367b73a92d5adad523bb8 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Thu, 12 Sep 2024 08:25:07 +0900 Subject: [PATCH 17/23] RUN_GAME: moved into its own file + code cleanup + es_variables outsourced [skip ci] --- functions/global.sh | 51 +++--- functions/other_functions.sh | 337 +---------------------------------- functions/run_game.sh | 334 ++++++++++++++++++++++++++++++++++ 3 files changed, 362 insertions(+), 360 deletions(-) create mode 100755 functions/run_game.sh diff --git a/functions/global.sh b/functions/global.sh index b0a62c0f..5792a51a 100644 --- a/functions/global.sh +++ b/functions/global.sh @@ -18,40 +18,43 @@ source /app/libexec/post_update.sh source /app/libexec/prepare_component.sh source /app/libexec/presets.sh source /app/libexec/configurator_functions.sh +source /app/libexec/run_game.sh # Static variables -rd_conf="/var/config/retrodeck/retrodeck.cfg" # RetroDECK config file path -rd_conf_backup="/var/config/retrodeck/retrodeck.bak" # Backup of RetroDECK config file from update -rd_logs_folder="/var/config/retrodeck/logs" # Static location to write all RetroDECK-related logs -config="/app/retrodeck/config" # folder with all the default emulator configs +rd_conf="/var/config/retrodeck/retrodeck.cfg" # RetroDECK config file path +rd_conf_backup="/var/config/retrodeck/retrodeck.bak" # Backup of RetroDECK config file from update +rd_logs_folder="/var/config/retrodeck/logs" # Static location to write all RetroDECK-related logs +config="/app/retrodeck/config" # folder with all the default emulator configs rd_defaults="$config/retrodeck/retrodeck.cfg" # A default RetroDECK config file -rd_update_patch="/var/config/retrodeck/rd_update.patch" # A static location for the temporary patch file used during retrodeck.cfg updates +rd_update_patch="/var/config/retrodeck/rd_update.patch" # A static location for the temporary patch file used during retrodeck.cfg updates bios_checklist="$config/retrodeck/reference_lists/bios_checklist.cfg" # A config file listing BIOS file information that can be verified input_validation="$config/retrodeck/reference_lists/input_validation.cfg" # A config file listing valid CLI inputs finit_options_list="$config/retrodeck/reference_lists/finit_options_list.cfg" # A config file listing available optional installs during finit -splashscreen_dir="/var/config/ES-DE/resources/graphics/extra_splashes" # The default location of extra splash screens -current_splash_file="/var/config/ES-DE/resources/graphics/splash.svg" # The active splash file that will be shown on boot -default_splash_file="/var/config/ES-DE/resources/graphics/splash-orig.svg" # The default RetroDECK splash screen +splashscreen_dir="/var/config/ES-DE/resources/graphics/extra_splashes" # The default location of extra splash screens +current_splash_file="/var/config/ES-DE/resources/graphics/splash.svg" # The active splash file that will be shown on boot +default_splash_file="/var/config/ES-DE/resources/graphics/splash-orig.svg" # The default RetroDECK splash screen # TODO: instead of this maybe we can iterate the features.json multi_user_emulator_config_dirs="$config/retrodeck/reference_lists/multi_user_emulator_config_dirs.cfg" # A list of emulator config folders that can be safely linked/unlinked entirely in multi-user mode -rd_es_themes="/app/share/es-de/themes" # The directory where themes packaged with RetroDECK are stored -lockfile="/var/config/retrodeck/.lock" # Where the lockfile is located -default_sd="/run/media/mmcblk0p1" # Steam Deck SD default path # A static location for RetroDECK logs to be written -hard_version="$(cat '/app/retrodeck/version')" # hardcoded version (in the readonly filesystem) -rd_repo="https://github.com/RetroDECK/RetroDECK" # The URL of the main RetroDECK GitHub repo -es_themes_list="https://gitlab.com/es-de/themes/themes-list/-/raw/master/themes.json" # The URL of the ES-DE 2.0 themes list -remote_network_target_1="https://flathub.org" # The URL of a common internet target for testing network access -remote_network_target_2="$rd_repo" # The URL of a common internet target for testing network access -remote_network_target_3="https://one.one.one.one" # The URL of a common internet target for testing network access +rd_es_themes="/app/share/es-de/themes" # The directory where themes packaged with RetroDECK are stored +lockfile="/var/config/retrodeck/.lock" # Where the lockfile is located +default_sd="/run/media/mmcblk0p1" # Steam Deck SD default path +hard_version="$(cat '/app/retrodeck/version')" # hardcoded version (in the readonly filesystem) +rd_repo="https://github.com/RetroDECK/RetroDECK" # The URL of the main RetroDECK GitHub repo +es_themes_list="https://gitlab.com/es-de/themes/themes-list/-/raw/master/themes.json" # The URL of the ES-DE 2.0 themes list +remote_network_target_1="https://flathub.org" # The URL of a common internet target for testing network access +remote_network_target_2="$rd_repo" # The URL of a common internet target for testing network access +remote_network_target_3="https://one.one.one.one" # The URL of a common internet target for testing network access helper_files_folder="$config/retrodeck/helper_files" # The parent folder of RetroDECK documentation files for deployment -rd_appdata="/app/share/appdata/net.retrodeck.retrodeck.appdata.xml" # The shipped appdata XML file for this version -rpcs3_firmware="http://dus01.ps3.update.playstation.net/update/ps3/image/us/2024_0227_3694eb3fb8d9915c112e6ab41a60c69f/PS3UPDAT.PUP" -RA_API_URL="https://retroachievements.org/dorequest.php" # API URL for RetroAchievements.org +rd_appdata="/app/share/appdata/net.retrodeck.retrodeck.appdata.xml" # The shipped appdata XML file for this version +rpcs3_firmware="http://dus01.ps3.update.playstation.net/update/ps3/image/us/2024_0227_3694eb3fb8d9915c112e6ab41a60c69f/PS3UPDAT.PUP" # RPCS3 Firmware download location +RA_API_URL="https://retroachievements.org/dorequest.php" # API URL for RetroAchievements.org presets_dir="$config/retrodeck/presets" # Repository for all system preset config files -git_organization_name="RetroDECK" # The name of the organization in our git repository such as GitHub -cooker_repository_name="Cooker" # The name of the cooker repository under RetroDECK organization -main_repository_name="RetroDECK" # The name of the main repository under RetroDECK organization -features="$config/retrodeck/reference_lists/features.json" # A file where all the RetroDECK and component capabilities are kept for querying +git_organization_name="RetroDECK" # The name of the organization in our git repository such as GitHub +cooker_repository_name="Cooker" # The name of the cooker repository under RetroDECK organization +main_repository_name="RetroDECK" # The name of the main repository under RetroDECK organization +features="$config/retrodeck/reference_lists/features.json" # A file where all the RetroDECK and component capabilities are kept for querying +es_systems="/app/share/es-de/resources/systems/linux/es_systems.xml" # ES-DE supported system list +es_find_rules="/app/share/es-de/resources/systems/linux/es_find_rules.xml" # ES-DE emulator find rules # Godot data transfer temp files diff --git a/functions/other_functions.sh b/functions/other_functions.sh index 4e58ebcf..f8d6a012 100644 --- a/functions/other_functions.sh +++ b/functions/other_functions.sh @@ -890,339 +890,4 @@ start_retrodeck() { ponzu log i "Starting RetroDECK v$version" es-de -} - -run_game() { - # Initialize variables - emulator="" - system="" - manual_mode=false - es_systems="/app/share/es-de/resources/systems/linux/es_systems.xml" - - # Parse options - while getopts ":e:s:m" opt; do # Use `m` for manual mode flag - case ${opt} in - e ) - emulator=$OPTARG - ;; - s ) - system=$OPTARG - ;; - m ) - manual_mode=true - log i "Run game: manual mode enabled" - ;; - \? ) - echo "Usage: $0 --run [-e emulator] [-s system] [-m manual] game" - exit 1 - ;; - esac - done - shift $((OPTIND -1)) - - # Check for game argument - if [[ -z "$1" ]]; then - log e "Game path is required." - log i "Usage: $0 start [-e emulator] [-s system] [-m manual] game" - exit 1 - fi - - game=$1 - - # If no system is provided, extract it from the game path - if [[ -z "$system" ]]; then - system=$(echo "$game" | grep -oP '(?<=roms/)[^/]+') - fi - - log d "Game: \"$game\"" - log d "System: \"$system\"" - - # Try finding the inside the specific game block - altemulator=$(xmllint --recover --xpath "string(//game[path='$game']/altemulator)" "$rdhome/ES-DE/gamelists/$system/gamelist.xml" 2>/dev/null) - - if [[ -n "$altemulator" ]]; then - log d "Alternate emulator found in : $altemulator" - emulator_name=$(echo "$altemulator" | sed -e 's/ (Standalone)//') # Strip " (Standalone)" from name - emulator=$(find_emulator "$emulator_name") - - if [[ -n "$emulator" ]]; then - log d "Using alternate emulator: $emulator" - else - log e "No valid path found for emulator: $altemulator" - exit 1 - fi - else - # Try to fetch from anywhere in the document - alternative_emulator=$(xmllint --recover --xpath 'string(//alternativeEmulator/label)' "$rdhome/ES-DE/gamelists/$system/gamelist.xml" 2>/dev/null) - - if [[ -n "$alternative_emulator" ]]; then - log d "Alternate emulator found in header: $alternative_emulator" - - # Find the emulator name from the label in es_systems.xml - emulator_name=$(find_emulator_name_from_label "$alternative_emulator") - - if [[ -n "$emulator_name" ]]; then - # Pass the extracted emulator name to find_emulator function - emulator=$(find_emulator "$emulator_name") - fi - - if [[ -n "$emulator" ]]; then - log d "Using alternate emulator from : $emulator" - else - log e "No valid path found for emulator: $alternative_emulator" - exit 1 - fi - else - log i "No alternate emulator found in game block or header, proceeding to auto mode." - fi - fi - - # If an emulator is found, substitute placeholders in the command before running - if [[ -n "$emulator" ]]; then - # Ensure command substitution - find_system_commands "$emulator" - # TODO: almost there, we need just to start the emulator without Zenity: maybe we have to edit THAT function to pass the emulator to run - log d "Final command: $command" - eval "$command" - else - log e "No emulator found or selected. Exiting." - return 1 - fi - - # If the emulator is not specified or manual mode is set, ask the user to select it via Zenity - if [[ -z "$emulator" && "$manual_mode" == true ]]; then - emulator=$(find_system_commands) - fi - - # If emulator is still not set, fall back to the first available emulator - if [[ -z "$emulator" ]]; then - emulator=$(get_first_emulator) - fi - -} - -# Function to extract commands from es_systems.xml and present them in Zenity -find_system_commands() { - local system_name=$system - # Use xmllint to extract the system commands from the XML - system_section=$(xmllint --xpath "//system[name='$system_name']" "$es_systems" 2>/dev/null) - - if [ -z "$system_section" ]; then - log e "System not found: $system_name" - exit 1 - fi - - # Extract commands and labels - commands=$(echo "$system_section" | xmllint --xpath "//command" - 2>/dev/null) - - # Prepare Zenity command list - command_list=() - while IFS= read -r line; do - label=$(echo "$line" | sed -n 's/.*label="\([^"]*\)".*/\1/p') - command=$(echo "$line" | sed -n 's/.*]*>\(.*\)<\/command>.*/\1/p') - - # Substitute placeholders in the command - command=$(substitute_placeholders "$command") - - # Add label and command to Zenity list (label first, command second) - command_list+=("$label" "$command") - done <<< "$commands" - - # Check if there's only one command - if [ ${#command_list[@]} -eq 2 ]; then - log d "Only one command found for $system_name, running it directly: ${command_list[1]}" - selected_command="${command_list[1]}" - else - # Show the list with Zenity and return the **command** (second column) selected - selected_command=$(zenity --list \ - --title="Select an emulator for $system_name" \ - --column="Emulator" --column="Hidden Command" "${command_list[@]}" \ - --width=800 --height=400 --print-column=2 --hide-column=2) - fi - - echo "$selected_command" -} - -# Function to substitute placeholders in the command -substitute_placeholders() { - local cmd="$1" - local rom_path="$game" - local rom_dir=$(dirname "$rom_path") - - # Strip all file extensions from the base name - local base_name=$(basename "$rom_path") - base_name="${base_name%%.*}" - - local file_name=$(basename "$rom_path") - local rom_raw="$rom_path" - local rom_dir_raw="$rom_dir" - local es_path="" - local emulator_path="" - - # Manually replace %EMULATOR_*% placeholders - while [[ "$cmd" =~ (%EMULATOR_[A-Z0-9_]+%) ]]; do - placeholder="${BASH_REMATCH[1]}" - emulator_path=$(replace_emulator_placeholder "$placeholder") - cmd="${cmd//$placeholder/$emulator_path}" - done - - # Substitute %BASENAME% and other placeholders - cmd="${cmd//"%BASENAME%"/"'$base_name'"}" - cmd="${cmd//"%FILENAME%"/"'$file_name'"}" - cmd="${cmd//"%ROMRAW%"/"'$rom_raw'"}" - cmd="${cmd//"%ROMPATH%"/"'$rom_dir'"}" - - # Ensure paths are quoted correctly - cmd="${cmd//"%ROM%"/"'$rom_path'"}" - cmd="${cmd//"%GAMEDIR%"/"'$rom_dir'"}" - cmd="${cmd//"%GAMEDIRRAW%"/"'$rom_dir_raw'"}" - cmd="${cmd//"%CORE_RETROARCH%"/"/var/config/retroarch/cores"}" - - log d "Command after %BASENAME% and other substitutions: $cmd" - - # Now handle %INJECT% after %BASENAME% has been substituted - cmd=$(handle_inject_placeholder "$cmd") - - echo "$cmd" -} - -# Function to replace %EMULATOR_SOMETHING% with the actual path of the emulator -replace_emulator_placeholder() { - local placeholder=$1 - # Extract emulator name from placeholder without changing case - local emulator_name="${placeholder//"%EMULATOR_"/}" # Extract emulator name after %EMULATOR_ - emulator_name="${emulator_name//"%"/}" # Remove the trailing % - - # Use the find_emulator function to get the emulator path using the correct casing - local emulator_exec=$(find_emulator "$emulator_name") - - if [[ -z "$emulator_exec" ]]; then - log e "Emulator '$emulator_name' not found." - exit 1 - fi - echo "$emulator_exec" -} - -# Function to handle the %INJECT% placeholder -handle_inject_placeholder() { - local cmd="$1" - local rom_dir=$(dirname "$game") # Get the ROM directory based on the game path - - # Find and process all occurrences of %INJECT%='something'.extension - while [[ "$cmd" =~ (%INJECT%=\'([^\']+)\')(.[^ ]+)? ]]; do - inject_file="${BASH_REMATCH[2]}" # Extract the quoted file name - extension="${BASH_REMATCH[3]}" # Extract the extension (if any) - inject_file_full_path="$rom_dir/$inject_file$extension" # Form the full path - - log d "Found inject part: %INJECT%='$inject_file'$extension" - - # Check if the file exists - if [[ -f "$inject_file_full_path" ]]; then - # Read the content of the file and replace newlines with spaces - inject_content=$(cat "$inject_file_full_path" | tr '\n' ' ') - log i "File \"$inject_file_full_path\" found. Replacing %INJECT% with content." - - # Escape special characters in the inject part for the replacement - escaped_inject_part=$(printf '%s' "%INJECT%='$inject_file'$extension" | sed 's/[]\/$*.^[]/\\&/g') - - # Replace the entire %INJECT%=...'something'.extension part with the file content - cmd=$(echo "$cmd" | sed "s|$escaped_inject_part|$inject_content|g") - - log d "Replaced cmd: $cmd" - else - log e "File \"$inject_file_full_path\" not found. Removing %INJECT% placeholder." - - # Use sed to remove the entire %INJECT%=...'something'.extension - escaped_inject_part=$(printf '%s' "%INJECT%='$inject_file'$extension" | sed 's/[]\/$*.^[]/\\&/g') - cmd=$(echo "$cmd" | sed "s|$escaped_inject_part||g") - - log d "sedded cmd: $cmd" - fi - done - - log d "Returning the command with injected content: $cmd" - echo "$cmd" -} - -# Function to get the first available emulator in the list -get_first_emulator() { - local system_name=$system - system_section=$(xmllint --xpath "//system[name='$system_name']" "$es_systems" 2>/dev/null) - - if [ -z "$system_section" ]; then - log e "System not found: $system_name" - exit 1 - fi - - # Extract the first command and use it as the selected emulator - first_command=$(echo "$system_section" | xmllint --xpath "string(//command[1])" - 2>/dev/null) - - if [[ -n "$first_command" ]]; then - # Substitute placeholders in the command - first_command=$(substitute_placeholders "$first_command") - log d "Automatically selected the first emulator: $first_command" - echo "$first_command" - else - log e "No command found for the system: $system_name" - return 1 - fi -} - -find_emulator() { - local emulator_name=$1 - local found_path="" - local es_find_rules="/app/share/es-de/resources/systems/linux/es_find_rules.xml" - - # Search the es_find_rules.xml file for the emulator - emulator_section=$(xmllint --xpath "//emulator[@name='$emulator_name']" "$es_find_rules" 2>/dev/null) - - if [ -z "$emulator_section" ]; then - log e "Emulator not found: $emulator_name" - return 1 - fi - - # Search systempath entries - while IFS= read -r line; do - command_path=$(echo "$line" | sed -n 's/.*\(.*\)<\/entry>.*/\1/p') - if [ -x "$(command -v $command_path)" ]; then - found_path=$command_path - break - fi - done <<< "$(echo "$emulator_section" | xmllint --xpath "//rule[@type='systempath']/entry" - 2>/dev/null)" - - # If not found, search staticpath entries - if [ -z "$found_path" ]; then - while IFS= read -r line; do - command_path=$(eval echo "$line" | sed -n 's/.*\(.*\)<\/entry>.*/\1/p') - if [ -x "$command_path" ]; then - found_path=$command_path - break - fi - done <<< "$(echo "$emulator_section" | xmllint --xpath "//rule[@type='staticpath']/entry" - 2>/dev/null)" - fi - - if [ -z "$found_path" ]; then - log e "No valid path found for emulator: $emulator_name" - return 1 - else - log d "Found emulator: \"$found_path\"" - echo "$found_path" - return 0 - fi -} - -# Function to find the emulator name from the label in es_systems.xml -find_emulator_name_from_label() { - local label="$1" - - # Search for the emulator matching the label in the es_systems.xml file - extracted_emulator_name=$(xmllint --recover --xpath "string(//system[name='$system']/command[@label='$label']/text())" "$es_systems" 2>/dev/null | sed 's/%//g' | sed 's/EMULATOR_//g' | cut -d' ' -f1) - - if [[ -n "$extracted_emulator_name" ]]; then - log d "Found emulator by label: $extracted_emulator_name" - echo "$extracted_emulator_name" - else - log e "Emulator name not found for label: $label" - return 1 - fi -} +} \ No newline at end of file diff --git a/functions/run_game.sh b/functions/run_game.sh new file mode 100755 index 00000000..c6cee211 --- /dev/null +++ b/functions/run_game.sh @@ -0,0 +1,334 @@ +#!/bin/bash + +run_game() { + # Initialize variables + emulator="" + system="" + manual_mode=false + + # Parse options + while getopts ":e:s:m" opt; do # Use `m` for manual mode flag + case ${opt} in + e ) + emulator=$OPTARG + ;; + s ) + system=$OPTARG + ;; + m ) + manual_mode=true + log i "Run game: manual mode enabled" + ;; + \? ) + echo "Usage: $0 --run [-e emulator] [-s system] [-m manual] game" + exit 1 + ;; + esac + done + shift $((OPTIND -1)) + + # Check for game argument + if [[ -z "$1" ]]; then + log e "Game path is required." + log i "Usage: $0 start [-e emulator] [-s system] [-m manual] game" + exit 1 + fi + + game=$1 + + # If no system is provided, extract it from the game path + if [[ -z "$system" ]]; then + system=$(echo "$game" | grep -oP '(?<=roms/)[^/]+') + fi + + log d "Game: \"$game\"" + log d "System: \"$system\"" + + # Try finding the inside the specific game block + altemulator=$(xmllint --recover --xpath "string(//game[path='$game']/altemulator)" "$rdhome/ES-DE/gamelists/$system/gamelist.xml" 2>/dev/null) + + if [[ -n "$altemulator" ]]; then + log d "Alternate emulator found in : $altemulator" + emulator_name=$(echo "$altemulator" | sed -e 's/ (Standalone)//') # Strip " (Standalone)" from name + emulator=$(find_emulator "$emulator_name") + + if [[ -n "$emulator" ]]; then + log d "Using alternate emulator: $emulator" + else + log e "No valid path found for emulator: $altemulator" + exit 1 + fi + else + # Try to fetch from anywhere in the document + alternative_emulator=$(xmllint --recover --xpath 'string(//alternativeEmulator/label)' "$rdhome/ES-DE/gamelists/$system/gamelist.xml" 2>/dev/null) + + if [[ -n "$alternative_emulator" ]]; then + log d "Alternate emulator found in header: $alternative_emulator" + + # Find the emulator name from the label in es_systems.xml + emulator_name=$(find_emulator_name_from_label "$alternative_emulator") + + if [[ -n "$emulator_name" ]]; then + # Pass the extracted emulator name to find_emulator function + emulator=$(find_emulator "$emulator_name") + fi + + if [[ -n "$emulator" ]]; then + log d "Using alternate emulator from : $emulator" + else + log e "No valid path found for emulator: $alternative_emulator" + exit 1 + fi + else + log i "No alternate emulator found in game block or header, proceeding to auto mode." + fi + fi + + # If an emulator is found, substitute placeholders in the command before running + if [[ -n "$emulator" ]]; then + # Ensure command substitution + find_system_commands "$emulator" + # TODO: almost there, we need just to start the emulator without Zenity: maybe we have to edit THAT function to pass the emulator to run + log d "Final command: $command" + eval "$command" + else + log e "No emulator found or selected. Exiting." + return 1 + fi + + # If the emulator is not specified or manual mode is set, ask the user to select it via Zenity + if [[ -z "$emulator" && "$manual_mode" == true ]]; then + emulator=$(find_system_commands) + fi + + # If emulator is still not set, fall back to the first available emulator + if [[ -z "$emulator" ]]; then + emulator=$(get_first_emulator) + fi + +} + +# Function to extract commands from es_systems.xml and present them in Zenity +find_system_commands() { + local system_name=$system + # Use xmllint to extract the system commands from the XML + system_section=$(xmllint --xpath "//system[name='$system_name']" "$es_systems" 2>/dev/null) + + if [ -z "$system_section" ]; then + log e "System not found: $system_name" + exit 1 + fi + + # Extract commands and labels + commands=$(echo "$system_section" | xmllint --xpath "//command" - 2>/dev/null) + + # Prepare Zenity command list + command_list=() + while IFS= read -r line; do + label=$(echo "$line" | sed -n 's/.*label="\([^"]*\)".*/\1/p') + command=$(echo "$line" | sed -n 's/.*]*>\(.*\)<\/command>.*/\1/p') + + # Substitute placeholders in the command + command=$(substitute_placeholders "$command") + + # Add label and command to Zenity list (label first, command second) + command_list+=("$label" "$command") + done <<< "$commands" + + # Check if there's only one command + if [ ${#command_list[@]} -eq 2 ]; then + log d "Only one command found for $system_name, running it directly: ${command_list[1]}" + selected_command="${command_list[1]}" + else + # Show the list with Zenity and return the **command** (second column) selected + selected_command=$(zenity --list \ + --title="Select an emulator for $system_name" \ + --column="Emulator" --column="Hidden Command" "${command_list[@]}" \ + --width=800 --height=400 --print-column=2 --hide-column=2) + fi + + echo "$selected_command" +} + +# Function to substitute placeholders in the command +substitute_placeholders() { + local cmd="$1" + local rom_path="$game" + local rom_dir=$(dirname "$rom_path") + + # Strip all file extensions from the base name + local base_name=$(basename "$rom_path") + base_name="${base_name%%.*}" + + local file_name=$(basename "$rom_path") + local rom_raw="$rom_path" + local rom_dir_raw="$rom_dir" + local es_path="" + local emulator_path="" + + # Manually replace %EMULATOR_*% placeholders + while [[ "$cmd" =~ (%EMULATOR_[A-Z0-9_]+%) ]]; do + placeholder="${BASH_REMATCH[1]}" + emulator_path=$(replace_emulator_placeholder "$placeholder") + cmd="${cmd//$placeholder/$emulator_path}" + done + + # Substitute %BASENAME% and other placeholders + cmd="${cmd//"%BASENAME%"/"'$base_name'"}" + cmd="${cmd//"%FILENAME%"/"'$file_name'"}" + cmd="${cmd//"%ROMRAW%"/"'$rom_raw'"}" + cmd="${cmd//"%ROMPATH%"/"'$rom_dir'"}" + + # Ensure paths are quoted correctly + cmd="${cmd//"%ROM%"/"'$rom_path'"}" + cmd="${cmd//"%GAMEDIR%"/"'$rom_dir'"}" + cmd="${cmd//"%GAMEDIRRAW%"/"'$rom_dir_raw'"}" + cmd="${cmd//"%CORE_RETROARCH%"/"/var/config/retroarch/cores"}" + + log d "Command after %BASENAME% and other substitutions: $cmd" + + # Now handle %INJECT% after %BASENAME% has been substituted + cmd=$(handle_inject_placeholder "$cmd") + + echo "$cmd" +} + +# Function to replace %EMULATOR_SOMETHING% with the actual path of the emulator +replace_emulator_placeholder() { + local placeholder=$1 + # Extract emulator name from placeholder without changing case + local emulator_name="${placeholder//"%EMULATOR_"/}" # Extract emulator name after %EMULATOR_ + emulator_name="${emulator_name//"%"/}" # Remove the trailing % + + # Use the find_emulator function to get the emulator path using the correct casing + local emulator_exec=$(find_emulator "$emulator_name") + + if [[ -z "$emulator_exec" ]]; then + log e "Emulator '$emulator_name' not found." + exit 1 + fi + echo "$emulator_exec" +} + +# Function to handle the %INJECT% placeholder +handle_inject_placeholder() { + local cmd="$1" + local rom_dir=$(dirname "$game") # Get the ROM directory based on the game path + + # Find and process all occurrences of %INJECT%='something'.extension + while [[ "$cmd" =~ (%INJECT%=\'([^\']+)\')(.[^ ]+)? ]]; do + inject_file="${BASH_REMATCH[2]}" # Extract the quoted file name + extension="${BASH_REMATCH[3]}" # Extract the extension (if any) + inject_file_full_path="$rom_dir/$inject_file$extension" # Form the full path + + log d "Found inject part: %INJECT%='$inject_file'$extension" + + # Check if the file exists + if [[ -f "$inject_file_full_path" ]]; then + # Read the content of the file and replace newlines with spaces + inject_content=$(cat "$inject_file_full_path" | tr '\n' ' ') + log i "File \"$inject_file_full_path\" found. Replacing %INJECT% with content." + + # Escape special characters in the inject part for the replacement + escaped_inject_part=$(printf '%s' "%INJECT%='$inject_file'$extension" | sed 's/[]\/$*.^[]/\\&/g') + + # Replace the entire %INJECT%=...'something'.extension part with the file content + cmd=$(echo "$cmd" | sed "s|$escaped_inject_part|$inject_content|g") + + log d "Replaced cmd: $cmd" + else + log e "File \"$inject_file_full_path\" not found. Removing %INJECT% placeholder." + + # Use sed to remove the entire %INJECT%=...'something'.extension + escaped_inject_part=$(printf '%s' "%INJECT%='$inject_file'$extension" | sed 's/[]\/$*.^[]/\\&/g') + cmd=$(echo "$cmd" | sed "s|$escaped_inject_part||g") + + log d "sedded cmd: $cmd" + fi + done + + log d "Returning the command with injected content: $cmd" + echo "$cmd" +} + +# Function to get the first available emulator in the list +get_first_emulator() { + local system_name=$system + system_section=$(xmllint --xpath "//system[name='$system_name']" "$es_systems" 2>/dev/null) + + if [ -z "$system_section" ]; then + log e "System not found: $system_name" + exit 1 + fi + + # Extract the first command and use it as the selected emulator + first_command=$(echo "$system_section" | xmllint --xpath "string(//command[1])" - 2>/dev/null) + + if [[ -n "$first_command" ]]; then + # Substitute placeholders in the command + first_command=$(substitute_placeholders "$first_command") + log d "Automatically selected the first emulator: $first_command" + echo "$first_command" + else + log e "No command found for the system: $system_name" + return 1 + fi +} + +find_emulator() { + local emulator_name=$1 + local found_path="" + + # Search the es_find_rules.xml file for the emulator + emulator_section=$(xmllint --xpath "//emulator[@name='$emulator_name']" "$es_find_rules" 2>/dev/null) + + if [ -z "$emulator_section" ]; then + log e "Emulator not found: $emulator_name" + return 1 + fi + + # Search systempath entries + while IFS= read -r line; do + command_path=$(echo "$line" | sed -n 's/.*\(.*\)<\/entry>.*/\1/p') + if [ -x "$(command -v $command_path)" ]; then + found_path=$command_path + break + fi + done <<< "$(echo "$emulator_section" | xmllint --xpath "//rule[@type='systempath']/entry" - 2>/dev/null)" + + # If not found, search staticpath entries + if [ -z "$found_path" ]; then + while IFS= read -r line; do + command_path=$(eval echo "$line" | sed -n 's/.*\(.*\)<\/entry>.*/\1/p') + if [ -x "$command_path" ]; then + found_path=$command_path + break + fi + done <<< "$(echo "$emulator_section" | xmllint --xpath "//rule[@type='staticpath']/entry" - 2>/dev/null)" + fi + + if [ -z "$found_path" ]; then + log e "No valid path found for emulator: $emulator_name" + return 1 + else + log d "Found emulator: \"$found_path\"" + echo "$found_path" + return 0 + fi +} + +# Function to find the emulator name from the label in es_systems.xml +find_emulator_name_from_label() { + local label="$1" + + # Search for the emulator matching the label in the es_systems.xml file + extracted_emulator_name=$(xmllint --recover --xpath "string(//system[name='$system']/command[@label='$label']/text())" "$es_systems" 2>/dev/null | sed 's/%//g' | sed 's/EMULATOR_//g' | cut -d' ' -f1) + + if [[ -n "$extracted_emulator_name" ]]; then + log d "Found emulator by label: $extracted_emulator_name" + echo "$extracted_emulator_name" + else + log e "Emulator name not found for label: $label" + return 1 + fi +} From ab0f3e033a2347eb7811cfcdbaaaada5bed84948 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Thu, 12 Sep 2024 10:38:00 +0900 Subject: [PATCH 18/23] RUN_GAME: altemulator working --- functions/global.sh | 3 +- functions/run_game.sh | 272 +++++++++++++++++++++--------------------- 2 files changed, 137 insertions(+), 138 deletions(-) diff --git a/functions/global.sh b/functions/global.sh index 5792a51a..0488a22b 100644 --- a/functions/global.sh +++ b/functions/global.sh @@ -54,7 +54,7 @@ cooker_repository_name="Cooker" main_repository_name="RetroDECK" # The name of the main repository under RetroDECK organization features="$config/retrodeck/reference_lists/features.json" # A file where all the RetroDECK and component capabilities are kept for querying es_systems="/app/share/es-de/resources/systems/linux/es_systems.xml" # ES-DE supported system list -es_find_rules="/app/share/es-de/resources/systems/linux/es_find_rules.xml" # ES-DE emulator find rules +es_find_rules="/app/share/es-de/resources/systems/linux/es_find_rules.xml" # ES-DE emulator find rules # Godot data transfer temp files @@ -84,6 +84,7 @@ es_source_logs="/var/config/ES-DE/logs" raconf="/var/config/retroarch/retroarch.cfg" ra_core_conf="/var/config/retroarch/retroarch-core-options.cfg" ra_scummvm_conf="/var/config/retroarch/system/scummvm.ini" +ra_cores_path="/var/config/retroarch/cores" # CEMU config files diff --git a/functions/run_game.sh b/functions/run_game.sh index c6cee211..8cba7459 100755 --- a/functions/run_game.sh +++ b/functions/run_game.sh @@ -1,111 +1,106 @@ #!/bin/bash run_game() { - # Initialize variables - emulator="" - system="" - manual_mode=false + # Initialize variables + emulator="" + system="" + manual_mode=false - # Parse options - while getopts ":e:s:m" opt; do # Use `m` for manual mode flag - case ${opt} in - e ) - emulator=$OPTARG - ;; - s ) - system=$OPTARG - ;; - m ) - manual_mode=true - log i "Run game: manual mode enabled" - ;; - \? ) - echo "Usage: $0 --run [-e emulator] [-s system] [-m manual] game" - exit 1 - ;; - esac - done - shift $((OPTIND -1)) + # Parse options for system, emulator, and manual mode + while getopts ":e:s:m" opt; do + case ${opt} in + e) + emulator=$OPTARG # Emulator provided via -e + ;; + s) + system=$OPTARG # System provided via -s + ;; + m) + manual_mode=true # Manual mode enabled via -m + log i "Run game: manual mode enabled" + ;; + \?) + echo "Usage: $0 --run [-e emulator] [-s system] [-m manual] game" + exit 1 + ;; + esac + done + shift $((OPTIND - 1)) - # Check for game argument - if [[ -z "$1" ]]; then - log e "Game path is required." - log i "Usage: $0 start [-e emulator] [-s system] [-m manual] game" - exit 1 - fi + # Check for game argument + if [[ -z "$1" ]]; then + log e "Game path is required." + log i "Usage: $0 start [-e emulator] [-s system] [-m manual] game" + exit 1 + fi - game=$1 + game=$1 + game_basename="./$(basename "$game")" - # If no system is provided, extract it from the game path - if [[ -z "$system" ]]; then - system=$(echo "$game" | grep -oP '(?<=roms/)[^/]+') - fi - - log d "Game: \"$game\"" - log d "System: \"$system\"" - - # Try finding the inside the specific game block - altemulator=$(xmllint --recover --xpath "string(//game[path='$game']/altemulator)" "$rdhome/ES-DE/gamelists/$system/gamelist.xml" 2>/dev/null) - - if [[ -n "$altemulator" ]]; then - log d "Alternate emulator found in : $altemulator" - emulator_name=$(echo "$altemulator" | sed -e 's/ (Standalone)//') # Strip " (Standalone)" from name - emulator=$(find_emulator "$emulator_name") - - if [[ -n "$emulator" ]]; then - log d "Using alternate emulator: $emulator" - else - log e "No valid path found for emulator: $altemulator" - exit 1 - fi - else - # Try to fetch from anywhere in the document - alternative_emulator=$(xmllint --recover --xpath 'string(//alternativeEmulator/label)' "$rdhome/ES-DE/gamelists/$system/gamelist.xml" 2>/dev/null) - - if [[ -n "$alternative_emulator" ]]; then - log d "Alternate emulator found in header: $alternative_emulator" - - # Find the emulator name from the label in es_systems.xml - emulator_name=$(find_emulator_name_from_label "$alternative_emulator") - - if [[ -n "$emulator_name" ]]; then - # Pass the extracted emulator name to find_emulator function - emulator=$(find_emulator "$emulator_name") + # Step 1: System Recognition + if [[ -z "$system" ]]; then + # Automatically detect system from game path + system=$(echo "$game" | grep -oP '(?<=roms/)[^/]+') + if [[ -z "$system" ]]; then + log e "Failed to detect system from game path." + exit 1 fi - - if [[ -n "$emulator" ]]; then - log d "Using alternate emulator from : $emulator" - else - log e "No valid path found for emulator: $alternative_emulator" + fi + log d "System recognized: $system" + + # Step 2: Emulator Definition + if [[ -n "$emulator" ]]; then + log d "Emulator provided via command-line: $emulator" + elif [[ "$manual_mode" = true ]]; then + log d "Manual mode: showing Zenity emulator selection" + emulator=$(show_zenity_emulator_list "$system") + if [[ -z "$emulator" ]]; then + log e "No emulator selected in manual mode." exit 1 fi else - log i "No alternate emulator found in game block or header, proceeding to auto mode." + log d "Automatically searching for an emulator for system: $system" + + # Check for in the game block in gamelist.xml + altemulator=$(xmllint --recover --xpath "string(//game[path='$game_basename']/altemulator)" "$rdhome/ES-DE/gamelists/$system/gamelist.xml" 2>/dev/null) + + if [[ -n "$altemulator" ]]; then + log d "Found for game: $altemulator" + emulator=$(xmllint --recover --xpath "string(//command[@label=\"$altemulator\"])" "$es_systems" 2>/dev/null) + fi + + # Fallback to first available emulator in es_systems.xml if no found + if [[ -z "$emulator" ]]; then + log d "No alternate emulator found, using first available emulator in es_systems.xml" + emulator_command=$(xmllint --recover --xpath "string(//system[name='$system']/command[1])" "$es_systems" 2>/dev/null) + emulator=$(find_emulator_name_from_label "$emulator_command") + fi + + if [[ -z "$emulator" ]]; then + log e "No valid emulator found for system: $system" + exit 1 + fi fi - fi - # If an emulator is found, substitute placeholders in the command before running - if [[ -n "$emulator" ]]; then - # Ensure command substitution - find_system_commands "$emulator" - # TODO: almost there, we need just to start the emulator without Zenity: maybe we have to edit THAT function to pass the emulator to run - log d "Final command: $command" - eval "$command" - else - log e "No emulator found or selected. Exiting." - return 1 - fi - - # If the emulator is not specified or manual mode is set, ask the user to select it via Zenity - if [[ -z "$emulator" && "$manual_mode" == true ]]; then - emulator=$(find_system_commands) - fi + # Step 3: Construct and Run the Command + log d "Preparing to launch with emulator: $emulator" - # If emulator is still not set, fall back to the first available emulator - if [[ -z "$emulator" ]]; then - emulator=$(get_first_emulator) - fi + # Now pass the final constructed command to substitute_placeholders function + final_command=$(substitute_placeholders "$emulator") + # Log and execute the command + log i "Launching game with command: $final_command" + eval "$final_command" +} + + +# Assume this function handles showing the Zenity list of emulators for manual mode +show_zenity_emulator_list() { + local system="$1" + # Example logic to retrieve and show Zenity list of emulators for the system + # This would extract available emulators for the system from es_systems.xml and show a Zenity dialog + emulators=$(xmllint --xpath "//system[name='$system']/command/@label" "$es_systems" | sed 's/ label=/\n/g' | sed 's/\"//g' | grep -o '[^ ]*') + zenity --list --title="Select Emulator" --column="Emulators" $emulators } # Function to extract commands from es_systems.xml and present them in Zenity @@ -153,6 +148,7 @@ find_system_commands() { # Function to substitute placeholders in the command substitute_placeholders() { local cmd="$1" + log d "Substitute placeholder: working on $cmd" local rom_path="$game" local rom_dir=$(dirname "$rom_path") @@ -183,9 +179,9 @@ substitute_placeholders() { cmd="${cmd//"%ROM%"/"'$rom_path'"}" cmd="${cmd//"%GAMEDIR%"/"'$rom_dir'"}" cmd="${cmd//"%GAMEDIRRAW%"/"'$rom_dir_raw'"}" - cmd="${cmd//"%CORE_RETROARCH%"/"/var/config/retroarch/cores"}" + cmd="${cmd//"%CORE_RETROARCH%"/"$ra_cores_path"}" - log d "Command after %BASENAME% and other substitutions: $cmd" + log d "Command after placeholders substitutions: $cmd" # Now handle %INJECT% after %BASENAME% has been substituted cmd=$(handle_inject_placeholder "$cmd") @@ -276,45 +272,45 @@ get_first_emulator() { } find_emulator() { - local emulator_name=$1 - local found_path="" + local emulator_name="$1" + found_path="" - # Search the es_find_rules.xml file for the emulator - emulator_section=$(xmllint --xpath "//emulator[@name='$emulator_name']" "$es_find_rules" 2>/dev/null) - - if [ -z "$emulator_section" ]; then - log e "Emulator not found: $emulator_name" - return 1 - fi - - # Search systempath entries - while IFS= read -r line; do - command_path=$(echo "$line" | sed -n 's/.*\(.*\)<\/entry>.*/\1/p') - if [ -x "$(command -v $command_path)" ]; then - found_path=$command_path - break - fi - done <<< "$(echo "$emulator_section" | xmllint --xpath "//rule[@type='systempath']/entry" - 2>/dev/null)" - - # If not found, search staticpath entries - if [ -z "$found_path" ]; then - while IFS= read -r line; do - command_path=$(eval echo "$line" | sed -n 's/.*\(.*\)<\/entry>.*/\1/p') - if [ -x "$command_path" ]; then - found_path=$command_path - break - fi - done <<< "$(echo "$emulator_section" | xmllint --xpath "//rule[@type='staticpath']/entry" - 2>/dev/null)" - fi - - if [ -z "$found_path" ]; then - log e "No valid path found for emulator: $emulator_name" - return 1 - else - log d "Found emulator: \"$found_path\"" - echo "$found_path" - return 0 - fi + # Search the es_find_rules.xml file for the emulator + emulator_section=$(xmllint --xpath "//emulator[@name='$emulator_name']" "$es_find_rules" 2>/dev/null) + + if [ -z "$emulator_section" ]; then + log e "Find emulator: emulator not found: $emulator_name" + return 1 + fi + + # Search systempath entries + while IFS= read -r line; do + command_path=$(echo "$line" | sed -n 's/.*\(.*\)<\/entry>.*/\1/p') + if [ -x "$(command -v $command_path)" ]; then + found_path=$command_path + break + fi + done <<< "$(echo "$emulator_section" | xmllint --xpath "//rule[@type='systempath']/entry" - 2>/dev/null)" + + # If not found, search staticpath entries + if [ -z "$found_path" ]; then + while IFS= read -r line; do + command_path=$(eval echo "$line" | sed -n 's/.*\(.*\)<\/entry>.*/\1/p') + if [ -x "$command_path" ]; then + found_path=$command_path + break + fi + done <<< "$(echo "$emulator_section" | xmllint --xpath "//rule[@type='staticpath']/entry" - 2>/dev/null)" + fi + + if [ -z "$found_path" ]; then + log e "Find emulator: no valid path found for emulator: $emulator_name" + return 1 + else + log d "Find emulator: found emulator \"$found_path\"" + echo "$found_path" + return 0 + fi } # Function to find the emulator name from the label in es_systems.xml @@ -323,12 +319,14 @@ find_emulator_name_from_label() { # Search for the emulator matching the label in the es_systems.xml file extracted_emulator_name=$(xmllint --recover --xpath "string(//system[name='$system']/command[@label='$label']/text())" "$es_systems" 2>/dev/null | sed 's/%//g' | sed 's/EMULATOR_//g' | cut -d' ' -f1) + log d "Found emulator from label: $extracted_emulator_name" - if [[ -n "$extracted_emulator_name" ]]; then - log d "Found emulator by label: $extracted_emulator_name" - echo "$extracted_emulator_name" + emulator_command=$(find_emulator "$extracted_emulator_name") + + if [[ -n "$emulator_command" ]]; then + echo "$emulator_command" else - log e "Emulator name not found for label: $label" + log e "Found emulator from label: emulator name not found for label: $label" return 1 fi } From 3055ee5d94db22c1305bd6a4fb6adf4321f433a2 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Thu, 12 Sep 2024 10:52:34 +0900 Subject: [PATCH 19/23] RUN_GAME: alternativeEmulator added but not working --- functions/run_game.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/functions/run_game.sh b/functions/run_game.sh index 8cba7459..2dbee57c 100755 --- a/functions/run_game.sh +++ b/functions/run_game.sh @@ -67,10 +67,26 @@ run_game() { if [[ -n "$altemulator" ]]; then log d "Found for game: $altemulator" emulator=$(xmllint --recover --xpath "string(//command[@label=\"$altemulator\"])" "$es_systems" 2>/dev/null) + else + + log d "No altemulator found in the game entry, searching for alternativeEmulator to check if a global emulator is set for the system $system" + + alternative_emulator=$(xmllint --recover --xpath 'string(//alternativeEmulator/label)' "$rdhome/ES-DE/gamelists/$system/gamelist.xml" 2>/dev/null) + + log d "Alternate emulator found in header: $alternative_emulator" + + # TODO: fix this function + # [2024-09-12 10:51:11.232] [DEBUG] Alternate emulator found in header: PicoDrive + # then is broken + + # Find the emulator name from the label in es_systems.xml + emulator_name=$(find_emulator_name_from_label "$alternative_emulator") + emulator=$(find_emulator "$emulator_name") fi # Fallback to first available emulator in es_systems.xml if no found if [[ -z "$emulator" ]]; then + # TODO: the non-alt emulator is broken log d "No alternate emulator found, using first available emulator in es_systems.xml" emulator_command=$(xmllint --recover --xpath "string(//system[name='$system']/command[1])" "$es_systems" 2>/dev/null) emulator=$(find_emulator_name_from_label "$emulator_command") From a1e55bb06b33133bf79638f4298e4b2e8f667341 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Thu, 12 Sep 2024 11:30:39 +0900 Subject: [PATCH 20/23] RUN_GAME: fixed alternativeEmulator --- functions/run_game.sh | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/functions/run_game.sh b/functions/run_game.sh index 2dbee57c..4f3afcbd 100755 --- a/functions/run_game.sh +++ b/functions/run_game.sh @@ -65,23 +65,17 @@ run_game() { altemulator=$(xmllint --recover --xpath "string(//game[path='$game_basename']/altemulator)" "$rdhome/ES-DE/gamelists/$system/gamelist.xml" 2>/dev/null) if [[ -n "$altemulator" ]]; then + log d "Found for game: $altemulator" emulator=$(xmllint --recover --xpath "string(//command[@label=\"$altemulator\"])" "$es_systems" 2>/dev/null) - else + + else # if no altemulator is found we search if a global one is set log d "No altemulator found in the game entry, searching for alternativeEmulator to check if a global emulator is set for the system $system" - alternative_emulator=$(xmllint --recover --xpath 'string(//alternativeEmulator/label)' "$rdhome/ES-DE/gamelists/$system/gamelist.xml" 2>/dev/null) - log d "Alternate emulator found in header: $alternative_emulator" + emulator=$(xmllint --recover --xpath "string(//system[platform='$system']/command[@label=\"$alternative_emulator\"])" "$es_systems" 2>/dev/null) - # TODO: fix this function - # [2024-09-12 10:51:11.232] [DEBUG] Alternate emulator found in header: PicoDrive - # then is broken - - # Find the emulator name from the label in es_systems.xml - emulator_name=$(find_emulator_name_from_label "$alternative_emulator") - emulator=$(find_emulator "$emulator_name") fi # Fallback to first available emulator in es_systems.xml if no found From d980c9858f0847bf37c759c55bb06bbc26b2e669 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Thu, 12 Sep 2024 11:45:24 +0900 Subject: [PATCH 21/23] RA: added libbz2 (to be outsourced) --- net.retrodeck.retrodeck.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/net.retrodeck.retrodeck.yml b/net.retrodeck.retrodeck.yml index acda1f52..becf1bb6 100644 --- a/net.retrodeck.retrodeck.yml +++ b/net.retrodeck.retrodeck.yml @@ -197,6 +197,24 @@ modules: sha256: RASHAPLACEHOLDER # Not part of the offical RetroArch AppImage + + # TODO: outsource me + - name: libbz2 + no-autogen: true + make-args: + - --f=Makefile-libbz2_so + - PREFIX=${FLATPAK_DEST} + no-make-install: true + post-install: + - mv libbz2.so.1.0.8 ${FLATPAK_DEST}/lib/ + - ln -s ${FLATPAK_DEST}/lib/libbz2.so.1.0.8 ${FLATPAK_DEST}/lib/libbz2.so.1.0 + sources: + - type: archive + url: https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz + sha256: ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269 + + # TODO: If more are mising are here: https://github.com/flathub/org.libretro.RetroArch/tree/8c388bb84df63b3a2efb40dc3d8f78df7717059e/modules + # retroarch-cores-nightly must be earlier than retroarch-cores as it will overwrite this cores with the stable ones - name: retroarch-cores-nightly buildsystem: simple From f2f7e0946a620a5b07d6600bb7946848900334d9 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Thu, 12 Sep 2024 14:25:57 +0900 Subject: [PATCH 22/23] RUN_GAME: fixed default emulator launch --- functions/run_game.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/functions/run_game.sh b/functions/run_game.sh index 4f3afcbd..f15a17b0 100755 --- a/functions/run_game.sh +++ b/functions/run_game.sh @@ -35,6 +35,13 @@ run_game() { fi game=$1 + + if [[ -d "$game" ]]; then + log d "$(basename "$game") is a directory, parsing it like a \"directory as a file\"" + game="$game/$(basename "$game")" + log d "Actual file is in \"$game\"" + fi + game_basename="./$(basename "$game")" # Step 1: System Recognition @@ -46,7 +53,6 @@ run_game() { exit 1 fi fi - log d "System recognized: $system" # Step 2: Emulator Definition if [[ -n "$emulator" ]]; then @@ -80,10 +86,8 @@ run_game() { # Fallback to first available emulator in es_systems.xml if no found if [[ -z "$emulator" ]]; then - # TODO: the non-alt emulator is broken log d "No alternate emulator found, using first available emulator in es_systems.xml" - emulator_command=$(xmllint --recover --xpath "string(//system[name='$system']/command[1])" "$es_systems" 2>/dev/null) - emulator=$(find_emulator_name_from_label "$emulator_command") + emulator=$(xmllint --recover --xpath "string(//system[name='$system']/command[1])" "$es_systems") fi if [[ -z "$emulator" ]]; then @@ -93,7 +97,12 @@ run_game() { fi # Step 3: Construct and Run the Command - log d "Preparing to launch with emulator: $emulator" + log i "-------------------------------------------" + log i " RetroDECK is now booting the game" + log i " Game path: \"$game\"" + log i " Recognized system: $system" + log i " Given emulator: $emulator" + log i "-------------------------------------------" # Now pass the final constructed command to substitute_placeholders function final_command=$(substitute_placeholders "$emulator") From 6614c8adf836aeb9f4d075f2aeb16a310a68b641 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Thu, 12 Sep 2024 14:49:19 +0900 Subject: [PATCH 23/23] RUN_GAME: fixed help arguments --- functions/run_game.sh | 4 ++-- retrodeck.sh | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/functions/run_game.sh b/functions/run_game.sh index f15a17b0..8f084a05 100755 --- a/functions/run_game.sh +++ b/functions/run_game.sh @@ -20,7 +20,7 @@ run_game() { log i "Run game: manual mode enabled" ;; \?) - echo "Usage: $0 --run [-e emulator] [-s system] [-m manual] game" + echo "Usage: $0 start [-e emulator] [-s system] [-m] game" exit 1 ;; esac @@ -30,7 +30,7 @@ run_game() { # Check for game argument if [[ -z "$1" ]]; then log e "Game path is required." - log i "Usage: $0 start [-e emulator] [-s system] [-m manual] game" + log i "Usage: $0 start [-e emulator] [-s system] [-m] game" exit 1 fi diff --git a/retrodeck.sh b/retrodeck.sh index 94be9b78..146371f4 100644 --- a/retrodeck.sh +++ b/retrodeck.sh @@ -28,11 +28,15 @@ Arguments: --info-msg \t Print paths and config informations --configurator \t Starts the RetroDECK Configurator --compress-one \t Compresses target file to a compatible format - --compress-all \t Compresses all supported games into a compatible format.\n\t\t\t\t\t\t Available formats are \"chd\", \"zip\", \"rvz\" and \"all\". + --compress-all \t Compresses all supported games into a compatible format.\n\t\t\t\t\t\t Available formats are \"chd\", \"zip\", \"rvz\" and \"all\" --reset-component \t Reset one or more component or emulator configs to the default values --reset-retrodeck \t Starts the initial RetroDECK installer (backup your data first!) - start [-s ] [-e ] \t Start a game from cli, if no system is defined it will deducted from the path.\n\t\t\t\t\t\t For example flatpak run net.retrodeck.retrodeck start ~/retrodeck/roms/system/game.ext will be run with the system "system".\n\t\t\t\t\t\t Optionally -e (emulator) and -s (system) can be passed as arguments. + start [-e emulator] [-s system] [-m] \t Start a game from cli using the default emulator or\n\t\t\t\t\t\t\t the one defined in ES-DE for game or system + \t start arguments: + \t \t-e (emulator)\t Run the game with the defined emulator (optional) + \t \t-s (system)\t Force the game running with the defined system, for example running a gb game on gba (optional) + \t \t-m (manual)\t Manual mode: show the list of available emulator to chose from (optional) For flatpak run specific options please run: flatpak run -h