Skip to content

Insert menu: Stick dead zone (Default 24%, 5%–30%), one cut for SDL and XInput pads (#752) - #932

Closed
amaralthalesalves wants to merge 1 commit into
NotRexed:mainfrom
amaralthalesalves:feat/stick-dead-zone
Closed

amaralthalesalves wants to merge 1 commit into
NotRexed:mainfrom
amaralthalesalves:feat/stick-dead-zone

Conversation

@amaralthalesalves

Copy link
Copy Markdown
Contributor

Closes #752.

Both pad paths cut each stick axis at XInput's 7849 (about 24%): pad_sdl.c's stick_value and nn_hid.c's XInput pads_read. They now go through one function, hos_stick_axis(v, zone) in nn_hid.c, with the threshold chosen by a new Insert menu row on the Controls tab:

  • Stick dead zone: Default (24%), 5%, 10%, 15%, 20%, 30%. It's saved as stick_dead_zone in hookshot_options.ini by the same row-name mechanism as the other options, and clamped to 0..5.
  • Menu option id 18 (vk_replay.cpp's t.option). Like the other controls rows, it doesn't move the quality preset to Custom.
  • At Default the output is the same as before for every input on both paths, so options_version isn't bumped: an ini without the key reads as 0, which is today's behaviour.
  • The cut is per axis and only the threshold changes; there's no anti-dead-zone scaling. The game's own dead zone still applies after ours, which the row's help text and the readme say.

Tests: tests/test_stick_dead_zone.py, registered in run_all.py with gcc/g++.

  • It compiles the real hos_stick_axis and stick_value with gcc -Wall -Werror and checks them against copies of the old XInput and SDL code for all 65536 inputs at Default, plus each threshold's edges in both directions and out-of-range zones.
  • Through g++ it uses the real Row, tx_stick_dead_zone, ini_key and menu_init's parse line: it checks clamping (3, 9, -4, x, a misspelled key) and the labels.
  • It also checks in the source that id 18 is wired, that the row doesn't reset the preset, and that the readme row is there.
$ python -I -B tests/test_stick_dead_zone.py          # main
FAIL: nn_hid.c has no hos_stick_axis
$ python -I -B tests/test_stick_dead_zone.py          # this branch
stick: Default is the old cut for all 65536 inputs, both paths; 5 other thresholds exact
menu: stick_dead_zone parses and clamps to 0..5; labels Default (24%) ... 30%
ok

The related input, rumble, text-speed and mouse tests pass. nn_hid.c and pad_sdl.c pass gcc -fsyntax-only -Wall, and vk_menu.cpp and vk_replay.cpp pass g++ -fsyntax-only.

Not verified: I have no game or GPU here, so I haven't seen the row drawn on screen or played with the lower settings.

Both pad paths cut each axis at XInput's 7849 (~24%). They now cut through one
function, nn_hid.c's hos_stick_axis, at the row's threshold: Default (7849, the
same output as before for every input), 5%, 10%, 15%, 20%, 30%. Per axis, as
before; no anti-deadzone scaling. tests/test_stick_dead_zone.py checks all
65536 inputs on both paths, each threshold, and the ini parsing and labels.
@amaralthalesalves

Copy link
Copy Markdown
Contributor Author

Closing for now: this is a feature request rather than a bug fix, and I'd rather leave feature decisions to the maintainers. The branch stays up if anyone wants to pick it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Controller dead zone adjuster

1 participant