# big-haptic-driver

Initial OpenVR driver scaffold in Rust.

## Current capabilities

- Exports `HmdDriverFactory` with minimal interface-name validation
- Registers a tracked controller device with `IVRServerDriverHost::TrackedDeviceAdded`
- Creates a haptic input component (`/output/haptic`) via `IVRDriverInput`
- Routes `VREvent_Input_HapticVibration` events to firmware haptics (`SET_INTENSITY` + timed stop)
- Exposes DLL-callable haptics test exports:
  - `BigHapticDriver_SendAmplitude(float)`
  - `BigHapticDriver_Stop()`
- Sends packets to firmware through shared `hid-bridge`

## Build

From workspace root:

- `cargo build -p big-haptic-driver --release`

Output DLL path:

- `target/release/big_haptic_driver.dll`

## Build + deploy (one command)

From workspace root:

- `./tools/scripts/build_and_deploy_openvr_driver.ps1`

This builds the crate and copies the DLL to:

- `openvr-driver/big-haptic-driver/bin/win64/driver_big_haptic_driver.dll`

## SteamVR layout

Driver folder should include:

- `driver.vrdrivermanifest`
- `resources/`
- `resources/input/big_haptic_profile.json`
- `resources/localization/en_us.json`
- `bin/win64/driver_big_haptic_driver.dll`

## Register with SteamVR

PowerShell command (note the `&` call operator before the quoted exe path):

- `& "C:\Program Files (x86)\Steam\steamapps\common\SteamVR\bin\win64\vrpathreg.exe" adddriver "C:\Users\decid\Documents\projects\qt-py-haptics\openvr-driver\big-haptic-driver"`

To verify registration:

- `& "C:\Program Files (x86)\Steam\steamapps\common\SteamVR\bin\win64\vrpathreg.exe"`

To remove registration:

- `& "C:\Program Files (x86)\Steam\steamapps\common\SteamVR\bin\win64\vrpathreg.exe" removedriver "C:\Users\decid\Documents\projects\qt-py-haptics\openvr-driver\big-haptic-driver"`

## Testing status (important)

The driver now performs real device/input registration and listens for haptic vibration events from SteamVR.

Recommended validation flow:

1. Ensure firmware is flashed and responding to HID.
2. Restart SteamVR after deploying the driver DLL.
3. Open SteamVR input bindings and look for controller type `big_haptic_driver`.
4. Trigger haptics from an app/binding and verify actuator response.

If DLL deploy fails with "file in use", close SteamVR (and any PowerShell process that loaded the DLL) and redeploy.

Temporary direct test (bypasses SteamVR input bindings):

- `./tools/scripts/test_big_haptic_driver_exports.ps1 -Amplitude 0.35 -DurationSeconds 0.20 -Frequency 160`

Note: in this direct-export mode, SteamVR frame pumping is bypassed, so the script performs an explicit delayed stop for `-DurationSeconds` unless `-NoAutoStop` is supplied.

Stop command:

- `./tools/scripts/test_big_haptic_driver_exports.ps1 -Stop`
