gameinput: darner_controller, a controller for mods (read, hold, chords, feed) #560

Open
jack wants to merge 1 commit from jack/Darner:mods-controller into Main
First-time contributor

Contributor role (optional)

  • Fluxer ID: 1578071566602731521

What it changes

  • The problem on main: read from the code only. A mod DLL from %LOCALAPPDATA%\darner\mods runs in our process but has no way to read the pad or to keep its buttons from the title. DARNER_TRAINER=1 (menu_share) serves one trainer: a page at a fixed address that always holds the same five buttons.

darner.exe exports darner_controller(version). It returns a C table (crates/darner-hle/src/modules/gameinput/modpad.rs, documented there) that any mod can use:

  • Clients: open(name) / close. Each mod's holds, chords and feeds are its own, and several mods can use the controller at once (their holds add up).
  • Reading: state(slot), one pad or all of them as one, before anything is held or fed.
  • Holding: hold(client, buttons, flags, ms) keeps buttons, and optionally the sticks and triggers, from the title. It lasts at most 1 s unless renewed, so a mod that stops gives the pad back on its own.
  • Chords: chord(client, {buttons, hold_ms, guard_ms}) and fired(chord). The combination is watched on the input poll thread (every 8 ms), not at the mod's frame rate.
    • The first buttons pressed are held back for up to guard_ms while the rest come.
    • The chord fires once all its buttons are down for hold_ms, and they stay away from the title until they are let go.
    • A press that turns out not to be the chord reaches the title late: still down after the guard, or as a 50 ms press if already let go. So a menu combination never leaks into the game, and a lone press of one of its buttons still works.
  • Feeding: feed(client, slot, pad, flags, ms) adds a mod's buttons, and optionally its sticks and triggers, to a pad. An empty slot gets a pad while it is fed. Holds do not take fed input.

It runs in Hub::poll right after menu_share, on the host pads only (the keyboard's stand-in pad and the mouse look are untouched, as with menu_share). Until a mod opens a client, nothing changes for the title. The table carries its size and version, and later versions only add fields at the end.

Also in it: apps/darner/build.rs exports the function (/EXPORT, and the .def for GNU), apps/darner/tests/exports.rs checks darner.exe's export directory, and README's mods-folder line says what a mod can use.

How it was tested

  • Tested revision: 0fc2116 (upstream main c8258f9 plus this commit)

  • Commands and results:

    • cargo test -p darner-hle --lib modpad: 14 passed, 0 failed
    • the three gates below
  • Changes a default: no. Nothing is held, fed or watched until a mod asks.

  • A/B result: not needed (no default changes, and no speed claim). With no mod, exchange takes one uncontended lock per 8 ms poll and finds nothing to do.

  • Gates run: gate 1 (cargo clippy --workspace --all-targets --locked -- -D warnings) exit 0; gate 2 (--all-features) exit 0; gate 3 (cargo test --workspace --locked --no-fail-fast) exit 0: 3535 passed, 0 failed, 121 ignored. Gates ran on c8258f9 with this change's code, before the README line was added; nothing else differs from 0fc2116.

  • Gameplay: not on this revision. The same modpad.rs and hook ran on my local build of the NVIDIA fork, RTX 4080, Series S profile, DLSS Quality, DLSS frame generation 2x. A mod loader used it:

    • its menu opened from LB + RB, and the game did not get either button;
    • a lone tap of LB or RB still reached the game;
    • RB + d-pad left and Hold View opened it too;
    • the whole pad was held while the menu was open, and nothing leaked after it closed.

    Darner's logs of those runs show no panic, exception or device removal.

  • Shader wave sizes tested: not relevant.

  • Hardware dependence: likely general (CPU-side input path).

  • Coverage gaps: feeds are covered by unit tests only, not by a mod in the game. The GNU .def export was not built (MSVC only). Not run on Linux/Proton.

Written with Claude Code (Claude Opus 5.5); I read and tested the change.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only).
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: none change the same lines. They share gameinput.rs: #525, #473, #447, #429, #421, #405, #402, #364, #302, #185. They share apps/darner/build.rs: #130.
  • Replaces or overlaps: none found

🤖 Generated with Claude Code

## Contributor role (optional) - Fluxer ID: 1578071566602731521 ## What it changes - The problem on main: read from the code only. A mod DLL from `%LOCALAPPDATA%\darner\mods` runs in our process but has no way to read the pad or to keep its buttons from the title. `DARNER_TRAINER=1` (`menu_share`) serves one trainer: a page at a fixed address that always holds the same five buttons. darner.exe exports `darner_controller(version)`. It returns a C table (`crates/darner-hle/src/modules/gameinput/modpad.rs`, documented there) that any mod can use: - **Clients**: `open(name)` / `close`. Each mod's holds, chords and feeds are its own, and several mods can use the controller at once (their holds add up). - **Reading**: `state(slot)`, one pad or all of them as one, before anything is held or fed. - **Holding**: `hold(client, buttons, flags, ms)` keeps buttons, and optionally the sticks and triggers, from the title. It lasts at most 1 s unless renewed, so a mod that stops gives the pad back on its own. - **Chords**: `chord(client, {buttons, hold_ms, guard_ms})` and `fired(chord)`. The combination is watched on the input poll thread (every 8 ms), not at the mod's frame rate. - The first buttons pressed are held back for up to `guard_ms` while the rest come. - The chord fires once all its buttons are down for `hold_ms`, and they stay away from the title until they are let go. - A press that turns out not to be the chord reaches the title late: still down after the guard, or as a 50 ms press if already let go. So a menu combination never leaks into the game, and a lone press of one of its buttons still works. - **Feeding**: `feed(client, slot, pad, flags, ms)` adds a mod's buttons, and optionally its sticks and triggers, to a pad. An empty slot gets a pad while it is fed. Holds do not take fed input. It runs in `Hub::poll` right after `menu_share`, on the host pads only (the keyboard's stand-in pad and the mouse look are untouched, as with `menu_share`). Until a mod opens a client, nothing changes for the title. The table carries its size and version, and later versions only add fields at the end. Also in it: `apps/darner/build.rs` exports the function (`/EXPORT`, and the `.def` for GNU), `apps/darner/tests/exports.rs` checks darner.exe's export directory, and README's mods-folder line says what a mod can use. ## How it was tested - Tested revision: 0fc2116 (upstream `main` c8258f9 plus this commit) - Commands and results: - `cargo test -p darner-hle --lib modpad`: 14 passed, 0 failed - the three gates below - Changes a default: no. Nothing is held, fed or watched until a mod asks. - A/B result: not needed (no default changes, and no speed claim). With no mod, `exchange` takes one uncontended lock per 8 ms poll and finds nothing to do. - Gates run: gate 1 (`cargo clippy --workspace --all-targets --locked -- -D warnings`) exit 0; gate 2 (`--all-features`) exit 0; gate 3 (`cargo test --workspace --locked --no-fail-fast`) exit 0: 3535 passed, 0 failed, 121 ignored. Gates ran on c8258f9 with this change's code, before the README line was added; nothing else differs from 0fc2116. - Gameplay: not on this revision. The same `modpad.rs` and hook ran on my local build of the NVIDIA fork, RTX 4080, Series S profile, DLSS Quality, DLSS frame generation 2x. A mod loader used it: - its menu opened from LB + RB, and the game did not get either button; - a lone tap of LB or RB still reached the game; - RB + d-pad left and Hold View opened it too; - the whole pad was held while the menu was open, and nothing leaked after it closed. Darner's logs of those runs show no panic, exception or device removal. - Shader wave sizes tested: not relevant. - Hardware dependence: likely general (CPU-side input path). - Coverage gaps: feeds are covered by unit tests only, not by a mod in the game. The GNU `.def` export was not built (MSVC only). Not run on Linux/Proton. Written with Claude Code (Claude Opus 5.5); I read and tested the change. ## Checklist - [x] I ran this change in the game, or say below why it can't be (docs, tests only). - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: none change the same lines. They share `gameinput.rs`: #525, #473, #447, #429, #421, #405, #402, #364, #302, #185. They share `apps/darner/build.rs`: #130. - Replaces or overlaps: none found 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A DLL loaded from %LOCALAPPDATA%\darner\mods runs in our process, and a
mod's own menu needs the pad: to open from a button combination, and to
keep the buttons that drive it from the title while it is open. The only
way so far is DARNER_TRAINER=1's fixed page, which holds the same five
buttons for one trainer.

darner.exe now exports darner_controller(version), which returns a C
table (gameinput::modpad): clients, the pads' reading by slot or as one,
holds per client (at most 1 s unless renewed, so a mod that stops gives
the pad back), chords watched on the poll thread every 8 ms (a press that
turns out not to be the chord reaches the title late, as a 50 ms press),
and feeds (a mod's own buttons and sticks; an empty slot gets a pad while
it is fed). Until a mod opens a client nothing changes for the title.
menu_share (DARNER_TRAINER=1) is left as it is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TrustNo1 changed title from [pr-feature][input] gameinput: darner_controller, a controller for mods (read, hold, chords, feed) to gameinput: darner_controller, a controller for mods (read, hold, chords, feed) 2026-12-06 03:27:05 +00:00
Owner

Test needed — commit 0fc21164; what to check:

  • The problem on main: read from the code only. A mod DLL from %LOCALAPPDATA%\darner\mods runs in our process but has no way to read the pad or to keep its buttons from the title. DARNER_TRAINER=1 (menu_share) serves one trainer: a page at a fixed address that always holds the same five buttons.

darner.exe exports darner_controller(version). It returns a C table (crates/darner-hle/src/modules/gameinput/modpad.rs, documented there) that any mod can use:

  • Clients: open(name) / close. Each mod's holds, chords and feeds are its own, and several mods can use the controller at once (their holds add up).
  • Reading: state(slot), one pad or all of them as one, before anything is held or fed.
  • Holding: hold(client, buttons, flags, ms) keeps buttons, and optionally the sticks and triggers, from the title. It lasts at most 1 s unless renewed, so a mod that stops gives the pad back on its own.
  • Chords: chord(client, {buttons, hold_ms, guard_ms}) and fired(chord). The combination is watched on the input poll thread (every 8 ms), not at the mod's frame rate.
    • The first buttons pressed are held back for up to guard_ms while the rest come.
    • The cho

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 `0fc21164`; what to check: - The problem on main: read from the code only. A mod DLL from `%LOCALAPPDATA%\darner\mods` runs in our process but has no way to read the pad or to keep its buttons from the title. `DARNER_TRAINER=1` (`menu_share`) serves one trainer: a page at a fixed address that always holds the same five buttons. darner.exe exports `darner_controller(version)`. It returns a C table (`crates/darner-hle/src/modules/gameinput/modpad.rs`, documented there) that any mod can use: - **Clients**: `open(name)` / `close`. Each mod's holds, chords and feeds are its own, and several mods can use the controller at once (their holds add up). - **Reading**: `state(slot)`, one pad or all of them as one, before anything is held or fed. - **Holding**: `hold(client, buttons, flags, ms)` keeps buttons, and optionally the sticks and triggers, from the title. It lasts at most 1 s unless renewed, so a mod that stops gives the pad back on its own. - **Chords**: `chord(client, {buttons, hold_ms, guard_ms})` and `fired(chord)`. The combination is watched on the input poll thread (every 8 ms), not at the mod's frame rate. - The first buttons pressed are held back for up to `guard_ms` while the rest come. - The cho 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 'mods-controller:jack-mods-controller'
git switch 'jack-mods-controller'

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 'jack-mods-controller'
git switch 'jack-mods-controller'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'jack-mods-controller'
git switch 'jack-mods-controller'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'jack-mods-controller'
git switch 'Main'
git merge --squash 'jack-mods-controller'
git switch 'Main'
git merge --ff-only 'jack-mods-controller'
git switch 'Main'
git merge 'jack-mods-controller'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 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!560
No description provided.