Gamepad

Gamepad helpers for input.devices.gamepads.

The types and pure helpers live in the companion roc-ray-types package so reusable packages can depend on them without depending on this platform. This module re-exports them, so the nominal types are shared either way.

Pass input.devices directly to these helpers; there is nothing to construct.

from_index : U64 -> Try(Id, [InvalidGamepadIndex, ..])

Validate and wrap a raw gamepad slot index.

lookup : Snapshot, Id -> [Connected(View), Disconnected]

Resolve a gamepad slot in a sampled snapshot.

available : { ..state, connected : List(U8) }, Id -> Bool

Whether a gamepad slot is connected in this input's latest sample.

button_down : { ..state, buttons : List(U8) }, Id, Button -> Bool

Check if a gamepad button is currently held down.

button_up : { ..state, buttons : List(U8) }, Id, Button -> Bool

Check if a gamepad button is currently up.

button_pressed : { ..state, buttons : List(U8) }, Id, Button -> Bool

Check if a gamepad button was pressed during this input interval.

button_released : { ..state, buttons : List(U8) }, Id, Button -> Bool

Check if a gamepad button was released during this input interval.

axis : { ..state, axes : List(F32) }, Id, Axis -> F32

Sampled value for one axis, in the range raylib reports.

Snapshot : Snapshot

Gamepad input sampled once per host-cycle input for every slot.

Declared in the roc-ray-types package's Gamepad and re-exported here, which is also where its receivers are documented.

Id : Id

The four gamepad slots the platform samples.

Button : Button

Face, shoulder, d-pad, and stick buttons.

Axis : Axis

Analogue stick and trigger axes.

View : View

A gamepad resolved against a snapshot, carrying its receivers.