Turn Your Body Into a Game Controller

Build a local webcam controller that maps squats and punches to game keys.

Introduction

30 Second Summary

Most computer games expect your hands to do all the work while the rest of your body stays still. A workout and a game often compete for the same free time.

In this project, you will build a private body controller with Claude Code and MediaPipe. Your webcam will track squats and punches before the controller turns each completed movement into a keyboard action for a learner-owned single-player game.

What You'll Build

You'll play a single-player game with squats and punches while a mirrored camera view shows your 33-point skeleton and movement counters.

By the end of this project, you'll have:

  • A mirrored live view where 33 pose landmarks follow your body.
  • Tuned movement counters that show SQUATS: n, LEFT: n, and RIGHT: n while half squats leave the totals unchanged.
  • Movement-controlled game input that you can pause with p. A local CSV session log in sessions.csv and a proof recording preserve the result.
  • Secret Mission: A running-in-place control that holds a movement key and releases it within half a second after you stop.

Are there any prerequisites?

You need an Apple silicon Mac running macOS 13 or later or a Windows 10 or 11 PC. Your physical setup also needs a webcam with two to three metres of clear space.

You also need a Claude Pro, Max, Ultra, Team, Enterprise, or Console account. Choose a keyboard-controlled single-player game that you own because online games with anti-cheat are excluded.

Before We Start

This is your moment to commit to the private, local body controller you are about to build. Lock in why you want squats and punches to drive your learner-owned single-player game before the hands-on work begins.

Set Up Your Tools

Your body controller needs a clean local environment so old Python packages and conflicting OpenCV builds cannot break the first webcam test.

You will install Python 3.14.10 with Claude Code. Then you will create an isolated .venv with MediaPipe 1.3.0 and pynput 1.8.2 before downloading the local pose model.

In this step, get ready to:
  • Install Python 3.14.10.
  • Set up Claude Code.
  • Prepare the local project environment.
Install Python 3.14.10 and Claude Code

The pinned package versions support Python 3.14.10 on Apple silicon macOS and Windows. Use the tab for your computer.

macOS

  • Select the macOS installer from the release files.
  • Install Python 3.14.10 with the downloaded macOS installer.
  • Complete the installer with its recommended options.

Python 3.14.10 is now available to new Terminal sessions.

  • Start Terminal through macOS search.
  • Press Cmd+Space to open Spotlight.
  • Type Terminal.
  • Press Return.
  • Install Claude Code by running this command:
curl -fsSL https://claude.ai/install.sh | bash

What does this command do?

The command downloads Claude Code's native installer from Anthropic. It passes that installer to your shell so Claude Code can be installed.

You should see the installer finish without an error.

  • Start a new Terminal window so the installed command is available.
  • Press Cmd+N in Terminal.
  • Verify Python and Claude Code by running these commands:
python3 --version
claude --version

What do these commands check?

  • The first command reports the Python version available to Terminal.
  • The second command reports the installed Claude Code version.

You should see Python 3.14.10 and a Claude Code version number.

The next command opens Claude Code. It may send you to browser sign-in if this computer has not authenticated before.

  • Start Claude Code by running this command:
claude

What does this command do?

The command starts an interactive Claude Code session in Terminal. The same session can read and create files in the folder where you launch it.

  • Complete the browser sign-in prompts with your qualifying Claude account.
  • Follow the account prompts shown in your browser.
  • Return to Terminal after authentication completes.

You should see an authenticated Claude Code session in Terminal.

  • Close the Claude Code session with its on-screen exit instruction so the Terminal prompt returns.

Windows

  • Select the recommended Windows 64-bit installer from the release files.
  • Install the Python install manager with the downloaded Windows installer.
  • Complete the installer with its recommended options.
  • Start PowerShell through Windows search.
  • Press the Windows key to open search.
  • Type PowerShell.
  • Press Enter.
  • Install the Python 3.14 runtime by running this command:
py install 3.14

What does this command do?

The Python install manager downloads the newest Python runtime in the 3.14 line. This project uses Python 3.14.10.

You should see the Python install manager complete the runtime installation.

  • Install Claude Code by running this command:
irm https://claude.ai/install.ps1 | iex

What does this command do?

The command retrieves Claude Code's PowerShell installer from Anthropic. PowerShell then runs that installer.

You should see the installer finish without an error.

  • Start a new PowerShell window so the installed commands are available.
  • Press the Windows key to open search.
  • Type PowerShell.
  • Press Enter.
  • Verify Python and Claude Code by running these commands:
py -V:3.14 --version
claude --version

What do these commands check?

  • The first command asks the Python install manager for the installed 3.14 runtime version.
  • The second command reports the installed Claude Code version.

You should see Python 3.14.10 and a Claude Code version number.

The next command opens Claude Code. It may send you to browser sign-in if this computer has not authenticated before.

  • Start Claude Code by running this command:
claude

What does this command do?

The command starts an interactive Claude Code session in PowerShell. The same session can read and create files in the folder where you launch it.

  • Complete the browser sign-in prompts with your qualifying Claude account.
  • Follow the account prompts shown in your browser.
  • Return to PowerShell after authentication completes.

You should see an authenticated Claude Code session in PowerShell.

  • Close the Claude Code session with its on-screen exit instruction so the PowerShell prompt returns.

Choose the tab that matches the Python version result you just saw.

✔️ I see Python 3.14.10

Your pinned Python runtime is ready. A Claude Code version number confirms that its command is available too.

ⓧ I see an older version

Upgrade Python before creating the project environment. The pinned packages expect Python 3.14.10.

macOS

  • Check the upgraded runtime by running this command:
python3 --version
What does this command do?

The command reports which Python version the new Terminal session can use.

You should now see Python 3.14.10.

Windows

  • Install the current Python 3.14 runtime by running this command:
py install 3.14
What does this command do?

The Python install manager updates the installed runtime in the 3.14 line.

  • Check the upgraded runtime by running this command:
py -V:3.14 --version
What does this command do?

The command reports the installed Python 3.14 runtime version.

You should now see Python 3.14.10.

ⓧ Command not found

One installer has not reached your command path yet. Use the matching platform instructions below.

macOS

  • Install Python 3.14.10 from the Python release page if python3 is missing.
  • Reinstall Claude Code by running this command if claude is missing:
curl -fsSL https://claude.ai/install.sh | bash
What does this command do?

The command downloads and runs the supported Claude Code installer.

  • Start a new Terminal window.
  • Repeat both version checks.

Windows

  • Install Python 3.14 through the Python install manager by running this command:
py install 3.14
What does this command do?

The Python install manager downloads the supported Python runtime.

  • Reinstall Claude Code by running this command if claude is missing:
irm https://claude.ai/install.ps1 | iex
What does this command do?

The command downloads and runs the supported Claude Code installer for PowerShell.

  • Start a new PowerShell window.
  • Repeat both version checks.
Create the project environment

The project-only virtual environment keeps these pinned packages away from other Python work on your computer. It also gives Claude Code a predictable place to build the controller.

macOS

  • Create body-controller on your Desktop.
  • Click Finder in the Dock.
  • Select Desktop in the sidebar.
  • Choose File from the menu bar.
  • Choose New Folder.
  • Type body-controller.
  • Press Return.

You should see body-controller on your Desktop.

  • Open Terminal with body-controller as its current folder.
  • Open body-controller in Finder.
  • Choose View from the menu bar.
  • Choose Show Path Bar.
  • Control-click body-controller in the path bar.
  • Choose Open in Terminal.

The Terminal prompt should point to body-controller.

  • Create .venv by running this command:
python3 -m venv .venv

What does this command do?

Python creates a project-only environment named .venv inside body-controller.

  • Activate .venv by running this command:
source .venv/bin/activate

What does this command do?

The activation script points Python and package commands at the project-only environment.

You should see (.venv) at the start of the Terminal prompt.

  • Upgrade the active environment's package installer by running this command:
python -m pip install --upgrade pip

What does this command do?

The command upgrades pip inside .venv. Your computer's other Python environments stay unchanged.

You should see pip finish its upgrade inside the active environment.

  • Install the three pinned project packages by running this command:
python -m pip install mediapipe==1.3.0 opencv-contrib-python==5.1.0.95 pynput==1.8.2

What does this command do?

The command installs MediaPipe 1.3.0, opencv-contrib-python 5.1.0.95, and pynput 1.8.2 inside .venv.

MediaPipe depends on opencv-contrib-python. Installing a second OpenCV wheel would create competing cv2 packages.

You should see successful installation output for all three pinned packages.

Windows

  • Create body-controller on your Desktop.
  • Press the Windows key to open search.
  • Type File Explorer.
  • Press Enter.
  • Select Desktop in the navigation pane.
  • Press Ctrl+Shift+N.
  • Type body-controller.
  • Press Enter.

You should see body-controller on your Desktop.

  • Open Command Prompt with body-controller as its current folder.
  • Open body-controller in File Explorer.
  • Select the address bar.
  • Type cmd.exe.
  • Press Enter.

The Command Prompt should point to body-controller.

  • Create .venv by running this command:
py -V:3.14 -m venv .venv

What does this command do?

The Python install manager uses the 3.14 runtime to create a project-only environment named .venv.

  • Activate .venv by running this command:
.venv\Scripts\activate

What does this command do?

The activation script points Python and package commands at the project-only environment.

You should see (.venv) at the start of the Command Prompt.

  • Upgrade the active environment's package installer by running this command:
python -m pip install --upgrade pip

What does this command do?

The command upgrades pip inside .venv. Your computer's other Python environments stay unchanged.

You should see pip finish its upgrade inside the active environment.

  • Install the three pinned project packages by running this command:
python -m pip install mediapipe==1.3.0 opencv-contrib-python==5.1.0.95 pynput==1.8.2

What does this command do?

The command installs MediaPipe 1.3.0, opencv-contrib-python 5.1.0.95, and pynput 1.8.2 inside .venv.

MediaPipe depends on opencv-contrib-python. Installing a second OpenCV wheel would create competing cv2 packages.

You should see successful installation output for all three pinned packages.

MediaPipe will not install?

On a Mac, a message about no compatible distribution can mean the computer uses an Intel processor. MediaPipe 1.3.0 supports Apple silicon Macs for this project.

Confirm that (.venv) appears before the prompt. Then ask for help with the installation result.

Download and verify the pose model

The Pose Landmarker model stays inside body-controller so the later webcam scripts can process frames locally. Claude Code downloads the official bundle before it creates any script.

  • Start Claude Code from the active .venv inside body-controller by running this command:
claude

What does this command do?

The command opens Claude Code in the current body-controller folder. Claude Code can now create the model file in the correct location.

You should see Claude Code open while (.venv) remains active in the terminal session.

  • Ask Claude Code to download the official model by pasting this prompt:
Download the official MediaPipe Pose Landmarker Lite model from https://storage.googleapis.com/mediapipe-models/pose_landmarker/pose_landmarker_lite/float16/1/pose_landmarker_lite.task and save it in this folder as pose_landmarker_lite.task. Do not create any script yet.

What does this prompt do?

The prompt gives Claude Code the official model URL. It fixes the local filename as pose_landmarker_lite.task while keeping this setup step free of scripts.

You should see Claude Code report that pose_landmarker_lite.task now exists inside body-controller.

Before the final check, do you expect Claude Code to find every pinned package and the model file in the same project environment?

  • Verify the complete setup by pasting this checkpoint prompt:
Check this active virtual environment. Confirm that mediapipe imports as version 1.3.0, cv2 imports as OpenCV 5.1.0, and pynput is installed as version 1.8.2. Confirm that pose_landmarker_lite.task exists in this folder. Do not use mediapipe.solutions or create any script.

What does this prompt check?

Claude Code imports the installed libraries from the active .venv. It also checks the project folder for the local model bundle.

The restriction keeps this project on the supported MediaPipe Tasks API before any webcam script is created.

You should see MediaPipe 1.3.0, OpenCV 5.1.0, pynput 1.8.2, and pose_landmarker_lite.task confirmed inside body-controller.

Your supported environment is ready. Next, Claude Code turns the local pose model into a live skeleton viewer.

See Yourself as a Skeleton

Your project environment and local pose model are ready. Now you can turn the webcam feed into a moving skeleton with OpenCV.

A visible skeleton is the smallest useful test that your webcam, local MediaPipe model, and all 33 pose landmarks work together before you count any movements.

In this step, get ready to:
  • Create pose_view.py with Claude Code.
  • Run pose_view.py with access to your webcam.
  • Position your whole body inside the camera frame.
Ask Claude Code to create the skeleton viewer

The viewer needs one clear job before exercise logic enters the project. It should prove that local webcam frames reach the pose model and return a drawable skeleton.

  • Return to the Claude Code session from earlier and create pose_view.py by pasting this prompt:
Write pose_view.py in this folder. Open the default webcam with OpenCV. Use MediaPipe 1.3.0 Tasks API only through mp.tasks.vision.PoseLandmarker with pose_landmarker_lite.task in VIDEO mode. Never use mp.solutions or mediapipe.solutions. Convert each webcam frame into the MediaPipe image format the Tasks API expects, use monotonically increasing millisecond timestamps, and draw all 33 pose points plus the pose connections with OpenCV. Mirror the displayed image, show frames per second, and close when I press q. Process frames locally, never save frames, and never upload frames. After writing the file, explain only how to run it and what I should see. Do not paste the full script into chat unless I explicitly ask to inspect a bug.

What does this prompt do?

  • The prompt requires mp.tasks.vision.PoseLandmarker with pose_landmarker_lite.task in VIDEO mode.
  • Increasing timestamps keep each webcam frame in the correct order for video processing.
  • Local frame processing keeps the webcam images on your computer without saving them.

You should see Claude Code report that pose_view.py now opens the default webcam, draws the 33-point pose skeleton, mirrors the display, shows FPS, and closes with q.

Run the body controller camera window

Before you run the viewer, do you expect the pose model to track your whole body if your knees and ankles are outside the frame?

  • Run pose_view.py from the active .venv using the command for your computer:

macOS

python pose_view.py

What does this command do?

The command runs pose_view.py with the interpreter from your active .venv. The script loads the local pose model and requests the webcam.

  • Grant camera access to the terminal app that is running pose_view.py if macOS asks.
  • Search macOS for System Settings if the camera stays blocked.
  • Open the matching app.
  • Select Privacy & Security.
  • Select Camera.
  • Turn on the terminal app that is running pose_view.py.

Windows

py pose_view.py

What does this command do?

The command runs pose_view.py with the interpreter from your active .venv. The script loads the local pose model and requests the webcam.

  • Turn on Camera access if Windows blocks the feed.
  • Search Windows for Settings.
  • Open the matching app.
  • Select Privacy & security.
  • Select Camera.
  • Turn on Camera access.
  • Turn on Let desktop apps access your camera if it is off.
  • Stay on the Camera page.
  • Scroll to Let desktop apps access your camera.
  • Turn on the setting.

You should see the mirrored body controller camera window with skeleton points, pose connections, and an FPS value.

Black window or camera error?

  • Close any other app that is using the webcam before you run pose_view.py again.
  • Confirm that camera access is enabled for the same terminal app or desktop apps that launched the viewer.
  • Help me diagnose the camera problem.
Put your whole body in frame

Before you move, do you think the skeleton can follow a squat if the camera cannot see your ankles?

  • Step back until the camera shows your body from head to ankles.
  • Wave at the camera.
  • Raise one arm.
  • Complete one squat.

You should see the visible points in the 33-point skeleton follow each movement while the pose connections stay attached.

Only see upper-body points?

  • Move farther from the camera until your knees and ankles remain inside the image.
  • Help me improve the full-body framing.
  • Capture the body controller camera window with your computer's built-in screenshot controls while the mirrored skeleton and FPS are visible.
  • Close the body controller camera window by pressing q.

You should have a screenshot showing the working skeleton viewer. The body controller camera window should close after you press q.

That is your first live proof that the webcam and local pose model can follow your movement together.

Your live skeleton is working. Next, you will turn changing knee angles into counted squats.

Count Your Squats

Your 33-point skeleton now follows your body in the body controller camera window.

Raw pose landmarks cannot decide when a repetition is complete, so this step exposes the limits of starting thresholds through a tunable down-then-up state.

In this step, get ready to:
  • Create a squat counter in moves.py.
  • Test the starting thresholds with five full squats and five half squats.
  • Tune the thresholds until only full squats increase the counter.
Create the squat counter

The same knee angle can appear on the way down and on the way up. Finite-state rep counting keeps the sequence in order.

  • Ask Claude Code to create moves.py from pose_view.py by pasting this prompt:
Create moves.py from pose_view.py. Keep MediaPipe Tasks API only through mp.tasks.vision.PoseLandmarker with pose_landmarker_lite.task in VIDEO mode. Never use mp.solutions or mediapipe.solutions. Calculate each knee angle from hip, knee, and ankle landmarks: 23, 25, 27 on the left and 24, 26, 28 on the right. Treat 100 degrees down and 160 degrees up as starting values, not universal truths. Count one squat only after the knee angle goes below the down threshold and then returns above the up threshold. Ignore frames where the required landmarks have low visibility. Show SQUATS: n in large text, flash SQUAT! for each completed rep, and show the current knee angle for tuning. Keep frames local and never save or upload them. After writing the file, explain only how to run it and what I should see. Do not paste the full script into chat unless I explicitly ask to inspect a bug.

What does this prompt do?

  • The prompt keeps the existing local webcam flow in moves.py.
  • Landmarks 23, 25, and 27 provide the left knee angle.
  • Landmarks 24, 26, and 28 provide the right knee angle.
  • The down-then-up state awards one rep only after a complete movement sequence.
  • The visible angle gives you measurements for tuning the two starting thresholds.

Good progress. Claude Code should report that moves.py now displays SQUATS: n, SQUAT!, and the current knee angle.

Test the starting thresholds

A live movement test supplies the measurements that code alone cannot predict.

Before you run it, ask yourself whether five full squats will produce a count of exactly five on the first try.

macOS

  • Run the squat counter from the active .venv by running this command:
python moves.py

What does this command do?

The active Python environment runs moves.py with the installed camera and pose-tracking packages.

Windows

  • Run the squat counter from the active .venv by running this command:
py moves.py

What does this command do?

The Python launcher uses the active .venv to run moves.py.

  • Perform five slow full squats while facing the webcam.
  • Record the count immediately after the full squats: full squat count.
  • Record the lowest displayed knee angle from the full squats: lowest knee angle.
  • Perform five half squats while facing the webcam.
  • Record the count immediately after the half squats: final squat count.
  • Stand upright in the camera frame.
  • Record the displayed standing angle: standing knee angle.
  • Press q in the body controller camera window to close it.

The full-squat count may differ from 5. The half squats may also add reps.

This is the planned shortfall from applying starting thresholds to your camera and movement.

No knee angle on screen?

Move far enough from the webcam to keep your hips, knees, and ankles visible throughout each squat.

Ask for help with the missing landmarks: Help me diagnose why moves.py is not showing a knee angle from my webcam pose landmarks..

Tune the thresholds with Claude Code

Threshold tuning is the fiddly part because camera position changes the angles you see.

The four values you recorded give Claude Code a concrete range for your full and partial movements.

  • Ask Claude Code to tune moves.py by pasting this prompt with your recorded observations:
Tune the squat thresholds in moves.py for my camera and movement. I completed 5 full squats and 5 half squats. The script counted [[FULL_SQUAT_COUNT="full squat count"]] after the full squats and [[FINAL_COUNT="final squat count"]] after the half squats. The displayed knee angle was about [[LOWEST_ANGLE="lowest knee angle"]] at the bottom and [[STANDING_ANGLE="standing knee angle"]] while standing. Keep 100 degrees down and 160 degrees up as documented starting values, but adjust them from my observations. If the angle wobbles across a threshold, require it to remain past that threshold for a few consecutive frames. Keep SQUATS: n and SQUAT! unchanged. After updating the file, tell me which values changed and ask me to rerun the same 5 full plus 5 half squat test.

What does this prompt do?

  • Your observed angles replace assumptions about how your movement appears to the camera.
  • The tuned down threshold separates a full squat from a half squat.
  • The tuned up threshold confirms that you returned to standing before the counter awards a rep.
  • The optional consecutive-frame check reduces extra counts when the measured angle wobbles near a threshold.

Claude Code should report which threshold values changed while preserving SQUATS: n and SQUAT!.

Before you rerun it, ask yourself whether the tuned thresholds will count every full squat while ignoring each half squat.

macOS

  • Run the tuned squat counter by running this command:
python moves.py

What does this command do?

The active Python environment runs the updated threshold logic in moves.py.

Windows

  • Run the tuned squat counter by running this command:
py moves.py

What does this command do?

The Python launcher uses the active .venv to run the updated threshold logic.

  • Perform five full squats with the same camera position.

You should see SQUATS: 5 after the fifth full squat.

  • Perform five half squats with the same camera position.

The counter should remain at SQUATS: 5 after all five half squats.

The tuning cycle is complete when five full squats count once each while five half squats add nothing.

That tuning work paid off. Your body controller can now recognize full squats while ignoring partial movement, ready for separate punch controls next.

Add Punches

Your squat counter can now separate a full rep from a partial movement. That tuned state gives the controller one reliable action.

Separate left and right punch states give your body controller more actions while preserving the tuned squat count.

In this step, get ready to:
  • Add separate left and right punch counting to moves.py.
  • Test each physical movement against its matching counter.
  • Tune punch detection for your body and camera.
Add separate punch states

Your script already uses pose landmarks for lower-body motion. Punches add a separate state for each arm, so one side cannot increment the other.

  • In the Claude Code session from earlier, update moves.py by pasting this prompt:
Update moves.py to count left and right punches separately while preserving the tuned squat logic. Use the shoulder, elbow, and wrist landmarks for each arm. Treat an arm angle above 150 degrees with the wrist at about shoulder height as a starting punch threshold, then require the arm to bend back before another punch can count. Remember that the displayed image is mirrored, but do not swap the underlying anatomical left and right landmarks. Show SQUATS: n, LEFT: n, and RIGHT: n. Flash PUNCH L or PUNCH R for the matching rep. Keep frames local and never save or upload them. After updating the file, explain only what movement test to run and what I should see. Do not paste the full script into chat unless I explicitly ask to inspect a bug.

What does this prompt do?

  • It preserves your tuned squat state while adding independent states for both arms.
  • It keeps the MediaPipe Tasks API and the existing local frame processing.
  • It uses the anatomical left and right landmarks before handling the mirrored display labels.
  • It requires a bent arm before another punch can count, which prevents one extended arm from adding repeated punches.

Claude Code should report that moves.py now preserves squats and adds separate left and right punch states with SQUATS: n, LEFT: n, and RIGHT: n.

Test each movement separately

Each punch counter should react to one physical arm. Testing the movements separately makes a threshold error or mirrored label mismatch easier to spot.

Before you run the test, which counter do you expect each physical arm to change?

macOS

  • Run the updated movement counter from the active .venv by running this command:
python moves.py

What does this command do?

Python runs the updated moves.py file inside your project environment. The body controller camera window shows the three movement counters while the script processes your webcam locally.

Windows

  • Run the updated movement counter from the active .venv by running this command:
py moves.py

What does this command do?

The Python launcher runs the updated moves.py file inside your project environment. The body controller camera window shows the three movement counters while the script processes your webcam locally.

  • Face the camera with both arms visible from shoulder to wrist.
  • Perform five left jabs.

You should see only one punch counter change during the left jabs.

  • Perform five right jabs.

You should see only the other punch counter change during the right jabs.

  • Perform three full squats.

You should see the tuned squat counter reach SQUATS: 3 without either punch counter changing.

  • Record the final LEFT count here: your LEFT count after five punches.
  • Record the final RIGHT count here: your RIGHT count after five punches.
  • Record the straight-arm angle here: your straight-arm angle.
  • Record the label result here: the labels were correct, my physical left changed right, or my physical right changed left.

The counts may miss 5 because the 150-degree threshold is a starting value. Your observations now give Claude Code the evidence needed for tuning.

Tune the punch threshold and mirroring

Your straight-arm angle reveals whether the starting threshold fits your camera position. The physical-arm observation reveals whether the mirrored label mapping needs one correction.

  • Return to the Claude Code session from earlier and tune moves.py by pasting this prompt:
Tune the punch logic in moves.py for my camera. I performed 5 left punches and 5 right punches. The counters ended at LEFT: [[LEFT_COUNT="your LEFT count after five punches"]] and RIGHT: [[RIGHT_COUNT="your RIGHT count after five punches"]]. The straight-arm angle reached about [[PUNCH_ANGLE="your straight-arm angle"]] degrees. [[LABEL_MAPPING="the labels were correct, my physical left changed right, or my physical right changed left"]]. Keep 150 degrees as the documented starting value, but adjust it from my observation. Preserve SQUATS: n, LEFT: n, RIGHT: n, and the existing squat tuning. Fix mirroring only once if needed. After updating the file, tell me what changed and ask me to repeat 5 left, 5 right, and 3 squats.

What does this prompt do?

  • It gives Claude Code your measured arm angle and actual counter results.
  • It preserves the squat thresholds you already tuned.
  • It changes the punch threshold from your observation when needed.
  • It corrects the mirrored label mapping in one place when your physical arm changes the opposite label.

Claude Code should report the adjusted punch threshold or the single left-right mapping correction. It should also confirm that the existing squat tuning and required labels remain unchanged.

Before you rerun the test, do you expect all three counters to land on their target values?

macOS

  • Rerun the tuned movement counter by running this command:
python moves.py

What does this command do?

Python loads the updated tuning from moves.py. This fresh run lets you compare the three counters with the exact movement totals you perform.

Windows

  • Rerun the tuned movement counter by running this command:
py moves.py

What does this command do?

The Python launcher loads the updated tuning from moves.py. This fresh run lets you compare the three counters with the exact movement totals you perform.

  • Perform five left punches.

You should see LEFT: 5 while the other two counters remain unchanged.

  • Perform five right punches.

You should see RIGHT: 5 while the squat counter remains unchanged.

  • Perform three full squats.

That tuning paid off. The body controller camera window should now show SQUATS: 3, LEFT: 5, and RIGHT: 5.

Counters still drift?

  • Keep each shoulder, elbow, and wrist inside the camera frame throughout the punch.
  • Compare the displayed straight-arm angle with Claude Code's updated threshold.
  • Check that each arm bends before you throw the next punch.
  • Help me debug the punch counters in moves.py.

Your body controller now distinguishes squats from left and right punches. Next up, you will turn those completed movements into keyboard input.

Turn Moves Into Key Presses

Your tuned counters can now tell a full squat from each punch. The next goal is to make those movement events press keys.

Your movement counts need a synthetic keyboard input layer before they can control another window.

In this step, get ready to:
  • Generate the movement-to-key controller files.
  • Test the mapped keys in an empty document.
  • Resolve the intentional macOS permission failure.
Create the key map and controller

The controls.json file keeps each movement separate from its assigned key. The controller uses pynput for one key tap each time a tuned movement completes.

  • Ask Claude Code to create controls.json plus body_controller.py by pasting this prompt into the Claude Code session from earlier:
Create controls.json with squat mapped to space, left punch mapped to j, and right punch mapped to k. Create body_controller.py from moves.py. Use pynput to tap the mapped key exactly once for each counted movement. Start paused. In the body controller camera window, pressing p must toggle key output on and off and show whether output is PAUSED or ACTIVE. Stop sending keys whenever no body is detected. Keep SQUATS: n, LEFT: n, and RIGHT: n. Keep frames local and never save or upload them. After creating both files, explain only how to test them in TextEdit on Mac or Notepad on Windows. Do not paste the full scripts into chat unless I explicitly ask to inspect a bug.

What does this prompt do?

  • The controls.json file maps each counted movement to one keyboard key.
  • The body_controller.py file preserves your tuned movement logic while adding one key tap per completed movement.
  • The p toggle keeps output paused until you deliberately switch it to ACTIVE.

Claude Code should report that it created controls.json and body_controller.py. The controller should preserve SQUATS: n, LEFT: n, and RIGHT: n.

Test keypresses before the game

The keypress test document separates controller problems from game-specific input behavior. A successful document test proves that movement events are reaching another app.

  • Create an empty keypress test document in TextEdit on macOS or Notepad on Windows.

macOS

  • Press Cmd+Space to open the macOS search bar.
  • Type TextEdit.
  • Press Enter to open TextEdit.
  • Keep the new document empty.

Windows

  • Press the Windows key to open the Windows search bar.
  • Type Notepad.
  • Press Enter to open Notepad.
  • Keep the new document empty.

Before you move, consider whether the keypress test document will receive text on your computer.

macOS

  • Start the controller from the active .venv in body-controller by running this command:
python body_controller.py

What does this command do?

This command runs body_controller.py with the packages installed inside your active project environment.

  • Enable key output by pressing p while the body controller camera window is focused.
  • Focus the keypress test document.
  • Perform three squats followed by two left punches.

You should see no text appear in the keypress test document. This is the intentional macOS permission failure.

Windows

  • Start the controller from the active .venv in body-controller by running this command:
py body_controller.py

What does this command do?

This command runs body_controller.py with the active Windows project environment.

  • Enable key output by pressing p while the body controller camera window is focused.
  • Focus the keypress test document.
  • Perform three squats followed by two left punches.

You should see the cursor advance by three spaces followed by jj in the keypress test document.

Resolve the macOS permission failure

macOS can block keyboard control from a terminal app until you approve that app under Accessibility. The controller code has reached the operating-system boundary you designed this test to expose.

Accessibility permission is powerful, so grant it only to the exact terminal app that launched body_controller.py.

macOS

  • Grant Accessibility permission to the exact terminal app that ran body_controller.py.
  • Press Cmd+Space to open the macOS search bar.
  • Type System Settings.
  • Press Enter to open System Settings.
  • Select Privacy & Security.
  • Select Accessibility.
  • Turn on the exact terminal app that launched body_controller.py.
  • If the terminal app is missing, use the control beneath the app list to add that exact app.
  • Quit the terminal app completely.
  • Restart the same terminal app.
  • Return to the body-controller folder from earlier.
  • Reactivate .venv by running this command:
source .venv/bin/activate

What does this command do?

This command restores the project-only Python environment that contains MediaPipe, OpenCV, and pynput.

Before you rerun the controller, consider how granting permission to the exact terminal app should change the document test.

  • Rerun the controller by running this command:
python body_controller.py

What does this command do?

This starts the same controller again after macOS has approved its terminal app.

  • Enable key output by pressing p while the body controller camera window is focused.
  • Focus the keypress test document.
  • Perform three squats followed by two left punches.

You should now see the cursor advance by three spaces followed by jj. That permission hurdle is cleared, and your movements now generate known-good keys.

Windows

Windows needs no Accessibility change for this test. Keep the successful keypress test document showing three spaces followed by jj.

Still seeing no keypresses?

On macOS, confirm that the app enabled under Accessibility is the same terminal app that launched body_controller.py.

Confirm that the body controller camera window shows ACTIVE before you focus the keypress test document.

Help me diagnose why my movement controller is not typing into the keypress test document.

Your movements now produce verified keyboard input. Next up, you will map those known-good keys to your learner-owned single-player game.

Play Your Game With Your Body

Your keypress test document already showed that squats and punches can produce keyboard input. You now have a known-good controller to connect to your game.

That proof isolates any ignored input as game-specific before you record the finished controller.

In this step, get ready to:
  • Map your movements to the game window's keyboard controls.
  • Complete a body-controlled session that writes totals to sessions.csv.
  • Capture the finished controller in a proof recording.
Map movements and add session logging

A local CSV log preserves the totals after the body controller camera window closes. Your existing movement tuning and safety controls remain in place.

This project uses a learner-owned single-player game. Online games with anti-cheat are outside this project.

  • Start your learner-owned single-player game.
  • Use the game or its launcher to start the game window.
  • Record the keyboard control you want a squat to trigger as your squat key.
  • Use the game window's controls screen or official controls page to find the keyboard action for your squat movement.
  • Record the keyboard control you want a left punch to trigger as your left punch key.
  • Use the same controls screen or official controls page to find the keyboard action for your left-punch movement.
  • Record the keyboard control you want a right punch to trigger as your right punch key.
  • Use the same controls screen or official controls page to find the keyboard action for your right-punch movement.
  • Update the movement map and add local session logging by pasting this prompt into the Claude Code session from earlier:
Update controls.json for my learner-owned single-player game: squat should press [[SQUAT_KEY="your squat key"]], left punch should press [[LEFT_PUNCH_KEY="your left punch key"]], and right punch should press [[RIGHT_PUNCH_KEY="your right punch key"]]. Update body_controller.py so that when the session ends it appends one row to sessions.csv with the date, minutes played, squat count, left punch count, and right punch count, then prints the same totals. Preserve the p toggle, PAUSED and ACTIVE states, no-body safety stop, tuned movement logic, and the labels SQUATS: n, LEFT: n, and RIGHT: n. Keep all webcam frames local and never save or upload them. After updating the files, tell me which controls are mapped and what totals line I should see after quitting.

What does this prompt do?

Claude Code replaces the temporary movement map in controls.json with the three controls you selected.

It also updates body_controller.py to append completed session totals to sessions.csv.

You should see Claude Code report the three mapped controls. It should also confirm that the session totals print and append when the controller stops.

Did the update remove existing behavior?

Check that body_controller.py still preserves the p toggle, PAUSED and ACTIVE states, no-body safety stop, tuned movement logic, and all three counter labels.

Ask for help checking the controller update if any required behavior is missing.

Test movement input in the game window

The keypress test document already proved that pynput sends your mapped keys. This test reveals whether the game window accepts the same input.

  • Set the game window to windowed mode.
  • Use the game window's display controls to select its windowed option.
  • Start the existing controller with the command for your computer:

macOS

python body_controller.py

What does this command do?

This starts the controller from the active .venv. The body controller camera window starts with key output paused.

Windows

py body_controller.py

What does this command do?

This starts the controller with the active .venv runtime. The body controller camera window starts with key output paused.

You should see the body controller camera window with the existing counters and a PAUSED status.

  • Focus the body controller camera window.
  • Click once inside the body controller camera window so it receives your next keypress.
  • Press p to enable movement-triggered key output.

You should see the status change from PAUSED to ACTIVE.

  • Return focus to the game window.
  • Click once inside the game window so it receives the movement-triggered keys.

Before you move, do you expect the game window to accept the same synthetic keys as the keypress test document?

  • Perform each mapped movement once.

You should see the game window react to the matching keyboard action whenever the controller counts that movement.

  • Switch to a different learner-owned single-player game on macOS if the current game ignores the proven keypresses.

Continue with the next fallback only on Windows when the keypress test document received keys but the game window ignored them.

  • Install PyDirectInput version 1.0.4 inside the active Windows .venv by running:
python -m pip install pydirectinput==1.0.4

What does this command do?

This installs PyDirectInput 1.0.4 inside the project environment. This fallback uses Windows DirectInput scan codes for a game that rejected the proven pynput input.

  • Change only the Windows key-output backend by pasting this prompt into Claude Code:
Windows only: the keypress test document received keys from body_controller.py, but the game window ignores them. Change only the Windows key-output backend to pydirectinput 1.0.4. Keep pynput as the normal backend and do not use pydirectinput on Mac. Preserve controls.json, the p toggle, PAUSED and ACTIVE states, no-body safety stop, movement counters, and sessions.csv logging. After updating the file, tell me to rerun the same game test.

What does this prompt do?

Claude Code changes only the Windows key-output path. The movement logic, control map, safety controls, and session logging remain unchanged.

You should see Claude Code confirm that PyDirectInput is limited to the proven Windows game-input problem.

  • Rerun the Windows controller after Claude Code completes the fallback update:
py body_controller.py

What does this command do?

This restarts the controller with the Windows-only fallback. The body controller camera window still starts with key output paused.

You should see the game window react when the controller counts the matching movement. If it still ignores input, stop and use a different learner-owned single-player game.

Save the totals and record the proof

The proof recording brings the game response and movement counters into one view. The session log preserves the totals after the controller closes.

  • Arrange the game window beside the body controller camera window.
  • Use your computer's window controls to keep both windows visible at the same time.

macOS

  • Start a proof recording with the Screenshot app that captures both windows.
  • Press Shift-Command-5 to show the Screenshot app controls.
  • Select the recording area containing both windows.
  • Use the recording control to begin recording.

Windows

  • Start the proof recording with Xbox Game Bar by pressing Windows-Alt-R.
  • Press p if the body controller camera window shows PAUSED.

The body controller camera window should show ACTIVE before you return to the game window.

  • Play the game with your mapped movements for at least 30 seconds.

Before you stop the session, which squat and punch totals do you expect the controller to print?

  • Stop body_controller.py from the terminal that is running it.

You should see the date, minutes played, squat count, left punch count, and right punch count printed in the terminal. The same totals should be appended to sessions.csv.

macOS

  • Stop the proof recording with the Screenshot app controls.
  • Press Shift-Command-5 to show the Screenshot app controls again.
  • Use the recording control to stop and save the local proof recording.

Windows

  • Stop the proof recording by pressing Windows-Alt-R.
  • Open sessions.csv inside the body-controller folder.
  • Use your computer's normal folder controls to locate sessions.csv inside body-controller.

You should see a new row similar in structure to 2026-12-04,12,squats 20,left 31,right 33. Your row uses the date, duration, and totals from your own session.

  • Play the saved proof recording.
  • Use the recording file's playback controls to start the video.

You should see the game window beside the body controller camera window. The game should react while your movements change the counters.

You have the full loop working. Your body now controls the game while the local log and proof recording preserve the session.

Secret mission

Make Running Hold a Key Down

Your squat and punch controls tap a key once per rep. Extend the controller so running in place holds `w` until you stop or leave the camera frame.

Clean Up Your Resources

Clean Up Your Resources

Your body controller runs entirely on your computer, with no ongoing compute or storage cost from its local files. Choose whether to keep them, pause your local tools, or delete the project files completely.

Cost warning

Your qualifying Claude plan may continue billing independently of these local files. Deleting body-controller does not cancel that subscription.

  • Manage or cancel your qualifying Claude plan separately if you no longer need Claude Code.

Resources you used:

  • The local body-controller folder, including .venv, pose_landmarker_lite.task, pose_view.py, moves.py, controls.json, body_controller.py, and sessions.csv.
  • The local proof recording saved by your operating system.

Keep everything running

No action is needed. Choose this option if you want to continue testing movements or extending the controller.

  • Keep body-controller so your tuned controls, local model, session history, and project environment remain available.
  • Keep the proof recording so you can replay the finished body-controlled game demo.
  • Keep your qualifying Claude plan if you want to continue making changes with Claude Code.

Pause - I'll come back to this later

Pausing ends the active local tools while preserving every file for later.

macOS

  • End the active Claude Code session so you return to the terminal prompt.
  • Deactivate .venv by running this command:
deactivate
What does this command do?

The deactivate command leaves the project-only environment while keeping .venv and every project file in place.

  • Close the terminal app when you finish using it.
  • Close the body controller camera window if it is still open.
  • Close the game window if it is still open.
  • Leave body-controller and the proof recording in place until you return.

Windows

  • End the active Claude Code session so you return to the Command Prompt.
  • Deactivate .venv by running this command:
deactivate
What does this command do?

The deactivate command leaves the project-only environment while keeping .venv and every project file in place.

  • Close the Command Prompt when you finish using it.
  • Close the body controller camera window if it is still open.
  • Close the game window if it is still open.
  • Leave body-controller and the proof recording in place until you return.

Delete - I don't want to use this again

Deleting body-controller permanently removes the scripts, tuned settings, model, environment, and session history. A backup keeps any files you may want later.

macOS

  • Copy any files you want to keep from body-controller to a location outside that folder.
  • Stop body_controller.py if it is still running.
  • End the active Claude Code session so you return to the terminal prompt.
  • Remove the local body-controller folder by running these commands from its active terminal:
deactivate
cd ..
rm -rf body-controller
What do these commands do?
  • The deactivate command leaves the active project environment.
  • The cd .. command moves the terminal to the folder containing body-controller.
  • The rm -rf body-controller command permanently removes the project folder and everything inside it.
  • Find the proof recording in the folder where macOS saved it.
  • Delete the proof recording with the local file controls.
  • Confirm the proof recording no longer appears in that folder.

Windows

  • Copy any files you want to keep from body-controller to a location outside that folder.
  • Stop body_controller.py if it is still running.
  • End the active Claude Code session so you return to the Command Prompt.
  • Remove the local body-controller folder by running these commands from its active Command Prompt:
deactivate
cd ..
rmdir /s /q body-controller
What do these commands do?
  • The deactivate command leaves the active project environment.
  • The cd .. command moves the Command Prompt to the folder containing body-controller.
  • The rmdir /s /q body-controller command permanently removes the project folder and everything inside it.
  • Find the proof recording in the folder where Windows saved it.
  • Delete the proof recording with the local file controls.
  • Confirm the proof recording no longer appears in that folder.

Nice Work!

Nice Work!

You made it! Your local body controller now converts squats, punches, and running in place into keyboard input for your learner-owned single-player game.

Your proof recording shows the game window reacting beside the body controller camera window. The local sessions.csv log preserves your totals without storing webcam frames.

You've learned how to:

  • Guide Claude Code to build a local 33-point skeleton with MediaPipe Pose Landmarker and pose_landmarker_lite.task. The mirrored camera view follows your movement. Every webcam frame stays on your computer.
  • Tune movement counters for full squats, left punches, and right punches around your own range of motion. Read each result through SQUATS: n, LEFT: n, and RIGHT: n. Prove synthetic keyboard input in the keypress test document before sending the mapped controls to the game window.
  • Run a movement-controlled game session with p switching key output between PAUSED and ACTIVE. Save the session totals in sessions.csv. Capture the proof recording with both windows visible.
  • Secret Mission: Extend body_controller.py with a running hold-and-release action. Alternating high knees hold w. Stopping or losing body tracking releases the key within half a second.

Ready to quiz yourself?