From 77b3a6afaf6bd70cdbb8d79f1c25f9279be43937 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 6 May 2024 10:10:57 -0700 Subject: [PATCH 01/59] Added a Windows mapping for the SPEEDLINK STRIKE Gamepad Fixes https://github.com/libsdl-org/SDL/issues/9705 (cherry picked from commit 01d560df509bf5fa58fe9c5b758caf07d11ccd0a) (cherry picked from commit 8c92af5e54ba7b3e52b8da9f7557ecd863633a1f) --- src/joystick/SDL_gamecontrollerdb.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/joystick/SDL_gamecontrollerdb.h b/src/joystick/SDL_gamecontrollerdb.h index c7d85c9725a5c..b997f00d2a500 100644 --- a/src/joystick/SDL_gamecontrollerdb.h +++ b/src/joystick/SDL_gamecontrollerdb.h @@ -304,6 +304,7 @@ static const char *s_ControllerMappings[] = { "030000006f0e00002f01000000000000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000341a00000208000000000000,SL-6555-SBK,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:-a4,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a3,righty:a2,start:b7,x:b2,y:b3,", "03000000341a00000908000000000000,SL-6566,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", + "03000000790000000600000000000000,SPEEDLINK STRIKE Gamepad,crc:5811,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,", "03000000790000001c18000000000000,STK-7024X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,", "03000000ff1100003133000000000000,SVEN X-PAD,a:b2,b:b3,back:b4,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a4,start:b5,x:b0,y:b1,", "03000000457500002211000000000000,SZMY-POWER PC Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", From 9dcfc308ef71731d8df35562664a6ac5921fa0fa Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Fri, 10 May 2024 18:56:24 +0300 Subject: [PATCH 02/59] SDL_iconv_string: simplify recomputation of outbuf and outbytesleft Noticed this in SDL-1.2 where gcc-13 emits a -Wuse-after-free warning. No such warning in SDL2 and SDL3, because unlike SDL1.2, SDL_realloc() is not a macro expanding to libc realloc(). It warns, of course, if SDL_realloc() is replaced with plain realloc(): src/stdlib/SDL_iconv.c: In function 'SDL_iconv_string_REAL': src/stdlib/SDL_iconv.c:824:39: warning: pointer 'oldstring' may be used after 'realloc' [-Wuse-after-free] 824 | outbuf = string + (outbuf - oldstring); | ~~~~~~~~^~~~~~~~~~~~ src/stdlib/SDL_iconv.c:818:30: note: call to 'realloc' here 818 | string = (char *)realloc(string, stringsize + sizeof(Uint32)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (cherry picked from commit 22056268168fa62bb66af62ef648b7030c9522d9) (cherry picked from commit b6899f82fb35896c94d831a5eff3ec99dd6cd45e) --- src/stdlib/SDL_iconv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/stdlib/SDL_iconv.c b/src/stdlib/SDL_iconv.c index 2ab748c98f528..416e199b76cf2 100644 --- a/src/stdlib/SDL_iconv.c +++ b/src/stdlib/SDL_iconv.c @@ -822,6 +822,7 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb switch (retCode) { case SDL_ICONV_E2BIG: { + const ptrdiff_t diff = (ptrdiff_t) (outbuf - string); char *oldstring = string; stringsize *= 2; string = (char *)SDL_realloc(string, stringsize + sizeof(Uint32)); @@ -830,8 +831,8 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb SDL_iconv_close(cd); return NULL; } - outbuf = string + (outbuf - oldstring); - outbytesleft = stringsize - (outbuf - string); + outbuf = string + diff; + outbytesleft = stringsize - diff; SDL_memset(outbuf, 0, sizeof(Uint32)); continue; } From c27219695a3027c6dc2295dcb2f73049fec66d2e Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 10 May 2024 12:17:28 -0700 Subject: [PATCH 03/59] Don't enable enhanced report mode for Bluetooth Nintendo Switch controllers by default This breaks applications using them in DirectInput mode, which isn't worth just getting battery status. We'll turn on enhanced mode if the application enables sensors. (cherry picked from commit a87fa020ac0e282cc147299f7f69f8072de68024) (cherry picked from commit efaa58732abb3faf3900b2d93a166b955fbd8ed0) --- src/joystick/hidapi/SDL_hidapi_switch.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c index 0e2257f1c666f..6b5ea4d3a573f 100644 --- a/src/joystick/hidapi/SDL_hidapi_switch.c +++ b/src/joystick/hidapi/SDL_hidapi_switch.c @@ -758,7 +758,10 @@ static Uint8 GetDefaultInputMode(SDL_DriverSwitch_Context *ctx) * battery level over Bluetooth anyway. */ if (ctx->device->vendor_id == USB_VENDOR_NINTENDO) { + /* However, switching to full controller state breaks DirectInput, so let's not do that */ + #if 0 input_mode = k_eSwitchInputReportIDs_FullControllerState; + #endif } return input_mode; } From 0800d81fb4afc60f064474badc2ed9062a435a76 Mon Sep 17 00:00:00 2001 From: Oleg Date: Thu, 16 May 2024 02:51:46 +0300 Subject: [PATCH 04/59] Added Cammus C5 wheelbase VID/PID to wheel devices list (cherry picked from commit ce9177b64ffd325fbe30fdd410540b2fc506db0b) (cherry picked from commit 0c7a83ecd5e5eae85416605969a659d94f432491) --- src/joystick/SDL_joystick.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index c4d43ec0532fc..c1a22df980486 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -389,6 +389,7 @@ static Uint32 initial_wheel_devices[] = { MAKE_VIDPID(0x2433, 0xf301), /* Asetek SimSports Forte Wheelbase */ MAKE_VIDPID(0x2433, 0xf303), /* Asetek SimSports La Prima Wheelbase */ MAKE_VIDPID(0x2433, 0xf306), /* Asetek SimSports Tony Kannan Wheelbase */ + MAKE_VIDPID(0x3416, 0x0301), /* Cammus C5 Wheelbase */ }; static SDL_vidpid_list wheel_devices = { SDL_HINT_JOYSTICK_WHEEL_DEVICES, 0, 0, NULL, From c3b53c72c7ee2baef3c02547a17d5717f56a9de9 Mon Sep 17 00:00:00 2001 From: Oleg Date: Thu, 16 May 2024 02:47:33 +0300 Subject: [PATCH 05/59] Added Simucube wheelbases VID/PID to wheel devices list (cherry picked from commit dc9d9dd85aabe28d069c757c8ccd4cfe8ace8e67) (cherry picked from commit 1f54ee1da6e469f159c23c61763d7a079dae4eb9) --- src/joystick/SDL_joystick.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index c1a22df980486..b23a58ef8e2fb 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -385,6 +385,10 @@ static Uint32 initial_wheel_devices[] = { MAKE_VIDPID(0x0eb7, 0x0e03), /* Fanatec CSL Elite Wheel Base */ MAKE_VIDPID(0x11ff, 0x0511), /* DragonRise Inc. Wired Wheel (initial mode) (also known as PXN V900 (PS3), Superdrive SV-750, or a Genesis Seaborg 400) */ MAKE_VIDPID(0x1209, 0xffb0), /* Generic FFBoard OpenFFBoard universal forcefeedback wheel */ + MAKE_VIDPID(0x16d0, 0x0d5a), /* Simucube 1 Wheelbase */ + MAKE_VIDPID(0x16d0, 0x0d5f), /* Simucube 2 Ultimate Wheelbase */ + MAKE_VIDPID(0x16d0, 0x0d60), /* Simucube 2 Pro Wheelbase */ + MAKE_VIDPID(0x16d0, 0x0d61), /* Simucube 2 Sport Wheelbase */ MAKE_VIDPID(0x2433, 0xf300), /* Asetek SimSports Invicta Wheelbase */ MAKE_VIDPID(0x2433, 0xf301), /* Asetek SimSports Forte Wheelbase */ MAKE_VIDPID(0x2433, 0xf303), /* Asetek SimSports La Prima Wheelbase */ From 9ad6a36b7b1b5977b5619f781a0397c7b5ec4221 Mon Sep 17 00:00:00 2001 From: Oleg Date: Thu, 16 May 2024 02:06:37 +0300 Subject: [PATCH 06/59] Added Moza wheelbases VID/PID to wheel devices list (cherry picked from commit 79cabeef18ccbf27f3d2d6bd43fbfcc974569277) (cherry picked from commit 96e379949545c24152e50abed24fa1cd7c06f877) --- src/joystick/SDL_joystick.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index b23a58ef8e2fb..e3d8bae862ccd 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -394,6 +394,11 @@ static Uint32 initial_wheel_devices[] = { MAKE_VIDPID(0x2433, 0xf303), /* Asetek SimSports La Prima Wheelbase */ MAKE_VIDPID(0x2433, 0xf306), /* Asetek SimSports Tony Kannan Wheelbase */ MAKE_VIDPID(0x3416, 0x0301), /* Cammus C5 Wheelbase */ + MAKE_VIDPID(0x346e, 0x0000), /* Moza R16/R21 Wheelbase */ + MAKE_VIDPID(0x346e, 0x0002), /* Moza R9 Wheelbase */ + MAKE_VIDPID(0x346e, 0x0004), /* Moza R5 Wheelbase */ + MAKE_VIDPID(0x346e, 0x0005), /* Moza R3 Wheelbase */ + MAKE_VIDPID(0x346e, 0x0006), /* Moza R12 Wheelbase */ }; static SDL_vidpid_list wheel_devices = { SDL_HINT_JOYSTICK_WHEEL_DEVICES, 0, 0, NULL, From 825ffaa168d6e89c76f3b74a15e5167082e1ab80 Mon Sep 17 00:00:00 2001 From: APGR22 <143316176+APGR22@users.noreply.github.com> Date: Fri, 17 May 2024 21:05:40 +0700 Subject: [PATCH 07/59] Added NULL pointer check (cherry picked from commit 961488b0dc992365adcc7f9c668da5e62afa3e00) (cherry picked from commit e4fc07cad074fade6182bbf9ca5e9df0ae785f95) --- src/SDL_hints.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/SDL_hints.c b/src/SDL_hints.c index ae4055d3252bd..2455cc13a1b61 100644 --- a/src/SDL_hints.c +++ b/src/SDL_hints.c @@ -161,6 +161,10 @@ const char *SDL_GetHint(const char *name) const char *env; SDL_Hint *hint; + if (!name) { + return NULL; + } + env = SDL_getenv(name); for (hint = SDL_hints; hint; hint = hint->next) { if (SDL_strcmp(name, hint->name) == 0) { From 793a0681a92d156733fa3aaa174651dc7345cc5f Mon Sep 17 00:00:00 2001 From: Phena Ildanach Date: Fri, 17 May 2024 02:40:19 -0500 Subject: [PATCH 08/59] hidapi: Use a whitelist for libusb when other backends are available (cherry picked from commit fdf28471c03731b82f215c979e4d5930f9c29bca) --- src/hidapi/SDL_hidapi.c | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/hidapi/SDL_hidapi.c b/src/hidapi/SDL_hidapi.c index 6ed1eb613a42b..ef9597782ff84 100644 --- a/src/hidapi/SDL_hidapi.c +++ b/src/hidapi/SDL_hidapi.c @@ -877,6 +877,41 @@ static int SDL_libusb_get_string_descriptor(libusb_device_handle *dev, #undef make_path #undef read_thread +/* If the platform has any backend other than libusb, try to avoid using + * libusb as the main backend for devices, since it detaches drivers and + * therefore makes devices inaccessible to the rest of the OS. + * + * We do this by whitelisting devices we know to be accessible _exclusively_ + * via libusb; these are typically devices that look like HIDs but have a + * quirk that requires direct access to the hardware. + */ +static const struct { + Uint16 vendor; + Uint16 product; +} SDL_libusb_whitelist[] = { + { 0x057e, 0x0337 } /* Nintendo WUP-028, Wii U/Switch GameCube Adapter */ +}; + +static SDL_bool +IsInWhitelist(Uint16 vendor, Uint16 product) +{ + int i; + for (i = 0; i < SDL_arraysize(SDL_libusb_whitelist); i += 1) { + if (vendor == SDL_libusb_whitelist[i].vendor && + product == SDL_libusb_whitelist[i].product) { + return SDL_TRUE; + } + } + return SDL_FALSE; +} + +#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND +static const SDL_bool use_libusb_whitelist_default = SDL_TRUE; +#else +static const SDL_bool use_libusb_whitelist_default = SDL_FALSE; +#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND */ +static SDL_bool use_libusb_whitelist = use_libusb_whitelist_default; + #endif /* HAVE_LIBUSB */ #endif /* !SDL_HIDAPI_DISABLED */ @@ -1062,6 +1097,8 @@ int SDL_hid_init(void) #endif #ifdef HAVE_LIBUSB + use_libusb_whitelist = SDL_GetHintBoolean("SDL_HIDAPI_LIBUSB_WHITELIST", + use_libusb_whitelist_default); if (SDL_getenv("SDL_HIDAPI_DISABLE_LIBUSB") != NULL) { SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "libusb disabled by SDL_HIDAPI_DISABLE_LIBUSB"); @@ -1238,6 +1275,16 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned SDL_Log("libusb devices found:"); #endif for (usb_dev = usb_devs; usb_dev; usb_dev = usb_dev->next) { + if (use_libusb_whitelist) { + if (!IsInWhitelist(usb_dev->vendor_id, usb_dev->product_id)) { +#ifdef DEBUG_HIDAPI + SDL_Log("Device was not in libusb whitelist: %ls %ls 0x%.4hx 0x%.4hx", + usb_dev->manufacturer_string, usb_dev->product_string, + usb_dev->vendor_id, usb_dev->product_id); +#endif /* DEBUG_HIDAPI */ + continue; + } + } new_dev = (struct SDL_hid_device_info *)SDL_malloc(sizeof(struct SDL_hid_device_info)); if (new_dev == NULL) { LIBUSB_hid_free_enumeration(usb_devs); From 1e5db996ff917d6c3c799672df2674d8f16af2fd Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 23 May 2024 15:34:38 -0700 Subject: [PATCH 09/59] Added Linux bindings for the Qanba Drone 2 Arcade Joystick (cherry picked from commit 98a9ca5e329bd74799a3cdfa63c1ddd55bdf8a12) (cherry picked from commit 964e0c9b47818c13338cb5ae9833bb2cef318ffd) --- src/joystick/SDL_gamecontrollerdb.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/joystick/SDL_gamecontrollerdb.h b/src/joystick/SDL_gamecontrollerdb.h index b997f00d2a500..22979210f1b52 100644 --- a/src/joystick/SDL_gamecontrollerdb.h +++ b/src/joystick/SDL_gamecontrollerdb.h @@ -772,6 +772,8 @@ static const char *s_ControllerMappings[] = { "03000000300f00001211000011010000,QanBa Arcade JoyStick,a:b2,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b9,x:b1,y:b3,", "03000000222c00000225000011010000,Qanba Dragon Arcade Joystick (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000222c00000025000011010000,Qanba Dragon Arcade Joystick (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", + "03000000222c00001020000011010000,Qanba Drone 2 Arcade Joystick (PS5),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", + "03000000222c00001220000011010000,Qanba Drone 2 Arcade Joystick (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000222c00000020000011010000,Qanba Drone Arcade Joystick (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,rightshoulder:b5,righttrigger:a4,start:b9,x:b0,y:b3,", "03000000222c00000223000011010000,Qanba Obsidian Arcade Joystick (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000222c00000023000011010000,Qanba Obsidian Arcade Joystick (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", From e49349ac0cec8766e6e76ee6226fe80d3ababb1e Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Fri, 24 May 2024 19:36:20 +0200 Subject: [PATCH 10/59] d3d12: xbox has no DXGI_PRESENT flags (cherry picked from commit 54c435409bdb2dbd40e194104581bd564c3d2086) --- src/render/direct3d12/SDL_render_d3d12.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c index 04c065ccf5f08..9b097f0f825e4 100644 --- a/src/render/direct3d12/SDL_render_d3d12.c +++ b/src/render/direct3d12/SDL_render_d3d12.c @@ -58,6 +58,11 @@ #define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str #endif +/* DXGI_PRESENT flags are removed on Xbox */ +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#define DXGI_PRESENT_ALLOW_TEARING 0 +#endif + #ifdef __cplusplus #define SAFE_RELEASE(X) \ if (X) { \ From cf6c760cd352166911410fe264c56ee34afc8af7 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Fri, 24 May 2024 19:34:14 +0200 Subject: [PATCH 11/59] d3d12: older Windows SDK headers contain wrong function prototypes Declare correct function pointers ourselves. Backport of: - 98fcf112e74dfd6b99a755c957195671e642b57d - 89a4d9ae67e82913af71a93611f396530a05f61d (cherry picked from commit c79e6168061960e000e421e3ac67087b62105763) --- CMakeLists.txt | 9 +-- configure | 30 +-------- configure.ac | 12 +--- src/render/direct3d12/SDL_render_d3d12.c | 77 +++++++++++++++++++----- 4 files changed, 68 insertions(+), 60 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e65c149ddf2a3..cdf43a4b0ed2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1809,14 +1809,7 @@ elseif(WINDOWS) check_include_file(d3d9.h HAVE_D3D_H) check_include_file(d3d11_1.h HAVE_D3D11_H) - check_c_source_compiles(" - #include - #include - #include - ID3D12Device1 *device; - #if WDK_NTDDI_VERSION > 0x0A000008 - int main(int argc, char **argv) { return 0; } - #endif" HAVE_D3D12_H) + check_include_file(d3d12.h HAVE_D3D12_H) check_include_file(ddraw.h HAVE_DDRAW_H) check_include_file(dsound.h HAVE_DSOUND_H) check_include_file(dinput.h HAVE_DINPUT_H) diff --git a/configure b/configure index 2a004fef2cacb..fe83c4997029d 100755 --- a/configure +++ b/configure @@ -27513,36 +27513,12 @@ then : have_d3d11=yes fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for d3d12 Windows SDK version" >&5 -printf %s "checking for d3d12 Windows SDK version... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -ID3D12Device1 *device; -#if WDK_NTDDI_VERSION <= 0x0A000008 -asdf -#endif - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" + ac_fn_c_check_header_compile "$LINENO" "d3d12.h" "ac_cv_header_d3d12_h" "$ac_includes_default" +if test "x$ac_cv_header_d3d12_h" = xyes then : have_d3d12=yes -else $as_nop - have_d3d12=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_d3d12" >&5 -printf "%s\n" "$have_d3d12" >&6; } + ac_fn_c_check_header_compile "$LINENO" "ddraw.h" "ac_cv_header_ddraw_h" "$ac_includes_default" if test "x$ac_cv_header_ddraw_h" = xyes then : diff --git a/configure.ac b/configure.ac index a968c4c606ecc..258d947d1cc40 100644 --- a/configure.ac +++ b/configure.ac @@ -3343,17 +3343,7 @@ CheckDIRECTX() if test x$enable_directx = xyes; then AC_CHECK_HEADER(d3d9.h, have_d3d=yes) AC_CHECK_HEADER(d3d11_1.h, have_d3d11=yes) - AC_MSG_CHECKING(for d3d12 Windows SDK version) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -#include -#include -ID3D12Device1 *device; -#if WDK_NTDDI_VERSION <= 0x0A000008 -asdf -#endif - ]])], [have_d3d12=yes],[have_d3d12=no]) - AC_MSG_RESULT($have_d3d12) + AC_CHECK_HEADER(d3d12.h, have_d3d12=yes) AC_CHECK_HEADER(ddraw.h, have_ddraw=yes) AC_CHECK_HEADER(dsound.h, have_dsound=yes) AC_CHECK_HEADER(dinput.h, have_dinput=yes) diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c index 9b097f0f825e4..8a607bfbe03d7 100644 --- a/src/render/direct3d12/SDL_render_d3d12.c +++ b/src/render/direct3d12/SDL_render_d3d12.c @@ -48,6 +48,7 @@ #include #include #include +#include #endif #include "SDL_shaders_d3d12.h" @@ -83,6 +84,54 @@ #define D3D_GUID(X) &(X) #endif +/* + * Older MS Windows SDK headers declare some d3d12 functions with the wrong function prototype. + * - ID3D12Heap::GetDesc + * - ID3D12Resource::GetDesc + * - ID3D12DescriptorHeap::GetDesc + * (and 9 more)+ + * This is fixed in SDKs since WDK_NTDDI_VERSION >= NTDDI_WIN10_FE (0x0A00000A) + */ + +#if !(defined(__MINGW32__) || defined(__XBOXONE__) || defined(__XBOXSERIES__)) \ + && (WDK_NTDDI_VERSION < 0x0A00000A) + +#define D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(THIS, ...) do { \ + void (STDMETHODCALLTYPE * func)(ID3D12DescriptorHeap * This, D3D12_CPU_DESCRIPTOR_HANDLE * Handle) = \ + (void*)(THIS)->lpVtbl->GetCPUDescriptorHandleForHeapStart; \ + func((THIS), ##__VA_ARGS__); \ + } while (0) + +#define D3D_CALL_RET_ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(THIS, ...) do { \ + void (STDMETHODCALLTYPE * func)(ID3D12DescriptorHeap * This, D3D12_GPU_DESCRIPTOR_HANDLE * Handle) = \ + (void*)(THIS)->lpVtbl->GetGPUDescriptorHandleForHeapStart; \ + func((THIS), ##__VA_ARGS__); \ + } while (0) + +#define D3D_CALL_RET_ID3D12Resource_GetDesc(THIS, ...) do { \ + void (STDMETHODCALLTYPE * func)(ID3D12Resource * This, D3D12_RESOURCE_DESC * Desc) = \ + (void*)(THIS)->lpVtbl->GetDesc; \ + func((THIS), ##__VA_ARGS__); \ + } while (0) + +#else + +/* + * MinGW has correct function prototypes in the vtables, but defines wrong functions + * Xbox just needs these macros defined as used below (because CINTERFACE doesn't exist) + */ + +#define D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(THIS, ...) \ + D3D_CALL_RET(THIS, GetCPUDescriptorHandleForHeapStart, ##__VA_ARGS__); + +#define D3D_CALL_RET_ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(THIS, ...) \ + D3D_CALL_RET(THIS, GetGPUDescriptorHandleForHeapStart, ##__VA_ARGS__); + +#define D3D_CALL_RET_ID3D12Resource_GetDesc(THIS, ...) \ + D3D_CALL_RET(THIS, GetDesc, ##__VA_ARGS__); + +#endif + /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { @@ -398,10 +447,10 @@ static D3D12_GPU_DESCRIPTOR_HANDLE D3D12_CPUtoGPUHandle(ID3D12DescriptorHeap *he SIZE_T offset; /* Calculate the correct offset into the heap */ - D3D_CALL_RET(heap, GetCPUDescriptorHandleForHeapStart, &CPUHeapStart); + D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(heap, &CPUHeapStart); offset = CPUHandle.ptr - CPUHeapStart.ptr; - D3D_CALL_RET(heap, GetGPUDescriptorHandleForHeapStart, &GPUHandle); + D3D_CALL_RET_ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(heap, &GPUHandle); GPUHandle.ptr += offset; return GPUHandle; @@ -432,7 +481,7 @@ static D3D12_CPU_DESCRIPTOR_HANDLE D3D12_GetCurrentRenderTargetView(SDL_Renderer } SDL_zero(rtvDescriptor); - D3D_CALL_RET(data->rtvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &rtvDescriptor); + D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(data->rtvDescriptorHeap, &rtvDescriptor); rtvDescriptor.ptr += data->currentBackBufferIndex * data->rtvDescriptorSize; return rtvDescriptor; } @@ -1052,7 +1101,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) samplerDesc.ComparisonFunc = D3D12_COMPARISON_FUNC_ALWAYS; samplerDesc.MinLOD = 0.0f; samplerDesc.MaxLOD = D3D12_FLOAT32_MAX; - D3D_CALL_RET(data->samplerDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &data->nearestPixelSampler); + D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(data->samplerDescriptorHeap, &data->nearestPixelSampler); D3D_CALL(data->d3dDevice, CreateSampler, &samplerDesc, data->nearestPixelSampler); samplerDesc.Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR; @@ -1341,7 +1390,7 @@ static HRESULT D3D12_CreateWindowSizeDependentResources(SDL_Renderer *renderer) rtvDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D; SDL_zero(rtvDescriptor); - D3D_CALL_RET(data->rtvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &rtvDescriptor); + D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(data->rtvDescriptorHeap, &rtvDescriptor); rtvDescriptor.ptr += i * data->rtvDescriptorSize; D3D_CALL(data->d3dDevice, CreateRenderTargetView, data->renderTargets[i], &rtvDesc, rtvDescriptor); } @@ -1555,7 +1604,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) resourceViewDesc.Texture2D.MipLevels = textureDesc.MipLevels; textureData->mainSRVIndex = D3D12_GetAvailableSRVIndex(renderer); - D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceView); + D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceView); textureData->mainTextureResourceView.ptr += textureData->mainSRVIndex * rendererData->srvDescriptorSize; D3D_CALL(rendererData->d3dDevice, CreateShaderResourceView, @@ -1564,7 +1613,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) textureData->mainTextureResourceView); #if SDL_HAVE_YUV if (textureData->yuv) { - D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceViewU); + D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceViewU); textureData->mainSRVIndexU = D3D12_GetAvailableSRVIndex(renderer); textureData->mainTextureResourceViewU.ptr += textureData->mainSRVIndexU * rendererData->srvDescriptorSize; D3D_CALL(rendererData->d3dDevice, CreateShaderResourceView, @@ -1572,7 +1621,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) &resourceViewDesc, textureData->mainTextureResourceViewU); - D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceViewV); + D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceViewV); textureData->mainSRVIndexV = D3D12_GetAvailableSRVIndex(renderer); textureData->mainTextureResourceViewV.ptr += textureData->mainSRVIndexV * rendererData->srvDescriptorSize; D3D_CALL(rendererData->d3dDevice, CreateShaderResourceView, @@ -1586,7 +1635,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) nvResourceViewDesc.Format = DXGI_FORMAT_R8G8_UNORM; - D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceViewNV); + D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceViewNV); textureData->mainSRVIndexNV = D3D12_GetAvailableSRVIndex(renderer); textureData->mainTextureResourceViewNV.ptr += textureData->mainSRVIndexNV * rendererData->srvDescriptorSize; D3D_CALL(rendererData->d3dDevice, CreateShaderResourceView, @@ -1603,7 +1652,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) renderTargetViewDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D; renderTargetViewDesc.Texture2D.MipSlice = 0; - D3D_CALL_RET(rendererData->textureRTVDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureRenderTargetView); + D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->textureRTVDescriptorHeap, &textureData->mainTextureRenderTargetView); textureData->mainTextureRenderTargetView.ptr += textureData->mainSRVIndex * rendererData->rtvDescriptorSize; D3D_CALL(rendererData->d3dDevice, CreateRenderTargetView, @@ -1668,7 +1717,7 @@ static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Res /* Create an upload buffer, which will be used to write to the main texture. */ SDL_zero(textureDesc); - D3D_CALL_RET(texture, GetDesc, &textureDesc); + D3D_CALL_RET_ID3D12Resource_GetDesc(texture, &textureDesc); textureDesc.Width = w; textureDesc.Height = h; @@ -1924,7 +1973,7 @@ static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, /* Create an upload buffer, which will be used to write to the main texture. */ SDL_zero(textureDesc); - D3D_CALL_RET(textureData->mainTexture, GetDesc, &textureDesc); + D3D_CALL_RET_ID3D12Resource_GetDesc(textureData->mainTexture, &textureDesc); textureDesc.Width = rect->w; textureDesc.Height = rect->h; @@ -2033,7 +2082,7 @@ static void D3D12_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) D3D_CALL(textureData->stagingBuffer, Unmap, 0, NULL); SDL_zero(textureDesc); - D3D_CALL_RET(textureData->mainTexture, GetDesc, &textureDesc); + D3D_CALL_RET_ID3D12Resource_GetDesc(textureData->mainTexture, &textureDesc); textureDesc.Width = textureData->lockedRect.w; textureDesc.Height = textureData->lockedRect.h; @@ -2744,7 +2793,7 @@ static int D3D12_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, /* Create a staging texture to copy the screen's data to: */ SDL_zero(textureDesc); - D3D_CALL_RET(backBuffer, GetDesc, &textureDesc); + D3D_CALL_RET_ID3D12Resource_GetDesc(backBuffer, &textureDesc); textureDesc.Width = rect->w; textureDesc.Height = rect->h; From faa9bbdc8e2d5616c725e2e963bf0618db79b002 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Mon, 27 May 2024 02:34:26 +0200 Subject: [PATCH 12/59] cmake: direct3d12 renderer needs d3d12.h and d3d12sdklayers.h Older MinGW releases don't ship d3d12sdklayers.h backport of 3af4f120d0e76cfd1121713414a12aca1ac2f588 (cherry picked from commit 6c10201e5815d85b85334299b2d63d8e6c835349) --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cdf43a4b0ed2c..c44fa80227dc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1809,7 +1809,12 @@ elseif(WINDOWS) check_include_file(d3d9.h HAVE_D3D_H) check_include_file(d3d11_1.h HAVE_D3D11_H) - check_include_file(d3d12.h HAVE_D3D12_H) + check_c_source_compiles(" + #include + #include + ID3D12Device1 *device; + int main(int argc, char **argv) {return 0; } + " HAVE_D3D12_H) check_include_file(ddraw.h HAVE_DDRAW_H) check_include_file(dsound.h HAVE_DSOUND_H) check_include_file(dinput.h HAVE_DINPUT_H) From acc2e040ce724373c5a25dcd7d53c0de3237b257 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Mon, 27 May 2024 02:42:04 +0200 Subject: [PATCH 13/59] VC+d3d12: use __has_include to detect presence of d3d12 headers backport of 4fa50062472795234806e89eccf1fcebbab3407a (cherry picked from commit 6c297788262f766745f0195673de4d67ff463af2) --- include/SDL_config_windows.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/SDL_config_windows.h b/include/SDL_config_windows.h index dba78086016e4..aae52ebc63de3 100644 --- a/include/SDL_config_windows.h +++ b/include/SDL_config_windows.h @@ -99,9 +99,11 @@ typedef unsigned int uintptr_t; #define HAVE_D3D11_H 1 #define HAVE_ROAPI_H 1 #endif -#if defined(WDK_NTDDI_VERSION) && WDK_NTDDI_VERSION > 0x0A000008 /* 10.0.19041.0 */ +#if defined(__has_include) +#if __has_include() && __has_include() #define HAVE_D3D12_H 1 #endif +#endif #if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0603 /* Windows 8.1 SDK */ #define HAVE_SHELLSCALINGAPI_H 1 #endif From 607f37dafde2f7a76bd17a51535dcd5b99070015 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 27 May 2024 14:33:18 -0700 Subject: [PATCH 14/59] Fixed compiling SDL_platform_defines.h on macOS with older compilers (thanks @sezero!) Fixes #9632 (cherry picked from commit 36015ad5e58c413e8a101c48ed2bdbcdd044c868) (cherry picked from commit 8bc47dc3f155f4dd2f01b7f63ef32a45f620f70c) --- include/SDL_platform.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/SDL_platform.h b/include/SDL_platform.h index e8bf11acfd4b9..2b11bf201685e 100644 --- a/include/SDL_platform.h +++ b/include/SDL_platform.h @@ -73,7 +73,13 @@ #if defined(__APPLE__) /* lets us know what version of Mac OS X we're compiling on */ #include +#ifndef __has_extension /* Older compilers don't support this */ +#define __has_extension(x) 0 #include +#undef __has_extension +#else +#include +#endif /* Fix building with older SDKs that don't define these See this for more information: From 2c07ed320e6bd739635a0a4696a0db6a2864b2db Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Tue, 28 May 2024 08:01:04 +0300 Subject: [PATCH 15/59] SDL_config_os2.h: remove duplicated HAVE_WCSL* defines. (cherry picked from commit 6825a4aabb9ad40a3689c0561fb61591061a7395) --- include/SDL_config_os2.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/SDL_config_os2.h b/include/SDL_config_os2.h index 9be6b2d50eb33..b2b061d716bd2 100644 --- a/include/SDL_config_os2.h +++ b/include/SDL_config_os2.h @@ -114,9 +114,6 @@ #define HAVE_MEMCPY 1 #define HAVE_MEMMOVE 1 #define HAVE_MEMCMP 1 -#define HAVE_WCSLEN 1 -#define HAVE_WCSLCPY 1 -#define HAVE_WCSLCAT 1 #define HAVE_WCSCMP 1 #define HAVE__WCSICMP 1 #define HAVE__WCSNICMP 1 From 244951067348bb3350faecb310fdac42dec9c989 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Tue, 28 May 2024 14:10:28 +0300 Subject: [PATCH 16/59] Makefile.in: add VisualC-GDK to SRC_DIST Fixes https://github.com/libsdl-org/SDL/issues/9913 (cherry picked from commit 0439fc6007e6246358bcbba212821b96044950f9) --- Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index eb4c4bc1abc8a..27e0bbbf3b44e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -52,7 +52,7 @@ WAYLAND_SCANNER_CODE_MODE = @WAYLAND_SCANNER_CODE_MODE@ INSTALL_SDL2_CONFIG = @INSTALL_SDL2_CONFIG@ -SRC_DIST = *.md *.txt acinclude Android.mk autogen.sh android-project build-scripts cmake cmake_uninstall.cmake.in configure configure.ac docs include Makefile.* mingw sdl2-config.cmake.in sdl2-config-version.cmake.in sdl2-config.in sdl2.m4 sdl2.pc.in SDL2.spec.in SDL2Config.cmake.in src test VisualC VisualC-WinRT Xcode Xcode-iOS wayland-protocols +SRC_DIST = *.md *.txt acinclude Android.mk autogen.sh android-project build-scripts cmake cmake_uninstall.cmake.in configure configure.ac docs include Makefile.* mingw sdl2-config.cmake.in sdl2-config-version.cmake.in sdl2-config.in sdl2.m4 sdl2.pc.in SDL2.spec.in SDL2Config.cmake.in src test VisualC VisualC-GDK VisualC-WinRT Xcode Xcode-iOS wayland-protocols GEN_DIST = SDL2.spec ifneq ($V,1) From 3ee20388c574096bff412041745a5fd8086d6afc Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Tue, 28 May 2024 17:02:26 +0200 Subject: [PATCH 17/59] autotools needs to check d3d12sdklayers.h too (cherry picked from commit 5e876db89f06a477187242e4b9c7bf65e18a6b9b) --- configure | 25 +++++++++++++++++++++++-- configure.ac | 9 ++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/configure b/configure index fe83c4997029d..3218dd532cdbd 100755 --- a/configure +++ b/configure @@ -27513,11 +27513,32 @@ then : have_d3d11=yes fi - ac_fn_c_check_header_compile "$LINENO" "d3d12.h" "ac_cv_header_d3d12_h" "$ac_includes_default" -if test "x$ac_cv_header_d3d12_h" = xyes + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for compatible d3d12 headers" >&5 +printf %s "checking for compatible d3d12 headers... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +ID3D12Device1 *device; + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" then : have_d3d12=yes +else $as_nop + have_d3d12=no fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_d3d12" >&5 +printf "%s\n" "$have_d3d12" >&6; } ac_fn_c_check_header_compile "$LINENO" "ddraw.h" "ac_cv_header_ddraw_h" "$ac_includes_default" if test "x$ac_cv_header_ddraw_h" = xyes diff --git a/configure.ac b/configure.ac index 258d947d1cc40..2bcdd8d4ea8a4 100644 --- a/configure.ac +++ b/configure.ac @@ -3343,7 +3343,14 @@ CheckDIRECTX() if test x$enable_directx = xyes; then AC_CHECK_HEADER(d3d9.h, have_d3d=yes) AC_CHECK_HEADER(d3d11_1.h, have_d3d11=yes) - AC_CHECK_HEADER(d3d12.h, have_d3d12=yes) + AC_MSG_CHECKING(for compatible d3d12 headers) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +ID3D12Device1 *device; + ]])], [have_d3d12=yes],[have_d3d12=no]) + AC_MSG_RESULT($have_d3d12) + AC_CHECK_HEADER(ddraw.h, have_ddraw=yes) AC_CHECK_HEADER(dsound.h, have_dsound=yes) AC_CHECK_HEADER(dinput.h, have_dinput=yes) From 91accc391d9d85cdeb541f3b136776f6c3e4f97d Mon Sep 17 00:00:00 2001 From: mechakotik Date: Fri, 31 May 2024 15:13:07 +0300 Subject: [PATCH 18/59] android: Default to custom theme in styles.xml Custom theme file exists in project, but is not used by app, which is kinda unintuitive. Using it by default so people who not familiar with Android development won't spend lots of time troubleshooting. (cherry picked from commit 8f88c32ca6af066d586a22a0b5efd9ff6873e315) (cherry picked from commit 1568501dd6dc29d412823ccc0fbfe4a5c85d377b) --- android-project/app/src/main/AndroidManifest.xml | 2 +- android-project/app/src/main/res/values/styles.xml | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/android-project/app/src/main/AndroidManifest.xml b/android-project/app/src/main/AndroidManifest.xml index e0d033410e14e..5157374b52865 100644 --- a/android-project/app/src/main/AndroidManifest.xml +++ b/android-project/app/src/main/AndroidManifest.xml @@ -62,7 +62,7 @@ - - From 5cc0644aa024ee6fd0e35d7fbc9a4c6c7e4c1df0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 31 May 2024 15:18:15 -0700 Subject: [PATCH 19/59] Added support for the Razer Kitsune in PS5 mode (cherry picked from commit e3beaa1972f3eda462a30481b1efb095f25c43a0) (cherry picked from commit 35d719ef2522385a4950ca4900f95808eb47dc5f) --- src/joystick/controller_list.h | 1 + src/joystick/hidapi/SDL_hidapi_ps5.c | 6 ++++++ src/joystick/hidapi/SDL_hidapijoystick.c | 2 +- src/joystick/usb_ids.h | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/joystick/controller_list.h b/src/joystick/controller_list.h index 15d3902782129..27cacc5aeb3a3 100644 --- a/src/joystick/controller_list.h +++ b/src/joystick/controller_list.h @@ -157,6 +157,7 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x0f0d, 0x0184 ), k_eControllerType_PS5Controller, NULL }, // Hori Fighting Stick α { MAKE_CONTROLLER_ID( 0x1532, 0x100b ), k_eControllerType_PS5Controller, NULL }, // Razer Wolverine V2 Pro (Wired) { MAKE_CONTROLLER_ID( 0x1532, 0x100c ), k_eControllerType_PS5Controller, NULL }, // Razer Wolverine V2 Pro (Wireless) + { MAKE_CONTROLLER_ID( 0x1532, 0x1012 ), k_eControllerType_PS5Controller, NULL }, // Razer Kitsune { MAKE_CONTROLLER_ID( 0x3285, 0x0d18 ), k_eControllerType_PS5Controller, NULL }, // NACON Revolution 5 Pro (PS5 mode with dongle) { MAKE_CONTROLLER_ID( 0x3285, 0x0d19 ), k_eControllerType_PS5Controller, NULL }, // NACON Revolution 5 Pro (PS5 mode wired) { MAKE_CONTROLLER_ID( 0x358a, 0x0104 ), k_eControllerType_PS5Controller, NULL }, // Backbone One PlayStation Edition for iOS diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c index afefa3dd4f56b..dfdbc81201d75 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps5.c +++ b/src/joystick/hidapi/SDL_hidapi_ps5.c @@ -499,6 +499,12 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) ctx->sensors_supported = SDL_TRUE; ctx->touchpad_supported = SDL_TRUE; ctx->use_alternate_report = SDL_TRUE; + } else if (device->vendor_id == USB_VENDOR_RAZER && + device->product_id == USB_PRODUCT_RAZER_KITSUNE) { + /* The Razer Kitsune doesn't respond to the detection protocol, but has a touchpad */ + joystick_type = SDL_JOYSTICK_TYPE_ARCADE_STICK; + ctx->touchpad_supported = SDL_TRUE; + ctx->use_alternate_report = SDL_TRUE; } } ctx->effects_supported = (ctx->lightbar_supported || ctx->vibration_supported || ctx->playerled_supported); diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c index 1584a2cf9df43..3f793fc9d2dc1 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/src/joystick/hidapi/SDL_hidapijoystick.c @@ -190,7 +190,7 @@ SDL_bool HIDAPI_SupportsPlaystationDetection(Uint16 vendor, Uint16 product) /* Most Razer devices are not game controllers, and some of them lock up * or reset when we send them the Sony third-party query feature report, * so don't include that vendor here. Instead add devices as appropriate - * to controller_type.c + * to controller_list.h * * Reference: https://github.com/libsdl-org/SDL/issues/6733 * https://github.com/libsdl-org/SDL/issues/6799 diff --git a/src/joystick/usb_ids.h b/src/joystick/usb_ids.h index 19ca22710eeab..ef6cdb843dc31 100644 --- a/src/joystick/usb_ids.h +++ b/src/joystick/usb_ids.h @@ -90,6 +90,7 @@ #define USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V103 0x7210 #define USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V104 0x7214 #define USB_PRODUCT_RAZER_ATROX 0x0a00 +#define USB_PRODUCT_RAZER_KITSUNE 0x1012 #define USB_PRODUCT_RAZER_PANTHERA 0x0401 #define USB_PRODUCT_RAZER_PANTHERA_EVO 0x1008 #define USB_PRODUCT_RAZER_RAIJU 0x1000 From d48f9c4af4dcba7b97e7db031ddb815b6627da75 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 3 May 2023 09:47:16 -0700 Subject: [PATCH 20/59] Added support for the Saitek Cyborg V.3 Rumble Pad in PS3 mode (cherry picked from commit b6ca3602289aa2b0c34856f31e0214d924bda2c9) (cherry picked from commit e2f597de84be93351c22850f3cd78a7646756e98) --- src/joystick/hidapi/SDL_hidapi_ps3.c | 93 +++++++++++++++------------- src/joystick/usb_ids.h | 2 + 2 files changed, 53 insertions(+), 42 deletions(-) diff --git a/src/joystick/hidapi/SDL_hidapi_ps3.c b/src/joystick/hidapi/SDL_hidapi_ps3.c index e9baf7e09ca84..c09909eb9bdbc 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps3.c +++ b/src/joystick/hidapi/SDL_hidapi_ps3.c @@ -584,7 +584,8 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_IsSupportedDevice(SDL_HIDAPI_Device * Uint8 data[USB_PACKET_LENGTH]; int size; - if (HIDAPI_SupportsPlaystationDetection(vendor_id, product_id)) { + if ((type == SDL_CONTROLLER_TYPE_PS3 && vendor_id != USB_VENDOR_SONY) || + HIDAPI_SupportsPlaystationDetection(vendor_id, product_id)) { if (device && device->dev) { size = ReadFeatureReport(device->dev, 0x03, data, sizeof(data)); if (size == 8 && data[2] == 0x26) { @@ -813,48 +814,56 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket19(SDL_Joystick *joystic SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data[1] & 0x10) ? SDL_PRESSED : SDL_RELEASED); } - if (ctx->last_state[2] != data[2]) { - SDL_bool dpad_up = SDL_FALSE; - SDL_bool dpad_down = SDL_FALSE; - SDL_bool dpad_left = SDL_FALSE; - SDL_bool dpad_right = SDL_FALSE; - - switch (data[2] & 0x0f) { - case 0: - dpad_up = SDL_TRUE; - break; - case 1: - dpad_up = SDL_TRUE; - dpad_right = SDL_TRUE; - break; - case 2: - dpad_right = SDL_TRUE; - break; - case 3: - dpad_right = SDL_TRUE; - dpad_down = SDL_TRUE; - break; - case 4: - dpad_down = SDL_TRUE; - break; - case 5: - dpad_left = SDL_TRUE; - dpad_down = SDL_TRUE; - break; - case 6: - dpad_left = SDL_TRUE; - break; - case 7: - dpad_up = SDL_TRUE; - dpad_left = SDL_TRUE; - break; - default: - break; + if (ctx->device->vendor_id == USB_VENDOR_SAITEK && ctx->device->product_id == USB_PRODUCT_SAITEK_CYBORG_V3) { + /* Cyborg V.3 Rumble Pad doesn't set the dpad bits as expected, so use the axes instead */ + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN, data[10] ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, data[9] ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, data[7] ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, data[8] ? SDL_PRESSED : SDL_RELEASED); + } else { + if (ctx->last_state[2] != data[2]) { + SDL_bool dpad_up = SDL_FALSE; + SDL_bool dpad_down = SDL_FALSE; + SDL_bool dpad_left = SDL_FALSE; + SDL_bool dpad_right = SDL_FALSE; + + switch (data[2] & 0x0f) { + case 0: + dpad_up = SDL_TRUE; + break; + case 1: + dpad_up = SDL_TRUE; + dpad_right = SDL_TRUE; + break; + case 2: + dpad_right = SDL_TRUE; + break; + case 3: + dpad_right = SDL_TRUE; + dpad_down = SDL_TRUE; + break; + case 4: + dpad_down = SDL_TRUE; + break; + case 5: + dpad_left = SDL_TRUE; + dpad_down = SDL_TRUE; + break; + case 6: + dpad_left = SDL_TRUE; + break; + case 7: + dpad_up = SDL_TRUE; + dpad_left = SDL_TRUE; + break; + default: + break; + } + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN, dpad_down); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, dpad_up); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, dpad_right); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, dpad_left); } - SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN, dpad_down); - SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, dpad_up); - SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, dpad_right); - SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, dpad_left); } axis = ((int)data[17] * 257) - 32768; diff --git a/src/joystick/usb_ids.h b/src/joystick/usb_ids.h index ef6cdb843dc31..9cdcfa68ad7da 100644 --- a/src/joystick/usb_ids.h +++ b/src/joystick/usb_ids.h @@ -47,6 +47,7 @@ #define USB_VENDOR_POWERA_ALT 0x20d6 #define USB_VENDOR_QANBA 0x2c22 #define USB_VENDOR_RAZER 0x1532 +#define USB_VENDOR_SAITEK 0x06a3 #define USB_VENDOR_SHANWAN 0x2563 #define USB_VENDOR_SHANWAN_ALT 0x20bc #define USB_VENDOR_SONY 0x054c @@ -104,6 +105,7 @@ #define USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_PS5_WIRELESS 0x100c #define USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_XBOX_WIRED 0x1010 #define USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_XBOX_WIRELESS 0x1011 +#define USB_PRODUCT_SAITEK_CYBORG_V3 0xf622 #define USB_PRODUCT_SHANWAN_DS3 0x0523 #define USB_PRODUCT_SONY_DS3 0x0268 #define USB_PRODUCT_SONY_DS4 0x05c4 From ab8659922dcc4f4faadc78652bf7a9e94e1bdd54 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 5 Jun 2024 19:11:10 -0700 Subject: [PATCH 21/59] Fixed PlayStation detection interrupting input for the Logitech K400 keyboard Also added the Logitech Chillstream to the list of PS3 controllers and fixed the right shoulder axis. (cherry picked from commit b6d7adfec11c355cdbb5ebde26ed5a5c958ce489) (cherry picked from commit f520062ad1837f6c4a60e876a2113617f9c11b0e) --- src/joystick/controller_list.h | 1 + src/joystick/hidapi/SDL_hidapi_ps3.c | 7 ++++++- src/joystick/hidapi/SDL_hidapijoystick.c | 24 ++++++++++-------------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/joystick/controller_list.h b/src/joystick/controller_list.h index 27cacc5aeb3a3..fb124798123a2 100644 --- a/src/joystick/controller_list.h +++ b/src/joystick/controller_list.h @@ -24,6 +24,7 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x0079, 0x1844 ), k_eControllerType_PS3Controller, NULL }, // From SDL { MAKE_CONTROLLER_ID( 0x044f, 0xb315 ), k_eControllerType_PS3Controller, NULL }, // Firestorm Dual Analog 3 { MAKE_CONTROLLER_ID( 0x044f, 0xd007 ), k_eControllerType_PS3Controller, NULL }, // Thrustmaster wireless 3-1 + { MAKE_CONTROLLER_ID( 0x046d, 0xcad1 ), k_eControllerType_PS3Controller, NULL }, // Logitech Chillstream //{ MAKE_CONTROLLER_ID( 0x046d, 0xc24f ), k_eControllerType_PS3Controller, NULL }, // Logitech G29 (PS3) { MAKE_CONTROLLER_ID( 0x054c, 0x0268 ), k_eControllerType_PS3Controller, NULL }, // Sony PS3 Controller { MAKE_CONTROLLER_ID( 0x056e, 0x200f ), k_eControllerType_PS3Controller, NULL }, // From SDL diff --git a/src/joystick/hidapi/SDL_hidapi_ps3.c b/src/joystick/hidapi/SDL_hidapi_ps3.c index c09909eb9bdbc..1b10e9ffbad8a 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps3.c +++ b/src/joystick/hidapi/SDL_hidapi_ps3.c @@ -584,6 +584,11 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_IsSupportedDevice(SDL_HIDAPI_Device * Uint8 data[USB_PACKET_LENGTH]; int size; + if (vendor_id == USB_VENDOR_LOGITECH && + product_id == USB_PRODUCT_LOGITECH_CHILLSTREAM) { + return SDL_TRUE; + } + if ((type == SDL_CONTROLLER_TYPE_PS3 && vendor_id != USB_VENDOR_SONY) || HIDAPI_SupportsPlaystationDetection(vendor_id, product_id)) { if (device && device->dev) { @@ -769,7 +774,7 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket18(SDL_Joystick *joystic 0, /* SDL_GAMEPAD_BUTTON_LEFT_STICK */ 0, /* SDL_GAMEPAD_BUTTON_RIGHT_STICK */ 14, /* SDL_GAMEPAD_BUTTON_LEFT_SHOULDER */ - 16, /* SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER */ + 15, /* SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER */ 8, /* SDL_GAMEPAD_BUTTON_DPAD_UP */ 9, /* SDL_GAMEPAD_BUTTON_DPAD_DOWN */ 7, /* SDL_GAMEPAD_BUTTON_DPAD_LEFT */ diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c index 3f793fc9d2dc1..84767dca528d9 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/src/joystick/hidapi/SDL_hidapijoystick.c @@ -157,16 +157,12 @@ SDL_bool HIDAPI_SupportsPlaystationDetection(Uint16 vendor, Uint16 product) case USB_VENDOR_HORI: return SDL_TRUE; case USB_VENDOR_LOGITECH: - /* Most Logitech devices are fine with this, but there are a few exceptions */ - if (product == USB_PRODUCT_LOGITECH_F310) { - /* The Logitech F310 gamepad will lock up */ - return SDL_FALSE; - } - if (product == 0xc33f) { - /* The Logitech G815 keyboard will reset the LEDs */ - return SDL_FALSE; - } - return SDL_TRUE; + /* Most Logitech devices are not PlayStation controllers, and some of them + * lock up or reset when we send them the Sony third-party query feature + * report, so don't include that vendor here. Instead add devices as + * appropriate to controller_list.h + */ + return SDL_FALSE; case USB_VENDOR_MADCATZ: if (product == USB_PRODUCT_MADCATZ_SAITEK_SIDE_PANEL_CONTROL_DECK) { /* This is not a Playstation compatible device */ @@ -187,10 +183,10 @@ SDL_bool HIDAPI_SupportsPlaystationDetection(Uint16 vendor, Uint16 product) case USB_VENDOR_QANBA: return SDL_TRUE; case USB_VENDOR_RAZER: - /* Most Razer devices are not game controllers, and some of them lock up - * or reset when we send them the Sony third-party query feature report, - * so don't include that vendor here. Instead add devices as appropriate - * to controller_list.h + /* Most Razer devices are not PlayStation controllers, and some of them + * lock up or reset when we send them the Sony third-party query feature + * report, so don't include that vendor here. Instead add devices as + * appropriate to controller_list.h * * Reference: https://github.com/libsdl-org/SDL/issues/6733 * https://github.com/libsdl-org/SDL/issues/6799 From 785eac863bde7cc2ed9ba9617b73fe3216599b67 Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Thu, 6 Jun 2024 09:47:32 -0400 Subject: [PATCH 22/59] wayland: Set the initial min/max limits on non-libdecor windows during a show operation Libdecor windows will have this done during the first frame configure, but bare xdg-toplevel windows need it set explicitly, or a non-resizable window might be able to be resized. (cherry picked from commit fc6bbde525aa7702e74741283ecae0391610678d) --- src/video/wayland/SDL_waylandwindow.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index 34008d5e7af36..c8d55def1754d 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -1373,6 +1373,8 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window) data->shell_surface.xdg.roleobj.toplevel = xdg_surface_get_toplevel(data->shell_surface.xdg.surface); xdg_toplevel_set_app_id(data->shell_surface.xdg.roleobj.toplevel, c->classname); xdg_toplevel_add_listener(data->shell_surface.xdg.roleobj.toplevel, &toplevel_listener_xdg, data); + + SetMinMaxDimensions(window, SDL_FALSE); } } From e0b0a98c8e85fdecfaa7fe6dc30238e3ef88c5de Mon Sep 17 00:00:00 2001 From: Oleg Date: Thu, 6 Jun 2024 12:55:13 +0300 Subject: [PATCH 23/59] Added VRS DirectForce Pro wheelbase VID/PID to wheel devices list (cherry picked from commit 7529b4bed52e7a76806c4f863bacd99cff047332) (cherry picked from commit 0f9191a643f36bb095bb75567fd172cbeb5da89f) --- src/joystick/SDL_joystick.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index e3d8bae862ccd..05c9807c26eaf 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -373,6 +373,7 @@ static Uint32 initial_wheel_devices[] = { MAKE_VIDPID(0x044f, 0xb691), /* Thrustmaster TS-XW (initial mode) */ MAKE_VIDPID(0x044f, 0xb692), /* Thrustmaster TS-XW (active mode) */ MAKE_VIDPID(0x0483, 0x0522), /* Simagic Wheelbase (including M10, Alpha Mini, Alpha, Alpha U) */ + MAKE_VIDPID(0x0483, 0xa355), /* VRS DirectForce Pro Wheel Base */ MAKE_VIDPID(0x0eb7, 0x0001), /* Fanatec ClubSport Wheel Base V2 */ MAKE_VIDPID(0x0eb7, 0x0004), /* Fanatec ClubSport Wheel Base V2.5 */ MAKE_VIDPID(0x0eb7, 0x0005), /* Fanatec CSL Elite Wheel Base+ (PS4) */ From 6243a80b3f6716e17ac3993d30dc3652eae6ad54 Mon Sep 17 00:00:00 2001 From: Fabrice Desclaux Date: Mon, 3 Jun 2024 11:10:37 +0200 Subject: [PATCH 24/59] Fix spurious LCtrl on RAlt key pressed (cherry picked from commit 22c14442e22b432c69348211fc97c81248269d30) --- src/video/windows/SDL_windowsevents.c | 45 +++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index cb2a44c50b544..cfaef4f0850e4 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -638,6 +638,10 @@ WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) if (nCode < 0 || nCode != HC_ACTION) { return CallNextHookEx(NULL, nCode, wParam, lParam); } + if (hookData->scanCode == 0x21d) { + // Skip fake LCtrl when RAlt is pressed + return 1; + } switch (hookData->vkCode) { case VK_LWIN: @@ -692,6 +696,39 @@ WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) #endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ + +// Return 1 if spruious LCtrl is pressed +// LCtrl is sent when RAltGR is pressed +int skip_bad_lcrtl(WPARAM wParam, LPARAM lParam) +{ + MSG next_msg; + DWORD msg_time; + if (wParam != VK_CONTROL) { + return 0; + } + // Is this an extended key (i.e. right key)? + if (lParam & 0x01000000) + return 0; + + // Here is a trick: "Alt Gr" sends LCTRL, then RALT. We only + // want the RALT message, so we try to see if the next message + // is a RALT message. In that case, this is a false LCTRL! + msg_time = GetMessageTime(); + if (PeekMessage(&next_msg, NULL, 0, 0, PM_NOREMOVE)) { + if (next_msg.message == WM_KEYDOWN || + next_msg.message == WM_SYSKEYDOWN) { + if (next_msg.wParam == VK_MENU && + (next_msg.lParam & 0x01000000) && + next_msg.time == msg_time) { + // Next message is a RALT down message, which + // means that this is NOT a proper LCTRL message! + return 1; + } + } + } + return 0; +} + LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -1006,6 +1043,10 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_KEYDOWN: case WM_SYSKEYDOWN: { + if (skip_bad_lcrtl(wParam, lParam)) { + returnCode = 0; + break; + } SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam); const Uint8 *keyboardState = SDL_GetKeyboardState(NULL); @@ -1028,6 +1069,10 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_SYSKEYUP: case WM_KEYUP: { + if (skip_bad_lcrtl(wParam, lParam)) { + returnCode = 0; + break; + } SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam); const Uint8 *keyboardState = SDL_GetKeyboardState(NULL); From 4b91f0793c25451f50bf0dd26ca63c49c45c0cbe Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 7 Jun 2024 09:05:10 -0700 Subject: [PATCH 25/59] Fixed build (cherry picked from commit 2e8bd8f1f3f10f6581a34c1496342df2b34f313f) --- src/video/windows/SDL_windowsevents.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index cfaef4f0850e4..35bae2596a504 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -1043,12 +1043,13 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_KEYDOWN: case WM_SYSKEYDOWN: { + SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam); + const Uint8 *keyboardState = SDL_GetKeyboardState(NULL); + if (skip_bad_lcrtl(wParam, lParam)) { returnCode = 0; break; } - SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam); - const Uint8 *keyboardState = SDL_GetKeyboardState(NULL); /* Detect relevant keyboard shortcuts */ if (keyboardState[SDL_SCANCODE_LALT] == SDL_PRESSED || keyboardState[SDL_SCANCODE_RALT] == SDL_PRESSED) { @@ -1069,12 +1070,13 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_SYSKEYUP: case WM_KEYUP: { + SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam); + const Uint8 *keyboardState = SDL_GetKeyboardState(NULL); + if (skip_bad_lcrtl(wParam, lParam)) { returnCode = 0; break; } - SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam); - const Uint8 *keyboardState = SDL_GetKeyboardState(NULL); if (code != SDL_SCANCODE_UNKNOWN) { if (code == SDL_SCANCODE_PRINTSCREEN && From fbb964680621774b84f9d4a64d76e11b8d3cb19a Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 12 Jun 2024 23:03:50 -0700 Subject: [PATCH 26/59] Ignore spurious reply packets when reading Nintendo Switch controller reports (cherry picked from commit 5ee9a840b1b5f8f1dc60cb831d0a1143153ce51d) (cherry picked from commit f1b19aa744e7515181eeba848c4eb0dc6181c406) --- src/joystick/hidapi/SDL_hidapi_switch.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c index 6b5ea4d3a573f..40a012dd96979 100644 --- a/src/joystick/hidapi/SDL_hidapi_switch.c +++ b/src/joystick/hidapi/SDL_hidapi_switch.c @@ -2214,6 +2214,10 @@ static SDL_bool HIDAPI_DriverSwitch_UpdateDevice(SDL_HIDAPI_Device *device) continue; } + if (ctx->m_rgucReadBuffer[0] == k_eSwitchInputReportIDs_SubcommandReply) { + continue; + } + if (ctx->m_bInputOnly) { HandleInputOnlyControllerState(joystick, ctx, (SwitchInputOnlyControllerStatePacket_t *)&ctx->m_rgucReadBuffer[0]); } else { From 72e5620202c2dd12fc0e7b9304228224d791f337 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 12 Jun 2024 23:22:44 -0700 Subject: [PATCH 27/59] Try to guess the type of a Nintendo Switch controller if we can't read the device info (cherry picked from commit 6619de8f2441971b585f18e022668e1875d1991e) (cherry picked from commit 6b9bf711339f715298d9d2ba1c917045ef89fe51) --- src/joystick/hidapi/SDL_hidapi_switch.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c index 40a012dd96979..c518fb7949d50 100644 --- a/src/joystick/hidapi/SDL_hidapi_switch.c +++ b/src/joystick/hidapi/SDL_hidapi_switch.c @@ -1295,6 +1295,27 @@ static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device) break; case k_eSwitchDeviceInfoControllerType_Unknown: /* We couldn't read the device info for this controller, might not be fully compliant */ + if (device->vendor_id == USB_VENDOR_NINTENDO) { + switch (device->product_id) { + case USB_PRODUCT_NINTENDO_SWITCH_JOYCON_LEFT: + ctx->m_eControllerType = k_eSwitchDeviceInfoControllerType_JoyConLeft; + HIDAPI_SetDeviceName(device, "Nintendo Switch Joy-Con (L)"); + device->type = SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT; + break; + case USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT: + ctx->m_eControllerType = k_eSwitchDeviceInfoControllerType_JoyConRight; + HIDAPI_SetDeviceName(device, "Nintendo Switch Joy-Con (R)"); + device->type = SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT; + break; + case USB_PRODUCT_NINTENDO_SWITCH_PRO: + ctx->m_eControllerType = k_eSwitchDeviceInfoControllerType_ProController; + HIDAPI_SetDeviceName(device, "Nintendo Switch Pro Controller"); + device->type = SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO; + break; + default: + break; + } + } return; default: device->type = SDL_CONTROLLER_TYPE_UNKNOWN; From bd06e43b87e19310282afd9ba6b2f30c6b920869 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 12 Jun 2024 23:36:16 -0700 Subject: [PATCH 28/59] Re-enable full controller reports for Joy-Con controllers When they are in simple report mode, the thumbstick gets turned into a digital hat, so let's use them in full report mode. (cherry picked from commit bf27269952742a9cc5db6e0a840fce51996b8675) (cherry picked from commit 169f77ed5e23503c1ceb0e9e786f1a4e6cd2e057) --- src/joystick/hidapi/SDL_hidapi_switch.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c index c518fb7949d50..45a2260d1b035 100644 --- a/src/joystick/hidapi/SDL_hidapi_switch.c +++ b/src/joystick/hidapi/SDL_hidapi_switch.c @@ -762,6 +762,14 @@ static Uint8 GetDefaultInputMode(SDL_DriverSwitch_Context *ctx) #if 0 input_mode = k_eSwitchInputReportIDs_FullControllerState; #endif + + /* However, Joy-Con controllers switch their thumbsticks into D-pad mode in simple mode, + * so let's enable full controller state for them. + */ + if (ctx->device->product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_LEFT || + ctx->device->product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT) { + input_mode = k_eSwitchInputReportIDs_FullControllerState; + } } return input_mode; } From 499bff9c3a5ff21bee827b1df597394c5669477f Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Fri, 14 Jun 2024 14:50:10 +0300 Subject: [PATCH 29/59] SDL_qsort.c: fix calling conventions of private functions' compare args --- src/stdlib/SDL_qsort.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/stdlib/SDL_qsort.c b/src/stdlib/SDL_qsort.c index 0e5728ad33231..d1375ec40d882 100644 --- a/src/stdlib/SDL_qsort.c +++ b/src/stdlib/SDL_qsort.c @@ -28,7 +28,7 @@ #include "SDL_stdinc.h" #if defined(HAVE_QSORT) -void SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *)) +void SDL_qsort(void *base, size_t nmemb, size_t size, int (SDLCALL *compare) (const void *, const void *)) { if (!base) { return; @@ -368,7 +368,7 @@ typedef struct { char * first; char * last; } stack_entry; /* ---------------------------------------------------------------------- */ static char * pivot_big(char *first, char *mid, char *last, size_t size, - int compare(const void *, const void *)) { + int (SDLCALL * compare)(const void *, const void *)) { size_t d=(((last-first)/size)>>3)*size; #ifdef DEBUG_QSORT fprintf(stderr, "pivot_big: first=%p last=%p size=%lu n=%lu\n", first, (unsigned long)last, size, (unsigned long)((last-first+1)/size)); @@ -409,7 +409,7 @@ fprintf(stderr,"-> %d %d %d @ %p %p %p\n",*(int*)m1,*(int*)m2,*(int*)m3, m1,m2,m /* ---------------------------------------------------------------------- */ static void qsort_nonaligned(void *base, size_t nmemb, size_t size, - int (*compare)(const void *, const void *)) { + int (SDLCALL * compare)(const void *, const void *)) { stack_entry stack[STACK_SIZE]; int stacktop=0; @@ -440,7 +440,7 @@ static void qsort_nonaligned(void *base, size_t nmemb, size_t size, } static void qsort_aligned(void *base, size_t nmemb, size_t size, - int (*compare)(const void *, const void *)) { + int (SDLCALL * compare)(const void *, const void *)) { stack_entry stack[STACK_SIZE]; int stacktop=0; @@ -471,7 +471,7 @@ static void qsort_aligned(void *base, size_t nmemb, size_t size, } static void qsort_words(void *base, size_t nmemb, - int (*compare)(const void *, const void *)) { + int (SDLCALL * compare)(const void *, const void *)) { stack_entry stack[STACK_SIZE]; int stacktop=0; @@ -523,7 +523,7 @@ fprintf(stderr, "after partitioning first=#%lu last=#%lu\n", (first-(char*)base) /* ---------------------------------------------------------------------- */ extern void qsortG(void *base, size_t nmemb, size_t size, - int (*compare)(const void *, const void *)) { + int (SDLCALL * compare)(const void *, const void *)) { if (nmemb<=1) return; if (((size_t)base|size)&(WORD_BYTES-1)) @@ -536,7 +536,7 @@ extern void qsortG(void *base, size_t nmemb, size_t size, #endif /* HAVE_QSORT */ -void *SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compare)(const void *, const void *)) +void *SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (SDLCALL * compare)(const void *, const void *)) { #if defined(HAVE_BSEARCH) return bsearch(key, base, nmemb, size, compare); @@ -569,4 +569,3 @@ void *SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, } /* vi: set ts=4 sw=4 expandtab: */ - From 1cdd37b32c71de32206c45c22ddcdac9d5dc0bce Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Sat, 1 Jun 2024 01:15:02 +0300 Subject: [PATCH 30/59] always define PRI?64 using 'I64' when targeting windows avoids -Wformat warnings from mingw toolchains -- e.g.: src/test/SDL_test_harness.c:581:37: warning: unknown conversion type character 'l' in format [-Wformat=] (cherry picked from commit 49b6c24722e3c193f1093c728791ad5692766818) (cherry picked from commit 863670c0a8627f3c52bdfe87de61441efa294461) --- include/SDL_stdinc.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index 8c22283af0917..45e2a7830aae2 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -253,10 +253,10 @@ typedef uint64_t Uint64; * should define these but this is not true all platforms. * (for example win32) */ #ifndef SDL_PRIs64 -#ifdef PRIs64 -#define SDL_PRIs64 PRIs64 -#elif defined(__WIN32__) || defined(__GDK__) +#if defined(__WIN32__) || defined(__GDK__) #define SDL_PRIs64 "I64d" +#elif defined(PRIs64) +#define SDL_PRIs64 PRIs64 #elif defined(__LP64__) && !defined(__APPLE__) #define SDL_PRIs64 "ld" #else @@ -264,10 +264,10 @@ typedef uint64_t Uint64; #endif #endif #ifndef SDL_PRIu64 -#ifdef PRIu64 -#define SDL_PRIu64 PRIu64 -#elif defined(__WIN32__) || defined(__GDK__) +#if defined(__WIN32__) || defined(__GDK__) #define SDL_PRIu64 "I64u" +#elif defined(PRIu64) +#define SDL_PRIu64 PRIu64 #elif defined(__LP64__) && !defined(__APPLE__) #define SDL_PRIu64 "lu" #else @@ -275,10 +275,10 @@ typedef uint64_t Uint64; #endif #endif #ifndef SDL_PRIx64 -#ifdef PRIx64 -#define SDL_PRIx64 PRIx64 -#elif defined(__WIN32__) || defined(__GDK__) +#if defined(__WIN32__) || defined(__GDK__) #define SDL_PRIx64 "I64x" +#elif defined(PRIx64) +#define SDL_PRIx64 PRIx64 #elif defined(__LP64__) && !defined(__APPLE__) #define SDL_PRIx64 "lx" #else @@ -286,10 +286,10 @@ typedef uint64_t Uint64; #endif #endif #ifndef SDL_PRIX64 -#ifdef PRIX64 -#define SDL_PRIX64 PRIX64 -#elif defined(__WIN32__) || defined(__GDK__) +#if defined(__WIN32__) || defined(__GDK__) #define SDL_PRIX64 "I64X" +#elif defined(PRIX64) +#define SDL_PRIX64 PRIX64 #elif defined(__LP64__) && !defined(__APPLE__) #define SDL_PRIX64 "lX" #else From 325465935d85f9c70aec2df50be168f3ec76e7bc Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Fri, 14 Jun 2024 18:47:56 +0300 Subject: [PATCH 31/59] SDL_events.c: remove long long casts an the override of SDL_PRIs64 (cherry picked from commit a4d240d295e93cd48ca0d64e9ae82b2901d17876) --- src/events/SDL_events.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index 47f57214a1252..b432703b4d44c 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -34,13 +34,6 @@ #include "../video/SDL_sysvideo.h" #include "SDL_syswm.h" -#undef SDL_PRIs64 -#if (defined(__WIN32__) || defined(__GDK__)) && !defined(__CYGWIN__) -#define SDL_PRIs64 "I64d" -#else -#define SDL_PRIs64 "lld" -#endif - /* An arbitrary limit so we don't have unbounded growth */ #define SDL_MAX_QUEUED_EVENTS 65535 @@ -454,8 +447,8 @@ static void SDL_LogEvent(const SDL_Event *event) #define PRINT_FINGER_EVENT(event) \ (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u touchid=%" SDL_PRIs64 " fingerid=%" SDL_PRIs64 " x=%f y=%f dx=%f dy=%f pressure=%f)", \ - (uint)event->tfinger.timestamp, (long long)event->tfinger.touchId, \ - (long long)event->tfinger.fingerId, event->tfinger.x, event->tfinger.y, \ + (uint)event->tfinger.timestamp, event->tfinger.touchId, \ + event->tfinger.fingerId, event->tfinger.x, event->tfinger.y, \ event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure) SDL_EVENT_CASE(SDL_FINGERDOWN) PRINT_FINGER_EVENT(event); @@ -470,8 +463,8 @@ static void SDL_LogEvent(const SDL_Event *event) #define PRINT_DOLLAR_EVENT(event) \ (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u touchid=%" SDL_PRIs64 " gestureid=%" SDL_PRIs64 " numfingers=%u error=%f x=%f y=%f)", \ - (uint)event->dgesture.timestamp, (long long)event->dgesture.touchId, \ - (long long)event->dgesture.gestureId, (uint)event->dgesture.numFingers, \ + (uint)event->dgesture.timestamp, event->dgesture.touchId, \ + event->dgesture.gestureId, (uint)event->dgesture.numFingers, \ event->dgesture.error, event->dgesture.x, event->dgesture.y) SDL_EVENT_CASE(SDL_DOLLARGESTURE) PRINT_DOLLAR_EVENT(event); @@ -483,7 +476,7 @@ static void SDL_LogEvent(const SDL_Event *event) SDL_EVENT_CASE(SDL_MULTIGESTURE) (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u touchid=%" SDL_PRIs64 " dtheta=%f ddist=%f x=%f y=%f numfingers=%u)", - (uint)event->mgesture.timestamp, (long long)event->mgesture.touchId, + (uint)event->mgesture.timestamp, event->mgesture.touchId, event->mgesture.dTheta, event->mgesture.dDist, event->mgesture.x, event->mgesture.y, (uint)event->mgesture.numFingers); break; From f8943854fd2ff0f239af3de7d34838e95ac1702b Mon Sep 17 00:00:00 2001 From: Miku AuahDark Date: Mon, 17 Jun 2024 19:17:37 +0800 Subject: [PATCH 32/59] Android: Use SCREEN_ORIENTATION_FULL_USER instead of SCREEN_ORIENTATION_FULL_SENSOR for resizable window. The former will respect user orientation lock setting while the latter does not. (cherry picked from commit 3373667faa6c75bacd901b744dd38c60c7902753) (cherry picked from commit 77285b6c3fba3cad57a53c1b804926a679e07411) --- .../app/src/main/java/org/libsdl/app/SDLActivity.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java index d762e4e9d2ffc..cbb3275d865e9 100644 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -995,8 +995,8 @@ public void setOrientationBis(int w, int h, boolean resizable, String hint) /* No valid hint, nothing is explicitly allowed */ if (!is_portrait_allowed && !is_landscape_allowed) { if (resizable) { - /* All orientations are allowed */ - req = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR; + /* All orientations are allowed, respecting user orientation lock setting */ + req = ActivityInfo.SCREEN_ORIENTATION_FULL_USER; } else { /* Fixed window and nothing specified. Get orientation from w/h of created window */ req = (w > h ? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); @@ -1005,8 +1005,8 @@ public void setOrientationBis(int w, int h, boolean resizable, String hint) /* At least one orientation is allowed */ if (resizable) { if (is_portrait_allowed && is_landscape_allowed) { - /* hint allows both landscape and portrait, promote to full sensor */ - req = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR; + /* hint allows both landscape and portrait, promote to full user */ + req = ActivityInfo.SCREEN_ORIENTATION_FULL_USER; } else { /* Use the only one allowed "orientation" */ req = (is_landscape_allowed ? orientation_landscape : orientation_portrait); From 30e2b03a654fb7c95a46df2b4167f567be2f2027 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 17 Jun 2024 12:11:35 -0700 Subject: [PATCH 33/59] Pass through the original name used by the Steam Virtual Gamepad Proton uses this on Linux to determine what the XInput slot is for the gamepad. Other applications will get the real controller name and VID/PID by virtue of the code in SDL_steam_virtual_gamepad.c (cherry picked from commit 361cae087495653286c523d664d2031e2f0dafe7) (cherry picked from commit a6fdd155fbe0f366c087db98372f0ea521b028b7) --- src/joystick/controller_list.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/joystick/controller_list.h b/src/joystick/controller_list.h index fb124798123a2..fd77b2a9d5a1d 100644 --- a/src/joystick/controller_list.h +++ b/src/joystick/controller_list.h @@ -595,7 +595,7 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x28de, 0x1102 ), k_eControllerType_SteamController, NULL }, // Valve wired Steam Controller (D0G) { MAKE_CONTROLLER_ID( 0x28de, 0x1105 ), k_eControllerType_SteamController, NULL }, // Valve Bluetooth Steam Controller (D0G) { MAKE_CONTROLLER_ID( 0x28de, 0x1106 ), k_eControllerType_SteamController, NULL }, // Valve Bluetooth Steam Controller (D0G) - { MAKE_CONTROLLER_ID( 0x28de, 0x11ff ), k_eControllerType_UnknownNonSteamController, "Steam Virtual Gamepad" }, // Steam virtual gamepad + { MAKE_CONTROLLER_ID( 0x28de, 0x11ff ), k_eControllerType_UnknownNonSteamController, NULL }, // Steam Virtual Gamepad { MAKE_CONTROLLER_ID( 0x28de, 0x1142 ), k_eControllerType_SteamController, NULL }, // Valve wireless Steam Controller { MAKE_CONTROLLER_ID( 0x28de, 0x1201 ), k_eControllerType_SteamControllerV2, NULL }, // Valve wired Steam Controller (HEADCRAB) { MAKE_CONTROLLER_ID( 0x28de, 0x1202 ), k_eControllerType_SteamControllerV2, NULL }, // Valve Bluetooth Steam Controller (HEADCRAB) From 92fe3b19c868ad062c323dde2cfc9d8b4bfdd785 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 17 Jun 2024 12:32:13 -0700 Subject: [PATCH 34/59] Updated to version 2.30.4 for release --- CMakeLists.txt | 2 +- Makefile.os2 | 2 +- Makefile.w32 | 2 +- Xcode/SDL/Info-Framework.plist | 4 ++-- Xcode/SDL/SDL.xcodeproj/project.pbxproj | 12 ++++++------ Xcode/SDL/pkg-support/SDL.info | 2 +- .../src/main/java/org/libsdl/app/SDLActivity.java | 2 +- configure | 2 +- configure.ac | 2 +- include/SDL_version.h | 2 +- src/main/windows/version.rc | 8 ++++---- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c44fa80227dc3..8b5bd7056535d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,7 +87,7 @@ endif() # See docs/release_checklist.md set(SDL_MAJOR_VERSION 2) set(SDL_MINOR_VERSION 30) -set(SDL_MICRO_VERSION 3) +set(SDL_MICRO_VERSION 4) set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}") # Set defaults preventing destination file conflicts diff --git a/Makefile.os2 b/Makefile.os2 index f2fe6d1cb180c..ca8b876d18850 100644 --- a/Makefile.os2 +++ b/Makefile.os2 @@ -15,7 +15,7 @@ LIBNAME = SDL2 MAJOR_VERSION = 2 MINOR_VERSION = 30 -MICRO_VERSION = 3 +MICRO_VERSION = 4 VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION) DESCRIPTION = Simple DirectMedia Layer 2 diff --git a/Makefile.w32 b/Makefile.w32 index 613884a5f21a4..aacdd83d63a03 100644 --- a/Makefile.w32 +++ b/Makefile.w32 @@ -6,7 +6,7 @@ LIBNAME = SDL2 MAJOR_VERSION = 2 MINOR_VERSION = 30 -MICRO_VERSION = 3 +MICRO_VERSION = 4 VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION) LIBHOME = . diff --git a/Xcode/SDL/Info-Framework.plist b/Xcode/SDL/Info-Framework.plist index 9815221613e3f..fc1167f1a3414 100644 --- a/Xcode/SDL/Info-Framework.plist +++ b/Xcode/SDL/Info-Framework.plist @@ -19,10 +19,10 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.30.3 + 2.30.4 CFBundleSignature SDLX CFBundleVersion - 2.30.3 + 2.30.4 diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj index 670c98e83ef77..d260331509064 100644 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -9729,7 +9729,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEPLOYMENT_POSTPROCESSING = YES; DYLIB_COMPATIBILITY_VERSION = 3001.0.0; - DYLIB_CURRENT_VERSION = 3001.3.0; + DYLIB_CURRENT_VERSION = 3001.4.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_ALTIVEC_EXTENSIONS = YES; @@ -9770,7 +9770,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_LINK_OBJC_RUNTIME = NO; - MARKETING_VERSION = 2.30.3; + MARKETING_VERSION = 2.30.4; OTHER_LDFLAGS = "-liconv"; }; name = Release; @@ -9814,7 +9814,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 3001.0.0; - DYLIB_CURRENT_VERSION = 3001.3.0; + DYLIB_CURRENT_VERSION = 3001.4.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -9856,7 +9856,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_LINK_OBJC_RUNTIME = NO; - MARKETING_VERSION = 2.30.3; + MARKETING_VERSION = 2.30.4; OTHER_LDFLAGS = "-liconv"; }; name = Debug; @@ -10063,7 +10063,7 @@ DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 3001.0.0; - DYLIB_CURRENT_VERSION = 3001.3.0; + DYLIB_CURRENT_VERSION = 3001.4.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; @@ -10115,7 +10115,7 @@ DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 3001.0.0; - DYLIB_CURRENT_VERSION = 3001.3.0; + DYLIB_CURRENT_VERSION = 3001.4.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_NS_ASSERTIONS = NO; GCC_C_LANGUAGE_STANDARD = gnu11; diff --git a/Xcode/SDL/pkg-support/SDL.info b/Xcode/SDL/pkg-support/SDL.info index 7808139ce10ec..87eff0c52bfcb 100644 --- a/Xcode/SDL/pkg-support/SDL.info +++ b/Xcode/SDL/pkg-support/SDL.info @@ -1,4 +1,4 @@ -Title SDL 2.30.3 +Title SDL 2.30.4 Version 1 Description SDL Library for Mac OS X (http://www.libsdl.org) DefaultLocation /Library/Frameworks diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java index cbb3275d865e9..a88c4611946c9 100644 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -61,7 +61,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh private static final String TAG = "SDL"; private static final int SDL_MAJOR_VERSION = 2; private static final int SDL_MINOR_VERSION = 30; - private static final int SDL_MICRO_VERSION = 3; + private static final int SDL_MICRO_VERSION = 4; /* // Display InputType.SOURCE/CLASS of events and devices // diff --git a/configure b/configure index 3218dd532cdbd..4c2bb0444a7af 100755 --- a/configure +++ b/configure @@ -3508,7 +3508,7 @@ orig_CFLAGS="$CFLAGS" # See docs/release_checklist.md SDL_MAJOR_VERSION=2 SDL_MINOR_VERSION=30 -SDL_MICRO_VERSION=3 +SDL_MICRO_VERSION=4 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION` diff --git a/configure.ac b/configure.ac index 2bcdd8d4ea8a4..67ef7ebfce55c 100644 --- a/configure.ac +++ b/configure.ac @@ -13,7 +13,7 @@ dnl Set various version strings - taken gratefully from the GTk sources # See docs/release_checklist.md SDL_MAJOR_VERSION=2 SDL_MINOR_VERSION=30 -SDL_MICRO_VERSION=3 +SDL_MICRO_VERSION=4 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION` diff --git a/include/SDL_version.h b/include/SDL_version.h index b7b7f39b60689..d05fed77c2207 100644 --- a/include/SDL_version.h +++ b/include/SDL_version.h @@ -59,7 +59,7 @@ typedef struct SDL_version */ #define SDL_MAJOR_VERSION 2 #define SDL_MINOR_VERSION 30 -#define SDL_PATCHLEVEL 3 +#define SDL_PATCHLEVEL 4 /** * Macro to determine SDL version program was compiled against. diff --git a/src/main/windows/version.rc b/src/main/windows/version.rc index 01a21be5d604a..4862fdd649a59 100644 --- a/src/main/windows/version.rc +++ b/src/main/windows/version.rc @@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,30,3,0 - PRODUCTVERSION 2,30,3,0 + FILEVERSION 2,30,4,0 + PRODUCTVERSION 2,30,4,0 FILEFLAGSMASK 0x3fL FILEFLAGS 0x0L FILEOS 0x40004L @@ -23,12 +23,12 @@ BEGIN BEGIN VALUE "CompanyName", "\0" VALUE "FileDescription", "SDL\0" - VALUE "FileVersion", "2, 30, 3, 0\0" + VALUE "FileVersion", "2, 30, 4, 0\0" VALUE "InternalName", "SDL\0" VALUE "LegalCopyright", "Copyright (C) 2024 Sam Lantinga\0" VALUE "OriginalFilename", "SDL2.dll\0" VALUE "ProductName", "Simple DirectMedia Layer\0" - VALUE "ProductVersion", "2, 30, 3, 0\0" + VALUE "ProductVersion", "2, 30, 4, 0\0" END END BLOCK "VarFileInfo" From 630272eb552618e4cfa40f5bef2c5d64f5b85f7a Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 17 Jun 2024 15:10:33 -0700 Subject: [PATCH 35/59] Fixed requesting USB permission on Android 14 (thanks @ikhoeyZX!) Fixes https://github.com/libsdl-org/SDL/issues/9831 (cherry picked from commit 8ab1ffca8abe8c7db5bdf24175b724374b78579e) (cherry picked from commit 5a26b26880539e4c54e8457290a8586a0a086ca8) --- .../src/main/java/org/libsdl/app/HIDDeviceManager.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java b/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java index e7281fdf26ac4..ea6b5d5b17a18 100644 --- a/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java +++ b/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java @@ -590,7 +590,13 @@ public boolean openDevice(int deviceID) { } else { flags = 0; } - mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mContext, 0, new Intent(HIDDeviceManager.ACTION_USB_PERMISSION), flags)); + if (Build.VERSION.SDK_INT >= 33 /* Android 14.0 (U) */) { + Intent intent = new Intent(HIDDeviceManager.ACTION_USB_PERMISSION); + intent.setPackage(mContext.getPackageName()); + mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mContext, 0, intent, flags)); + } else { + mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mContext, 0, new Intent(HIDDeviceManager.ACTION_USB_PERMISSION), flags)); + } } catch (Exception e) { Log.v(TAG, "Couldn't request permission for USB device " + usbDevice); HIDDeviceOpenResult(deviceID, false); From a9bb92b3aec9da7abe724591d848d2f61959756b Mon Sep 17 00:00:00 2001 From: Aikawa Yataro Date: Wed, 19 Jun 2024 00:09:45 +0000 Subject: [PATCH 36/59] Update qsort implementation (cherry picked from commit 0fe9f5da54cf19021bf0b688877f0642b96edc78) (cherry picked from commit 4800edfa0c997a79b3d7527d00474074466b5ad6) --- src/stdlib/SDL_qsort.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/stdlib/SDL_qsort.c b/src/stdlib/SDL_qsort.c index d1375ec40d882..91fb1d23485c2 100644 --- a/src/stdlib/SDL_qsort.c +++ b/src/stdlib/SDL_qsort.c @@ -65,7 +65,7 @@ void SDL_qsort(void *base, size_t nmemb, size_t size, int (SDLCALL *compare) (co /* This code came from Gareth McCaughan, under the zlib license. -Specifically this: https://www.mccaughan.org.uk/software/qsort.c-1.15 +Specifically this: https://www.mccaughan.org.uk/software/qsort.c-1.16 Everything below this comment until the HAVE_QSORT #endif was from Gareth (any minor changes will be noted inline). @@ -112,7 +112,7 @@ benefit! * Gareth McCaughan */ -/* Copyright (c) 1998-2016 Gareth McCaughan +/* Copyright (c) 1998-2021 Gareth McCaughan * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any @@ -148,17 +148,23 @@ benefit! * (pre-insertion-sort messed up). * Disable DEBUG_QSORT by default. * Tweak comments very slightly. + * 2021-02-20 v1.16 Fix bug kindly reported by Ray Gardner + * (error in recursion leading to possible + * stack overflow). + * When checking alignment, avoid casting + * pointer to possibly-smaller integer. */ /* BEGIN SDL CHANGE ... commented this out with an #if 0 block. --ryan. */ #if 0 #include +#include #include #include #undef DEBUG_QSORT -static char _ID[]=""; +static char _ID[]=""; #endif /* END SDL CHANGE ... commented this out with an #if 0 block. --ryan. */ @@ -168,7 +174,8 @@ static char _ID[]=""; #define WORD_BYTES sizeof(int) /* How big does our stack need to be? Answer: one entry per - * bit in a |size_t|. + * bit in a |size_t|. (Actually, a bit less because we don't + * recurse all the way down to size-1 subarrays.) */ #define STACK_SIZE (8*sizeof(size_t)) @@ -207,11 +214,12 @@ typedef struct { char * first; char * last; } stack_entry; * on large datasets for locality-of-reference reasons, * but it makes the code much nastier and increases * bookkeeping overhead. - * 2. We always save the shorter and get to work on the - * longer. This guarantees that every time we push - * an item onto the stack its size is <= 1/2 of that - * of its parent; so the stack can't need more than - * log_2(max-array-size) entries. + * 2. We always save the longer and get to work on the + * shorter. This guarantees that whenever we push + * a k'th entry onto the stack we are about to get + * working on something of size <= N/2^k where N is + * the original array size; so the stack can't need + * more than log_2(max-array-size) entries. * 3. We choose a pivot by looking at the first, last * and middle elements. We arrange them into order * because it's easy to do that in conjunction with @@ -273,8 +281,8 @@ typedef struct { char * first; char * last; } stack_entry; if (r>=Trunc) doRight \ else pop \ } \ - else if (l<=r) { pushLeft; doRight } \ - else if (r>=Trunc) { pushRight; doLeft }\ + else if (l<=r) { pushRight; doLeft } \ + else if (r>=Trunc) { pushLeft; doRight }\ else doLeft \ } @@ -526,7 +534,7 @@ extern void qsortG(void *base, size_t nmemb, size_t size, int (SDLCALL * compare)(const void *, const void *)) { if (nmemb<=1) return; - if (((size_t)base|size)&(WORD_BYTES-1)) + if (((uintptr_t)base|size)&(WORD_BYTES-1)) qsort_nonaligned(base,nmemb,size,compare); else if (size!=WORD_BYTES) qsort_aligned(base,nmemb,size,compare); From 8b204815ccef946db9db28c3d2da0790a88f8c3c Mon Sep 17 00:00:00 2001 From: expikr <77922942+expikr@users.noreply.github.com> Date: Sun, 16 Jun 2024 06:21:29 -0700 Subject: [PATCH 37/59] Add SDL_MOUSE_RELATIVE_CURSOR_VISIBLE (#7947) (cherry picked from commit ee559d51bed864968e529d4e63e2019d9de72291) (cherry picked from commit 194d72bb29d22427a53bde63d1634bfdbd07fcc4) --- include/SDL_hints.h | 14 +++++++++++++- src/events/SDL_mouse.c | 15 ++++++++++++++- src/events/SDL_mouse_c.h | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/include/SDL_hints.h b/include/SDL_hints.h index e775a6509bc0e..a26ab60e869d4 100644 --- a/include/SDL_hints.h +++ b/include/SDL_hints.h @@ -1424,7 +1424,19 @@ extern "C" { #define SDL_HINT_MOUSE_RELATIVE_WARP_MOTION "SDL_MOUSE_RELATIVE_WARP_MOTION" /** - * \brief A variable controlling whether mouse events should generate synthetic touch events + * \brief A variable controlling whether the hardware cursor stays visible when relative mode is active. + * + * This variable can be set to the following values: + * "0" - The cursor will be hidden while relative mode is active (default) + * "1" - The cursor will remain visible while relative mode is active + * + * Note that for systems without raw hardware inputs, relative mode is implemented using warping, so the hardware cursor will visibly warp between frames if this is enabled on those systems. + */ +#define SDL_HINT_MOUSE_RELATIVE_CURSOR_VISIBLE "SDL_MOUSE_RELATIVE_CURSOR_VISIBLE" + +/** + * A variable controlling whether mouse events should generate synthetic touch + * events * * This variable can be set to the following values: * "0" - Mouse events will not generate touch events (default for desktop platforms) diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index 431354f88b39b..b13383279d768 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -170,6 +170,13 @@ static void SDLCALL SDL_MouseRelativeWarpMotionChanged(void *userdata, const cha mouse->relative_mode_warp_motion = SDL_GetStringBoolean(hint, SDL_FALSE); } +static void SDLCALL SDL_MouseRelativeCursorVisibleChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +{ + SDL_Mouse *mouse = (SDL_Mouse *)userdata; + + mouse->relative_mode_cursor_visible = SDL_GetStringBoolean(hint, SDL_FALSE); +} + /* Public functions */ int SDL_MousePreInit(void) { @@ -209,6 +216,9 @@ int SDL_MousePreInit(void) SDL_AddHintCallback(SDL_HINT_MOUSE_RELATIVE_WARP_MOTION, SDL_MouseRelativeWarpMotionChanged, mouse); + SDL_AddHintCallback(SDL_HINT_MOUSE_RELATIVE_CURSOR_VISIBLE, + SDL_MouseRelativeCursorVisibleChanged, mouse); + mouse->was_touch_mouse_events = SDL_FALSE; /* no touch to mouse movement event pending */ mouse->cursor_shown = SDL_TRUE; @@ -992,6 +1002,9 @@ void SDL_MouseQuit(void) SDL_DelHintCallback(SDL_HINT_MOUSE_RELATIVE_WARP_MOTION, SDL_MouseRelativeWarpMotionChanged, mouse); + + SDL_DelHintCallback(SDL_HINT_MOUSE_RELATIVE_CURSOR_VISIBLE, + SDL_MouseRelativeCursorVisibleChanged, mouse); } Uint32 SDL_GetMouseState(int *x, int *y) @@ -1412,7 +1425,7 @@ void SDL_SetCursor(SDL_Cursor *cursor) } } - if (cursor && mouse->cursor_shown && !mouse->relative_mode) { + if (cursor && mouse->cursor_shown && (!mouse->relative_mode || mouse->relative_mode_cursor_visible)) { if (mouse->ShowCursor) { mouse->ShowCursor(cursor); } diff --git a/src/events/SDL_mouse_c.h b/src/events/SDL_mouse_c.h index 4204f6201f746..db1c6c4f6fd25 100644 --- a/src/events/SDL_mouse_c.h +++ b/src/events/SDL_mouse_c.h @@ -92,6 +92,7 @@ typedef struct SDL_bool relative_mode; SDL_bool relative_mode_warp; SDL_bool relative_mode_warp_motion; + SDL_bool relative_mode_cursor_visible; SDL_bool enable_normal_speed_scale; float normal_speed_scale; SDL_bool enable_relative_speed_scale; From c32a1a502309d99b3113d22bf4ca0f1b5359ba14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Toma=C5=BEi=C4=8D?= Date: Thu, 20 Jun 2024 09:48:02 +0200 Subject: [PATCH 38/59] android: actually use ReLinker When loading libraries the `SDL.mContext` is still `null`. This results in relinker code path in `SDL.loadLibrary(...)` always throwing a null exception and fallbacking to system loader. Fix it by passing the context explicitly. (cherry picked from commit 6a2dd96ac7ce5c0575e91290a983048c0e5e6d2c) --- .../app/src/main/java/org/libsdl/app/SDLActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java index a88c4611946c9..6ea366205f577 100644 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -281,7 +281,7 @@ protected String[] getLibraries() { // Load the .so public void loadLibraries() { for (String lib : getLibraries()) { - SDL.loadLibrary(lib); + SDL.loadLibrary(lib, this); } } From 53cf48f5057b1c1c901d52ba521f866ddd60d4c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Toma=C5=BEi=C4=8D?= Date: Thu, 20 Jun 2024 09:45:00 +0200 Subject: [PATCH 39/59] android: add an option to manually pass the context when loading a native library (cherry picked from commit b444e656cdb488ae86fac6479e75fead561546eb) --- .../app/src/main/java/org/libsdl/app/SDL.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/android-project/app/src/main/java/org/libsdl/app/SDL.java b/android-project/app/src/main/java/org/libsdl/app/SDL.java index 44c21c1c75c95..139be9d151c39 100644 --- a/android-project/app/src/main/java/org/libsdl/app/SDL.java +++ b/android-project/app/src/main/java/org/libsdl/app/SDL.java @@ -38,6 +38,10 @@ public static Context getContext() { } public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError, SecurityException, NullPointerException { + loadLibrary(libraryName, mContext); + } + + public static void loadLibrary(String libraryName, Context context) throws UnsatisfiedLinkError, SecurityException, NullPointerException { if (libraryName == null) { throw new NullPointerException("No library name provided."); @@ -53,10 +57,10 @@ public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError, // To use ReLinker, just add it as a dependency. For more information, see // https://github.com/KeepSafe/ReLinker for ReLinker's repository. // - Class relinkClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker"); - Class relinkListenerClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener"); - Class contextClass = mContext.getClassLoader().loadClass("android.content.Context"); - Class stringClass = mContext.getClassLoader().loadClass("java.lang.String"); + Class relinkClass = context.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker"); + Class relinkListenerClass = context.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener"); + Class contextClass = context.getClassLoader().loadClass("android.content.Context"); + Class stringClass = context.getClassLoader().loadClass("java.lang.String"); // Get a 'force' instance of the ReLinker, so we can ensure libraries are reinstalled if // they've changed during updates. @@ -66,7 +70,7 @@ public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError, // Actually load the library! Method loadMethod = relinkInstanceClass.getDeclaredMethod("loadLibrary", contextClass, stringClass, stringClass, relinkListenerClass); - loadMethod.invoke(relinkInstance, mContext, libraryName, null, null); + loadMethod.invoke(relinkInstance, context, libraryName, null, null); } catch (final Throwable e) { // Fall back From f08f458896d99f63b829c994623f8b9701d7eaf9 Mon Sep 17 00:00:00 2001 From: Ganael Laplanche Date: Sat, 22 Jun 2024 18:14:16 +0200 Subject: [PATCH 40/59] Fix joystick (/dev/input/xxx) support on FreeBSD Backport f8ad4abe from main branch. When switching to CMake, src/joystick/linux/SDL_sysjoystick.c file got excluded from FreeBSD builds, losing support for /dev/input/xxx devices. See also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=279907 and: https://github.com/libsdl-org/SDL/pull/10087 (cherry picked from commit ab5740bde2ac593f5a6821ec2ac3800cdfcaf754) --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b5bd7056535d..a98d3cc6e4b84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1674,7 +1674,7 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU) if(FREEBSD OR NETBSD OR OPENBSD OR BSDI) CheckUSBHID() endif() - if(LINUX AND HAVE_LINUX_INPUT_H AND NOT ANDROID) + if((LINUX OR FREEBSD) AND HAVE_LINUX_INPUT_H AND NOT ANDROID) set(SDL_JOYSTICK_LINUX 1) file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/linux/*.c ${SDL2_SOURCE_DIR}/src/joystick/steam/*.c) list(APPEND SOURCE_FILES ${JOYSTICK_SOURCES}) From c18173c260e99752c972f7dda0b6a4cc33164dc1 Mon Sep 17 00:00:00 2001 From: Edoardo Lolletti Date: Mon, 24 Jun 2024 19:45:37 +0200 Subject: [PATCH 41/59] Fix std::thread memory leak In the stdcpp thread implementation, the allocated std::thread objects were never deleted after joining/detaching (cherry picked from commit 20dbe907714730a7d7ab1957beafbfb608e20320) (cherry picked from commit 99d7b9e6268d2037967090947b1ee77b2cb2a2c0) --- src/thread/stdcpp/SDL_systhread.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/thread/stdcpp/SDL_systhread.cpp b/src/thread/stdcpp/SDL_systhread.cpp index 3d93a014dd13b..5b052bf373656 100644 --- a/src/thread/stdcpp/SDL_systhread.cpp +++ b/src/thread/stdcpp/SDL_systhread.cpp @@ -120,8 +120,12 @@ SDL_SYS_WaitThread(SDL_Thread *thread) try { std::thread *cpp_thread = (std::thread *)thread->handle; - if (cpp_thread->joinable()) { - cpp_thread->join(); + if (cpp_thread) { + if (cpp_thread->joinable()) { + cpp_thread->join(); + } + delete cpp_thread; + thread->handle = nullptr; } } catch (std::system_error &) { // An error occurred when joining the thread. SDL_WaitThread does not, @@ -139,8 +143,12 @@ SDL_SYS_DetachThread(SDL_Thread *thread) try { std::thread *cpp_thread = (std::thread *)thread->handle; - if (cpp_thread->joinable()) { - cpp_thread->detach(); + if (cpp_thread) { + if (cpp_thread->joinable()) { + cpp_thread->detach(); + } + delete cpp_thread; + thread->handle = nullptr; } } catch (std::system_error &) { // An error occurred when detaching the thread. SDL_DetachThread does not, From 620e875335e35a6cc6c187079951f598bfd3b595 Mon Sep 17 00:00:00 2001 From: Cecill Etheredge Date: Tue, 25 Jun 2024 22:43:32 +0200 Subject: [PATCH 42/59] fix: Use drmModeAddFB2WithModifiers instead of drmModeAddFB to allow using GBM modifiers. This fixes corrupt framebuffers on platforms that require the use of modifiers. --- src/video/kmsdrm/SDL_kmsdrmsym.h | 9 +++++++++ src/video/kmsdrm/SDL_kmsdrmvideo.c | 32 +++++++++++++++++++++--------- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/video/kmsdrm/SDL_kmsdrmsym.h b/src/video/kmsdrm/SDL_kmsdrmsym.h index d1e856f4b77ce..49680448984c1 100644 --- a/src/video/kmsdrm/SDL_kmsdrmsym.h +++ b/src/video/kmsdrm/SDL_kmsdrmsym.h @@ -54,6 +54,11 @@ SDL_KMSDRM_SYM(int,drmModeAddFB2,(int fd, uint32_t width, uint32_t height, const uint32_t pitches[4], const uint32_t offsets[4], uint32_t *buf_id, uint32_t flags)) +SDL_KMSDRM_SYM(int,drmModeAddFB2WithModifiers,(int fd, uint32_t width, + uint32_t height, uint32_t pixel_format, const uint32_t bo_handles[4], + const uint32_t pitches[4], const uint32_t offsets[4], + const uint64_t modifier[4], uint32_t *buf_id, uint32_t flags)) + SDL_KMSDRM_SYM(int,drmModeRmFB,(int fd, uint32_t bufferId)) SDL_KMSDRM_SYM(drmModeFBPtr,drmModeGetFB,(int fd, uint32_t buf)) SDL_KMSDRM_SYM(drmModeCrtcPtr,drmModeGetCrtc,(int fd, uint32_t crtcId)) @@ -124,6 +129,10 @@ SDL_KMSDRM_SYM(void,gbm_surface_destroy,(struct gbm_surface *surf)) SDL_KMSDRM_SYM(struct gbm_bo *,gbm_surface_lock_front_buffer,(struct gbm_surface *surf)) SDL_KMSDRM_SYM(void,gbm_surface_release_buffer,(struct gbm_surface *surf, struct gbm_bo *bo)) +SDL_KMSDRM_SYM(uint64_t,gbm_bo_get_modifier,(struct gbm_bo *bo)) +SDL_KMSDRM_SYM(int,gbm_bo_get_plane_count,(struct gbm_bo *bo)) +SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_offset,(struct gbm_bo *bo, int plane)) +SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_stride_for_plane,(struct gbm_bo *bo, int plane)) #undef SDL_KMSDRM_MODULE #undef SDL_KMSDRM_SYM diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index bdcd2207adea6..2dab65cbccc0e 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -336,8 +336,9 @@ KMSDRM_FBInfo *KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo) { SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); unsigned w, h; - int ret; - Uint32 stride, handle; + int ret, num_planes = 0; + Uint32 format, strides[4] = { 0 }, handles[4] = { 0 }, offsets[4] = { 0 }, flags = 0; + uint64_t modifiers[4] = { 0 }; /* Check for an existing framebuffer */ KMSDRM_FBInfo *fb_info = (KMSDRM_FBInfo *)KMSDRM_gbm_bo_get_user_data(bo); @@ -357,20 +358,33 @@ KMSDRM_FBInfo *KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo) fb_info->drm_fd = viddata->drm_fd; - /* Create framebuffer object for the buffer */ + /* Create framebuffer object for the buffer using the modifiers requested by GBM. + Use of the modifiers is necessary on some platforms. */ w = KMSDRM_gbm_bo_get_width(bo); h = KMSDRM_gbm_bo_get_height(bo); - stride = KMSDRM_gbm_bo_get_stride(bo); - handle = KMSDRM_gbm_bo_get_handle(bo).u32; - ret = KMSDRM_drmModeAddFB(viddata->drm_fd, w, h, 24, 32, stride, handle, - &fb_info->fb_id); + format = KMSDRM_gbm_bo_get_format(bo); + + modifiers[0] = KMSDRM_gbm_bo_get_modifier(bo); + num_planes = KMSDRM_gbm_bo_get_plane_count(bo); + for (int i = 0; i < num_planes; i++) { + strides[i] = KMSDRM_gbm_bo_get_stride_for_plane(bo, i); + handles[i] = KMSDRM_gbm_bo_get_handle(bo).u32; + offsets[i] = KMSDRM_gbm_bo_get_offset(bo, i); + modifiers[i] = modifiers[0]; + } + + if (modifiers[0]) { + flags = DRM_MODE_FB_MODIFIERS; + } + + ret = KMSDRM_drmModeAddFB2WithModifiers(viddata->drm_fd, w, h, format, handles, strides, offsets, modifiers, &fb_info->fb_id, flags); if (ret) { SDL_free(fb_info); return NULL; } - SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "New DRM FB (%u): %ux%u, stride %u from BO %p", - fb_info->fb_id, w, h, stride, (void *)bo); + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "New DRM FB (%u): %ux%u, from BO %p", + fb_info->fb_id, w, h, (void *)bo); /* Associate our DRM framebuffer with this buffer object */ KMSDRM_gbm_bo_set_user_data(bo, fb_info, KMSDRM_FBDestroyCallback); From 31f77182d0bab34b1e9f5bf0c69b8bc6e231d270 Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Fri, 21 Jun 2024 12:59:21 -0400 Subject: [PATCH 43/59] wayland: Fix double free when deleting an output display (cherry picked from commit 3b88d4f46f94e8adafc77ea0edd317b5e61d196c) --- src/video/wayland/SDL_waylandvideo.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c index 9b593cc917704..11f3695e385c1 100644 --- a/src/video/wayland/SDL_waylandvideo.c +++ b/src/video/wayland/SDL_waylandvideo.c @@ -751,12 +751,11 @@ static void Wayland_free_display(SDL_VideoData *d, uint32_t id) } } } - SDL_DelVideoDisplay(i); if (data->xdg_output) { zxdg_output_v1_destroy(data->xdg_output); } wl_output_destroy(data->output); - SDL_free(data); + SDL_DelVideoDisplay(i); /* Update the index for all remaining displays */ num_displays -= 1; @@ -1016,9 +1015,6 @@ static void Wayland_VideoCleanup(_THIS) } wl_output_destroy(((SDL_WaylandOutputData *)display->driverdata)->output); - SDL_free(display->driverdata); - display->driverdata = NULL; - SDL_DelVideoDisplay(i); } data->output_list = NULL; From 0f5752b0fc305f2ce6df680ffd81ee2bead77ac6 Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Fri, 21 Jun 2024 13:02:36 -0400 Subject: [PATCH 44/59] video: Fix memory leak when deleting a video display The display deletion code would not free the driver data or name if the display index was the last, or only one, in the list. (cherry picked from commit 20f1061cc86b07146ba410e551d4994cd430e209) --- src/video/SDL_video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index ee723a57b197f..26c7b8ad718a2 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -672,9 +672,9 @@ void SDL_DelVideoDisplay(int index) SDL_SendDisplayEvent(&_this->displays[index], SDL_DISPLAYEVENT_DISCONNECTED, 0); + SDL_free(_this->displays[index].driverdata); + SDL_free(_this->displays[index].name); if (index < (_this->num_displays - 1)) { - SDL_free(_this->displays[index].driverdata); - SDL_free(_this->displays[index].name); SDL_memmove(&_this->displays[index], &_this->displays[index + 1], (_this->num_displays - index - 1) * sizeof(_this->displays[index])); } --_this->num_displays; From d9901e0b85dd7365bddd20f923b832e7b5626693 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 19 Jan 2024 22:27:59 -0800 Subject: [PATCH 45/59] Fix building with the steamrt/scout SDK (cherry picked from commit b552f26e6a37dc5a911d1876ce60d8aae3c85e9f) (cherry picked from commit 64d4baccb5e36bd6999cadc54251467d7acb6308) --- src/video/kmsdrm/SDL_kmsdrmvideo.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.h b/src/video/kmsdrm/SDL_kmsdrmvideo.h index c9222f81a55e3..1f7796496e0e4 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.h +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h @@ -33,6 +33,20 @@ #include #include +#ifndef DRM_CAP_CURSOR_WIDTH +#define DRM_CAP_CURSOR_WIDTH 8 +#endif +#ifndef DRM_CAP_CURSOR_HEIGHT +#define DRM_CAP_CURSOR_HEIGHT 9 +#endif + +#ifndef GBM_FORMAT_ARGB8888 +#define GBM_FORMAT_ARGB8888 ((uint32_t)('A') | ((uint32_t)('R') << 8) | ((uint32_t)('2') << 16) | ((uint32_t)('4') << 24)) +#define GBM_BO_USE_CURSOR (1 << 1) +#define GBM_BO_USE_WRITE (1 << 3) +#define GBM_BO_USE_LINEAR (1 << 4) +#endif + typedef struct SDL_VideoData { int devindex; /* device index that was passed on creation */ From 0811b4dc515d8ab7f792d72e48729a27a373b72a Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 19 Jan 2024 23:02:48 -0800 Subject: [PATCH 46/59] Fixed building with the steamrt/scout SDK (cherry picked from commit 4b82bed2599395cb3a37704f41ec7d1a37466cb8) (cherry picked from commit ecde0ca6b661f21ef4d482afadc20e8156f8e321) --- src/video/kmsdrm/SDL_kmsdrmvideo.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.h b/src/video/kmsdrm/SDL_kmsdrmvideo.h index 1f7796496e0e4..9c8ebe85e099d 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.h +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h @@ -33,9 +33,26 @@ #include #include +#ifndef DRM_MODE_PAGE_FLIP_ASYNC +#define DRM_MODE_PAGE_FLIP_ASYNC 2 +#endif + +#ifndef DRM_MODE_OBJECT_CONNECTOR +#define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0 +#endif + +#ifndef DRM_MODE_OBJECT_CRTC +#define DRM_MODE_OBJECT_CRTC 0xcccccccc +#endif + +#ifndef DRM_CAP_ASYNC_PAGE_FLIP +#define DRM_CAP_ASYNC_PAGE_FLIP 7 +#endif + #ifndef DRM_CAP_CURSOR_WIDTH #define DRM_CAP_CURSOR_WIDTH 8 #endif + #ifndef DRM_CAP_CURSOR_HEIGHT #define DRM_CAP_CURSOR_HEIGHT 9 #endif From ed86b02df875499432c6faaf9c1265a79c56cc0d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 26 Jun 2024 12:18:43 -0700 Subject: [PATCH 47/59] Fixed building with older libdrm headers (cherry picked from commit 8949de3978a360c04dbf9e9b4b7d7b6b4f86be5a) (cherry picked from commit 88bbab275f284afbb08263f19e6d66e8a3c254e9) --- src/video/kmsdrm/SDL_kmsdrmvideo.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.h b/src/video/kmsdrm/SDL_kmsdrmvideo.h index 9c8ebe85e099d..096f00cd162d6 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.h +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h @@ -33,6 +33,10 @@ #include #include +#ifndef DRM_MODE_FB_MODIFIERS +#define DRM_MODE_FB_MODIFIERS 2 +#endif + #ifndef DRM_MODE_PAGE_FLIP_ASYNC #define DRM_MODE_PAGE_FLIP_ASYNC 2 #endif From a9fdbf7f2100a7249172c1345e27af2910445050 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 26 Jun 2024 15:42:06 -0700 Subject: [PATCH 48/59] Make sure we don't try to use the XInput DLL after it's unloaded Steam ran into a crash SDL_XINPUT_JoystickDetect() with XINPUTGETCAPABILITIES being NULL. I'm not sure how that happened, and there may still be a race condition if this is a multi-threaded issue, but at least this is more correct. (cherry picked from commit 0ae4fd0ec9e2d6b048cde926653b7895b380232b) (cherry picked from commit ee3b2b7de1000be07339a967385614aa13fcad60) --- src/joystick/windows/SDL_xinputjoystick.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/joystick/windows/SDL_xinputjoystick.c b/src/joystick/windows/SDL_xinputjoystick.c index 1ae7fb489957e..38c27d80de2ad 100644 --- a/src/joystick/windows/SDL_xinputjoystick.c +++ b/src/joystick/windows/SDL_xinputjoystick.c @@ -458,6 +458,7 @@ void SDL_XINPUT_JoystickClose(SDL_Joystick *joystick) void SDL_XINPUT_JoystickQuit(void) { if (s_bXInputEnabled) { + s_bXInputEnabled = SDL_FALSE; WIN_UnloadXInputDLL(); } } From c60e2704c88ecb8bf55d69085b9c1bd2a68e5321 Mon Sep 17 00:00:00 2001 From: 1F616EMO Date: Sat, 29 Jun 2024 14:47:27 +0800 Subject: [PATCH 49/59] Remove the inconsistent and lag-causing usleep call in SDL_fcitx.c (cherry picked from commit 3bf2b90da09637059cac62a08ac42b630bbfa817) --- src/core/linux/SDL_fcitx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/linux/SDL_fcitx.c b/src/core/linux/SDL_fcitx.c index 88b6d06f40587..f948fc98b2816 100644 --- a/src/core/linux/SDL_fcitx.c +++ b/src/core/linux/SDL_fcitx.c @@ -485,7 +485,6 @@ void SDL_Fcitx_PumpEvents(void) while (dbus->connection_dispatch(conn) == DBUS_DISPATCH_DATA_REMAINS) { /* Do nothing, actual work happens in DBus_MessageFilter */ - usleep(10); } } From 8a39054b547b4d09594d1e48f43a648d074b0f4a Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 29 Jun 2024 02:34:17 -0700 Subject: [PATCH 50/59] Clean up any renderer in SDL_DestroyWindowSurface() Also added an automated test to verify window surface functionality. Fixes https://github.com/libsdl-org/SDL/issues/10133 (cherry picked from commit a522bfe3f1402a3f47dfb90b6b44e2d5695fc953) (cherry picked from commit a3f0c373d3435e7943924cccbe92a24df20fe5fb) --- src/video/SDL_video.c | 131 +++++++++++++++++++----------------- test/testautomation_video.c | 76 ++++++++++++++++++++- 2 files changed, 143 insertions(+), 64 deletions(-) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 26c7b8ad718a2..a557f0e1f98f6 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1941,12 +1941,6 @@ int SDL_RecreateWindow(SDL_Window *window, Uint32 flags) /* Tear down the old native window */ SDL_DestroyWindowSurface(window); - if (_this->checked_texture_framebuffer) { /* never checked? No framebuffer to destroy. Don't risk calling the wrong implementation. */ - if (_this->DestroyWindowFramebuffer) { - _this->DestroyWindowFramebuffer(_this, window); - } - } - if (_this->DestroyWindow && !(flags & SDL_WINDOW_FOREIGN)) { _this->DestroyWindow(_this, window); } @@ -2661,55 +2655,57 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) using a GPU texture through the 2D render API, if we think this would be more efficient. This only checks once, on demand. */ if (!_this->checked_texture_framebuffer) { - SDL_bool attempt_texture_framebuffer = SDL_TRUE; - - /* See if the user or application wants to specifically disable the framebuffer */ - const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); - if (hint) { - if ((*hint == '0') || (SDL_strcasecmp(hint, "false") == 0) || (SDL_strcasecmp(hint, "software") == 0)) { - attempt_texture_framebuffer = SDL_FALSE; - } - } + SDL_bool attempt_texture_framebuffer; if (_this->is_dummy) { /* dummy driver never has GPU support, of course. */ attempt_texture_framebuffer = SDL_FALSE; - } + } else { + /* See if the user or application wants to specifically disable the framebuffer */ + const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); + if (hint && *hint) { + if ((*hint == '0') || (SDL_strcasecmp(hint, "false") == 0) || (SDL_strcasecmp(hint, "software") == 0)) { + attempt_texture_framebuffer = SDL_FALSE; + } else { + attempt_texture_framebuffer = SDL_TRUE; + } + } else { + attempt_texture_framebuffer = SDL_TRUE; #if defined(__LINUX__) - /* On WSL, direct X11 is faster than using OpenGL for window framebuffers, so try to detect WSL and avoid texture framebuffer. */ - else if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "x11") == 0)) { - struct stat sb; - if ((stat("/proc/sys/fs/binfmt_misc/WSLInterop", &sb) == 0) || (stat("/run/WSL", &sb) == 0)) { /* if either of these exist, we're on WSL. */ - attempt_texture_framebuffer = SDL_FALSE; + /* On WSL, direct X11 is faster than using OpenGL for window framebuffers, so try to detect WSL and avoid texture framebuffer. */ + if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "x11") == 0)) { + struct stat sb; + if ((stat("/proc/sys/fs/binfmt_misc/WSLInterop", &sb) == 0) || (stat("/run/WSL", &sb) == 0)) { /* if either of these exist, we're on WSL. */ + attempt_texture_framebuffer = SDL_FALSE; + } } - } #endif #if defined(__WIN32__) || defined(__WINGDK__) /* GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) */ - else if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "windows") == 0)) { - attempt_texture_framebuffer = SDL_FALSE; - } + if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "windows") == 0)) { + attempt_texture_framebuffer = SDL_FALSE; + } #endif #if defined(__EMSCRIPTEN__) - else { attempt_texture_framebuffer = SDL_FALSE; - } #endif + } - if (attempt_texture_framebuffer) { - if (SDL_CreateWindowTexture(_this, window, &format, &pixels, &pitch) == -1) { - /* !!! FIXME: if this failed halfway (made renderer, failed to make texture, etc), - !!! FIXME: we probably need to clean this up so it doesn't interfere with - !!! FIXME: a software fallback at the system level (can we blit to an - !!! FIXME: OpenGL window? etc). */ - } else { - /* future attempts will just try to use a texture framebuffer. */ - /* !!! FIXME: maybe we shouldn't override these but check if we used a texture - !!! FIXME: framebuffer at the right places; is it feasible we could have an - !!! FIXME: accelerated OpenGL window and a second ends up in software? */ - _this->CreateWindowFramebuffer = SDL_CreateWindowTexture; - _this->UpdateWindowFramebuffer = SDL_UpdateWindowTexture; - _this->DestroyWindowFramebuffer = SDL_DestroyWindowTexture; - created_framebuffer = SDL_TRUE; + if (attempt_texture_framebuffer) { + if (SDL_CreateWindowTexture(_this, window, &format, &pixels, &pitch) == -1) { + /* !!! FIXME: if this failed halfway (made renderer, failed to make texture, etc), + !!! FIXME: we probably need to clean this up so it doesn't interfere with + !!! FIXME: a software fallback at the system level (can we blit to an + !!! FIXME: OpenGL window? etc). */ + } else { + /* future attempts will just try to use a texture framebuffer. */ + /* !!! FIXME: maybe we shouldn't override these but check if we used a texture + !!! FIXME: framebuffer at the right places; is it feasible we could have an + !!! FIXME: accelerated OpenGL window and a second ends up in software? */ + _this->CreateWindowFramebuffer = SDL_CreateWindowTexture; + _this->UpdateWindowFramebuffer = SDL_UpdateWindowTexture; + _this->DestroyWindowFramebuffer = SDL_DestroyWindowTexture; + created_framebuffer = SDL_TRUE; + } } } @@ -2718,6 +2714,7 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) if (!created_framebuffer) { if (!_this->CreateWindowFramebuffer || !_this->UpdateWindowFramebuffer) { + SDL_SetError("Window framebuffer support not available"); return NULL; } @@ -2727,6 +2724,7 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) } if (window->surface) { + /* We may have gone recursive and already created the surface */ return window->surface; } @@ -2749,7 +2747,12 @@ SDL_Surface *SDL_GetWindowSurface(SDL_Window *window) CHECK_WINDOW_MAGIC(window, NULL); if (!window->surface_valid) { - SDL_DestroyWindowSurface(window); + if (window->surface) { + window->surface->flags &= ~SDL_DONTFREE; + SDL_FreeSurface(window->surface); + window->surface = NULL; + } + window->surface = SDL_CreateWindowFramebuffer(window); if (window->surface) { window->surface_valid = SDL_TRUE; @@ -2786,6 +2789,25 @@ int SDL_UpdateWindowSurfaceRects(SDL_Window *window, const SDL_Rect *rects, return _this->UpdateWindowFramebuffer(_this, window, rects, numrects); } +int SDL_DestroyWindowSurface(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, -1); + + if (window->surface) { + window->surface->flags &= ~SDL_DONTFREE; + SDL_FreeSurface(window->surface); + window->surface = NULL; + window->surface_valid = SDL_FALSE; + } + + if (_this->checked_texture_framebuffer) { /* never checked? No framebuffer to destroy. Don't risk calling the wrong implementation. */ + if (_this->DestroyWindowFramebuffer) { + _this->DestroyWindowFramebuffer(_this, window); + } + } + return 0; +} + int SDL_SetWindowBrightness(SDL_Window * window, float brightness) { Uint16 ramp[256]; @@ -2831,19 +2853,6 @@ int SDL_SetWindowOpacity(SDL_Window * window, float opacity) return retval; } -int SDL_DestroyWindowSurface(SDL_Window *window) -{ - CHECK_WINDOW_MAGIC(window, -1); - - if (window->surface) { - window->surface->flags &= ~SDL_DONTFREE; - SDL_FreeSurface(window->surface); - window->surface = NULL; - window->surface_valid = SDL_FALSE; - } - return 0; -} - int SDL_GetWindowOpacity(SDL_Window *window, float *out_opacity) { CHECK_WINDOW_MAGIC(window, -1); @@ -3282,19 +3291,15 @@ void SDL_DestroyWindow(SDL_Window *window) SDL_SetMouseFocus(NULL); } - /* make no context current if this is the current context window. */ + SDL_DestroyWindowSurface(window); + + /* Make no context current if this is the current context window */ if (window->flags & SDL_WINDOW_OPENGL) { if (_this->current_glwin == window) { SDL_GL_MakeCurrent(window, NULL); } } - SDL_DestroyWindowSurface(window); - if (_this->checked_texture_framebuffer) { /* never checked? No framebuffer to destroy. Don't risk calling the wrong implementation. */ - if (_this->DestroyWindowFramebuffer) { - _this->DestroyWindowFramebuffer(_this, window); - } - } if (_this->DestroyWindow) { _this->DestroyWindow(_this, window); } diff --git a/test/testautomation_video.c b/test/testautomation_video.c index dd8f1c5c25b85..d9d7d2b6dc708 100644 --- a/test/testautomation_video.c +++ b/test/testautomation_video.c @@ -2181,6 +2181,76 @@ int video_setWindowCenteredOnDisplay(void *arg) return TEST_COMPLETED; } +/** + * Tests window surface functionality + */ +static int video_getWindowSurface(void *arg) +{ + const char *title = "video_getWindowSurface Test Window"; + SDL_Window *window; + SDL_Surface *surface; + SDL_Renderer *renderer; + Uint32 renderer_flags = SDL_RENDERER_ACCELERATED; + int result; + + if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "dummy") == 0) { + renderer_flags = SDL_RENDERER_SOFTWARE; + } + + /* Make sure we're testing interaction with an accelerated renderer */ + SDL_SetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION, "1"); + + window = SDL_CreateWindow(title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 320, 320, 0); + SDLTest_AssertPass("Call to SDL_CreateWindow('%s', SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 320, 320, 0)", title); + SDLTest_AssertCheck(window != NULL, "Validate that returned window is not NULL"); + + surface = SDL_GetWindowSurface(window); + SDLTest_AssertPass("Call to SDL_GetWindowSurface(window)"); + SDLTest_AssertCheck(surface != NULL, "Validate that returned surface is not NULL"); + SDLTest_AssertCheck(SDL_HasWindowSurface(window), "Validate that window has a surface"); + + result = SDL_UpdateWindowSurface(window); + SDLTest_AssertPass("Call to SDL_UpdateWindowSurface(window)"); + SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result); + + /* We shouldn't be able to create a renderer on a window with a surface */ + renderer = SDL_CreateRenderer(window, -1, renderer_flags); + SDLTest_AssertPass("Call to SDL_CreateRenderer(window, -1, 0x%x)", renderer_flags); + SDLTest_AssertCheck(renderer == NULL, "Validate that returned renderer is NULL"); + + result = SDL_DestroyWindowSurface(window); + SDLTest_AssertPass("Call to SDL_DestroyWindowSurface(window)"); + SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result); + SDLTest_AssertCheck(!SDL_HasWindowSurface(window), "Validate that window does not have a surface"); + + /* We should be able to create a renderer on the window now */ + renderer = SDL_CreateRenderer(window, -1, renderer_flags); + SDLTest_AssertPass("Call to SDL_CreateRenderer(window, -1, 0x%x)", renderer_flags); + SDLTest_AssertCheck(renderer != NULL, "Validate that returned renderer is not NULL"); + + /* We should not be able to create a window surface now, unless it was created by the renderer */ + if (!SDL_HasWindowSurface(window)) { + surface = SDL_GetWindowSurface(window); + SDLTest_AssertPass("Call to SDL_GetWindowSurface(window)"); + SDLTest_AssertCheck(surface == NULL, "Validate that returned surface is NULL"); + } + + SDL_DestroyRenderer(renderer); + SDLTest_AssertPass("Call to SDL_DestroyRenderer(renderer)"); + SDLTest_AssertCheck(!SDL_HasWindowSurface(window), "Validate that window does not have a surface"); + + /* We should be able to create a window surface again */ + surface = SDL_GetWindowSurface(window); + SDLTest_AssertPass("Call to SDL_GetWindowSurface(window)"); + SDLTest_AssertCheck(surface != NULL, "Validate that returned surface is not NULL"); + SDLTest_AssertCheck(SDL_HasWindowSurface(window), "Validate that window has a surface"); + + /* Clean up */ + SDL_DestroyWindow(window); + + return TEST_COMPLETED; +} + /* ================= Test References ================== */ /* Video test cases */ @@ -2265,13 +2335,17 @@ static const SDLTest_TestCaseReference videoTest23 = static const SDLTest_TestCaseReference videoTest24 = { (SDLTest_TestCaseFp) video_setWindowCenteredOnDisplay, "video_setWindowCenteredOnDisplay", "Checks using SDL_WINDOWPOS_CENTERED_DISPLAY centers the window on a display", TEST_ENABLED }; +static const SDLTest_TestCaseReference videoTest25 = { + (SDLTest_TestCaseFp)video_getWindowSurface, "video_getWindowSurface", "Checks window surface functionality", TEST_ENABLED +}; + /* Sequence of Video test cases */ static const SDLTest_TestCaseReference *videoTests[] = { &videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6, &videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12, &videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17, &videoTest18, &videoTest19, &videoTest20, &videoTest21, &videoTest22, - &videoTest23, &videoTest24, NULL + &videoTest23, &videoTest24, &videoTest25, NULL }; /* Video test suite (global) */ From 5c8d92e4d08cb47feb0e5a911c43263d69325bdb Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 29 Jun 2024 10:14:27 -0700 Subject: [PATCH 51/59] Respect SDL_HINT_RENDER_DRIVER when creating an accelerated window surface Fixes https://github.com/libsdl-org/SDL/issues/10061 (cherry picked from commit 2a58e7b11c7896de0a9714d099de7409c360ee70) (cherry picked from commit 0d9e54237c240aede4d94bb913143881aa45b347) --- src/video/SDL_video.c | 148 ++++++++++++++++++++++++------------------ 1 file changed, 86 insertions(+), 62 deletions(-) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index a557f0e1f98f6..c1a2dbdd6a1d9 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -227,26 +227,37 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U if (!data) { SDL_Renderer *renderer = NULL; - const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); - const SDL_bool specific_accelerated_renderer = (hint && *hint != '0' && *hint != '1' && - SDL_strcasecmp(hint, "true") != 0 && - SDL_strcasecmp(hint, "false") != 0 && - SDL_strcasecmp(hint, "software") != 0); + const char *render_driver = NULL; + const char *hint; + + /* See if there's a render driver being requested */ + hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); + if (hint && *hint != '0' && *hint != '1' && + SDL_strcasecmp(hint, "true") != 0 && + SDL_strcasecmp(hint, "false") != 0 && + SDL_strcasecmp(hint, "software") != 0) { + render_driver = hint; + } + + if (!render_driver) { + hint = SDL_GetHint(SDL_HINT_RENDER_DRIVER); + if (hint && *hint && SDL_strcasecmp(hint, "software") != 0) { + render_driver = hint; + } + } /* Check to see if there's a specific driver requested */ - if (specific_accelerated_renderer) { + if (render_driver) { for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) { SDL_GetRenderDriverInfo(i, &info); - if (SDL_strcasecmp(info.name, hint) == 0) { + if (SDL_strcasecmp(info.name, render_driver) == 0) { renderer = SDL_CreateRenderer(window, i, 0); break; } } - if (!renderer || (SDL_GetRendererInfo(renderer, &info) == -1)) { - if (renderer) { - SDL_DestroyRenderer(renderer); - } - return SDL_SetError("Requested renderer for " SDL_HINT_FRAMEBUFFER_ACCELERATION " is not available"); + if (!renderer) { + /* The error for this specific renderer has already been set */ + return -1; } /* if it was specifically requested, even if SDL_RENDERER_ACCELERATED isn't set, we'll accept this renderer. */ } else { @@ -2639,6 +2650,55 @@ int SDL_SetWindowFullscreen(SDL_Window *window, Uint32 flags) return -1; } +static SDL_bool ShouldAttemptTextureFramebuffer(void) +{ + const char *hint; + SDL_bool attempt_texture_framebuffer = SDL_TRUE; + + /* The dummy driver never has GPU support, of course. */ + if (_this->is_dummy) { + return SDL_FALSE; + } + + /* See if there's a hint override */ + hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); + if (hint && *hint) { + if (*hint == '0' || SDL_strcasecmp(hint, "false") == 0 || SDL_strcasecmp(hint, "software") == 0) { + attempt_texture_framebuffer = SDL_FALSE; + } else { + attempt_texture_framebuffer = SDL_TRUE; + } + } else { + /* Check for platform specific defaults */ +#if defined(__LINUX__) + /* On WSL, direct X11 is faster than using OpenGL for window framebuffers, so try to detect WSL and avoid texture framebuffer. */ + if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "x11") == 0)) { + struct stat sb; + if ((stat("/proc/sys/fs/binfmt_misc/WSLInterop", &sb) == 0) || (stat("/run/WSL", &sb) == 0)) { /* if either of these exist, we're on WSL. */ + attempt_texture_framebuffer = SDL_FALSE; + } + } +#endif +#if defined(__WIN32__) || defined(__WINGDK__) /* GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) */ + if (_this->CreateWindowFramebuffer && (SDL_strcmp(_this->name, "windows") == 0)) { + attempt_texture_framebuffer = SDL_FALSE; + } +#endif +#if defined(__EMSCRIPTEN__) + attempt_texture_framebuffer = SDL_FALSE; +#endif + } + + if (attempt_texture_framebuffer) { + /* Using a software renderer will try to display on a window surface, so avoid recursion here */ + hint = SDL_GetHint(SDL_HINT_RENDER_DRIVER); + if (hint && SDL_strcasecmp(hint, "software") == 0) { + attempt_texture_framebuffer = SDL_FALSE; + } + } + return attempt_texture_framebuffer; +} + static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) { Uint32 format = 0; @@ -2655,57 +2715,21 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) using a GPU texture through the 2D render API, if we think this would be more efficient. This only checks once, on demand. */ if (!_this->checked_texture_framebuffer) { - SDL_bool attempt_texture_framebuffer; - - if (_this->is_dummy) { /* dummy driver never has GPU support, of course. */ - attempt_texture_framebuffer = SDL_FALSE; - } else { - /* See if the user or application wants to specifically disable the framebuffer */ - const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); - if (hint && *hint) { - if ((*hint == '0') || (SDL_strcasecmp(hint, "false") == 0) || (SDL_strcasecmp(hint, "software") == 0)) { - attempt_texture_framebuffer = SDL_FALSE; - } else { - attempt_texture_framebuffer = SDL_TRUE; - } + if (ShouldAttemptTextureFramebuffer()) { + if (SDL_CreateWindowTexture(_this, window, &format, &pixels, &pitch) < 0) { + /* !!! FIXME: if this failed halfway (made renderer, failed to make texture, etc), + !!! FIXME: we probably need to clean this up so it doesn't interfere with + !!! FIXME: a software fallback at the system level (can we blit to an + !!! FIXME: OpenGL window? etc). */ } else { - attempt_texture_framebuffer = SDL_TRUE; - -#if defined(__LINUX__) - /* On WSL, direct X11 is faster than using OpenGL for window framebuffers, so try to detect WSL and avoid texture framebuffer. */ - if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "x11") == 0)) { - struct stat sb; - if ((stat("/proc/sys/fs/binfmt_misc/WSLInterop", &sb) == 0) || (stat("/run/WSL", &sb) == 0)) { /* if either of these exist, we're on WSL. */ - attempt_texture_framebuffer = SDL_FALSE; - } - } -#endif -#if defined(__WIN32__) || defined(__WINGDK__) /* GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) */ - if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "windows") == 0)) { - attempt_texture_framebuffer = SDL_FALSE; - } -#endif -#if defined(__EMSCRIPTEN__) - attempt_texture_framebuffer = SDL_FALSE; -#endif - } - - if (attempt_texture_framebuffer) { - if (SDL_CreateWindowTexture(_this, window, &format, &pixels, &pitch) == -1) { - /* !!! FIXME: if this failed halfway (made renderer, failed to make texture, etc), - !!! FIXME: we probably need to clean this up so it doesn't interfere with - !!! FIXME: a software fallback at the system level (can we blit to an - !!! FIXME: OpenGL window? etc). */ - } else { - /* future attempts will just try to use a texture framebuffer. */ - /* !!! FIXME: maybe we shouldn't override these but check if we used a texture - !!! FIXME: framebuffer at the right places; is it feasible we could have an - !!! FIXME: accelerated OpenGL window and a second ends up in software? */ - _this->CreateWindowFramebuffer = SDL_CreateWindowTexture; - _this->UpdateWindowFramebuffer = SDL_UpdateWindowTexture; - _this->DestroyWindowFramebuffer = SDL_DestroyWindowTexture; - created_framebuffer = SDL_TRUE; - } + /* future attempts will just try to use a texture framebuffer. */ + /* !!! FIXME: maybe we shouldn't override these but check if we used a texture + !!! FIXME: framebuffer at the right places; is it feasible we could have an + !!! FIXME: accelerated OpenGL window and a second ends up in software? */ + _this->CreateWindowFramebuffer = SDL_CreateWindowTexture; + _this->UpdateWindowFramebuffer = SDL_UpdateWindowTexture; + _this->DestroyWindowFramebuffer = SDL_DestroyWindowTexture; + created_framebuffer = SDL_TRUE; } } From e1e36d213bea3a0b56d91b454c53a2c94312a5be Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 29 Jun 2024 11:22:29 -0700 Subject: [PATCH 52/59] Fixed build (cherry picked from commit 288aea3b40faf882f26411e6a3fe06329bba2c05) --- test/testautomation_video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/testautomation_video.c b/test/testautomation_video.c index d9d7d2b6dc708..af49c0041cc8a 100644 --- a/test/testautomation_video.c +++ b/test/testautomation_video.c @@ -2215,7 +2215,7 @@ static int video_getWindowSurface(void *arg) /* We shouldn't be able to create a renderer on a window with a surface */ renderer = SDL_CreateRenderer(window, -1, renderer_flags); - SDLTest_AssertPass("Call to SDL_CreateRenderer(window, -1, 0x%x)", renderer_flags); + SDLTest_AssertPass("Call to SDL_CreateRenderer(window)"); SDLTest_AssertCheck(renderer == NULL, "Validate that returned renderer is NULL"); result = SDL_DestroyWindowSurface(window); @@ -2225,7 +2225,7 @@ static int video_getWindowSurface(void *arg) /* We should be able to create a renderer on the window now */ renderer = SDL_CreateRenderer(window, -1, renderer_flags); - SDLTest_AssertPass("Call to SDL_CreateRenderer(window, -1, 0x%x)", renderer_flags); + SDLTest_AssertPass("Call to SDL_CreateRenderer(window)"); SDLTest_AssertCheck(renderer != NULL, "Validate that returned renderer is not NULL"); /* We should not be able to create a window surface now, unless it was created by the renderer */ From 80d36aba5b2f3f3229a6b9642d19143a49ac32a4 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 3 Jul 2024 11:43:43 -0700 Subject: [PATCH 53/59] Only use the default gamepad mapping if an automatic mapping isn't available Fixes https://github.com/libsdl-org/SDL/issues/10162 (cherry picked from commit 0f8054cf87e6b221659acca70d2471e05f2133e1) (cherry picked from commit cd8ea5e3f169250cfe435f58d3b4c6c0d42dd2b2) --- src/joystick/SDL_gamecontroller.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index a7d3303b3161a..1cf8c2e417dba 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -1391,9 +1391,6 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForNameAndGUID(const } #endif /* __LINUX__ */ - if (!mapping) { - mapping = s_pDefaultMapping; - } return mapping; } @@ -1506,6 +1503,9 @@ static ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index) } } + if (!mapping) { + mapping = s_pDefaultMapping; + } return mapping; } @@ -2059,7 +2059,7 @@ SDL_bool SDL_IsGameControllerNameAndGUID(const char *name, SDL_JoystickGUID guid SDL_LockJoysticks(); { - if (SDL_PrivateGetControllerMappingForNameAndGUID(name, guid) != NULL) { + if (s_pDefaultMapping || SDL_PrivateGetControllerMappingForNameAndGUID(name, guid) != NULL) { retval = SDL_TRUE; } else { retval = SDL_FALSE; From 59b0a1dc6510f26809028cd97dd7e610d6b8ccad Mon Sep 17 00:00:00 2001 From: Wouter Wijsman Date: Sun, 24 Mar 2024 22:58:28 +0100 Subject: [PATCH 54/59] PSP: send initial SDL_JOYDEVICEADDED event (cherry picked from commit 5d801799542ab4dc547142ba8f0afbf5a294e452) --- src/joystick/psp/SDL_sysjoystick.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/joystick/psp/SDL_sysjoystick.c b/src/joystick/psp/SDL_sysjoystick.c index 3d7d53148c3db..9b60dfede9e48 100644 --- a/src/joystick/psp/SDL_sysjoystick.c +++ b/src/joystick/psp/SDL_sysjoystick.c @@ -96,6 +96,9 @@ static int PSP_JoystickInit(void) analog_map[127 - i] = -1 * analog_map[i + 128]; } + /* Fire off a joystick add event */ + SDL_PrivateJoystickAdded(0); + return 1; } From ed441c82892dd76da660a481ad000d088087730b Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 10 Mar 2024 15:00:49 -0700 Subject: [PATCH 55/59] Turn HIDAPI joystick support off by default on mobile platforms On Android, HIDAPI prompts for permissions and acquires exclusive access to the device, and on Apple mobile platforms it doesn't do anything except for handling Bluetooth Steam Controllers. Fixes https://github.com/libsdl-org/SDL/issues/9241 (cherry picked from commit e3cf2e479498205cec56906e03800da24e38786b) (cherry picked from commit 66054a6515f8538b055dc77c4a9ac27ff8a822a6) --- src/joystick/hidapi/SDL_hidapijoystick_c.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/joystick/hidapi/SDL_hidapijoystick_c.h b/src/joystick/hidapi/SDL_hidapijoystick_c.h index cd18730a83e9f..738c43abebe46 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick_c.h +++ b/src/joystick/hidapi/SDL_hidapijoystick_c.h @@ -47,7 +47,14 @@ #define SDL_JOYSTICK_HIDAPI_SHIELD /* Whether HIDAPI is enabled by default */ +#if defined(__ANDROID__) || \ + defined(__IPHONEOS__) || \ + defined(__TVOS__) +/* On Android, HIDAPI prompts for permissions and acquires exclusive access to the device, and on Apple mobile platforms it doesn't do anything except for handling Bluetooth Steam Controllers, so we'll leave it off by default. */ +#define SDL_HIDAPI_DEFAULT SDL_FALSE +#else #define SDL_HIDAPI_DEFAULT SDL_TRUE +#endif /* The maximum size of a USB packet for HID devices */ #define USB_PACKET_LENGTH 64 From eb053c7f3fd3c7515d57bc3ecd5abee5f37e781e Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 8 May 2024 16:35:10 -0400 Subject: [PATCH 56/59] SDL_JoystickEventState: Make documentation and implementation match. This changes the `SDL_EVENTS_DISABLED` path's return value from SDL_DISABLE to SDL_IGNORE to match expectations, but doesn't actually change the ABI, since these two symbols are both zero. Fixes https://github.com/libsdl-org/sdlwiki/issues/460 (cherry picked from commit 7d60ff996542ff023caec9bdb23649731683c5ef) --- include/SDL_joystick.h | 15 ++++++++++----- src/joystick/SDL_joystick.c | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/SDL_joystick.h b/include/SDL_joystick.h index 561e01099cede..7a3faf841c891 100644 --- a/include/SDL_joystick.h +++ b/include/SDL_joystick.h @@ -790,12 +790,17 @@ extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void); * **WARNING**: Calling this function may delete all events currently in SDL's * event queue. * - * \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE` - * \returns 1 if enabled, 0 if disabled, or a negative error code on failure; - * call SDL_GetError() for more information. + * While `param` is meant to be one of `SDL_QUERY`, `SDL_IGNORE`, or + * `SDL_ENABLE`, this function accepts any value, with any non-zero value that + * isn't `SDL_QUERY` being treated as `SDL_ENABLE`. * - * If `state` is `SDL_QUERY` then the current state is returned, - * otherwise the new processing state is returned. + * If SDL was built with events disabled (extremely uncommon!), this will + * do nothing and always return `SDL_IGNORE`. + * + * \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE` + * \returns If `state` is `SDL_QUERY` then the current state is returned, + * otherwise `state` is returned (even if it was not one of the + * allowed values). * * \since This function is available since SDL 2.0.0. * diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 05c9807c26eaf..73c63c5d777b3 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -2220,7 +2220,7 @@ void SDL_JoystickUpdate(void) int SDL_JoystickEventState(int state) { #ifdef SDL_EVENTS_DISABLED - return SDL_DISABLE; + return SDL_IGNORE; #else const Uint32 event_list[] = { SDL_JOYAXISMOTION, SDL_JOYBALLMOTION, SDL_JOYHATMOTION, From e5024fae3decb724e397d3c9dbcb744d8c79aac1 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 14 Mar 2024 13:26:56 -0700 Subject: [PATCH 57/59] If a mapping specifies a crc, don't match for controllers that don't have that CRC The CRC is used to distinguish between different controllers that have the same VID/PID, so if the CRC doesn't match, it's probably a different controller that we don't know about. Fixes https://github.com/libsdl-org/SDL/issues/9265 (cherry picked from commit 30e93b40c2a6fd2219ad55e820f5d037e3619c2c) (cherry picked from commit b8daf14fe550512c42d5e30bd696d52effc337e5) --- src/joystick/SDL_gamecontroller.c | 52 +++++++++++-------------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index 1cf8c2e417dba..410c985d46259 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -688,16 +688,14 @@ static ControllerMapping_t *SDL_CreateMappingForWGIController(SDL_JoystickGUID g /* * Helper function to scan the mappings database for a controller with the specified GUID */ -static ControllerMapping_t *SDL_PrivateMatchControllerMappingForGUID(SDL_JoystickGUID guid, SDL_bool match_crc, SDL_bool match_version) +static ControllerMapping_t *SDL_PrivateMatchControllerMappingForGUID(SDL_JoystickGUID guid, SDL_bool match_version) { - ControllerMapping_t *mapping; + ControllerMapping_t *mapping, *best_match = NULL; Uint16 crc = 0; SDL_AssertJoysticksLocked(); - if (match_crc) { - SDL_GetJoystickGUIDInfo(guid, NULL, NULL, NULL, &crc); - } + SDL_GetJoystickGUIDInfo(guid, NULL, NULL, NULL, &crc); /* Clear the CRC from the GUID for matching, the mappings never include it in the GUID */ SDL_SetJoystickGUIDCRC(&guid, 0); @@ -719,20 +717,26 @@ static ControllerMapping_t *SDL_PrivateMatchControllerMappingForGUID(SDL_Joystic } if (SDL_memcmp(&guid, &mapping_guid, sizeof(guid)) == 0) { - Uint16 mapping_crc = 0; + const char *crc_string = SDL_strstr(mapping->mapping, SDL_CONTROLLER_CRC_FIELD); + if (crc_string) { + Uint16 mapping_crc = (Uint16)SDL_strtol(crc_string + SDL_CONTROLLER_CRC_FIELD_SIZE, NULL, 16); - if (match_crc) { - const char *crc_string = SDL_strstr(mapping->mapping, SDL_CONTROLLER_CRC_FIELD); - if (crc_string) { - mapping_crc = (Uint16)SDL_strtol(crc_string + SDL_CONTROLLER_CRC_FIELD_SIZE, NULL, 16); + if (mapping_crc != crc) { + /* This mapping specified a CRC and they don't match */ + continue; } - } - if (crc == mapping_crc) { + + /* An exact match, including CRC */ return mapping; } + + + if (!best_match) { + best_match = mapping; + } } } - return NULL; + return best_match; } /* @@ -741,19 +745,8 @@ static ControllerMapping_t *SDL_PrivateMatchControllerMappingForGUID(SDL_Joystic static ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickGUID guid, SDL_bool adding_mapping) { ControllerMapping_t *mapping; - Uint16 vendor, product, crc; - SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, &crc); - if (crc) { - /* First check for exact CRC matching */ - mapping = SDL_PrivateMatchControllerMappingForGUID(guid, SDL_TRUE, SDL_TRUE); - if (mapping) { - return mapping; - } - } - - /* Now check for a mapping without CRC */ - mapping = SDL_PrivateMatchControllerMappingForGUID(guid, SDL_FALSE, SDL_TRUE); + mapping = SDL_PrivateMatchControllerMappingForGUID(guid, SDL_TRUE); if (mapping) { return mapping; } @@ -767,14 +760,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickG if (SDL_JoystickGUIDUsesVersion(guid)) { /* Try again, ignoring the version */ - if (crc) { - mapping = SDL_PrivateMatchControllerMappingForGUID(guid, SDL_TRUE, SDL_FALSE); - if (mapping) { - return mapping; - } - } - - mapping = SDL_PrivateMatchControllerMappingForGUID(guid, SDL_FALSE, SDL_FALSE); + mapping = SDL_PrivateMatchControllerMappingForGUID(guid, SDL_FALSE); if (mapping) { return mapping; } From d126e7bbba97f198979878f1c70632721b20dc47 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 3 Jul 2024 13:54:00 -0700 Subject: [PATCH 58/59] Added support for the ROG RAIKIRI (cherry picked from commit a04596c9a7b3c29e08d258c077bf466ccad1a66a) (cherry picked from commit 845ebbbe96b0c05a4b64736122dbbc4f51900694) --- .../app/src/main/java/org/libsdl/app/HIDDeviceManager.java | 1 + src/hidapi/libusb/hid.c | 1 + src/joystick/SDL_joystick.c | 5 +++++ src/joystick/hidapi/SDL_hidapijoystick.c | 1 + src/joystick/usb_ids.h | 2 ++ 5 files changed, 10 insertions(+) diff --git a/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java b/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java index ea6b5d5b17a18..21a1c1d18eea5 100644 --- a/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java +++ b/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java @@ -277,6 +277,7 @@ private boolean isXboxOneController(UsbDevice usbDevice, UsbInterface usbInterfa 0x044f, // Thrustmaster 0x045e, // Microsoft 0x0738, // Mad Catz + 0x0b05, // ASUS 0x0e6f, // PDP 0x0f0d, // Hori 0x10f5, // Turtle Beach diff --git a/src/hidapi/libusb/hid.c b/src/hidapi/libusb/hid.c index 008131bd9d2d0..7da8a959f44b6 100644 --- a/src/hidapi/libusb/hid.c +++ b/src/hidapi/libusb/hid.c @@ -715,6 +715,7 @@ static int is_xboxone(unsigned short vendor_id, const struct libusb_interface_de 0x044f, /* Thrustmaster */ 0x045e, /* Microsoft */ 0x0738, /* Mad Catz */ + 0x0b05, /* ASUS */ 0x0e6f, /* PDP */ 0x0f0d, /* Hori */ 0x10f5, /* Turtle Beach */ diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 73c63c5d777b3..0884cf92dd0fe 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -2748,6 +2748,11 @@ SDL_bool SDL_IsJoystickXboxSeriesX(Uint16 vendor_id, Uint16 product_id) return SDL_TRUE; } } + if (vendor_id == USB_VENDOR_ASUS) { + if (product_id == USB_PRODUCT_ROG_RAIKIRI) { + return SDL_TRUE; + } + } return SDL_FALSE; } diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c index 84767dca528d9..0db0cbb1c34d9 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/src/joystick/hidapi/SDL_hidapijoystick.c @@ -280,6 +280,7 @@ static SDL_GameControllerType SDL_GetJoystickGameControllerProtocol(const char * 0x044f, /* Thrustmaster */ 0x045e, /* Microsoft */ 0x0738, /* Mad Catz */ + 0x0b05, /* ASUS */ 0x0e6f, /* PDP */ 0x0f0d, /* Hori */ 0x10f5, /* Turtle Beach */ diff --git a/src/joystick/usb_ids.h b/src/joystick/usb_ids.h index 9cdcfa68ad7da..d16605751b47d 100644 --- a/src/joystick/usb_ids.h +++ b/src/joystick/usb_ids.h @@ -28,6 +28,7 @@ #define USB_VENDOR_AMAZON 0x1949 #define USB_VENDOR_APPLE 0x05ac #define USB_VENDOR_ASTRO 0x9886 +#define USB_VENDOR_ASUS 0x0b05 #define USB_VENDOR_BACKBONE 0x358a #define USB_VENDOR_GAMESIR 0x3537 #define USB_VENDOR_DRAGONRISE 0x0079 @@ -105,6 +106,7 @@ #define USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_PS5_WIRELESS 0x100c #define USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_XBOX_WIRED 0x1010 #define USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_XBOX_WIRELESS 0x1011 +#define USB_PRODUCT_ROG_RAIKIRI 0x1a38 #define USB_PRODUCT_SAITEK_CYBORG_V3 0xf622 #define USB_PRODUCT_SHANWAN_DS3 0x0523 #define USB_PRODUCT_SONY_DS3 0x0268 From 2eef7ca475decd2b864214cdbfe72b143b16d459 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 3 Jul 2024 14:21:42 -0700 Subject: [PATCH 59/59] Updated to version 2.30.5 for release --- CMakeLists.txt | 2 +- Makefile.os2 | 2 +- Makefile.w32 | 2 +- Xcode/SDL/Info-Framework.plist | 4 ++-- Xcode/SDL/SDL.xcodeproj/project.pbxproj | 12 ++++++------ Xcode/SDL/pkg-support/SDL.info | 2 +- .../src/main/java/org/libsdl/app/SDLActivity.java | 2 +- configure | 2 +- configure.ac | 2 +- include/SDL_version.h | 2 +- src/main/windows/version.rc | 8 ++++---- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a98d3cc6e4b84..47b3dca6c2e09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,7 +87,7 @@ endif() # See docs/release_checklist.md set(SDL_MAJOR_VERSION 2) set(SDL_MINOR_VERSION 30) -set(SDL_MICRO_VERSION 4) +set(SDL_MICRO_VERSION 5) set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}") # Set defaults preventing destination file conflicts diff --git a/Makefile.os2 b/Makefile.os2 index ca8b876d18850..80f95653eb465 100644 --- a/Makefile.os2 +++ b/Makefile.os2 @@ -15,7 +15,7 @@ LIBNAME = SDL2 MAJOR_VERSION = 2 MINOR_VERSION = 30 -MICRO_VERSION = 4 +MICRO_VERSION = 5 VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION) DESCRIPTION = Simple DirectMedia Layer 2 diff --git a/Makefile.w32 b/Makefile.w32 index aacdd83d63a03..d7a01f16eb06b 100644 --- a/Makefile.w32 +++ b/Makefile.w32 @@ -6,7 +6,7 @@ LIBNAME = SDL2 MAJOR_VERSION = 2 MINOR_VERSION = 30 -MICRO_VERSION = 4 +MICRO_VERSION = 5 VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION) LIBHOME = . diff --git a/Xcode/SDL/Info-Framework.plist b/Xcode/SDL/Info-Framework.plist index fc1167f1a3414..87d07aecd8c77 100644 --- a/Xcode/SDL/Info-Framework.plist +++ b/Xcode/SDL/Info-Framework.plist @@ -19,10 +19,10 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.30.4 + 2.30.5 CFBundleSignature SDLX CFBundleVersion - 2.30.4 + 2.30.5 diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj index d260331509064..82bf8b52e4166 100644 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -9729,7 +9729,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEPLOYMENT_POSTPROCESSING = YES; DYLIB_COMPATIBILITY_VERSION = 3001.0.0; - DYLIB_CURRENT_VERSION = 3001.4.0; + DYLIB_CURRENT_VERSION = 3001.5.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_ALTIVEC_EXTENSIONS = YES; @@ -9770,7 +9770,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_LINK_OBJC_RUNTIME = NO; - MARKETING_VERSION = 2.30.4; + MARKETING_VERSION = 2.30.5; OTHER_LDFLAGS = "-liconv"; }; name = Release; @@ -9814,7 +9814,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 3001.0.0; - DYLIB_CURRENT_VERSION = 3001.4.0; + DYLIB_CURRENT_VERSION = 3001.5.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -9856,7 +9856,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_LINK_OBJC_RUNTIME = NO; - MARKETING_VERSION = 2.30.4; + MARKETING_VERSION = 2.30.5; OTHER_LDFLAGS = "-liconv"; }; name = Debug; @@ -10063,7 +10063,7 @@ DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 3001.0.0; - DYLIB_CURRENT_VERSION = 3001.4.0; + DYLIB_CURRENT_VERSION = 3001.5.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; @@ -10115,7 +10115,7 @@ DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 3001.0.0; - DYLIB_CURRENT_VERSION = 3001.4.0; + DYLIB_CURRENT_VERSION = 3001.5.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_NS_ASSERTIONS = NO; GCC_C_LANGUAGE_STANDARD = gnu11; diff --git a/Xcode/SDL/pkg-support/SDL.info b/Xcode/SDL/pkg-support/SDL.info index 87eff0c52bfcb..ee03b718a20d0 100644 --- a/Xcode/SDL/pkg-support/SDL.info +++ b/Xcode/SDL/pkg-support/SDL.info @@ -1,4 +1,4 @@ -Title SDL 2.30.4 +Title SDL 2.30.5 Version 1 Description SDL Library for Mac OS X (http://www.libsdl.org) DefaultLocation /Library/Frameworks diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java index 6ea366205f577..dd152b5dd2f33 100644 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -61,7 +61,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh private static final String TAG = "SDL"; private static final int SDL_MAJOR_VERSION = 2; private static final int SDL_MINOR_VERSION = 30; - private static final int SDL_MICRO_VERSION = 4; + private static final int SDL_MICRO_VERSION = 5; /* // Display InputType.SOURCE/CLASS of events and devices // diff --git a/configure b/configure index 4c2bb0444a7af..c12fef7e75115 100755 --- a/configure +++ b/configure @@ -3508,7 +3508,7 @@ orig_CFLAGS="$CFLAGS" # See docs/release_checklist.md SDL_MAJOR_VERSION=2 SDL_MINOR_VERSION=30 -SDL_MICRO_VERSION=4 +SDL_MICRO_VERSION=5 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION` diff --git a/configure.ac b/configure.ac index 67ef7ebfce55c..907d1d082df72 100644 --- a/configure.ac +++ b/configure.ac @@ -13,7 +13,7 @@ dnl Set various version strings - taken gratefully from the GTk sources # See docs/release_checklist.md SDL_MAJOR_VERSION=2 SDL_MINOR_VERSION=30 -SDL_MICRO_VERSION=4 +SDL_MICRO_VERSION=5 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION` diff --git a/include/SDL_version.h b/include/SDL_version.h index d05fed77c2207..00436603afb68 100644 --- a/include/SDL_version.h +++ b/include/SDL_version.h @@ -59,7 +59,7 @@ typedef struct SDL_version */ #define SDL_MAJOR_VERSION 2 #define SDL_MINOR_VERSION 30 -#define SDL_PATCHLEVEL 4 +#define SDL_PATCHLEVEL 5 /** * Macro to determine SDL version program was compiled against. diff --git a/src/main/windows/version.rc b/src/main/windows/version.rc index 4862fdd649a59..69e6a8e17fb40 100644 --- a/src/main/windows/version.rc +++ b/src/main/windows/version.rc @@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,30,4,0 - PRODUCTVERSION 2,30,4,0 + FILEVERSION 2,30,5,0 + PRODUCTVERSION 2,30,5,0 FILEFLAGSMASK 0x3fL FILEFLAGS 0x0L FILEOS 0x40004L @@ -23,12 +23,12 @@ BEGIN BEGIN VALUE "CompanyName", "\0" VALUE "FileDescription", "SDL\0" - VALUE "FileVersion", "2, 30, 4, 0\0" + VALUE "FileVersion", "2, 30, 5, 0\0" VALUE "InternalName", "SDL\0" VALUE "LegalCopyright", "Copyright (C) 2024 Sam Lantinga\0" VALUE "OriginalFilename", "SDL2.dll\0" VALUE "ProductName", "Simple DirectMedia Layer\0" - VALUE "ProductVersion", "2, 30, 4, 0\0" + VALUE "ProductVersion", "2, 30, 5, 0\0" END END BLOCK "VarFileInfo"