Files
psxrecomp/runtime/tests/test_mod_controller_override.py
T
Matthew Stanley 987c6eeced Revert "Merge pull request #87 from mstan/feat/ui-5p"
This reverts commit e01347cbca, reversing
changes made to 60cb60eee6.
2026-07-31 15:37:57 -07:00

37 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""Guard the game-owned controller-mode override lifecycle."""
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
MAIN = (ROOT / "runtime" / "src" / "main.cpp").read_text(encoding="utf-8")
HEADER = (ROOT / "runtime" / "include" / "mod_plugins.h").read_text(
encoding="utf-8"
)
for symbol in (
"PSX_MOD_CONTROLLER_HYBRID",
"PSX_MOD_CONTROLLER_ANALOG",
"PSX_MOD_CONTROLLER_DIGITAL",
"psx_mod_set_controller_mode_override",
):
assert symbol in HEADER, f"missing trusted-plugin controller API: {symbol}"
reset = """g_mod_controller_mode_override[0] = -1;
g_mod_controller_mode_override[1] = -1;"""
activate = "mod_runtime_activate_plugins();"
apply = """if (g_mod_controller_mode_override[0] >= 0)
p1_mode = g_mod_controller_mode_override[0];
if (g_mod_controller_mode_override[1] >= 0)
p2_mode = g_mod_controller_mode_override[1];"""
assert reset in MAIN, "controller overrides must reset before every activation pass"
assert activate in MAIN, "plugins must activate after controller overrides reset"
assert apply in MAIN, "controller overrides must replace the resolved launch modes"
assert MAIN.index(reset) < MAIN.index(activate) < MAIN.index(apply), (
"reset/activate must precede controller override application"
)
print("mod controller override lifecycle guard passed")