diff options
Diffstat (limited to 'src/play.c')
-rw-r--r-- | src/play.c | 37 |
1 files changed, 36 insertions, 1 deletions
@@ -39,6 +39,7 @@ typedef struct play_t { unsigned ticks_paused:1; unsigned update_needed:1; unsigned has_audio:1; + unsigned pointer_owned:1; const play_ops_t **ops; int n_ops; int context; @@ -196,7 +197,7 @@ void play_context_enter(play_t *play, int context) /* return context pointer of specified context, * a negative context requests the current context. */ -void * play_context(play_t *play, int context) +void * play_context(const play_t *play, int context) { assert(play); @@ -285,6 +286,40 @@ int play_ticks_elapsed(play_t *play, play_ticks_t timer, unsigned duration) } +void play_pointer_own(play_t *play) +{ + assert(play); + + if (play->pointer_owned) + return; + + SDL_SetRelativeMouseMode(SDL_TRUE); + + play->pointer_owned = 1; +} + + +void play_pointer_disown(play_t *play) +{ + assert(play); + + if (!play->pointer_owned) + return; + + SDL_SetRelativeMouseMode(SDL_FALSE); + + play->pointer_owned = 0; +} + + +int play_pointer_owned(const play_t *play) +{ + assert(play); + + return !!play->pointer_owned; +} + + void play_quit(play_t *play) { SDL_Event ev = { .type = SDL_QUIT }; |