diff --git a/apps/demos/scenery/scenes/ingame.c b/apps/demos/scenery/scenes/ingame.c index 0f8733f..a8ba304 100644 --- a/apps/demos/scenery/scenes/ingame.c +++ b/apps/demos/scenery/scenes/ingame.c @@ -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); diff --git a/include/twn_context.h b/include/twn_context.h index f78b3d1..55b2412 100644 --- a/include/twn_context.h +++ b/include/twn_context.h @@ -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 */ diff --git a/include/twn_input.h b/include/twn_input.h index d4b8032..d84df7a 100644 --- a/include/twn_input.h +++ b/include/twn_input.h @@ -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 diff --git a/share/twn_api.json b/share/twn_api.json index 6f9e044..2e3f7c9 100644 --- a/share/twn_api.json +++ b/share/twn_api.json @@ -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" }, diff --git a/src/twn_input.c b/src/twn_input.c index 550f762..cef4aa1 100644 --- a/src/twn_input.c +++ b/src/twn_input.c @@ -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;