Skip to main content

An anywidget that allows gamepad input in Marimo

Project description

mopad

An anywidget that allows gamepad input in Marimo notebooks. Perfect for interactive data exploration, games, or any application that needs real-time gamepad input.

Features

  • 🎮 Automatic gamepad detection - No need to press buttons before starting
  • 📊 Real-time visual feedback - Connection status and button press information
  • ⏱️ Precise timestamp tracking - Millisecond-accurate timing for button presses
  • 🔗 Any button support - Capture input from any bluetooth gamepad

Installation

pip install mopad

Usage

Basic Example

import marimo as mo
from mopad import MopadWidget

# Create and display the widget
gamepad = mo.ui.anywidget(MopadWidget())
gamepad

For a full demo you can check Github pages.

Widget Properties

Property Type Description
last_button_pressed int Index of the last pressed button (-1 if none)
current_timestamp float Timestamp of the most recent button press (ms)
previous_timestamp float Timestamp of the previous button press (ms)
axes list[float] Analog stick values: [left_x, left_y, right_x, right_y]
dpad_up bool True when D-pad up is pressed
dpad_down bool True when D-pad down is pressed
dpad_left bool True when D-pad left is pressed
dpad_right bool True when D-pad right is pressed
button_id int Legacy property for backward compatibility
k

Gamepad Setup

  1. Connect your gamepad to your computer (USB or Bluetooth)
  2. Press any button on the gamepad to activate it in the browser
  3. Start the widget - it will automatically detect the connected gamepad

Note: Due to browser security policies, gamepads need user interaction to be detected. The widget will guide you through the connection process with clear visual indicators.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mopad-0.3.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mopad-0.3.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file mopad-0.3.0.tar.gz.

File metadata

  • Download URL: mopad-0.3.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.7

File hashes

Hashes for mopad-0.3.0.tar.gz
Algorithm Hash digest
SHA256 31bc65eaecb5f00401dc5b7b33b88e124727df1b4939d737c85389b77bce60b4
MD5 7f856cc90878ce4edd4a65c682862879
BLAKE2b-256 2e4b85f9ba4c2ba306b85a4b2e1d68a4add12a69e85d8b416f2bea4c7ba9c740

See more details on using hashes here.

File details

Details for the file mopad-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: mopad-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.7

File hashes

Hashes for mopad-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b0beeb554ebfb208e0c1c201ab61841ce56473ff310b3beec7c410f89b2e885
MD5 2607112340bf56e35aab7aa3ffab4862
BLAKE2b-256 9af0261e25c10460bd91375363c397b7b870a57f89056128295f29ad6784c8c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page