Skip to content

Add Doom-style mouse/trackpad steering#1130

Open
aversag wants to merge 1 commit into
dethrace-labs:mainfrom
aversag:feature/mouse-steering-labs
Open

Add Doom-style mouse/trackpad steering#1130
aversag wants to merge 1 commit into
dethrace-labs:mainfrom
aversag:feature/mouse-steering-labs

Conversation

@aversag

@aversag aversag commented Jun 26, 2026

Copy link
Copy Markdown

What

Lets you steer the car with the mouse or trackpad, Doom-style. Press ` (backtick) or the Cmd/Win key in-game to grab the mouse — the cursor is hidden and locked in relative mode, and horizontal movement steers the car. Press the same key again to release it for the menus. Keyboard steering keeps working at the same time.

How

Implemented in the SDL harness (plus one small read-only helper), so no existing byte-matched game function is modified:

  • Relative mouse motion accumulates into a "steering charge" that decays back to centre on every poll — so the wheel recentres when you stop moving, and a stationary mouse releases the steering even though SDL only sends motion events while the mouse is moving.
  • That charge becomes a held steer-left/right key press by OR-ing the currently bound steer scancode into the keyboard state the game reads in GetKeyboardState. It follows the player's key mapping (arrows, WASD, …) instead of assuming a fixed binding. The underlying key_state is never modified, so real key presses are untouched and keyboard steering works alongside it.
  • A new GetBoundScanCode() helper resolves the bound steer keys from gKey_mapping; it only reads game state.
  • Mirrored across both the SDL2 and SDL3 drivers.

Config

Enabled by default.

  • Disable: --no-mouse-steering, or MouseSteering = 0 in dethrace.ini.
  • Sensitivity: --mouse-steering-sensitivity=1.5, or MouseSteeringSensitivity in the INI.

Notes

  • The grab key accepts ` and Cmd/Win because backtick is a dead key on some layouts (e.g. macOS French), where the Cmd key is a reliable alternative.
  • Built and tested in-game on macOS (arm64) with SDL2; also compiles cleanly against SDL3.

Steer the car with the mouse or trackpad. Press ` (backtick) or the
Cmd/Win key in-game to grab the mouse: the cursor is hidden and locked
in relative mode, and horizontal motion steers the car. Press the same
key again to release the mouse for the menus. Keyboard steering keeps
working alongside it.

Mouse motion accumulates into a steering charge that decays back to
centre every poll, so the wheel recentres when the mouse stops. The
charge becomes a held steer-left/right key press by OR-ing the
*currently bound* steer key into the keyboard state the game reads, so
it follows the player's key mapping (arrows, WASD, ...) instead of
assuming a fixed binding.

Implemented in the SDL harness (SDL2 and SDL3) plus a small read-only
helper (GetBoundScanCode) that resolves the bound steer keys; no
existing byte-matched game function is modified. Enabled by default;
configurable with --no-mouse-steering / --mouse-steering-sensitivity
and the matching [General] MouseSteering / MouseSteeringSensitivity
INI keys.
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.

1 participant