Record controller input

This commit is contained in:
Phireh 2024-12-13 02:44:08 +01:00
commit e84a413c9e
2 changed files with 87 additions and 2 deletions

32
input.h
View file

@ -44,6 +44,27 @@ typedef enum {
MOUSE_KEY_TOTAL = 18
} mouse_keysym_t;
typedef enum {
CONT_NORTH = 0,
CONT_EAST,
CONT_SOUTH,
CONT_WEST,
CONT_UP,
CONT_RIGHT,
CONT_DOWN,
CONT_LEFT,
CONT_L,
CONT_L2,
CONT_R,
CONT_R2,
CONT_RTHUMB,
CONT_LTHUMB,
CONT_SELECT,
CONT_START,
CONT_MODE,
CONT_TOTAL
} controller_keysym_t;
#define IME_STR_MAX 200 // TODO: check if this limit is sensible
#define KEYBOARD_KEY_TOTAL 256
@ -51,11 +72,18 @@ typedef struct {
uint8_t keyboard_state; // mostly used to check if we are using the IME
uint8_t keys[KEYBOARD_KEY_TOTAL]; // the state of the full keyboard
uint8_t mouse_state;
int32_t mouse_x;
int32_t mouse_x;
int32_t mouse_y;
uint8_t mouse_keys[MOUSE_KEY_TOTAL];
uint8_t mouse_keys[MOUSE_KEY_TOTAL];
uint32_t modifiers; // TODO: Decide on a format for keyboard mod keys
uint8_t ime_str[IME_STR_MAX]; // the final string coming from the IME for text input fields as utf8
uint8_t controller_buttons[CONT_TOTAL];
float lx_axis;
float ly_axis;
float lz_axis;
float rx_axis;
float ry_axis;
float rz_axis;
} input_t;
int32_t is_key_down(input_t *i, uint8_t key)