yet another api rework, removal of integer types in public api, optionals at the end, some cleaning
This commit is contained in:
@ -221,12 +221,14 @@ void input_state_update(InputState *input) {
|
||||
if (SDL_SetRelativeMouseMode(input->mouse_captured) != 0)
|
||||
log_warn("(%s) Mouse capture isn't supported.", __func__);
|
||||
|
||||
input->keyboard_state = SDL_GetKeyboardState(NULL);
|
||||
input->mouse_state = SDL_GetMouseState(&input->mouse_window_position.x,
|
||||
&input->mouse_window_position.y);
|
||||
int x, y;
|
||||
|
||||
SDL_GetRelativeMouseState(&input->mouse_relative_position.x,
|
||||
&input->mouse_relative_position.y);
|
||||
input->keyboard_state = SDL_GetKeyboardState(NULL);
|
||||
input->mouse_state = SDL_GetMouseState(&x, &y);
|
||||
input->mouse_window_position = (Vec2){ (float)x, (float)y };
|
||||
|
||||
SDL_GetRelativeMouseState(&x, &y);
|
||||
input->mouse_relative_position = (Vec2){ (float)x, (float)y };
|
||||
|
||||
ctx.game.mouse_position = input->mouse_window_position;
|
||||
ctx.game.mouse_movement = input->mouse_relative_position;
|
||||
@ -253,7 +255,7 @@ void input_state_update(InputState *input) {
|
||||
}
|
||||
|
||||
|
||||
void input_bind_action_control(char const *action_name,
|
||||
void input_action(char const *action_name,
|
||||
Control control)
|
||||
{
|
||||
SDL_assert_always(action_name);
|
||||
@ -275,29 +277,7 @@ void input_bind_action_control(char const *action_name,
|
||||
}
|
||||
|
||||
|
||||
// static void input_unbind_action_control(char const *action_name,
|
||||
// Control control)
|
||||
// {
|
||||
// SDL_assert_always(action_name);
|
||||
|
||||
// if (CONTROL_SCANCODE_START <= control && control < CONTROL_SCANCODE_LIMIT)
|
||||
// input_unbind_code_from_action(&ctx.input,
|
||||
// action_name,
|
||||
// BUTTON_SOURCE_KEYBOARD_PHYSICAL,
|
||||
// (union ButtonCode) { .scancode = (SDL_Scancode)control });
|
||||
|
||||
// else if (CONTROL_MOUSECODE_START <= control && control < CONTROL_MOUSECODE_LIMIT) {
|
||||
// uint8_t const mouse_button = (uint8_t)(control - CONTROL_MOUSECODE_START);
|
||||
// input_unbind_code_from_action(&ctx.input,
|
||||
// action_name,
|
||||
// BUTTON_SOURCE_MOUSE,
|
||||
// (union ButtonCode) { .mouse_button = (uint8_t)SDL_BUTTON(mouse_button)});
|
||||
// } else
|
||||
// log_warn("(%s) Invalid control value given: %i.", __func__, control);
|
||||
// }
|
||||
|
||||
|
||||
bool input_is_action_pressed(char const *action_name) {
|
||||
bool input_action_pressed(char const *action_name) {
|
||||
SDL_assert_always(action_name);
|
||||
|
||||
ActionHashItem *action = shgetp_null(ctx.input.action_hash, action_name);
|
||||
@ -309,7 +289,7 @@ bool input_is_action_pressed(char const *action_name) {
|
||||
}
|
||||
|
||||
|
||||
bool input_is_action_just_pressed(char const *action_name) {
|
||||
bool input_action_just_pressed(char const *action_name) {
|
||||
SDL_assert_always(action_name);
|
||||
|
||||
ActionHashItem *action = shgetp_null(ctx.input.action_hash, action_name);
|
||||
@ -321,7 +301,7 @@ bool input_is_action_just_pressed(char const *action_name) {
|
||||
}
|
||||
|
||||
|
||||
bool input_is_action_just_released(char const *action_name) {
|
||||
bool input_action_just_released(char const *action_name) {
|
||||
SDL_assert_always(action_name);
|
||||
|
||||
ActionHashItem *action = shgetp_null(ctx.input.action_hash, action_name);
|
||||
@ -333,7 +313,7 @@ bool input_is_action_just_released(char const *action_name) {
|
||||
}
|
||||
|
||||
|
||||
Vec2 input_get_action_position(char const *action_name) {
|
||||
Vec2 input_action_position(char const *action_name) {
|
||||
SDL_assert_always(action_name);
|
||||
|
||||
ActionHashItem *action = shgetp_null(ctx.input.action_hash, action_name);
|
||||
@ -346,7 +326,7 @@ Vec2 input_get_action_position(char const *action_name) {
|
||||
}
|
||||
|
||||
|
||||
void input_set_mouse_captured(bool enabled) {
|
||||
void input_mouse_captured(bool enabled) {
|
||||
ctx.input.mouse_captured = enabled;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user