Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
Loading...
Searching...
No Matches
camera_input.c File Reference
#include "camera_input.h"
#include "camera.h"
#include "gamepad_context.h"
#include "gamepad_input.h"
#include <GLFW/glfw3.h>
#include <cglm/vec3.h>
Include dependency graph for camera_input.c:

Functions

void camera_input_handle_key (Camera *cam, int key, int action)
 Processes a keyboard event to update camera movement flags.
 
void camera_input_handle_mouse (Camera *cam, double xpos, double ypos)
 Processes a mouse movement event to update camera orientation.
 
void camera_input_handle_scroll (Camera *cam, double yoffset)
 Processes a scroll event to adjust camera speed or zoom.
 
void camera_apply_gamepad (Camera *cam, const GamepadState *state)
 Applies gamepad input to camera within a fixed physics step.
 

Function Documentation

◆ camera_apply_gamepad()

void camera_apply_gamepad ( Camera *  cam,
const GamepadState *  state 
)

Applies gamepad input to camera within a fixed physics step.

Encapsulates the Camera↔GamepadContext copy-in/copy-out pattern: builds the GamepadContext from Camera fields, calls gamepad_write_input(), then copies modified values back into the Camera.

Parameters
camPointer to the Camera instance (move_input, yaw/pitch_target).
statePointer to the gamepad state (with cached axes from poll).
Here is the call graph for this function:

◆ camera_input_handle_key()

void camera_input_handle_key ( Camera *  cam,
int  key,
int  action 
)

Processes a keyboard event to update camera movement flags.

Maps specific keys (W, A, S, D, Q, E) to camera movement directions.

Parameters
camPointer to the Camera instance.
keyThe key code (e.g., GLFW_KEY_W).
actionThe key action (e.g., GLFW_PRESS, GLFW_RELEASE).

◆ camera_input_handle_mouse()

void camera_input_handle_mouse ( Camera *  cam,
double  xpos,
double  ypos 
)

Processes a mouse movement event to update camera orientation.

Calculates the delta from the last known position stored in the Camera struct and applies rotation (yaw/pitch).

Parameters
camPointer to the Camera instance.
xposThe current absolute X coordinate of the mouse.
yposThe current absolute Y coordinate of the mouse.
Here is the call graph for this function:

◆ camera_input_handle_scroll()

void camera_input_handle_scroll ( Camera *  cam,
double  yoffset 
)

Processes a scroll event to adjust camera speed or zoom.

Parameters
camPointer to the Camera instance.
yoffsetThe vertical scroll amount.
Here is the call graph for this function: