From f0708fc9dd589a2d478fd2858159779aff2169f7 Mon Sep 17 00:00:00 2001 From: Brandon Schaefer Date: Tue, 7 Jun 2016 09:01:23 -0700 Subject: [PATCH] MIR: Support relative mouse mode --- src/video/mir/SDL_mirevents.c | 18 ++++++++++++++---- src/video/mir/SDL_mirmouse.c | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/video/mir/SDL_mirevents.c b/src/video/mir/SDL_mirevents.c index 0873a5806..c585822f6 100644 --- a/src/video/mir/SDL_mirevents.c +++ b/src/video/mir/SDL_mirevents.c @@ -136,7 +136,8 @@ HandleMouseButton(SDL_Window* sdl_window, Uint8 state, MirPointerEvent const* po static void HandleMouseMotion(SDL_Window* sdl_window, int x, int y) { - SDL_SendMouseMotion(sdl_window, 0, 0, x, y); + SDL_Mouse* mouse = SDL_GetMouse(); + SDL_SendMouseMotion(sdl_window, 0, mouse->relative_mode, x, y); } static void @@ -218,11 +219,20 @@ HandleMouseEvent(MirPointerEvent const* pointer, SDL_Window* sdl_window) SDL_Mouse* mouse = SDL_GetMouse(); x = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_x); y = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_y); + + if (mouse && (mouse->x != x || mouse->y != y)) { + if (mouse->relative_mode) { + int relative_x = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_relative_x); + int relative_y = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_relative_y); + HandleMouseMotion(sdl_window, relative_x, relative_y); + } + else { + HandleMouseMotion(sdl_window, x, y); + } + } + hscroll = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_hscroll); vscroll = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_vscroll); - - if (mouse && (mouse->x != x || mouse->y != y)) - HandleMouseMotion(sdl_window, x, y); if (vscroll != 0 || hscroll != 0) HandleMouseScroll(sdl_window, hscroll, vscroll); } diff --git a/src/video/mir/SDL_mirmouse.c b/src/video/mir/SDL_mirmouse.c index 439f3f3f2..b028d00b5 100644 --- a/src/video/mir/SDL_mirmouse.c +++ b/src/video/mir/SDL_mirmouse.c @@ -252,7 +252,7 @@ MIR_WarpMouseGlobal(int x, int y) static int MIR_SetRelativeMouseMode(SDL_bool enabled) { - return SDL_Unsupported(); + return 0; } /* TODO Actually implement the cursor, need to wait for mir support */