twn_input.c: remove input_mouse_captured(), add ctx.mouse_capture
This commit is contained in:
parent
6d19d2d819
commit
4ed3764c1d
@ -216,7 +216,7 @@ static void ingame_tick(State *state) {
|
||||
if (input_action_just_pressed("mouse_capture_toggle"))
|
||||
scn->mouse_captured = !scn->mouse_captured;
|
||||
|
||||
input_mouse_captured(scn->mouse_captured);
|
||||
ctx.mouse_capture = scn->mouse_captured;
|
||||
|
||||
generate_terrain(scn);
|
||||
draw_terrain(scn);
|
||||
|
@ -38,6 +38,7 @@ typedef struct Context {
|
||||
/* is set to true when state is invalidated and needs to be rebuilt */
|
||||
/* watch for it and handle properly! */
|
||||
bool initialization_needed;
|
||||
bool mouse_capture;
|
||||
} Context;
|
||||
|
||||
/* when included after twn_engine_context there's an 'ctx' defined already */
|
||||
|
@ -15,6 +15,5 @@ TWN_API bool input_action_pressed(const char *name);
|
||||
TWN_API bool input_action_just_pressed(const char *name);
|
||||
TWN_API bool input_action_just_released(const char *name);
|
||||
TWN_API Vec2 input_action_position(const char *name);
|
||||
TWN_API void input_mouse_captured(bool enabled);
|
||||
|
||||
#endif
|
||||
|
@ -52,15 +52,6 @@
|
||||
"return": "Vec2"
|
||||
},
|
||||
|
||||
"input_mouse_captured": {
|
||||
"module": "input",
|
||||
"symbol": "set_mouse_captured",
|
||||
"header": "twn_input.h",
|
||||
"params": [
|
||||
{ "name": "enabled", "type": "bool" }
|
||||
]
|
||||
},
|
||||
|
||||
"draw_sprite": {
|
||||
"module": "draw",
|
||||
"symbol": "sprite",
|
||||
@ -268,7 +259,8 @@
|
||||
{ "name": "mouse_movement", "type": "Vec2" },
|
||||
{ "name": "random_seed", "type": "float" },
|
||||
{ "name": "debug", "type": "bool" },
|
||||
{ "name": "initialization_needed", "type": "bool" }
|
||||
{ "name": "initialization_needed", "type": "bool" },
|
||||
{ "name": "mouse_capture", "type": "bool" }
|
||||
],
|
||||
"c_type": "Context"
|
||||
},
|
||||
|
@ -218,7 +218,7 @@ void input_state_deinit(InputState *input) {
|
||||
|
||||
void input_state_update(InputState *input) {
|
||||
/* TODO: don't spam it if it happens */
|
||||
if (SDL_SetRelativeMouseMode(input->mouse_captured) != 0)
|
||||
if (SDL_SetRelativeMouseMode(ctx.game_copy.mouse_capture) != 0)
|
||||
log_warn("(%s) Mouse capture isn't supported.", __func__);
|
||||
|
||||
int x, y;
|
||||
@ -326,11 +326,6 @@ Vec2 input_action_position(char const *action_name) {
|
||||
}
|
||||
|
||||
|
||||
void input_mouse_captured(bool enabled) {
|
||||
ctx.input.mouse_captured = enabled;
|
||||
}
|
||||
|
||||
|
||||
void input_reset_state(InputState *input) {
|
||||
for (size_t i = 0; i < shlenu(input->action_hash); ++i) {
|
||||
Action *action = &input->action_hash[i].value;
|
||||
|
Loading…
Reference in New Issue
Block a user