Skip to content

FiniteJoystick

The FiniteJoystick struct stores data about a controller’s joystick.

typedef struct {
char *name;
uint16_t xAxis;
double xValue; // value between -1 and 1
int xMin;
int xMax;
int xFlat; // deadzone
uint16_t yAxis;
double yValue;
int yMin;
int yMax;
int yFlat;
} FiniteJoystick;
TypeDescription
uint16_t idThe linux evdev code of the given input.
bool isHeldWhether the button is being held down. Acts as combined state of isDown and isUp
bool isDownWhether the button is currently being pressed down.
bool isUpWhether the button is not being pressed down.

Developers in general are discourageed from trying to read data from a gamepad directly as they are a “voliatile type” Controllers can be disconnected at any time for any reason and as such this struct may not always exist when trying to read it even after verifying its existance (TOCTOU).