Commit Graph

6101 Commits

Author SHA1 Message Date
Sam Lantinga
92b3c53c92 Added a hint SDL_HINT_MOUSE_RELATIVE_SYSTEM_SCALE to control whether to use system mouse acceleration on raw relative motion.
This is currently only implemented on Windows, and "Enhanced pointer
precision" mode is not quite correct.
2022-08-22 16:48:09 -07:00
Sam Lantinga
d166f5ef76 Fixed uninitialized variable warning 2022-08-22 14:10:54 -07:00
Sam Lantinga
b2819e43a7 Send SDL_CONTROLLERDEVICEREMOVED for all joysticks because we don't know after the fact whether it was a game controller.
Fixes https://github.com/libsdl-org/SDL/issues/2092
2022-08-22 13:10:57 -07:00
Sam Lantinga
0e61c106f5 Don't calculate relative mouse motion if we don't have a valid position
Fixes https://github.com/libsdl-org/SDL/issues/1928
2022-08-22 12:49:41 -07:00
slime
b204db1e6b cocoa: change Shape data to use ObjC objects instead of C structs.
Fixes #6089
2022-08-21 14:49:00 -07:00
Frank Praznik
057086e389 wayland: Add high resolution scroll wheel support
Update the Wayland core protocol spec file and add support for the new axis_value120 event to handle high resolution scroll wheels.

The axis_value120 replaces the axis_discrete event, which is no longer sent as of version 8 of the protocol.  Note that unlike the axis_discrete event, no mention in the spec is made regarding how many axis_value120 events may occur per-axis per-frame, so the values are accumulated and committed when the pointer frame event occurs.
2022-08-21 08:54:58 -07:00
Frank Praznik
d731ad769d wayland: Fix include order when building with libdecor
The libdecor header internally includes wayland-client.h, which pulls in the wayland-client-protocol.h file from the system include path and overrides the local one generated from the included Wayland protocol spec files. Move the Wayland protocol header inclusion above the libdecor header inclusion to ensure that the locally generated protocol header is used instead.
2022-08-21 08:54:58 -07:00
Ryan C. Gordon
4ca7b378c5
x11: Specify windowed dimensions when creating fullscreen windows.
This lets the window manager adjust the window correctly if it ever
leaves fullscreen mode.

Fixes #5725.
2022-08-21 11:35:14 -04:00
Sam Lantinga
ffab139646 Fixed minimized window detection when handling WM_WINDOWPOSCHANGED
When minimizing a window, we get this sequence of events:
WM_WINDOWPOSCHANGING
WM_GETMINMAXINFO
WM_NCCALCSIZE
WM_WINDOWPOSCHANGED - IsIconic() is true
WM_MOVE
WM_SIZE - SDL sees minimized state here

When restoring a window, we get this sequence of events:
WM_WINDOWPOSCHANGING
WM_GETMINMAXINFO
WM_NCCALCSIZE
WM_NCPAINT
WM_ERASEBKGND
WM_WINDOWPOSCHANGED - IsIconic() is false
WM_MOVE
WM_SIZE - SDL sees restored state here

On Windows 10 a minimized window has a non-empty client rect, so we were delivering a minimized size before SDL knows that the window is minimized, and then ignoring the restored size when handling the restore message.

The fix is to use IsIconic() which returns the correct window state when WM_WINDOWPOSCHANGED is actually delivered.
2022-08-19 17:28:31 -07:00
Sam Lantinga
5a3adbfdb2 Added the hint SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED to control whether the player LED is set on Xbox 360 controllers 2022-08-19 11:11:25 -07:00
Sam Lantinga
52b6899a6b Added hints for more fine grained control over HIDAPI Xbox controller support 2022-08-19 11:11:23 -07:00
Luke Street
2b93f6e148 cocoa/uikit: Use VK_EXT_metal_surface in Vulkan_GetInstanceExtensions
Replaces VK_MVK_macos_surface and VK_MVK_ios_surface
2022-08-19 09:48:22 -07:00
Luke Street
029a9b2fa1 cocoa/uikit: Support VK_EXT_metal_surface
Uses VK_EXT_metal_surface (vkCreateMetalSurfaceEXT)
when possible, otherwise falls back to the obsoleted
VK_MVK_macos_surface and VK_MVK_ios_surface.

Fixes #3906
2022-08-19 09:48:22 -07:00
antonino
ad874536a4 kmsdrm: enable vrr on displays that support it 2022-08-19 09:45:03 -07:00
Sam Lantinga
6e9c14e550 Updated to version 2.25.0 for development 2022-08-19 09:38:42 -07:00
Sam Lantinga
8c9beb0c87 Updated to version Updated to version 2.24.0 for release 2022-08-19 08:44:09 -07:00
Sam Lantinga
6e007c36e7 Add null termination to Wayland_data_source_get_data() if requested
Fixes https://github.com/libsdl-org/SDL/issues/6083
2022-08-18 19:05:55 -07:00
Sam Lantinga
948dbe7d3f Don't include the null terminator in Wayland clipboard text
Fixes https://github.com/libsdl-org/SDL/issues/6083
2022-08-18 16:24:20 -07:00
Frank Praznik
3bae2d57da wayland: Set the libdecor app ID after visibility calls
Set the frame app ID after toggling visibility or the name displayed in window manager task switchers may not display correctly.
2022-08-18 10:58:32 -07:00
Sam Lantinga
8acb4e45b3 Fixed interactions between mouse capture and grab on X11
Fixes https://github.com/libsdl-org/SDL/issues/6072
2022-08-17 14:26:34 -07:00
Frank Praznik
7da74eb5be wayland: Never commit with an undefined window title
If libdecor performs a commit with the frame title being undefined, a crash can occur within the library or its plugins. Always ensure that the title is set to a valid string to avoid this.
2022-08-17 12:40:16 -07:00
Cameron Cawley
09b6956dcc opengl: Support NV12 textures on GPUs with only 2 texture units 2022-08-16 07:30:13 -07:00
Cameron Cawley
2fcd8f889c Handle SDL_PIXELFORMAT_EXTERNAL_OES in SDL_GetPixelFormatName() 2022-08-16 07:29:45 -07:00
Sam Lantinga
9670d2bb9e Make sure we hold the joystick lock when disconnecting a HIDAPI joystick
This prevents crashes when calling SDL joystick API functions from a different thread while disconnection is happening.

See https://github.com/libsdl-org/SDL/issues/6063 for a more thorough review of joystick locking.
2022-08-15 17:28:50 -07:00
Ryan C. Gordon
26948f01a3 cocoa: Make SDL_MinimizeWindow() work with borderless windows.
Fixes #6046.
2022-08-15 20:09:09 -04:00
Frank Praznik
650612fdcb wayland: Eliminate excessive calls to SetFullscreen
Eliminate excessive calls to SetFullscreen by removing the calls in the libdecor and xdg-toplevel config callbacks.

These calls were being made there in case something explicitly called the window minimization function from within SDL, which unsets fullscreen, and as minimizing a window in Wayland is just a suggestion to the compositor and doesn't actually change the window state or communicate anything back to the application, it was necessary to call SetFullscreen in every call to the config functions just in case something minimized a window via SDL_MinimizeWindow() and later needed to restore it.  GNOME in particular had issues when fullscreen set/unset operations were being hammered, leading to overlapping acks and commits when switching to fullscreen.

With the new video system flag to disable unsetting fullscreen when minimizing a window, these calls in the configuration functions are no longer needed and can be removed. This significantly reduces calls to the SetFullscreen() function, reverts #6044 while fixing the issue, and fixes a similar problem when hiding and showing a window initially created with fullscreen flags.
2022-08-15 11:16:20 -07:00
Frank Praznik
cc9cc2028d video: Add video device quirk flags and apply them to the video subsystem
Add quirk flags to the video device struct and add flags to allow video backend drivers to disable mode switching and disable unsetting the fullscreen mode when minimizing a window. As certain platforms can have multiple video backends compiled in at once, #ifdefs, as used by other platforms, aren't suitable as different backends on the same platform may not need the same quirks.

This replaces the formerly dedicated 'disable_display_mode_switching' boolean as additional quirks are needed by the Wayland backend.  Helper functions have also been added to simplify reading the flag states.
2022-08-15 11:16:20 -07:00
Sam Lantinga
0cc8dfdb58 Added SDL_system.h for the declaration of SDL_iPhoneSetAnimationCallback() and SDL_iPhoneSetEventPump() 2022-08-15 07:44:56 -07:00
Mathieu Eyraud
c6c688ab01 Add SDL_JOYBATTERYUPDATED event to SDL_JoystickEventState() 2022-08-14 07:00:12 -07:00
Frank Praznik
b72cf207fb core: linux: Don't cache the RealtimeKit D-Bus connection
If the D-Bus subsystem is shutdown and restarted mid-execution, the cached connection will be invalid. Fetch it each time that it is used to ensure that the connection is always from the current context.
2022-08-14 06:59:18 -07:00
Francisco Javier Trujillo Mata
7d5ccae22d Fix memory leak when destroying texture 2022-08-14 08:13:37 -04:00
Francisco Javier Trujillo Mata
5b4b4fa1ff Decrease audio thread priority when created 2022-08-14 08:13:17 -04:00
Sam Lantinga
cb46e1b3f0 Removed unused variable 2022-08-12 20:51:44 -07:00
Sam Lantinga
67cb3874ef Fixed potential uninitialized variable usage 2022-08-12 20:51:28 -07:00
Frank Praznik
74bdb2115d wayland: Don't roundtrip in ShowWindow unless restoring a hidden window
Don't call the roundtrip in ShowWindow unless restoring a previously hidden window.  This fixes a regression in GNOME when creating a window with the fullscreen flag set, as the fullscreen window will be positioned down the screen by the height of the top bar if the window is made fullscreen on the primary display and the roundtrip is called when initially displaying the window.
2022-08-12 23:34:47 -04:00
Cameron Gutman
3046d55d0e cocoa: Return an error if GetWindowDisplayIndex() is called too early
SDL_CreateWindow() may call GetWindowDisplayIndex() to compute the position
of a new window that the caller has requested to be placed on a certain
display. Since we haven't fully constructed the window yet, our driverdata
will be nil and we will fail to get the NSScreen (which is fine). However,
we need to return an error (not 0, which is a valid display index) for
SDL_GetWindowDisplayIndex() to know to figure out the display index itself.

Fixes positioning new windows on secondary displays when using
SDL_WINDOWPOS_CENTERED_DISPLAY() and SDL_WINDOWPOS_UNDEFINED_DISPLAY().
2022-08-12 20:30:59 -07:00
Sam Lantinga
f1416ef2ba Updated to version 2.23.2 for release candidate 2022-08-12 20:27:22 -07:00
Sam Lantinga
08d17f47b3 Removed unused variable 2022-08-12 20:26:23 -07:00
Sam Lantinga
be0cf257fe Only force the resize event in the DPI changed case
OpenGL windows don't actually get the WM_WINDOWPOSCHANGED event in the SetWindowPos() call in WIN_SetWindowFullscreen(), so setting the window size to zero never gets reset and we're stuck with a zero sized window.

Instead, just force the resize event in WM_DPICHANGED handling, where we know we need it. If we end up needing to force it in WIN_SetWindowFullscreen(), just set a flag in the window data and respond to that in WM_WINDOWPOSCHANGED, but that's a fairly risky behavior change as suddenly all applications would start getting SDL_WINDOWEVENT_SIZE_CHANGED when going fullscreen, and they may respond to that in expensive and potentially disruptive ways.

For later we'll probably create a DPI changed event and respond to that in the renderer instead of this window size changed hack.

This fixes https://github.com/libsdl-org/SDL/issues/6033 @ericwa
2022-08-12 18:21:00 -07:00
Sam Lantinga
b880709e9c Added libusb hack for Gamesir-G3w which needs the same adjustment as the Hori controllers 2022-08-12 18:21:00 -07:00
Cameron Gutman
1b08cd20b3 wayland: Add roundtrip in SetWindowFullscreen() to get new size
The video core assumes that window->w/h will be updated before returning
from SetWindowFullscreen(). This is needed to generate a resize event
with the correct window size when exiting fullscreen.

The roundtrip allows us to receive the configure callback that informs
us of the new window size before returning.

Fixes #6043
2022-08-12 19:03:18 -05:00
Cameron Gutman
780b031b1b wayland: Avoid duplicate resize events when entering fullscreen 2022-08-12 18:47:09 -05:00
Ethan Lee
a28f426acb render: Only update size/scale/viewport when moving to a new display, rather than all window movement.
We really only care about DPI changes here, so this both reduces work and also avoids weird cases where viewport state can be corrupted by trivial window events. This doesn't _completely_ get rid of the issue but this is somewhat intentional, since apps will definitely want to do a full reset when changing displays anyhow (otherwise DPI/adapter changes will screw things up, and that's out of our control as long as both window size and drawable size are exposed at the same time.

Note that OpenGL still captures window events because of weird platform-specific issues like macOS and viewport stretching!

Fixes #5949
2022-08-12 16:13:24 -04:00
Your Name
cfbeb438c1 fix a bug if XINPUTGETBATTERYINFORMATION is nullptr 2022-08-12 10:07:35 -04:00
Sam Lantinga
f42291ce68 Don't change mouse capture based on touch events
Fixes https://github.com/libsdl-org/SDL/issues/5652
2022-08-11 16:13:14 -07:00
Sam Lantinga
bf925b9ecd Fixed build 2022-08-11 14:41:48 -07:00
Sam Lantinga
24f97dd700 Added an SDL error to SDL_GameControllerMapping* functions 2022-08-11 14:39:49 -07:00
Sam Lantinga
9f30d4981e Added note about CRC algorithm compatibility 2022-08-11 14:27:08 -07:00
Sam Lantinga
3861c557da Added the hint SDL_HINT_MOUSE_RELATIVE_WARP_MOTION
This hint controls whether mouse warping generates motion events in relative mode, and defaults off.

Fixes https://github.com/libsdl-org/SDL/issues/6034
Fixes https://github.com/libsdl-org/SDL/issues/5741
2022-08-11 14:02:03 -07:00
Sam Lantinga
b4c4dd84c2 Added SDL_crc16() to be used in joystick GUIDs after 2.24.0 2022-08-11 09:53:25 -07:00
Sam Lantinga
a1e34b5e35 Don't send a resize event when the window is resized to the dock icon
Partially addresses https://github.com/libsdl-org/SDL/issues/6033
2022-08-11 08:55:31 -07:00
Sam Lantinga
879af7b5c8 Fixed mapping for paired Joy-Con controllers on iOS 2022-08-10 14:01:23 -07:00
Guldoman
5f682e77cb wayland: Remove freed display from SDL_WaylandOutputData->output_list 2022-08-10 15:57:47 -04:00
Sam Lantinga
e49321cec5 Fixed double-free in combined HIDAPI controller code 2022-08-10 08:21:15 -07:00
Sam Lantinga
d4192850c1 Added SDL_ResetHint() to reset a hint to the default value
Resolves question of how to clear an override hint raised by @pionere in https://github.com/libsdl-org/SDL/pull/5309
2022-08-10 08:01:24 -07:00
Ryan C. Gordon
3119d58ff5
cocoa: Change the new sync_dispatch hint to async_dispatch.
This is so the default is safer.
2022-08-10 10:48:23 -04:00
Ryan C. Gordon
c6c0a8394e
windows: If a display's friendly name is blank, try the generic name.
Fixes #6031.
2022-08-10 09:54:49 -04:00
Sam Lantinga
9ff498e78e Make HIDAPI_JoystickOpen() more robust against internal logic errors
Fixes https://github.com/libsdl-org/SDL/issues/6030
2022-08-10 06:00:30 -07:00
Ryan C. Gordon
bdc7f958fd cocoa: Added hint to treat MacBook trackpads as touch devices, not mice.
Fixes #5511.
2022-08-10 00:42:31 -04:00
Sam Lantinga
8e782876bb Fixed spamming the controller with reset IMU commands when they are failing 2022-08-09 21:30:11 -07:00
Sam Lantinga
eab27b9049 Make sure Switch controller initialization is synchronous and start the input timeout then 2022-08-09 17:59:44 -07:00
Salman Ahmed
b4660e9d8b
macOS: Add hint for blocking thread on OpenGL context update dispatch (#5708) 2022-08-09 20:40:00 -04:00
pionere
7eb13c21c6
improve behavior of SDL_SetHint(WithPriority) (#5309) 2022-08-09 20:27:25 -04:00
Sam Lantinga
1db7d33dc4 Recover from Bluetooth devices temporarily out of range 2022-08-09 17:04:26 -07:00
Sam Lantinga
6d012b2a5d Better fix for rescanning devices after read failure 2022-08-09 16:54:11 -07:00
Sam Lantinga
483a010f0c Fixed accidentally deadlocking the rumble thread with combined Joy-Cons
Also added more accurate check for sensor data. At least one axis will always have acceleration because of gravity.
2022-08-09 15:39:39 -07:00
Sam Lantinga
5d63a3d435 Re-enumerate devices if a read fails
This allows combined Joy-Con devices to immediately separate if one of them is disconnected
2022-08-09 14:06:49 -07:00
Sam Lantinga
da50f1bd3e Bluetooth devices can recover from over a second of dropped reports 2022-08-09 14:05:43 -07:00
Sam Lantinga
824f2d4650 Added a second hint SDL_HINT_JOYSTICK_HIDAPI_JOYCON_HOME_LED to control the Home button LED on Nintendo Joy-Con controllers separately from Nintendo Switch Pro controllers 2022-08-09 13:41:58 -07:00
Sam Lantinga
8aa6922fec Fixed detecting Bluetooth disconnection on Nintendo Switch controllers 2022-08-09 13:26:10 -07:00
Ryan C. Gordon
a346c4bbef
egl: Add support for SDL_GL_FLOATBUFFERS.
Fixes #6001.
2022-08-09 15:41:02 -04:00
Sam Lantinga
201484ff6f Don't duplicate the serial number twice if a child doesn't set one 2022-08-09 09:03:28 -07:00
Sam Lantinga
d90c0d41cc Include the child serial numbers in the serial number for a HIDAPI combined device 2022-08-09 09:00:56 -07:00
Ryan C. Gordon
b599205d0c
x11: Don't look up xinput2 devices unless we're in relative mode. 2022-08-09 09:50:55 -04:00
Ryan C. Gordon
2dd7659884
test: Fixed wrong arguments to SDL_SetWindowFullscreen. 2022-08-09 09:29:30 -04:00
Sam Lantinga
55882e43c4 Fixed invalid read when SDL_GameControllerSetPlayerIndex() is passed a negative player_index 2022-08-09 00:19:02 -07:00
Sam Lantinga
df537a7c0e SDL_GameControllerSetPlayerIndex(gamecontroller, -1) means turn off the player LED if possible 2022-08-09 00:18:19 -07:00
Sam Lantinga
5545be8530 The player LED index wraps for PS5 controllers, like it does for other controller types 2022-08-08 23:44:50 -07:00
Sam Lantinga
593d20d9cc Removed debug logging 2022-08-08 20:11:43 -07:00
Sam Lantinga
6204ae5002 Restart the IMU if the controller stops sending gyro/accel data 2022-08-08 20:10:12 -07:00
Ryan C. Gordon
56c1481cab cocoa: Don't mark fullscreen-desktop windows as non-resizable.
Otherwise, we can't tile SDL apps in Spaces.

Fixes #4883.
2022-08-08 20:35:11 -04:00
Sam Lantinga
d58bec72a0 Fixed Joy-Con gyro axes in mini-gamepad mode 2022-08-08 17:19:33 -07:00
Shawn Hoffman
5aa438e80a WGI: fix interop with applications that have their own WGI code
QI for Added/Removed events need to handle IAgileObject
2022-08-08 15:53:57 -07:00
Sam Lantinga
ada55c690d Fixed Joy-Con type detection for the Nintendo Joy-Con Charging Grip 2022-08-08 15:38:19 -07:00
Sam Lantinga
a547c185ce Fixed crash if uevent info isn't available 2022-08-08 12:21:40 -07:00
Sam Lantinga
7530bd74b3 Fix right, bottom computation in SDL_GetClosestPointOnRect which should be exclusive, not inclusive 2022-08-08 11:26:55 -07:00
Sam Lantinga
98bac00dcc Add SDL_GetPointDisplayIndex and SDL_GetRectDisplayIndex and re-implement SDL_GetWindowDisplayIndex in terms of SDL_GetRectDisplayIndex
- This allows looking up the display index for an arbitrary location rather than requiring an active window to do so.

- This change also reimplements the fallback display lookup that found the display with center closest to the window's center to instead find the display rect edge
  closest to the window center (this was done in the almost identical display lookup used in SDL_windowsmodes.c, which now uses `SDL_GetPointDisplayIndex`). In
  practice this should almost never be hit as it requires the window's center to not be enclosed by any display rect.
2022-08-08 11:26:52 -07:00
Francisco Javier Trujillo Mata
20f9a1b8a4 Implement SetTextureScaleMode 2022-08-08 09:34:08 -07:00
Sam Lantinga
47ebf0087a Fixed shadow variable warning 2022-08-08 08:36:17 -07:00
Francisco Javier Trujillo Mata
d355ea9981 Add a way to avoid IOP reset 2022-08-08 08:32:38 -07:00
Francisco Javier Trujillo Mata
c5fe234d53 Improve SDL main adding usb drivers 2022-08-08 08:32:38 -07:00
Francisco Javier Trujillo Mata
0a307628e6 Fix wrong mapping in some ps2 controller keys 2022-08-08 08:32:11 -07:00
Adam Butcher
0bcbdfe2bd video: dummy: Support evdev psuedo-device with no video. 2022-08-08 08:31:04 -07:00
Sam Lantinga
8f05b4f833 Fixed iOS/tvOS build 2022-08-08 08:26:21 -07:00
Sam Lantinga
878259722f Added SDL_GameControllerType enumeration for Nintendo Switch Joy-Con controllers 2022-08-08 08:22:20 -07:00
Sam Lantinga
4f19421ed8 Fixed build 2022-08-07 20:17:40 -07:00
Sam Lantinga
29265d0738 Use SDL_GetStringBoolean() to parse the hint value 2022-08-07 18:49:30 -07:00
Adam Butcher
8f5932dc2e evdev: Support user-provided devices via SDL_EVDEV_DEVICES in non-udev mode. 2022-08-07 16:37:07 -07:00
Sam Lantinga
198d62d813 joystick: remove unused Xbox Controller Keyboard VID/PID.
0x045e, 0x0b02 - is actually virtual keyboard that is generated by XboxGip drivers for Xbox One Controllers.

Closes https://github.com/libsdl-org/SDL/pull/5121
2022-08-06 23:53:18 -07:00
Frank Praznik
dd2e318211 wayland: Use libdecor visibility toggle for hiding/showing the window
The current method of toggling the libdecor window visibility by destroying and recreating the frame results in a race where a use-after-free bug can manifest itself within libdecor when window visibility is toggled quickly. Instead, use the libdecor function for toggling visibility instead of destroying and recreating the frame every time.
2022-08-06 12:12:21 -07:00