Files
2026-06-01 01:25:58 +01:00

152 lines
3.5 KiB
Markdown

# Fake Gaming Wheel Emulator
Virtual USB gaming wheel device emulator for Linux. Creates a fake Logitech G29 Racing Wheel for testing purposes.
## Quick Start (Recommended)
**Use the uinput version** - it's more reliable:
```bash
sudo python3 fake_wheel_uinput.py
```
## Files
- **fake_wheel_uinput.py** - Uses `/dev/uinput` (RECOMMENDED)
- **fake_wheel.py** - Uses `/dev/uhid` (alternative, more complex)
- **debug_uhid.py** - Debug script for uhid
- **check_wheel.sh** - Check if device appears
## Features
The emulated wheel provides:
- **Steering Wheel**: Full 900° rotation (±450°)
- **Throttle Pedal**: 0-100% range
- **Brake Pedal**: 0-100% range
- **16 Buttons**: Standard gaming buttons
- **USB Device ID**: Logitech (0x046d) G29 (0xc24f)
## Simulated Behavior
When running, the script automatically simulates:
- Steering wheel rotating left/right in smooth sine wave
- Throttle pulsing between 0-78%
- Brake activating every 5 seconds
- Buttons cycling through 1-16 in sequence
## Verification
Check if the device appears:
```bash
# Method 1: Check by-id
ls -l /dev/input/by-id/ | grep -i logitech
# Method 2: Check input devices
cat /proc/bus/input/devices | grep -A 10 "Logitech G29"
# Method 3: Use evtest
sudo evtest
# Then select the G29 device from the list
# Method 4: Use jstest (for joystick interface)
jstest /dev/input/js0
```
## Requirements
- Linux kernel with uinput support
- Python 3.6+
- Root access OR user in 'input' group
- uinput kernel module (usually loaded by default)
### Enable uinput module (if needed)
```bash
sudo modprobe uinput
# Make it permanent:
echo "uinput" | sudo tee /etc/modules-load.d/uinput.conf
```
### Run without sudo (optional)
Add udev rule to allow non-root access:
```bash
echo 'KERNEL=="uinput", MODE="0666"' | sudo tee /etc/udev/rules.d/99-uinput.rules
sudo udevadm control --reload-rules
```
Or add your user to the input group:
```bash
sudo usermod -a -G input $USER
# Log out and back in for changes to take effect
```
## Troubleshooting
### Device doesn't appear
1. Check if uinput module is loaded:
```bash
lsmod | grep uinput
```
2. Check permissions:
```bash
ls -l /dev/uinput
```
3. Check kernel messages:
```bash
sudo dmesg | tail -20 | grep -i input
```
### Test with minimal script
Run the debug_uhid.py to test basic functionality:
```bash
sudo python3 debug_uhid.py
```
## Usage in Your Testing App
Once the fake wheel is running, it appears as a real USB device. Your gaming wheel tester should detect it automatically as:
- **Device Name**: "Logitech G29 Racing Wheel"
- **Vendor ID**: 0x046d (Logitech)
- **Product ID**: 0xc24f (G29 Racing Wheel)
The device will show up in standard input device APIs:
- `/dev/input/eventX` (evdev)
- `/dev/input/jsX` (joystick)
- SDL2, pygame, etc.
## Stopping the Emulator
Press `Ctrl+C` to cleanly stop and remove the virtual device.
## Technical Details
### uinput vs uhid
- **uinput**: Kernel interface for creating virtual input devices. Simpler API, better for basic input devices.
- **uhid**: Kernel interface for userspace HID drivers. More complex, allows full HID descriptor control.
This project provides both implementations. The uinput version is recommended for most use cases.
### Device Specifications
- **Bus Type**: USB (0x03)
- **Axes**:
- X (Steering): -32768 to 32767
- Y (Throttle): 0 to 255
- Z (Brake): 0 to 255
- **Buttons**: 16 buttons (BTN_TRIGGER + 0-15)
- **Update Rate**: 100 Hz (10ms intervals)
## License
Free to use for testing and educational purposes.