diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1f75fbfe0..53a3b6567 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -10,7 +10,7 @@ jobs: - template: .ci/esy-build-steps.yml - job: MacOS14 - displayName: "MacOS High Sierra" + displayName: "MacOS Mojave" pool: vmImage: 'macOS-10.14' steps: diff --git a/include/SDL_events.h b/include/SDL_events.h index d35ec36c6..5a16eb6cd 100644 --- a/include/SDL_events.h +++ b/include/SDL_events.h @@ -325,14 +325,12 @@ typedef struct SDL_PanEvent Uint32 type; /**< ::SDL_PANEVENT */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 windowID; /**< The window with mouse focus, if any */ - Uint64 x; /**< Precise scrolling amount on x axis. */ - Uint64 y; /**< Precise scrolling amount on y axis. */ Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ - Uint32 source_type; /**< One of SDL_MOUSEWHEEL_SOURCE_[...] */ - Uint8 contains_x; /**< Indicates event contains a useful value in scalar_x and a pan should be calculated */ - Uint8 contains_y; /**< Indicates event contains a useful value in scalar_y and a pan should be calculated */ - Uint8 interrupt; /**< If some fling event was dispatched, this is intended to terminate it */ - Uint8 fling; /**< Indicates the user has "flung" the wheel and kinetic scrolling (if enabled) should begin here */ + SDL_PanAxis axis; + SDL_PanType pantype; + SDL_PanContents contents; + + SDL_MouseWheelSource source; } SDL_PanEvent; /** diff --git a/include/SDL_mouse.h b/include/SDL_mouse.h index 53bf92c65..044ddad9a 100644 --- a/include/SDL_mouse.h +++ b/include/SDL_mouse.h @@ -92,6 +92,40 @@ typedef enum SDL_MOUSEWHEEL_SOURCE_OTHER_KINETIC, } SDL_MouseWheelSource; +typedef enum +{ + SDL_PAN_AXIS_VERTICAL, + SDL_PAN_AXIS_HORIZONTAL, +} SDL_PanAxis; + +typedef enum +{ + SDL_PANEVENTTYPE_PAN, + SDL_PANEVENTTYPE_FLING, + SDL_PANEVENTTYPE_INTERRUPT, + SDL_PANEVENTTYPE_SOURCE, +} SDL_PanType; + +typedef struct SDL_PanType_Pan +{ + double delta; +} SDL_PanType_Pan; + +typedef struct SDL_PanType_Interrupt +{ +} SDL_PanType_Interrupt; + +typedef struct SDL_PanType_Fling +{ +} SDL_PanType_Fling; + +typedef union SDL_PanContents +{ + SDL_PanType_Pan pan; + SDL_PanType_Interrupt interrupt; + SDL_PanType_Fling fling; +} SDL_PanContents; + /* Function prototypes */ /** diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index b341ab632..05fb7d182 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -661,17 +661,47 @@ SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, S return posted; } +static SDL_MouseWheelSource latest_source = SDL_MOUSEWHEEL_SOURCE_LAST; + +static void +SDL_SetPanSource(SDL_MouseWheelSource source) { + latest_source = source; +} + +static SDL_MouseWheelSource +SDL_GetPanLastSource() { + return latest_source; +} + +int +SDL_SendPanDelta( + SDL_Window * window, + SDL_MouseID mouseID, + double delta, + SDL_PanAxis axis +) { + SDL_Mouse *mouse = SDL_GetMouse(); + + if( SDL_GetEventState(SDL_PANEVENT) == SDL_ENABLE ) { + SDL_Event event; + event.type = SDL_PANEVENT; + event.pan.windowID = mouse->focus ? mouse->focus->id : 0; + event.pan.which = mouseID; + event.pan.pantype = SDL_PANEVENTTYPE_PAN; + event.pan.contents.pan.delta = delta; + event.pan.source = SDL_GetPanLastSource(); + event.pan.axis = axis; + return SDL_PushEvent(&event); + } else { + return 0; + } +} + int -SDL_SendPanEvent( +SDL_SendPanFling( SDL_Window * window, SDL_MouseID mouseID, - Sint64 precise_x, - Sint64 precise_y, - Uint8 contains_x, - Uint8 contains_y, - Uint8 is_fling, - Uint8 is_interrupt, - SDL_MouseWheelSource source_type + SDL_PanAxis axis ) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -680,19 +710,52 @@ SDL_SendPanEvent( event.type = SDL_PANEVENT; event.pan.windowID = mouse->focus ? mouse->focus->id : 0; event.pan.which = mouseID; - event.pan.contains_x = contains_x; - event.pan.contains_y = contains_y; - event.pan.x = precise_x; - event.pan.y = precise_y; - event.pan.fling = is_fling; - event.pan.interrupt = is_interrupt; - event.pan.source_type = source_type; - return SDL_PushEvent(&event) > 0; + event.pan.pantype = SDL_PANEVENTTYPE_FLING; + // no union contents written for this event type + event.pan.source = SDL_GetPanLastSource(); + event.pan.axis = axis; + return SDL_PushEvent(&event); } else { return 0; } } +int +SDL_SendPanInterrupt( + SDL_Window * window, + SDL_MouseID mouseID, + SDL_PanAxis axis +) { + SDL_Mouse *mouse = SDL_GetMouse(); + + if( SDL_GetEventState(SDL_PANEVENT) == SDL_ENABLE ) { + SDL_Event event; + event.type = SDL_PANEVENT; + event.pan.windowID = mouse->focus ? mouse->focus->id : 0; + event.pan.which = mouseID; + event.pan.pantype = SDL_PANEVENTTYPE_INTERRUPT; + // no union contents written for this event type + event.pan.source = SDL_GetPanLastSource(); + event.pan.axis = axis; + return SDL_PushEvent(&event); + } else { + return 0; + } +} + +int +SDL_SendPanSource( + SDL_Window * window, + SDL_MouseID mouseID, + SDL_MouseWheelSource source +) { + // may become a full event at some point, + // implemented very basically here. Expect semantics + // to be the same as other event dispatch functions + SDL_SetPanSource(source); + return 1; +} + void SDL_MouseQuit(void) { diff --git a/src/events/SDL_mouse_c.h b/src/events/SDL_mouse_c.h index b73746c6c..e0182a226 100644 --- a/src/events/SDL_mouse_c.h +++ b/src/events/SDL_mouse_c.h @@ -135,7 +135,10 @@ extern int SDL_SendMouseButtonClicks(SDL_Window * window, SDL_MouseID mouseID, U extern int SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction); /* Send a pan/scroll event */ -extern int SDL_SendPanEvent( SDL_Window * window, SDL_MouseID mouseID, Sint64 precise_x, Sint64 precise_y, Uint8 contains_x, Uint8 contains_y, Uint8 is_fling, Uint8 is_interrupt, SDL_MouseWheelSource source_type); +extern int SDL_SendPanSource( SDL_Window * window, SDL_MouseID mouseID, SDL_MouseWheelSource source); +extern int SDL_SendPanDelta( SDL_Window * window, SDL_MouseID mouseID, double precise_delta, SDL_PanAxis axis); +extern int SDL_SendPanFling( SDL_Window * window, SDL_MouseID mouseID, SDL_PanAxis axis); +extern int SDL_SendPanInterrupt( SDL_Window * window, SDL_MouseID mouseID, SDL_PanAxis axis); /* Shutdown the mouse subsystem */ extern void SDL_MouseQuit(void); diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index 073491980..04aa0a344 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -389,11 +389,11 @@ pointer_handle_axis(void *data, struct wl_pointer *pointer, // dispatch new pan event switch(axis) { - case 0: y = value; break; - case 1: x = value; break; + case 0: axis = SDL_PAN_AXIS_VERTICAL; break; + case 1: axis = SDL_PAN_AXIS_HORIZONTAL; break; } - SDL_SendPanEvent(window->sdlwindow, 0, x, y, axis, !axis, 0, 0, SDL_MOUSEWHEEL_SOURCE_LAST); + SDL_SendPanDelta(window->sdlwindow, 0, wl_fixed_to_double(value), axis); } static void @@ -409,7 +409,7 @@ pointer_handle_axis_source(void *data, struct wl_pointer *pointer, struct SDL_WaylandInput *input = data; SDL_WindowData *window = input->pointer_focus; - int source; + SDL_MouseWheelSource source; switch(axis_source) { case 0: source = SDL_MOUSEWHEEL_SOURCE_WHEEL; break; @@ -419,7 +419,7 @@ pointer_handle_axis_source(void *data, struct wl_pointer *pointer, default: source = SDL_MOUSEWHEEL_SOURCE_UNDEFINED; break; } - SDL_SendPanEvent(window->sdlwindow, 0, 0, 0, 0, 0, 0, 0, source); + SDL_SendPanSource(window->sdlwindow, 0, source); } static void @@ -429,7 +429,13 @@ pointer_handle_axis_stop(void *data, struct wl_pointer *pointer, struct SDL_WaylandInput *input = data; SDL_WindowData *window = input->pointer_focus; - SDL_SendPanEvent(window->sdlwindow, 0, 0, 0, 0, 0, 1, 0, SDL_MOUSEWHEEL_SOURCE_LAST); + uint32_t mapped_axis; + switch(axis) { + case 0: mapped_axis = SDL_PAN_AXIS_VERTICAL; break; + case 1: mapped_axis = SDL_PAN_AXIS_HORIZONTAL; break; + } + + SDL_SendPanFling(window->sdlwindow, 0, mapped_axis); } static void @@ -441,12 +447,14 @@ pointer_handle_axis_discrete(void *data, struct wl_pointer *pointer, Uint64 x = 0; Uint64 y = 0; + uint32_t mapped_axis; switch(axis) { - case 0: y = discrete; - case 1: x = discrete; + case 0: mapped_axis = SDL_PAN_AXIS_VERTICAL; break; + case 1: mapped_axis = SDL_PAN_AXIS_HORIZONTAL; break; } - SDL_SendPanEvent(window->sdlwindow, 0, x, y, axis, !axis, 0, 0, SDL_MOUSEWHEEL_SOURCE_WHEEL); + // Is this actually something that should be picked up for mousewheels or do they already go through + // the normal axis pan event? TODO: figure this out } static const struct wl_pointer_listener pointer_listener = {