Fix cursor warping to center on older SDL versions
Reverted the order of the SDL_WarpMouseInWindow and SDL_GetMouseState to its original sequence. This avoids cursor warping to the center of screen on older SDL versions It causes an additional SDL_MOUSEMOTION event when ungrabbing, but does not cause any issues.
This commit is contained in:
parent
e3b0f24626
commit
a10eb1351a
|
@ -240,8 +240,8 @@ nk_sdl_handle_grab(void)
|
|||
if (ctx->input.mouse.grab) {
|
||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||
} else if (ctx->input.mouse.ungrab) {
|
||||
SDL_WarpMouseInWindow(sdl.win, (int)ctx->input.mouse.prev.x, (int)ctx->input.mouse.prev.y);
|
||||
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) {
|
||||
ctx->input.mouse.pos.x = ctx->input.mouse.prev.x;
|
||||
ctx->input.mouse.pos.y = ctx->input.mouse.prev.y;
|
||||
|
|
|
@ -349,8 +349,8 @@ nk_sdl_handle_grab(void)
|
|||
if (ctx->input.mouse.grab) {
|
||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||
} else if (ctx->input.mouse.ungrab) {
|
||||
SDL_WarpMouseInWindow(sdl.win, (int)ctx->input.mouse.prev.x, (int)ctx->input.mouse.prev.y);
|
||||
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) {
|
||||
ctx->input.mouse.pos.x = ctx->input.mouse.prev.x;
|
||||
ctx->input.mouse.pos.y = ctx->input.mouse.prev.y;
|
||||
|
|
|
@ -349,8 +349,8 @@ nk_sdl_handle_grab(void)
|
|||
if (ctx->input.mouse.grab) {
|
||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||
} else if (ctx->input.mouse.ungrab) {
|
||||
SDL_WarpMouseInWindow(sdl.win, (int)ctx->input.mouse.prev.x, (int)ctx->input.mouse.prev.y);
|
||||
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) {
|
||||
ctx->input.mouse.pos.x = ctx->input.mouse.prev.x;
|
||||
ctx->input.mouse.pos.y = ctx->input.mouse.prev.y;
|
||||
|
|
|
@ -271,8 +271,8 @@ nk_sdl_handle_grab(void)
|
|||
if (ctx->input.mouse.grab) {
|
||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||
} else if (ctx->input.mouse.ungrab) {
|
||||
SDL_WarpMouseInWindow(sdl.win, (int)ctx->input.mouse.prev.x, (int)ctx->input.mouse.prev.y);
|
||||
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) {
|
||||
ctx->input.mouse.pos.x = ctx->input.mouse.prev.x;
|
||||
ctx->input.mouse.pos.y = ctx->input.mouse.prev.y;
|
||||
|
|
Loading…
Reference in New Issue