src/events


Log

Author Commit Date CI Message
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Cameron Gutman 9ae56cb3 2021-12-06T21:18:23 events: Add logging for SDL_MOUSEWHEEL preciseX/Y fields
Sylvain e72beeb2 2021-11-22T16:40:29 Remove 'malloc' from comment
Sylvain 0445c13a 2021-11-22T16:49:17 Remove 'malloc' from comment
Cameron Gutman d7d67af4 2021-11-14T17:52:41 mouse: Fix Y value in motion events when confinement is active
Sam Lantinga dfb834d3 2021-11-10T13:41:44 Track button state for each mouse input source separately This way we'll get button down and up events for each mouseID individually. Fixes https://github.com/libsdl-org/SDL/issues/4518
Sam Lantinga fd79607e 2021-11-08T21:34:48 Added SDL_GetWindowMouseRect() Also guarantee that we won't get mouse movement outside the confining area, even if the OS implementation allows it (e.g. macOS)
Sam Lantinga a3e8fd49 2021-11-08T09:58:11 Cancel any accumulated mouse wheel motion in the opposite direction when the wheel direction changes Fixes https://github.com/libsdl-org/SDL/issues/2912
Sam Lantinga 5dbbc8e6 2021-11-08T09:44:31 Added mouse wheel deltas with floating point precision Fixes https://github.com/libsdl-org/SDL/issues/4888
Cameron Gutman f73376ae 2021-11-02T00:31:25 events: Add logging for SDL_CONTROLLERTOUCHPAD*, SDL_CONTROLLERSENSORUPDATE, and SDL_SENSORUPDATE events
Cameron Gutman a5598649 2021-10-30T19:30:34 x11/wayland: Fix signal handling while blocking in WaitEventTimeout() Add a new flag to avoid suppressing EINTR in SDL_IOReady(). Pass the flag in WaitEventTimeout() to ensure that a SIGINT will wake up SDL_WaitEvent() without another event coming in.
Cameron Gutman ac54d57a 2021-10-26T20:02:38 event: Check subsystem initialization before events or devices SDL_WasInit() is cheaper SDL_NumJoysticks()/SDL_NumSensors().
Cameron Gutman 1bc6dc3e 2021-10-26T20:02:04 event: Cap maximum wait time if sensor or joystick subsystems are active Joystick and sensor subsystems require periodic polling to detect new devices.
Cacodemon345 19dee1cd 2021-10-22T06:37:20 Add SDL_GetWindowICCProfile(). (#4314) * Add SDL_GetWindowICCProfile * Add new SDL display events * Implement ICC profile change event for macOS * Implement ICC profile notification for Windows * Fix SDL_GetWindowICCProfile() for X11 * Fix compile errors
Sam Lantinga d5700ed2 2021-10-15T00:01:39 Don't log SDL_POLLSENTINEL, it's purely for internal bookkeeping
Sam Lantinga dd5d8950 2021-10-14T23:53:25 Fixed whitespace
Brick 8bf32e12 2021-10-15T06:26:10 Improved SDL_PollEvent usage (#4794) * Avoid unnecessary SDL_PumpEvents calls in SDL_WaitEventTimeout * Add a sentinel event to avoid infinite poll loops * Move SDL_POLLSENTINEL to new internal event category * Tweak documentation to indicate SDL_PumpEvents isn't always called * Avoid shadowing event variable * Ignore poll sentinel if more (user) events have been added after Co-authored-by: Sam Lantinga <slouken@libsdl.org>
Sam Lantinga 88e9f776 2021-10-14T18:37:27 Fixed relative mouse mode using warping after https://github.com/libsdl-org/SDL/commit/82793ac279d19b5bde8fc2bd62877b05ba5a76e0
Sam Lantinga 82793ac2 2021-10-14T14:26:21 Fixed mouse warping while in relative mode We should get a mouse event with an absolute position and no relative motion and shouldn't change the OS cursor position at all
Sam Lantinga 1fa154fd 2021-10-13T09:33:54 Fix weak enforcement of timeouts in SDL_WaitEventTimeout_Device. This will loop pumping events and waiting for a system event to come in. However not all system events will turn into an SDL event. It's not unusual for a Windows message to be some internal thing that SDL doesn't convert into a message. In that case the loop will simple circle but not exit. As long as such messages are coming in the loop will continue to run regardless of the timeout. When messages finally stop it'll still wait for the full timeout so you can have arbitrarily long delays. Instead do an absolute elapsed time check since the start of the wait. If that is exceeded during any iteration the routine exits as the timeout has elapsed.
Sam Lantinga 1ec409c2 2021-10-06T09:09:09 Don't warp the mouse within a window while it's minimized
Ethan Lee 7ed415d2 2021-09-23T14:07:38 wayland: Reuse KeySymToUcs4 to replicate X11 keymap behavior
David Gow fbc36490 2021-08-14T22:29:05 Use the new SDL_clamp() macro where sensible There were a few places throughout the SDL code where values were clamped using SDL_min() and SDL_max(). Now that we have an SDL_clamp() macro, use this instead.
Sam Lantinga 69477151 2021-08-13T23:45:01 Get the window size for the window receiving the mouse motion This is the mouse focus except in the case where relative motion is enabled and the mouse is over a window floating on top of the application window (e.g. the taskbar)
Sam Lantinga 6a1e1ed9 2021-08-13T23:36:13 Relative mouse mode grab is based on the window with the input focus This fixes restoring the cursor clip rectangle after the mouse has moved off of the window. Also try to better synchronize cursor visibility with mouse position changes when changing relative mode. This doesn't work perfectly, but it seems to improve things on Windows.
Sam Lantinga b28ed028 2021-08-13T11:39:41 Don't warp the mouse for relative mode when the window doesn't have focus
Sam Lantinga cb1e20b0 2021-08-10T17:50:17 Added KMOD_SCROLL to track the scroll lock state Fixes https://github.com/libsdl-org/SDL/issues/4566
Dean Herbert 8fb95034 2021-04-02T12:52:21 Avoid warping the cursor to the center of the window when not in relative_warp_mode When relative mode is enabled and not using warp mode, the cursor is being clipped to the window. Therefore there is no reason to restore the cursor position to the center. Avoiding the warp to center simplifies mouse position event flow, as we are no longer potentially receiving mouse events for the automated movement of the cursor and can be (mostly) assured that an incoming event from the windowing system is that of external means.
Cameron Gutman 7948c16d 2021-06-12T17:56:52 Pump events each time through the loop in SDL_WaitEventTimeout_Device() Not only is it more efficient to batch process pending events, it is necessary for correctness with the Win32 backend. WIN_PumpEvents() runs periodic updates of the cursor clip region and disambiguation of left and right shift keys in addition to standard event processing.
Cameron Gutman 105de64c 2021-06-12T16:19:03 Only queue one wakeup event per wait Queuing more than one can lead to a spurious wakeup on the next wait.
Ozkan Sezer d28437de 2021-06-12T08:00:50 SDL_keyboard.c: Add bounds guards when assigning to the scancode array. Based on a patch by Jochen Schäfer <josch1710@live.de> : On a T420 pressing the ACPI button for volume control, big scancodes were emitted. This was causing an overflow, because missing guards.
Cameron Gutman e13b43ac 2021-06-05T12:44:08 Don't skip sending wakeups for the current thread We can be in a situation where we receive a win32 hook callback on the same thread that is currently waiting. In that case, we do still need to trigger a wakeup when an event is pushed because the hook itself won't necessarily do that (depending on what we return from the hook).
Cameron Gutman b992b915 2021-06-05T11:57:30 Optimize SDL_WaitEventTimeout() for the SDL_PollEvent() case There's no sense in doing all the setup for waiting if we're just polling.
Cameron Gutman 85b51e6c 2021-06-05T11:46:47 Fall back to polling normally if not operating the win32 message loop In this condition, we cannot safely wait/wake on events.
Cameron Gutman e13d5df0 2021-06-05T11:41:55 Call SDL_SendWakeupEvent() directly from SDL_PeepEvent() SDL_PeepEvent() is a documented public API, so we must properly support waking a waiting thread in SDL_WaitEventTimeout() with SDL_PeepEvent().
Francesco Abbate 0dd7024d 2021-03-12T21:58:20 Modifies WaitEvent and WaitEventTimeout to actually wait instead of polling When possible use native os functions to make a blocking call waiting for an incoming event. Previous behavior was to continuously poll the event queue with a small delay between each poll. The blocking call uses a new optional video driver event, WaitEventTimeout, if available. It is called only if an window already shown is available. If present the window is designated using the variable wakeup_window to receive a wakeup event if needed. The WaitEventTimeout function accept a timeout parameter. If positive the call will wait for an event or return if the timeout expired without any event. If the timeout is zero it will implement a polling behavior. If the timeout is negative the function will block indefinetely waiting for an event. To let the main thread sees events sent form a different thread a "wake-up" signal is sent to the main thread if the main thread is in a blocking state. The wake-up event is sent to the designated wakeup_window if present. The wake-up event is sent only if the PushEvent call is coming from a different thread. Before sending the wake-up event the ID of the thread making the blocking call is saved using the variable blocking_thread_id and it is compared to the current thread's id to decide if the wake-up event should be sent. Two new optional video device methods are introduced: WaitEventTimeout SendWakeupEvent in addition the mutex wakeup_lock which is defined and initialized but only for the drivers supporting the methods above. If the methods are not present the system behaves as previously performing a periodic polling of the events queue. The blocking call is disabled if a joystick or sensor is detected and falls back to previous behavior.
Ankith 07fc1bb8 2021-03-15T15:10:49 Fix invalid UTF-8 handling of extra bytes
Cameron Gutman 79cd8cab 2021-01-27T20:41:36 Add default handler for Alt+Tab while keyboard grab is enabled By default, we will minimize the window when we receive Alt+Tab with a full-screen keyboard grabbed window to allow the user to escape the full-screen application. Some applications like remote desktop clients may want to handle Alt+Tab themselves, so provide an opt-out via SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED=0.
Sylvain Becker 68815b6c 2021-01-10T22:21:12 Fixed bug 5465 - Invalid memcpy inside SDL_GestureDelTouch (Thanks dmikushin and Yuki Okumura)
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Sam Lantinga 5f7cd1fa 2020-12-18T10:08:59 Added hints to control whether SDL updates joystick and sensor state in the main event loop
Sam Lantinga cb361896 2020-12-09T07:16:22 Fixed bug 5235 - All internal sources should include SDL_assert.h Ryan C. Gordon We should really stick this in SDL_internal.h or something so it's always available.
Ozkan Sezer d2723875 2020-10-14T23:01:06 os2: integrate the port into main tree.
Sam Lantinga bcbaa4ec 2020-05-26T16:34:50 If there isn't a GetGlobalMouseState() implementation, fall back to the normal one.
Ryan C. Gordon fa23e3d0 2020-05-04T02:27:29 locale: Implemented SDL_GetPreferredLocales(). This was something I proposed a long time ago, Sylvain Becker did additional work on it, then back to me. Fixes Bugzilla #2131.
Sam Lantinga d4f1b520 2020-04-08T19:16:31 Added support for press/release hardware keyboard events in iOS 13.4
Sam Lantinga 1f4965c8 2020-03-08T21:24:06 Fixed warnings building with mingw64
Sam Lantinga 997f3e9e 2020-03-02T09:03:55 Fixed build warnings
Sam Lantinga b5849daf 2020-02-01T09:23:04 Fixed build warnings on Android
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sam Lantinga dd7fe0af 2019-11-16T22:45:49 Fixed bug 4814 - Missing scancodes on Linux Michael Roe The mappings for keyboard scancodes on Linux do not include keypad left and right parentheses (used on some Microsoft keyboard), keypad plus/minus, LANG1 and LANG2 (used on Korean keyboards), XK86MenuKB, and F20 (remapped to Audio Mic Mute in the usual X11 config).
Sam Lantinga cf33f1f0 2019-11-13T21:53:01 Added a utility function to simplify the hint handling logic
Sylvain Becker b458d7a2 2019-10-30T15:13:55 Readability: remove redundant cast to the same type
Sam Lantinga 526b9bdf 2019-10-14T22:41:27 Backed out changeset b0241180cdc5 Better commit incoming!
Ryan C. Gordon cd8652d8 2019-10-15T01:13:44 events: SDL_WaitEvent()'s polling loop now sleeps 1ms instead of 10ms. Fixes Bugzilla #4356.
Ryan C. Gordon cf092eca 2019-10-09T13:42:13 mouse: Save initial position yet even if xrel and yrel are 0. The X11 target sets mouse->last_x and last_y in EnterNotify and then calls SDL_SendMouseMotion(), which throws away the new position because it matches the mouse->last_x and last_y we just set, meaning that if the pointer is in the window when it created, SDL_GetMouseState() will report a position of 0,0 until a MotionNotify event (the pointer moves) arrives and corrects the mouse state. Mostly fixes Bugzilla #1612.
Sylvain Becker 70dc8d16 2019-08-30T08:55:20 Android: fix corresponding warnings
Sylvain Becker 2cb26188 2019-08-24T20:40:37 Fixed bug 1663 - SDL_EventState(SDL_DOLLARGESTURE,SDL_IGNORE) etc. has no effect
Sylvain Becker 2937317f 2019-08-22T10:15:33 Fixed bug 4172 - remove logging Gesture error "NumPoints = 0" - not necessary when app isn't recording gesture. - happen when gesture path has less than 2 different points
Alex Szpakowski d5ec735a 2019-08-01T18:22:12 Add a windowID field to SDL_TouchFingerEvent (bug #4331). This is unimplemented on some platforms and will cause compile errors when building those platform backends for now.
Sam Lantinga e7c2cf10 2019-07-15T09:36:53 Fixed bug 4704 - SDL_HINT_ANDROID_SEPERATE_MOUSE_AND_TOUCH on Windows? superfury I notice that, somehow, when locking the mouse into place(using SDL_SetRelativeMouseMode), somehow at least the movement information gets through to both mouse movement and touch movement events? My app handles both, so when moving a touched finger accross the app(using RDP from an Android device) I see the mouse moving inside the app when it shouldn't(meaning that the touch movement is ignored properly by the app(press-location dependant) but the mouse movement is still performed due to the mouse movement events)?
Sylvain Becker 66252035 2019-07-09T11:46:42 SDL_Mouse/Touch: discard synthetic events when hints are not set. Those are generated/flagged by platform layer.
Ryan C. Gordon e841b066 2019-07-08T13:41:01 cocoa: Another attempt at mouse vs touch support. This time, we make anything we think is a MacBook trackpad report its touches as SDL_MOUSE_TOUCHID, even though they're not _actually_ synthesized events, and let all mouse input--even if the OS synthesized it from a multitouch trackpad on our behalf--look like physical input. This is backwards from reality, but produces the results most apps will expect. Note that if you have a real touch device that doesn't appear to be the trackpad, it'll produce real touch events with unique device ids, so it's not a total loss here, but also note that the way we decide if it was the trackpad is an imperfect heuristic; it happens to work out right now, but it's not impossible that a real touchscreen could come to the Mac at some point and (incorrectly?) call it a "mouse" input, etc. But for now, good enough. Fixes Bugzilla #4690.
Sam Lantinga f3226457 2019-06-19T17:11:20 Fixed bug 4672 - Warnings in SDL_LogEvent()
Sam Lantinga 8ab907ba 2019-06-18T14:24:26 Only warp the mouse to set focus if we're definitely going into relative mode
Alex Szpakowski 9306ef9b 2019-06-16T14:10:30 Fix synthetically generated mouse events getting lost forever after the device orientation changes (or the window is otherwise resized) while a finger is touching the screen.
Ryan C. Gordon d9a2eff2 2019-06-13T21:31:03 cocoa: Another attempt at synthesized mouse/touch events.
Ryan C. Gordon 29457464 2019-06-13T01:57:13 cocoa: Revised synthesized mouse/touch event strategy. I _think_ I understand what Sylvain is working on here now, so hopefully I got this right. Fixes Bugzilla #4576. (I think!)
Sam Lantinga e401b950 2019-05-23T11:32:36 Return an error if both mouse relative mode and mouse warping are unavailable, instead of asserting.
Sam Lantinga 62a57970 2019-05-15T14:01:15 Windows are not in a minimized state when they are shown This fixes https://github.com/ValveSoftware/steam-for-linux/issues/4313 "Exiting game a in Steam Big Picture Mode gets semi-windowed BPM"
Sylvain Becker aae49015 2019-04-10T10:59:53 Fixed bug 4581 - generate synthetic mouse events at window boundaries when real touch events are actually outside the window.
Sylvain Becker cfefe543 2019-04-08T21:27:24 Fixed bug 4581 - mouse events with SDL_TOUCH_MOUSEID make window lost focus Virtual mouse events should never leave the window or change focus for single window applications.
Sylvain Becker eb7affee 2019-04-06T21:52:51 SDL_HINT_MOUSE_TOUCH_EVENTS: move tracking appart in case of 'window' is null
Sylvain Becker a1a9fd50 2019-04-06T21:43:16 Bug 4581: move tracking appart so it doesn't require the window to have focus
Sam Lantinga 9eac91dd 2019-04-05T08:10:12 Set SDL_HINT_MOUSE_TOUCH_EVENTS for iPhone and iPad as well
Sylvain Becker b470cd9b 2019-04-05T08:36:31 Android: default SDL_HINT_MOUSE_TOUCH_EVENTS to 1 as previous behaviour
Sylvain Becker e4157618 2019-04-04T16:51:50 Add hint SDL_HINT_MOUSE_TOUCH_EVENTS for mouse events to generate touch events controlling whether mouse events should generate synthetic touch events By default SDL will *not* generate touch events for mouse events
Sylvain Becker ab03892d 2019-04-04T15:19:00 Bug 4576: track both FingerId and TrackId
Sylvain Becker e39c0a1f 2019-04-03T10:14:42 Bug 4576: fix wrong scaling
Sylvain Becker b45abbb2 2019-04-02T17:57:27 Bug 4576: fix warning and compile
Sylvain Becker a3f2c446 2019-04-02T16:46:17 Bug 4576: handle mapping of TouchEvents to MouseEvents at higher level
Sam Lantinga b8bd0aa0 2019-03-16T19:07:34 Fixed bug 4450 - SDL_mouse.c fails to compile with CMake generated Visual Studio files if SDL_VIDEO_VULKAN 0/undefined Max Waine SDL_mouse.c, if compiled for Windows, requires GetDoubleClickTime to compile (available from winuser.h). Without Vulkan present this fails to compile as the include chain for winuser.h is the following. SDL_mouse.c -> SDL_sysvideo.h -> SDL_vulkan_internal.h -> SDL_windows.h -> windows.h -> winuser.h. Problem is that SDL_vulkan_internal.h doesn't include SDL_windows.h if Vulkan isn't present, so under MinGW/GCC it will give a -Wimplicit-function-declaration warning for GetDoubleClickTime, and under MSVC fails to compile completely. The solution to this would be to simplify the include chain: including SDL_windows.h under the same condition as GetDoubleClickTime (#ifdef __WIN32__) in SDL_mouse.c (or another file that isn't quite so indirectly included).
Ryan C. Gordon 12c5cda6 2019-03-16T00:08:19 Fix compiler warnings.
Ryan C. Gordon f95ca7bb 2019-03-15T16:13:19 events: Disable all the signal-handling code on platforms without support. So on Windows, for example, this mostly becomes a few empty functions.
Ryan C. Gordon 8a5a05c1 2019-03-15T15:51:05 events: Let arbitrary signals to simulate iOS/Android backgrounding events. This lets you build a custom embedded device that roughly offers the "this process is going to the background NOW" semantics of SDL on a mobile device.
Ryan C. Gordon 911bf624 2019-03-15T14:08:30 events: Make debug logging of the event queue a hint instead of an #ifdef. This makes it easy to toggle it on when debugging a new platform (or just getting more visibility into an app) without having to rebuild SDL.
Sylvain Becker 28f54ee4 2019-03-11T15:31:46 SDL_MouseQuit(): clear mouse->cur_cursor (Bug 4530)
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Sylvain Becker c0c8f2d7 2018-12-16T11:15:21 Gesture: remove warnings when ENABLE_DOLLAR is undefined.
Sam Lantinga 898644d1 2018-12-06T09:09:05 Made it more clear that the values being compared are floats
Sylvain Becker 252dc85e 2018-12-06T09:22:00 Fix warnings detected on Android build
Alex Szpakowski 5029d50e 2018-11-10T16:15:48 Add SDL_TouchDeviceType enum and SDL_GetTouchDeviceType(SDL_TouchID id). Touch device types include SDL_TOUCH_DEVICE_DIRECT (a touch screen with window-relative coordinates for touches), SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE (a trackpad-style device with absolute device coordinates), and SDL_TOUCH_DEVICE_INDIRECT_RELATIVE (a trackpad-style device with screen cursor-relative coordinates). Phone screens are an example of a direct device type. Mac trackpads are the indirect-absolute touch device type. The Apple TV remote is an indirect-relative touch device type.
Cameron Gutman 31ee4d3d 2018-11-03T15:46:42 Reduce delay to 1 ms in SDL_WaitEventTimeout() and SDL_WaitEvent() The 10 ms delay effectively caps input polling at 100 Hz and rendering at 100 FPS if applications use these functions in their event loop. The delay may also lead to dropped frames even at 60 FPS due if they are unlucky enough to hit the delay and rendering takes longer than 6 ms.
Micha? Janiszewski 91820998 2018-10-28T21:36:48 Add and update include guards Include guards in most changed files were missing, I added them keeping the same style as other SDL files. In some cases I moved the include guards around to be the first thing the header has to take advantage of any possible improvements compiler may have for inclusion guards.
Sam Lantinga f8b4cd41 2018-09-30T19:53:26 Re-enable drag-and-drop events by default
Sam Lantinga 6b3e8931 2018-09-14T19:26:26 Added hints SDL_HINT_MOUSE_DOUBLE_CLICK_TIME and SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS to allow tuning double-click sensitivity. Also increased the default double-click radius to 32 pixels to be more forgiving for touch interfaces
Sam Lantinga 50d50025 2018-08-23T02:21:17 Fixed build
Sam Lantinga f225af0c 2018-08-22T21:48:28 Added SDL_GetDisplayOrientation() to get the display orientation, and added a new event SDL_DISPLAYEVENT to notify the application when the orientation changes. Documented the values returned by the accelerometer and gyroscope sensors
Sam Lantinga 7c3040e0 2018-08-21T12:11:34 First pass on the new SDL sensor API
Ethan Lee de9f5415 2018-08-13T12:52:52 Filter both SIZE_CHANGED and RESIZED on any SIZE_CHANGED