GestureDrive is a desktop application written in Python that transforms your hands into a virtual steering wheel using your webcam. By tracking hand positions and gestures in real time with MediaPipe and OpenCV, GestureDrive calculates your steering angle and converts gestures into keyboard or virtual Xbox controller inputs for car racing games.
- Virtual Steering Wheel: Track two-hand rotation angle or single-hand horizontal offset with live video overlay and HUD gauges.
- Hand Gesture Controls:
- ✊ Closed Fist: Brake / Reverse
- 👍 Thumbs Up: Accelerate
- ✋ Open Palm / Neutral: Free Steering
- 👐 Spread Hands Wide: Nitro / Boost
- ❌ Hands Removed: Fail-Safe Release (All inputs reset instantly)
- Robust Steering Engine:
- Configurable Neutral / Dead-Zone filtering
- Exponential Moving Average (EMA) smoothing for zero-jitter driving
- Configurable Sensitivity & Response Curves (Linear, Quadratic, Exponential)
- Configurable Maximum Steering Angle
- Multiple Input Adapters:
- ⌨️ Keyboard Adapter: Stateful key press/release with no key spamming.
- 🎮 Virtual Gamepad Adapter: Analog XInput Xbox 360 controller emulation via
vgamepad. - 🧪 Simulation / Test Mode: Live HUD & telemetry testing without OS key injection.
- Game Profiles: Create, save, edit, and switch profile mappings for games like Need for Speed, Forza, and TrackMania.
- 100% Fail-Safe Safety System: Automatically zeroes all inputs if tracking drops, camera disconnects, or app exits.
GestureDrive/
│
├── main.py # Entry point
├── requirements.txt # App dependencies
├── README.md # Documentation & User Guide
│
├── app/
│ ├── config.py # Settings & dataclasses
│ ├── camera.py # Threaded non-blocking OpenCV webcam capture
│ ├── hand_tracker.py # MediaPipe Hands 21-landmark tracking wrapper
│ ├── steering.py # Steering geometry, angle calculation & smoothing engine
│ ├── gesture_detector.py # Hand gesture classifier (Fist, Thumbs Up, Nitro)
│ ├── calibration.py # Baseline zero calibration manager
│ ├── controls.py # Control state diffing & fail-safe engine
│ ├── input_adapter.py # Abstract base class for input adapters
│ ├── keyboard_adapter.py # Stateful pynput keyboard adapter
│ ├── gamepad_adapter.py # Virtual Xbox 360 controller adapter (vgamepad)
│ ├── profiles.py # Game profiles loader/saver
│ └── logger.py # Centralized logging
│
├── ui/
│ ├── dashboard.py # CustomTkinter main dark dashboard
│ ├── settings.py # Comprehensive tabbed settings window
│ ├── calibration_ui.py # Guided steering calibration wizard
│ └── debug_panel.py # Real-time telemetry & diagnostics overlay
│
├── profiles/ # Game profile presets (JSON)
│ ├── default.json
│ ├── nfs.json
│ └── forza.json
│
└── tests/ # Pytest unit test suite
├── test_steering.py
├── test_gestures.py
├── test_calibration.py
├── test_controls.py
└── test_profiles.py
Requires Python 3.11+. Install required packages:
pip install -r requirements.txtTo use Virtual Xbox 360 Controller mode on Windows:
- Download and install the ViGEmBus Driver (version 1.21+).
- Restart your computer after installing ViGEmBus.
Note: If ViGEmBus is not installed, GestureDrive will gracefully fall back to Keyboard Mode and Simulation Mode, allowing you to play games using keyboard input without any issues!
Launch the GestureDrive dashboard:
python main.pyTo start directly in Simulation / Test Mode:
python main.py --simulationTo specify a webcam device index (e.g., camera 1):
python main.py --camera 1- Sit in front of your webcam and click the
[Calibrate]button on the dashboard. - Put your hands up in your natural, comfortable driving position.
- Click
Calibrate Now. - GestureDrive will measure your baseline angle and center point as
$0^\circ$ neutral steering. You can recalibrate anytime while driving!
- Keyboard Mode: Translates hand rotation to discrete key presses (
A/Dfor steering,W/Sfor throttle/brake,Spacefor handbrake,Shiftfor nitro). - Virtual Gamepad Mode: Translates hand rotation directly to analog Left Stick X (
-32768to32767), Right Trigger for throttle, and Left Trigger for brake. - Simulation Mode: Visualizes all telemetry and steering inputs on screen without sending key/controller events to the OS.
Run the full pytest suite to verify math, deadzone calculations, gestures, calibration, and fail-safes:
python -m pytest tests/GestureDrive prioritizes user safety and system stability:
- Instant Emergency Release: If hand tracking drops or landmarks are lost,
release_all_controls()is triggered immediately, releasing all virtual keys/buttons. - Clean Shutdown: Closing the window or pressing
ESCstops the camera thread and safely clears all virtual input states.