Commit graph

79 commits

Author SHA1 Message Date
chalonverse f317d619cc
Xbox GDKX support (#5869)
* Xbox GDK support (14 squashed commits)

* Added basic keyboard testing

* Update readme

* Code review fixes

* Fixed issue where controller add/removal wasn't working (since the device notification events don't work on Xbox, have to use the joystick thread to poll XInput)
2022-07-01 13:59:14 -07:00
chalonverse 3b191580c3
Windows GDK Support (#5830)
* Added GDK

* Simplfied checks in SDL_config_wingdk.h

* Added testgdk sample

* Added GDK readme

* Fixed error in merge of SDL_windows.h

* Additional GDK fixes

* OpenWatcom should not export _SDL_GDKGetTaskQueue

* Formatting fixes

* Moved initialization code into SDL_GDKRunApp
2022-06-27 10:19:39 -07:00
Sam Lantinga 5669743a43 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
2022-05-19 09:52:47 -07:00
Sam Lantinga f9a9d3c8d4 Also restore previous capture window if CaptureMouse() fails 2022-05-18 17:23:49 -07:00
Sam Lantinga 7044452dd6 Handle recursion in SDL_UpdateMouseCapture()
Fixes https://github.com/libsdl-org/SDL/pull/5608
2022-05-18 17:15:45 -07:00
Sam Lantinga e19a9a7931 Fixed a message box getting the mouse capture state out of sync 2022-05-18 15:34:07 -07:00
Sam Lantinga 06aca7edaa Fixed warping back into the window when gaining focus with warp relative mode enabled 2022-05-18 10:10:51 -07:00
Sam Lantinga b44241ab2f 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
2022-05-18 08:56:09 -07:00
Sam Lantinga fa073ed01a Revert "Fix relative mouse input for Unvanquished (unvanquished.net)"
This reverts commit 3318590796.

Fixes https://github.com/libsdl-org/SDL/issues/5569
2022-04-22 22:31:04 -07:00
Sam Lantinga 27fc582b59 Minor cleanup 2022-04-05 15:11:49 -07:00
Sam Lantinga 86acb1a347 Handle interaction between auto capture and the SDL_CaptureMouse() API
Fixes https://github.com/libsdl-org/SDL/issues/5457
2022-04-05 15:05:07 -07:00
Ivan Epifanov 96be9cddcc Vita: add hint to select which touchpad generates mouse events 2022-03-28 08:36:32 -07:00
Ryan C. Gordon 4fe7b2cbd1
static analysis: Fixed several complaints from codechecker.
There are still some pending Objective-C specific issues.

Reference issue #4600.
2022-03-24 11:00:43 -04:00
Sam Lantinga 5ff42438e3 Added a hint to capture the mouse when mouse buttons are pressed, defaulting on
Fixes https://github.com/libsdl-org/SDL/issues/5301
2022-03-17 17:39:46 -07:00
Sam Lantinga 09b8152fae Use SDL_Log instead of printf 2022-03-17 17:19:21 -07:00
Antoine Fontaine 3318590796 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 82793ac279
	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 31f8c3ef44
	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.
2022-03-17 14:00:59 -07:00
pionere ebdd536676 use SDL_InvalidParamError or SDL_assert instead of custom SDL_SetError 2022-01-28 20:40:19 -05:00
Sam Lantinga 120c76c84b Updated copyright for 2022 2022-01-03 09:40:21 -08:00
Cameron Gutman d7d67af441 mouse: Fix Y value in motion events when confinement is active 2021-11-14 17:52:41 -06:00
Sam Lantinga dfb834d3d4 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
2021-11-10 13:44:29 -08:00
Sam Lantinga fd79607eb0 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)
2021-11-08 21:34:48 -08:00
Sam Lantinga a3e8fd49e6 Cancel any accumulated mouse wheel motion in the opposite direction when the wheel direction changes
Fixes https://github.com/libsdl-org/SDL/issues/2912
2021-11-08 09:58:11 -08:00
Sam Lantinga 5dbbc8e61f Added mouse wheel deltas with floating point precision
Fixes https://github.com/libsdl-org/SDL/issues/4888
2021-11-08 09:44:31 -08:00
Sam Lantinga 88e9f7765c Fixed relative mouse mode using warping after 82793ac279 2021-10-14 18:37:27 -07:00
Sam Lantinga 82793ac279 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
2021-10-14 14:26:21 -07:00
Sam Lantinga 1ec409c214 Don't warp the mouse within a window while it's minimized 2021-10-06 09:09:09 -07:00
Sam Lantinga 694771513c 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)
2021-08-14 00:00:57 -07:00
Sam Lantinga 6a1e1ed9ae 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.
2021-08-14 00:00:57 -07:00
Sam Lantinga b28ed02803 Don't warp the mouse for relative mode when the window doesn't have focus 2021-08-13 11:39:41 -07:00
Dean Herbert 8fb95034e8 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.
2021-07-08 09:27:09 -07:00
Sam Lantinga 9130f7c377 Updated copyright for 2021 2021-01-02 10:25:38 -08:00
Sam Lantinga cb36189692 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.
2020-12-09 07:16:22 -08:00
Ozkan Sezer d27238751f os2: integrate the port into main tree. 2020-10-14 23:01:06 +03:00
Sam Lantinga bcbaa4ec1f If there isn't a GetGlobalMouseState() implementation, fall back to the normal one. 2020-05-26 16:34:50 -07:00
Sam Lantinga a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
Sam Lantinga cf33f1f0ef Added a utility function to simplify the hint handling logic 2019-11-13 21:53:01 -08:00
Ryan C. Gordon cf092eca90 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.
2019-10-09 13:42:13 -04:00
Alex Szpakowski d5ec735a33 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.
2019-08-01 18:22:12 -03:00
Sam Lantinga e7c2cf107a 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)?
2019-07-15 09:36:53 -07:00
Sylvain Becker 6625203514 SDL_Mouse/Touch: discard synthetic events when hints are not set.
Those are generated/flagged by platform layer.
2019-07-09 11:46:42 +02:00
Ryan C. Gordon e841b066fd 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.
2019-07-08 13:41:01 -04:00
Sam Lantinga 8ab907baa6 Only warp the mouse to set focus if we're definitely going into relative mode 2019-06-18 14:24:26 -07:00
Ryan C. Gordon d9a2eff26f cocoa: Another attempt at synthesized mouse/touch events. 2019-06-13 21:31:03 -04:00
Ryan C. Gordon 294574647d 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!)
2019-06-13 01:57:13 -04:00
Sam Lantinga e401b95025 Return an error if both mouse relative mode and mouse warping are unavailable, instead of asserting. 2019-05-23 11:32:36 -07:00
Sylvain Becker eb7affeeb8 SDL_HINT_MOUSE_TOUCH_EVENTS: move tracking appart in case of 'window' is null 2019-04-06 21:52:51 +02:00
Sam Lantinga 9eac91dd29 Set SDL_HINT_MOUSE_TOUCH_EVENTS for iPhone and iPad as well 2019-04-05 08:10:12 -07:00
Sylvain Becker b470cd9b09 Android: default SDL_HINT_MOUSE_TOUCH_EVENTS to 1 as previous behaviour 2019-04-05 08:36:31 +02:00
Sylvain Becker e41576188d 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
2019-04-04 16:51:50 +02:00
Sylvain Becker ab03892ddf Bug 4576: track both FingerId and TrackId 2019-04-04 15:19:00 +02:00