mirror of
https://git.triforceproject.com/triforce/source
synced 2026-12-01 05:18:50 -04:00
Character tab, faster renderer defaults, HD rumble shipped, and the 11-30 bug pass: ending softlock below 60 fps, adult first-night lock, Intel Arc robust buffers, adult map, randomizer load order.
79 lines
4.8 KiB
Python
79 lines
4.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,',
|
|
'"Invert mouse horizontal", &opts.mouse_invert_x, 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")
|
|
# ((Triforce) 11-24: Invert mouse horizontal, option 190: answered by the renderer, read by both mouse paths, and
|
|
# applied where each takes the mouse's sideways motion)
|
|
if "enum { HOS_OPT_MOUSE_INVERT_X = 190 };" not in api or \
|
|
"if (id == HOS_OPT_MOUSE_INVERT_X) return opts.mouse_invert_x != 0;" not in replay:
|
|
raise SystemExit("option 190, Invert mouse horizontal, does not reach the host")
|
|
if "rx_option(HOS_OPT_MOUSE_INVERT_X, 0)" not in hid or "rx_option(190, 0)" not in native:
|
|
raise SystemExit("the menu's horizontal inversion is not read by both mouse paths")
|
|
for text, where in (("dyaw = (float)((invert_x() ? -dx : dx) * k);", native),
|
|
("look_x += (invert_x ? -dx : dx) * k;", hid),
|
|
("mouse_look_move(invert_x ? -dx : dx, invert ? dy : -dy);", hid)):
|
|
if text not in where:
|
|
raise SystemExit("the mouse's left and right are not swapped where it is read: " + text)
|
|
# ((Triforce, 11-30) every change of the sensitivity is logged with its writer: the file at the start, the host's keys, the
|
|
# options' own input at a tick's end, and any other at a tick's start (a player's 0.30 that nobody's log explained)
|
|
watch = menu[menu.index("void sens_watch(const char* why) {"):]
|
|
watch = watch[:watch.index("\n}\n")]
|
|
if "opts.mouse_sens" not in watch or "logf(" not in watch:
|
|
raise SystemExit("sens_watch no longer logs the sensitivity's changes")
|
|
tick = menu[menu.index("void menu_tick() {"):]
|
|
if not tick.startswith('void menu_tick() {\n sens_watch("another writer'):
|
|
raise SystemExit("menu_tick does not look for another writer of the sensitivity first")
|
|
for need in ("sens_watch(\"the options' input at this tick", 'sens_watch("the host: its - or = key',
|
|
'sens_watch("as the options file has it, at the start")'):
|
|
if need not in menu:
|
|
raise SystemExit("a writer of the sensitivity is not logged: " + need)
|
|
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()
|