From afbc0dd649809b34583c52f2bc99b5c82c06fd53 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Tue, 1 Apr 2014 16:37:10 -0400 Subject: [PATCH 1/2] input: sdl2: Fix guest_cursor logic Unbreaks relative mouse mode with sdl2, just like was done with sdl.c in c3aa84b6. Signed-off-by: Cole Robinson Signed-off-by: Gerd Hoffmann --- ui/sdl2.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ui/sdl2.c b/ui/sdl2.c index f1532e9d2c..e4cb9fbba6 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -403,13 +403,17 @@ static void sdl_send_mouse_event(struct sdl2_state *scon, int dx, int dy, } qemu_input_queue_abs(scon->dcl.con, INPUT_AXIS_X, off_x + x, max_w); qemu_input_queue_abs(scon->dcl.con, INPUT_AXIS_Y, off_y + y, max_h); - } else if (guest_cursor) { - x -= guest_x; - y -= guest_y; - guest_x += x; - guest_y += y; - qemu_input_queue_rel(scon->dcl.con, INPUT_AXIS_X, x); - qemu_input_queue_rel(scon->dcl.con, INPUT_AXIS_Y, y); + } else { + if (guest_cursor) { + x -= guest_x; + y -= guest_y; + guest_x += x; + guest_y += y; + dx = x; + dy = y; + } + qemu_input_queue_rel(scon->dcl.con, INPUT_AXIS_X, dx); + qemu_input_queue_rel(scon->dcl.con, INPUT_AXIS_Y, dy); } qemu_input_event_sync(); } From 2d968ffbae6b7899064f9f86f8508d9c19021e39 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Tue, 1 Apr 2014 16:37:11 -0400 Subject: [PATCH 2/2] input: sdl2: Fix relative mode to match SDL1 behavior Right now relative mode accelerates too fast, and has the 'invisible wall' problem. SDL2 added an explicit API to handle this use case, so let's use it. Signed-off-by: Cole Robinson Signed-off-by: Gerd Hoffmann --- ui/sdl2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/sdl2.c b/ui/sdl2.c index e4cb9fbba6..7506e2e13f 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -278,7 +278,7 @@ static void sdl_hide_cursor(void) SDL_ShowCursor(1); SDL_SetCursor(sdl_cursor_hidden); } else { - SDL_ShowCursor(0); + SDL_SetRelativeMouseMode(SDL_TRUE); } } @@ -289,6 +289,7 @@ static void sdl_show_cursor(void) } if (!qemu_input_is_absolute()) { + SDL_SetRelativeMouseMode(SDL_FALSE); SDL_ShowCursor(1); if (guest_cursor && (gui_grab || qemu_input_is_absolute() || absolute_enabled)) {