← Back to Docs
  • index.html
  • Clayground
  • Clayground.GameController
  • GamepadHub
  • Clayground 2026.11
  • GamepadHub QML Type

    Internal singleton listing the connected physical gamepads. More...

    Import Statement: import Clayground.GameController

    Detailed Description

    GamepadHub reads physical pads through one backend - SDL3 on Linux, Windows, macOS and iOS, the browser's Gamepad API on WebAssembly - polled 125 times a second, and lists them. Games use GameController.gamepads, numConnectedGamepads and selectGamepad() rather than the hub.

    Properties

    The backend reading the pads: sdl, browser, or none where the build reads no pads.

    The connected pads, as GameController.gamepads describes them.

    The number of connected pads.

    Methods

    Returns the pad with deviceId, or null when it is not connected.

    Plugs in a pad that exists only in software, called name, with every standard button and axis, and returns its deviceId; -1 where the backend has no such pads. For tests: the pad goes through the same backend as a real one.

    Sets the button or axis input of the virtual pad deviceId to value, named as the pad's buttons and axes name them; a button is pressed above 0.5. Returns false for an unknown pad or input.

    Unplugs the virtual pad deviceId.

    Reads the backend now rather than at the next tick.