This document covers technical details about building, developing, and contributing to the Supermodel Lightgun Auto-Configurator.
- Rust - Install rustup from https://rustup.rs/. The toolchain version, components and the
Windows target are pinned in
rust-toolchain.toml; rustup installs them on the firstcargocall. - libusb development libraries (not needed on Windows)
- Ubuntu/Debian:
sudo apt-get install libusb-1.0-0-dev - macOS:
brew install libusb
- Ubuntu/Debian:
Build the release binary (optimized):
cargo build --releaseThe compiled binary will be at:
./target/release/smgunBuild a debug binary (faster compile, slower runtime):
cargo buildDebug binary location:
./target/debug/smgunFrom source:
cargo run --release -- --listOr run the compiled binary directly:
./target/release/smgun --listsmgun --listsmgun --gun1 046D:C05A --gun2 046D:C05B --ini Config/Supermodel.inismgun --gun1 046D:C05A --ini Config/Supermodel.inismgun --gun1 046D:C05A --gun2 046D:C05B --ini Config/Supermodel.ini --use-analogRUST_LOG=debug smgun --gun1 046D:C05A --ini Config/Supermodel.iniCheck for compile errors without building:
cargo checkRun clippy linter for code quality:
cargo clippyCheck code formatting:
cargo fmt --checkAuto-format code:
cargo fmtShow detailed dependency tree:
cargo tree- Devices are enumerated with libusb and sorted by bus number
- Device names are read from
/sys/bus/usb/devices/<bus>-<port path>/(no permissions needed) - Falls back to USB descriptor reading if sysfs is unavailable
- VID:PID matching works across all device names
- Uses USB descriptor reading (requires brief permission dialog on first run)
- Devices may appear with manufacturer names instead of product names
- VID:PID values are consistent regardless of device name
- Does not use libusb. Mice are enumerated via the Raw Input API (
GetRawInputDeviceList) in the same order as Supermodel's RawInput system, so theMOUSExindices match (list walked backwards,Root#RDP_devices skipped, onlyRIM_TYPEMOUSEcounted) - Every mouse counts towards the index, including non-USB ones (shown as VID:0000 PID:0000)
- Supermodel must use
InputSystem = rawinputfor per-mouse lightgun input - Device names come from the HID product/manufacturer strings
Versions are SemVer and computed by scripts/version.sh from the GitFlow branch and the
vX.Y.Z tags. Cargo.toml stays at 0.0.0; don't bump it. The version is injected at build
time via SMGUN_VERSION (read by build.rs):
- tag
vX.Y.Z→X.Y.Z release/X.Y.Zorhotfix/X.Y.Z→X.Y.Z-rc.N- anything else (incl.
develop) →0.0.0+<sha>
SMGUN_VERSION=$(scripts/version.sh) cargo build --release
scripts/test.sh # tests for version.sh and changelog.shAdd changes to ## [Unreleased] in CHANGELOG.md. Branching and releases are
described in GITFLOW.md, the workflows in .github/WORKFLOWS.md.
CI checks (fix these before pushing):
cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo clippy --all-targets --target x86_64-pc-windows-msvc -- -D warnings # Windows path, from Linux
cargo test
shellcheck scripts/*.shWhen making changes:
- Maintain the module separation - keep USB enumeration in
usb.rs, INI logic inini.rs, CLI inmain.rs - Add documentation comments to public functions explaining VID:PID matching behavior
- Test builds for Windows/macOS/Linux when possible
- Preserve INI file layout - avoid reformatting user files
- Keep error messages user-friendly and include VID:PID values when relevant
- Ensure VID:PID matching works reliably across different device types
MIT