src/events/SDL_mouse.c


Log

Author Commit Date CI Message
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 1ec409c2 2021-10-06T09:09:09 Don't warp the mouse within a window while it's minimized
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
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.
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
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.
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sam Lantinga cf33f1f0 2019-11-13T21:53:01 Added a utility function to simplify the hint handling logic
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.
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 8ab907ba 2019-06-18T14:24:26 Only warp the mouse to set focus if we're definitely going into relative mode
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.
Sylvain Becker eb7affee 2019-04-06T21:52:51 SDL_HINT_MOUSE_TOUCH_EVENTS: move tracking appart in case of 'window' is null
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
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).
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
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
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 a5158535 2018-06-18T13:14:02 Added support for external mouse in Samsung DeX mode relative mode doesn't work, but absolute coordinates are functional
Sam Lantinga 2dedbc72 2018-06-05T12:46:11 Add Android support for relative mouse mode to SDL.
Sam Lantinga e3cc5b2c 2018-01-03T10:03:25 Updated copyright for 2018
Ryan C. Gordon 5cc46f3d 2017-11-06T15:29:24 mouse: remove assert for unimplemented platforms (thanks, tomwardio!). Fixes Bugzilla #3946.
Sam Lantinga a223560a 2017-10-13T19:30:34 Fixed bug 3880 - X Error upon quit since rev. 11607 Ozkan Sezer Since changeset 11607:60cd425a2f14, I am getting the following error upon quit. Running testsprite2, clicking the mouse, and quiting it is enough to trigger it. This is on my old Fedora9 x86-Linux: X Error of failed request: BadCursor (invalid Cursor parameter) Major opcode of failed request: 2 (X_ChangeWindowAttributes) Resource id in failed request: 0xb057340 Serial number of failed request: 905 Current serial number in output stream: 906 Reverting https://hg.libsdl.org/SDL/rev/60cd425a2f14 removes the error.
Sam Lantinga 1887c54c 2017-10-12T13:28:48 Fixed memory leak in Cocoa mouse code The video quit call cleans up the mouse cursor driver data, which happens after mouse quit
Ryan C. Gordon 7a9b9e05 2017-08-17T20:47:16 SDL_mouse.c doesn't need default_cursor.h.
Sam Lantinga a4cfa936 2017-08-14T21:28:04 Fixed bug 2293 - Precise scrolling events Martijn Courteaux I implemented precise scrolling events. I have been through all the folders in /src/video/[platform] to implement where possible. This works on OS X, but I can't speak for others. Build farm will figure that out, I guess. I think this patch should introduce precise scrolling on OS X, Wayland, Mir, Windows, Android, Nacl, Windows RT. The way I provide precise scrolling events is by adding two float fields to the SDL_MouseWheelScrollEvent datastructure, called "preciseX" and "preciseY". The old integer fields "x" and "y" are still present. The idea is that every platform specific code normalises the scroll amounts and forwards them to the SDL_SendMouseWheel function. It is this function that will now accumulate these (using a static variable, as I have seen how it was implemented in the Windows specific code) and once we hit a unit size, set the traditional integer "x" and "y" fields. I believe this is pretty solid way of doing it, although I'm not the expert here. There is also a fix in the patch for a typo recently introduced, that might need to be taken away by the time anybody merges this in. There is also a file in Nacl which I have stripped a horrible amount of trailing whitespaces. (Leave that part out if you want).
Sam Lantinga de91b124 2017-08-14T06:28:21 Fixed bug 3745 - specify SDLCALL as the calling convention for API callbacks Patches contributed by Ozkan Sezer
Sam Lantinga bfd5a134 2017-08-12T20:25:49 Fixed bug 2931 - Large relative mouse motion jumps when using touch input
Sam Lantinga 56cab6d4 2017-08-03T09:48:44 Added a hint SDL_HINT_TOUCH_MOUSE_EVENTS to control whether touch events generate synthetic mouse events.
Ryan C. Gordon 61a3ba30 2017-01-07T17:09:14 Replaced a few single-line "//" comments.
Sam Lantinga 45b774e3 2017-01-01T18:33:28 Updated copyright for 2017
Sam Lantinga 54188c8b 2016-12-03T09:59:43 Fixed crash at startup
Sam Lantinga 16074e67 2016-12-02T22:18:05 Fixed compile warning on Visual Studio
Sam Lantinga 4eda58ba 2016-12-02T21:01:13 Added SDL_HINT_MOUSE_NORMAL_SPEED_SCALE and SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE to scale the speed of the mouse. This currently doesn't affect absolute motion, which would need to be implemented on each windowing system so the cursor matches the reported mouse coordinates.
Sam Lantinga 57d01d7d 2016-11-13T22:57:41 Patch from Sylvain to fix clang warnings
Sam Lantinga 27d4f099 2016-10-07T23:40:44 Implemented SDL_GetHintBoolean() to make it easier to check boolean hints
Philipp Wiesemann 7b23eef3 2016-09-30T23:30:54 Fixed crash if allocating memory for mouse clicks failed.
Alex Szpakowski 450fa8cd 2016-09-24T18:46:34 Use OS-provided click counts on macOS and iOS for mouse press and release events.
Sam Lantinga 42065e78 2016-01-02T10:10:34 Updated copyright to 2016
Ryan C. Gordon e346f142 2015-07-17T21:03:58 SDL_WarpMouseGlobal() should return non-void. There are platforms it isn't implemented on (and currently can't be implemented on!), and there's currently no way for an app to know this. This shouldn't break ABI on apps that moved to a revision between 2.0.3 and 2.0.4.
Philipp Wiesemann 0e45984f 2015-06-21T17:33:46 Fixed crash if initialization of EGL failed but was tried again later. The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly uninitialized data structure if loading the library first failed. A later try to use EGL then skipped initialization and assumed it was previously successful because the data structure now already existed. This led to at least one crash in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was dereferenced to make a call to eglBindAPI().
Sam Lantinga 2c4a6ea0 2015-05-26T06:27:46 Updated the copyright year to 2015
Ryan C. Gordon b72938c8 2015-04-20T12:22:44 Windows: Always set the system timer resolution to 1ms by default. An existing hint lets apps that don't need the timer resolution changed avoid this, to save battery, etc, but this fixes several problems in timing, audio callbacks not firing fast enough, etc. Fixes Bugzilla #2944.
Alex Szpakowski fe6c797c 2015-04-10T23:30:31 Fixed an iOS view orientation issue when SDL_GL_CreateContext or SDL_CreateRenderer is called.
Sam Lantinga 236deab4 2015-03-30T11:31:53 Fixed relative mouse motion moving farther and farther off screen.
Edward Rudd b88ca1b4 2015-02-10T16:28:56 the last parameter of XChangeProperty is the number of elements.. and when the element format is 32.. the element is "long" so we have 5 long elements here. Yes this seems confusing as on mac+linux Long is either 32 or 64bits depending on the architecture, but this is how the X11 protocol is defined. Thus 5 is the correct value for the nelts here. Not 5 or 10 depending on the architecture. More info on the confusion https://bugs.freedesktop.org/show_bug.cgi?id=16802
Philipp Wiesemann fe586d07 2015-02-08T21:25:37 Fixed three memory leaks on failed allocation.
Philipp Wiesemann b48e54aa 2015-01-26T22:00:29 Fixed bug 2802 - [patch] Fix android build compiling in wrong filesystem implementation Jonas Kulla The configure script didn't differentiate between Linux and Android, unconditionally compiling in the unix implementation of SDL_sysfilesystem.c. I'm probably one of the very few people building SDL for android using classic configure + standalone toolchain, so this has gone undetected all along.
David Ludwig 70438be2 2014-12-03T10:55:23 WinRT: fixed bug whereby SDL would override an app's default orientation WinRT apps can set a default, preferred orientation via a .appxmanifest file. SDL was overriding this on app startup, and making the app use all possible orientations (landscape and portrait). Thanks to Eric Wing for the heads up on this!
Edward Rudd 5b5823ee 2014-11-23T21:09:54 add in support for passing down the "natural" (or flipped) scrolling direction in the MouseWheelEvent event
Philipp Wiesemann 9c398852 2014-11-22T22:20:40 Corrected header file documentation comment.
Sam Lantinga 348cf3ee 2014-10-15T09:11:15 Fixed spurious SDL error on shutdown if mouse capture isn't supported
Pierre-Loup A. Griffais 24c86b55 2014-09-11T19:24:42 [X11] Reconcile logical keyboard state with physical state on FocusIn since the window system doesn't do it for us like other platforms. This prevents sticky keys and missed keys when going in and out of focus, for example Alt would appear to stick if switching away from an SDL app with Alt-Tab and had to be pressed again. CR: Sam
Sam Lantinga 7187b74c 2014-07-07T11:00:25 Fixed compiler warnings on iOS
Sam Lantinga 1ee96bb9 2014-07-07T10:26:28 Fixed mingw64 build and warnings
Gabriel Jacobo 9dc2614e 2014-06-28T12:50:17 Another fix to prevent dereferencing a null window pointer in SDL_mouse.c
Gabriel Jacobo 1ed1f7f2 2014-06-28T12:36:44 Fixes #2611 #2610, Touch events cause crash on Android, thanks Alvin & Sylvain This bug was introduced on this rev: https://hg.libsdl.org/SDL/rev/42f6bd8c8575
Ryan C. Gordon 4318910e 2014-06-25T17:20:22 Whoops, lost this in the merge.
Ryan C. Gordon b29740b8 2014-06-25T17:06:12 Merged Ryan's SDL-gui-backend branch. Adds three APIs, and implements them on X11, Cocoa, and Windows: - SDL_CaptureMouse() - SDL_GetGlobalMouseState() - SDL_SetWindowHitTest()
Ryan C. Gordon 84369567 2014-06-25T16:16:55 Changed SDL_GetAbsoluteMouseState() to SDL_GetGlobalMouseState(). This matches naming conventions in the main repository, between SDL_GetRelativeMouseState() and SDL_WarpMouseGlobal().
Ryan C. Gordon b861efde 2014-06-05T00:03:33 Implemented SDL_GetAbsoluteMouseState(). X11 only for now, but this should be doable on every platform, I think.
Ryan C. Gordon 264eb4bb 2014-06-05T00:02:42 Added some (harmlessly) missing braces.
Sam Lantinga 45ed5ee4 2014-06-04T10:55:26 Added an API function to warp the mouse cursor in global screen space: SDL_WarpMouseGlobal()
Ryan C. Gordon b7d2c0e9 2014-05-24T01:30:37 Implemented SDL_CaptureMouse().
Ryan C. Gordon 846a3e07 2014-05-24T01:27:19 Added some FIXMEs.
Philipp Wiesemann ca11d7c8 2014-05-17T22:02:25 Changed C++ style comments to fix pedantic warnings.
David Ludwig 3dcb451f 2014-04-09T21:29:19 Added a README file regarding WinRT support To note, this file is currently formatted with CRLF line endings, rather than LF, to allow the file to be viewed with Notepad.
Sam Lantinga c916f388 2014-03-01T09:59:06 Fixed bug 2368 - Security Software is blocking RegisterRawInputDevices() Yamagi A customer of mine had the strange problem, that SDL_SetRelativeMouseMode() was failing for him on Windows 7. Luckily he was willing to provide some debug informations. We could track this problem down to RegisterRawInputDevices() failing due to security software running on his system (Norton Internet Security to be precise, but there are reports of similar problems with other products. For example [1]). Working around this issue with SDL_WarpMouseInWindow() is easy, and while I don't think that SDL2 can provide an internal workaround it would be really nice and helpfull if this could be documentated somewhere. 1: http://forums.codeguru.com/showthread.php?498374-How-to-run-a-very-long-SQL-statement
Sam Lantinga 58edac3e 2014-02-02T00:53:27 Fixed bug 2374 - Update copyright for 2014... Is it that time already??
Sam Lantinga 7aef2350 2013-12-23T17:37:22 Added a relative mouse mode that uses mouse warping instead of raw input. To enable this, set the environment variable SDL_MOUSE_RELATIVE_MODE_WARP to "1" When mouse relative mode is disabled, put the cursor back where the application expects it to be, instead of where it was when relative mode was enabled.
Sam Lantinga 74692835 2013-12-23T12:17:52 Added support for double-clicks, through a new "clicks" field in the mouse button event.
Sam Lantinga 43825e27 2013-12-05T09:14:56 Clean up the cursor clipping area when quitting SDL. This fixes the cursor being clipped after the streaming client quits when streaming Dungeons of Dredmor
Gabriel Jacobo f848adff 2013-11-29T10:06:08 Improve Android pause/resume behavior.
Ryan C. Gordon 7e1289af 2013-11-24T23:56:17 Make internal SDL sources include SDL_internal.h instead of SDL_config.h The new header will include SDL_config.h, but allows for other global stuff.
Gabriel Jacobo 9ceed73d 2013-09-28T13:28:19 Raspberry Pi support (also unified UDEV and EVDEV support)
Sam Lantinga 3e2930de 2013-08-29T08:29:51 Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x)
Gabriel Jacobo 1e49b1ed 2013-08-21T09:47:10 OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo 695344d1 2013-08-21T09:43:09 OCD fixes: Adds a space before */
Gabriel Jacobo dad42067 2013-08-12T11:13:50 Fixes #2022, do not resume on Android when surfaceChanged If the app is in landscape mode and the user presses the power button, a pause is followed immediately by a surfaceChanged event because the lock screen is shown in portrait mode. This triggers a "false" resume. So, we just pause and resume following the onWindowFocusChanged events. Also, wait for SDL_APP_WILLENTERBACKGROUND and SDL_APP_DIDENTERBACKGROUND before blocking the event pump.
Sam Lantinga 1ad936eb 2013-08-11T19:56:43 Fixed bug 2027 - Full-screen appears to be broken - hang in SDL_DestroyWindow() Rainer Deyke I'm running Linux Mint 15 with the Cinnamon window manager. SDL_DestroyWindow consistently locks up for me when the window if fullscreen.