twn_input: add twn_scancode.h as port of SDL_scancode.h, remove SDL2/SDL.h header usage sa for plans on having clean public headers

This commit is contained in:
2024-10-06 23:49:05 +03:00
parent 61caec7258
commit 3e972b2dad
4 changed files with 451 additions and 22 deletions

View File

@ -202,7 +202,7 @@ void input_state_update(InputState *input) {
void input_bind_action_scancode(InputState *input,
char *action_name,
SDL_Scancode scancode)
Scancode scancode)
{
input_bind_code_to_action(input,
action_name,
@ -213,7 +213,7 @@ void input_bind_action_scancode(InputState *input,
void input_unbind_action_scancode(InputState *input,
char *action_name,
SDL_Scancode scancode)
Scancode scancode)
{
input_unbind_code_from_action(input,
action_name,

View File

@ -2,6 +2,26 @@
#define INPUT_INTERNAL_API_H
#include "twn_input.h"
#include "twn_vec.h"
#include <SDL2/SDL.h>
union ButtonCode {
SDL_Scancode scancode;
SDL_Keycode keycode;
SDL_GameControllerButton gamepad_button;
uint8_t mouse_button; /* SDL_BUTTON_ enum */
};
/* an input to which an action is bound */
/* it is not limited to literal buttons */
typedef struct Button {
enum ButtonSource source;
union ButtonCode code;
} Button;
void input_reset_state(InputState *input);