#pragma once #include #include #include #ifdef __cplusplus extern "C" { #endif /** * @brief Unified, normalized controller state representing any gamepad. * * Analog sticks are scaled to -32768 to 32767 (0 is neutral centered). * Triggers are normalized from 0 to 255 (0 is released, 255 is fully depressed). */ typedef struct { /* Analog Axes */ int16_t lx; /* Left Stick X (-32768 to 32767) */ int16_t ly; /* Left Stick Y (-32768 to 32767, up is positive) */ int16_t rx; /* Right Stick X (-32768 to 32767) */ int16_t ry; /* Right Stick Y (-32768 to 32767, up is positive) */ /* Analog Triggers */ uint8_t lt; /* Left Trigger (0 to 255) */ uint8_t rt; /* Right Trigger (0 to 255) */ /* D-Pad Buttons */ uint8_t dpad_up : 1; uint8_t dpad_down : 1; uint8_t dpad_left : 1; uint8_t dpad_right : 1; /* Face Buttons */ uint8_t btn_a : 1; /* South (Xbox A, Switch B, PS Cross) */ uint8_t btn_b : 1; /* East (Xbox B, Switch A, PS Circle) */ uint8_t btn_x : 1; /* West (Xbox X, Switch Y, PS Square) */ uint8_t btn_y : 1; /* North (Xbox Y, Switch X, PS Triangle) */ /* Shoulder & Trigger Digital Buttons */ uint8_t btn_lb : 1; /* Left Bumper / L1 / L */ uint8_t btn_rb : 1; /* Right Bumper / R1 / R */ uint8_t btn_lt : 1; /* Left Trigger digital click / ZL */ uint8_t btn_rt : 1; /* Right Trigger digital click / ZR */ /* Special & Navigation Buttons */ uint8_t btn_select : 1; /* Back / View / Minus / Select */ uint8_t btn_start : 1; /* Start / Menu / Plus */ uint8_t btn_l3 : 1; /* Left Thumbstick Click */ uint8_t btn_r3 : 1; /* Right Thumbstick Click */ uint8_t btn_system : 1; /* Xbox Guide / PS / Switch Home */ uint8_t btn_share : 1; /* Share / Capture */ } controller_state_t; /** * @brief Reset controller state to neutral rest position. */ static inline void controller_state_reset(controller_state_t *state) { if (state) { memset(state, 0, sizeof(controller_state_t)); } } #ifdef __cplusplus } #endif