mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-20 22:16:49 +01:00
MIR: Support relative mouse mode
This commit is contained in:
parent
ea2f5e5930
commit
f0708fc9dd
@ -136,7 +136,8 @@ HandleMouseButton(SDL_Window* sdl_window, Uint8 state, MirPointerEvent const* po
|
|||||||
static void
|
static void
|
||||||
HandleMouseMotion(SDL_Window* sdl_window, int x, int y)
|
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
|
static void
|
||||||
@ -218,11 +219,20 @@ HandleMouseEvent(MirPointerEvent const* pointer, SDL_Window* sdl_window)
|
|||||||
SDL_Mouse* mouse = SDL_GetMouse();
|
SDL_Mouse* mouse = SDL_GetMouse();
|
||||||
x = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_x);
|
x = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_x);
|
||||||
y = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_y);
|
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);
|
hscroll = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_hscroll);
|
||||||
vscroll = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_vscroll);
|
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)
|
if (vscroll != 0 || hscroll != 0)
|
||||||
HandleMouseScroll(sdl_window, hscroll, vscroll);
|
HandleMouseScroll(sdl_window, hscroll, vscroll);
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ MIR_WarpMouseGlobal(int x, int y)
|
|||||||
static int
|
static int
|
||||||
MIR_SetRelativeMouseMode(SDL_bool enabled)
|
MIR_SetRelativeMouseMode(SDL_bool enabled)
|
||||||
{
|
{
|
||||||
return SDL_Unsupported();
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO Actually implement the cursor, need to wait for mir support */
|
/* TODO Actually implement the cursor, need to wait for mir support */
|
||||||
|
Loading…
Reference in New Issue
Block a user