Final Platform Layer 0.9.8-beta
No Matches
Polling of input states


FPL supports manual polling of input states for Keyboard/Gamepad/Mouse as well.

Disable Input-Events

If you are only use polling to get your input states, you should disable the input-events entirely.
This is done by simply setting the fplInputSettings::disabledEvents to "1" in your fplSettings structure.


Use fplPollKeyboardState to poll the current keyboard state.
This state contains all the raw/mapped button states and the modifier states.

fplKeyboardState keyboardState;
if (fplPollKeyboardState(&keyboardState)) {
if (keyboardState.buttonStatesMapped[fplKey_Space] >= fplButtonState_Press) {
// Spacebar pressed
fpl_platform_api bool fplPollKeyboardState(fplKeyboardState *outState)
Polls the current keyboard state and writes it out into the output structure.
@ fplButtonState_Press
Key pressed.
A struct containing the full keyboard state.
fplButtonState buttonStatesMapped[FPL_MAX_KEYBOARD_STATE_COUNT]
Mapped button states.

See fplKeyboardState for more details.


Use fplPollGamepadStates to poll the current states for all connected game controllers.
This state contains all the buttons, digital-pad, the left/right stick position + trigger, etc.

fplGamepadStates gamepadStates;
if (fplPollGamepadStates(&gamepadStates)) {
for (int index = 0; index < fplArrayCount(gamepadStates.deviceStates); ++index) {
fplGamepadState *gamepadState = gamepadStates.deviceStates + index;
// ... do something with the gamepad state
fpl_platform_api bool fplPollGamepadStates(fplGamepadStates *outStates)
Polls the current gamepad states and writes it out into the output structure.
#define fplArrayCount(arr)
Returns the element count from a static array. This should ideally produce a compile error when passi...
A structure containing the entire gamepad state.
A struct containing the full state for all gamepad devices.
fplGamepadState deviceStates[FPL_MAX_GAMEPAD_STATE_COUNT]
Device states.

See fplGamepadStates for more details.

use fplGamepadState::isConnected to check if the gamepad is connected or not.


Use fplPollMouseState to poll the current mouse state.
This state contains the state of all the buttons (Left, Right, Middle) and the position in pixels coordinates.

fplMouseState mouseState;
if (fplPollMouseState(&mouseState)) {
int mousePosX = mouseState.x;
int mousePosY = mouseState.y;
if (mouseState.buttonStates[fplMouseButtonType_Left] >= fplButtonState_Pressed) {
// Left mouse button down
fpl_platform_api bool fplPollMouseState(fplMouseState *outState)
Polls the current mouse state and writes it out into the output structure.
@ fplMouseButtonType_Left
Left mouse button.
A struct containing the full mouse state.
int32_t y
Y-Position in pixels.
fplButtonState buttonStates[fplMouseButtonType_MaxCount]
Mouse button states mapped to fplMouseButtonType.
int32_t x
X-Position in pixels.

See fplMouseState for more details.


You can always use all those polling functions, regardless of the fplInputSettings::disabledEvents field!