Commit Graph

11438 Commits

Author SHA1 Message Date
Sam Lantinga
ac4f5dcadd Relicensed testutils to match other test code
Permission granted in 76a7b629bf (commitcomment-121408342)

(cherry picked from commit 6c2472d459)
(cherry picked from commit a4ad293d4a)
2023-07-16 04:38:48 -07:00
Sam Lantinga
ff4fd93f4c Fixed getting the CRC of virtual joysticks without a VID/PID
(cherry picked from commit b40fb5c51e)
(cherry picked from commit 6089b35706)
2023-07-16 04:38:48 -07:00
Frank Praznik
52a14998a8 wayland/video: Validate the returned window display pointer before dereferencing it
If, in the case where all displays has been disconnected, and some window state change occurs before an active display is re-added and finalized, the pointer returned by SDL_GetDisplayForWindow() will be null necessitating that the returned pointer be checked for validity before dereferencing it.

(cherry picked from commit a999100858)
2023-07-14 11:30:31 -04:00
Anonymous Maarten
14b0b0e6c8 ci: move 'set -eu' to after source_cmd 2023-07-14 15:03:19 +02:00
Sam Lantinga
cb4b41ddf7 RAWINPUT_RegisterNotifications() should return int, for consistency
(cherry picked from commit 1903d7b1bf)
(cherry picked from commit e8b6edd5a0)
2023-07-11 10:54:44 -07:00
Sam Lantinga
5a2d165b7b Improved RAWINPUT <-> XInput/WGI device correlation
If there is only one controller slot available, assume that's the one matching new RAWINPUt devices. This will be right most of the time, and uncorrelation will fix any bad guesses.

(cherry picked from commit 41882a1acb)
(cherry picked from commit 34c5bde355)
2023-07-11 10:54:44 -07:00
Sam Lantinga
11022c23b2 Fixed crash if RAWINPUT is not initialized
We shouldn't be doing any of this work in that case

(cherry picked from commit dfc5e6964e)
(cherry picked from commit 9117b2e300)
2023-07-11 10:54:44 -07:00
Sam Lantinga
b7c93a2d77 Don't send k_ePS4FeatureReportIdCapabilities to Sony PS4 controllers
This report is for third party controllers only, and might be causing issues with fake PS4 controllers.

Reference https://github.com/libsdl-org/SDL/issues/7960

(cherry picked from commit 092a4b780c)
(cherry picked from commit 6bf5f5a221)
2023-07-10 09:49:17 -07:00
Christopher Wellons
078e817ceb Unaligned stacks on i686-w64-mingw32, may lead to crashes (#7607)
Co-authored-by: Ozkan Sezer <sezeroz@gmail.com>(cherry picked from commit 8231278817)
2023-07-10 03:10:20 +03:00
Ozkan Sezer
aba2be820c SDL_RWFromMem, SDL_RWFromConstMem: reject negative size parameters.
(cherry picked from commit 0ad822eb70)
2023-07-10 00:15:56 +03:00
Sam Lantinga
0dbeec449f Re-added mappings for older Xbox One controllers on Linux
The xpad kernel driver doesn't know about these controllers and ends up using BTN_C and BTN_Z and the automatic mapping doesn't work correctly.

It turns out VID 0x045e and PID 0x02e0 is used by the 8BitDo SN30 Pro when connecting via Bluetooth in XInput mode.

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

(cherry picked from commit 80e1c75e1c)
(cherry picked from commit 156c7badf5)
2023-07-09 09:51:10 -07:00
Joshua Barnett
3f46546f79 Add kernel32 to SDL_EXTRA_LIBS required for cross-compilation to Win32 native
Linking error experienced while compiling with the following toolchain
due to lack of kernel32.lib

d35e5f8dde/cmake/platforms/WinMsvc.cmake (L317-L321)
2023-07-09 14:03:36 +02:00
Sam Lantinga
a614d8f8f7 Fixed mapping BTN_TR2 to right trigger
(cherry picked from commit ea60da5b94)
(cherry picked from commit 4b1dd54a56)
2023-07-08 18:19:06 -07:00
Sam Lantinga
bb3997d81d Added WGI gamepad added/removed listeners for RAWINPUT
This fixes WGI correlation on startup when the WGI gamepad list isn't populated yet

(cherry picked from commit f047e178b6)
(cherry picked from commit f8a0135edf)
2023-07-08 10:40:56 -07:00
Sam Lantinga
035121040f Don't tickle Bluetooth PS4 controllers in simple mode with an effects packet
That will put the PS4 controller into enhanced mode, which breaks DirectInput games

(cherry picked from commit efed24850a)
(cherry picked from commit 1f7bc08884)
2023-07-08 10:40:55 -07:00
Sam Lantinga
f2d016e353 Lazily initialize the WGI gamepad support
Initializing "Windows.Gaming.Input.Gamepad" will put Bluetooth PS4 controllers into enhanced report mode, which breaks any game using DirectInput. Let's wait to do this until absolutely necessary.

(cherry picked from commit 785f57eb91)
(cherry picked from commit de849d5e6f)
2023-07-08 10:40:55 -07:00
Sam Lantinga
b858242823 Added the hint SDL_HINT_JOYSTICK_WGI to control whether to use Windows.Gaming.Input for controllers
(cherry picked from commit a6228e7aaf)
2023-07-08 09:35:22 -07:00
Sam Lantinga
46927b1362 Prefer using XInput for rumble over WGI, as it allows rumble in the background
(cherry picked from commit e16a83d393)
2023-07-07 09:48:25 -07:00
Sam Lantinga
3bee5cf538 Continue running XInput detection while RAWINPUT is active
This allows us to re-enable XInput correlation for RAWINPUT devices without reintroducing the controller shutdown bug for controllers using the wireless adapter in https://github.com/libsdl-org/SDL/issues/3468.

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

(cherry picked from commit a0a3957eb6)
2023-07-07 09:48:25 -07:00
Takase
03dcee1731 video(wayland): use both --icon and --icon-name for Zenity (#7897)
video(wayland): use both --icon and --icon-name for Zenity

Many distros ship an older version of Zenity that supports GTK3, while some distros ship newer version of Zenity which uses libadwaita.

This command tries to use --icon and fall back to --icon-name when it fails.

(cherry picked from commit b90343e512)
2023-07-06 18:00:37 -07:00
Sam Lantinga
fdcc1d59b9 Fixed crash if mutex functions are used before any mutex has been created
(cherry picked from commit cc49f1e279)
(cherry picked from commit 488a91eb40)
2023-07-05 10:17:42 -07:00
Anonymous Maarten
2633540746 cmake: explicitly disable WINDOWS_EXPORT_ALL_SYMBOLS for SDL2
This fixes the following errors when a dll attempts to link to a shared SDL2::SDL2:

m.c.obj : error LNK2019: unresolved external symbol __imp___acrt_iob_func referenced in function printf
m.c.obj : error LNK2019: unresolved external symbol __imp___stdio_common_vfprintf referenced in function _vfprintf_l
MSVCRTD.lib(init.obj) : error LNK2019: unresolved external symbol _CrtDbgReport referenced in function _CRT_RTC_INIT
MSVCRTD.lib(init.obj) : error LNK2019: unresolved external symbol _CrtDbgReportW referenced in function _CRT_RTC_INITW
MSVCRTD.lib(error.obj) : error LNK2019: unresolved external symbol strcpy_s referenced in function "void __cdecl _RTC_StackFailure(void *,char const *)" (?_RTC_StackFailure@@YAXPEAXPEBD@Z)
MSVCRTD.lib(error.obj) : error LNK2019: unresolved external symbol strcat_s referenced in function "void __cdecl _RTC_StackFailure(void *,char const *)" (?_RTC_StackFailure@@YAXPEAXPEBD@Z)
MSVCRTD.lib(error.obj) : error LNK2019: unresolved external symbol __stdio_common_vsprintf_s referenced in function _vsprintf_s_l
MSVCRTD.lib(error.obj) : error LNK2001: unresolved external symbol __C_specific_handler_noexcept
MSVCRTD.lib(pdblkup.obj) : error LNK2019: unresolved external symbol _wmakepath_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned __int64)" (?GetPdbDllPathFromFilePath@@YAHPEB_WPEA_W_K@Z)
MSVCRTD.lib(pdblkup.obj) : error LNK2019: unresolved external symbol _wsplitpath_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned __int64)" (?GetPdbDllPathFromFilePath@@YAHPEB_WPEA_W_K@Z)
MSVCRTD.lib(pdblkup.obj) : error LNK2019: unresolved external symbol wcscpy_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned __int64)" (?GetPdbDllPathFromFilePath@@YAHPEB_WPEA_W_K@Z)
MSVCRTD.lib(pdblkup.obj) : error LNK2019: unresolved external symbol __vcrt_GetModuleFileNameW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPEAUHINSTANCE__@@XZ)
MSVCRTD.lib(pdblkup.obj) : error LNK2019: unresolved external symbol __vcrt_GetModuleHandleW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPEAUHINSTANCE__@@XZ)
MSVCRTD.lib(pdblkup.obj) : error LNK2019: unresolved external symbol __vcrt_LoadLibraryExW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPEAUHINSTANCE__@@XZ)
2023-07-05 00:18:13 +02:00
Sam Lantinga
116a5344ff Fixed resource leak and crash at exit in the D3D11 renderer
Also, for some reason ID3D11DeviceContext_OMGetRenderTargets() was failing in the second read pixels call in the "testautomation --filter render_testViewport" test.

We already know the target view, so just use that.

(cherry picked from commit 619f65af0c)
(cherry picked from commit 61808b03b5)
2023-07-03 17:43:21 -07:00
Sam Lantinga
f3436bc103 The clip rect is defined in terms of the current viewport
Don't use the viewport offset when setting the clip rect in the D3D12 renderer.

This fixes "testautomation --filter render_testViewport" on Windows

(cherry picked from commit 304d425f99)
(cherry picked from commit bf277eb808)
2023-07-03 17:16:03 -07:00
Ozkan Sezer
5e21571374 fixed windows build after commit 7e8be3f 2023-07-04 02:29:10 +03:00
Sam Lantinga
699f8697fe Retry to open the clipboard in case another application has it open
This fixes 'testautomation --filter clipboard_testClipboardTextFunctions' on Windows

(cherry picked from commit c24496727cdd40d5c0ffdf7b6a61085ec3a2766d)
(cherry picked from commit 7e8be3f280)
2023-07-03 16:13:46 -07:00
scribam
0352301e1a cmake: use SDL_CPU_ARM32 instead of CMAKE_GENERATOR_PLATFORM STREQUAL "ARM" 2023-07-01 23:26:38 +02:00
Sam Lantinga
4761467b2e Updated to version 2.28.1 for release release-2.28.1 2023-07-01 09:56:20 -07:00
Ryan C. Gordon
cd662ceb54 rwops: Use SetFilePointerEx on Windows for appending writes.
Fixes #7900.

(cherry picked from commit 769bf2ebcc)
2023-07-01 00:40:51 -04:00
Sam Lantinga
7207f5155b Added Linux mapping for the Logitech Chillstream
Fixes https://github.com/libsdl-org/SDL/issues/7829

(cherry picked from commit 675fc8c38f)
(cherry picked from commit fc0854651b)
2023-06-29 16:16:10 -07:00
Anonymous Maarten
5d9013beb9 wayland: don't use libdecor_frame_get_* functions when header doesn't have it
and we're statically linking to the library.
This fixes building SDL with -DSDL_WAYLAND_SHARED=OFF

(cherry picked from commit 5b5b67df20)
(cherry picked from commit e6f635ca17)
2023-06-29 16:14:23 -04:00
Sam Lantinga
4af1f6ed0c Fixed build
(cherry picked from commit 099e53f3a5)
2023-06-29 11:26:16 -07:00
Sam Lantinga
446fb3028e Added support for the Nintendo Online Famicom controllers
(cherry picked from commit baa9c57581)
(cherry picked from commit 0f940cb6ce)
2023-06-29 11:18:30 -07:00
Sam Lantinga
ba170daf84 Don't crash if SDL_MapRGB() and SDL_MapRGBA() are passed a NULL format
(cherry picked from commit fadc4916a9bcc410c2148a91bf0adf742410a4ba)
(cherry picked from commit 0ba93e4aac)
2023-06-27 16:10:49 -07:00
Sam Lantinga
7fa2ddb0de Fixed Nintendo Switch Pro controllers that don't have readable user calibration
(cherry picked from commit 9ee1200e6f)
(cherry picked from commit 170428b107)
2023-06-27 07:50:41 -07:00
Narr the Reg
9aca2a4339 hidapi: switch: Handle MCU input reports
(cherry picked from commit 425062c123)
(cherry picked from commit 950ff0056a)
2023-06-26 10:07:35 -07:00
Sam Lantinga
491fba1d06 SDL_FindFreePlayerIndex() will always return the next available player index
Fixes https://github.com/libsdl-org/SDL/issues/7868

(cherry picked from commit 87e916dd21)
(cherry picked from commit 38619bb28d)
2023-06-24 15:40:30 -07:00
Sam Lantinga
c27f3ead7c Removed 100 ms hitch when querying third party Nintendo Switch controllers that don't respond to request for info
(cherry picked from commit 8acf729650)
2023-06-21 14:13:09 -07:00
Sam Lantinga
1429e525fb Use default sensor calibration if we can't read it from the Nintendo Switch controller
Fixes https://github.com/libsdl-org/SDL/issues/7830

(cherry picked from commit 3694dabe7c)
(cherry picked from commit dfbdaca2b8)
2023-06-21 10:41:58 -07:00
Sam Lantinga
de6963ea99 Apply DPI scale to mouse coordinates in SDL_WarpMouseInWindow()
Fixes https://github.com/libsdl-org/SDL/issues/7855

(cherry picked from commit 657c346556)
2023-06-21 08:46:45 -07:00
Sam Lantinga
ffa78e6bea Updated to version 2.28.0 for release release-2.28.0 2023-06-20 11:00:20 -07:00
Simon McVittie
4ce5c3a694 ibus: Handle error when getting the D-Bus machine ID
It is possible for retrieving the machine ID to fail, either because
dbus was installed incorrectly (machine ID absent or corrupt), or in
32-bit builds, because stat() on the machine ID fails with EOVERFLOW
if it has an out-of-range timestamp or inode number.

dbus has historically treated this as a faulty installation, raising
a warning which by default causes the process to crash. Unfortunately,
dbus_get_local_machine_id() never had a way to report errors, so it has
no alternative for that (bad) error handling.

In dbus >= 1.12.0, we can use dbus_try_get_local_machine_id() to get
the same information, but with the ability to cope gracefully with
errors. ibus won't work in this situation, but that's better than
crashing.

(cherry picked from commit 91198baed4)

Mitigates: https://github.com/ValveSoftware/steam-for-linux/issues/9605
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-20 09:45:25 -07:00
Sam Lantinga
a3d4fd71c3 Added support for blitting SDL_PIXELFORMAT_INDEX1LSB
Fixes https://github.com/libsdl-org/SDL/issues/7844
2023-06-19 08:36:30 -07:00
Sam Lantinga
d97423ebab Fixed DualSense controllers not being picked up by the HIDAPI driver
The hidraw device may take additional time to get the correct permissions for us to open it. In my tests on Steam Deck hardware, this ranges between 5-8ms.

(cherry picked from commit c6ee9780df)
2023-06-18 12:22:06 -07:00
Sam Lantinga
333a03f1ec We don't know in advance whether a device is connected over Bluetooth in SDL2 2023-06-17 13:15:07 -07:00
Sam Lantinga
5b8fc907df Added support for the GameSir G4 Pro
We can't read device info or IMU calibration from this controller, and it has no gyro or accelerometer, but is otherwise perfectly functional.

(cherry picked from commit f168f9c813)
2023-06-17 13:07:03 -07:00
Eric Wasylishen
76392f4fe1 Handle DPI scaling in SDL_GetWindowSurface
Fixes DPI awareness of testdrawchessboard (previously, the surface was
being created in points instead of pixels, resulting in the demo app
only drawing in a corner of the screen on High-DPI displays)

*_CreateWindowFramebuffer()/*_UpdateWindowFramebuffer(): are updated
to use SDL_GetWindowSizeInPixels instead of SDL_GetWindowSize() or
window->w/window->h.

Most of the _CreateWindowFramebuffer backends are untested except
for Windows.

Fixes #7047

(cherry picked from commit 67c91353e0)
2023-06-14 17:23:54 -07:00
Sam Lantinga
3a5abee512 Removed unused function
(cherry picked from commit 73927b0948)
2023-06-14 15:16:44 -07:00
Sam Lantinga
e7ee375f22 Fixed third-party Nintendo Switch Pro controllers shutting down when we try to set the home LED.
This fixes the PDP Afterglow Wireless Deluxe Controller.

(cherry picked from commit 0c16f4faf0)
2023-06-14 15:15:27 -07:00
Sam Lantinga
4aec54988c Allow switching licensed Nintendo Switch Pro controllers into gyro input mode
(cherry picked from commit 8c95bd814b)
2023-06-14 15:13:11 -07:00