mnk: add opt-in chords, CapsLock, Driver*/Flight* bindings & aim wheel zoom #584

Open
aowu wants to merge 1 commit from aowu/Darner:pr/mnk-bindings-extensions into Main
First-time contributor

Summary

Extends bindings.ini with 100% opt-in, backwards-compatible PC mouse & keyboard capabilities while leaving the shipped default bindings.ini and all stock behavior completely unchanged unless configured:

  1. CapsLock key name: Accepts CapsLock / Caps (0x14) in bindings.ini.
  2. Multi-input chords (+ syntax): Bind a single PC key to a gamepad chord such as LS+RS = CapsLock (focus mode) or LT+DpadLeft = E (shoulder swap), with automatic aim lead-in when an LT+... chord is pressed from hipfire.
  3. Dedicated driver-seat overrides (opt-in):
    • DriverHorn: extra LS horn/nitrous key
    • DriverHeadlights: fixed 80 ms short-press B pulse (never triggers vehicle duck)
    • DriverDuck + DriverDuckMode = toggle | hold: dedicated vehicle duck with a 420 ms anti-headlight floor so rapid taps never flash headlights
  4. Dedicated aircraft-pilot overrides (opt-in):
    • FlightPitchDown, FlightPitchUp, FlightYawLeft, FlightYawRight, FlightRollLeft, FlightRollRight, FlightThrottleUp, FlightThrottleDown, FlightFire, FlightGear
    • Only activates when at least one Flight* key is configured in bindings.ini; otherwise stock AircraftPilot behavior is untouched.
  5. Aiming mouse-wheel zoom: When aiming (LT/RMB) and WheelUp/WheelDown are not explicitly bound elsewhere, scrolling pulses DpadUp/DpadDown for scope zoom.

Backwards Compatibility

  • Shipped bindings.ini is not modified.
  • Implemented additively via mnk::apply_native_extensions on top of stand_in_pad, preserving AZERTY layout handling, DARNER_BINDINGS_ONLY=1, DARNER_WHEEL_HOLD=1, and all existing unit tests unmodified.

Verification

  • Added unit tests:
    • chords_and_capslock_and_aim_wheel_zoom_work
    • opt_in_driver_overrides_separate_headlights_and_duck
    • opt_in_flight_overrides_only_activate_when_configured
  • cargo test -p darner-hle --lib gameinput passes (116 passed, 0 failed).
### Summary Extends `bindings.ini` with **100% opt-in, backwards-compatible** PC mouse & keyboard capabilities while leaving the shipped default `bindings.ini` and all stock behavior completely unchanged unless configured: 1. **`CapsLock` key name**: Accepts `CapsLock` / `Caps` (`0x14`) in `bindings.ini`. 2. **Multi-input chords (`+` syntax)**: Bind a single PC key to a gamepad chord such as `LS+RS = CapsLock` (focus mode) or `LT+DpadLeft = E` (shoulder swap), with automatic aim lead-in when an `LT+...` chord is pressed from hipfire. 3. **Dedicated driver-seat overrides (opt-in)**: - `DriverHorn`: extra `LS` horn/nitrous key - `DriverHeadlights`: fixed 80 ms short-press `B` pulse (never triggers vehicle duck) - `DriverDuck` + `DriverDuckMode = toggle | hold`: dedicated vehicle duck with a 420 ms anti-headlight floor so rapid taps never flash headlights 4. **Dedicated aircraft-pilot overrides (opt-in)**: - `FlightPitchDown`, `FlightPitchUp`, `FlightYawLeft`, `FlightYawRight`, `FlightRollLeft`, `FlightRollRight`, `FlightThrottleUp`, `FlightThrottleDown`, `FlightFire`, `FlightGear` - Only activates when at least one `Flight*` key is configured in `bindings.ini`; otherwise stock `AircraftPilot` behavior is untouched. 5. **Aiming mouse-wheel zoom**: When aiming (`LT`/RMB) and `WheelUp`/`WheelDown` are not explicitly bound elsewhere, scrolling pulses `DpadUp`/`DpadDown` for scope zoom. ### Backwards Compatibility - Shipped `bindings.ini` is not modified. - Implemented additively via `mnk::apply_native_extensions` on top of `stand_in_pad`, preserving AZERTY layout handling, `DARNER_BINDINGS_ONLY=1`, `DARNER_WHEEL_HOLD=1`, and all existing unit tests unmodified. ### Verification - Added unit tests: - `chords_and_capslock_and_aim_wheel_zoom_work` - `opt_in_driver_overrides_separate_headlights_and_duck` - `opt_in_flight_overrides_only_activate_when_configured` - `cargo test -p darner-hle --lib gameinput` passes (116 passed, 0 failed).
Contributor

Heads-up on overlap with two open PRs of mine, so whichever lands second knows what to adapt:

  • #402 (native mouse Sensitivity) changes the same lines in mnk.rs: it adds an explicit_sensitivity field next to sensitivity in struct Bindings, sets it in parse (the Bindings { .. sensitivity: 0.045 } initializer and the Sensitivity branch), and adds config_at() / sensitivity_with_count() around config(). This PR adds fields at the same spots, so the two will conflict in text. The fix is mechanical: keep both sets of fields.
  • #405 (native mouse: Mouse4, Mouse5, WheelUp, WheelDown press their bindings) covers part of the same ground: on the native mouse path it reads those keys with mnk::native_mouse_keys and presses their plain bindings through mouse_key_pad in gameinput.rs, reading the same wheel queue, which it clears outside gameplay and while the weapon wheel is open (mnk::forget_wheel). Here, apply_native_extensions_from reads 5 | 6 and WHEEL_UP | WHEEL_DOWN through its own wheel().poll() for chords, the Driver*/Flight* keys and the aim zoom. With both merged, two places would read the wheel queue, so it is worth checking that a scroll reaches each of them once. It would be simpler if one built on the other: this PR reading the native keys through #405's native_mouse_keys, or #405 rebased on top of this one.

Neither of mine is merged yet. I'm happy to rebase mine on this PR if it goes in first.

Heads-up on overlap with two open PRs of mine, so whichever lands second knows what to adapt: - **#402** (native mouse `Sensitivity`) changes the same lines in `mnk.rs`: it adds an `explicit_sensitivity` field next to `sensitivity` in `struct Bindings`, sets it in `parse` (the `Bindings { .. sensitivity: 0.045 }` initializer and the `Sensitivity` branch), and adds `config_at()` / `sensitivity_with_count()` around `config()`. This PR adds fields at the same spots, so the two will conflict in text. The fix is mechanical: keep both sets of fields. - **#405** (native mouse: `Mouse4`, `Mouse5`, `WheelUp`, `WheelDown` press their bindings) covers part of the same ground: on the native mouse path it reads those keys with `mnk::native_mouse_keys` and presses their plain bindings through `mouse_key_pad` in `gameinput.rs`, reading the same wheel queue, which it clears outside gameplay and while the weapon wheel is open (`mnk::forget_wheel`). Here, `apply_native_extensions_from` reads `5 | 6` and `WHEEL_UP | WHEEL_DOWN` through its own `wheel().poll()` for chords, the `Driver*`/`Flight*` keys and the aim zoom. With both merged, two places would read the wheel queue, so it is worth checking that a scroll reaches each of them once. It would be simpler if one built on the other: this PR reading the native keys through #405's `native_mouse_keys`, or #405 rebased on top of this one. Neither of mine is merged yet. I'm happy to rebase mine on this PR if it goes in first.
Owner

Test needed — commit 9518e7ab; what to check: the change described above

Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture.

Reply testing to take this run; it's free again after 24 h with no results.

**Test needed** — commit `9518e7ab`; what to check: the change described above Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture. Reply `testing` to take this run; it's free again after 24 h with no results.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'pr/mnk-bindings-extensions:aowu-pr/mnk-bindings-extensions'
git switch 'aowu-pr/mnk-bindings-extensions'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'Main'
git merge --no-ff 'aowu-pr/mnk-bindings-extensions'
git switch 'aowu-pr/mnk-bindings-extensions'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'aowu-pr/mnk-bindings-extensions'
git switch 'aowu-pr/mnk-bindings-extensions'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'aowu-pr/mnk-bindings-extensions'
git switch 'Main'
git merge --squash 'aowu-pr/mnk-bindings-extensions'
git switch 'Main'
git merge --ff-only 'aowu-pr/mnk-bindings-extensions'
git switch 'Main'
git merge 'aowu-pr/mnk-bindings-extensions'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!584
No description provided.