Input

backend.Input (Class)

Clay backend input handling implementation.

This class provides the input event system for the Clay backend, handling:

  • Keyboard input events (key presses and releases)
  • Gamepad/controller input including analog sticks, buttons, and gyroscope
  • Gamepad haptic feedback (rumble/vibration)

Input events are forwarded from the Clay runtime (SDL on native platforms) and dispatched through Ceramic's event system. The backend supports multiple simultaneous gamepads and provides normalized analog stick values.

Instance Members

clay
startGamepadRumble(gamepadId: Int, lowFrequency: Float, highFrequency: Float, duration: Float): Void

Starts haptic feedback (rumble/vibration) on a gamepad.

Modern gamepads typically have two rumble motors:

  • Low frequency motor: Creates a strong, rumbly vibration
  • High frequency motor: Creates a weaker, buzzy vibration
Name Type Description
gamepadId Int The ID of the gamepad to rumble
lowFrequency Float Intensity of the low frequency motor (0.0 to 1.0)
highFrequency Float Intensity of the high frequency motor (0.0 to 1.0)
duration Float Duration of the rumble effect in seconds (0 for infinite)

clay
stopGamepadRumble(gamepadId: Int): Void

Stops any active haptic feedback on a gamepad.

Name Type Description
gamepadId Int The ID of the gamepad to stop rumbling

clay
unbindEvents(): Void

clay
new(): Void

Creates a new Input backend instance. Input events are automatically dispatched by the Clay runtime.

Private Members

clay
emitKeyDown(key: ceramic.Key): Void

Fired when a keyboard key is pressed down.

Name Type Description
key ceramic.Key The key that was pressed, including both key code and scan code information

clay
emitKeyUp(key: ceramic.Key): Void

Fired when a keyboard key is released.

Name Type Description
key ceramic.Key The key that was released, including both key code and scan code information

clay
emitGamepadAxis(gamepadId: Int, axisId: Int, value: Float): Void

Fired when a gamepad analog stick or trigger moves.

Name Type Description
gamepadId Int The ID of the gamepad (0-based index)
axisId Int The axis identifier (e.g., 0=left stick X, 1=left stick Y)
value Float The normalized axis value, typically -1.0 to 1.0 for sticks, 0.0 to 1.0 for triggers

clay
emitGamepadDown(gamepadId: Int, buttonId: Int): Void

Fired when a gamepad button is pressed down.

Name Type Description
gamepadId Int The ID of the gamepad (0-based index)
buttonId Int The button identifier (mapped to standard gamepad layout)

clay
emitGamepadUp(gamepadId: Int, buttonId: Int): Void

Fired when a gamepad button is released.

Name Type Description
gamepadId Int The ID of the gamepad (0-based index)
buttonId Int The button identifier (mapped to standard gamepad layout)

clay
emitGamepadGyro(gamepadId: Int, dx: Float, dy: Float, dz: Float): Void

Fired when gamepad gyroscope data is received (if supported by the controller).

Name Type Description
gamepadId Int The ID of the gamepad (0-based index)
dx Float Angular velocity around X axis (pitch) in degrees per second
dy Float Angular velocity around Y axis (yaw) in degrees per second
dz Float Angular velocity around Z axis (roll) in degrees per second

clay
emitGamepadEnable(gamepadId: Int, name: String): Void

Fired when a gamepad is connected and recognized.

Name Type Description
gamepadId Int The ID assigned to the gamepad (0-based index)
name String The name/description of the gamepad device

clay
emitGamepadDisable(gamepadId: Int): Void

Fired when a gamepad is disconnected.

Name Type Description
gamepadId Int The ID of the disconnected gamepad

Metadata

Name Parameters
:build tracker.macros.EventsMacro.build()
:autoBuild tracker.macros.EventsMacro.build()