This standalone Python project uses a webcam feed to recognize hand gestures in real-time and translate them into keystrokes to control games like Hill Climb Racing.
- GAS (Accelerate / Lean Right): Fully open hand (all 5 fingers extended) simulates holding down the Right Arrow key.
- BRAKE (Slow down / Lean Left): Closed fist (0 fingers extended) simulates holding down the Left Arrow key.
- NEUTRAL: A relaxed hand, partial fingers, or no hand detected releases both keys.
- Real-time Status Overlay: Displays current command state and hand tracking skeleton on the live video stream.
Open your terminal, navigate to this project folder, and run:
python3 -m venv venv- macOS / Linux:
source venv/bin/activate - Windows:
venv\Scripts\activate
Run the following command to install the required libraries:
pip install -r requirements.txt- Run the controller script:
python controller.py
- A window named "Hill Climb Controller" will pop up showing your webcam feed.
- Position this window so it doesn't block your game window (e.g. side-by-side or on a second screen).
- Select/click your game window to make it the active, focused window. (Simulated keypresses are sent to the currently focused window on the system).
- Use gestures in front of the webcam to play!
- To exit, select the webcam window and press
q.
Because macOS restricts applications from simulating keyboard inputs for safety, you must grant Accessibility permission to the terminal or IDE you are running this script from.
If the keys do not register in-game:
- Open System Settings on your Mac.
- Search for or navigate to Privacy & Security > Accessibility.
- Look for your terminal application (e.g.,
Terminal,iTerm,VS Code, etc.) in the list. - Toggle the switch to ON to allow it to control your computer.
- Restart your terminal application and launch the script again.
Ensure that you grant Camera permission to the terminal or IDE when prompted. If it is blocked, OpenCV will not be able to read frames. You can verify and adjust this under System Settings > Privacy & Security > Camera.