Skip to main content

snakedream

GitHub license GitHub last commit PyPI version Code style: black

Python interface for a Daydream controller.

Description

Provides a Python interface to a Daydream controller, by subscribing to GATT notifications for a characteristic (UUID: 00000001-1000-1000-8000-00805f9b34fb).

The DaydreamController class can be found in snakedream.device.

Byte definitions to interpret returned data are found in snakedream.constants (see this Stack Overflow answer for more information).

Data models to represent returned data and handle byte definition calculations are found in snakedream.models. Please note, ctypes.c_int32 is used when performing bitwise shifts to intentionally allow overflows.

snakedream.mouse and snakedream.graph contain callbacks for mouse and graph support, respectively. Mouse control is currently supported via two backends: uinput, creating a virtual mouse device, and PyAutoGUI, which controls the cursor directly. uinput is supported on Linux, both Xorg and Wayland. PyAutoGUI supports all known platforms, except Wayland on Linux. To manually specify which backend is used, set snakedream.config.MOUSE_BACKEND to the desired value.

Callbacks

snakedream.base provides an abstract base class, BaseCallback, to provide a parent for subclasses which utilise data from the Daydream controller.

To create a new callback class, create a subclass of BaseCallback, which implements the callback async method, which accepts the following arguments: sender: BleakGATTCharacteristic, data: bytearray. To register the callback for the controller, call the start method of the instance.

When new data is available from the controller, the callback will be called. The subclass will also have a controller attribute - passed at instantiation - which can be accessed directly within the callback.

For example:

class ExampleCallback(BaseCallback):
    async def callback(self, sender: BleakGATTCharacteristic, data: bytearray) -> None:
        if self.controller.buttons.click:
            print("Button clicked!")

callback = ExampleCallback(controller)
await callback.start()

Installation

PyPI

  1. Install project: pip install snakedream
  2. Run: snakedream

Source

Alternatively, after cloning the repository with: git clone https://github.com/Zedeldi/snakedream.git

Build

  1. Install project: pip install .
  2. Run: snakedream

Development

  1. Install dependencies: pip install -r requirements.txt
  2. Run: python -m snakedream

Usage

By default, with no arguments, snakedream will control the mouse with the gyroscope, using the appropriate backend for the host platform. Additionally, snakedream can output the controller state as JSON or to a graph with matplotlib.

For more information, see snakedream --help.

Libraries

Credits

License

snakedream is licensed under the MIT Licence for everyone to use, modify and share freely.

This project is distributed in the hope that it will be useful, but without any warranty.

Donate

If you found this project useful, please consider donating. Any amount is greatly appreciated! Thank you :smiley:

PayPal

Metadata

Release files for snakedream 1.2.2

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

Source distribution (sdist)

Source distribution for snakedream 1.2.2
File Size Uploaded
snakedream-1.2.2.tar.gz 13.4 kB Details

Built distribution (wheel)

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

Total release size: 28.6 kB

Release files / snakedream-1.2.2.tar.gz

Download URL snakedream-1.2.2.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7262911e18eb8c03ec05979ca1185cc0237e964057edd7dc06f1c7d0fffa61a8
BLAKE2b-256 checksum
How to use checksums
b06439356e26ee1deadb939400d094cdf828ab7c97691f8cbf81194ec65dff76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.2

Release files / snakedream-1.2.2-py3-none-any.whl

Download URL snakedream-1.2.2-py3-none-any.whl
Size 15.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
34e1924fc7ee6be591ca51d5ca2833690dae85ad43616aab1571ad759e4e10e1
BLAKE2b-256 checksum
How to use checksums
8f8ee46e442f47c5c805b35d6c6775e52f05222ccd601f6df5c6983f90f1a45f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.2

Release history Release notifications | RSS feed

This release

1.2.2 This release

2 release files

1.2.1

2 release files

1.2.0

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