rmp::input
rmp::input — named actions, and who gets to hear them.
Two things raylib deliberately does not decide for you, and a game needs both on its first day.
rmp::input::action("jump", KEY_SPACE, KEY_W, GAMEPAD_BUTTON_RIGHT_FACE_DOWN);
if (rmp::input::just_pressed("jump")) player.jump();A name and as many bindings as you like. The TYPE of each one says which device it belongs to — raylib's KeyboardKey, MouseButton and GamepadButton are different enums in C++ — so the dispatch happens at compile time and passing anything else is a compile error that names the argument.
And moving in eight directions, with keyboard, d-pad and stick at once, with no configuration at all:
player.velocity = rmp::input::vector() * speed;THE PART THAT IS NOT OBVIOUS is who gets to hear an action. A finger that presses a UI button must not also fire the gun underneath it, and that has to be true without anyone writing an if. So a query BY NAME is routed:
rmp::input::just_pressed("fire") // silent while the UI wants the pointer
rmp::input::pressed(KEY_W) // raw, exactly IsKeyDown, never routedThe argument type says which of the two you asked for, and you can see it at the call site without going to look anything up.
stick
Half of an analogue stick, as a binding. The one place you write something that is not a plain raylib constant:
rmp::input::action("left", KEY_A, rmp::input::stick(GAMEPAD_AXIS_LEFT_X, -1));sign is -1 or +1 and says which way counts. Anything else is clamped to those two, because a stick has two halves and there is no third thing to mean.
action
Define an action. At least one binding — an action with none is a mistake the compiler can catch, so it does.
REGISTERING THE SAME NAME AGAIN REPLACES IT. It does not add to it. That is what makes calling these from a scene's _ready() safe when the player enters that scene twenty times, which is where they naturally get written.
Reading actions
pressed
Held down
just_pressed
The frame it goes down
just_released
The frame it comes up
pressed, just_pressed, just_released
BY DEVICE these are raw: exactly IsKeyDown and friends, never routed, for when you want to know regardless of who else is listening.
axis_value
The raw position of an analogue axis, -1..+1, with the dead zone applied. A stick that reports past its end reads its end, and one that reports something that is not a number reads 0.
Directions
axis
-1, 0 or +1 from two actions, or the analogue value when a stick is what is moving them. negative and positive pressed at once gives 0, which is what a player mashing both keys expects.
vector
A direction from four actions, NORMALISED — so going diagonally is not 41 % faster than going straight. That is the single most common bug in 2D movement code and it costs one line here instead of being everybody's to remember.
+Y is DOWN, matching raylib's screen coordinates and rmp::Object::position, so "up" gives a negative Y and nothing has to be flipped on the way out.
axis, vector
The movement every game starts with, already bound: axis() is axis("move_left", "move_right"), and vector() is vector("move_left", "move_right", "move_up", "move_down"). A game that never calls action() moves with the keyboard, a d-pad and a stick at once, because these come defined out of the box:
move_left KEY_A, KEY_LEFT d-pad left left stick -X
move_right KEY_D, KEY_RIGHT d-pad right left stick +X
move_up KEY_W, KEY_UP d-pad up left stick -Y
move_down KEY_S, KEY_DOWN d-pad down left stick +Y
ui_accept KEY_ENTER, KEY_SPACE bottom face button
ui_cancel KEY_ESCAPE right face buttonThey are ordinary actions: action("move_left", ...) replaces one, and axis() and vector() read what it was given from then on.
The pointer
pointer_screen
In pixels, top-left origin
pointer, pointer_delta
In WORLD units, through the current scene's camera — what you compare an object's position with — and so through [window] stretch as well: on a letterboxed window, a pointer on a bar is outside the world. Same as pointer_screen() while the camera is where it starts AND the window is the design size — under NONE too, a bigger window puts the design's middle in its middle — and in a game with no scenes (RMP_ENTRY_POINT), which has no camera to go through.
pointer_delta: How far it moved since the last frame, in pixels
pointer_down, pointer_pressed, pointer_released
The left mouse button, which a touch presses too: held, the frame it goes down, the frame it comes up. Raw like pressed(MOUSE_BUTTON_LEFT), never routed.
Escape hatches
deadzone, set_deadzone
The dead zone below which a stick reads as zero. From [input] deadzone in raylib_multiplatform.toml; set it here to change it at runtime, clamped to 0..0.95 so a slider cannot switch the sticks off. NaN changes nothing, and is said once.
consumed_pointer, consumed_keyboard
Is anything above the caller holding the input? Useful for drawing a different cursor, or for code that wants the reason rather than the answer.