Skip to content

BruRdgz/SAMIR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SAMIR — Simulated Analog Mouse Interface Runtime

“SAMIR, YOU'RE BREAKING THE CAR!”


SAMIR is a virtual analog steering and pedal system that turns a standard mouse into a fully playable rally controller.

Originally created out of necessity after a catastrophic controller failure during an intense desire to play DiRT Rally 2.0, SAMIR translates mouse movement into smooth analog steering, throttle, and braking input through a virtual hardware interface.

Unlike keyboard steering, SAMIR provides continuous analog control designed specifically for rally driving, with features such as real-time DSP smoothing, snap zones, cross-center damping, configurable pedal response curves, and bounded virtual wheel behavior.

By spoofing the exact hardware ID of a Logitech G29 Driving Force Racing Wheel, it bypasses heuristic filters in SDL2/Proton and plugs directly into native game wheel profiles. It should technically work with any racing game that supports standard steering wheels.

Technically is the operating keyword here.

This has not been extensively tested.

It is, however, surprisingly driveable.


Quick Start

Requirements

  • Linux
  • Rust toolchain (cargo)
  • evdev system dependencies
  • Root privileges (Access to /dev/input/* and /dev/uinput to create the virtual wheel and grab the mouse)

Build & Run

# Build the project
just build

# Run SAMIR (requires sudo to access /dev/input)
just run

Default Controls

Upon running, SAMIR will hijack your mouse and keyboard inputs and display a live Telemetry HUD in the terminal.

Key / Action Function
F10 Enable / disable SAMIR and release the mouse to the OS
Middle Mouse Recenter steering and pedals to absolute neutral
Left Click Downshift (Mapped to G29 Left Paddle)
Right Click Upshift (Mapped to G29 Right Paddle)
Shift (Hold) Clutch
[ Decrease steering sensitivity (SENSITIVITY_X)
] Increase steering sensitivity (SENSITIVITY_X)
c Open Settings TUI (Terminal User Interface)
Ctrl + C Exit gracefully and save configuration to disk

Configuration Reference

Configurations are stored in a persistent JSON file (usually located at $XDG_CONFIG_HOME/samir/config.json or samir_config.json next to the binary). Unknown keys or invalid types are safely ignored and reverted to defaults.

Steering

Parameter Default What It Does / When To Adjust
SENSITIVITY_X 1.0 Mouse pixels → virtual steering displacement. Increase if steering feels too slow. Decrease if tiny movements throw the car around. This is usually the first setting to tune. Adjustable in-game with [ and ].
STEER_RANGE 750.0 Physical mouse travel from center to full lock. Increase for more granular steering (tarmac, long corners). Decrease for faster response (gravel, snow).
STEER_CURVE_POWER 2.0 Steering response curve. 1.0 = linear. 2.0 = quadratic (soft center, aggressive edges). 3.0 = cubic (very fine center control). Increase if fine corrections feel difficult. Decrease if steering reacts too slowly near center.
STEER_SMOOTHING 0.15 EMA smoothing filter applied to output. Removes high-frequency mouse jitter. Increase (0.3) if steering still trembles. Decrease (0.05) if input feels delayed. Watch the HUD's "Raw vs Smoothed" bars to visualize this.
STEER_SNAP_ZONE 0.05 Percentage of steering range near center that collapses to exact neutral. With 750, 0.05 = ±37 px. Increase if finding center is difficult. Decrease if it interferes during tight corners. Primary cure for oversteer oscillation on snow/ice.
STEER_CROSS_DAMPING 0.4 Fraction of overshoot absorbed when crossing center. 0.4 = arrives on the opposite side with 60% of the excess remaining. Simulates physical Force Feedback returning to center. Increase (0.6) if oscillation persists. Decrease (0.2) if steering corrections feel too constrained.
STEER_DEADZONE 0.0 Output deadzone applied after steering curve. Ignores tiny values before sending input to the game. Usually best left at 0, since STEER_SNAP_ZONE already handles center stability more elegantly.

Pedals — Throttle, Brake & Clutch

Parameter Default What It Does / When To Adjust
THROTTLE_SENSITIVITY 0.8 Accumulation multiplier when moving the mouse upward (throttle). Increase if full throttle requires too much travel. Decrease for finer traction control on corner exits. On gravel/snow, 0.5~0.6 helps prevent accidental wheelspin.
BRAKE_SENSITIVITY 0.3 Accumulation multiplier when moving the mouse downward (brake). Intentionally low by default to reduce accidental lockups. Increase if braking feels weak. Decrease for finer modulation. Tarmac with ABS can tolerate 0.5. Snow without ABS should stay lower.
PEDAL_RANGE 250.0 Physical mouse travel from neutral to 100% pedal input. Decrease (150.0) for faster response. Increase (400.0) for finer modulation. If you constantly hit the 100% wall unexpectedly, the range is probably too small.
PEDAL_SNAP_ZONE 0.05 Final percentage of pedal range that locks to 100% input, bypassing curves and velocity scaling. With 250.0, 0.05 = last 12.5 px become guaranteed full input. Increase if reaching max throttle/brake is difficult. Decrease if it triggers accidentally.
PEDAL_CURVE_POWER 2.0 Pedal response curve. 1.0 = linear. 2.0 = softer initial response, aggressive near full press. Useful for traction control in the first 30% of throttle input. Increase for finer corner exits. Decrease if pedals feel dead near center.
PEDAL_VELOCITY_FACTOR 0.25 Additional gain based on mouse movement speed. Slow movement = fine modulation. Fast movement = aggressive pedal application. Increase for more explosive response. Decrease for more linear behavior. If emergency braking feels weak, try 0.4~0.5.
PEDAL_VELOCITY_MAX 3.0 Maximum velocity multiplier cap. Prevents violent mouse movements from producing absurd inputs. Increase for more decisive emergency braking. Decrease if shaking the mouse accidentally triggers full brake/throttle. Always tune together with PEDAL_VELOCITY_FACTOR.
PEDAL_DEADZONE 0.02 Neutral deadzone where neither throttle nor brake is applied. Increase if the car slowly crawls while the mouse rests. Decrease for immediate response leaving neutral. Rarely needs adjustment.
CLUTCH_REQUIRED false If set to true, clicking Left/Right mouse buttons to shift gears will be ignored unless you are holding the Shift key (Clutch).

System / Output / Misc

Parameter Default What It Does / When To Adjust
OUTPUT_HZ 60 Virtual gamepad update rate. Higher = smoother input. 120 if the game runs at 120 FPS. Values above 250 rarely provide meaningful benefits and only increase CPU usage. Matching your game's physics tick-rate is ideal.
INVERT_Y_AXIS false Inverts pedal direction: mouse up becomes brake, mouse down becomes throttle. Also reverses directional sensitivity logic internally. Purely personal preference.
PROTON_MODE true Re-maps the physical axes on the virtual device to align with SDL2's DirectInput legacy translation (ABS_RZ instead of ABS_Z). Leave true for Windows games via Proton/Wine (e.g., DiRT Rally 2.0). Set to false for native Linux games.
SENSITIVITY_STEP 0.1 Increment used by [ and ] hotkeys for adjusting SENSITIVITY_X. Use 0.05 for finer tuning or 0.2 for faster switching between setups.

Calibration Notes

SAMIR's drivability is heavily dependent on your personal setup and hardware:

  • Mouse DPI & Polling Rate
  • Mousepad size & surface friction
  • In-game steering saturation
  • Seating position
  • General tolerance for suffering

It is strongly recommended that you spend at least 15 minutes calibrating the config.json parameters to your preferences while looking at the SAMIR Telemetry HUD before attempting serious driving.

The defaults are intended as a baseline for a 1000 DPI mouse — not a universal solution.


Frequently Asked Questions (FAQ)

The game doesn't detect my wheel! (DiRT Rally 2.0 / Proton)

  1. Disable Steam Input: Right-click the game in Steam > Properties > Controller > Override for [Game] > Disable Steam Input. If Steam Input is active, it will wrap SAMIR in an Xbox 360 controller layer, breaking wheel detection entirely.
  2. Clear the Prefix Cache: If you ran the game before SAMIR was running correctly, Proton may have permanently cached the virtual device as a generic gamepad. Close the game, delete the game's compatdata prefix (e.g. rm -rf ~/.steam/steam/steamapps/compatdata/690790), and start the game again with SAMIR running so it gets detected cleanly on first setup.
  3. Verify Proton Mode: Make sure PROTON_MODE is set to true in your settings. This aligns the axes so Proton routes the brake to ABS_RZ correctly.

SAMIR throws an error about /dev/uinput or /dev/input/* permissions

SAMIR requires direct low-level kernel access to read your physical mouse and create the virtual steering wheel.

  • Quick fix: Run it with sudo (sudo cargo run or just run).
  • Permanent fix: Add your user to the input group and write a udev rule granting your user write access to /dev/uinput.

My steering/pedals are jittery or laggy

If your input stutters, increase STEER_SMOOTHING (e.g., 0.3). If the input feels delayed or floaty, decrease STEER_SMOOTHING (e.g., 0.05) and check your game's internal frame rate. SAMIR runs by default at OUTPUT_HZ = 60; matching this to your monitor/game FPS often provides the tightest response.


Notes

A large portion of the configuration, feature set, and internal DSP logic exists because I was trying to adapt the experience to my own setup, comfort, and driving style.

Have fun. Drive fast. Stay out of the guardrails.


"SAMIR, YOU HAVE TO TURN THE WHEEL! PLEASE!" — Me, moments before discovering that my mouse-to-G29 spoofing software was not extensively tested against Finnish forestry.

"🌲" — Finnish forestry.

About

Mouse-to-virtual-wheel translation layer for rally games and other racing simulators.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors