Commit Graph

6885 Commits (a2b2464b46c62b87e669d88268c7a31439eb676d)

Author SHA1 Message Date
Frank Praznik a7d345958d wayland: Trigger a commit on fullscreen update
If additional fullscreen requests are received when the window is already fullscreen, it is typically due to the fullscreen flags or emulated video mode being changed. A commit must be explicitly triggered or the requested changes won't take effect until some other event, such as a resize or focus change, causes the changes to be committed.
2022-09-09 08:17:27 -07:00
Frank Praznik 707b561f97 wayland: Enable compositor fullscreen toggling
The compositor can toggle the fullscreen state (via a hotkey or otherwise), so the internal SDL state must be updated accordingly when it does.

When toggling fullscreen via the compositor, SDL will attempt to use the last fullscreen flag explicitly set. If no flag was previously set, SDL_WINDOW_FULLSCREEN will be used if a window video mode was set, otherwise SDL_WINDOW_FULLSCREEN_DESKTOP will be used. If the previous flag was SDL_WINDOW_FULLSCREEN and the window video mode was cleared, it will revert to SDL_WINDOW_FULLSCREEN_DESKTOP.
2022-09-09 08:17:27 -07:00
Frank Praznik 31979e2d98 wayland: Add missing static qualifiers 2022-09-09 08:17:27 -07:00
Taiko2k 1c88a0522f Update Wayland cursors to match X11 cursors 2022-09-09 08:59:37 -04:00
Sam Lantinga 9f4baeea53 Clean up thread local storage when quitting SDL
SDL_Quit() should be the last SDL API that you call before exiting your application, and is intended to clean up all internal state.

If real-life applications are relying on thread-local storage after SDL_Quit() we could potentially add a hint to control this behavior.

Fixes https://github.com/libsdl-org/SDL/issues/6200
2022-09-08 20:08:20 -07:00
Sam Lantinga a3900a751e Lock joysticks when removing a controller on the WGI thread 2022-09-08 13:59:25 -07:00
Sam Lantinga 12413ab31f Lock joysticks while attaching a virtual one 2022-09-08 13:33:21 -07:00
Ozkan Sezer 787cd580ee silence unused function warning for SDL_endswith() on non-linux. 2022-09-08 23:00:04 +03:00
Sam Lantinga 4071573241 Don't try to second guess DS4Windows, let it remap things as expected.
DS4Windows can create both emulated Xbox and emulated PS4 controllers, and we don't know which the user has it doing, so don't try to second guess it, just let it do it's thing. Users should follow the remapping software recommendations on when to enable/disable it for various situations.

Fixes https://github.com/libsdl-org/SDL/issues/6167
2022-09-08 11:50:56 -07:00
Sam Lantinga a0f169603d Fixed the CRC in the mappings for PS2, PSP, and Vita controllers 2022-09-08 09:53:51 -07:00
Sylvain 90a480a100
Fixed bug #6199 - Broken clip behaviour on a render target (metal) 2022-09-08 05:44:39 +02:00
Sam Lantinga 0ad8d9d292 SDL_IsXInputDevice() shouldn't return true if XInput isn't enabled 2022-09-07 15:31:24 -07:00
Sam Lantinga d93f9a778b The new Wii Remote shares the same VID/PID as the Wii U Pro controller 2022-09-07 12:33:43 -07:00
Sam Lantinga f398d8a424 Note that the Logitech Extreme 3D is a flight stick 2022-09-07 11:53:13 -07:00
Sam Lantinga 0a05b281f2 Make sure we hold the joystick lock when updating the device state while opening it 2022-09-07 11:51:51 -07:00
Sam Lantinga d4e0d27c1c Added Wii Remote controller mappings for Linux 2022-09-07 02:02:04 -07:00
Sam Lantinga 42cf6d6c56 Don't treat the Wii extension controls as a separate game controller on Linux 2022-09-07 01:41:11 -07:00
Sam Lantinga 87f8b6ff0f Don't mess with the state of the Motion Plus extension on Linux 2022-09-07 01:21:01 -07:00
Sam Lantinga c28da4892a Fixed build 2022-09-07 00:52:40 -07:00
Sam Lantinga 638452ecf7 Assert that continuous reporting is enabled, so input timeout is a reliable way of detecting Bluetooth connection problems. 2022-09-07 00:44:13 -07:00
Sam Lantinga 8dfe0e4beb Removed checks not needed for the Wii U Pro Controller 2022-09-07 00:41:29 -07:00
Sam Lantinga 4018f35ef2 Added left and right sensors for Nintendo Joy-Con and Wii controllers 2022-09-07 00:00:27 -07:00
Sam Lantinga 30f55a5d59 Added initial support for the Wii Motion Plus extension
This adds a gyro sensor to the Wii controller, and is enabled in standalone and nunchuk mode
2022-09-06 23:33:55 -07:00
Sam Lantinga 29f4a5ba0e Add GLES2 shader prologue infrastructure. (by @eloj)
There is supposedly an OpenGL ES2 target that does not support precision specifiers. However, the existing logic to detect this is currently broken in two ways:

1) There's a typo of the `#ifdef` as `#if`.
2) Checking for `GL_FRAGMENT_PRECISION_HIGH` can not be the correct way to detect this platform. Other targets, including some desktops, will also not have this defined (for various reasons).

Because some of the shader code is missing precision specifiers, and because a default is ONLY provided if `GL_FRAGMENT_PRECISION_HIGH` is set, these other targets break.

Instead of 'hard-coding' the prologue string into shaders in the C source, use our ability to provide a list of strings to `glShaderSource` instead, leaving the determination to run-time.

This commit closes https://github.com/libsdl-org/SDL/pull/6182
2022-09-06 15:55:27 -07:00
Sam Lantinga 4fd6bba257 Refactored for similarity to surrounding code 2022-09-06 12:29:42 -07:00
Ozkan Sezer 5ffede35d9 Fix https://github.com/libsdl-org/SDL/issues/6191 2022-09-06 19:56:29 +03:00
Cameron Cawley 10e1ef00e2 Fix compatibility with Windows XP 2022-09-06 08:55:35 -04:00
Sam Lantinga d1fea10c0f Added support for the accelerometer in the Wii Remote 2022-09-05 16:08:15 -07:00
Sam Lantinga a61b823da8 Added support for the Wii Remote with the Classic Controller Pro extension
Also changed event order to: buttons, triggers, axes, for consistency with other drivers
2022-09-05 14:32:45 -07:00
Ozkan Sezer 612a86ebad HIDAPI_DriverPS3_UpdateEffects: kill bad use of & operator on effects[] 2022-09-05 20:47:00 +03:00
Sam Lantinga b00e1b1b62 Added support for a ShanWan PS2 -> PS3 USB converter to the HIDAPI driver 2022-09-05 10:01:51 -07:00
Cameron Cawley fd93f817ba Assume that stdint.h is available on Windows with compilers other than MSVC <= 2008 2022-09-05 09:01:31 -07:00
Sylvain 03485db0a3
Android: understand HAL_PIXEL_FORMAT_BGR_565 as a returned value from ANativeWindow_getFormat() (see #6016) 2022-09-03 23:40:14 +02:00
Sam Lantinga 1b4e08b89e Added an entry for the Hori Fighting Stick mini 4 kai
This is a PS3/PS4 arcade stick which becomes an Xbox 360 controller on PC
2022-09-02 17:04:53 -07:00
Sam Lantinga 47f2373dc1 Added locking for Android joystick events 2022-09-02 16:52:55 -07:00
Sam Lantinga e8f6b7503a Added mappings for the ASUS ROG Kunai 3 Gamepad 2022-09-02 15:06:13 -07:00
Sam Lantinga 5770e87cb2 Fixed regression handling touchpad input with PS5 controllers using the original shipping firmware 2022-09-02 13:57:59 -07:00
Sam Lantinga 253f6a913d Variable renaming for consistency 2022-09-02 11:49:06 -07:00
Sam Lantinga 5002624e8a Fixed crash when extension controllers are hotplugged 2022-09-02 11:41:19 -07:00
Sam Lantinga 7df571ffc6 HIDAPI_DumpPacket() takes a const memory pointer 2022-09-02 11:37:16 -07:00
Sam Lantinga b6d23d21db Fixed interactions with the Linux Wiimote driver 2022-09-02 11:21:51 -07:00
Ozkan Sezer 0c984360d1 SDL_hidapi_wii.c: fix a -Wshadow warning 2022-09-02 20:02:56 +03:00
Sam Lantinga b6b3fb0023 This was intended to be Uint8 2022-09-02 09:59:32 -07:00
Ozkan Sezer 5be157b3a2 SDL_hidapi_wii.c: fix -Wpointer-sign warnings 2022-09-02 19:33:40 +03:00
Sam Lantinga 54356f41a9 Wii: fixed trigger axis reporting for the Wii U Pro Controller 2022-09-02 09:03:44 -07:00
Sam Lantinga a35642fa3e Wii: don't bother reading the extension type for the Wii U Pro controller, we already know what it is 2022-09-02 08:58:52 -07:00
Sam Lantinga c3ecb9d099 Wii: re-request the status if we get a communication error 2022-09-02 08:58:52 -07:00
Ozkan Sezer 0c24b46e9f SDL_hidapi_wii.c: fix build in c89 mode. 2022-09-02 18:55:00 +03:00
Sam Lantinga 9874fc4e6a Reconnect as a different controller if the Wii extension hardware changes 2022-09-02 08:47:15 -07:00
Sam Lantinga 5f3cb54972 Updated Wii support with @tellowkrinkle's changes in 2f288e9d5b 2022-09-02 08:28:28 -07:00
Sam Lantinga 785d784a93 Set the output value for ParseExtensionResponse() in all return cases 2022-09-01 22:30:05 -07:00
Sam Lantinga 046aaa2d21 Use auto calibration for the Wii Nunchuk thumbstick axis values 2022-09-01 21:37:26 -07:00
Sam Lantinga 8381e008ea Handle hotplugging of Wii controller extensions 2022-09-01 21:13:16 -07:00
Sam Lantinga 396411c090 Added mapping for the Wii Nunchuk extension 2022-09-01 20:27:34 -07:00
Sam Lantinga e19b36d871 Initial support for the Wii Remote with Nunchuk extension 2022-09-01 19:29:20 -07:00
Sam Lantinga c887cb02af Added the hint SDL_HINT_JOYSTICK_HIDAPI_WII_PLAYER_LED to control whether the player LED should be lit on the Nintendo Wii controllers
Also fixed the Y axes on the Wii U Pro controller, and various formatting cleanup
2022-09-01 16:30:55 -07:00
Ozkan Sezer 0ffaf5b871 SDL_hidapi_wii.c: fix build in c89 mode and builds using watcom compiler 2022-09-02 02:04:20 +03:00
Sam Lantinga c72e14e8f4 Added initial support for Wii controllers (thanks @tellowkrinkle!) 2022-09-01 15:29:41 -07:00
Ozkan Sezer 2847696338 hidapi: really fix dynamic / non-dynamic libusb loading. 2022-09-01 22:55:00 +03:00
Ozkan Sezer 9d77945d36 fixed linkage libusb not dynamicaly loaded after commit 3f89d1704d
build/.libs/SDL_hidapi.o: In function `SDL_EnableGameCubeAdaptors':
src/hidapi/SDL_hidapi.c:1593: undefined reference to `libusb_init'
src/hidapi/SDL_hidapi.c:1594: undefined reference to `libusb_get_device_list'
src/hidapi/SDL_hidapi.c:1596: undefined reference to `libusb_get_device_descriptor'
src/hidapi/SDL_hidapi.c:1604: undefined reference to `libusb_open'
src/hidapi/SDL_hidapi.c:1608: undefined reference to `libusb_kernel_driver_active'
src/hidapi/SDL_hidapi.c:1614: undefined reference to `libusb_claim_interface'
src/hidapi/SDL_hidapi.c:1623: undefined reference to `libusb_close'
src/hidapi/SDL_hidapi.c:1626: undefined reference to `libusb_free_device_list'
src/hidapi/SDL_hidapi.c:1628: undefined reference to `libusb_exit'
src/hidapi/SDL_hidapi.c:1609: undefined reference to `libusb_detach_kernel_driver'
src/hidapi/SDL_hidapi.c:1620: undefined reference to `libusb_attach_kernel_driver'
src/hidapi/SDL_hidapi.c:1615: undefined reference to `libusb_control_transfer'
src/hidapi/SDL_hidapi.c:1616: undefined reference to `libusb_release_interface'
build/.libs/SDL_hidapi.o: In function `SDL_hid_init_REAL':
src/hidapi/SDL_hidapi.c:1086: undefined reference to `libusb_init'
src/hidapi/SDL_hidapi.c:1087: undefined reference to `libusb_exit'
src/hidapi/SDL_hidapi.c:1088: undefined reference to `libusb_get_device_list'
src/hidapi/SDL_hidapi.c:1089: undefined reference to `libusb_free_device_list'
src/hidapi/SDL_hidapi.c:1090: undefined reference to `libusb_get_device_descriptor'
src/hidapi/SDL_hidapi.c:1091: undefined reference to `libusb_get_active_config_descriptor'
src/hidapi/SDL_hidapi.c:1092: undefined reference to `libusb_get_config_descriptor'
src/hidapi/SDL_hidapi.c:1093: undefined reference to `libusb_free_config_descriptor'
src/hidapi/SDL_hidapi.c:1094: undefined reference to `libusb_get_bus_number'
src/hidapi/SDL_hidapi.c:1095: undefined reference to `libusb_get_device_address'
src/hidapi/SDL_hidapi.c:1096: undefined reference to `libusb_open'
src/hidapi/SDL_hidapi.c:1097: undefined reference to `libusb_close'
src/hidapi/SDL_hidapi.c:1098: undefined reference to `libusb_claim_interface'
src/hidapi/SDL_hidapi.c:1099: undefined reference to `libusb_release_interface'
src/hidapi/SDL_hidapi.c:1100: undefined reference to `libusb_kernel_driver_active'
src/hidapi/SDL_hidapi.c:1101: undefined reference to `libusb_detach_kernel_driver'
src/hidapi/SDL_hidapi.c:1102: undefined reference to `libusb_attach_kernel_driver'
src/hidapi/SDL_hidapi.c:1103: undefined reference to `libusb_set_interface_alt_setting'
src/hidapi/SDL_hidapi.c:1104: undefined reference to `libusb_alloc_transfer'
src/hidapi/SDL_hidapi.c:1105: undefined reference to `libusb_submit_transfer'
src/hidapi/SDL_hidapi.c:1106: undefined reference to `libusb_cancel_transfer'
src/hidapi/SDL_hidapi.c:1107: undefined reference to `libusb_free_transfer'
src/hidapi/SDL_hidapi.c:1108: undefined reference to `libusb_control_transfer'
src/hidapi/SDL_hidapi.c:1109: undefined reference to `libusb_interrupt_transfer'
src/hidapi/SDL_hidapi.c:1110: undefined reference to `libusb_handle_events'
src/hidapi/SDL_hidapi.c:1111: undefined reference to `libusb_handle_events_completed'
collect2: ld returned 1 exit status
2022-09-01 21:56:50 +03:00
Sam Lantinga 3f89d1704d Fixed building with libusb not dynamicaly loaded 2022-09-01 11:30:02 -07:00
Sam Lantinga 7708bf0f8a Try matching game controller mappings on CRC and version and fall back to no CRC and no version, in that order.
We do exact match when adding mappings, but loose matching everywhere else we look up a mapping for a GUID.
2022-09-01 08:18:58 -07:00
Sam Lantinga 7861f924ea Removed debug print statements 2022-08-31 13:34:43 -07:00
Sam Lantinga 62f2379e4c Try up to 20 times to read the controller type
It takes a while for Joy-Cons to initialize when plugged in via the Nintendo Joy-Con Charging Grip.
2022-08-31 13:24:23 -07:00
Sam Lantinga e5f161bda4 Restored accidentally removed code to guess XInput device 2022-08-30 19:12:22 -07:00
Ozkan Sezer 973a677a2d SDL_xinputjoystick.c: commented out GuessXInputDevice()
Not used since commit 277b033e78.
2022-08-31 02:32:28 +03:00
Shawn Hoffman 42d09a8f42 wgi: refcount the delegate objects 2022-08-30 15:01:31 -07:00
Shawn Hoffman ca915b1884 WGI_JoystickUpdate: bounds-check array sizes 2022-08-30 14:59:38 -07:00
Sam Lantinga cdaafcec0d The Kinvoca Joy-Cons are handled by the Joy-Con driver, not the Switch Pro driver. 2022-08-30 14:56:11 -07:00
Sam Lantinga b2c3237b75 Added support for the Kinvoca Joy-Cons
These report their VID/PID as a Nintendo Switch Pro controller, but they are actually left/right Joy-Cons. We'll fix up the joystick GUID so applications can handle them appropriately.
2022-08-30 14:14:38 -07:00
Sam Lantinga 92d3fc4883 Fixed deadlock when shutting down the Windows joystick system 2022-08-30 12:59:02 -07:00
Brad Smith 371735e95b Silence unused variable warning
SDL_x11dyn.c:123:17: warning: unused variable 'i' [-Wunused-variable]
            int i;
                ^
2022-08-30 12:52:01 -07:00
Sam Lantinga 0e4baf1c4e Don't crash if SDL functions are passed a closed joystick or gamecontroller 2022-08-30 12:39:23 -07:00
Sam Lantinga 675d90c708 Revert "wgi: refcount the delegate objects"
This reverts commit ff233fe306.

This doesn't compile cleanly with Visual Studio and I don't want to introduce any subtle issues because we're passing the wrong types of pointers to WGI functions.
2022-08-30 12:09:57 -07:00
Sam Lantinga 40bd4feedc Revamped joystick locking
This makes the joystick locking more robust by holding the lock while updating joysticks.

The lock should be held when calling any SDL joystick function on a different thread than the one calling SDL_PumpEvents() and SDL_JoystickUpdate().

It is now possible to hold the lock while reinitializing the joystick subsystem, however any open joysticks will become invalid and potentially cause crashes if used afterwards.

Fixes https://github.com/libsdl-org/SDL/issues/6063
2022-08-30 11:42:13 -07:00
Shawn Hoffman ff233fe306 wgi: refcount the delegate objects
assert if calls become unbalanced.
2022-08-30 10:48:10 -07:00
Francisco Javier Trujillo Mata f1e4685806 Adding specific SDL_Hint for the dynamic VSYNC 2022-08-30 07:20:36 -04:00
Sam Lantinga 2f08bf2313 Added the share button to the Linux mapping for the third party Nintendo Switch Pro controllers 2022-08-29 22:15:35 -07:00
Sam Lantinga b2ac758f61 Added support for the Hori Fighting Stick Alpha to the HIDAPI driver 2022-08-29 17:33:00 -07:00
Ludovico de Nittis 3c78ba570b dbus: Use xdg-desktop-portal Inhibit when running under Flatpak or Snap
In order to inhibit the screen saver, SDL currently uses
`org.freedesktop.ScreenSaver.Inhibit()` and, as a fallback, a protocol
specific method for X11 or Wayland.

Accessing `org.freedesktop.ScreenSaver` is usually not allowed when
inside a sandbox like Flatpak, unless the permission has been explicitly
granted to the application.

Another issue is that the Wayland protocol "Idle inhibit" is relatively
new and not yet widely adopted. For example Mutter still doesn't support
it.

For those reasons, when running under Flatpak or Snap, we should try to
inhibit the screen saver by using xdg-desktop-portal instead. This
should give us an higher chance of success.

Fixes: https://github.com/libsdl-org/SDL/issues/6075

Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
2022-08-29 06:30:40 -07:00
Ludovico de Nittis e8cb4da71f Add utility function to detect if SDL is inside a sandbox
Refactor the previous sandbox check in a standalone function that also
includes Snap support.

Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
2022-08-29 06:30:40 -07:00
Ludovico de Nittis a3ce700ded dbus: Add generic internal function to send messages with reply
SDL_DBus_CallWithBasicReply() allows us to send a DBus message and get
its result, if it is a basic type, e.g. integer or string.

With this function we avoid duplicating code.

Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
2022-08-29 06:30:40 -07:00
Sam Lantinga 1153aaae0d Fixed compiling with USB_GET_DEVICEINFO on DragonFly BSD
Although the ioctl() currently fails on this platform...
2022-08-29 00:15:56 -07:00
Sam Lantinga 57cbec1095 Added controller mappings for Xbox 360, PS4, and PS5 controllers on OpenBSD
Removed the axis flipping hack for Xbox controllers which would actually apply to any controller with a full 16-bit range.

Fixes https://github.com/libsdl-org/SDL/issues/6143
2022-08-28 23:18:40 -07:00
Sam Lantinga 0b8b321f9e Allow the product version to be different when trying to find a controller mapping
This is in the hope that revving the product version doesn't change the mapping, which is the case for some devices. In cases where it does, we just need to provide a mapping for each version of the product.
2022-08-28 23:01:30 -07:00
Sam Lantinga 761b9d1e49 Use the HID usage for the button as the button number 2022-08-28 22:33:17 -07:00
Sam Lantinga a9d3935a84 Improved code to get the name and guid for joysticks on OpenBSD and NetBSD
Also dynamically allocate joysticks to reduce static memory usage
2022-08-28 18:20:54 -07:00
Sam Lantinga 32700294e2 Don't crash if SDL_CreateJoystickGUID() is passed a NULL name 2022-08-28 18:20:54 -07:00
Sam Lantinga bac8df4abd Fixed memory leak when out of memory 2022-08-28 18:20:54 -07:00
Sam Lantinga ffbad3617c Use the correct type for the device_instance 2022-08-28 18:20:54 -07:00
Sam Lantinga 4a800ae149 Created a consolidated define enabling BSD gameport joystick support 2022-08-28 18:20:54 -07:00
Sam Lantinga 42f90c6292 Removed unused path variable 2022-08-28 18:20:54 -07:00
Cameron Gutman b7c1fbf9f0 WGI: Fix a couple of reference leaks 2022-08-28 17:38:02 -05:00
Sam Lantinga 0db1813049 Applied OpenBSD patch
http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/ports/devel/sdl2/patches/patch-src_joystick_bsd_SDL_bsdjoystick_c?rev=1.5&content-type=text/plain&hideattic=1
2022-08-28 07:27:01 -07:00
Mathieu Eyraud b8af865f18 Fix candidate list size for Windows IME
Adjust candidate count so list is not draw bigger that needed. This also fix potential uninitialised read of variable `candsize[i]` if `vertical` is false.
2022-08-28 06:27:24 -07:00
Sam Lantinga 3cbfd75d0f Re-added the CRC to the joystick guid
This is now used as a crc field in the mapping rather than directly in mapping guids, for better mapping compatibility between versions of SDL.

Added SDL_GetJoystickGUIDInfo() to get device information encoded in a joystick GUID, so that mapping programs can clear the CRC from the GUID when generating mappings.

sort_controllers.py has been updated to extract the CRC from mappings created by older mapping programs and convert it into the new crc field. It will also take the CRC into account when checking for duplicate mappings.

Also regenerated the GUIDs for the PS2/PSP/Vita controller mappings, fixing https://github.com/libsdl-org/SDL/issues/6151
2022-08-27 19:00:31 -07:00
Francisco Javier Trujillo Mata b9e3cae572 Add more valid configurations to PS2 audio driver 2022-08-27 18:34:33 -07:00
Sam Lantinga b188a916ff Fixed uhid device name for non-OpenBSD platforms 2022-08-27 09:46:28 -07:00
Brad Smith 3f93ec470a Add support for OpenBSD's ujoy(4) 2022-08-27 09:45:08 -07:00
Sam Lantinga 9a01eac57d Temporarily disable joystick GUID CRCs 2022-08-26 13:45:05 -07:00
Charlie Birks d75fb0995d emscripten: Add a hint for specifying the canvas selector
Now that we're not going through EGL, this is easy
2022-08-26 15:20:24 +01:00
Charlie Birks b5aedaad59 emscripten: Modify UpdateWindowFramebuffer
To work with multiple canvases
2022-08-26 15:20:24 +01:00
Charlie Birks 539efc1bba emscripten: Return an error for webgl context limitations 2022-08-26 15:18:22 +01:00
Charlie Birks eebbf3457c emscripten: Use emscripten_webgl_ API directly 2022-08-26 15:18:19 +01:00
Sam Lantinga f6c2c22d38 Don't try to use the charging port for the PowerA wireless controller as an input device 2022-08-25 22:25:25 -07:00
Sam Lantinga f1aa843415 Don't report rumble capability for Nintendo Online controllers 2022-08-25 21:51:43 -07:00
Steven Noonan 9ce9c2530a SDL_windowsmodes: fix WIN_GetDisplayNameVista source identifier number
This was getting the wrong monitor's name because the source identifier
was not being included in the DisplayConfigGetDeviceInfo request.
2022-08-25 18:44:46 -07:00
Anonymous Maarten ce227aa69e wayland: fix build with SDL_WAYLAND_SHARED=OFF/--enable-wayland-shared=no 2022-08-25 17:15:54 -07:00
Sam Lantinga 679582e702 Fixed crash if there are no devices available 2022-08-25 11:07:20 -07:00
DomGries 40b2499273 Fix building with SDL_DISABLE_WINDOWS_IME
Regression of f317d619cc (diff-bff8f3e638d51e86cb6f0f42e2c527549d649951b7aa5ec4a539e865a5b57027R398)
2022-08-25 06:59:24 -07:00
Sam Lantinga babaa7d2bd Fixed PS3 accelerometer values on little endian systems 2022-08-24 16:10:47 -07:00
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
Sebastian Krzyszkowiak 041666e6c3 video: wayland: Don't switch to libdecor path for borderless windows
We actually request CSD mode with xdg-decoration for borderless
windows, so we get what we wanted there and there's no point in going
into fallback paths.
2022-07-24 10:59:42 -04:00
Sebastian Krzyszkowiak 405d1f6598 video: wayland: Roundtrip after falling back to libdecor in xdg-decoration handler
Otherwise libdecor doesn't have a chance to acquire xdg-toplevel after
libdecor_new before we attempt to use it in Wayland_ShowWindow.

Fixes #5952
2022-07-24 10:57:51 -04:00
Ozkan Sezer 8c51cae784 audio/aaudio, audio/openslES: fix -Wdeclaration-after-statement errors
Fixes https://github.com/libsdl-org/SDL/issues/5950
2022-07-23 14:56:04 +03:00
slime 65647b3417 SDL_Render: use high precision texcoords in ES2 shaders, when possible
Fixes #5884
2022-07-22 19:03:53 -07:00
Sam Lantinga f9beef760a Added support for the Nintendo Switch Joy-Con Controllers on iOS and tvOS 16 2022-07-22 18:58:29 -07:00
Sam Lantinga aad7ef6eaf Added support for the Nintendo Switch Pro Controller on iOS and tvOS 16 2022-07-22 10:58:34 -07:00
Sam Lantinga 20f51b1fd7 Fixed crash if debug text wasn't drawn during a session 2022-07-22 10:58:29 -07:00
Ethan Lee f3008e4aab
audio: 3- and 5-channel formats are now supported 2022-07-20 19:08:31 -04:00
Ryan C. Gordon 45c3b59d4b audio: Turn off DEBUG_CONFIG logging again. 2022-07-20 18:41:53 -04:00
Ryan C. Gordon bec721f08a audio: Fixed dst pointer on channel conversions that grow in-place. 2022-07-20 18:41:53 -04:00
Ryan C. Gordon 9f56c7cf02 audio: Remove 5.1->X SIMD converters, add SSE mono->stereo.
The 5.1 versions didn't use the new algorithm, and making that new
algorithm work took so many permutes that it was significantly slower
than just using the scalar versions.

However, mono-to-stereo is an extremely common conversion, and it's
trivial to accelerate it with plain SSE, so that was added!
2022-07-20 18:41:53 -04:00
Ryan C. Gordon b83ae9f24c audio: Replaced some debug-printfs with debug-SDL_Logs. :) 2022-07-20 18:41:53 -04:00
Ryan C. Gordon 49ec8db5f8 audio: Generate the channel converter code from a program. 2022-07-20 18:41:53 -04:00
Ryan C. Gordon f06cc3e945 audio: "SL" means "surround left" not "side left", etc. 2022-07-20 18:41:53 -04:00
Ryan C. Gordon 5a0c819863 audio: Add channel convert filter _after_ choosing an SIMD version. 2022-07-20 18:41:53 -04:00
Ryan C. Gordon fe16084075 audio: LOG_DEBUG_CONVERT should use SDL_Log, not fprintf(stderr). 2022-07-20 18:41:53 -04:00
Ryan C. Gordon 257277903e audio: first attempt at rewriting the channel converters.
This is not ready for production use!
2022-07-20 18:41:53 -04:00
Sam Lantinga be3a945a8b Added support for the 8BitDo Ultimate Wired Controller for Xbox 2022-07-20 11:05:55 -07:00
Ozkan Sezer b700a32630 audio, pipewire: fix signatures of pw_get_library_version and pw_init.
Reference issue: https://github.com/libsdl-org/SDL/issues/5938
2022-07-20 07:01:10 +03:00
Ozkan Sezer 6e210d3797 audio, pipewire: pipewire_version_xx globals out of dynamic loading
Fixes build with --disable-pipewire-shared
Reference issue: https://github.com/libsdl-org/SDL/issues/5938
2022-07-20 07:01:10 +03:00
David Gow 78bad66773 video: wayland: Resize the window before sending the SDL_RESIZE event
Currently, the SDL_WINDOWEVENT_RESIZED event is sent before the actual
window is resized (and various internal state, such as the desired
GL/Vulkan backbuffer size, are updated). This makes sense, as SDL will
discard a no-op resize, which would be the case if we had resized before
sending the event (indeed, there are existing hacks to prevent this).

However, this means that SDL_{GL,Vulkan}_GetDrawableSize() will still
use the old size in the SDL_WINDOWEVENT_RESIZED handler. In the case of
SDL_Renderer, this means the drawable size it uses will be wrong, and
the viewport will get "updated" to the old value.

This then results in bug #5899.
2022-07-18 09:21:15 -07:00
Sam Lantinga 53e685168d Fixed declaration-after-statement warning 2022-07-18 07:31:23 -07:00
Sam Lantinga 6ad7fdecce Fixed infinite loop for values bigger than 0x40000000
Fixes https://github.com/libsdl-org/SDL/issues/5930
2022-07-18 07:26:29 -07:00
Sam Lantinga 2be9301410 Fixed comment (thanks @pionere!) 2022-07-18 07:18:56 -07:00
Sam Lantinga cef1514b01 Fixed some Xcode warnings 2022-07-17 09:07:04 -07:00
Sam Lantinga b299cb3d3c Added a utility function to calculate the next power of 2 for a value 2022-07-17 08:31:16 -07:00
Ethan Lee 90b86b132a audio: Handle non-power-of-two spec.samples when unsupported
Fixes #3685
2022-07-17 10:36:15 -04:00
Ethan Lee a09d62e4d8
directsound: Remove redundant SubFormat copy 2022-07-15 23:45:56 -04:00
Ethan Lee c5e408ae98 directsound: For channel counts > 2, generate a dwChannelMask for CreateSoundBuffer 2022-07-15 13:59:46 -04:00
Ethan Lee fff34f6304 windows: SDL_IMMDevice needed more deinit code from the Win32 path.
Fixes #5919
2022-07-15 09:49:29 -04:00
Frank Praznik 37aecda2c1 pipewire: Use PW_KEY_TARGET_OBJECT to specify stream connection nodes
Pipewire 0.3.44 introduced PW_KEY_TARGET_OBJECT, which is to be used to specify target connection nodes for streams.  This parameter takes either a node path (PW_KEY_NODE_NAME) or serial number (PW_KEY_OBJECT_SERIAL) to specify a target node.  The former is used in this case since the path is already being retrieved and stored for other purposes.

The target_id parameter in pw_stream_connect() is now deprecated and should always be PW_ID_ANY when PW_KEY_TARGET_OBJECT is used.
2022-07-14 12:23:50 -04:00
Ozkan Sezer 2201d80255 avoid -Werror=declaration-after-statement after last commit. 2022-07-14 02:40:00 +03:00
freebsd 24b3efd08d (OpenBSD) Exe Path: Use PWD instead of CWD and use CWD as fallback 2022-07-13 16:24:20 -07:00
Sam Lantinga 883409ea07 Added support for the misc1 button on the Nintendo Switch Pro Controller
when using hid_nintendo kernel driver
2022-07-13 11:26:42 -07:00
SuperSamus 9a4f200d44 gamecontrollerdb: Linux, add mappings for hid-nintendo driver and more
Taken from https://github.com/gabomdq/SDL_GameControllerDB/blob/master/gamecontrollerdb.txt
2022-07-13 11:23:15 -07:00
Sam Lantinga 06c7d22653 Added mappings for the HORI Fighting Stick mini 4 on Linux and macOS 2022-07-12 18:53:53 -07:00
Sam Lantinga e24b971a34 Added support for the NVIDIA Shield controller guide button 2022-07-12 17:53:03 -07:00
Cameron Gutman b321eae51a joystick: Fix spurious battery empty events when opening a Shield controller 2022-07-11 19:43:25 -05:00
Cameron Gutman a0d8848baa joystick: Plumb SDL_JoystickSendEffect() for the Shield HIDAPI driver
The effect data format consists of one command byte followed by zero or more
payload bytes.
2022-07-11 19:38:26 -05:00
Frank Praznik 36d8460c9e pipewire: Dynamically allocate the buffer for node strings
Calculate and allocate the buffer for the IO node name and path strings dynamically instead of using arbitrary sized static buffers.
2022-07-11 18:03:56 -04:00
Frank Praznik 996cea31ee pipewire: Update default audio devices during runtime
Make the default device metadata node persist for the lifetime of the hotplug loop so the default source/sink devices will be updated if they change during runtime.
2022-07-11 18:03:56 -04:00
Frank Praznik 60da11f0e2 pipewire: Remove deprecated configuration key
With Pipewire now requiring a minimum version 0.3.24, the PW_KEY_CONTEXT_PROFILE_MODULES value is no longer required for legacy compatability and can be safely removed.
2022-07-11 18:03:56 -04:00
Ozkan Sezer 4fa2653394 SDL_GetJoystickGUIDInfo: byte-swap vendor, product and version values.
Reference issue: https://github.com/libsdl-org/SDL/issues/5907
2022-07-12 00:55:00 +03:00
Ethan Lee ecfbdce64b pipewire: Require version 0.3.24 or newer at runtime 2022-07-11 13:34:35 -04:00
Ethan Lee 2f0816adb7 Add SDL_GetDefaultAudioInfo.
This API is supported on pipewire, pulseaudio, wasapi, and directsound.

Co-authored-by: Frank Praznik <frank.praznik@gmail.com>
2022-07-11 13:34:35 -04:00
Ethan Lee 15d0618083 SDL_IMMDevice: Fix a WASAPI-specific leak, clean up Add() 2022-07-11 12:54:34 -04:00
Ethan Lee ae105ae1c7 windows: Move IMMDevice work to common file, implement DirectSound enumeration support 2022-07-11 12:54:34 -04:00
Sam Lantinga 2373da5d94 Exposed SDL_ResetKeyboard() as a public function
This will be used by Source 2 titles to reset keyboard state before showing assertion dialogs
2022-07-11 09:49:00 -07:00
Cameron Gutman 6e712d2440 joystick: Add HIDAPI driver for NVIDIA SHIELD 2017 controller
Basic input already works using the OS HID driver, but this enables
force feedback and battery state reporting.
2022-07-10 10:53:26 -07:00
Cameron Gutman 3242265ff1 joystick: Fix endianness issues in Xbox HIDAPI drivers 2022-07-10 10:49:38 -07:00
Ozkan Sezer 2f21648528 SDL_os2video.c: silenced -Wempty-body warning, along with minor tidy-up. 2022-07-08 20:56:40 +03:00
285424336 4aad594a8b Update SDL_qsa_audio.c
Fix qnx platform compile error, change SDL_Bool to SDL_bool.
2022-07-08 12:15:00 +03:00
Eric Curtin c0eada2019
Fix assumption that DRI_DEVNAME begins at 0 (#5865)
* Fix assumption that DRI_DEVNAME begins at 0

The existing logic of the code was to count every possible entry in
KMSDRM_DRI_PATH. After this a for loop would start trying to open
filename0, filename1, filename2, etc. In recent Linux kernels (say
5.18) with simpledrm, the lowest KMSDRM_DRI_DEVNAME is often
/dev/dri/card1, rather than /dev/dri/card0, causing the code to fail
once /dev/dri/card0 has failed to open. Running:

modprobe foodrm && modprobe bardrm && rmmod foodrm

before you try to run an application with SDL KMSDRM would have also
made this fail.

* Various changes from review

- Removed newline and period from SDL error
- Explicitely compare memcmp to zero (also changed to SDL_memcmp)
- Changed memcpy to strncpy
- Less aggressive line wrapping

* Various changes from review

- strncpy to SDL_strlcpy
- removed size hardcodings for KMSDRM_DRI_PATHSIZE and
  KMSDRM_DRI_DEVNAMESIZE
- made all KMSDRM_DRI defines, run-time variables to reduce bugs caused
  by these defines being more build-time on Linux and more run-rime on
  OpenBSD
- renamed openbsd69orgreater variable to moderndri
- altered comment from "if on OpenBSD" to add difference in 6.9

* Various changes from review

- Use max size of destination, rather than max size of source
- Less hardcodings
2022-07-06 09:00:16 -07:00
Sam Lantinga adf3ce7c01 Don't drop mouse focus on WM_MOUSELEAVE if the mouse is in relative mode; mouse-level is not meaningful for that case.
Do drop mouse focus when keyboard focus is lost if the mouse is in relative mode.
2022-07-05 21:42:24 -07:00
Sam Lantinga 0253a45029 Fix format specifiers for WPARAM/LPARAM values, they are UINT_PTR. 2022-07-05 21:42:20 -07:00
Eddy Jansson ad0b91302d android: Add missing entries to SDL_category_prefixes table.
Add static assert so this shouldn't happen in the future.

Fixes #5883
2022-07-05 17:50:19 -07:00
Chris Mumford 98411c0d33 Added include: libkern/OSAtomic.h
When building on macOS without gcc (e.g. clang) where HAVE_GCC_ATOMICS
is not defined, `SDL_AtomicTryLock` will call
`OSAtomicCompareAndSwap32Barrier` which is not yet declared.
Including OSAtomic.h on OSX resolves this error/warning:

    SDL_spinlock.c:125:12: error: implicit declaration of function
      'OSAtomicCompareAndSwap32Barrier' is invalid in
      C99 [-Werror,-Wimplicit-function-declaration]
        return OSAtomicCompareAndSwap32Barrier(0, 1, lock);

This was reported in issue #3885 but marked Invalid and closed - possibly
because the default CMake build uses gcc instead of clang.
2022-07-05 07:50:57 -07:00
Ryan C. Gordon fdb86b8266
x11: Don't try to use XInput2 multitouch if not supported.
Fixes #5889.
2022-07-04 12:48:32 -04:00
rohlem b085c18251 make SDL_SetTextInputRect take a pointer to const
The documentation doesn't state that the argument is ever modified,
and no implementation does so currently.
This is a non-breaking change to guarantee as much to callers.
2022-07-04 09:38:01 -07:00
Dav999-v 51f75b8b30 Fix fallback implementations of SDL_strchr and SDL_strrchr for '\0'
strchr and strrchr return a pointer to the first/last occurrence of a
character in a string, or NULL if the character is not found. According
to the C standard, the final null terminator is part of the string, and
it should thus be possible to get a pointer to the final null with
these functions. The fallback implementations of SDL_strchr and
SDL_strrchr would always return NULL if trying to find '\0', and this
commit fixes that.
2022-07-04 11:10:26 -04:00
chalonverse 85bbf8eec9 Fixed coment after #endif 2022-07-03 15:22:30 -04:00
Francisco Javier Trujillo Mata 7d7c5b803c Improving mkdir creating parents folder 2022-07-03 09:23:34 -07:00
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
Sam Lantinga 89624485cc Updated the test bitmap font to cover the Latin-1 character set
Based on Marcel Sondaar's font8_8.asm, in the public domain
2022-07-01 13:32:56 -07:00
Sam Lantinga e9d5060c4c checkkeys will now render text that is input
Also added test functions for multi-line debug text display

Currently this only supports ASCII, as the font doesn't have the correct Latin-1 characters
2022-07-01 12:56:47 -07:00
Sam Lantinga bdbf90e3fc on-screen keyboard newline is reported as an Enter key 2022-07-01 09:17:30 -07:00
Sam Lantinga 7ac5d616f3 Fixed backspace being delivered after committed text on Android 12
Testing:
Enter "hello ", followed by "?" - the events generated are:
: commitText hello
: Key pressed :  scancode 11 = H, keycode 0x00000068 = H  modifiers: (none)
: Key released:  scancode 11 = H, keycode 0x00000068 = H  modifiers: (none)
: Key pressed :  scancode 8 = E, keycode 0x00000065 = E  modifiers: (none)
: Key released:  scancode 8 = E, keycode 0x00000065 = E  modifiers: (none)
: Key pressed :  scancode 15 = L, keycode 0x0000006C = L  modifiers: (none)
: Key released:  scancode 15 = L, keycode 0x0000006C = L  modifiers: (none)
: Key pressed :  scancode 15 = L, keycode 0x0000006C = L  modifiers: (none)
: Key released:  scancode 15 = L, keycode 0x0000006C = L  modifiers: (none)
: Key pressed :  scancode 18 = O, keycode 0x0000006F = O  modifiers: (none)
: Key released:  scancode 18 = O, keycode 0x0000006F = O  modifiers: (none)
: Key pressed :  scancode 44 = Space, keycode 0x00000020 = Space  modifiers: (none)
: Key released:  scancode 44 = Space, keycode 0x00000020 = Space  modifiers: (none)
: INPUT Text (\x68\x65\x6c\x6c\x6f\x20): "hello "
: finishComposingText
: deleteSurroundingText 1 / 0
: Key pressed :  scancode 42 = Backspace, keycode 0x00000008 = Backspace  modifiers: (none)
: Key released:  scancode 42 = Backspace, keycode 0x00000008 = Backspace  modifiers: (none)
: commitText ?
: Key pressed :  scancode 225 = Left Shift, keycode 0x400000E1 = Left Shift  modifiers: LSHIFT
: Key pressed :  scancode 56 = /, keycode 0x0000002F = /  modifiers: (none)
: Key released:  scancode 56 = /, keycode 0x0000002F = /  modifiers: (none)
: Key released:  scancode 225 = Left Shift, keycode 0x400000E1 = Left Shift  modifiers: (none)
: INPUT Text (\x3f): "?"
: setComposingText , at 1
: EDIT Text (): ""

Previously, the backspace would be delivered after the "?"
2022-07-01 08:58:08 -07:00
Cameron Cawley 78089e6598 Remove unused internal header SDL_sysevents.h 2022-07-01 07:39:48 -07:00
Cameron Gutman 3e114872e8 joystick: Fix redetection of HIDAPI joysticks after reinitializing
The HIDAPI joystick driver doesn't properly reset the change counter
it uses to track if re-enumeration is needed when the joystick
subsystem is quit and then reinitialized.

The first SDL_Init(SDL_INIT_JOYSTICK) will result in the expected
HIDAPI joysticks appearing, but subsequent calls will result in no
joysticks being enumerated until another HIDAPI joystick is added
or removed from the system.
2022-06-30 20:43:14 -07:00
chalonverse 4f73219794 Fixed D3D12 renderer not working with batching, and got rid of the vertex buffer size limit 2022-06-30 03:41:17 -07:00
Sam Lantinga 0ad65277ce Refactored code to send scancodes for an ASCII on-screen keyboard key 2022-06-29 17:26:09 -07:00
Francisco Javier Trujillo Mata a054a5f7f2 Improve SDL2 main, adding memory card and usb drivers 2022-06-29 03:15:00 +03:00
Jade Macho 6a2e6c82a0 Add SDL_HINT_DIRECTINPUT_ENABLED (on by default) 2022-06-28 15:59:05 -07:00
Sam Lantinga 1d1fb95a61 Removed double va_end() 2022-06-28 06:21:45 -07:00
Sylvain f815580dde
Fix SIGSEV in SDL_error. Re-apply same pattern on this uncompiled code (see #5795) 2022-06-28 13:09:38 +02:00
Sylvain d4e6047e3c
Fix SIGSEV in SDL_error (After removing the limit on the size of the SDL error message) (see #5795) 2022-06-28 09:46:12 +02:00
Sourcery AI cddf095a16 'Refactored by Sourcery' 2022-06-27 17:55:47 -07:00
Sam Lantinga b6f1c91862 Fixed Watcom C build 2022-06-27 17:44:55 -07:00
Sam Lantinga cbd0187475 Removed the limit on the size of the SDL error message
Also added SDL_GetOriginalMemoryFunctions()

Fixes https://github.com/libsdl-org/SDL/issues/5795
2022-06-27 16:59:50 -07:00
Pierre Wendling f25b4b2774 Style: Flip `if` statement. 2022-06-27 15:19:40 -07:00
Pierre Wendling 6c536afdb7 Fix C89 declaration for macOS modules.
Since Clang 14, `-Wdeclaration-after-statement` is enforced on every
standard.
2022-06-27 15:19:40 -07:00
Francisco Javier Trujillo Mata e4a8087551 Initial Audio driver 2022-06-27 15:18:48 -07:00
Brad Smith 9723917637 Use proper header for OpenBSD PPC CPU detection 2022-06-27 11:01:34 -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
Sylvain 314bb5a1ed
Fixed bug #5850: Android EGL_BAD_ACCESS because of viewport command while turning the screen off/on. 2022-06-27 14:45:14 +02:00
Francisco Javier Trujillo Mata 7fd46ec581 Initial PS2_Joystick implementation 2022-06-27 00:32:43 -07:00
Francisco Javier Trujillo Mata 84d69da4e1 Initial SDL_ps2_main implementation 2022-06-27 00:32:43 -07:00
Ivan Epifanov b2f07d94d2 Vita: create rendertarget color surface with same format as texture. Fixes #5844 2022-06-26 15:41:14 -07:00
unknown ebe4f47f2b Fixed __VA_ARGS__ in gcc when no args 2022-06-26 15:35:18 -07:00
unknown 51c6488f97 Add support for SDL_render_d3d12.c to compile in C++ mode 2022-06-26 15:35:18 -07:00
Francisco Javier Trujillo Mata 2b41f497db Improve Joystick removing semaphores 2022-06-22 15:08:41 +02:00
Francisco Javier Trujillo Mata c3a5e4aa7b Adding GetGamepadMapping to Vita Joystick driver 2022-06-22 02:23:00 +03:00
Ozkan Sezer 7adb08a79a fixed SDL_BlitMap typedef redefinition errors 2022-06-22 01:37:00 +03:00
Ryan C. Gordon 12b371ee0f
x11: Don't send diplay-add events for displays connected at init time.
Reference Issue #4977.
2022-06-21 14:49:21 -04:00
Frank Praznik c11bdeeb69 wayland: Round fractional backbuffer sizes halfway away from zero
Use SDL_lroundf() to round fractional backbuffer sizes halfway away from zero, as this is the rounding method recommended by the forthcoming Wayland fractional scaling protocol.
2022-06-21 14:01:29 -04:00
Pieter-Jan Briers 9914e87faa Also send DPI change when expected resize. 2022-06-20 06:54:40 -07:00
Pieter-Jan Briers af733c7a32 Fix DPI-raised SDL_WINDOWEVENT_SIZE_CHANGED with event callback.
Move the sending of this event down so stuff like calling SDL_GL_GetDrawableSize() from a callback reports the new size instead of the old one.
2022-06-20 06:54:40 -07:00
Ozkan Sezer 2316e5682e SDL_windows.h: match WINVER value to _WIN32_WINNT. 2022-06-19 08:33:28 -07:00
Ozkan Sezer 22a29321e9 tweak _WIN32_WINNT value for shellscalingapi.h present but no d3d12 2022-06-19 08:33:28 -07:00
Sam Lantinga abe38bca3e Support SDL_AUDIODRIVER set to "dsound", which was used by SDL 1.2
Fixes https://github.com/libsdl-org/SDL/issues/5818
2022-06-18 13:08:58 -07:00
Ozkan Sezer a8d41b3b45 check for shellscalingapi.h presence instead of WINVER >= 0x0603 2022-06-18 13:00:44 -07:00
Sam Lantinga 5f6d0abebe SDL_SendEditingText() has int parameters, so use that type for parameter calculation
We might want to use ssize_t as @Guldoman suggested, but that's a larger internal API change, and still requires casting of the SDL_utf8strnlen() result.

Fixes https://github.com/libsdl-org/SDL/pull/5821
2022-06-18 12:59:28 -07:00
Mathieu Eyraud 00b95e989b Fix read of uninitialised variable
If the condition (dbus->message_iter_get_arg_type(&sub) == DBUS_TYPE_STRING) is false, subtext is not initialised.
2022-06-18 18:23:50 +03:00
Sam Lantinga 12f14bdbeb Fixed digit count in sscanf, e.g. "%1x" 2022-06-18 07:02:38 -07:00
Sam Lantinga 53e307050b List the available tests if the filter didn't match 2022-06-18 06:52:16 -07:00
Sam Lantinga eb7e29a8b2 Fixed crash when the joystick product name isn't available 2022-06-17 17:43:14 -07:00
Sam Lantinga adc6875870 Added SDL_copyp to avoid size mismatch when copying values (thanks @1bsyl!)
Closes https://github.com/libsdl-org/SDL/pull/5811
2022-06-17 10:22:28 -07:00
Sam Lantinga b0e827fb65 Enable improved rumble emulation on DualSense(tm) Wireless Controllers with firmware version 2.24 and newer 2022-06-17 07:55:53 -07:00
Sam Lantinga 1eb247fa2e Fixed building D3D12 renderer with latest mingw-64 2022-06-16 15:44:18 -07:00
Sam Lantinga b004133f08 Updated to version 2.23.1 for pre-release checkpoint 2022-06-16 12:50:19 -07:00
Sam Lantinga a5949d7b03 Fixed crash on Windows
These functions really are WINAPI
2022-06-15 23:00:28 -07:00
Sam Lantinga 16f55fbdb4 Separate the controller protocol from the controller style
This allows us to handle controllers that use the Xbox protocol but look like Nintendo Switch or Playstation controllers, like the Qanba Dragon Arcade Stick in PC mode
2022-06-15 20:46:01 -07:00
Sam Lantinga 017e237005 Removed the Qanba Obsidian Arcade Joystick from the unknown controller list 2022-06-15 17:32:46 -07:00
Sam Lantinga a9cf313eef Added the Qanba Obsidian and Dragon Arcade Sticks to the arcade stick list 2022-06-15 17:28:29 -07:00
Sam Lantinga bfe81a0c05 Added the name of the Qanba Obsidian Arcade Joystick in PC mode 2022-06-15 17:28:20 -07:00
Sam Lantinga a6a2cdbd7c Added the name of the Qanba Dragon Arcade Joystick in PC mode 2022-06-15 17:28:18 -07:00
Francisco Javier Trujillo Mata 6b03c1adf6 Add filesystem driver 2022-06-15 15:15:26 -07:00
Francisco Javier Trujillo Mata 52f00833b0 Add Thread drivers 2022-06-15 15:15:26 -07:00
Francisco Javier Trujillo Mata 217d3a6dab Add systimer support 2022-06-15 15:15:26 -07:00
Francisco Javier Trujillo Mata 7343ece806 Define available PS2 RAM 2022-06-15 15:15:26 -07:00
Francisco Javier Trujillo Mata e4409f6733 Include SDL_Log driver 2022-06-15 15:15:26 -07:00
Francisco Javier Trujillo Mata f0a05ed476 Add some PS2 flags 2022-06-15 15:15:26 -07:00
Francisco Javier Trujillo Mata 273d9e4640 Fix atomic support for PS2 2022-06-15 15:15:26 -07:00
Anonymous Maarten ae7446a959 stlib: Extract SDL_memcpy and SDL_memset to its own file respectively
This is done such that we can disable LTO for these 2 functions when
building with MSVC.

This is due to a limitation of Link Time Code Generation (LTCG).
Code generation might generate a new reference to memset after linking
has started. The LTCG must make assumptions about where memset is
defined which is normally the C runtime.
2022-06-15 14:17:35 -07:00
Sam Lantinga a5d338bd2d Added support for the Qanba Dragon Arcade Joystick (PS3) on macOS 2022-06-15 14:11:00 -07:00
Sam Lantinga 7d7c48302b Use python3 for sort_controllers.py 2022-06-15 14:10:22 -07:00
Sam Lantinga 72fea0ed6f Added support for the Qanba Dragon Arcade Joystick 2022-06-15 13:58:28 -07:00
takase1121 f8ae3ef1eb wayland: use libdecor resize edge enums for libdecor 2022-06-15 10:21:18 -04:00
Ozkan Sezer 960b86dcb5 update SDL_render_d3d12.c after DPI scaling/highdpi support patch.
See https://github.com/libsdl-org/SDL/pull/5778#issuecomment-1153006938
2022-06-14 21:03:31 -07:00
Ryan C. Gordon ded6c22efb
render: Corrected wrong SDL_memcpy() sizes for viewport, cliprect.
Fixes #5786.
2022-06-14 14:10:14 -04:00
Frank Praznik e427e80bfe wayland: Use the output descriptions from xdg-output when available
Some compositors will provide 'nicer' / 'human readable' output descriptions via the xdg-output protocol. Use these description strings, when available, instead of the model name provided by wl-output.  On compositors such as GNOME where this is provided, the display names provided to applications by SDL will now match those in the desktop display settings panel.  On compositors where this data isn't provided, the old behavior of using the model string provided by wl-output will remain unchanged.

Additionally, per the protocol spec, output data provided by xdg-output should supersede wl-output data, so this is the recommended behavior in general.
2022-06-14 11:02:20 -04:00
Ozkan Sezer 714502d373 minor windows warning fixes. 2022-06-13 22:15:56 +03:00
Simon McVittie 507ce36d80 video: Note unused SDL_surface creation parameters for removal in SDL 3
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-13 11:53:53 -07:00
Simon McVittie 535fdc3adc video: Detect and reject nonsense SDL_surface dimensions
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-13 11:53:53 -07:00
Simon McVittie 8c9f7104e3 video: Harden calculation of SDL_surface pitch and size against overflow
If the width is sufficiently ludicrous, then the calculated pitch or
the image size could conceivably be a signed integer overflow, which
is undefined behaviour. Calculate in the unsigned size_t domain, with
overflow checks.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-13 11:53:53 -07:00
Simon McVittie 63b3b9a558 Fix some typos in diagnostic messages
Detected by Debian's packaging QA tool, Lintian.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-13 08:33:27 -07:00
Ryan C. Gordon 9a0367675f
windows: Get better name for the physical display, for Vista and later.
Fixes #5321.
2022-06-12 15:28:49 -04:00
Cameron Cawley fd8cafc72e Rename variables in SDL_egl.c to be more intuitive 2022-06-11 14:20:18 -07:00
Eric Wasylishen e09551bc80 Fix WinRT build 2022-06-11 14:19:01 -07:00
Eric Wasylishen ab81a559f4 Windows DPI scaling/highdpi support
Adds hint "SDL_WINDOWS_DPI_SCALING" which can be set to "1" to
change the SDL coordinate system units to be DPI-scaled points, rather
than pixels everywhere.

This means windows will be appropriately sized, even when created on
high-DPI displays with scaling.

e.g. requesting a 640x480 window from SDL, on a display with 125%
scaling in Windows display settings, will create a window with an
800x600 client area (in pixels).

Setting this to "1" implicitly requests process DPI awareness
(setting SDL_WINDOWS_DPI_AWARENESS is unnecessary),
and forces SDL_WINDOW_ALLOW_HIGHDPI on all windows.
2022-06-11 14:19:01 -07:00
Eric Wasylishen 448e05e3c8 add DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED define 2022-06-11 14:19:01 -07:00
Eric Wasylishen 1b797957c1 SDL_windowsvideo.c: add HIGHDPI_DEBUG ifdef, print DPI awareness at startup if defined
document some additional quirks
2022-06-11 14:19:01 -07:00
Eric Wasylishen 1488c40812 WM_DPICHANGED: remove some dead code, add comment 2022-06-11 14:19:01 -07:00
Eric Wasylishen 60ef11b3cb Fix Watcom compile errors 2022-06-11 14:19:01 -07:00
Eric Wasylishen d3b970d4d5 HighDPI: remove SWP_NOSIZE in WIN_SetWindowPosition
If the move results in a DPI change, we need to allow the window to resize (e.g. AdjustWindowRectExForDpi frame sizes are different).

- WM_DPICHANGED: Don't assume WM_GETDPISCALEDSIZE is always called for PMv2 awareness - it's only called during interactive dragging.

- WIN_AdjustWindowRectWithStyle: always calculate final window size including frame based on the destination rect,
not based on the current window DPI.

- Update wmmsg.h to include WM_GETDPISCALEDSIZE (for WMMSG_DEBUG)

- WIN_AdjustWindowRectWithStyle: add optional logging

- WM_GETMINMAXINFO: add optional HIGHDPI_DEBUG logging

- WM_DPICHANGED: fix potentially clobbering data->expected_resize

Together these changes fix the following scenario:
- launch testwm2 with the SDL_WINDOWS_DPI_AWARENESS=permonitorv2 environment variable
- Windows 10 21H2 (OS Build 19044.1706)
- Left (primary) monitor: 3840x2160, 125% scaling
- Right (secondary) monitor: 2560x1440, 100% scaling

- Alt+Enter, Alt+Enter (to enter + leave desktop fullscreen), Alt+Right (to move window to right monitor). Ensure the window client area stays 640x480. Drag the window back to the 125% monitor, ensure client area stays 640x480.
2022-06-11 14:19:01 -07:00
Eric Wasylishen 51ebefeeee Support PMv2 DPI awareness, add SDL_HINT_WINDOWS_DPI_AWARENESS
The hint allows setting a specific DPI awareness ("unaware", "system", "permonitor", "permonitorv2").

This is the first part of High-DPI support on Windows ( https://github.com/libsdl-org/SDL/issues/2119 ).
It doesn't implement a virtualized SDL coordinate system, which will be
addressed in a later commit. (This hint could be useful for SDL apps
that want 1 SDL unit = 1 pixel, though.)

Detecting and behaving correctly under per-monitor V2
(calling AdjustWindowRectExForDpi where needed) should fix the
following issues:

https://github.com/libsdl-org/SDL/issues/3286
https://github.com/libsdl-org/SDL/issues/4712
2022-06-11 14:19:01 -07:00
Cameron Gutman 81d3adddbf events: Fix spurious early returns from SDL_WaitEvent()/SDL_WaitEventTimeout()
Fixes #5780
2022-06-11 14:18:45 -07:00
Nhalrath b3260e7eb3 Remove macro definition for SDL_ERRBUFIZE
I was looking at how errors are handled by SDL and came across this #define SDL_ERRBUFIZE which looks like a typo for SDL_ERRBUFSIZE, but either way, it looks like this isn't being used anywhere anymore because it was getting reported whenever I compile SDL with -Wunused-macros, and the last time it was mentioned in the code was from commit 09ca66b.
2022-06-11 08:42:59 -07:00
Frank Praznik 4a3277b0f9 wayland: Always commit window constraints before entering fullscreen
XDG-toplevel min/max size values are double-buffered data and must be committed before entering the fullscreen state, or a max window size value smaller than the display dimensions may cause the compositor to incorrectly configure the fullscreen window size.  This fixes windowed->fullscreen transitions on GNOME, where, previously, certain combinations of window flags and min/max size values could cause entering fullscreen mode to fail with odd window sizes and/or offsets due to the new max size values not being committed before entering fullscreen, causing the compositor to clamp to the old values.

In the case of libdecor, it has its own layer of buffering on top of the xdg-toplevel surface for the min/max window dimensions, so both a frame commit and surface commit are required to set the state properly.
2022-06-10 14:24:12 -07:00
Frank Praznik 78698a0ba2 wayland: Use a separate frame callback for setting the surface damage region
Previously, the surface damage region was being set in the same callback used for preventing render hangs in the GL backend when the surface was not visible.  This was not ideal, as the callback was never fired in the case of using a different render backend or having a swap interval of 0.  Use a separate frame callback for setting the surface damage region to ensure that it fires reliably, regardless of the backend being used or swap interval.
2022-06-10 14:24:12 -07:00
Frank Praznik 146ea9b0e1 wayland: Only set the surface opaque region if EGL transparency is disabled
Check if the "SDL_VIDEO_EGL_ALLOW_TRANSPARENCY" hint is enabled and don't mark surfaces as opqaue if it is.
2022-06-10 14:24:12 -07:00
Frank Praznik a20516d4f3 wayland: Swap emulated mode dimensions in more cases
Some compositors (GNOME for example) don't set the transform flag when dealing with portrait mode displays, so the video modes won't have the width/height swapped in all cases where they should be.  Check for both the 90/270 degree transform flag and if the display is taller than it is wide when determining whether to swap the width and height of the emulated video modes, and adjust the comparison logic when size testing against the native mode to account for this.
2022-06-10 14:24:12 -07:00
Frank Praznik e1c8350439 wayland: Add a hint to disable video mode emulation under Wayland
Add the hint "SDL_VIDEO_WAYLAND_MODE_EMULATION", which can be used to disable mode emulation under Wayland. When disabled, only the desktop and/or native display resolution is exposed.
2022-06-10 14:24:12 -07:00
Frank Praznik e9d3dcea73 wayland: Unify integer and fractional output scaling
Previously, scale values used by the displays and surfaces were always integers, with fractional scale values only being calculated when the backbuffer and viewport sizes were being determined. Now, if xdg-output is available, the fractional scale of output displays is calculated when the displays are enumerated and the true scale values of the output devices are used whenever possible.

This unifies the integer and fractional scaling systems, allows for the use of more accurate scale values that minimize overdraw when windows straddle multiple outputs, and lays the groundwork for the pending Wayland scaling protocols that will report the preferred scale values per-surface instead of per-output.
2022-06-10 14:24:12 -07:00
Frank Praznik 4fde7dd830 wayland: Refactor the Wayland mode emulation and viewport logic
Compartmentalize the fullscreen mode emulation code blocks, unify the windowed/fullscreen viewport logic, consolidate all window geometry code into a central function to eliminate blocks of duplicate code and rename related variables and functions to more explicitly reflect their purpose.
2022-06-10 14:24:12 -07:00
Sam Lantinga ce5763230b The backlight event is "change", not "add" or "remove" 2022-06-10 12:42:45 -07:00
Sam Lantinga 68544be44b Added support for the Nintendo Online controllers 2022-06-10 11:31:59 -07:00
Ryan C. Gordon b75cd2b36d
x11: Force window back to expected size after SDL_SetWindowBordered.
This helps if the window manager decided to let it fill the space that
an existing border was using before its removal.

Fixes #5718.
2022-06-10 14:13:07 -04:00
Ozkan Sezer 51db775442 updated windows watcom exports file after last commit. 2022-06-10 06:23:20 +03:00
Sam Lantinga 9202df0472 Implemented SDL_GameControllerGetFirmwareVersion() for HIDAPI PS5 controllers 2022-06-09 18:11:34 -07:00
Guldoman e5a3acd6bd ime: fcitx: Retrieve cursor position and selection
Also, if `SDL_HINT_IME_SUPPORT_EXTENDED_TEXT` is enabled, make use of
`SDL_TEXTEDITING_EXT` by sending the full preedit string.
2022-06-09 15:18:50 -07:00
Guldoman dd7bed9ebc ime: ibus: Retrieve cursor position and selection
Also, if `SDL_HINT_IME_SUPPORT_EXTENDED_TEXT` is enabled, make use of
`SDL_TEXTEDITING_EXT` by sending the full preedit string.
2022-06-09 15:18:50 -07:00
Guldoman d11702ce29 ime: wayland: Make use of `SDL_TEXTEDITING_EXT`
Because we were sending multiple chunks of preedit strings,
`SDL_SendEditingText` was using the old `SDL_TEXTEDITING` event only.

Now if `SDL_HINT_IME_SUPPORT_EXTENDED_TEXT` is enabled, we send the full
string and correctly set the cursor position and selection size.
2022-06-09 15:18:50 -07:00
Guldoman 74bcc5a0a3 stdlib: Add `SDL_utf8strnlen` 2022-06-09 15:18:50 -07:00
Sam Lantinga c7f4103807 Special case for k_eControllerType_XInputSwitchController in the raw input path 2022-06-09 13:47:29 -07:00
Sam Lantinga e6cb082232 Fixed the default mapping on Windows for the HORI Fighting Commander 2022-06-09 13:20:38 -07:00
Cameron Cawley 0a93ac1294 Work around the lack of clock() on PS Vita 2022-06-09 11:07:06 -07:00
chalonverse 6f69bbc541 D3D11: Fix SDL_TEXTUREACCESS_TARGET not working if SDL_HAVE_YUV was 0
Added a couple of missing SDL_zeros in CreateTexture
2022-06-08 12:51:09 -07:00
chalonverse 8303c5d0a3 Added missing SDL_zero for renderTargetViewDesc 2022-06-08 12:51:09 -07:00
Sam Lantinga d58d637ac6 Added support for the Qanba Obsidian Arcade Joystick on Linux 2022-06-08 11:07:36 -07:00
Charlie Birks 0fcfaf9e94 emscripten: use MAIN_THREAD_EM_ASM for the fb/cursor proxying
This is how everything else was handled and fixes undefined symbol
errors in non-threads builds.
2022-06-08 08:09:46 -07:00
chalonverse 7a335df9cf Updated CMakeLists.txt and configure.asc/script so that it checks for the required Windows SDK version before it enables the d3d12 renderer. Also fixed reported warnings in some builds. 2022-06-07 17:07:33 -07:00
Sylvain 2cc2260435
Fixed bug #5768 - SDL_RenderGeometry's software backend failed to render when texture coordinates are reversed
handle flip vertical/horizontal when reconstructing rects from triangles
2022-06-07 16:30:01 +02:00
chalonverse 4082821822
DirectX 12 Renderer (#5761)
* DirectX 12 Renderer (27 squashed commits)

* Add missing SDL_hidapi.h of merge of SDL.vcxproj.filters

* Fixed OpenWatcom build failure

* Dynapi fix

Co-authored-by: Ryan C. Gordon <icculus@icculus.org>
2022-06-06 17:42:30 -07:00
Ozkan Sezer 63e12cf601 SDL_windows_main.c: replace CopyMemory() with SDL_memcpy() 2022-06-06 22:55:56 +03:00
Ryan C. Gordon ec0204d243
x11: Don't use GetXftDPI() when XRandR can tell us the DPI per-output.
Fixes #5764.
2022-06-06 14:39:58 -04:00
Ozkan Sezer 61115aebd3 update dynapi after the loongarch support patch 2022-06-06 19:29:56 +03:00
yuanhecai 50d8642fa3 Add optimiztion function with LSX in LoongArch
1. yuv420_rgb24_lsx
1. yuv420_rgba_lsx
2. yuv420_bgra_lsx
3. yuv420_argb_lsx
4. yuv420_abgr_lsx
2022-06-06 08:49:09 -07:00
yuanhecai 17f63e53f8 Add loongarch support
LSX and LASX are enabled by default if compiler supports them.
2022-06-06 08:49:09 -07:00
Ryan C. Gordon 9703f23663
SDL_SetHintWithPriority: actually, this test is good.
Otherwise, we end up calling the callback if both the old and new value
are NULL.

This reverts commit 5f25a6ea78 (and also
trims some whitespace).
2022-06-06 10:55:29 -04:00
Ryan C. Gordon 5f25a6ea78
Revert "SDL_SetHintWithPriority: better test if hint value has changed."
Actually, the original test was fine, disregard.

This reverts commit c391bdc160.
2022-06-06 09:36:20 -04:00
Ryan C. Gordon c391bdc160
SDL_SetHintWithPriority: better test if hint value has changed. 2022-06-06 09:31:35 -04:00
Ryan C. Gordon 55a07d91fa
SDL_SetHintWithPriority: Allow setting NULL hints.
Fixes #5120.
2022-06-06 09:30:43 -04:00
Ryan C. Gordon a236bf4f25
x11: Hook up display hotplug notifications.
Obviously this needs XRandR support.

Fixes #4977.
2022-06-06 02:13:37 -04:00
Ryan C. Gordon 6b4bd5a759
test_harness: Report if zero tests to run.
Fixes static analysis complain about a potential malloc(0) call.
2022-06-05 09:34:54 -04:00
Christoph Reichenbach 3a20274ddf Refactoring: move GUID operations out of Joystick
- SDL_JoystickGUID -> SDL_GUID (though we retain a type alias)
- Operations for GUID <-> String ops are now in
  src/SDL_guid.c and include/SDL_guid.h
- The corresponding Joystick operations delegate to SDL_guid.c
- Added test/testguid.c
2022-06-04 17:22:13 -07:00
Sam Lantinga 423141bfca Added a function to get the controller firmware version 2022-06-03 18:50:00 -07:00
Sam Lantinga 17410887d0 Separated controller type data into a C file 2022-06-03 15:03:08 -07:00
Sam Lantinga ae2cc29f8b Make sure initial state is set correctly for the D3D renderer
Fixes https://github.com/libsdl-org/SDL/issues/5749
2022-06-03 09:44:34 -07:00
David Gow 847539afeb wayland: Only call libdecor_dispatch() if we've loaded libdecor
As of #5703, we call libdecor_dispatch() in Wayland_WaitEventTimeout(),
but this will crash if we don't load libdecor, as
SDL_VideoData::shell.libdecor will be NULL.

Since we don't load libdecor if we don't intend to use it (i.e., if
should_use_libdecor returns false), this results in a crash under KDE in
almost all circumstances.
2022-06-01 08:32:13 -07:00
Sam Lantinga 7fa46ec40b The Google Pixel fingerprint sensor also shows up on Linux when running on the phone 2022-05-31 11:11:19 -07:00
Ethan Lee 964e979d06 hidapi: Allow disabling libusb support at runtime 2022-05-30 13:45:24 -07:00
Sam Lantinga c87b0142fe Fixed building with C89 compiler 2022-05-30 12:02:25 -07:00
Guldoman f78f775238 ime: windows: allocate space for null terminator 2022-05-28 08:57:29 -07:00
Sam Lantinga fd2a2eea10 Fixed declaration-after-statement warning 2022-05-28 07:49:18 -07:00
Sam Lantinga d2c4d74dd0 Fixed build with MinGW-64 windows.devices.power.h
The MinGW-64 header defines the parameters as ABI::Windows::Foundation::IReference<INT32 > **, but the Windows header defines the parameters as __FIReference_1_int**
2022-05-27 15:49:35 -07:00
Sam Lantinga bd22ca762e Revert "Workaround for compiling with MinGW-w64"
This reverts commit efdf43aa9b.

The broken mingw headers aren't in an official release yet, so reporting this upstream.
2022-05-27 15:40:50 -07:00
Sam Lantinga efdf43aa9b Workaround for compiling with MinGW-w64
Fixes bug https://github.com/libsdl-org/SDL/issues/5589
2022-05-27 15:34:45 -07:00
Sam Lantinga bef9f2b2c4 Don't trigger device notifications when Steam Deck backlight changes 2022-05-26 20:45:48 -07:00
Cameron Cawley 347659e8cf riscos: Ensure that last_mouse_buttons is initialised correctly 2022-05-25 14:26:36 -07:00
Cameron Cawley cb43eb43f8 riscos: Ensure the mouse focus is set when creating the window 2022-05-25 14:26:36 -07:00
Cameron Cawley 6eda520f64 riscos: Add a basic implementation of SDL_ShowCursor() 2022-05-25 14:26:36 -07:00
Sam Lantinga 22d6e09a8d Don't try to call hid_ble_scan() if HIDAPI is disabled
Fixes https://github.com/libsdl-org/SDL/issues/5699
2022-05-25 11:05:39 -07:00
Sam Lantinga b28d304b23 Only include controller_type.h in SDL_joystick.c
It has a huge array of controllers and we only want it instantiated once
2022-05-24 17:24:54 -07:00
Ozkan Sezer 9220f92bae hidapi/libusb/hid.c (read_thread): mark as SDLCALL 2022-05-25 01:01:02 +03:00
Simon McVittie 412ceb84d4 video: Only check major version in SDL_GetWindowWMInfo
Since #5602, SDL is intended to have the same ABI across the whole
major-version 2 cycle, so we should not check that the minor version
matches the one that was used to compile an application.

There are two checks that could make sense here.

The first check is that the major version matches the expected major
version. This is usually unnecessary and is not usually done (if we're
calling into the wrong library we'll likely crash anyway), but since we
have the information, we might as well continue to use it.

The second check is whether the version provided by the caller is
equal to or greater than a threshold version at which additional fields
were added to the struct. If it is, we should populate those fields;
if it is not, then we cannot. This is only useful on platforms where
additional fields have genuinely been added during the lifetime of
SDL 2, like Windows and DirectFB (but not X11).

This commit changes the first check to be consistent about only looking
at the minor version, while leaving the second check using SDL_VERSIONNUM
(which will be removed or widened in SDL 3, but it's fine for now).

Resolves: https://github.com/libsdl-org/SDL/issues/5711
Fixes: cd7c2f1 "Switch versioning scheme to be the same as GLib and Flatpak"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-05-24 08:56:23 -07:00
Mathieu Eyraud fe46569cce Fix potential memory leak in SDL_AddHintCallback 2022-05-21 09:47:34 -07:00
Ivan Le Lann e4b5afa576 fix unused variable depending on YUV format 2022-05-21 09:46:46 -07:00
Christian Rauch e59cba95a0 add libdecor_dispatch 2022-05-21 09:40:26 -07:00
Ryan C. Gordon dc62fec5e9
audio: Fix locking in backends that manage their own callback threads.
Otherwise you might get a race where an app pauses the device, but
the audio callback still manages to run after the pause is in place.
2022-05-20 21:08:29 -04:00
Sam Lantinga b1cf322971 Fixed HIDAPI PS4 controller being picked up when running under Steam
Input with PS4 configuration enabled
2022-05-19 16:50:59 -07:00
Ryan C. Gordon 9edd411a83
x11: send move/resize events when waiting on fullscreen change.
Otherwise we ignore the Configure/etc events when they come in because
the window is already in an identical state as far as SDL is concerned.

Fixes #5593.

May also fix:
Issue #5572.
Issue #5595.
2022-05-19 17:19:52 -04:00
Cameron Cawley b798e49c92 Fix build warning with MSVC 2022-05-19 23:55:24 +03:00
Cameron Cawley f0566702c5 Fix enabling SDL_DYNAMIC_API in OpenWatcom builds 2022-05-19 20:11:10 +03:00
Cameron Cawley 3d52d04977 Remove the '_' prefix from symbol names in Windows OpenWatcom builds 2022-05-19 20:11:10 +03:00
Cameron Cawley 9dfa000bc0 Initial support for building for Windows with OpenWatcom 2022-05-19 20:11:10 +03: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
Ozkan Sezer 15781a6986 dynapi: fix SDL_DYNAPI_PROC for SDL_iPhoneSetAnimationCallback() 2022-05-19 18:55:02 +03:00
Cameron Cawley f5cf0e37f7 Remove unused and duplicate defines from SDL_dynapi_overrides.h 2022-05-19 17:23:24 +03:00
Ozkan Sezer 03ebc4397f dynapi: add missing SDLCALL for SDL_TLSSet's dtor param. 2022-05-19 14:01:10 +03:00
Pierre Wendling 501a499180 Add clang-format on/off comments where necessary.
Comments were added in places where INDENT-ON/OFF comments are. Places
like stdlib's asm don't need it as clang-format doesn't try to indent it.
2022-05-19 01:31:29 -07:00
Sam Lantinga 0e6d4baa6b Fixed compile warning on gcc 11 2022-05-19 01:23:24 -07:00
Sam Lantinga c7dff3a22e Attempt to get the X1 and X2 button state on X11 by using the current event state instead of direct X11 query. 2022-05-19 00:35:22 -07:00
Sam Lantinga 57130b75a9 Revert "x11: get x1/x2 button state in GetGlobalMouseState"
This reverts commit 3fcc2cb500.

Button4 and Button5 are for the scrollwheel, not the extended buttons.
I don't know of a way to query the state of the extended buttons using X11.
2022-05-19 00:31:20 -07:00
Sam Lantinga 47f1cb550d Fixed picking up the correct mapping for virtual controllers on Android
Fixes https://github.com/libsdl-org/SDL/issues/5662
2022-05-18 23:48:15 -07:00
Sam Lantinga f7b774a7e0 Fixed build error on Linux if HAVE_INOTIFY isn't defined
Fixes https://github.com/libsdl-org/SDL/issues/5682
2022-05-18 17:59:17 -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
Ozkan Sezer dbd54dd708 adjust dynapi after commit 0cca71a changes for SDL_qsort and SDL_bsearch 2022-05-19 03:00:04 +03:00
Sam Lantinga e19a9a7931 Fixed a message box getting the mouse capture state out of sync 2022-05-18 15:34:07 -07:00
Cameron Cawley 622311c016 Add extra XInput structures and defines for older SDKs 2022-05-18 15:04:42 -07:00
Cameron Cawley c8eea02071 Fix C89 build errors in Windows builds 2022-05-18 15:03:15 -07:00
Cameron Cawley 0cca71a846 Use SDLCALL for callbacks in public APIs 2022-05-18 15:01:27 -07:00
Cameron Cawley ffab9f46b5 Avoid clashing with system headers when redefining standard library functions 2022-05-18 16:44:17 -04: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
Ivan Epifanov 8c5bda6acd Vita: remove Vita-specific RWOps code 2022-05-18 08:29:25 -07:00
Sam Lantinga aa6ea607d9 Fixed whitespace
Whitespace inconsistencies reported in https://github.com/libsdl-org/SDL/pull/5673
2022-05-18 06:58:14 -07:00
Ryan C. Gordon 56665e1d9d cocoa: Try to use better system cursors.
These try to pull from the .pdf files that are installed with
macOS, which fit our needs better, and fall back to the most
reasonable defaults available from NSCursor if we can't load
them.

Since these are installed under /System, they should be sandbox
accessible, and if this totally fails, it should still go on,
albeit with a less good cursor.

Reference Issue #2123.
2022-05-17 12:51:08 -04:00
Alex Szpakowski e9c7b5191c macOS: Fix reference counts of internal window data.
Fixes crashes when destroying or recreating a window (#5664).
2022-05-16 18:17:27 -07:00
Ozkan Sezer a48004952d disable dynapi for os/2, at least for now. (see bugs #5667 and #5669.) 2022-05-17 01:33:20 +03:00
Ozkan Sezer ec1a0f62dd SDL_malloc.c: workaround calling convention issues for real_xxx procs. 2022-05-17 01:33:02 +03:00
Sam Lantinga 1f2a241688 Add new virtual joysticks to the end of the list
This guarantees that the device index that's returned is stable, as long as no joystick hotplug events occur.
2022-05-16 09:02:35 -07:00
Sam Lantinga 3c3ccb1d48 Fixed crash if a virtual joystick was disconnected 2022-05-16 08:56:17 -07:00
Ryan C. Gordon 2317a96c8e
x11: Use XC_top_left_corner/XC_top_right_corner instead of XC_fleur.
On Gnome (and hopefully others!), this produces something that actually
matches SDL_SYSTEM_CURSOR_SIZENWSE/SDL_SYSTEM_CURSOR_SIZENESW. On
other desktop enviroments, it probably fits the spirit better than
XC_fleur in any case.

Reference Issue #2123.
2022-05-16 10:53:01 -04:00
Sam Lantinga 48b6cd8bc2 Fixed whitespace 2022-05-16 07:23:30 -07:00
Sam Lantinga f0bc5c9cbf Added effects support for virtual controllers 2022-05-16 07:21:28 -07:00
Sam Lantinga b3a18706ee Removed unused variables 2022-05-16 06:37:38 -07:00
Sam Lantinga 7e005bd843 Fixed mapping the paddle buttons with the virtual controller 2022-05-16 06:22:18 -07:00
Sam Lantinga bfac54b59c Added the ability to specify which buttons and axes are present for virtual controllers 2022-05-15 20:34:44 -07:00
Sam Lantinga 94eeb587c1 First pass at extending virtual controller functionality
Added the ability to specify a name and the product VID/PID for a virtual controller

Also added a test case to testgamecontroller, if you pass --virtual as a parameter
2022-05-15 20:01:12 -07:00
Sam Lantinga 7ad15c5b8f Added game controller support for virtual joysticks
Fixes https://github.com/libsdl-org/SDL/issues/5662
2022-05-15 09:35:52 -07:00
Sam Lantinga 996b3dc37a Fixed warning building with Visual Studio 2022-05-15 09:33:28 -07:00
Ethan Lee e4bb3c8649 wayland: Fix build for configs without libdecor 2022-05-11 18:13:44 -04:00
Ethan Lee 6222bd3143
wayland: Don't create a new libdecor context if one already exists 2022-05-11 16:26:43 -04:00
Ethan Lee 6f88cbe4c9 wayland: Support xdg_decoration requesting client-side decorations.
Don't be fooled by the diff size - this ended up being a big refactor of the
shell surface management, masked only by some helper macros I wrote for the
popup support.

This change makes it so when xdg_decoration is supported, but CSD is requested,
the system bails on xdg support entirely and resets all the windows to use
libdecor instead. This transition isn't pretty, but once it's done it will be
smooth if decorations are an OS toggle since libdecor will take things from
there.

In hindsight, we really should have designed libdecor to be passed a toplevel,
having it manage that for us keeps causing major refactors for _every_ change.
2022-05-11 13:13:59 -07:00
Eddy Jansson d7866ffac8 assert: Check for integer overflow.
Move rendering of the assert message into a separate
function so we can remove the ugly loop construction.

Changes the logic such that allocation failure no longer
immediately returns SDL_ASSERTION_ABORT, instead we
fall back to the truncated message.

If an error is indicated from SDL_snprintf, then we do
abort with SDL_ASSERTION_ABORT.
2022-05-11 12:55:49 -07:00
Michael Fitzmayer 9b75fa0165
N-Gage port: add changes from code reviews, overall cleanup (#5618)
* Add changes from code review by @ccawley2011, #5597, overall cleanup

* Update N-Gage README, minor cleanup and rephrasing

* Call SDL_SetMainReady() before calling SDL_main, return SDL_main instead of main
2022-05-11 09:31:34 -07:00
Sam Lantinga 6da99d4a6c Don't use SDL_SIMDFree() if the pixels haven't been allocated with SDL_SIMDAlloc() 2022-05-11 08:40:17 -07:00
Cameron Cawley 2f924020e8 Add SDL_SCANCODE_CALL and SDL_SCANCODE_ENDCALL 2022-05-10 16:12:10 -07:00
Cameron Cawley 2bc373622b Add SDL_SCANCODE_SOFTLEFT and SDL_SCANCODE_SOFTRIGHT 2022-05-10 16:12:10 -07:00
Alex Szpakowski f871c178b9 macOS: remove dead code for supporting 10.6 at runtime. 2022-05-10 14:04:14 -07:00
Eddy Jansson f7280dcebb log: Check for integer overflow. 2022-05-10 06:47:11 -07:00
Alex Szpakowski ec8fa57750 macOS: always use Objective-C ARC (automatic ref counting).
Change Cocoa SDL_VideoData and SDL_WindowData implementations from C structs to Objective-C objects, since bridging between C and ObjC is easier that way.
2022-05-09 21:53:40 -07:00
Simon McVittie 2a7948016a cpuinfo: Check for overflow in SIMD allocation
If the size to be allocated is very large and untrusted, then adding
the padding etc. might be enough to cause unsigned overflow, after
which a very small amount of memory will be allocated.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-05-09 21:31:39 -07:00
Simon McVittie cf1daafa3f cpuinfo: Set padding to 0 if none is needed
It'll be simpler to use overflow detection after this refactor.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-05-09 21:31:39 -07:00
Frank Richter 0e63b514d5 Don't define memcpy(), memset() when using static VC runtime.
The linker will complain about duplicated symbols otherwise
(see #3662, #5156).
2022-05-07 08:10:52 -07:00
Sam Lantinga 8cd908e0b9 Fixed building with Visual Studio 2013
Added SDL_vacopy.h since it needs to be included after Windows headers
2022-05-06 10:51:55 -07:00
Sam Lantinga a3c1ca1fa1 Added support for the Backbone One guide button
The guide button is activated on a long press (> 400ms)
2022-05-06 09:07:36 -07:00
Simon McVittie fff97c95eb build: Mechanically generate ABI versions from version number
If we're strict about applying something resembling semantic versioning
to the "marketing" version number, then we can mechanically generate
the ABI version from it.

This limits the range of valid micro versions (patchlevels) to 0-99.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-05-04 09:55:35 -07:00
Simon McVittie cd7c2f1de7 Switch versioning scheme to be the same as GLib and Flatpak
For stable releases, this gives us the ability to make bugfix-only point
releases such as 2.24.1 if we want to, and distinguish between them
programmatically. For example, this ability could have been useful after
2.0.16 to fix Xwayland regressions, and after 2.0.18 to fix event loop
regressions.

For development releases, this gives us the ability to make multiple
prereleases during the same feature cycle, and distinguish between them
programmatically. For example, this would have been useful during 2.0.22
development, which went through three prereleases before reaching the
final release.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-05-04 09:55:35 -07:00
Simon McVittie 63814ec767 Add static assertions that the version number is consistent
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-05-04 09:55:35 -07:00
Simon McVittie d4b82bfa4c Add static assertions for version numbers' limits
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-05-04 09:55:35 -07:00
Cameron Cawley b398a847be Add SDL_FLOATWORDORDER for older ARM toolchains 2022-05-04 09:52:11 -07:00
Alexander Kanavin adac3bd1e2 video: restore ability to disable fb accel via hint
Somewhere in code refactoring between .20 and .22 this check
was lost, and so the hint had no effect anymore.
2022-05-04 08:35:13 -07:00
Ozkan Sezer 3f813cf1ef SDL_rawinputjoystick.c: fixed -Werror=declaration-after-statement 2022-05-04 10:05:56 +03:00
atfrase db9e14e504 disabled linux joystick debugging outputs and reverted unnecessary comment edit 2022-05-03 10:44:09 -07:00
atfrase 3b53555bcf copied default Steam Controller mapping for wired and wireless-dongle USB pids 2022-05-03 10:44:09 -07:00
atfrase 13b1bf4f21 added default gamepad mapping for Steam Controller with new GUID (possibly caused by the firmware update to enable BLE?) 2022-05-03 10:44:09 -07:00
atfrase f7a19f9ea8 relaxed the digital hat deadzone slightly, and fixed typo in DEBUG_GAMEPAD_MAPPING define 2022-05-03 10:44:09 -07:00
atfrase 3696e23d09 added hints SDL_HINT_LINUX_DIGITAL_HATS and SDL_HINT_LINUX_HAT_DEADZONES to control the new Linux hat handling; added define DEBUG_GAMEPAD_MAPPINGS to log messages when generating default gamepad mapings for Linux joysticks 2022-05-03 10:44:09 -07:00
atfrase 0b8e796e2c added hueristic to differentiate digital vs analog 'hat' input axes and expose the latter as regular axes; added automatic deadzones to hat outputs, in case analog axes are still mapped to digital hats; updated automatic gamepad control mapping to more completely follow the spec 2022-05-03 10:44:09 -07:00
Michael Fitzmayer fbd230bb6c
Add support for the Nokia N-Gage (#5597)
* Add initial support for the Nokia N-Gage

* N-Gage: disable clipping for the time being, issue needs to be resolved later

* Move va_copy definition to SDL_internal.h

* Move stdlib.h include to SDL_config_ngage.h, much cleaner this way

* Remove redundant include, add HAVE_STDLIB_H

* Revert "N-Gage: disable clipping for the time being, issue needs to be resolved later"

This reverts commit 4f5f0fc36cc7f34fad05e45671dfa7b8dc32fd51.

* N-Gage: fix clipping issue by providing proper math functions
2022-05-03 08:51:49 -07:00
emily 3fcc2cb500 x11: get x1/x2 button state in GetGlobalMouseState 2022-05-03 07:12:04 -07:00
Susko3 6150245d65 Add new verbosity level for logging of `SDL_SysWMEvent`s
Now logged only if SDL_HINT_EVENT_LOGGING is set to "3" or above.
2022-05-02 15:33:13 -07:00
Daniel Brookman d1a3981bf8 Fix crash when reading background events for MFi controllers on macOS
Enabling GCController.shouldMonitorBackgroundEvents to read background events
for MFi controllers before receiving the first GCControllerDidConnectNotification
is apparently a no-go on macOS (12.3.1 for me), and would crash on attempt.
Apple's documentation is... not great, and doesn't point this out.

This waits for IOS_AddMFIJoystickDevice() to get called down the chain from GCControllerDidConnectNotification, and enables GCController.shouldMonitorBackgroundEvents
if it hadn't been already.

On iOS and tvOS, GCController.shouldMonitorBackgroundEvents is ignored, so
there's no need to check their versions.
2022-05-02 15:31:28 -07:00
Jan200101 bb0b6dd42e Fixed using WGI without XInput 2022-05-02 11:33:55 -07:00
Sam Lantinga 5394238cdc Don't include the internal header for a file intended for use by applications 2022-04-30 11:40:26 -07:00
Eddy Jansson 9e5cbf034a Disallow non-positive allocation.
Ensure that we're not trying to call SDL_small_alloc()
with a count of zero.

Transforming the code like this fixes a
-Wmaybe-uninitialized warning from GCC 12.0.1
2022-04-29 18:34:13 -07:00
Eddy Jansson 6c2928b4be Switch uses of MIN() to SDL_min()
We're excluding files in src/hidapi to minimize the
diff against the upstream project.
2022-04-29 10:39:51 -07:00
Eddy Jansson ca26df3404 assert: Allow messages of any length.
Messages are no longer truncated to SDL_MAX_LOG_MESSAGE.
2022-04-29 10:39:02 -07:00
Eddy Jansson 888899244c log: Allow log messages of any length.
Log messages are no longer truncated to SDL_MAX_LOG_MESSAGE.
2022-04-29 10:39:02 -07:00
Eddy Jansson 645db217a0 log: Use malloc for long messages.
For short messages, use a stack buffer that is
significantly smaller than SDL_MAX_LOG_MESSAGE.

The rationale for this is that we don't want to risk
blowing the stack, while at the same time we would
like to not put pressure on the memory allocator unless
absolutely necessary.
2022-04-29 10:39:02 -07:00
Eddy Jansson 73448fe245 assert: Remove use of alloca()
For short messages, use a stack buffer that is
significantly smaller than SDL_MAX_LOG_MESSAGE.

For larger messages, fall back to allocation.
2022-04-29 10:39:02 -07:00
Eddy Jansson 97774cdf72 Move in va_copy() define block from stdlib. 2022-04-29 10:39:02 -07:00
Sam Lantinga 7e636b03cc Removed log message length limitation for Apple platforms
This works in conjunction with https://github.com/libsdl-org/SDL/pull/5584
2022-04-29 10:16:14 -07:00
Carl Friess 2ccb0dfd16 Check for macOS 10.16 to support apps built with older macOS SDKs 2022-04-29 00:24:23 -07:00
Sam Lantinga a0cdc1fc30 Added declaration of SDL_LogInit() and SDL_LogQuit()
Fixes compile warning on Android
2022-04-28 15:01:34 -07:00
Ryan C. Gordon 29694869b1
audio: Revert one of the resampler optimizations.
This is the one that splits the "left wing" into two for loops to
bubble out the conditional that decides if it should read from the
left padding or the input buffer.

I still believe the optimization is good, but the basic logic of it
was incorrect, and needs to be reexamined and fixed before going
back into revision control.
2022-04-28 15:58:39 -04:00
Ryan C. Gordon 0f45a4e303
log: Don't try to SDL_free the static array. :)
I shouldn't be allowed near computers, I swear.
2022-04-27 12:22:37 -04:00
Ryan C. Gordon 31e83cd14c
log: Fixed build (sorry!) 2022-04-27 12:13:44 -04:00
Ryan C. Gordon fde9a7086e
log: Make the message buffer static.
Now we don't have to worry about allocation failure, or performance
issues or changes to the allocation layout when trying to track down
subtle bugs.
2022-04-27 12:05:07 -04:00
Ryan C. Gordon c4141bc11c
log: Wrap the call to the logging implementation in a mutex.
Fixes #2463.
2022-04-27 09:41:05 -04:00
Ryan C. Gordon 2a42952281
log: Don't stack-allocate the message buffer.
It's 4 kilobytes, so I could see this failing if you have a thread with
a tiny stack that unexpectedly logs something.
2022-04-27 09:41:04 -04:00
Ozkan Sezer 12f15aaa74 fix build 2022-04-27 10:03:32 +03:00
Ryan C. Gordon 05bd225a80
x11: If XRandR isn't available, add a generic display.
We can get _some_ of the info we need out of standard Xlib and report a
single display (which might actually be multiple physical displays mushed
into a single desktop). This is better than nothing, but you should really
just build with XRandR support and get a better X server.  :)
2022-04-26 23:17:14 -04:00
Ryan C. Gordon ccc70e644b
x11: Fixed some compiler warnings. 2022-04-26 23:17:13 -04:00
Ryan C. Gordon 7d7ec9c951
x11: Remove XVidMode and Xinerama support.
Fixes #1782.
2022-04-26 23:17:13 -04:00
Sam Lantinga e551384a99 Added functions to get the platform dependent name for a joystick or game controller 2022-04-26 14:54:14 -07:00
Mirko Galimberti b293888c7d Fixes an issue introduced via #5573 when building for i686 2022-04-26 20:55:40 +03:00
Ryan C. Gordon 5066910bf5 audio: Make pregenerated resampler kaiser filter more precise. 2022-04-26 13:32:42 -04:00
Ryan C. Gordon 111c3add73 audio: Resampler optimizations.
- Calculate `j * RESAMPLER_SAMPLES_PER_ZERO_CROSSING` once per loop
  iteration since we use it multiple times.
- Do the left-wing loop in two sections: while `srcframe < 0` and then
  the remaining calculations when `srcframe >= 0`. This bubbles a conditional
  out of every iteration of a tight loop, giving us a boost. We could
  _probably_ do this to the right-wing loop too, but it's less straightforward
  there.
- The real win: Use floats instead of doubles. This almost doubles the speed
  of the entire function on Intel CPUs, and for embedded things without
  hardware-level support for doubles, the speedup is enormous. This in
  theory might reduce audio quality, though, and I had to put a check in
  place to avoid a division-by-zero that we avoided at higher precision, but
  this is likely to be worth keeping for at least the Sony PSP and other
  smaller platforms, if not everyone.
2022-04-26 13:32:42 -04:00
Ryan C. Gordon de019568dc audio: Prebake the resampler's kaiser table instead of doing it at runtime. 2022-04-26 13:32:42 -04:00
Ryan C. Gordon f6eb4b0759
pulseaudio: Feed audio data in response to write callbacks.
Instead of waiting until the entire buffer from the SDL callback is ready
to be accepted by PulseAudio, we use pa_stream_set_write_callback and
feed some portion of the buffer as callbacks come in asking for more.

This lets us remove the halving of the buffer size during device open,
and also (hopefully) solves several strange hangs that happen in unusual
circumstances.

Fixes #4387
Fixes #2262
2022-04-26 13:22:32 -04:00
Sam Lantinga 01ef98a5d0 Don't force keyboard auto-repeat on, if the user has disabled it for some reason
Fixes https://github.com/libsdl-org/SDL/issues/2400
2022-04-26 10:19:52 -07:00
FriendlyAI 795744fc75 Turn off relative mouse before window checks as well 2022-04-26 10:07:26 -07:00
FriendlyAI e2d268a399 SDL_cocoamouse.m: SetRelativeMouseMode even if out of focus
Should fix #3087
2022-04-26 10:07:26 -07:00
Jibb Smart d7c07d6b09
Read motion sensor scale from Switch controllers (#5555)
* Read IMU scale data from Switch controllers. Up until now, SDL has used hard-coded scaling which isn't correct with some supported controllers.

* Moved declarations to beginning of code blocks to better fit with SDL style requirements
2022-04-26 09:57:17 -07:00
Mirko Galimberti 76afb8583b Introduces Cocoa_GetWindowDisplayIndex. This enable a proper management for dpi when switching between retina and non-retina displays. 2022-04-26 09:51:31 -07:00
Dimitriy Ryazantcev c39df2fb0c joystick: get HID top-level collection preparsed data directly from RawInput API. 2022-04-26 09:48:35 -07:00
Ozkan Sezer e9ff4fdd49 add SDL_bsearch 2022-04-26 04:03:25 +03:00
Mathieu Eyraud 0b2a55ea7d Fix typo 2022-04-25 15:46:17 -07:00
meyraud705 3dcfe86082 Add joystick battery event 2022-04-25 15:46:17 -07:00
meyraud705 0964c84d77 Always use SDL_PrivateJoystickBatteryLevel to update battery level
But do not use it for initialisation.
2022-04-25 15:46:17 -07:00
Sam Lantinga fa29e2d7f7 Updated to version 2.0.23 for development 2022-04-25 13:45:51 -07:00
Ryan C. Gordon 53dea98309
x11: revert checks for _NET_WM_STATE_FULLSCREEN changes.
This reverts commit 85977354fb.
This reverts commit 0249df9d96.

Fixes #5572.
Reopens #5390.
2022-04-25 14:00:04 -04:00
Sam Lantinga 981e1e3c44 Fixed logical size synchronization issue on macOS
https://discourse.libsdl.org/t/sdl-2-0-22-prerelease/35306/6
2022-04-23 10:35:05 -07:00
Ozkan Sezer 7a5743031d hidapi, libusb: import mainstream commit 536bad201e 2022-04-23 20:01:40 +03: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 8986efd643 Added support for the Backbone One controller on iOS 2022-04-22 14:21:46 -07:00
Sam Lantinga 2ca0837888 SDL: sometimes the PS5 controller doesn't report having to power even when connected over USB. Possibly related to being completely charged? Either way we already know that it's USB or BT so let's use the driver's knowledge instead. 2022-04-22 14:21:41 -07:00
Sam Lantinga 04bf7c9434 Fixed build 2022-04-22 09:36:39 -07:00
Sam Lantinga d9b5805ba5 Return a correlation error when trigger rumble is attempted without correlation 2022-04-22 09:13:40 -07:00
Sam Lantinga ba62ead5ec Handle potential out of memory condition when working with hints 2022-04-21 08:47:41 -07:00
Cameron Gutman 145824f6ab WGI: Only call RoUninitialize() if RoInitialize() succeeded 2022-04-21 08:47:22 -07:00
Cameron Gutman 00b2e10a7a WGI: Keep a reference to the MTA to avoid crashing on COM teardown
Fixes #5552
Fixes #5270
2022-04-21 08:47:22 -07:00
Cameron Gutman 8982d9f403 windows: Fix RoInitialize() failure after a CoInitializeEx() call using apartment threading
This mirrors the same codepath in WIN_CoInitialize() which handles STA and MTA.
2022-04-21 08:47:22 -07:00
Cameron Gutman 923cb4463e windows: Fix calling convention for RoInitialize/RoUninitialize
Fixes #5563
2022-04-20 21:02:40 -05:00
Ryan C. Gordon d4a01bfef0
os2: SDL_DestroyMutex should ignore NULL mutexes.
Every other backend does this, so this should match, now.
It's possible this was harmless, but we can avoid the system call
and the (likely?) debug message when it fails, though!
2022-04-20 14:08:09 -04:00
Eddy Jansson a40405d724 hidapi: Wrap CopyHIDDeviceInfo in define checks.
The purpose of this is to silence a 'defined but not used'
warning.
2022-04-20 09:33:40 -07:00
Frank Praznik aeadbdd788 Remove an unused function prototype 2022-04-20 09:39:34 -04:00
Frank Praznik c8c59a2139 Fix a -Wshadow warning 2022-04-20 09:39:34 -04:00
Jaylon Gowie d9009388c8 SceKernelMemBlockType to unsigned int 2022-04-19 14:17:27 -07:00
Jaylon Gowie 3753a7b1c3 Fix recent changes in VitaSDK 2022-04-19 14:17:27 -07:00
Sam Lantinga 02225aa738 Fixed build 2022-04-18 22:57:03 -07:00
Ryan C. Gordon 49a2e4b0ea
x11: Revert "Fix keymap updating for X11 backend"
This reverts commit de6d290266.

This patch had multiple issues, discussed in #5520.
2022-04-19 00:37:39 -04:00
Sam Lantinga b9fe6ba0e7 Fixed compile warnings 2022-04-18 13:09:08 -07:00
Sam Lantinga 57927a2458 Don't call scandir() inside of scandir()
This works around a crash in address sanitizer
2022-04-18 12:57:28 -07:00
Sylvain 1ede941f5c SDL_render.c: internally change viewport/cliprect type from SDL_FRect to SDL_DRect (double precision). (see bug #5547) 2022-04-18 12:26:32 -07:00
Sam Lantinga 9919d1a7a5 Remove HWND_TOPMOST for fullscreen windows
Fixes https://github.com/libsdl-org/SDL/issues/5509
2022-04-18 11:51:54 -07:00
pionere 009a0ff95f use explicit GetModuleFileNameW 2022-04-18 14:12:22 -04:00
pionere de711e1685 simplify SDL_GetBasePath on windows
- use GetModuleFileName directly (as recommended)
2022-04-18 14:12:22 -04:00
Jan Beich 7c140429a8 Enable evdev-based gamecontrollerdb on FreeBSD 2022-04-18 09:57:49 -07:00
Sam Lantinga e7b01ee745 Added controller mapping for the Thrustmaster Dual Analog 3.2 on Linux 2022-04-18 09:55:52 -07:00
Frank Praznik 2b52946143 video: Don't minimize fullscreen windows on focus loss by default when mode switching is disabled
When mode switching is disabled in a video backend, fullscreen windows are basically just fullscreen desktop windows with different internal scaling.  As no mode switching occurs, there's no need to minimize them on focus loss by default.  This can still be overridden by explicitly setting the internal hint for minimizing on focus loss.

This has the side effect of fixing a bug on GNOME, where, when a fullscreen Wayland window has it's focus lost and restored via alt+tab followed by switching back to windowed mode, the top portion of the window won't end up being obstructed by GNOME's top bar.
2022-04-18 09:39:25 -07:00
Ethan Lee c37090f9a4 wayland: Add support for TOOLTIP/POPUP_MENU 2022-04-18 12:31:02 -04:00
Sam Lantinga 9e264b921b Certain audio drivers, like the RME "Pro" Audio driver, have resampling quality issues when using WASAPI.
We'll use SDL's resampling algorithm so we have consistent quality between platforms and drivers.

Fixes https://github.com/libsdl-org/SDL/issues/5538
2022-04-18 09:20:47 -07:00
Sam Lantinga 254fcc90eb Revert "video: Prefer Wayland over X11"
This reverts commit 8ceba27d62.

SDL Wayland support is stable, but there are a number of issues with third-party software (NVIDIA drivers, libwayland event overflow, libdecor not handling plugin load failures, Steam overlay not working with Wayland, etc.) that make it better to default to X11 at this time.

Games which would like to prefer wayland when available can use the following code before SDL_Init():
	SDL_SetHint(SDL_HINT_VIDEODRIVER, "wayland,x11");

Fixes https://github.com/libsdl-org/SDL/issues/5527
2022-04-18 09:03:14 -07:00
Ryan C. Gordon c1336b21ed hints: Make SDL_VIDEODRIVER and SDL_AUDIODRIVER formal hints.
They were just environment variables before.

Fixes #5528.
2022-04-17 11:31:55 -07:00
Ryan C. Gordon 67e0f546c5
x11: Update the display when the WM changes a window's fullscreen state.
Fixes #5390.
2022-04-15 18:25:53 -04:00
Frank Praznik edb473cf46 video: Wayland: Always round scaled pointer coordinates down
Rounding up can cause the pointer coordinates to exceed the window boundaries at the right and bottom edges.
2022-04-15 16:24:20 -04:00
Frank Praznik 13393a1c4b video: Wayland: Clamp fullscreen window dimensions to desktop
A scaled fullscreen window may exceed the bounds of the desktop.  Clamp the window size to the desktop dimensions in fullscreen mode.
2022-04-15 16:24:20 -04:00
pionere 0adb67017b avoid NullPointer in SDL_GetRenderTarget 2022-04-15 15:47:35 -04:00
pionere 01b14e14e6 avoid NullPointer in SDL_GL_MakeCurrent 2022-04-15 08:30:33 -04:00
David Gow 9c2f46b0d5 Wayland: Add SDL_HINT_VIDEO_WAYLAND_PREFER_LIBDECOR
This hint allows libdecor to be used even when xdg-decoration is
available. It's mostly useful for debugging libdecor, but could in
theory be used by applications which want to (for example) bundle their
own libdecor plugins.
2022-04-12 11:52:41 -04:00
Mathieu Eyraud 99ae6395b1 Initialise scandir argument
'scandir' does not initialise 'entries' on error
2022-04-12 11:14:07 -04:00
pionere f708cebe10 fix os2 timer in fallback mode 2022-04-12 17:01:20 +03:00
Ryan C. Gordon 727eef7064
audio: SDL_ConvertStereoToMono_SSE3 missed an unaligned load. 2022-04-09 10:13:37 -04:00
Sam Lantinga 505d6a4a05 Update version to 2.0.22 for release 2022-04-08 18:18:56 -07:00
Frank Praznik c2093fab99 video: wayland: Set the surface damage region when using fullscreen viewports
When using emulated display modes, the output size is often larger than the drawable buffer.  As the surface damage region is automatically calculated from the smaller drawable buffer size, the damage region needs to be manually set to cover the entire viewport region or visual repaint artifacts can result.
2022-04-08 14:11:44 -04:00
Ethan Lee ba0ba9ef16 direct3d11: Set the swapchain target immediately after creating it.
Fixes #4782
2022-04-07 23:47:20 -07:00
Ethan Lee cb81630816 render: Update the size/scale/viewport on moves, in addition to resizes.
For OpenGL this means resetting the viewport state shadowing flag too.

Fixes #1504
2022-04-07 23:38:33 -07:00
Sam Lantinga 5613a56032 Make sure the UIKit message box is being handled on the main thread
Potentially fixes https://github.com/libsdl-org/SDL/issues/4865
2022-04-07 11:33:54 -07:00
Sam Lantinga 49b9e3470b Only update modifier state for keys that are pressed in another application
Fixes https://github.com/libsdl-org/SDL/issues/4432
2022-04-07 08:24:03 -07:00
Ryan C. Gordon 85977354fb
x11: Treat WM setting the window "fullscreen" like FULLSCREEN_DESKTOP.
Fixes #5390.
2022-04-07 09:15:27 -04:00
Ethan Lee d1f7f9e35d wayland: Pin the fake window position at (0, 0).
I kind of thought it'd be nice to have it in the center, but this is an issue
for applications that still assume global mouse and window positions are
accessible. For example, this fixes cursor offset issues in UE5.
2022-04-06 11:18:46 -04:00
Ethan Lee 279aeb59be
wayland: Add a bug link for the detach FIXME 2022-04-06 01:32:57 -04:00
Ethan Lee 3ada694e62
wayland: Try to detach at the beginning of ShowWindow, just in case.
It's possible that an external component (probably a GL/VK context) committed, so we need to cover our bases and detach in both HideWindow and ShowWindow.

Fixes a crash in UE5 editor's pop-ups.
2022-04-06 01:18:03 -04:00
Ethan Lee dcfb7fff00
wayland: Evaluate WINDOWPOS_CENTERED_DISPLAY for move events
Partially fixes the mouse cursor in UE5 editor. Imperfect because UE5 uses window position and global mouse state to get position, but of course we don't have global mouse and this is just to get the right display index so this still fails overall. We really need to make global mouse support a feature query...
2022-04-06 00:55:32 -04:00
Sam Lantinga 7ea1b69dd4 Sort controllers by the js* index on Linux
Also fixed the initial scan to directly scan devices instead of using
udev so they can be sorted, as intended.

Fixes https://github.com/libsdl-org/SDL/issues/4688
2022-04-05 21:02:52 -07:00
Ryan C. Gordon 0249df9d96
x11: Try to keep SDL_WINDOW_FULLSCREEN* in sync with window manager.
So if Gnome/KDE/etc have a keyboard shortcut or titlebar decoration to
make any window go fullscreen (with the _NET_WM_FULLSCREEN flag on the
_NET_WM_STATE property), we update the SDL window flag.

Fixes #5390.
2022-04-05 23:18:10 -04:00
Sam Lantinga eb660e862c Cache the fact that a device didn't look like a joystick
Fixes https://github.com/libsdl-org/SDL/issues/5211
2022-04-05 19:47:42 -07:00
Weng Xuetian 138d96c8a6
Send key release event to input method. (#5281)
Co-authored-by: Ethan Lee <flibitijibibo@gmail.com>
2022-04-05 22:30:25 -04:00
Ryan C. Gordon 8bae343f25
x11: when waiting on fullscreen changes, not window position _and_ size.
This makes sure the window doesn't have outdated values if you try to access
them (or call something that does, like SDL_SetWindowMinimumSize).

Fixes #5233.
2022-04-05 22:21:57 -04:00
Sam Lantinga 268c2fa882 Don't resize fullscreen windows when hiding or minimizing them (thanks @madewokherd!)
This has the benefit of window previews (mousing over the icon) having the correct size and contents.

Fixes https://github.com/libsdl-org/SDL/issues/5320
2022-04-05 18:42:17 -07:00
Esme Povirk def27267b5 Ignore focus change messages that contradict GetForegroundWindow.
On Wine, when a window is programmatically minimized in response
to losing focus, we receive a WM_ACTIVATE for the deactivation,
but GetForegroundWindow still indicates that our window is focused.
This causes an incorrect SDL_WINDOWEVENT_FOCUS_GAINED.

This is probably a Wine bug, but it may take a while to fix and
then for the fix to make its way to users.
2022-04-05 18:00:39 -07:00
Weng Xuetian ff5b67e5e0 IBus should use ev keycode instead of X keycode
See: 5a455b1ead/client/gtk2/ibusimcontext.c (L468)
2022-04-05 20:04:40 -04: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