Skip to main content

PocketWand

Turn any phone into a motion controller for your Python program. The phone streams its rotation through its web browser, so there's no app to install, and it works on iPhone and Android, on any network (campus Wi-Fi included).

Try the demo

pip install "pocketwand[demo]"
pocketwand demo
  1. A window opens with a QR code (it takes a few seconds to get a public link).
  2. Scan it with your phone's camera and open the link.
  3. Tap Enable motion and allow access.
  4. Point your phone at the screen and move it. The phone on screen copies it.

Press R (or the Recentre button on the phone) to make "pointing at the screen" count as straight ahead again.

pocketwand print does the same without a window and prints the Controller state to the terminal.

Use it in your own Game

import pocketwand

room = pocketwand.Room()                  # starts the server and tunnel, prints a QR code
room.on_join = lambda c: print("joined slot", c.slot)

while True:
    c = room.controller(0)             # never None; an empty Slot reads as disconnected
    if c.connected:
        c.orientation                  # Quaternion(w, x, y, z)
        c.orientation.matrix()         # 3x3 rotation matrix
        yaw, pitch, roll = c.euler     # degrees
        c.button                       # True while the on-screen button is held
    # c.recenter() makes the current facing count as straight ahead

Frames. Orientation rotates the phone's frame (+X right edge, +Y top of the phone, +Z out of the screen) into the world frame (+X right, +Y towards your screen, +Z up). Recentring only changes heading, so tilt always matches gravity.

Several phones. Every phone that opens the link gets its own Slot (room.controller(1), …). A phone that reconnects gets its old Slot back. room.controllers lists the connected ones.

State is updated on a background thread; reading it from your game loop every frame is safe and cheap.

How it works

Room() runs a small web server on your computer and opens a free Cloudflare quick tunnel to it (the cloudflared program is downloaded automatically on first run). The phone opens the page over HTTPS, which iOS requires before a page can read motion sensors, and streams its orientation back over a WebSocket. Both sides only make outgoing connections, so firewalls and campus client isolation don't get in the way.

Needs Python 3.10+ and an internet connection.

Metadata

Release files for pocketwand 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pocketwand 0.1.3
File Size Uploaded
pocketwand-0.1.3.tar.gz 16.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pocketwand 0.1.3
File Interpreter ABI Platform
pocketwand-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 32.8 kB

Release files / pocketwand-0.1.3.tar.gz

Download URL pocketwand-0.1.3.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bcf21a7dcbdcc1884860798b2b773fe3cf2cf27ceb9e39d8f81058d1c1a315aa
BLAKE2b-256 checksum
How to use checksums
e25ab9854dbe5056f71f1df1377d18397e79aea546bc2c0f0303988c917afb4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release files / pocketwand-0.1.3-py3-none-any.whl

Download URL pocketwand-0.1.3-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
04cdc136e69208f4cf70c57828f418fd8c7d5eb482d1bcc8f855a6311433b85d
BLAKE2b-256 checksum
How to use checksums
4aa52064d2e7a63ee2da82fea412184460592335b2aa3a484bc1d2dba55ae057
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page