Skip to main content

Module input

Module input 

Source
Expand description

Actions: what a player can do, and the controls bound to each one.

A game names its own actions — Jump, Walk, Aim — in up to three vocabularies, one per kind: a button is pressed, released or down, an axis reads one number, an axis2 reads two. InputActions holds the three, and Game::InputActions names the set; NoInputActions is the set of a game that reads no input, and Key is the prototype set that binds each key to itself. Every query — down, pressed, released, axis, axis2 — takes an action of that set and no other.

Each action declares its own default bindings, which may hold a key, a mouse button, a pad button, a stick or a composite of them. An axis or axis2 binding holds a deadzone — AxisBinding::DEFAULT_DEADZONE for a pad or joystick control, and zero for the rest — and a scale. A PointerDelta lane, a WheelDelta lane and Axis2Binding::pointer read how far they moved through that scale and nothing clamps what they read; every other binding reads in its kind’s own range.

A game that rebinds reads bindings for what an action is bound to now, and shows each binding’s text. actuated_button, actuated_axis and actuated_axis2 then report whatever the player just moved, which rebind takes. The engine keeps every rebind in the platform’s own store, under a name made from the title Config::new was given.

Cursor is what the pointer itself is drawn as, the closed set set_cursor takes for one frame; a frame that sets none draws Cursor::Arrow. Where the UI sets a cursor of its own, the UI’s is drawn instead. Cursor::Held draws no pointer and holds it in place, leaving a PointerDelta binding its movement to read and pointer the place it was held at; the frame after it sets another cursor releases it.

Structs§

Axis2Binding
A pair of controls that read back a vector, and the knobs they read through.
AxisBinding
One control that reads back a number, and the knobs it reads through.
ButtonAxis
Two buttons that make an axis: negative counts down, positive counts up.
ButtonAxis2
Four buttons that make a vector, the way WASD is laid out.
JoystickControl
A control of a device with no standard layout, by the number its platform reports for it: captured rather than written, and usable only on the machine that captured it.

Enums§

ButtonBinding
One control that reads back true while it is held.
Cursor
What the pointer is drawn as, which FrameContext::set_cursor takes.
Key
A key by physical position, independent of the layout in use: Key::W is the key at the W position on a US keyboard.
MouseButton
A mouse button. The first touch of a touch screen presses MouseButton::Left, wherever it lands.
NoInputActions
The input action set of a game that reads no input at all.
NoInputAxes
The vocabulary of a game with no number actions of its own.
NoInputAxes2
The vocabulary of a game with no vector actions of its own.
NoInputButtons
The vocabulary of a game with no button actions of its own.
Pad
A button of the standard gamepad layout, by its position rather than by what a maker prints on it.
PadAxis
One lane of the standard gamepad layout: positive is right and up, and a trigger reads 0..=1 of the range.
PointerDelta
One lane of the pointer, reporting how far it moved since the last frame rather than where it is, so its range is open and AxisBinding::scale is what bounds it.
Stick
A stick of the standard gamepad layout, read as both its lanes at once.
Switch
A control the window sends events for, rather than one that is polled.
WheelDelta
One lane of the wheel, reporting the notches it turned since the last frame, so its range is open and AxisBinding::scale is what bounds it.

Traits§

InputAction
Trait every action vocabulary implements, written by InputButtonAction, InputAxisAction and InputAxis2Action.
InputActions
The three vocabularies one game plays with, named together as Game::InputActions.
InputAxis2Action
An action that reads back a vector no longer than 1, or, bound to Axis2Binding::pointer, how far the pointer moved.
InputAxisAction
An action that reads back a number in -1..=1, or, bound to a PointerDelta or WheelDelta lane, how far it moved.
InputButtonAction
An action that reads back true while it is held.