Simple Directmedia Layer
fork

Configure Feed

Select the types of activity you want to include in your feed.

Removed raw mouse events

It's too close the 3.2.0 release for an API change like this.

If/when we re-add these, some things for consideration:
* What use cases does this enable that aren't currently possible?
* What cross-platform API guarantees do we make about the availability of these events? e.g. do we try to simulate them where raw input isn't actually available?
* How is this different from the existing relative mode, and how do we clearly explain when you want these events vs wanting relative mode?

Notes from @expikr:
First observation: the reason I originally passed denominators instead of multipliers was because some rational values cannot be exactly represented by floats (e.g 1/120) so instead let the end-developer decide how to do the dividing themselves. It was the reason why it was using split values with an integer numerator to begin with, instead of having both as floats or even just normalize it in advance.

On the other hand, passing them as multipliers might have hypothetical uses for dynamically passing end-user controlled scaling in a transparent manner without coupling? (Though in that case why not just do that as additional fields appended to `motion` structs in an API-compatible layout?)

So it’s somewhat of a philosophical judgement of what this API of optional availability do we intend for it to present itself as:
- should it be a bit-perfect escape hatch with the absolute minimally-denominal abstraction over platform details just enough to be able to serve the full information (á la HIDPIAPI),
- or a renewed ergonomic API for splitting relative motion from cursor motion (in light of The Great Warping Purge) so that it is unburdened by legacy RelativeMode state machines, in which case it would be more appropriate to just call it `RELATIVE` instead of `RAW` and should be added alongside another new event purely for cursor events?

This alternate API stream was conceived in the context of preserving compatibility of the existing RelativeMode state machine by adding an escape hatch. So given the same context, my taste leans towards the former designation.

However, as The Great Warping Purge has made it potentially viable to do so, if I were allowed to break ABI by nuking the RelativeMode state machine entirely, I would prefer the latter designation unified as one of three separate components split from the old state machine, each independently controlled by platform-dependent availability without any state switching of a leaky melting pot:
- cursor visibility controls (if platform has cursor)
- cursor motion events (if platform has cursor)
- relative motion events (if the platform reports hardware motion)

+9 -290
-56
include/SDL3/SDL_events.h
··· 182 182 SDL_EVENT_MOUSE_WHEEL, /**< Mouse wheel motion */ 183 183 SDL_EVENT_MOUSE_ADDED, /**< A new mouse has been inserted into the system */ 184 184 SDL_EVENT_MOUSE_REMOVED, /**< A mouse has been removed */ 185 - SDL_EVENT_RAW_MOUSE_MOTION, /**< Mouse moved (raw motion deltas) */ 186 - SDL_EVENT_RAW_MOUSE_BUTTON_DOWN, /**< Mouse button pressed (raw button press) */ 187 - SDL_EVENT_RAW_MOUSE_BUTTON_UP, /**< Mouse button released (raw button release) */ 188 - SDL_EVENT_RAW_MOUSE_WHEEL, /**< Mouse wheel motion (raw wheel deltas) */ 189 185 190 186 /* Joystick events */ 191 187 SDL_EVENT_JOYSTICK_AXIS_MOTION = 0x600, /**< Joystick axis motion */ ··· 459 455 } SDL_MouseMotionEvent; 460 456 461 457 /** 462 - * Raw mouse motion event structure (event.raw_motion.*) 463 - * 464 - * \since This struct is available since SDL 3.1.8. 465 - */ 466 - typedef struct SDL_RawMouseMotionEvent 467 - { 468 - SDL_EventType type; /**< SDL_EVENT_RAW_MOUSE_MOTION */ 469 - Uint32 reserved; 470 - Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ 471 - SDL_MouseID which; /**< The mouse instance id */ 472 - Sint32 dx; /**< X axis delta */ 473 - Sint32 dy; /**< Y axis delta */ 474 - float scale_x; /**< X value scale to approximate desktop acceleration */ 475 - float scale_y; /**< Y value scale to approximate desktop acceleration */ 476 - } SDL_RawMouseMotionEvent; 477 - 478 - /** 479 458 * Mouse button event structure (event.button.*) 480 459 * 481 460 * \since This struct is available since SDL 3.1.3. ··· 496 475 } SDL_MouseButtonEvent; 497 476 498 477 /** 499 - * Raw mouse button event structure (event.raw_button.*) 500 - * 501 - * \since This struct is available since SDL 3.1.8. 502 - */ 503 - typedef struct SDL_RawMouseButtonEvent 504 - { 505 - SDL_EventType type; /**< SDL_EVENT_RAW_MOUSE_BUTTON_DOWN or SDL_EVENT_RAW_MOUSE_BUTTON_UP */ 506 - Uint32 reserved; 507 - Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ 508 - SDL_MouseID which; /**< The mouse instance id */ 509 - Uint8 button; /**< The mouse button index */ 510 - bool down; /**< true if the button is pressed */ 511 - } SDL_RawMouseButtonEvent; 512 - 513 - /** 514 478 * Mouse wheel event structure (event.wheel.*) 515 479 * 516 480 * \since This struct is available since SDL 3.1.3. ··· 528 492 float mouse_x; /**< X coordinate, relative to window */ 529 493 float mouse_y; /**< Y coordinate, relative to window */ 530 494 } SDL_MouseWheelEvent; 531 - 532 - /** 533 - * Raw mouse wheel event structure (event.raw_wheel.*) 534 - * 535 - * \since This struct is available since SDL 3.1.3. 536 - */ 537 - typedef struct SDL_RawMouseWheelEvent 538 - { 539 - SDL_EventType type; /**< SDL_EVENT_RAW_MOUSE_WHEEL */ 540 - Uint32 reserved; 541 - Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ 542 - SDL_MouseID which; /**< The mouse instance id */ 543 - Sint32 dx; /**< X axis delta, positive to the right and negative to the left */ 544 - Sint32 dy; /**< Y axis delta, positive away from the user and negative toward the user */ 545 - float scale_x; /**< X value scale to convert to logical scroll units */ 546 - float scale_y; /**< Y value scale to convert to logical scroll units */ 547 - } SDL_RawMouseWheelEvent; 548 495 549 496 /** 550 497 * Joystick axis motion event structure (event.jaxis.*) ··· 1048 995 SDL_TextInputEvent text; /**< Text input event data */ 1049 996 SDL_MouseDeviceEvent mdevice; /**< Mouse device change event data */ 1050 997 SDL_MouseMotionEvent motion; /**< Mouse motion event data */ 1051 - SDL_RawMouseMotionEvent raw_motion; /**< Raw mouse motion event data */ 1052 998 SDL_MouseButtonEvent button; /**< Mouse button event data */ 1053 - SDL_RawMouseButtonEvent raw_button; /**< Raw mouse button event data */ 1054 999 SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */ 1055 - SDL_RawMouseWheelEvent raw_wheel; /**< Raw mouse wheel event data */ 1056 1000 SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */ 1057 1001 SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */ 1058 1002 SDL_JoyBallEvent jball; /**< Joystick ball event data */
+3 -8
src/core/linux/SDL_evdev.c
··· 348 348 if (event->code >= BTN_MOUSE && event->code < BTN_MOUSE + SDL_arraysize(EVDEV_MouseButtons)) { 349 349 Uint64 timestamp = SDL_EVDEV_GetEventTimestamp(event); 350 350 mouse_button = event->code - BTN_MOUSE; 351 - SDL_SendRawMouseButton(timestamp, (SDL_MouseID)item->fd, EVDEV_MouseButtons[mouse_button], (event->value != 0)); 352 351 SDL_SendMouseButton(timestamp, mouse->focus, (SDL_MouseID)item->fd, EVDEV_MouseButtons[mouse_button], (event->value != 0)); 353 352 break; 354 353 } ··· 491 490 if (item->relative_mouse) { 492 491 if (item->mouse_x != 0 || item->mouse_y != 0) { 493 492 Uint64 timestamp = SDL_EVDEV_GetEventTimestamp(event); 494 - SDL_SendRawMouseMotion(timestamp, (SDL_MouseID)item->fd, item->mouse_x, item->mouse_y, 1.0f, 1.0f); 495 493 SDL_SendMouseMotion(timestamp, mouse->focus, (SDL_MouseID)item->fd, item->relative_mouse, (float)item->mouse_x, (float)item->mouse_y); 496 494 item->mouse_x = item->mouse_y = 0; 497 495 } ··· 516 514 517 515 if (item->mouse_wheel != 0 || item->mouse_hwheel != 0) { 518 516 Uint64 timestamp = SDL_EVDEV_GetEventTimestamp(event); 519 - const float scale = (item->high_res_hwheel ? 1.0f / 120.0f : 1.0f); 520 - SDL_SendRawMouseWheel(timestamp, 521 - (SDL_MouseID)item->fd, 522 - item->mouse_hwheel, item->mouse_wheel, scale, scale); 517 + const float denom = (item->high_res_hwheel ? 120.0f : 1.0f); 523 518 SDL_SendMouseWheel(timestamp, 524 519 mouse->focus, (SDL_MouseID)item->fd, 525 - item->mouse_hwheel * scale, 526 - item->mouse_wheel * scale, 520 + item->mouse_hwheel / denom, 521 + item->mouse_wheel / denom, 527 522 SDL_MOUSEWHEEL_NORMAL); 528 523 item->mouse_wheel = item->mouse_hwheel = 0; 529 524 }
-9
src/core/openbsd/SDL_wscons_mouse.c
··· 87 87 { 88 88 Uint8 button = SDL_BUTTON_LEFT + events[i].value; 89 89 bool down = (type == WSCONS_EVENT_MOUSE_DOWN); 90 - SDL_SendRawMouseButton(timestamp, input->mouseID, button, down); 91 90 SDL_SendMouseButton(timestamp, mouse->focus, input->mouseID, button, down); 92 91 break; 93 92 } 94 93 case WSCONS_EVENT_MOUSE_DELTA_X: 95 94 { 96 - const float scale = 1.0f; 97 - SDL_SendRawMouseMotion(timestamp, input->mouseID, events[i].value, 0, scale, scale); 98 95 SDL_SendMouseMotion(timestamp, mouse->focus, input->mouseID, true, (float)events[i].value, 0.0f); 99 96 break; 100 97 } 101 98 case WSCONS_EVENT_MOUSE_DELTA_Y: 102 99 { 103 - const float scale = 1.0f; 104 - SDL_SendRawMouseMotion(timestamp, input->mouseID, 0, -events[i].value, scale, scale); 105 100 SDL_SendMouseMotion(timestamp, mouse->focus, input->mouseID, true, 0.0f, -(float)events[i].value); 106 101 break; 107 102 } 108 103 case WSCONS_EVENT_MOUSE_DELTA_W: 109 104 { 110 - const float scale = 1.0f; 111 - SDL_SendRawMouseWheel(timestamp, input->mouseID, events[i].value, 0, scale, scale); 112 105 SDL_SendMouseWheel(timestamp, mouse->focus, input->mouseID, events[i].value, 0, SDL_MOUSEWHEEL_NORMAL); 113 106 break; 114 107 } 115 108 case WSCONS_EVENT_MOUSE_DELTA_Z: 116 109 { 117 - const float scale = 1.0f; 118 - SDL_SendRawMouseWheel(timestamp, input->mouseID, 0, -events[i].value, scale, scale); 119 110 SDL_SendMouseWheel(timestamp, mouse->focus, input->mouseID, 0, -events[i].value, SDL_MOUSEWHEEL_NORMAL); 120 111 break; 121 112 }
-4
src/events/SDL_categories.c
··· 78 78 return SDL_EVENTCATEGORY_EDIT_CANDIDATES; 79 79 80 80 case SDL_EVENT_MOUSE_MOTION: 81 - case SDL_EVENT_RAW_MOUSE_MOTION: 82 81 return SDL_EVENTCATEGORY_MOTION; 83 82 84 83 case SDL_EVENT_MOUSE_BUTTON_DOWN: 85 84 case SDL_EVENT_MOUSE_BUTTON_UP: 86 - case SDL_EVENT_RAW_MOUSE_BUTTON_DOWN: 87 - case SDL_EVENT_RAW_MOUSE_BUTTON_UP: 88 85 return SDL_EVENTCATEGORY_BUTTON; 89 86 90 87 case SDL_EVENT_MOUSE_WHEEL: 91 - case SDL_EVENT_RAW_MOUSE_WHEEL: 92 88 return SDL_EVENTCATEGORY_WHEEL; 93 89 94 90 case SDL_EVENT_MOUSE_ADDED:
-28
src/events/SDL_events.c
··· 390 390 // sensor/mouse/pen/finger motion are spammy, ignore these if they aren't demanded. 391 391 if ((SDL_EventLoggingVerbosity < 2) && 392 392 ((event->type == SDL_EVENT_MOUSE_MOTION) || 393 - (event->type == SDL_EVENT_RAW_MOUSE_MOTION) || 394 393 (event->type == SDL_EVENT_FINGER_MOTION) || 395 394 (event->type == SDL_EVENT_PEN_AXIS) || 396 395 (event->type == SDL_EVENT_PEN_MOTION) || ··· 568 567 event->motion.xrel, event->motion.yrel); 569 568 break; 570 569 571 - SDL_EVENT_CASE(SDL_EVENT_RAW_MOUSE_MOTION) 572 - (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%u dx=%d dy=%d)", 573 - (uint)event->raw_motion.timestamp, 574 - (uint)event->raw_motion.which, 575 - (int)event->raw_motion.dx, (int)event->raw_motion.dy); 576 - break; 577 - 578 570 #define PRINT_MBUTTON_EVENT(event) \ 579 571 (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u which=%u button=%u state=%s clicks=%u x=%g y=%g)", \ 580 572 (uint)event->button.timestamp, (uint)event->button.windowID, \ ··· 589 581 break; 590 582 #undef PRINT_MBUTTON_EVENT 591 583 592 - #define PRINT_RAW_MBUTTON_EVENT(event) \ 593 - (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%u button=%u state=%s)", \ 594 - (uint)event->raw_button.timestamp, \ 595 - (uint)event->raw_button.which, (uint)event->raw_button.button, \ 596 - event->raw_button.down ? "pressed" : "released"); 597 - SDL_EVENT_CASE(SDL_EVENT_RAW_MOUSE_BUTTON_DOWN) 598 - PRINT_RAW_MBUTTON_EVENT(event); 599 - break; 600 - SDL_EVENT_CASE(SDL_EVENT_RAW_MOUSE_BUTTON_UP) 601 - PRINT_RAW_MBUTTON_EVENT(event); 602 - break; 603 - #undef PRINT_RAW_MBUTTON_EVENT 604 - 605 584 SDL_EVENT_CASE(SDL_EVENT_MOUSE_WHEEL) 606 585 (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u which=%u x=%g y=%g direction=%s)", 607 586 (uint)event->wheel.timestamp, (uint)event->wheel.windowID, 608 587 (uint)event->wheel.which, event->wheel.x, event->wheel.y, 609 588 event->wheel.direction == SDL_MOUSEWHEEL_NORMAL ? "normal" : "flipped"); 610 - break; 611 - 612 - SDL_EVENT_CASE(SDL_EVENT_RAW_MOUSE_WHEEL) 613 - (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%u dx=%d dy=%d)", 614 - (uint)event->raw_wheel.timestamp, 615 - (uint)event->raw_wheel.which, 616 - (int)event->raw_wheel.dx, (int)event->raw_wheel.dy); 617 589 break; 618 590 619 591 SDL_EVENT_CASE(SDL_EVENT_JOYSTICK_AXIS_MOTION)
-45
src/events/SDL_mouse.c
··· 970 970 } 971 971 } 972 972 973 - void SDL_SendRawMouseMotion(Uint64 timestamp, SDL_MouseID mouseID, int dx, int dy, float scale_x, float scale_y) 974 - { 975 - if (SDL_EventEnabled(SDL_EVENT_RAW_MOUSE_MOTION)) { 976 - SDL_Event event; 977 - event.type = SDL_EVENT_RAW_MOUSE_MOTION; 978 - event.common.timestamp = timestamp; 979 - event.raw_motion.which = mouseID; 980 - event.raw_motion.dx = dx; 981 - event.raw_motion.dy = dy; 982 - event.raw_motion.scale_x = scale_x; 983 - event.raw_motion.scale_y = scale_y; 984 - SDL_PushEvent(&event); 985 - } 986 - } 987 - 988 - void SDL_SendRawMouseButton(Uint64 timestamp, SDL_MouseID mouseID, Uint8 button, bool down) 989 - { 990 - const SDL_EventType type = down ? SDL_EVENT_RAW_MOUSE_BUTTON_DOWN : SDL_EVENT_RAW_MOUSE_BUTTON_UP; 991 - 992 - if (SDL_EventEnabled(type)) { 993 - SDL_Event event; 994 - event.type = type; 995 - event.common.timestamp = timestamp; 996 - event.raw_button.which = mouseID; 997 - event.raw_button.button = button; 998 - event.raw_button.down = down; 999 - SDL_PushEvent(&event); 1000 - } 1001 - } 1002 - 1003 - void SDL_SendRawMouseWheel(Uint64 timestamp, SDL_MouseID mouseID, int dx, int dy, float scale_x, float scale_y) 1004 - { 1005 - if (SDL_EventEnabled(SDL_EVENT_RAW_MOUSE_WHEEL)) { 1006 - SDL_Event event; 1007 - event.type = SDL_EVENT_RAW_MOUSE_WHEEL; 1008 - event.common.timestamp = timestamp; 1009 - event.raw_wheel.which = mouseID; 1010 - event.raw_wheel.dx = dx; 1011 - event.raw_wheel.dy = dy; 1012 - event.raw_wheel.scale_x = scale_x; 1013 - event.raw_wheel.scale_y = scale_y; 1014 - SDL_PushEvent(&event); 1015 - } 1016 - } 1017 - 1018 973 void SDL_QuitMouse(void) 1019 974 { 1020 975 SDL_Cursor *cursor, *next;
-9
src/events/SDL_mouse_c.h
··· 178 178 // Send a mouse wheel event 179 179 extern void SDL_SendMouseWheel(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction); 180 180 181 - // Send raw mouse motion 182 - extern void SDL_SendRawMouseMotion(Uint64 timestamp, SDL_MouseID mouseID, int dx, int dy, float scale_x, float scale_y); 183 - 184 - // Send a raw mouse button event 185 - extern void SDL_SendRawMouseButton(Uint64 timestamp, SDL_MouseID mouseID, Uint8 button, bool down); 186 - 187 - // Send a raw mouse wheel event 188 - extern void SDL_SendRawMouseWheel(Uint64 timestamp, SDL_MouseID mouseID, int dx, int dy, float scale_x, float scale_y); 189 - 190 181 // Warp the mouse within the window, potentially overriding relative mode 191 182 extern void SDL_PerformWarpMouseInWindow(SDL_Window *window, float x, float y, bool ignore_relative_mode); 192 183
-2
src/render/SDL_render.c
··· 2881 2881 SDL_RenderCoordinatesFromWindow(renderer, event->motion.x, event->motion.y, &event->motion.x, &event->motion.y); 2882 2882 SDL_RenderVectorFromWindow(renderer, event->motion.xrel, event->motion.yrel, &event->motion.xrel, &event->motion.yrel); 2883 2883 } 2884 - } else if (event->type == SDL_EVENT_RAW_MOUSE_MOTION) { 2885 - SDL_RenderVectorFromWindow(renderer, event->raw_motion.scale_x, event->raw_motion.scale_y, &event->raw_motion.scale_x, &event->raw_motion.scale_y); 2886 2884 } else if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN || 2887 2885 event->type == SDL_EVENT_MOUSE_BUTTON_UP) { 2888 2886 SDL_Window *window = SDL_GetWindowFromID(event->button.windowID);
-18
src/test/SDL_test_common.c
··· 1784 1784 event->motion.xrel, event->motion.yrel, 1785 1785 event->motion.windowID); 1786 1786 break; 1787 - case SDL_EVENT_RAW_MOUSE_MOTION: 1788 - SDL_Log("SDL EVENT: Raw Mouse: mouse %" SDL_PRIu32 " moved %" SDL_PRIs32 ",%" SDL_PRIs32, 1789 - event->raw_motion.which, 1790 - event->raw_motion.dx, event->raw_motion.dy); 1791 - break; 1792 1787 case SDL_EVENT_MOUSE_BUTTON_DOWN: 1793 1788 SDL_Log("SDL EVENT: Mouse: button %d pressed at %g,%g with click count %d in window %" SDL_PRIu32, 1794 1789 event->button.button, event->button.x, event->button.y, event->button.clicks, ··· 1799 1794 event->button.button, event->button.x, event->button.y, event->button.clicks, 1800 1795 event->button.windowID); 1801 1796 break; 1802 - case SDL_EVENT_RAW_MOUSE_BUTTON_DOWN: 1803 - SDL_Log("SDL EVENT: Raw Mouse: mouse %" SDL_PRIu32 " button %d pressed", 1804 - event->raw_button.which, event->raw_button.button); 1805 - break; 1806 - case SDL_EVENT_RAW_MOUSE_BUTTON_UP: 1807 - SDL_Log("SDL EVENT: Raw Mouse: mouse %" SDL_PRIu32 " button %d released", 1808 - event->raw_button.which, event->raw_button.button); 1809 - break; 1810 1797 case SDL_EVENT_MOUSE_WHEEL: 1811 1798 SDL_Log("SDL EVENT: Mouse: wheel scrolled %g in x and %g in y (reversed: %d) in window %" SDL_PRIu32, 1812 1799 event->wheel.x, event->wheel.y, event->wheel.direction, event->wheel.windowID); 1813 - break; 1814 - case SDL_EVENT_RAW_MOUSE_WHEEL: 1815 - SDL_Log("SDL EVENT: Raw Mouse: mouse %" SDL_PRIu32 " wheel scrolled %" SDL_PRIs32 " in x and %" SDL_PRIs32 " in y", 1816 - event->raw_wheel.which, event->raw_wheel.dx, event->raw_wheel.dy); 1817 1800 break; 1818 1801 case SDL_EVENT_JOYSTICK_ADDED: 1819 1802 SDL_Log("SDL EVENT: Joystick %" SDL_PRIu32 " attached", ··· 2238 2221 2239 2222 if (state->verbose & VERBOSE_EVENT) { 2240 2223 if ((event->type != SDL_EVENT_MOUSE_MOTION && 2241 - event->type != SDL_EVENT_RAW_MOUSE_MOTION && 2242 2224 event->type != SDL_EVENT_FINGER_MOTION && 2243 2225 event->type != SDL_EVENT_PEN_MOTION && 2244 2226 event->type != SDL_EVENT_PEN_AXIS &&
-7
src/video/uikit/SDL_uikitevents.m
··· 320 320 static void OnGCMouseButtonChanged(SDL_MouseID mouseID, Uint8 button, BOOL pressed) 321 321 { 322 322 Uint64 timestamp = SDL_GetTicksNS(); 323 - SDL_SendRawMouseButton(timestamp, mouseID, button, pressed); 324 323 SDL_SendMouseButton(timestamp, SDL_GetMouseFocus(), mouseID, button, pressed); 325 324 } 326 325 ··· 351 350 mouse.mouseInput.mouseMovedHandler = ^(GCMouseInput *mouseInput, float deltaX, float deltaY) { 352 351 Uint64 timestamp = SDL_GetTicksNS(); 353 352 354 - // FIXME: Do we get non-integer deltas here? 355 - SDL_SendRawMouseMotion(timestamp, mouseID, (int)deltaX, (int)-deltaY, 1.0f, 1.0f); 356 - 357 353 if (SDL_GCMouseRelativeMode()) { 358 354 SDL_SendMouseMotion(timestamp, SDL_GetMouseFocus(), mouseID, true, deltaX, -deltaY); 359 355 } ··· 369 365 */ 370 366 float vertical = -xValue; 371 367 float horizontal = yValue; 372 - 373 - // FIXME: Do we get non-integer deltas here? 374 - SDL_SendRawMouseWheel(timestamp, mouseID, (int)horizontal, (int)vertical, 1.0f, 1.0f); 375 368 376 369 if (mouse_scroll_direction == SDL_MOUSEWHEEL_FLIPPED) { 377 370 // Since these are raw values, we need to flip them ourselves
-24
src/video/wayland/SDL_waylandevents.c
··· 719 719 default: 720 720 return; 721 721 } 722 - SDL_SendRawMouseButton(timestamp, input->pointer_id, sdl_button, down); 723 722 724 723 if (window) { 725 724 SDL_VideoData *viddata = window->waylandData; ··· 785 784 const Uint64 timestamp = Wayland_GetPointerTimestamp(input, time); 786 785 const enum wl_pointer_axis a = axis; 787 786 788 - // wl_fixed_t is a 24.8 signed fixed-point number which needs to be converted by dividing by 256 789 - const float scale = 1.0f / WAYLAND_WHEEL_AXIS_UNIT; 790 - const int amount = (value * WAYLAND_WHEEL_AXIS_UNIT) >> 8; 791 - if (a == WL_POINTER_AXIS_VERTICAL_SCROLL) { 792 - SDL_SendRawMouseWheel(timestamp, input->pointer_id, 0, amount, scale, scale); 793 - } else { 794 - SDL_SendRawMouseWheel(timestamp, input->pointer_id, amount, 0, scale, scale); 795 - } 796 - 797 787 if (input->pointer_focus) { 798 788 float x, y; 799 789 ··· 821 811 uint32_t axis, wl_fixed_t value) 822 812 { 823 813 const enum wl_pointer_axis a = axis; 824 - 825 - // wl_fixed_t is a 24.8 signed fixed-point number which needs to be converted by dividing by 256 826 - const float scale = (type == AXIS_EVENT_VALUE120) ? (1.0f / 120.0f) : (1.0f / WAYLAND_WHEEL_AXIS_UNIT); 827 - const int amount = (type == AXIS_EVENT_VALUE120) ? (value >> 8) : ((value * WAYLAND_WHEEL_AXIS_UNIT) >> 8); 828 - if (a == WL_POINTER_AXIS_VERTICAL_SCROLL) { 829 - SDL_SendRawMouseWheel(0, input->pointer_id, 0, amount, scale, scale); 830 - } else { 831 - SDL_SendRawMouseWheel(0, input->pointer_id, amount, 0, scale, scale); 832 - } 833 814 834 815 if (input->pointer_focus) { 835 816 switch (a) { ··· 1032 1013 1033 1014 // Relative pointer event times are in microsecond granularity. 1034 1015 const Uint64 timestamp = Wayland_GetEventTimestamp(SDL_US_TO_NS(((Uint64)time_hi << 32) | (Uint64)time_lo)); 1035 - 1036 - // wl_fixed_t is a 24.8 signed fixed-point number which needs to be converted by dividing by 256 1037 - const float scale_x = dx_unaccel_w ? (dx_w / (float)dx_unaccel_w) : 1.0f; 1038 - const float scale_y = dy_unaccel_w ? (dy_w / (float)dy_unaccel_w) : 1.0f; 1039 - SDL_SendRawMouseMotion(timestamp, input->pointer_id, dx_unaccel_w >> 8, dy_unaccel_w >> 8, scale_x, scale_y); 1040 1016 1041 1017 if (input->pointer_focus && d->relative_mouse_mode) { 1042 1018 double dx;
-35
src/video/windows/SDL_windowsevents.c
··· 545 545 bool isAbsolute = ((rawmouse->usFlags & MOUSE_MOVE_ABSOLUTE) != 0); 546 546 SDL_MouseID mouseID = (SDL_MouseID)(uintptr_t)hDevice; 547 547 548 - if (haveMotion && !isAbsolute) { 549 - // FIXME: Apply desktop mouse scale? 550 - const float scale = 1.0f; 551 - SDL_SendRawMouseMotion(timestamp, mouseID, dx, dy, scale, scale); 552 - } 553 - 554 - if (haveButton) { 555 - for (int i = 0; i < SDL_arraysize(raw_buttons); ++i) { 556 - if (rawmouse->usButtonFlags & raw_buttons[i].usButtonFlags) { 557 - Uint8 button = raw_buttons[i].button; 558 - bool down = raw_buttons[i].down; 559 - 560 - if (button == SDL_BUTTON_LEFT) { 561 - if (WIN_SwapButtons(hDevice)) { 562 - button = SDL_BUTTON_RIGHT; 563 - } 564 - } else if (button == SDL_BUTTON_RIGHT) { 565 - if (WIN_SwapButtons(hDevice)) { 566 - button = SDL_BUTTON_LEFT; 567 - } 568 - } 569 - 570 - SDL_SendRawMouseButton(timestamp, mouseID, button, down); 571 - } 572 - } 573 - 574 - const float scale = 1.0f / 120.0f; 575 - SHORT amount = (SHORT)rawmouse->usButtonData; 576 - if (rawmouse->usButtonFlags & RI_MOUSE_WHEEL) { 577 - SDL_SendRawMouseWheel(timestamp, mouseID, 0, amount, scale, scale); 578 - } else if (rawmouse->usButtonFlags & RI_MOUSE_HWHEEL) { 579 - SDL_SendRawMouseWheel(timestamp, mouseID, amount, 0, scale, scale); 580 - } 581 - } 582 - 583 548 // Check whether relative mode should also receive events from the rawinput stream 584 549 if (!data->raw_mouse_enabled) { 585 550 return;
-9
src/video/windows/SDL_windowsgameinput.c
··· 291 291 for (int i = 0; i < MAX_GAMEINPUT_BUTTONS; ++i) { 292 292 const GameInputMouseButtons mask = (1 << i); 293 293 bool down = ((state.buttons & mask) != 0); 294 - SDL_SendRawMouseButton(timestamp, mouseID, GAMEINPUT_button_map[i], down); 295 294 SDL_SendMouseButton(timestamp, window, mouseID, GAMEINPUT_button_map[i], down); 296 295 } 297 296 } ··· 314 313 delta.wheelY = (state.wheelY - last.wheelY); 315 314 316 315 if (delta.positionX || delta.positionY) { 317 - // FIXME: Apply desktop mouse scale? 318 - const float scale = 1.0f; 319 - SDL_SendRawMouseMotion(timestamp, mouseID, delta.positionX, delta.positionY, scale, scale); 320 - 321 316 SDL_SendMouseMotion(timestamp, window, mouseID, true, (float)delta.positionX, (float)delta.positionY); 322 317 } 323 318 if (delta.buttons) { ··· 325 320 const GameInputMouseButtons mask = (1 << i); 326 321 if (delta.buttons & mask) { 327 322 bool down = ((state.buttons & mask) != 0); 328 - SDL_SendRawMouseButton(timestamp, mouseID, GAMEINPUT_button_map[i], down); 329 323 SDL_SendMouseButton(timestamp, window, mouseID, GAMEINPUT_button_map[i], down); 330 324 } 331 325 } 332 326 } 333 327 if (delta.wheelX || delta.wheelY) { 334 - const float scale = 1.0f / WHEEL_DELTA; 335 - SDL_SendRawMouseWheel(timestamp, device->instance_id, delta.wheelX, delta.wheelY, scale, scale); 336 - 337 328 float fAmountX = (float)delta.wheelX / WHEEL_DELTA; 338 329 float fAmountY = (float)delta.wheelY / WHEEL_DELTA; 339 330 SDL_SendMouseWheel(timestamp, SDL_GetMouseFocus(), device->instance_id, fAmountX, fAmountY, SDL_MOUSEWHEEL_NORMAL);
+2 -3
src/video/windows/SDL_windowsrawinput.c
··· 193 193 { 194 194 SDL_VideoData *data = _this->internal; 195 195 Uint32 flags = 0; 196 - const bool ENABLE_RAW_INPUT_EVENTS = true; 197 - if (data->raw_mouse_enabled || ENABLE_RAW_INPUT_EVENTS) { 196 + if (data->raw_mouse_enabled) { 198 197 flags |= ENABLE_RAW_MOUSE_INPUT; 199 198 } 200 - if (data->raw_keyboard_enabled || ENABLE_RAW_INPUT_EVENTS) { 199 + if (data->raw_keyboard_enabled) { 201 200 flags |= ENABLE_RAW_KEYBOARD_INPUT; 202 201 } 203 202 if (flags != data->raw_input_enabled) {
-10
src/video/x11/SDL_x11events.c
··· 920 920 } 921 921 922 922 if (X11_IsWheelEvent(display, button, &xticks, &yticks)) { 923 - if (mouseID != SDL_GLOBAL_MOUSE_ID) { 924 - const float scale = 1.0f; 925 - SDL_SendRawMouseWheel(timestamp, mouseID, -xticks, yticks, scale, scale); 926 - } 927 923 SDL_SendMouseWheel(timestamp, window, mouseID, (float)-xticks, (float)yticks, SDL_MOUSEWHEEL_NORMAL); 928 924 } else { 929 925 bool ignore_click = false; ··· 931 927 /* X button values 4-7 are used for scrolling, so X1 is 8, X2 is 9, ... 932 928 => subtract (8-SDL_BUTTON_X1) to get value SDL expects */ 933 929 button -= (8 - SDL_BUTTON_X1); 934 - } 935 - if (mouseID != SDL_GLOBAL_MOUSE_ID) { 936 - SDL_SendRawMouseButton(timestamp, mouseID, button, true); 937 930 } 938 931 if (button == Button1) { 939 932 if (X11_TriggerHitTestAction(_this, windowdata, x, y)) { ··· 971 964 if (button > 7) { 972 965 // see explanation at case ButtonPress 973 966 button -= (8 - SDL_BUTTON_X1); 974 - } 975 - if (mouseID != SDL_GLOBAL_MOUSE_ID) { 976 - SDL_SendRawMouseButton(timestamp, mouseID, button, false); 977 967 } 978 968 SDL_SendMouseButton(timestamp, window, mouseID, button, false); 979 969 }
-5
src/video/x11/SDL_x11xinput2.c
··· 342 342 } 343 343 } 344 344 345 - // FIXME: Are the processed_coords always integral values? 346 - // FIXME: Apply desktop mouse scale? 347 - const float scale = 1.0f; 348 - SDL_SendRawMouseMotion(timestamp, (SDL_MouseID)rawev->sourceid, (int)processed_coords[0], (int)processed_coords[1], scale, scale); 349 - 350 345 // Relative mouse motion is delivered to the window with keyboard focus 351 346 if (mouse->relative_mode && SDL_GetKeyboardFocus()) { 352 347 SDL_SendMouseMotion(timestamp, mouse->focus, (SDL_MouseID)rawev->sourceid, true, (float)processed_coords[0], (float)processed_coords[1]);
+4 -18
test/testrelative.c
··· 25 25 static SDL_FRect rect; 26 26 static SDL_Event event; 27 27 static bool warp; 28 - static bool raw; 29 28 30 29 static void DrawRects(SDL_Renderer *renderer) 31 30 { ··· 94 93 break; 95 94 case SDL_EVENT_MOUSE_MOTION: 96 95 { 97 - if (!raw) { 98 - rect.x += event.motion.xrel; 99 - rect.y += event.motion.yrel; 96 + rect.x += event.motion.xrel; 97 + rect.y += event.motion.yrel; 100 98 101 - if (warp) { 102 - CenterMouse(); 103 - } 99 + if (warp) { 100 + CenterMouse(); 104 101 } 105 102 } break; 106 - case SDL_EVENT_RAW_MOUSE_MOTION: 107 - { 108 - rect.x += event.raw_motion.dx * event.raw_motion.scale_x; 109 - rect.y += event.raw_motion.dy * event.raw_motion.scale_y; 110 - } break; 111 103 default: 112 104 break; 113 105 } ··· 167 159 if (SDL_strcasecmp(argv[i], "--warp") == 0) { 168 160 warp = true; 169 161 consumed = 1; 170 - } else if (SDL_strcasecmp(argv[i], "--raw") == 0) { 171 - raw = true; 172 - consumed = 1; 173 162 } 174 163 } 175 164 176 165 if (consumed < 0) { 177 166 static const char *options[] = { 178 167 "[--warp]", 179 - "[--raw]", 180 168 NULL 181 169 }; 182 170 SDLTest_CommonLogUsage(state, argv[0], options); ··· 211 199 SDL_SetWindowRelativeMouseMode(state->windows[i], true); 212 200 } 213 201 } 214 - 215 - SDL_SetEventEnabled(SDL_EVENT_RAW_MOUSE_MOTION, raw); 216 202 217 203 rect.x = DEFAULT_WINDOW_WIDTH / 2; 218 204 rect.y = DEFAULT_WINDOW_HEIGHT / 2;