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] @ git+https://github.com/agasthyako/Pocket-Wand"
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.1

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.1
File Size Uploaded
pocketwand-0.1.1.tar.gz 16.5 kB Details

Built distribution (wheel)

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

Total release size: 32.7 kB

Release files / pocketwand-0.1.1.tar.gz

Download URL pocketwand-0.1.1.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
487a7b3fae5f02be6be4778e9c719a23bf855b264e1e225a8cab4e86e74e5c39
BLAKE2b-256 checksum
How to use checksums
4beb57091dac0c92eb94d642dc4b0a104d8d7d6a2d594b1983046505d70defc4
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.1-py3-none-any.whl

Download URL pocketwand-0.1.1-py3-none-any.whl
Size 16.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c35697e08ac8cba5e465558cb015f3c5a7273229e26ff71448e847421030ff43
BLAKE2b-256 checksum
How to use checksums
6541435c7704ab7486b337f07ccd8caa7cfd62dc2cc05b7f75d36eef39f851b0
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

0.1.3

2 release files

0.1.2

2 release files

This release

0.1.1 This release

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