Commit Graph

6274 Commits (d71df6448b04d756555d9d9d285ba4c36b7e9f61)

Author SHA1 Message Date
Julio C. Rocha 05983fb8ee Add Mayflash PC043 adapter 2022-08-24 15:34:46 -07:00
Sam Lantinga e7332cd814 Fixed zero CRC matching in the controller mapping database 2022-08-24 15:28:56 -07:00
Francisco Javier Trujillo Mata a4f84803c4 Disable fileXio and patch fio 2022-08-24 12:23:56 -07:00
Noel Berry 00452e47fa
Adding SDL_GetWindowSizeInPixels for window size in pixels (#6112) 2022-08-24 11:25:13 -07:00
Sam Lantinga 70c781c803 Fixed build warning because of redefining string functions 2022-08-24 10:25:56 -07:00
antonino 5f79cd1600 Fixed spacing 2022-08-24 10:10:49 -07:00
antonino dd68eb5c01 free drm prop before returning 2022-08-24 10:10:49 -07:00
Sam Lantinga 970344719a Fixed the Nintendo Switch Pro mappings on iOS/tvOS 2022-08-24 09:39:01 -07:00
Sam Lantinga 1fc7f68118 Document that it's not possible to use the HIDAPI driver for PS3 controllers on Windows 2022-08-24 06:38:36 -07:00
Sam Lantinga 645b0f6abf Enable HIDAPI PS3 support by default on macOS 2022-08-24 01:30:29 -07:00
Sam Lantinga 3ed8e219a5 Fixed building HIDAPI libusb support on Windows 2022-08-24 01:25:14 -07:00
Sam Lantinga 3d62ebdbf6 Fixed HIDAPI PS3 support on macOS 2022-08-24 00:34:30 -07:00
Sam Lantinga aaee6e242c Added missing file 2022-08-23 22:56:48 -07:00
Sam Lantinga b6f96b69aa Initial HIDAPI driver support for the PS3 controller 2022-08-23 22:45:37 -07:00
Sam Lantinga 50c5d23f7d Round coordinates so very small floating point values don't turn into 0x80000000
e.g. SDL_RenderDrawLineF(renderer, -1e20, -1e20, 10, 10);

Fixes https://github.com/libsdl-org/SDL/issues/6116
2022-08-23 07:42:48 -07:00
Sam Lantinga b6a3d76225 Look up mappings by GUID in two passes: first with CRC, second without 2022-08-23 07:24:21 -07:00
Sam Lantinga 277b033e78 Refactor joystick GUID creation 2022-08-22 19:44:14 -07:00
antonino aae566e196 Use SDL_bool 2022-08-22 18:43:43 -07:00
antonino e3ea9b5b7c restore vrr state on exit 2022-08-22 18:43:43 -07:00
antonino 450e9857cc Use SDL_TRUE and SDL_FALSE 2022-08-22 18:43:43 -07:00
antonino 605b50fcd9 kmsdrm: added missing checks 2022-08-22 18:43:43 -07:00
Sam Lantinga c1e0873940 Added the CRC of the joystick name to the GUID
This will make it possible to have mappings for different controllers
that have the same VID/PID. This happens frequently with some generic
controller boards that have been reused in many products.

Fixes https://github.com/libsdl-org/SDL/issues/6004
2022-08-22 18:22:35 -07:00
Sam Lantinga 20715fa014 Fixed build errors 2022-08-22 17:09:42 -07:00
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
Francisco Javier Trujillo Mata fbb440d167 Invalidate texture in the UnlockTextureMethod 2022-08-06 12:11:34 -07:00
Sam Lantinga 52bf5b1de9 Added the hint SDL_HINT_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED to control whether the player LED is set on Nintendo Switch controllers 2022-08-06 10:34:19 -07:00
Sam Lantinga f810dede16 Fixed comment so script processing works correctly 2022-08-06 09:50:13 -07:00
Ryan C. Gordon f600364b8a
wayland: Mark window as MOUSE_CAPTURE while a mouse button is down.
Wayland works like SDL's "auto capture" feature already, tracking the mouse
globally only while a drag is occuring, and this is the only way to get mouse
input outside the window.

Setting this flag ourselves lets SDL_CaptureMouse() work in the most common
use case without actually implementing CaptureMouse for the backend, including
SDL's auto capture feature.

Fixes #6010.
2022-08-06 09:19:52 -04:00
Ryan C. Gordon a6179e85c0
wayland: Don't double-free clipboard sources if ours gets cancelled.
Fixes #6007.
2022-08-05 21:25:00 -04:00
Francisco Javier Trujillo Mata 3da131c1c6 Check if port if closed and open it again 2022-08-05 17:44:59 -07:00
Sam Lantinga 5858c7dfce Fixed OpenGL ES Shaders for systems that don't understand precision keywords 2022-08-05 16:17:10 -07:00
Frank Praznik 3685c64ed1 wayland: Round trip after window show/hide operations.
Perform a round trip after showing/hiding the window to avoid protocol errors when ShowWindow() is called immediately after HideWindow().
2022-08-05 15:03:54 -07:00
Sam Lantinga d6a8b43cf7 Added support for the HORIPAD FPS for Nintendo Switch 2022-08-05 10:37:38 -07:00
Francisco Javier Trujillo Mata a2d3be904b Implement create windows method 2022-08-04 15:41:43 -07:00
Sam Lantinga 4a9ceb7be9 The HORIPAD S uses the Xbox 360 protocol on all platforms and shows up as multiple styles of controller, depending on what model you have. 2022-08-04 11:33:36 -07:00
Sam Lantinga 28c01955bc Fixed button mapping for the HORIPAD S
This controller actually comes in at least two flavors: a GameCube controller and an arcade pad, neither of which should have the face buttons remapped.
2022-08-04 10:46:37 -07:00
Sam Lantinga 40b7143180 Fixed button mapping for the HORIPAD S controller
This controller looks like a GameCube controller, is actually a Nintendo Switch controller, and shows up as an XInput device on Windows with the buttons already in the correct location.
2022-08-04 10:26:10 -07:00
David Carlier 16e699a761 Proposing exposing as public api the various arch dependent
pause instructions so could be used in app infinite loops.
A handful of games do already so we unify it in one place.
2022-08-04 08:47:39 -07:00
Sam Lantinga 43b90484c9 Retry a little longer when writing to the Nintendo Joy-Con Charging Grip 2022-08-04 00:40:38 -07:00
Ozkan Sezer 293d29b78a SDL_x11xinput2.c: fix build for macOS 2022-08-04 10:11:02 +03:00
Ryan C. Gordon 5907db56f1
x11: Attempt to deal with XInput2 devices with absolute coordinates.
This is untested!

Reference Issue #1836.
2022-08-04 02:12:46 -04:00
Sam Lantinga dfd2c574d7 Removed unused variable 2022-08-03 22:27:43 -07:00
Sam Lantinga a2b4f4406f The Nintendo Wii Remote Pro Controller respects the SDL_GAMECONTROLLER_USE_BUTTON_LABELS hint 2022-08-03 22:27:42 -07:00
Sam Lantinga c84dea0943 Fixed detecting the controller type of controllers over USB 2022-08-03 22:12:21 -07:00
Sam Lantinga ba297f12cd Use the Nintendo controller type to determine whether to always use button labels 2022-08-03 21:46:01 -07:00
Sam Lantinga 946f4777f6 Don't set Bluetooth controllers to wired power level 2022-08-03 21:33:38 -07:00
Sam Lantinga 57c3b2c950 Don't rely on the device VID/PID to get the Nintendo controller type
The Nintendo Online Sega Genesis controller reports the SNES VID/PID over Bluetooth. This is a more robust way of handling future controllers as well, so let's go with this instead.

Also use full reports over Bluetooth, and don't report gyro for Nintendo Online classic controllers.
2022-08-03 21:31:12 -07:00
Sam Lantinga b6aadb16b9 Added k_eSwitchDeviceInfoControllerType_N64 to ESwitchDeviceInfoControllerType 2022-08-03 20:38:33 -07:00
Sam Lantinga bdfb32de3c Added some additional Nintendo controller types to ESwitchDeviceInfoControllerType 2022-08-03 20:30:58 -07:00
Sam Lantinga ea7fbf7947 Update in-flight SDL_CONTROLLERDEVICEADDED messages when a device is removed
This fixes the application trying to open the wrong device index when a device is removed and another has just been added
2022-08-03 19:39:37 -07:00
Sam Lantinga 5d50fa52df Fixed timeout opening the Nintendo Joy-Con Charging Grip
Sometimes opening the right Joy-Con takes a little longer for some reason
2022-08-03 19:39:36 -07:00
Sam Lantinga 29cdb2c9c9 Added support for the Nintendo Switch Joy-Con Charging Grip 2022-08-03 18:01:10 -07:00
Sam Lantinga a8120104ad The Nintendo Online classic controllers and Joy-Cons shouldn't show up as Switch Pro controllers 2022-08-03 13:53:49 -07:00
Sam Lantinga 6e1ee1d4a5 sort the controller names 2022-08-03 13:51:25 -07:00
Sam Lantinga 8ab9dc8b2b Fixed crash if Joy-Cons are disabled while a combined Joy-Cons controller is open 2022-08-03 13:18:00 -07:00
Sam Lantinga bcdef4aaf9 Added separate hints for Nintendo Online classic controllers and Joy-Cons
This allows them to be enabled/disabled separately from Switch Pro HIDAPI support
2022-08-03 13:07:47 -07:00
Shootfast 60d1944e46 SDL_video: Added SDL_GL_FLOATBUFFERS to allow Cocoa GL contexts to use EDR 2022-08-02 15:45:30 -07:00
Frank Praznik 0b9868b026 wayland: Use D-Bus to retrieve the cursor size and theme on GNOME
GNOME exposes the cursor size and theme via the org.freedesktop.portal.Settings interface of the xdg-desktop portal, so query these values via D-Bus, if available.

The XCURSOR_SIZE/XCURSOR_THEME envvars will be tried first, so as not to override any user specified sizes or themes, then D-Bus, then, failing that, it will fall back to default values.
2022-08-02 14:52:01 -07:00
Francisco Javier Trujillo Mata 944111dbcf Cleaning up video driver 2022-08-02 11:40:31 -07:00
Francisco Javier Trujillo Mata 3f7dda8c72 Remove deinit of video driver 2022-08-02 11:40:31 -07:00
Francisco Javier Trujillo Mata 83c1179744 Adding SetViewPortCommand 2022-08-02 11:40:31 -07:00
Francisco Javier Trujillo Mata a9f4cda3f9 Adding setcliprect command 2022-08-02 11:40:31 -07:00
Francisco Javier Trujillo Mata fb1a205e70 Implement blend modes 2022-08-02 11:40:31 -07:00
Francisco Javier Trujillo Mata 075f9016fa Remove some unnecessary comments 2022-08-02 11:40:31 -07:00
Francisco Javier Trujillo Mata ed301b123b Updating supported format 2022-08-02 11:40:31 -07:00
Francisco Javier Trujillo Mata 1d1965b6ee Removing the BGR_888 from texture supported 2022-08-02 11:40:31 -07:00
Francisco Javier Trujillo Mata f75c35c071 Add invalidate texture when it changes 2022-08-02 11:40:31 -07:00
Daniel Santos 5bb965be3d Implement RenderLines 2022-08-02 11:40:31 -07:00
Francisco Javier Trujillo Mata 0f0e5b44dc Increase size of pool for gsKit events 2022-08-02 11:40:31 -07:00
Francisco Javier Trujillo Mata f758cad81a Remove non needed FillRects function 2022-08-02 11:40:31 -07:00
Daniel Santos 3cb124b98e Implement RenderPoints 2022-08-02 11:40:31 -07:00
Daniel Santos df6ebc2562 Implement FillRect 2022-08-02 11:40:31 -07:00
Daniel Santos a152e467b1 Fix "implicit declaration" with memalign 2022-08-02 11:40:31 -07:00
Daniel Santos 33cbf9acbe Fix some mixed declaration warnings 2022-08-02 11:40:31 -07:00
Daniel Santos acf48f14ac Vertex pointer revision
Now triangles are fully working
2022-08-02 11:40:31 -07:00
Daniel Santos 726180445e Add textured triangle prim 2022-08-02 11:40:31 -07:00
Francisco Javier Trujillo Mata 2a70d492f0 Destroy texture properly 2022-08-02 11:40:31 -07:00
Daniel Santos 7b0486d490 Try triangles 2022-08-02 11:40:31 -07:00
Daniel Santos d5305ee098 Do properly color assign 2022-08-02 11:40:31 -07:00
Daniel Santos b48c74a316 Add GeometryQueue 2022-08-02 11:40:31 -07:00
Francisco Javier Trujillo Mata 3bfc8f554e Removing some of the QueueCopy functions because they are legacy 2022-08-02 11:40:31 -07:00
Francisco Javier Trujillo Mata be1219bd4e Implement setDrawColor 2022-08-02 11:40:31 -07:00
Francisco Javier Trujillo Mata f1699ce735 Implementing Clear command and texture Update 2022-08-02 11:40:31 -07:00
Francisco Javier Trujillo Mata c472b8dd45 Whole clean around render and video driver 2022-08-02 11:40:31 -07:00
Daniel Santos cdf89fde91 Add triangle prim support
Improve line support
Add initial texture support
2022-08-02 11:40:31 -07:00
Francisco Javier Trujillo Mata 88e64f9ae1 Add natively supported colors 2022-08-02 11:40:31 -07:00
Daniel Santos 90e0e5c29d Add point, line and rect support 2022-08-02 11:40:31 -07:00
Daniel Santos 147a71b976 Finish dummy driver 2022-08-02 11:40:31 -07:00
Daniel Santos 2660449c6c Add dummy driver 2022-08-02 11:40:31 -07:00
Daniel Santos a81aa99298 Add prim video support 2022-08-02 11:40:31 -07:00
Francisco Javier Trujillo Mata 46f95a7a5f Create dummy PS2 Video driver 2022-08-02 11:40:31 -07:00
Mathieu Eyraud f1390780ca Fix use after free when removing Windows audio device 2022-08-02 10:24:11 -04:00
Mathieu Eyraud 59a104b803 Do not pass NULL to memcpy
ReadJoyConControllerType calls WriteSubcommandSync with pbuf=NULL
2022-08-02 06:38:51 -07:00
Mathieu Eyraud 42b2320756 Fix memory leak of children for combined JoyCon 2022-08-02 06:33:18 -07:00
Sam Lantinga 602b7dd0f4 Made the window ICMProfile filename per-window
The event no longer spams each time a window gets focus if there are windows on monitors with different color profiles.

This also has the side effect that you no longer get a color profile event at window creation, which is consistent with other events that communicate state changes.
2022-08-01 17:47:26 -07:00
Sam Lantinga cb107bef58 Fixed crash if all displays have been disconnected
Fixes https://github.com/libsdl-org/SDL/issues/5867
2022-08-01 14:23:50 -07:00
Sam Lantinga 12aa4d5653 Added header needed for SDL_Delay() 2022-08-01 11:11:25 -07:00
Sam Lantinga aeb275149a Poll DirectInput devices to get their initial state
Fixes https://github.com/libsdl-org/SDL/issues/3816
2022-08-01 10:39:56 -07:00
Sam Lantinga 3a6cb7e7c5 Convert XLookupString Latin-1 text to UTF-8
Fixes bug https://github.com/libsdl-org/SDL/issues/4699
2022-08-01 10:28:29 -07:00
Sam Lantinga 0cd5b08bfe Fixed infinite loop when SDL_SendKeyboardText() is passed invalid UTF-8 text 2022-08-01 09:55:53 -07:00
Sam Lantinga 15bcf58d77 Fixed memory leak in the Windows driver 2022-08-01 08:14:54 -07:00
Ryan C. Gordon cf63af8ae2
events: Don't lose window RESIZED events during SIZED_CHANGED processing.
Previously, calling SDL_SendWindowEvent for a SIZED_CHANGED event would
filter the queue to remove RESIZED and SIZED_CHANGED events, so you don't
overflow the queue with obsolete data, but any RESIZED events would be
lost in this process.

Now we note if there was a RESIZED pending and replace it with a new
event using the same dimensions as the new SIZED_CHANGED event. This fixes
cases where an app is only listening for RESIZED events and thus might
lose important information in some cases.

Fixes #5925.
2022-07-31 22:10:45 -04:00
Cameron Gutman 17f36c105c keyboard: Remove no-op calls to SDL_SetKeymap() 2022-07-31 15:46:35 -07:00
Cameron Gutman 9515fb2501 keyboard: Use SDL_SetKeymap() to set the default keymap
This ensures the AZERTY workaround is applied for backends that
never call SDL_SetKeymap() themselves.
2022-07-31 15:46:35 -07:00
Cameron Gutman 8b438f7b51 keyboard: Only send SDL_KEYMAPCHANGED when the keymap actually changes 2022-07-31 14:02:28 -07:00
Cameron Gutman a10c57dfe4 evdev: Report touchpad events with the correct device type 2022-07-31 14:18:44 -05:00
Cameron Gutman 9a33c62e13 evdev: Use SDL_bool for boolean types 2022-07-31 14:06:59 -05:00
Cameron Gutman f9d1f34b6c evdev: Report a unique ID for each mouse device 2022-07-31 13:10:43 -05:00
Cameron Gutman 574db63c8e evdev: Batch mouse axis updates until SYN_REPORT
This is necessary for consistent position reports with absolute mice
and improves application performance with relative mice by cutting the
number of reported mouse motion events roughly in half.
2022-07-31 12:36:11 -05:00
Sam Lantinga 7f42fb54ad Applied DragonFly BSD patch
https://github.com/DragonFlyBSD/DeltaPorts/blob/master/ports/devel/sdl20/dragonfly/patch-src_stdlib_SDL__malloc.c
2022-07-30 16:34:40 -07:00
Sam Lantinga 21100006ad Don't conflict with usage of stdout as a stdio macro
Patch inspired by http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/pkgsrc/devel/SDL2/patches/patch-src_video_wayland_SDL__waylandmessagebox.c?rev=1.1&content-type=text/plain
2022-07-30 16:22:24 -07:00
Frank Praznik 22f25b03d9 core: linux: Favor xdg-desktop-portal for elevating thread priority
Use the xdg-desktop-portal interface to RealtimeKit1, when available, to set realtime scheduling and elevated priority for threads.  This portal allows for the use of rtkit within containers such as Flatpak.  It will fall back to using RealtimeKit1 directly if the xdg-desktop-portal interface is too old or not available.
2022-07-30 08:38:22 -07:00
Sam Lantinga 2241bd669f Added a command line option `--info event_motion` to show mouse and finger motion events 2022-07-29 20:37:38 -07:00
Sam Lantinga 13e0c40ec2 Added mapping for the 8BitDo Pro 2 controller in DirectInput mode over Bluetooth on Linux 2022-07-29 17:28:36 -07:00
Sam Lantinga 62c831661c Added mapping for the 8BitDo Pro 2 controller in DirectInput mode 2022-07-29 17:14:55 -07:00
Sam Lantinga 41c363f7d6 Note that the PDP Versus Fighting Pad is an arcade fighting pad 2022-07-29 16:29:25 -07:00
Anonymous Maarten 36dfbe5d66 stdlib: exclude mslibc functions using SDL_STATIC_LIB macro 2022-07-29 15:05:19 +02:00
Sam Lantinga f3c1194c0f Removed obsolete comment 2022-07-28 21:50:41 -07:00
Sam Lantinga aee179e46f Removed debug output 2022-07-28 21:50:20 -07:00
Sam Lantinga d8fd78736b Added entry for the Nintendo Switch Joy-Con controller pair 2022-07-28 21:44:23 -07:00
Sam Lantinga 875b737c64 Added support for the Nintendo Online NES Controllers to the HIDAPI driver 2022-07-28 21:40:01 -07:00
Sam Lantinga ab967475c6 Greatly improved Nintendo Joy-Con support using the HIDAPI driver
* Added support for mini-gamepad mode for Joy-Con controllers, matching the mapping for hid-nintendo on Linux and iOS 16
* Added the ability to merge left and right Joy-Con controllers into a single Pro-style controller
* Added the hint SDL_HINT_JOYSTICK_HIDAPI_SWITCH_COMBINE_JOY_CONS to control this merging functionality
* Removed the hint SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS
2022-07-28 19:38:38 -07:00
Sam Lantinga dfed862a66 Fixed variable shadow warning 2022-07-28 19:35:46 -07:00
Sam Lantinga 2fa2f9ff77 Greatly improved Nintendo Joy-Con support using the HIDAPI driver
* Added support for mini-gamepad mode for Joy-Con controllers, matching the mapping for hid-nintendo on Linux and iOS 16
* Added the ability to merge left and right Joy-Con controllers into a single Pro-style controller
* Added the hint SDL_HINT_JOYSTICK_HIDAPI_SWITCH_COMBINE_JOY_CONS to control this merging functionality
* Removed the hint SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS
2022-07-28 19:22:27 -07:00
Sam Lantinga def60ce6fe Fixed the name of the HIDAPI Joy-Con controller for consistency with other drivers 2022-07-27 19:20:42 -07:00
Sam Lantinga 0f1be9401f Updated mapping for Joy-Con controllers using hid-nintendo
This matches the mapping on iOS 16 and will match the HIDAPI
implementation.
2022-07-27 17:32:51 -07:00
Sam Lantinga 756978a236 Left and right single Joy-Con controllers are mapped as individual mini controllers 2022-07-27 16:17:32 -07:00
Sam Lantinga 4990bd0517 Added debug code to show available inputs on iOS/tvOS controllers 2022-07-27 16:17:32 -07:00
Sam Lantinga dbf7940541 Enable capturing raw Xinput2 touch events and use to flag global mouse state as dirty
- Touch events may be translated to mouse movement events without the normal Xinput2 raw motion events
  being sent. Not all touch events will necessarily move the mouse but this ensures we update the global
  mouse state just in case.

- Fix up some formatting

CR: saml
2022-07-27 10:31:24 -07:00
Ryan C. Gordon 42165fe8d1
kmsdrm: slightly better device index hint parsing. 2022-07-27 12:12:36 -04:00
Anonymous Maarten 5da85376b9 stdlib: move all mslibc functions to SDL_mslibc.c
This allows disabling LTO on them by only specifying a single file.
2022-07-27 09:07:56 -07:00
Sam Lantinga a169259f62 Actually we don't need to unlock to send k_eSwitchProprietaryCommandIDs_ForceUSB since we don't wait for reply 2022-07-27 09:05:02 -07:00
Sam Lantinga c51464d9d8 Put the Nintendo Switch Pro controller back into enhanced mode as needed
Fixes https://github.com/libsdl-org/SDL/issues/3450
2022-07-27 09:00:39 -07:00
Sam Lantinga 613ce7850e Fixed interpreting SDL_KMSDRM_DEVICE_INDEX="" as index 0 2022-07-26 13:34:27 -07:00
Ryan C. Gordon cc982ea7a7 kmsdrm: let device indexes be > 2 digits. 2022-07-26 15:43:34 -04:00
diddily 1f276a5148 Fix Main Thread Checker warning on macOS
Cache off NSWindow's windowNumber in SDL_WindowData on setup and use that in `Cocoa_SendWakeupEvent` to prevent accessing windowNumber off the main  thread.
2022-07-26 15:17:44 -04:00
Ryan C. Gordon 542a4da3d6
kmsdrm: check SDL_HINT_KMSDRM_DEVICE_INDEX hint in dri_getindex().
Otherwise, it would work for Init but not Available.
2022-07-26 15:11:19 -04:00
Ryan C. Gordon 218c3dbb34
cocoa: Don't crash if moving a message box created before SDL_Init.
Fixes #5928.
2022-07-26 14:45:26 -04:00
Ryan C. Gordon 8ff738f234
audio: Report SDL_AUDIODEVICEREMOVED for unopened devices.
Unopened devices, if removed, now send SDL_AUDIODEVICEREMOVED events with
a `which` field set to zero. Apps can use this to decide if they need to
refresh a list of devices being shown in an options menu, etc.

It's safe to call SDL_CloseAudioDevice(0), so even if they try to clean
up this bogus id, it should be safe.

Fixes #5199.
2022-07-26 12:40:47 -04:00
Ryan C. Gordon 5d85c7d300
kmsdrm: Added a hint to specify device index.
Fixes #2811.
2022-07-26 00:19:54 -04:00
Ryan C. Gordon 20a76b0e3e
video: removed unused devindex argument from bootstrap's create method. 2022-07-26 00:19:52 -04:00
pionere 12211df669 hide SDL_GenerateAssertionReport in case SDL_ASSERT_LEVEL is 0
otherwise SDL_PromptAssertion (and SDL_GenerateAssertionReport) can not be eliminated
2022-07-25 14:26:46 -07:00
Sam Lantinga a423848ea0 Allow floating point values for SDL_HINT_JOYSTICK_HIDAPI_SWITCH_HOME_LED
This allows setting the brightness of the home LED on Nintendo Switch Pro controllers, in the range 0.0 - 1.0.

This can be updated at runtime by setting the hint dynamically.

Fixes https://github.com/libsdl-org/SDL/issues/3787
2022-07-25 11:26:18 -07:00
diddily 1e492b2f6d Improve behavior of SDL_events_need_periodic_poll() and SDL_events_need_polling()
SDL_events_need_periodic_poll() and SDL_events_need_polling() are intended to allow the event loop to update joysticks and/or sensors if needed, however those systems only update when the SDL_update_joysticks and/or SDL_update_sensors variables are true. This change brings the behavior of these functions in line with if work will actually need to be performed.

This change allows the hints for AUTO_UPDATE to influence the polling behavior of the event loop such that an app can choose to update joysticks/sensors itself and avoid the expense of constantly sleeping and waking the event loop. Additionally in makes these functions marginally faster in some situations by not searching the active events.
2022-07-25 09:00:31 -07:00
diddily d9bda89fce Fix updating SDL_update_joysticks and SDL_update_sensors in response to hint changes
Hint callbacks are called before the actual value in the hint is changed, so the functions SDL_AutoUpdateJoysticksChanged and SDL_AutoUpdateSensorsChanged were not actually properly updating their respective variables in repsonse to their auto update hint changing.

Instead, we pull the new hint value out of the value passed into the callback and use that to update the variables. Assume true on a null value as that was the previous behavior and it matches with the default values of SDL_update_joysticks/SDL_update_sensors.
2022-07-25 09:00:31 -07:00
diddily 0ec5bb4e6d Add missing controller events to `SDL_GameControllerEventState()`
Events to handle controller touchpads and sensors were added to the library but not added in `SDL_GameControllerEventState()`. This change adds the missing events.
2022-07-25 08:55:17 -07:00
Sam Lantinga 4d66501736 Fixed building with 10.9 SDK
Fixes https://github.com/libsdl-org/SDL/issues/5954
2022-07-24 18:04:26 -07:00
Cameron Gutman 3ab1e303ec joystick: Refactor and fix a few bugs in Shield HIDAPI driver
- CMD_CHARGE_STATE was checking the seqnum instead of the payload
- Off-by-one error in size validation for command payload
- Unused payload space was left uninitialized in output report
2022-07-24 15:36:30 -05:00
Sam Lantinga 4d8bb89c46 Fixed mouse clip rect bounds on Windows
Fixes https://github.com/libsdl-org/SDL/issues/5946
2022-07-24 11:50:14 -07:00
Dean Herbert 6bcde52d88 Further adjust implementation of `Cocoa_GetWindowDisplayIndex`
As discussed in PR review, there may be an off-chance that the index
returned doesn't match up with SDL's display indexing.

This change ensures that the indices match and adds a safety check for
off-screen windows.
2022-07-24 09:25:16 -07:00
Dean Herbert ce8aae1419 Fix `Cocoa_GetWindowDisplayIndex` failing and causing a catastrophic crash
With the introduction of this function, it is possible that for certain
monitor and window configurations, creating an SDL window will cause a
native crash.

```
Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000050
Exception Codes:       0x0000000000000001, 0x0000000000000050
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [56627]

VM Region Info: 0x50 is not in any region.  Bytes before following region: 140737486737328
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->
      VM_ALLOCATE              7fffffe75000-7fffffe76000 [    4K] r-x/r-x SM=ALI

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libSDL2.dylib                            0x10247f665 SDL_UpdateFullscreenMode + 357
1   libSDL2.dylib                            0x10247ec70 SDL_CreateWindow_REAL + 1504
2   ???                                      0x111262de8 ???
3   ???                                      0x110c39fff ???
4   libcoreclr.dylib                         0x101fdf2a9 CallDescrWorkerInternal + 124
```

Tracking thread from our end: https://github.com/ppy/osu-framework/issues/5190
Regressed with: https://github.com/libsdl-org/SDL/pull/5573

In testing, the window would not find a valid screen if created
"hanging" off a primary display with a secondary display below it. In
checking why this was the case, the `display_centre` was being
calculated with a negative y origin, causing a final negative value
falling outside all display bounds:

```
SDL error log [debug]: display_centre.y = -1296 + 1296 / 2

SDL error log [debug]: Display rect 0: 0 0 2560 1440
SDL error log [debug]: Display rect 1: 2560 -625 1080 2560
SDL error log [debug]: Display rect 2: 0 1440 1728 1296
```

The method that was being used to find the current window using the frame
origin/size seems unreliable, so I have opted to replace it with with a
tried method (https://stackoverflow.com/a/40891902).

Initial testing shows that this works with non-standard DPI screens, but
further testing would be appreciated (cc @sezero / @misl6 from the
original PR thread).
2022-07-24 09:25:16 -07:00