Gamepads and Joysticks are supported by ACGL when using GLFW to create the window or with QT on Linux.
Depending on the windowing toolkit, either ACGL_COMPILE_WITH_GLFW or ACGL_COMPILE_WITH_QT have to be defined at compile time. If none is defined the GamePad objects will always report a not-found device. Gamepads and joysticks are both supported by the ACGL::GamePad class that has two goals:
Abstract from the actual gamepad API (bare Linux access, GLFW).
Provide a gamepad independent access to the buttons and axes by logical names.
To understand point two we have to understand, that most APIs just list all buttons and analog axes with no information about which buttons are located where on the device. Also some gamepads report buttons only as analog inputs, some axes start at -1 and go to 1, some have a range of 0 to 1 etc.
At least for the supported and detected gamepads, all axes that the user can move in two directions range from -1 (left/down) to 1 (up/right) as float values. All trigger that are sensitive go from 0 (not pressed) to 1 (fully pressed). Currently the PS3 controller and the XBox 360 controller are supported. For all others the class will only support un-named button/axis access.
After a gamepad object was created, call update() each frame to get new inputs. Now you can check if a button is pressed, the button state changed (from pressed to unpressed and vice versa since the last update() ) or get the float value from an axis. Undefined axes will return 0.0f, undefined buttons false. This way it should always be save to query the buttons even if no gamepad is present (which also can be checked by querying ok() ).
For debugging printState() can be called to print all button and axis states as reported by the API of calling printPressedButtons() which writes the names of all mapped buttons. Button name to button number mappings can be created at runtime as well for unsupported controllers (same for analog axes) (setButtonMapping() / setAxisMapping() ).
Each axis can have a minimal sensitivity that has to be exceeded to trigger any movement, set by setMinAxisSensitivity() so a just touched analog stick will not always report a movement and result in a drift.