diff options
Diffstat (limited to 'vendors/input.h')
-rw-r--r-- | vendors/input.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/vendors/input.h b/vendors/input.h new file mode 100644 index 0000000..f7f0239 --- /dev/null +++ b/vendors/input.h @@ -0,0 +1,70 @@ +#pragma once +#include "TZR.h" +#include <stdbool.h> + +#define INPUT_TAG_LEN 32 + +typedef enum InputBindType { + IBT_SCANCODE, + IBT_CONBUTTON, + IBT_MOUSEBUTTON +} InputBindType; + +typedef struct InputBind InputBind; +struct InputBind { + InputBindType type; + union { + SDL_Scancode sc; + uint8_t cb; + uint8_t mb; + }; + InputBind *next; +}; + +typedef struct InputAction InputAction; +struct InputAction { + char tag[INPUT_TAG_LEN]; + InputBind binds; + InputAction *next; +}; + +typedef enum InputPairType { + IPT_ACTION, + IPT_STICK +} InputPairType; + +typedef struct InputPair InputPair; +struct InputPair { + InputPairType type; + union { + struct { + char left[INPUT_TAG_LEN]; + char right[INPUT_TAG_LEN]; + }; + float (*stick)(void); + }; + InputPair *next; +}; + +typedef struct InputAxis InputAxis; +struct InputAxis { + char tag[INPUT_TAG_LEN]; + InputPair pairs; + InputAxis *next; +}; + +void input_deinit(void); +void input_new_action(const char *tag); +void input_new_axis(const char *tag); +void input_bind_action_sc(const char *tag, SDL_Scancode sc); +void input_bind_action_cb(const char *tag, uint8_t cb); +void input_bind_action_mb(const char *tag, uint8_t mb); +void input_bind_axis_gc(const char *tag, SDL_GameControllerAxis ax); +void input_bind_axis_act(const char *tag, const char *l, const char *r); + +bool input_down(const char *tag); +bool input_up(const char *tag); +bool input_pressed(const char *tag); +bool input_released(const char *tag); +int input_axis(const char *tag); +float input_axisf(const char *tag); |