Skip to content

finite_key_pressed

The finite_key_pressed returns whether a given FiniteKey is being pressed.

bool finite_key_pressed(FiniteKey key, FiniteKeyboard *board)
TypeDescription
FiniteKey keyThe FiniteKey to check the state of
FiniteKeyboard *boardThe FiniteKeyboard to check the state from
#include <finite/draw.h>
#include <finite/input.h>
FiniteShell *myShell = finite_shell_init("wayland-0");
if (!myShell) {
FINITE_LOG_FATAL("Unable to init shell");
}
FiniteKeyboard *kbd = finite_input_keyboard_init(myShell->display);
while (wl_display_dispatch(myShell->display) != -1) {
if (!finite_key_valid(FINITE_KEY_A)) {
FINITE_LOG_ERROR("Finite Key A is not valid");
}
if (finite_key_pressed(FINITE_KEY_A, kbd)) {
FINITE_LOG("A was pressed");
}
}

This function returns whether a key was pushed down then immediately released. For “input held” related events use finite_key_down instead

Developers should ALWAYS call finite_key_valid to verify a FINITE_KEY’s existence in the internal finite_key_lookup table. Just because an enum exists does not mean that the evdev code for that input option is present.