#ifndef IZ_JOYSTICK_H #define IZ_JOYSTICK_H #include #include #include #include #include "IZ_action.h" typedef u8 IZ_PadButton; static const u16 IZ_DEFAULT_AXIS_THRESHOLD = 8000; typedef enum { IZ_JOY_AXIS_DIRECTION_HORIZONTAL1 = 0, IZ_JOY_AXIS_DIRECTION_VERTICAL1 = 1, IZ_JOY_AXIS_DIRECTION_HORIZONTAL2 = 3, IZ_JOY_AXIS_DIRECTION_VERTICAL2 = 4, } IZ_JoyAxisDirection; typedef struct { u16 axis_threshold; SDL_JoystickID device_id; IZ_PadButton control_mapping[CONTROLS]; } IZ_JoystickConfig; typedef struct { SDL_Joystick* device; IZ_JoystickConfig config; } IZ_JoystickState; static const IZ_JoystickState IZ_JOYSTICK_DEFAULT_STATE[IZ_PLAYERS] = { { .config = { .control_mapping = { 255, 255, 255, 255, 11, 10, 1, 0, 4, 3, 6, 7, 8, 9, 13, 14, }, .axis_threshold = 8000u, .device_id = 0, }, .device = NULL, }, { .config = { .control_mapping = { 255, 255, 255, 255, 11, 10, 1, 0, 4, 3, 6, 7, 8, 9, 13, 14, }, .axis_threshold = 8000u, .device_id = 1, }, .device = NULL, }, }; IZ_ProcedureResult IZ_JoystickSaveConfig(IZ_JoystickState(*)[IZ_PLAYERS], const char*); void IZ_JoystickHandleEvents(IZ_JoystickState(*)[IZ_PLAYERS], IZ_Action(*)[IZ_PLAYERS], SDL_Event); IZ_ProcedureResult IZ_JoystickInitialize(IZ_JoystickState(*)[IZ_PLAYERS], const char*, u8, const char**); void IZ_JoystickTeardown(IZ_JoystickState(*)[IZ_PLAYERS]); #endif