emulators.pcsx2
PCSX2 launcher: disc-image resolution, PCSX2.ini patching, and PINE-driven save states.
PCSX2 launcher: disc-image resolution, PCSX2.ini patching, and PINE-driven save states.
Resolves a RomM ROM folder to the disc image pcsx2-qt boots, forces the broker-required PCSX2.ini settings before every launch, keeps a folder memory card waiting in Slot 1, and drives save state load and save over PCSX2's PINE socket. A boot watchdog confirms the VM actually reaches a running state, because a disc that fails to boot leaves PCSX2 sitting on an error dialog rather than exiting.
attributelog= logging.getLogger(__name__)attributeROM_ROOT= Path(os.environ.get('ROM_ROOT', '/romm'))Root of the RomM library mount (env ROM_ROOT, default /romm).
A resolved disc image must sit under it; candidates resolving outside are discarded.
attributeINI_PATH= Path('/config/.config/PCSX2/inis/PCSX2.ini')The PCSX2.ini the broker patches before every launch.
attributeSSTATE_DIR= Path(os.environ.get('SSTATE_DIR', '/config/.config/PCSX2/sstates'))Directory PCSX2 writes its .p2s save states into (env SSTATE_DIR).
attributePCSX2_LOG_PATH= Path(os.environ.get('PCSX2_LOG_PATH', '/config/pcsx2-qt.log'))Log file the broker tails for this emulator (env PCSX2_LOG_PATH, default /config/pcsx2-qt.log).
attributeSTATE_SLOT= int(os.environ.get('PCSX2_STATE_SLOT', '10'))The one slot the broker works in (env PCSX2_STATE_SLOT, default 10).
10 is PCSX2's own autosave slot, which the per-emulator broker has always used, so containers that ran that one keep resolving their existing states.
attributeMEMCARD_DIR= Path('/config/.config/PCSX2/memcards')Directory PCSX2 keeps its memory cards in.
attributeSLOT1_CARD_NAME= os.environ.get('PCSX2_SLOT1_CARD', 'romm-slot1')Name of the Slot-1 card the broker owns (env PCSX2_SLOT1_CARD, default romm-slot1).
PCSX2 tells a folder card from a file card by what it finds at the path, so
this is a directory and the name carries no .ps2 extension, to keep it from
reading as one of PCSX2's own file cards.
attributeSLOT1_MARKER= '_pcsx2_superblock'File that marks a directory as a folder card.
PCSX2 only counts a directory as a folder card once this file is inside it, and skips the directory entirely otherwise, which leaves the slot reading as missing with nowhere for the game to save.
attributePINE_WAIT= float(os.environ.get('PINE_WAIT', '20.0'))Seconds a save state has to land on disk after the PINE save command (env PINE_WAIT, default 20).
attributeRESUME_LOAD_WAIT= float(os.environ.get('RESUME_LOAD_WAIT', '90.0'))Seconds the boot watchdog gives the VM to start running (env RESUME_LOAD_WAIT, default 90).
attributeRESUME_LOAD_SETTLE= float(os.environ.get('RESUME_LOAD_SETTLE', '3.0'))Seconds to wait after the VM reports running before a resume load is sent (env RESUME_LOAD_SETTLE).
attributeXDG_RUNTIME_DIR= os.environ.get('XDG_RUNTIME_DIR', '/config/.XDG')Runtime directory PCSX2 creates its PINE socket in (env XDG_RUNTIME_DIR, default /config/.XDG).
attributePINE_SOCKET= Path(XDG_RUNTIME_DIR) / 'pcsx2.sock'Path of the PINE Unix socket pcsx2-qt listens on.
attributeROM_EXTENSIONS= ('.chd', '.iso', '.cso', '.zso', '.gz', '.mdf', '.dump', '.bin', '.elf')Disc formats pcsx2-qt can boot, best first.
A folder holding several candidates picks by this order so a .chd beats the
raw .bin beside it.