Expand description
Raw keyboard, pointer and gamepads (next to the virtual pads).
ⓘ
use gasm::{input, keys};
input::set_mode(input::KEYS_RAW); // read the keyboard directly, no keymap pads
let k = input::keys().unwrap_or_default();
if k.held(keys::SHIFT_LEFT) && k.held(keys::ARROW_LEFT) { … }
if let Some(p) = input::pointer() && p.pressed & input::MOUSE_LEFT != 0 { click(p.frame_x, p.frame_y) }Structs§
- Gamepad
- Raw gamepad or joystick. With
standard, W3C order: buttons 0 south, 1 east, 2 west, 3 north, 4/5 shoulders, 6/7 triggers, 8 select, 9 start, 10/11 sticks, 12-15 d-pad, 16 home; axes 0/1 left stick, 2/3 right stick (y > 0 = down). - KeyEvent
- Keys
- Keys held this frame; index with
crate::keysconstants. - Pointer
Constants§
- KEYS_
RAW - The runner stops mapping the keyboard to pads (gamepads still map).
- MOUSE_
BACK - MOUSE_
FORWARD - MOUSE_
LEFT - MOUSE_
MIDDLE - MOUSE_
RIGHT - POINTER_
HIDDEN - Hide the system cursor over the game.
- POINTER_
LOCKED - Capture the pointer for relative motion (best effort; the browser needs a click).
Functions§
- gamepad
- Slot 0-3 (connection order).
Noneif the runner has no gamepad support. - gamepad_
name - Device name, if a gamepad is connected in
slot. - key_
events - Presses and releases since the previous frame, in order (
None: no keyboard). - keys
Noneif the runner has no keyboard.- pointer
Noneif the runner has no pointer.- set_
mode KEYS_RAW | POINTER_HIDDEN | POINTER_LOCKED, any combination.