|
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
|
#include "gamepad_input.h"#include "bool_utils.h"#include "gamepad_context.h"#include "log.h"#include <GLFW/glfw3.h>#include <math.h>Macros | |
| #define | GLFW_INCLUDE_NONE |
| #define | TRIGGER_NORM_FACTOR 0.5F |
Functions | |
| void | gamepad_input_init (GamepadState *state) |
| Initializes gamepad state with default values. | |
| float | gamepad_apply_deadzone (float value, float deadzone) |
| Applies a dead-zone filter to an axis value. | |
| static void | gamepad_poll_buttons (GamepadState *state, const GLFWgamepadstate *pad, GamepadActions *actions) |
| Detects edge-triggered button presses and saves state. | |
| void | gamepad_input_poll (GamepadState *state, GamepadActions *actions) |
| Polls GLFW gamepad state and detects button events. | |
| void | gamepad_write_input (const GamepadState *state, GamepadContext *ctx) |
| Writes gamepad axes into a GamepadContext. | |
| #define GLFW_INCLUDE_NONE |
| #define TRIGGER_NORM_FACTOR 0.5F |
Factor to convert GLFW trigger range [-1,1] to normalised [0,1].
| float gamepad_apply_deadzone | ( | float | value, |
| float | deadzone | ||
| ) |
Applies a dead-zone filter to an axis value.
Returns 0.0 if |value| < deadzone, otherwise rescales linearly so the usable range is [0, 1] (preserving sign).
| value | Raw axis value in [-1, 1]. |
| deadzone | Dead-zone threshold in [0, 1). |
| void gamepad_input_init | ( | GamepadState * | state | ) |
Initializes gamepad state with default values.
| state | Pointer to the gamepad state to initialize. |
| void gamepad_input_poll | ( | GamepadState * | state, |
| GamepadActions * | actions | ||
| ) |
Polls GLFW gamepad state and detects button events.
Reads axes (with deadzone) into state->axes for later use by gamepad_write_input. Detects edge-triggered button presses. Call once per frame, before the physics accumulator loop.
| state | Pointer to the persistent gamepad state. |
| actions | Output struct for edge-detected button events (may be NULL). |
|
static |
Detects edge-triggered button presses and saves state.
| void gamepad_write_input | ( | const GamepadState * | state, |
| GamepadContext * | ctx | ||
| ) |
Writes gamepad axes into a GamepadContext.
Overlays analog stick values onto move_input and applies look (yaw/pitch). The caller bridges Camera ↔ GamepadContext.
| state | Pointer to the gamepad state (with cached axes). |
| ctx | Pointer to the context to write into. |