jacdac.gamepad

Submodules

Package Contents

Classes

GamepadClient

A two axis directional gamepad with optional buttons.

class jacdac.gamepad.GamepadClient(bus: jacdac.bus.Bus, role: str, *, missing_direction_value: Tuple[jacdac.gamepad.constants.GamepadButtons, float, float] | None = None)

Bases: jacdac.bus.SensorClient

A two axis directional gamepad with optional buttons. Implements a client for the Gamepad service.

property direction: Tuple[jacdac.gamepad.constants.GamepadButtons, float, float] | None

If the gamepad is analog, the directional buttons should be “simulated”, based on gamepad position (Left is { x = -1, y = 0 }, Up is { x = 0, y = -1}). If the gamepad is digital, then each direction will read as either -1, 0, or 1 (in fixed representation). The primary button on the gamepad is A., x: /,y: /

property variant: jacdac.gamepad.constants.GamepadVariant | None

(Optional) The type of physical gamepad.,

property buttons_available: jacdac.gamepad.constants.GamepadButtons | None

Indicates a bitmask of the buttons that are mounted on the gamepad. If the Left/Up/Right/Down buttons are marked as available here, the gamepad is digital. Even when marked as not available, they will still be simulated based on the analog gamepad.,

on_buttons_changed(handler: jacdac.bus.EventHandlerFn) jacdac.bus.UnsubscribeFn

Emitted whenever the state of buttons changes.