Skip to content

finite_gamepad_key_up

The finite_gamepad_key_up returns whether a given FiniteGamepadKey is being pressed.

bool finite_gamepad_key_up(int id, FiniteShell *shell, FiniteGamepadKey key)
TypeDescription
int idThe id of the gamepad to get input from
FiniteShell *shellThe FiniteShell that the gamepad belongs to.
FiniteGamepadKey keyThe FiniteGamepadKey to check the state of
#include <finite/draw.h>
#include <finite/input.h>
FiniteShell *myShell = finite_shell_init("wayland-0");
if (!myShell) {
FINITE_LOG_FATAL("Unable to init shell");
}
bool withGP = finite_gamepad_init(myShell);
myShell->canHomeMenu = false;
if (!withGP) {
FINITE_LOG_ERROR("Can't poll controller data");
}
if (finite_gamepad_key_valid(FINITE_BTN_A)) {
FINITE_LOG("A btn is valid");
}
while (wl_display_dispatch(myShell->display) != -1) {
if (!finite_gamepad_key_up(0, myShell, FINITE_BTN_A)) {
FINITE_LOG("A btn down");
}
}

Developers should ALWAYS call finite_gamepad_key_valid to verify a FiniteGamepadKey’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.