Added comment to nk_sdl_handle_grab in SDL demos

Explains call order of SDL_SetRelativeMouseMode and SDL_SetWindowGrab
This commit is contained in:
paccer 2024-02-23 20:39:08 +01:00
parent a10eb1351a
commit 56ab9d96ea
4 changed files with 4 additions and 0 deletions

View File

@ -240,6 +240,7 @@ nk_sdl_handle_grab(void)
if (ctx->input.mouse.grab) {
SDL_SetRelativeMouseMode(SDL_TRUE);
} else if (ctx->input.mouse.ungrab) {
/* better support for older SDL by setting mode first; causes an extra mouse motion event */
SDL_SetRelativeMouseMode(SDL_FALSE);
SDL_WarpMouseInWindow(sdl.win, (int)ctx->input.mouse.prev.x, (int)ctx->input.mouse.prev.y);
} else if (ctx->input.mouse.grabbed) {

View File

@ -349,6 +349,7 @@ nk_sdl_handle_grab(void)
if (ctx->input.mouse.grab) {
SDL_SetRelativeMouseMode(SDL_TRUE);
} else if (ctx->input.mouse.ungrab) {
/* better support for older SDL by setting mode first; causes an extra mouse motion event */
SDL_SetRelativeMouseMode(SDL_FALSE);
SDL_WarpMouseInWindow(sdl.win, (int)ctx->input.mouse.prev.x, (int)ctx->input.mouse.prev.y);
} else if (ctx->input.mouse.grabbed) {

View File

@ -349,6 +349,7 @@ nk_sdl_handle_grab(void)
if (ctx->input.mouse.grab) {
SDL_SetRelativeMouseMode(SDL_TRUE);
} else if (ctx->input.mouse.ungrab) {
/* better support for older SDL by setting mode first; causes an extra mouse motion event */
SDL_SetRelativeMouseMode(SDL_FALSE);
SDL_WarpMouseInWindow(sdl.win, (int)ctx->input.mouse.prev.x, (int)ctx->input.mouse.prev.y);
} else if (ctx->input.mouse.grabbed) {

View File

@ -271,6 +271,7 @@ nk_sdl_handle_grab(void)
if (ctx->input.mouse.grab) {
SDL_SetRelativeMouseMode(SDL_TRUE);
} else if (ctx->input.mouse.ungrab) {
/* better support for older SDL by setting mode first; causes an extra mouse motion event */
SDL_SetRelativeMouseMode(SDL_FALSE);
SDL_WarpMouseInWindow(sdl.win, (int)ctx->input.mouse.prev.x, (int)ctx->input.mouse.prev.y);
} else if (ctx->input.mouse.grabbed) {