src/events


Log

Author Commit Date CI Message
Cameron Gutman 81d3addd 2022-06-11T12:59:33 events: Fix spurious early returns from SDL_WaitEvent()/SDL_WaitEventTimeout() Fixes #5780
Sam Lantinga 5669743a 2022-05-19T09:45:57 Make sure SDL_CaptureMouse() is only called on the main thread Windows handles mouse capture on a per-thread basis, and capture must be done on the thread used to create a window. Fixes https://github.com/libsdl-org/SDL/issues/5577
Pierre Wendling 501a4991 2022-05-05T18:44:32 Add clang-format on/off comments where necessary. Comments were added in places where INDENT-ON/OFF comments are. Places like stdlib's asm don't need it as clang-format doesn't try to indent it.
Sam Lantinga f9a9d3c8 2022-05-18T17:23:49 Also restore previous capture window if CaptureMouse() fails
Sam Lantinga 7044452d 2022-05-18T17:15:10 Handle recursion in SDL_UpdateMouseCapture() Fixes https://github.com/libsdl-org/SDL/pull/5608
Sam Lantinga e19a9a79 2022-05-18T15:29:59 Fixed a message box getting the mouse capture state out of sync
Sam Lantinga 06aca7ed 2022-05-18T10:09:24 Fixed warping back into the window when gaining focus with warp relative mode enabled
Sam Lantinga b44241ab 2022-05-18T08:50:59 Don't send mouse events when warping in relative mode This fixes games which set relative mode and then did mouse warping at the same time Reference https://github.com/libsdl-org/SDL/issues/5609
Cameron Cawley 2f924020 2022-05-05T20:12:07 Add SDL_SCANCODE_CALL and SDL_SCANCODE_ENDCALL
Cameron Cawley 2bc37362 2022-05-05T13:31:26 Add SDL_SCANCODE_SOFTLEFT and SDL_SCANCODE_SOFTRIGHT
Susko3 6150245d 2022-05-03T00:11:44 Add new verbosity level for logging of `SDL_SysWMEvent`s Now logged only if SDL_HINT_EVENT_LOGGING is set to "3" or above.
Sam Lantinga fa073ed0 2022-04-22T22:31:04 Revert "Fix relative mouse input for Unvanquished (unvanquished.net)" This reverts commit 331859079674465a39b24f32a6a113959601dca3. Fixes https://github.com/libsdl-org/SDL/issues/5569
Sam Lantinga 27fc582b 2022-04-05T15:11:49 Minor cleanup
Sam Lantinga 86acb1a3 2022-04-05T15:05:07 Handle interaction between auto capture and the SDL_CaptureMouse() API Fixes https://github.com/libsdl-org/SDL/issues/5457
Ivan Epifanov 96be9cdd 2022-03-27T21:48:09 Vita: add hint to select which touchpad generates mouse events
Ryan C. Gordon 4fe7b2cb 2022-03-24T11:00:43 static analysis: Fixed several complaints from codechecker. There are still some pending Objective-C specific issues. Reference issue #4600.
Ryan C. Gordon f782abe5 2022-03-22T09:52:52 hints: Added SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE. Fixes #2349.
Sam Lantinga 5ff42438 2022-03-17T17:39:46 Added a hint to capture the mouse when mouse buttons are pressed, defaulting on Fixes https://github.com/libsdl-org/SDL/issues/5301
Sam Lantinga 09b8152f 2022-03-17T17:19:21 Use SDL_Log instead of printf
Sam Lantinga ecaa22cb 2022-03-17T14:22:51 Don't warn if anyone peeps for events after quitting the event subsystem Fixes https://github.com/libsdl-org/SDL/issues/5013
Antoine Fontaine 33185907 2022-03-09T17:02:32 Fix relative mouse input for Unvanquished (unvanquished.net) Here's an IRC dump that hopefully explains the issue this fixes: > I'm debugging something odd where, for a libre game, unvanquished.net (a FPS), relative mouse input in fullscreen is buggy > it's like, working mostly ok, but it has a weird performance/cleanup bug > after some time in relative mouse input mode, some time as low as 15s, usually more, the SDL sends A LOT of relative mouse input per frame > almost all of which have xrel==0 && yrel==0 > by A LOT, I mean that after ~1min, it's usually in the thousands per frame > each frame, a while ( SDL_PollEvent( &e)) loop reads the inputs, but it seems SDL is not clearing the list. > one way to clear the list is to open the in-game console or menu, which switches the input mode to absolute, then close it which gets a working relative input mode (for some time at least) > I've shown the issue to be present with SDL2.0.20 but not with 2.0.14 on my system > some other players on Arch Linux (SDL2.0.20) report a possibly related issue, where some keys seem to be pressed at random > I've did some bisection on SDL master, and I've found that there are actually two commits involved, one breaking it totally (no input at all), and one fixing it partially (with the problem described above) First related commit that breaks it totally: commit 82793ac279d19b5bde8fc2bd62877b05ba5a76e0 Author: Sam Lantinga <slouken@libsdl.org> Date: Thu Oct 14 14:26:21 2021 -0700 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 Second related commit, that halfway fixes it: commit 31f8c3ef4409a93fafa894b78c2ce176bd0c3cf3 Author: Sam Lantinga <slouken@libsdl.org> Date: Thu Jan 6 11:27:44 2022 -0800 Fixed event pump starvation if the application frequently pushes its own events Reverting the first commit did fix the issue for me, but would probably reintroduce the bug it was fixing(?). This patch should fix it for everyone hopefully. https://github.com/DaemonEngine/Daemon/issues/600 is the upstream bug, and contains some early investigation.
Sam Lantinga cc152103 2022-03-17T11:37:08 Fixed warnings when building with cygwin Fixes https://github.com/libsdl-org/SDL/issues/5025
Zach Reedy d14a1263 2022-03-11T17:45:17 IME Composition Truncation + SDL_IsTextInputShown + SDL_ClearComposition (#5398) * Fixes for IME Composition Truncation + Addition of SDL_ClearComposition, SDL_IsTextInputShown * Fixed: Documentation and code style issues raised during code review.
Cameron Gutman b2463a91 2022-03-06T15:02:53 events: Add logging support for several missing event types
Sam Lantinga 2e801b1a 2022-03-04T10:49:12 Split long text input into multiple events if needed (thanks @zreedy!)
Sam Lantinga 6c531c43 2022-02-21T11:35:31 Correct handling of sentinel events when polling without removing events Fixes https://github.com/libsdl-org/SDL/issues/5350
Sylvain 34d4f5b1 2022-02-08T11:32:20 Fixed bug #2032: add SDL_GetTouchName to expose the driver name of the device (Thanks @mgerhardy!)
pionere e2f70a2d 2022-01-19T12:51:26 cleanup SDL_EventState
pionere ebdd5366 2022-01-17T16:26:02 use SDL_InvalidParamError or SDL_assert instead of custom SDL_SetError
Sam Lantinga 84320266 2022-01-25T12:37:43 Fixed the queue filling up with sentinel events when the WaitEvent call is passed NULL for the event The use case is an application that waits for events on the main thread and dispatches them on a separate thread.
ulatekh 8f8b14cb 2022-01-21T17:10:09 Synthesize a missing touch-up event. If a touch-down event is received for an existing touch-ID, that probably means the operating system lost it, and that the missing touch-up should be synthesized, to keep the client state coherent.
Sam Lantinga d8129c56 2022-01-10T10:50:59 Mark internal function as static
Sam Lantinga dca281e8 2022-01-08T08:49:34 Fixed getting different results for SDL_PollEvent(NULL) and SDL_PollEvent(&event)
Sam Lantinga 289c3fbb 2022-01-07T17:07:22 Revert "We only need to add the sentinel at the top of SDL_WaitEventTimeout()" This reverts commit c477768e6f926c38d4cdc236cab8376faf9f6789. We want to add the sentinel anytime we pump inside SDL_WaitEventTimeout() to avoid pumping again the next time through, as a performance optimization.
Sam Lantinga c477768e 2022-01-06T18:58:30 We only need to add the sentinel at the top of SDL_WaitEventTimeout()
Cameron Gutman e9134b04 2022-01-06T19:38:10 events: Only add sentinels for pumping done inside SDL_WaitEventTimeout() We don't want to catch explicit SDL_PumpEvents() calls by the application with our polling check to avoid stale data. If the call to SDL_PumpEvents() produced no events, there will be a sentinel sitting in the queue that will cause SDL_PollEvent() to immediately return 0 next time it is called. Our SDL_WaitEventTimeout() implementation avoids this issue by always popping an event after calling SDL_PumpEvents(). This will remove the new sentinel if we didn't get any new events.
Sam Lantinga 95485884 2022-01-06T13:58:39 Move special sentinel handling inside SDL_PeepEvents()
Sam Lantinga 2592e621 2022-01-06T13:30:26 Clarify that timeout == 0 is handled at the top of SDL_WaitEventTimeout()
Sam Lantinga 8ff21668 2022-01-06T12:56:07 Only return from SDL_PollEvent() if the last sentinel is consumed
Sam Lantinga c9ff90b9 2022-01-06T12:03:09 Clarify comment Co-authored-by: Simon McVittie <smcv@debian.org>
Sam Lantinga 31f8c3ef 2022-01-06T11:27:44 Fixed event pump starvation if the application frequently pushes its own events
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 0445c13a 2021-11-22T16:49:17 Remove 'malloc' from comment
Sylvain e72beeb2 2021-11-22T16:40:29 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