get the flycam going already

This commit is contained in:
2024-07-30 18:05:28 -03:00
parent f00bae7cfc
commit 7f1efce310
8 changed files with 146 additions and 12 deletions

View File

@ -2,6 +2,7 @@
#define INPUT_H
#include "config.h"
#include "src/vec.h"
#include "util.h"
#include <SDL2/SDL.h>
@ -39,8 +40,12 @@ struct button {
/* that is, changes in the states of any of the bound buttons will affect it */
struct action {
size_t num_bindings;
/* if you bind more than NUM_KEYBIND_SLOTS (set in config.h) */
/* it forgets the first button to add the new one at the end */
struct button bindings[NUM_KEYBIND_SLOTS];
t_fvec2 position; /* set if applicable */
t_fvec2 position; /* set if applicable, e.g. mouse click */
bool is_pressed;
bool just_changed;
};
@ -57,6 +62,7 @@ struct input_state {
const uint8_t *keyboard_state; /* array of booleans indexed by scancode */
uint32_t mouse_state; /* SDL mouse button bitmask */
t_vec2 mouse_window_position;
t_vec2 mouse_relative_position;
enum button_source last_active_source;
bool is_anything_just_pressed;
};
@ -85,7 +91,10 @@ void input_delete_action(struct input_state *input, char *action_name);
bool input_is_action_pressed(struct input_state *input, char *action_name);
bool input_is_action_just_pressed(struct input_state *input, char *action_name);
bool input_is_action_just_released(struct input_state *input, char *action_name);
t_fvec2 input_get_action_position(struct input_state *input, char *action_name);
void input_set_mouse_captured(struct input_state *input, bool value);
bool input_is_mouse_captured(struct input_state *input);
#endif