webstation-broker
DeveloperPython referenceemulatorsemulators.flycast

emulators.flycast.Flycast

Exit-only Flycast (Sega Dreamcast) launcher.

Exit-only Flycast (Sega Dreamcast) launcher.

Save state is triggered by a graceful window-close request (Alt+F4) rather than a control socket, since Flycast has no other clean shutdown path; see the module docstring for the full hardware/protocol rationale.

Attributes

attributename
= 'flycast'
attributedisplay_name
= 'Flycast'
attributesave_root
= DATA_DIR.parent
attributesave_subtrees
= (DATA_DIR.name,)
attributerom_extensions
= ROM_EXTENSIONS
attributelog_path
= FLYCAST_LOG_PATH
attributeterm_timeout
= float(os.environ.get('FLYCAST_STOP_WAIT', '20'))

Functions

func__init__(self) -> None

Initialize the emulator with no ROM loaded yet.

paramself

Returns

None
funcresolve_rom_file(self, path) -> Optional[Path]

Resolve a ROM path to a single playable disc image or file.

paramself
parampathPath

A direct file path, or a folder searched up to one level deep for the best candidate, ranked by disc number, extension preference, and path depth.

Returns

typing.Optional

The resolved file path, or None if no suitable candidate was

func_xdotool(self, *args) -> Optional[str]

Run xdotool, returning its stdout, or None if it failed.

paramself
paramargsstr
= ()

Returns

typing.Optional[str]
func_window(self) -> Optional[str]

The window id belonging to this launch's own process, or None.

Matched by title then confirmed by pid rather than trusting the first title hit, since Alt+F4 acts on whatever id comes back and a stray match would close the wrong thing instead of just failing a hotkey.

paramself

Returns

typing.Optional[str]
funclaunch(self, rom_path, resume_slot) -> None

Stop any running instance and launch Flycast for the given ROM.

paramself
paramrom_pathPath

The resolved disc image or file to boot.

paramresume_slotOptional[int]

If not None and a resume state exists for this rom, enable auto-load on boot; otherwise boot fresh.

Returns

None
funcstop(self) -> None

Request a graceful exit via Alt+F4, then escalate if it does not take.

Activates the emulator's own window and sends Alt+F4 to trigger Flycast's only clean-shutdown path (SDL_QUIT). Falls back to the base class's SIGTERM/SIGKILL escalation if no window can be found or activated, or if the process has not exited within term_timeout.

paramself

Returns

None
funcclear_working_slot(self) -> None

Drop every resume state left in DATA_DIR before a restore.

The name only stops being ambiguous once the rom is known, and that happens after this runs (activate resolves the rom, clears the slot, then launches), so a leftover from an earlier local session for the same title would otherwise sit here with a newer mtime than the incoming archive member and get skipped by extract_save_archive's newer-file guard. Anything still here belongs to a session that already exited, so dropping it all is the same trade-off DuckStation's clear_working_slot makes.

paramself

Returns

None
funcsave_and_exit(self, slot) -> dict

Stop the emulator and report whether this exit actually saved state.

paramself
paramslotOptional[int]

The resume slot to report on. If None, the emulator is stopped without inspecting any resume state.

Returns

dict

A dict with "state_saved" (bool), "state_slot" (the given

On this page