Files
Triforce-Source/tests/test_mouse_settings.py
ruckus7382sfgsgdf 6c7117635c Triforce v0.6.0 "Sage Of Power"
Faster frames (the replay's memory work, held submits, helper threads, collection and capture cuts), the game letting old areas go (QueryMemoryInfo), the 0.5.2 stutter fixed, AMD RX 5000/6000 and integrated-GPU fixes, the GPU device chosen by name, the in-game menus and launcher reworked, controller, Linux and benchmark fixes.
2026-11-20 17:06:21 -06:00

53 lines
2.8 KiB
Python

"""The mouse's sensitivity and inversion are the Insert menu's (options 7 and 8), and - and = change the menu's value.
Reads the sources: the menu's rows and their options, the renderer's option_set back to the menu, and the host reading
both options where the mouse is used (host/nn_hid.c's stick, host/mouse_native.c).
python -I -B tests/test_mouse_settings.py
"""
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def preset_exempt(menu, value):
"""the menu has no quality preset that a change of the row's could reset ((Triforce, options_version 7) the Quality preset
row is gone, and with it the memory budget it set: the card's own), and the row is on its tab"""
start = menu.index("&opts.%s," % value, menu.index("Row rows[] = {"))
row = menu[start:menu.index("},", start)]
return bool(row) and "opts.preset" not in menu and "void apply_preset" not in menu
def read(*parts):
return (ROOT.joinpath(*parts)).read_text(encoding="utf-8")
def main():
menu, replay, api = read("gpu", "vk", "vk_menu.cpp"), read("gpu", "vk", "vk_replay.cpp"), read("gpu", "vk", "vk_api.h")
hid, native, backend = read("host", "nn_hid.c"), read("host", "mouse_native.c"), read("host", "rx_backend.c")
for row in ('"Mouse sensitivity", &opts.mouse_sens, 10, 500,', '"Invert mouse vertical", &opts.mouse_invert, 0, 1,'):
if row not in menu:
raise SystemExit("the menu lost a mouse row: " + row)
if "id == 7 ? opts.mouse_sens" not in replay or "id == 8 ? opts.mouse_invert" not in replay:
raise SystemExit("options 7 and 8 do not reach the host")
sets = "t.option_set = menu_option_set" in replay or ("t.option_set = [](int id, int value) {" in replay
and " menu_option_set(id, value);" in replay)
if not sets or "void (*option_set)(int id, int value);" not in api:
raise SystemExit("the host cannot change the menu's sensitivity")
if "vk->option_set(id, value)" not in backend:
raise SystemExit("rx_option_set does not reach the renderer")
keys = hid[hid.index("static void mouse_sens_keys("):]
keys = keys[:keys.index("\n}\n")]
if "rx_option(7, 100)" not in keys or "rx_option_set(7," not in keys:
raise SystemExit("- and = do not change the menu's sensitivity")
if "HOS_MOUSE_SENS" not in keys:
raise SystemExit("HOS_MOUSE_SENS no longer wins over the menu")
if "rx_option(8, 0)" not in hid or "rx_option(8, 0)" not in native:
raise SystemExit("the menu's inversion is not read by both mouse paths")
if not preset_exempt(menu, "mouse_sens"):
raise SystemExit("a mouse setting turns the quality preset to Custom")
print("PASS: the mouse's settings are the menu's")
if __name__ == "__main__":
main()