Files
Triforce-Source/tests/test_mouse_settings.py
ruckus7382sfgsgdf 4fa4f9188b Triforce v0.8.0
Evil HD (SMAA Ultra, 16x filtering, full textures, ambient occlusion with bounce light, sunlight shafts, foliage drawn 4x as far, the remastered texture pack's loader and the launcher's download of it), FSR 3.1 frame generation for every GPU, Intel XeSS, FSR 4 model choice, ReShade presets, Auto (this PC), HUD placement, the options menu in 13 languages, a second input for every control, hold to toggle, DualSense speaker and haptics, NFC from the player's own dumps, the above-60 fps game fixes, the Debug tab's flight and Inventory fixes, the launcher's full settings, and over 250 fixes.
2026-11-25 10:21:32 -06:00

66 lines
3.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)
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()