46 lines
1.6 KiB
C
46 lines
1.6 KiB
C
#ifndef _CONTROLLER_H_
|
|
#define _CONTROLLER_H_
|
|
|
|
#include <SDL3/SDL.h>
|
|
#include <akerror.h>
|
|
#include "types.h"
|
|
|
|
#define AKGL_MAX_CONTROL_MAPS 8
|
|
#define AKGL_MAX_CONTROLS 32
|
|
|
|
typedef struct {
|
|
uint32_t event_on;
|
|
uint32_t event_off;
|
|
uint8_t button;
|
|
SDL_Keycode key;
|
|
uint8_t axis;
|
|
uint8_t axis_range_min;
|
|
uint8_t axis_range_max;
|
|
akerr_ErrorContext AKERR_NOIGNORE *(*handler_on)(akgl_Actor *obj, SDL_Event *event);
|
|
akerr_ErrorContext AKERR_NOIGNORE *(*handler_off)(akgl_Actor *obj, SDL_Event *event);
|
|
} akgl_Control;
|
|
|
|
typedef struct {
|
|
akgl_Actor *target;
|
|
uint16_t nextMap;
|
|
akgl_Control controls[AKGL_MAX_CONTROLS];
|
|
SDL_KeyboardID kbid;
|
|
SDL_JoystickID jsid;
|
|
SDL_MouseID mouseid;
|
|
SDL_PenID penid;
|
|
} akgl_ControlMap;
|
|
|
|
extern akgl_ControlMap GAME_ControlMaps[AKGL_MAX_CONTROL_MAPS];
|
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_controller_handle_event(void *appstate, SDL_Event *event);
|
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_controller_handle_button_down(void *appstate, SDL_Event *event);
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_controller_handle_button_up(void *appstate, SDL_Event *event);
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_controller_handle_added(void *appstate, SDL_Event *event);
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_controller_handle_removed(void *appstate, SDL_Event *event);
|
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_controller_pushmap(int controlmapid, akgl_Control *control);
|
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_controller_default(int controlmapid, char *actorname, int kbid, int jsid);
|
|
#endif // _CONTROLLER_H_
|