Compare commits

...
Author SHA1 Message Date
Anonymous Maarten 79ec168f3c Add docs to mingw release and don't modify libtool files in mingw's Makefile
(cherry picked from commit 2b2907db18)
2024-10-01 23:05:24 +02:00
Anonymous Maarten 40a3a80d45 release.yml needs setup-ninja 2024-10-01 21:38:05 +02:00
Anonymous Maarten 025fc35c87 Port SDL3 release scripts to SDL2
[skip ci]

(cherry picked from commit 8291b1be36)
2024-10-01 21:22:06 +02:00
Sam Lantinga e9f5f3ac1f Updated to version 2.30.8 for release 2024-10-01 09:25:57 -07:00
Sam Lantinga 235c87dc92 Don't use BlitARGBto555PixelAlpha() for SDL_PIXELFORMAT_ARGB1555
This didn't properly take into account destination alpha.

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

(cherry picked from commit 1aea43846e)
(cherry picked from commit c9f3cbe02f)
2024-09-25 21:58:42 -07:00
Cameron Gutman b6535836aa Throttle tickle reports to PS4/PS5 controllers
UpdateDevice() can be called at an arbitrary rate, so we need to
pace ourselves to avoid filling up the rumble queue with these.

(cherry picked from commit 6ec8b1a173)
(cherry picked from commit 656b599828)
2024-09-25 07:23:09 -07:00
Cameron Gutman 5e90dd3507 kmsdrm: Fix one more place that doesn't try to drop master
(cherry picked from commit 7eb85b07e0)
2024-09-23 19:11:42 -05:00
Cameron Gutman d9139ff3de kmsdrm: Keep fd around if we can drop master
Modern kernels (v5.8+) allow non-root usage of drmDropMaster(), so
we can hold on to our fd after dropping master on it. This fixes
populating drm_fd in the KMSDRM SysWMinfo when using Vulkan.

Also add a missing error check for open() while we're here.

(cherry picked from commit dab4f856c1)
2024-09-23 08:12:58 -07:00
T3hD0gg 5669b97fd7 Add Thrustmaster TMX VID & PID to wheel device list.
(cherry picked from commit 594edb6bd2)
(cherry picked from commit ec9a9fee58)
2024-09-18 22:22:22 -07:00
Cameron Gutman 6f0fae7432 wayland: Fix memory leaks
(cherry picked from commit e239295491)
2024-09-18 20:46:20 -04:00
Anders Jenbo 1c4dd015ac Spell "unknown" correctly
(cherry picked from commit ee377793fe)
(cherry picked from commit d9b4b7d0e0)
2024-09-13 12:30:16 -07:00
Ryan C. Gordon e9efcfb428 pulseaudio: Hotplug thread fixes.
This used a tiny stack, which apparently upsets Blender for various
technical reasons. Instead, just use the default stack size, which should
give it plenty of space to work.

If the thread failed to create, we would then wait on a semaphore that would
never trigger, so don't do that anymore!

Fixes #10806.

(cherry-picked from commit b7dc30ca24)

(cherry picked from commit 58f2586b44)
2024-09-12 15:15:08 -07:00
Frank Praznik d32189918b wayland: Send exposure events when showing or resizing the window
Clients may rely on this event to signal when they should redraw themselves, so send it when appropriate.

(cherry picked from commit 8fa99993af)
2024-09-10 10:22:45 -04:00
Simon McVittie 38d3b1b6d6 x11vulkan: Use the correct SONAME of libX11-xcb.so.1 on Linux, etc.
On most Unix platforms supported by SDL, the canonical name used to load
a library at runtime includes its ABI major version, and the name
without a version is not guaranteed to exist on non-developer systems.
libX11-xcb.so.1 is correct on Linux, and probably on other Unix
platforms like FreeBSD.

A notable exception is OpenBSD, which apparently does not use
ABI-suffixed names, so continue to use libX11-xcb.so there.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 7713a7eec7)
(cherry picked from commit 54757c29dd)
2024-09-09 12:54:20 -07:00
vanfanel 1df907b1ba Add SDL_VIDEO_DOUBLE_BUFFER support to the Wayland backend.
(cherry picked from commit 9e6b8d56e3)
2024-09-08 07:30:22 -07:00
Sam Lantinga 00a7191f67 SDL_XINPUT_Enabled() returns false until XInput DLL is successfully loaded
We make sure we initialize XInput first, so that anything checking whether it's enabled gets a valid result based on whether we were able to load it or not.

(cherry picked from commit 8f46cb771c)
(cherry picked from commit f5ed158d1f)
2024-09-06 11:24:58 -07:00
Sam Lantinga d53b22e8f0 Fixed race condition at startup that could cause a crash in the XInput driver
(cherry picked from commit 6d7c211faf)
(cherry picked from commit 5aadfd4eaf)
2024-09-06 10:38:16 -07:00
Sam Lantinga e5bb4fa90f Fixed memory leak in testthread
(cherry picked from commit dfe6efcd2d)
(cherry picked from commit 224a37faab)
2024-09-05 07:20:05 -07:00
Sam Lantinga ba9b075eba Use atomic variables for thread communication
Fixes https://github.com/libsdl-org/SDL/issues/10711

(cherry picked from commit a0f36fb85b)
(cherry picked from commit a75227aaeb)
2024-09-05 07:19:09 -07:00
Sam Lantinga 85b2733324 Make newer DRM and GBM functions optional
Fixes https://github.com/libsdl-org/SDL/issues/10675

(cherry picked from commit d501f6db07)
(cherry picked from commit 10b4a79379)
2024-09-02 13:08:47 -07:00
Sam Lantinga 9519b9916c Updated to version 2.30.7 for release 2024-09-01 08:11:12 -07:00
Ozkan Sezer 00494df2f1 RAWINPUT_JoystickOpen: add missing SDL_stack_free() calls.
Fixes https://github.com/libsdl-org/SDL/issues/10574.
(cherry picked from commit 845212388e)
(cherry picked from commit 4eac44bed4)
2024-08-25 11:05:56 +03:00
Sam Lantinga 948196448f Added support for the Retro-bit Controller in PS3 mode
Fixes https://github.com/libsdl-org/SDL/issues/10557

(cherry picked from commit e75175129f)
(cherry picked from commit 0de601dc64)
2024-08-19 16:50:00 -07:00
Ozkan Sezer 7ca3d26e7a SDL_x11mouse.c: avoid -Wunused-variable if xinput2 is not available
(cherry picked from commit 30972d7e7f)
2024-08-17 11:23:32 +03:00
Frank Praznik f79d28085d wayland: Send fake warp coordinates when emulating warps with relative mode
Send the fake warp coordinates when emulating warps with relative mode to ensure that it appears that the cursor is always reset to where the application expects it to be.

Fixes cases where games can continue moving the camera if the mouse is lifted during motion.

(cherry picked from commit 8fcbf972c6)
2024-08-16 11:27:44 -04:00
Frank Praznik 74a005f73f x11: Track cursor visibility internally
Cursor visibility in the SDL input layer only reflects whether ShowCursor/HideCursor was called. In the case of relative mode, the cursor can be hidden, but the SDL_Mouse visibility flag will be true.

Track cursor visibility separately in the X11 driver. Fixes the cursor becoming visible when using the warping relative mode with XWayland.

(cherry picked from commit b0713a7d30)
(cherry picked from commit 5b57573439)
2024-08-16 10:36:33 -04:00
Sam Lantinga 6f7aa1e755 Use drmModeAddFB() if drmModeAddFB2WithModifiers() fails
Fixes https://github.com/libsdl-org/SDL/issues/10276

(cherry picked from commit 8e99ec34bb)
(cherry picked from commit b360214950)
2024-08-15 11:54:06 -07:00
Wohlstand 847a6cce96 SDL_vitatouch.c: Fixed the incorrect touch device IDs
- Begining of device ID with 0 violates the SDL's specification that means the 0 is an error, invalid, failure, etc. But on Vita here it's an actual device...
- Replacing 0 and 1 with 1 and 2 to resolve this violation.

(cherry picked from commit dd6c663918)
2024-08-14 08:39:58 -07:00
Sam Lantinga 95aed34a69 Fixed build
(cherry picked from commit 70890b175e)
2024-08-13 09:36:36 -07:00
Ilya Mizus 21e0382edd Fixed secondary screens on KMSDRM (#10535)
* Removed window movement to left top corner that breaks secondary screens on KMSDRM

(cherry picked from commit ce98550cbb)
(cherry picked from commit 586a2dc721)
2024-08-13 09:36:36 -07:00
KaJe 0cdfdb9970 Add Cammus C12 VID & PID to wheel device list.
Add Cammus C12 in the SDL wheel list to enable wheel detection for them.

(cherry picked from commit e1571d704d)
(cherry picked from commit 5ecbc00f36)
2024-08-09 06:49:06 -07:00
Sam Lantinga f75b0aa814 kmsdrm: free the connector when looking for available devices
Fixes https://github.com/libsdl-org/SDL/issues/10499

(cherry picked from commit 1a57ea7fba)
(cherry picked from commit a5bff78d81)
2024-08-08 09:30:33 -07:00
Sam Lantinga 403f87340f Fixed crash when the current mouse capture window is destroyed
Fixes https://github.com/libsdl-org/SDL/issues/10494

(cherry picked from commit 91d97a367e)
(cherry picked from commit 5ca0639a42)
2024-08-07 12:36:04 -07:00
Sam Lantinga 07cfc34a2e Added detail about why a file couldn't be opened (thanks mgerhardy!)
Fixes https://github.com/libsdl-org/SDL/issues/10484

(cherry picked from commit 1512013320)
2024-08-06 05:46:37 -07:00
Anonymous Maarten 4222cebef6 Use SDL_test + don't use macros
The structure of the existing loop makes the inner loop of the previous commit unnecessary.

Manual backport of 558630d59c

(cherry picked from commit 62f35ab1b6)
2024-08-05 07:25:35 -07:00
Sam Lantinga 1e2aa2363b Implemented left-justification in SDL_PrintString()
Fixes https://github.com/libsdl-org/SDL/issues/10310

(cherry picked from commit f59d66f4b1)
(cherry picked from commit 2efbe7fa3f)
2024-08-04 20:07:06 -07:00
vanfanel 0b25cd2196 Fix KMSDRM double buffering.
(cherry picked from commit 5ab1151508)
2024-08-04 15:53:44 -07:00
Anonymous Maarten b7457ff61b cmake: SDL2 target is not always available
(cherry picked from commit 7cf3234efe)
2024-08-04 15:53:17 +02:00
Sam Lantinga ba2f78a006 Updated to version 2.30.6 for release 2024-08-01 14:16:41 -07:00
Sam Lantinga dcbdf09709 Fixed macOS build
(cherry picked from commit 230f1debd0)
2024-08-01 14:15:16 -07:00
Sam Lantinga a9b11980d2 Fixed building on macOS with OpenGL disabled
Fixes https://github.com/libsdl-org/SDL/issues/6226

(cherry picked from commit 0b6eff4167)
2024-08-01 14:04:27 -07:00
Sam Lantinga 906d0e9c03 Fixed crash with joystick rumble after disconnection
This prevents continuing a rumble after the first one fails, and fixes a long standing crash issue if rumble is started immediately before the controller is disconnected.

Thanks to @AntTheAlchemist for the key bug report that showed what was happening here.

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

(cherry picked from commit 0a924b185d)
(cherry picked from commit 7fdf794377)
2024-07-29 13:51:22 -07:00
Sam Lantinga 0952ab1ab9 Fixed whitespace
(cherry picked from commit 67b973b5fa)
(cherry picked from commit 15c73f5bfe)
2024-07-29 12:52:54 -07:00
Charles Cross 7635776ca4 Updates CheckLibUDev() to match main, fixing missing HAVE_LIBUDEV
(cherry picked from commit e306cbcbee)
2024-07-29 07:22:29 -07:00
Ozkan Sezer 76a3457ad5 SDL_mslibc.c: revert PR/10303 changes
(cherry picked from commit 2cb2897e50)
2024-07-28 22:50:00 +03:00
Frank Praznik 881c4cb49e wayland: Don't fail to retrieve a system cursor if no window is focused
Doing this can leave the cursor data in a weird, corrupt state.

(cherry picked from commit 5617ce277d)
(cherry picked from commit 5d1ca1c8c7)
2024-07-27 20:32:33 -04:00
Ozkan Sezer 0406d1c316 testshader.c: include stdlib.h for exit() 2024-07-22 17:40:56 +03:00
Ozkan Sezer 1ca76a29d9 SDL_stdinc.h (SDL_COMPILE_TIME_ASSERT): Keep C++ case alone (after PR/10331)
Some versions of gcc will define __STDC_VERSION__ even when compiling in C++ mode.
Reference issue: https://github.com/libsdl-org/SDL/issues/6078 which was fixed by
https://github.com/libsdl-org/SDL/commit/f6b81125b340e00129978f2c9eebfba6a4d25692

(cherry picked from commit 70c1012e8c)
(cherry picked from commit 86b4d035db)
2024-07-22 16:02:50 +03:00
Anonymous Maarten e53df5b07e stdinc: c23 deprecated _Static_assert in favor of static_assert
(cherry picked from commit 22bfbdbc02)
(cherry picked from commit 5d606eaae2)
2024-07-21 13:18:55 -07:00
Amir e7a47e783b Fix warning for Android NDK compiler: "function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]"
https://stackoverflow.com/questions/42125/warning-error-function-declaration-isnt-a-prototype
In C int foo() and int foo(void) are different functions. int foo() accepts an arbitrary number of arguments, while int foo(void) accepts 0 arguments. In C++ they mean the same thing.

(cherry picked from commit ccade50587)
2024-07-17 14:48:06 -07:00
Ryan C. Gordon 279eb89ce5 README-macos: Typo fixes.
(Manually cherry-picked from 199e6929e5284b8573f02dcb655d3803ed436615.)
2024-07-16 08:32:29 -04:00
Anonymous Maarten fe9020dcb8 pthread: timespec.tv_nsec must be less then 1000000000 ns
(cherry picked from commit 1ef041a2ca)
2024-07-14 17:29:33 +02:00
ceski 4927836b2d Add a Windows mapping for SplitFish Game Controller
(cherry picked from commit 68cf17d0d4)
(cherry picked from commit 3b7eafedb3)
2024-07-12 22:04:47 -07:00
Anonymous Maarten 5a072d38db cmake: only add SDL_LIBC=0 compile options to SDL2 libraries 2024-07-12 23:18:06 +02:00
Sam Lantinga 2d1ebf4850 Make sure SDL subsystems are initialized before starting threads
(cherry picked from commit b057159db7)
2024-07-12 09:11:38 -07:00
Sam Lantinga 44ec2027f3 Make sure timers are initialized before any threads start
This prevents race conditions and divide by zero if multiple threads start using the time functions simultaneously.

(cherry picked from commit b378bc5c83)
2024-07-12 08:02:09 -07:00
Sam Lantinga 000da98663 Fixed OS/2 build
(cherry picked from commit b13dcf24d6)
2024-07-11 13:56:11 -07:00
Sam Lantinga 87ba287f81 Added TLS initialization and shutdown functions
Fixes https://github.com/libsdl-org/SDL/issues/8576

(cherry picked from commit b517043936)
(cherry picked from commit 551164812a)
2024-07-11 13:10:40 -07:00
Ozkan Sezer d133701a72 ci: bump FreeBSD
Reference issue: https://github.com/libsdl-org/SDL/issues/10224.

(cherry picked from commit 956a8bf6c0)
2024-07-11 18:55:56 +03:00
Substring 4635f8597d KMSDRM: fix unsupported modifiers
(cherry picked from commit 9548bba63a)
(cherry picked from commit a2215ff81c)
2024-07-10 14:43:06 -07:00
Sam Lantinga 802351be25 Fixed build
(cherry picked from commit 026dfc6305)
2024-07-08 11:39:25 -07:00
Sam Lantinga d3765b27c2 Make sure we're actually running on Windows before using D3D renderers
(cherry picked from commit e22c89536a)
2024-07-08 11:29:29 -07:00
mariob92 7b11fff2ee wgl/glx: Fix attribute list for SDL_GL_FLOATBUFFERS
This commit fixes the attribute list in the WGL and GLX code when requesting a floating point pixel format. The name of the attribute was missing in the list.

Fixes libsdl-org#10189

(cherry picked from commit 9389712917)
(cherry picked from commit 58e179c8b5)
2024-07-06 11:57:23 -07:00
Sam Lantinga de4573275a Improved detection of Nintendo Switch Pro controller report mode
Fixes https://github.com/libsdl-org/SDL/issues/10182

(cherry picked from commit 4ba2e9f4f4)
(cherry picked from commit 4c44450258)
2024-07-06 05:30:41 -07:00
Ozkan Sezer 275c94c900 SDL_hidapi.c: work-around watcom build error when libusb is enabled
(cherry picked from commit 6a10309568)
2024-07-05 18:56:20 +03:00
Max Maisel c084e647ed Drain HIDAPI buffer in SDL_hidapi_steamdeck.c.
Add a loop around SDL_hid_read() in the Steam Deck HIDAPI driver as it
is done in other HIDAPI drivers. This loop reads data from the device and
processes it until the input buffer is empty which ensures that clients
always get the latest data.

This fixes an input latency issue if the application polls the events
slower than the hardware generates them.

(cherry picked from commit 22770e6496)
2024-07-05 08:29:01 -07:00
Sam Lantinga 2cdb419a21 Try to create an accelerated renderer for the window surface even if SDL_HINT_RENDER_DRIVER is "software"
This case is properly handled inside SDL_CreateWindowTexture()

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

(cherry picked from commit c7ed78a9ef)
(cherry picked from commit a4cbba1276)
2024-07-05 08:23:39 -07:00
Sam Lantinga 2eef7ca475 Updated to version 2.30.5 for release 2024-07-03 14:21:42 -07:00
Sam Lantinga d126e7bbba Added support for the ROG RAIKIRI
(cherry picked from commit a04596c9a7)
(cherry picked from commit 845ebbbe96)
2024-07-03 13:54:52 -07:00
Sam Lantinga e5024fae3d 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 30e93b40c2)
(cherry picked from commit b8daf14fe5)
2024-07-03 13:25:13 -07:00
Ryan C. Gordon eb053c7f3f 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 7d60ff9965)
2024-07-03 13:24:19 -07:00
Sam Lantinga ed441c8289 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 e3cf2e4794)
(cherry picked from commit 66054a6515)
2024-07-03 13:23:04 -07:00
Wouter Wijsman 59b0a1dc65 PSP: send initial SDL_JOYDEVICEADDED event
(cherry picked from commit 5d80179954)
2024-07-03 13:22:03 -07:00
Sam Lantinga 80d36aba5b 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 0f8054cf87)
(cherry picked from commit cd8ea5e3f1)
2024-07-03 11:47:46 -07:00
Sam Lantinga e1e36d213b Fixed build
(cherry picked from commit 288aea3b40)
2024-06-29 11:22:48 -07:00
Sam Lantinga 5c8d92e4d0 Respect SDL_HINT_RENDER_DRIVER when creating an accelerated window surface
Fixes https://github.com/libsdl-org/SDL/issues/10061

(cherry picked from commit 2a58e7b11c)
(cherry picked from commit 0d9e54237c)
2024-06-29 11:13:50 -07:00
Sam Lantinga 8a39054b54 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 a522bfe3f1)
(cherry picked from commit a3f0c373d3)
2024-06-29 11:13:36 -07:00
1F616EMO c60e2704c8 Remove the inconsistent and lag-causing usleep call in SDL_fcitx.c
(cherry picked from commit 3bf2b90da0)
2024-06-29 00:09:34 -07:00
Sam Lantinga a9fdbf7f21 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 0ae4fd0ec9)
(cherry picked from commit ee3b2b7de1)
2024-06-26 15:56:21 -07:00
Sam Lantinga ed86b02df8 Fixed building with older libdrm headers
(cherry picked from commit 8949de3978)
(cherry picked from commit 88bbab275f)
2024-06-26 15:56:20 -07:00
Sam Lantinga 0811b4dc51 Fixed building with the steamrt/scout SDK
(cherry picked from commit 4b82bed259)
(cherry picked from commit ecde0ca6b6)
2024-06-26 15:56:20 -07:00
Sam Lantinga d9901e0b85 Fix building with the steamrt/scout SDK
(cherry picked from commit b552f26e6a)
(cherry picked from commit 64d4baccb5)
2024-06-26 15:56:20 -07:00
Frank Praznik 0f5752b0fc 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 20f1061cc8)
2024-06-26 12:32:07 -04:00
Frank Praznik 31f77182d0 wayland: Fix double free when deleting an output display
(cherry picked from commit 3b88d4f46f)
2024-06-26 12:31:51 -04:00
Cecill Etheredge 620e875335 fix: Use drmModeAddFB2WithModifiers instead of drmModeAddFB to allow using GBM modifiers.
This fixes corrupt framebuffers on platforms that require the use of modifiers.
2024-06-25 14:20:36 -07:00
Edoardo Lolletti c18173c260 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 20dbe90771)
(cherry picked from commit 99d7b9e626)
2024-06-24 11:51:40 -07:00
Ganael Laplanche f08f458896 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 ab5740bde2)
2024-06-23 00:07:35 -07:00
Blaž Tomažič 53cf48f505 android: add an option to manually pass the context when loading a native library
(cherry picked from commit b444e656cd)
2024-06-20 10:40:05 -07:00
Blaž Tomažič c32a1a5023 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 6a2dd96ac7)
2024-06-20 09:35:58 -07:00
expikr 8b204815cc Add SDL_MOUSE_RELATIVE_CURSOR_VISIBLE (#7947)
(cherry picked from commit ee559d51be)
(cherry picked from commit 194d72bb29)
2024-06-20 09:32:27 -07:00
Aikawa Yataro a9bb92b3ae Update qsort implementation
(cherry picked from commit 0fe9f5da54)
(cherry picked from commit 4800edfa0c)
2024-06-19 05:50:00 +03:00
Sam Lantinga 630272eb55 Fixed requesting USB permission on Android 14 (thanks @ikhoeyZX!)
Fixes https://github.com/libsdl-org/SDL/issues/9831

(cherry picked from commit 8ab1ffca8a)
(cherry picked from commit 5a26b26880)
2024-06-17 15:12:05 -07:00
Sam Lantinga 92fe3b19c8 Updated to version 2.30.4 for release 2024-06-17 12:32:13 -07:00
Sam Lantinga 30e2b03a65 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 361cae0874)
(cherry picked from commit a6fdd155fb)
2024-06-17 12:15:18 -07:00
Miku AuahDark f8943854fd 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 3373667faa)
(cherry picked from commit 77285b6c3f)
2024-06-17 09:55:23 -07:00
Ozkan Sezer 325465935d SDL_events.c: remove long long casts an the override of SDL_PRIs64
(cherry picked from commit a4d240d295)
2024-06-14 21:37:24 +03:00
Ozkan Sezer 1cdd37b32c 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 49b6c24722)
(cherry picked from commit 863670c0a8)
2024-06-14 21:37:10 +03:00
Ozkan Sezer 499bff9c3a SDL_qsort.c: fix calling conventions of private functions' compare args 2024-06-14 14:50:10 +03:00
Sam Lantinga bd06e43b87 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 bf27269952)
(cherry picked from commit 169f77ed5e)
2024-06-13 00:02:52 -07:00
Sam Lantinga 72e5620202 Try to guess the type of a Nintendo Switch controller if we can't read the device info
(cherry picked from commit 6619de8f24)
(cherry picked from commit 6b9bf71133)
2024-06-13 00:02:52 -07:00
Sam Lantinga fbb9646806 Ignore spurious reply packets when reading Nintendo Switch controller reports
(cherry picked from commit 5ee9a840b1)
(cherry picked from commit f1b19aa744)
2024-06-13 00:02:52 -07:00
Sam Lantinga 4b91f0793c Fixed build
(cherry picked from commit 2e8bd8f1f3)
2024-06-07 09:14:33 -07:00
Fabrice Desclaux 6243a80b3f Fix spurious LCtrl on RAlt key pressed
(cherry picked from commit 22c14442e2)
2024-06-07 08:46:29 -07:00
Oleg e0b0a98c8e Added VRS DirectForce Pro wheelbase VID/PID to wheel devices list
(cherry picked from commit 7529b4bed5)
(cherry picked from commit 0f9191a643)
2024-06-06 09:55:35 -07:00
Frank Praznik 785eac863b 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 fc6bbde525)
2024-06-06 09:52:08 -04:00
Sam Lantinga ab8659922d 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 b6d7adfec1)
(cherry picked from commit f520062ad1)
2024-06-05 19:30:10 -07:00
Sam Lantinga d48f9c4af4 Added support for the Saitek Cyborg V.3 Rumble Pad in PS3 mode
(cherry picked from commit b6ca360228)
(cherry picked from commit e2f597de84)
2024-06-05 19:30:07 -07:00
Sam Lantinga 5cc0644aa0 Added support for the Razer Kitsune in PS5 mode
(cherry picked from commit e3beaa1972)
(cherry picked from commit 35d719ef25)
2024-05-31 15:19:13 -07:00
mechakotik 91accc391d 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 8f88c32ca6)
(cherry picked from commit 1568501dd6)
2024-05-31 11:33:17 -07:00
Anonymous Maarten 3ee20388c5 autotools needs to check d3d12sdklayers.h too
(cherry picked from commit 5e876db89f)
2024-05-28 17:02:49 +02:00
Ozkan Sezer 2449510673 Makefile.in: add VisualC-GDK to SRC_DIST
Fixes https://github.com/libsdl-org/SDL/issues/9913

(cherry picked from commit 0439fc6007)
2024-05-28 14:10:28 +03:00
Ozkan Sezer 2c07ed320e SDL_config_os2.h: remove duplicated HAVE_WCSL* defines.
(cherry picked from commit 6825a4aabb)
2024-05-28 08:01:04 +03:00
Sam Lantinga 607f37dafd Fixed compiling SDL_platform_defines.h on macOS with older compilers (thanks @sezero!)
Fixes #9632

(cherry picked from commit 36015ad5e5)
(cherry picked from commit 8bc47dc3f1)
2024-05-27 14:39:22 -07:00
Anonymous Maarten acc2e040ce VC+d3d12: use __has_include to detect presence of d3d12 headers
backport of 4fa5006247

(cherry picked from commit 6c29778826)
2024-05-27 02:43:59 +02:00
Anonymous Maarten faa9bbdc8e cmake: direct3d12 renderer needs d3d12.h and d3d12sdklayers.h
Older MinGW releases don't ship d3d12sdklayers.h

backport of 3af4f120d0

(cherry picked from commit 6c10201e58)
2024-05-27 02:43:29 +02:00
Anonymous Maarten cf6c760cd3 d3d12: older Windows SDK headers contain wrong function prototypes
Declare correct function pointers ourselves.

Backport of:
- 98fcf112e7
- 89a4d9ae67

(cherry picked from commit c79e616806)
2024-05-25 00:43:46 +02:00
Anonymous Maarten e49349ac0c d3d12: xbox has no DXGI_PRESENT flags
(cherry picked from commit 54c435409b)
2024-05-25 00:43:41 +02:00
Sam Lantinga 1e5db996ff Added Linux bindings for the Qanba Drone 2 Arcade Joystick
(cherry picked from commit 98a9ca5e32)
(cherry picked from commit 964e0c9b47)
2024-05-23 15:35:17 -07:00
Phena Ildanach 793a0681a9 hidapi: Use a whitelist for libusb when other backends are available
(cherry picked from commit fdf28471c0)
2024-05-17 11:18:45 -07:00
APGR22 825ffaa168 Added NULL pointer check
(cherry picked from commit 961488b0dc)
(cherry picked from commit e4fc07cad0)
2024-05-17 09:01:26 -07:00
Oleg 9ad6a36b7b Added Moza wheelbases VID/PID to wheel devices list
(cherry picked from commit 79cabeef18)
(cherry picked from commit 96e3799495)
2024-05-15 19:43:15 -07:00
Oleg c3b53c72c7 Added Simucube wheelbases VID/PID to wheel devices list
(cherry picked from commit dc9d9dd85a)
(cherry picked from commit 1f54ee1da6)
2024-05-15 19:43:15 -07:00
Oleg 0800d81fb4 Added Cammus C5 wheelbase VID/PID to wheel devices list
(cherry picked from commit ce9177b64f)
(cherry picked from commit 0c7a83ecd5)
2024-05-15 19:43:15 -07:00
Sam Lantinga c27219695a 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 a87fa020ac)
(cherry picked from commit efaa58732a)
2024-05-10 12:19:33 -07:00
Ozkan Sezer 9dcfc308ef 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 2205626816)
(cherry picked from commit b6899f82fb)
2024-05-10 09:10:48 -07:00
Sam Lantinga 77b3a6afaf Added a Windows mapping for the SPEEDLINK STRIKE Gamepad
Fixes https://github.com/libsdl-org/SDL/issues/9705

(cherry picked from commit 01d560df50)
(cherry picked from commit 8c92af5e54)
2024-05-06 10:11:58 -07:00
Ozkan Sezer dd42795131 autotools, cmake, macOS: Do not use the system iconv() by default
backport from PR #9676 by @flibitijibibo

(cherry picked from commit d8fbeec096)
2024-05-03 09:52:59 -07:00
Sam Lantinga fb1497566c Updated to version 2.30.3 for release 2024-05-01 09:14:37 -07:00
Ozkan Sezer cc6c0fe230 test, watcom.mif: revert f9a46a319b
%copy isn't recognized by older wmake versions.
2024-05-01 17:37:10 +03:00
Ozkan Sezer f9a46a319b test, watcom.mif: revert 48a0592a4 and use %copy instead
Ref.: https://github.com/open-watcom/open-watcom-v2/issues/1281.
2024-05-01 17:02:28 +03:00
Ozkan Sezer 48a0592a45 test, watcom makefile: change copy command to use a dos path separator
fixes copy failure with recent open watcom wmake changes. (Issue reported
mainstream as https://github.com/open-watcom/open-watcom-v2/issues/1281)
2024-05-01 11:02:04 +03:00
Sam Lantinga 1c74a8b5ae Fixed building with GDK (thanks @Romans-I-XVI!)
(cherry picked from commit 1caa427035)
2024-04-30 10:21:38 -07:00
Austin Sojka 3d18043005 Added GDK app constrained/unconstrained events (#9608)
(cherry picked from commit 7554e82ec3)
2024-04-30 10:21:32 -07:00
Tyson Whitehead 6e1e00701e Initialize udev before joystick manual scan so class lookup works
LINUX_JoystickInit does a manual scan first so devices are sorted.
If SDL_UDEV_Init hasn't run by then, then the product info cannot
be looked up by SDL_UDEV_GetProductInfo and the initial-plugged-
in-device classification falls back to heuristic guessing.

(cherry picked from commit 0963c11af8)
2024-04-26 12:15:52 -07:00
yuanhecai 5570d846ea loongarch: Delete the configuration of the compilation option "mlasx"
(cherry picked from commit 75340b827d)
2024-04-25 20:33:53 -07:00
Anonymous Maarten f5dcb8f7ad stdinc: modify default alloca prototype
For compatibilty with TinyCC.

Backport of 06758685a5

(cherry picked from commit 9216b7a5ee)
2024-04-25 21:39:23 +03:00
Sam Lantinga f6f1b09b69 Fixed build error (thanks @sezero!)
(cherry picked from commit ac5a61cd60)
(cherry picked from commit 67c60e0b9c)
2024-04-25 09:45:52 -07:00
Tyson Whitehead bf540985aa Avoid opening non-joystick devices if possible to speedup scanning
Closing a device file takes 0.01 to 0.5s, which can add up to
significant startup delays. The udev classification does not
require opening the actual device files, so, use it if possible,
and only fall back to opening the device and probing otherwise.

(cherry picked from commit 45b804c158)
2024-04-25 08:48:57 -07:00
Frank Praznik c39f86c28a x11: Fix pointer warp on XWayland
XWayland seems to require that the pointer be hidden when it is warped, so hide and show the pointer when warping, if required.

Note that XWayland still only allows warping within the window, so attempts to warp to global coordinates outside the window won't work.

(cherry picked from commit a845c7027e)
(cherry picked from commit 863d4a0f2a)
2024-04-25 08:42:04 -07:00
Sam Lantinga b5da8ad00d Fixed Win+V handling (pasting from clipboard history) on Windows (thanks @ocornut!)
Fixes https://github.com/libsdl-org/SDL/issues/9613

(cherry picked from commit 33af02ae68)
2024-04-24 09:24:41 -07:00
Ozkan Sezer f62b86263a CI, macOS: install autoconf.
Reference issue: https://github.com/libsdl-org/SDL/issues/9606 .

(cherry picked from commit 26e3d65ea8)
2024-04-24 00:39:00 +03:00
yassineimounachen 3449c734d5 Add USB IDs for the Thrustmaster TS-XW racing wheel
To be of use, this depends on https://github.com/berarma/oversteer/pull/200 and https://github.com/Kimplul/hid-tmff2/pull/94.

(cherry picked from commit 5ffb2f47d1)
(cherry picked from commit 8f18e2f52d)
2024-04-22 11:36:52 -07:00
Sam Lantinga 3f29d985fe Fixed compilation with C89 (thanks @d-s-a!)
Closes https://github.com/libsdl-org/SDL/pull/9564

(cherry picked from commit 4e29be814e)
2024-04-17 07:50:28 -07:00
Clownacy 2f4a7bbced Fix default Windows window icon not suiting the DPI.
For whatever reason, `ExtractIconEx` returns icons whose sizes are
inappropriate for the current DPI, resulting in terribly-blurry
window icons at higher DPIs.

To solve this, the window icon is now set to the first icon group
that is present in the executable. This behaviour should match what
Explorer does. By selecting an icon group instead of a specific icon,
Windows is free to select the icon within the group that best suits
the current DPI.

(cherry picked from commit 1fa6142903)
2024-04-02 12:05:09 -07:00
Zhuoran a0522e4c21 Fix Caps Lock and Backspace mapping for Colemak
(cherry picked from commit 906ad64d7b)
2024-04-02 07:49:41 -07:00
196 changed files with 3104 additions and 1092 deletions

No files matched your search

+62
View File
@@ -0,0 +1,62 @@
name: 'Setup ninja'
description: 'Download ninja and add it to the PATH environment variable'
inputs:
version:
description: 'Ninja version'
default: '1.12.1'
runs:
using: 'composite'
steps:
- name: 'Calculate variables'
id: calc
shell: sh
run: |
case "${{ runner.os }}-${{ runner.arch }}" in
"Linux-X86" | "Linux-X64")
archive="ninja-linux.zip"
;;
"Linux-ARM64")
archive="ninja-linux-aarch64.zip"
;;
"macOS-X86" | "macOS-X64" | "macOS-ARM64")
archive="ninja-mac.zip"
;;
"Windows-X86" | "Windows-X64")
archive="ninja-win.zip"
;;
"Windows-ARM64")
archive="ninja-winarm64.zip"
;;
*)
echo "Unsupported ${{ runner.os }}-${{ runner.arch }}"
exit 1;
;;
esac
echo "archive=${archive}" >> ${GITHUB_OUTPUT}
echo "cache-key=${archive}-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}" >> ${GITHUB_OUTPUT}
- name: 'Restore cached ${{ steps.calc.outputs.archive }}'
id: cache-restore
uses: actions/cache/restore@v4
with:
path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}'
key: ${{ steps.calc.outputs.cache-key }}
- name: 'Download ninja ${{ inputs.version }} for ${{ runner.os }} (${{ runner.arch }})'
if: ${{ !steps.cache-restore.outputs.cache-hit }}
shell: pwsh
run: |
Invoke-WebRequest "https://github.com/ninja-build/ninja/releases/download/v${{ inputs.version }}/${{ steps.calc.outputs.archive }}" -OutFile "${{ runner.temp }}/${{ steps.calc.outputs.archive }}"
- name: 'Cache ${{ steps.calc.outputs.archive }}'
if: ${{ !steps.cache-restore.outputs.cache-hit }}
uses: actions/cache/save@v4
with:
path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}'
key: ${{ steps.calc.outputs.cache-key }}
- name: 'Extract libusb'
shell: pwsh
run: |
7z "-o${{ runner.temp }}/ninja-${{ inputs.version }}-${{ runner.arch }}" x "${{ runner.temp }}/${{ steps.calc.outputs.archive }}"
- name: 'Set output variables'
id: final
shell: pwsh
run: |
echo "${{ runner.temp }}/ninja-${{ inputs.version }}-${{ runner.arch }}" >> $env:GITHUB_PATH
+2 -2
View File
@@ -10,10 +10,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Build
uses: cross-platform-actions/action@v0.23.0
uses: cross-platform-actions/action@v0.24.0
with:
operating_system: freebsd
version: '13.2'
version: '13.3'
shell: bash
run: |
sudo pkg update
+1
View File
@@ -64,6 +64,7 @@ jobs:
if: runner.os == 'macOS'
run: |
brew install \
autoconf \
ninja \
pkg-config
+406
View File
@@ -0,0 +1,406 @@
name: 'release'
run-name: 'Create SDL release artifacts for ${{ inputs.commit }}'
on:
workflow_dispatch:
inputs:
commit:
description: 'Commit of SDL'
required: true
jobs:
src:
runs-on: ubuntu-latest
outputs:
project: ${{ steps.releaser.outputs.project }}
version: ${{ steps.releaser.outputs.version }}
src-tar-gz: ${{ steps.releaser.outputs.src-tar-gz }}
src-tar-xz: ${{ steps.releaser.outputs.src-tar-xz }}
src-zip: ${{ steps.releaser.outputs.src-zip }}
steps:
- name: 'Set up Python'
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: 'Fetch build-release.py'
uses: actions/checkout@v4
with:
sparse-checkout: 'build-scripts/build-release.py'
- name: 'Set up SDL sources'
uses: actions/checkout@v4
with:
path: 'SDL'
fetch-depth: 0
- name: 'Build Source archive'
id: releaser
shell: bash
run: |
python build-scripts/build-release.py \
--create source \
--commit ${{ inputs.commit }} \
--project SDL2 \
--root "${{ github.workspace }}/SDL" \
--github \
--debug
- name: 'Store source archives'
uses: actions/upload-artifact@v4
with:
name: sources
path: '${{ github.workspace}}/dist'
linux-verify:
needs: [src]
runs-on: ubuntu-latest
steps:
- name: 'Download source archives'
uses: actions/download-artifact@v4
with:
name: sources
path: '${{ github.workspace }}'
- name: 'Unzip ${{ needs.src.outputs.src-zip }}'
id: zip
run: |
mkdir /tmp/zipdir
cd /tmp/zipdir
unzip "${{ github.workspace }}/${{ needs.src.outputs.src-zip }}"
echo "path=/tmp/zipdir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT
- name: 'Untar ${{ needs.src.outputs.src-tar-gz }}'
id: tar
run: |
mkdir -p /tmp/tardir
tar -C /tmp/tardir -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}"
echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT
- name: 'Compare contents of ${{ needs.src.outputs.src-zip }} and ${{ needs.src.outputs.src-tar-gz }}'
run: |
diff /tmp/zipdir /tmp/tardir
- name: 'Test versioning'
shell: bash
run: |
${{ steps.tar.outputs.path }}/build-scripts/test-versioning.sh
- name: 'CMake (configure + build + tests + examples)'
run: |
cmake -S ${{ steps.tar.outputs.path }} -B /tmp/build -DSDL_TEST_LIBRARY=TRUE -DSDL_TESTS=TRUE -DSDL_EXAMPLES=TRUE
cmake --build /tmp/build --verbose
ctest --test-dir /tmp/build --no-tests=error --output-on-failure
dmg:
needs: [src]
runs-on: macos-latest
outputs:
dmg: ${{ steps.releaser.outputs.dmg }}
steps:
- name: 'Set up Python'
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: 'Fetch build-release.py'
uses: actions/checkout@v4
with:
sparse-checkout: 'build-scripts/build-release.py'
- name: 'Download source archives'
uses: actions/download-artifact@v4
with:
name: sources
path: '${{ github.workspace }}'
- name: 'Untar ${{ needs.src.outputs.src-tar-gz }}'
id: tar
run: |
mkdir -p "${{ github.workspace }}/tardir"
tar -C "${{ github.workspace }}/tardir" -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}"
echo "path=${{ github.workspace }}/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT
- name: 'Build SDL2.dmg'
id: releaser
shell: bash
run: |
python build-scripts/build-release.py \
--create framework \
--commit ${{ inputs.commit }} \
--project SDL2 \
--root "${{ steps.tar.outputs.path }}" \
--github \
--debug
- name: 'Store DMG image file'
uses: actions/upload-artifact@v4
with:
name: dmg
path: '${{ github.workspace }}/dist'
dmg-verify:
needs: [dmg, src]
runs-on: macos-latest
steps:
- name: 'Download source archives'
uses: actions/download-artifact@v4
with:
name: sources
path: '${{ github.workspace }}'
- name: 'Download ${{ needs.dmg.outputs.dmg }}'
uses: actions/download-artifact@v4
with:
name: dmg
path: '${{ github.workspace }}'
- name: 'Untar ${{ needs.src.outputs.src-tar-gz }}'
id: src
run: |
mkdir -p /tmp/tardir
tar -C /tmp/tardir -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}"
echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT
- name: 'Mount ${{ needs.dmg.outputs.dmg }}'
id: mount
run: |
hdiutil attach '${{ github.workspace }}/${{ needs.dmg.outputs.dmg }}'
mount_point="/Volumes/${{ needs.src.outputs.project }}"
if [ ! -d "$mount_point/${{ needs.src.outputs.project }}.framework" ]; then
echo "Cannot find ${{ needs.src.outputs.project }}.framework!"
exit 1
fi
echo "mount_point=$mount_point">>$GITHUB_OUTPUT
- name: 'CMake (configure + build) Darwin'
run: |
set -e
cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
-DTEST_FULL=FALSE \
-DTEST_STATIC=FALSE \
-DTEST_TEST=FALSE \
-DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}" \
-DCMAKE_SYSTEM_NAME=Darwin \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-Werror=dev \
-B build_darwin
cmake --build build_darwin --config Release --verbose
cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
-DTEST_FULL=FALSE \
-DTEST_STATIC=FALSE \
-DTEST_TEST=FALSE \
-DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}" \
-DCMAKE_SYSTEM_NAME=Darwin \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-Werror=dev \
-B build_darwin_2
cmake --build build_darwin --config Release --verbose
msvc:
needs: [src]
runs-on: windows-2019
outputs:
VC-x86: ${{ steps.releaser.outputs.VC-x86 }}
VC-x64: ${{ steps.releaser.outputs.VC-x64 }}
VC-devel: ${{ steps.releaser.outputs.VC-devel }}
steps:
- name: 'Set up Python'
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: 'Fetch build-release.py'
uses: actions/checkout@v4
with:
sparse-checkout: 'build-scripts/build-release.py'
- name: 'Download source archives'
uses: actions/download-artifact@v4
with:
name: sources
path: '${{ github.workspace }}'
- name: 'Unzip ${{ needs.src.outputs.src-zip }}'
id: zip
run: |
New-Item C:\temp -ItemType Directory -ErrorAction SilentlyContinue
cd C:\temp
unzip "${{ github.workspace }}/${{ needs.src.outputs.src-zip }}"
echo "path=C:\temp\${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$Env:GITHUB_OUTPUT
- name: 'Build MSVC binary archives'
id: releaser
run: |
python build-scripts/build-release.py `
--create win32 `
--commit ${{ inputs.commit }} `
--project SDL2 `
--root "${{ steps.zip.outputs.path }}" `
--github `
--debug
- name: 'Store MSVC archives'
uses: actions/upload-artifact@v4
with:
name: win32
path: '${{ github.workspace }}/dist'
msvc-verify:
needs: [msvc, src]
runs-on: windows-latest
steps:
- name: 'Fetch .github/actions/setup-ninja/action.yml'
uses: actions/checkout@v4
with:
sparse-checkout: '.github/actions/setup-ninja/action.yml'
- name: 'Download source archives'
uses: actions/download-artifact@v4
with:
name: sources
path: '${{ github.workspace }}'
- name: 'Download MSVC binaries'
uses: actions/download-artifact@v4
with:
name: win32
path: '${{ github.workspace }}'
- name: 'Unzip ${{ needs.src.outputs.src-zip }}'
id: src
run: |
mkdir '${{ github.workspace }}/sources'
cd '${{ github.workspace }}/sources'
unzip "${{ github.workspace }}/${{ needs.src.outputs.src-zip }}"
echo "path=${{ github.workspace }}/sources/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$env:GITHUB_OUTPUT
- name: 'Unzip ${{ needs.msvc.outputs.VC-devel }}'
id: bin
run: |
mkdir '${{ github.workspace }}/vc'
cd '${{ github.workspace }}/vc'
unzip "${{ github.workspace }}/${{ needs.msvc.outputs.VC-devel }}"
echo "path=${{ github.workspace }}/vc/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$env:GITHUB_OUTPUT
- name: Set up ninja
uses: ./.github/actions/setup-ninja
- name: 'Configure vcvars x86'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64_x86
- name: 'CMake (configure + build + tests) x86'
run: |
cmake -S "${{ steps.src.outputs.path }}/cmake/test" `
-B build_x86 `
-GNinja `
-DCMAKE_BUILD_TYPE=Debug `
-Werror=dev `
-DTEST_FULL=FALSE `
-DTEST_STATIC=FALSE `
-DTEST_SHARED=TRUE `
-DTEST_TEST=TRUE `
-DCMAKE_SUPPRESS_REGENERATION=TRUE `
-DCMAKE_PREFIX_PATH="${{ steps.bin.outputs.path }}"
Start-Sleep -Seconds 2
cmake --build build_x86 --config Release --verbose
#ctest --test-dir build_x86 --no-tests=error -C Release --output-on-failure
- name: 'Configure vcvars x64'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
- name: 'CMake (configure + build + tests) x64'
run: |
cmake -S "${{ steps.src.outputs.path }}/cmake/test" `
-B build_x64 `
-GNinja `
-DCMAKE_BUILD_TYPE=Debug `
-Werror=dev `
-DTEST_FULL=FALSE `
-DTEST_STATIC=FALSE `
-DTEST_SHARED=TRUE `
-DTEST_TEST=TRUE `
-DCMAKE_SUPPRESS_REGENERATION=TRUE `
-DCMAKE_PREFIX_PATH="${{ steps.bin.outputs.path }}"
Start-Sleep -Seconds 2
cmake --build build_x64 --config Release --verbose
#ctest --test-dir build_x64 --no-tests=error -C Release --output-on-failure
mingw:
needs: [src]
runs-on: ubuntu-24.04 # FIXME: current ubuntu-latest ships an outdated mingw, replace with ubuntu-latest once 24.04 becomes the new default
outputs:
mingw-devel-tar-gz: ${{ steps.releaser.outputs.mingw-devel-tar-gz }}
mingw-devel-tar-xz: ${{ steps.releaser.outputs.mingw-devel-tar-xz }}
steps:
- name: 'Set up Python'
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: 'Fetch build-release.py'
uses: actions/checkout@v4
with:
sparse-checkout: 'build-scripts/build-release.py'
- name: 'Install Mingw toolchain'
run: |
sudo apt-get update -y
sudo apt-get install -y gcc-mingw-w64 g++-mingw-w64 ninja-build
- name: 'Download source archives'
uses: actions/download-artifact@v4
with:
name: sources
path: '${{ github.workspace }}'
- name: 'Untar ${{ needs.src.outputs.src-tar-gz }}'
id: tar
run: |
mkdir -p /tmp/tardir
tar -C /tmp/tardir -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}"
echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT
- name: 'Build MinGW binary archives'
id: releaser
run: |
python build-scripts/build-release.py \
--create mingw \
--commit ${{ inputs.commit }} \
--project SDL2 \
--root "${{ steps.tar.outputs.path }}" \
--github \
--debug
- name: 'Store MinGW archives'
uses: actions/upload-artifact@v4
with:
name: mingw
path: '${{ github.workspace }}/dist'
mingw-verify:
needs: [mingw, src]
runs-on: ubuntu-latest
steps:
- name: 'Install Mingw toolchain'
run: |
sudo apt-get update -y
sudo apt-get install -y gcc-mingw-w64 g++-mingw-w64 ninja-build
- name: 'Download source archives'
uses: actions/download-artifact@v4
with:
name: sources
path: '${{ github.workspace }}'
- name: 'Download MinGW binaries'
uses: actions/download-artifact@v4
with:
name: mingw
path: '${{ github.workspace }}'
- name: 'Untar ${{ needs.src.outputs.src-tar-gz }}'
id: src
run: |
mkdir -p /tmp/tardir
tar -C /tmp/tardir -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}"
echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT
- name: 'Untar ${{ needs.mingw.outputs.mingw-devel-tar-gz }}'
id: bin
run: |
mkdir -p /tmp/mingw-tardir
tar -C /tmp/mingw-tardir -v -x -f "${{ github.workspace }}/${{ needs.mingw.outputs.mingw-devel-tar-gz }}"
echo "path=/tmp/mingw-tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT
- name: 'CMake (configure + build) i686'
run: |
set -e
cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
-DCMAKE_BUILD_TYPE="Release" \
-DTEST_FULL=FALSE \
-DTEST_STATIC=TRUE \
-DTEST_TEST=TRUE \
-DCMAKE_PREFIX_PATH="${{ steps.bin.outputs.path }}" \
-DCMAKE_TOOLCHAIN_FILE="${{ steps.src.outputs.path }}/build-scripts/cmake-toolchain-mingw64-i686.cmake" \
-DCMAKE_C_FLAGS="-DSDL_DISABLE_SSE4_2" \
-Werror=dev \
-B build_x86
cmake --build build_x86 --config Release --verbose
- name: 'CMake (configure + build) x86_64'
run: |
set -e
cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
-DCMAKE_BUILD_TYPE="Release" \
-DTEST_FULL=FALSE \
-DTEST_STATIC=TRUE \
-DTEST_TEST=TRUE \
-DCMAKE_PREFIX_PATH="${{ steps.bin.outputs.path }}" \
-DCMAKE_TOOLCHAIN_FILE="${{ steps.src.outputs.path }}/build-scripts/cmake-toolchain-mingw64-x86_64.cmake" \
-DCMAKE_C_FLAGS="-DSDL_DISABLE_SSE4_2" \
-Werror=dev \
-B build_x64
cmake --build build_x64 --config Release --verbose
+1
View File
@@ -16,6 +16,7 @@ gen
Build
buildbot
/VERSION.txt
dist
*.so
*.so.*
+23 -32
View File
@@ -87,7 +87,7 @@ endif()
# See docs/release_checklist.md
set(SDL_MAJOR_VERSION 2)
set(SDL_MINOR_VERSION 30)
set(SDL_MICRO_VERSION 2)
set(SDL_MICRO_VERSION 8)
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
# Set defaults preventing destination file conflicts
@@ -241,7 +241,7 @@ endif()
if(UNIX OR MINGW OR MSYS OR (USE_CLANG AND NOT WINDOWS) OR VITA OR PSP OR PS2 OR N3DS)
set(OPT_DEF_LIBC ON)
endif()
if(WINDOWS OR IOS OR TVOS)
if(WINDOWS OR DARWIN OR MACOSX OR IOS OR TVOS)
set(SDL_SYSTEM_ICONV_DEFAULT OFF)
else()
set(SDL_SYSTEM_ICONV_DEFAULT ON)
@@ -926,22 +926,6 @@ if(SDL_ASSEMBLY)
endif()
endif()
if(SDL_LASX)
cmake_push_check_state()
set(CMAKE_REQUIRED_FLAGS "-mlasx")
check_c_source_compiles("
#ifndef __loongarch_asx
#error Assembler CPP flag not enabled
#endif
int main(int argc, char **argv) { return 0; }" CPU_SUPPORTS_LASX)
check_include_file("lasxintrin.h" HAVE_LASXINTRIN_H)
cmake_pop_check_state()
if(CPU_SUPPORTS_LASX AND HAVE_LASXINTRIN_H)
list(APPEND EXTRA_CFLAGS "-mlasx")
set(HAVE_LASX TRUE)
endif()
endif()
if(SDL_ARMSIMD)
set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -x assembler-with-cpp")
@@ -1690,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})
@@ -1793,14 +1777,6 @@ elseif(WINDOWS)
list(APPEND SOURCE_FILES ${WINRT_SOURCE_FILES})
endif()
if(MSVC AND NOT SDL_LIBC)
# Prevent codegen that would use the VC runtime libraries.
set_property(DIRECTORY . APPEND PROPERTY COMPILE_OPTIONS "/GS-;/Gs1048576")
if(NOT ARCH_64 AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM")
set_property(DIRECTORY . APPEND PROPERTY COMPILE_OPTIONS "/arch:SSE")
endif()
endif()
if(SDL_MISC)
if(WINDOWS_STORE)
file(GLOB MISC_SOURCES ${SDL2_SOURCE_DIR}/src/misc/winrt/*.cpp)
@@ -1826,13 +1802,11 @@ elseif(WINDOWS)
check_include_file(d3d9.h HAVE_D3D_H)
check_include_file(d3d11_1.h HAVE_D3D11_H)
check_c_source_compiles("
#include <winsdkver.h>
#include <sdkddkver.h>
#include <d3d12.h>
#include <d3d12sdklayers.h>
ID3D12Device1 *device;
#if WDK_NTDDI_VERSION > 0x0A000008
int main(int argc, char **argv) { return 0; }
#endif" HAVE_D3D12_H)
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)
@@ -3545,6 +3519,23 @@ if(SDL_TEST)
set_property(TARGET SDL2_test PROPERTY INTERFACE_SDL_VERSION "SDL2")
endif()
if(MSVC AND NOT SDL_LIBC)
set(targets )
if(TARGET SDL2)
list(APPEND targets SDL2)
endif()
if(TARGET SDL2-static)
list(APPEND targets SDL2-static)
endif()
if(TARGET SDL2_test)
list(APPEND targets SDL2_test)
endif()
set_property(TARGET ${targets} APPEND PROPERTY COMPILE_OPTIONS "/GS-;/Gs1048576")
if(NOT ARCH_64 AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM")
set_property(TARGET ${targets} APPEND PROPERTY COMPILE_OPTIONS "/arch:SSE")
endif()
endif()
##### Installation targets #####
if(NOT SDL2_DISABLE_INSTALL)
if(SDL_SHARED)
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -15,7 +15,7 @@
LIBNAME = SDL2
MAJOR_VERSION = 2
MINOR_VERSION = 30
MICRO_VERSION = 2
MICRO_VERSION = 8
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
DESCRIPTION = Simple DirectMedia Layer 2
+1 -1
View File
@@ -6,7 +6,7 @@
LIBNAME = SDL2
MAJOR_VERSION = 2
MINOR_VERSION = 30
MICRO_VERSION = 2
MICRO_VERSION = 8
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
LIBHOME = .
@@ -139,7 +139,7 @@
</ResourceCompile>
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalDependencies>xgameruntime.lib;../Microsoft.Xbox.Services.141.GDK.C.Thunks.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>xgameruntime.lib;../Microsoft.Xbox.Services.GDK.C.Thunks.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Gaming.Xbox.Scarlett.x64'">
@@ -211,7 +211,7 @@
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<AdditionalDependencies>xgameruntime.lib;../Microsoft.Xbox.Services.141.GDK.C.Thunks.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>xgameruntime.lib;../Microsoft.Xbox.Services.GDK.C.Thunks.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Gaming.Xbox.Scarlett.x64'">
@@ -409,7 +409,7 @@
<CopyFileToFolders Include="..\..\logos\Logo480x480.png" />
</ItemGroup>
<ItemGroup>
<CopyFileToFolders Include="$(Console_GRDKExtLibRoot)Xbox.Services.API.C\DesignTime\CommonConfiguration\Neutral\Lib\Release\Microsoft.Xbox.Services.141.GDK.C.Thunks.dll">
<CopyFileToFolders Include="$(Console_GRDKExtLibRoot)Xbox.Services.API.C\DesignTime\CommonConfiguration\Neutral\Lib\Release\Microsoft.Xbox.Services.GDK.C.Thunks.dll">
<FileType>Document</FileType>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Gaming.Xbox.Scarlett.x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Gaming.Xbox.XboxOne.x64'">true</ExcludedFromBuild>
-16
View File
@@ -44,22 +44,6 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
+3 -1
View File
@@ -79,6 +79,8 @@ endif()
unset(_sdl2_library)
unset(_sdl2_dll_library)
set(SDL2_SDL2-static_FOUND FALSE)
set(_sdl2main_library "${SDL2_LIBDIR}/SDL2main.lib")
if(EXISTS "${_sdl2main_library}")
if(NOT TARGET SDL2::SDL2main)
@@ -110,7 +112,7 @@ if(EXISTS "${_sdl2test_library}")
endif()
set(SDL2_SDL2test_FOUND TRUE)
else()
set(SDL2_SDL2_FOUND FALSE)
set(SDL2_SDL2test_FOUND FALSE)
endif()
unset(_sdl2test_library)
+4 -4
View File
@@ -52,9 +52,9 @@ void spawnTrailFromEmitter(struct particle *emitter);
void spawnEmitterParticle(GLfloat x, GLfloat y);
void explodeEmitter(struct particle *emitter);
void initializeParticles(void);
void initializeTexture();
void initializeTexture(void);
int nextPowerOfTwo(int x);
void drawParticles();
void drawParticles(void);
void stepParticles(double deltaTime);
/* helper function (used in texture loading)
@@ -159,7 +159,7 @@ stepParticles(double deltaTime)
This draws all the particles shown on screen
*/
void
drawParticles()
drawParticles(void)
{
/* draw the background */
@@ -324,7 +324,7 @@ initializeParticles(void)
loads the particle texture
*/
void
initializeTexture()
initializeTexture(void)
{
int bpp; /* texture bits per pixel */
+1 -1
View File
@@ -196,7 +196,7 @@ loadFont(void)
}
void
draw()
draw(void)
{
SDL_SetRenderDrawColor(renderer, bg_color.r, bg_color.g, bg_color.b, bg_color.a);
SDL_RenderClear(renderer);
+2 -2
View File
@@ -19,10 +19,10 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.30.2</string>
<string>2.30.8</string>
<key>CFBundleSignature</key>
<string>SDLX</string>
<key>CFBundleVersion</key>
<string>2.30.2</string>
<string>2.30.8</string>
</dict>
</plist>
+6 -6
View File
@@ -9729,7 +9729,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEPLOYMENT_POSTPROCESSING = YES;
DYLIB_COMPATIBILITY_VERSION = 3001.0.0;
DYLIB_CURRENT_VERSION = 3001.2.0;
DYLIB_CURRENT_VERSION = 3001.8.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.2;
MARKETING_VERSION = 2.30.8;
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.2.0;
DYLIB_CURRENT_VERSION = 3001.8.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.2;
MARKETING_VERSION = 2.30.8;
OTHER_LDFLAGS = "-liconv";
};
name = Debug;
@@ -10063,7 +10063,7 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 3001.0.0;
DYLIB_CURRENT_VERSION = 3001.2.0;
DYLIB_CURRENT_VERSION = 3001.8.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.2.0;
DYLIB_CURRENT_VERSION = 3001.8.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu11;
+1 -1
View File
@@ -1,4 +1,4 @@
Title SDL 2.30.2
Title SDL 2.30.8
Version 1
Description SDL Library for Mac OS X (http://www.libsdl.org)
DefaultLocation /Library/Frameworks
@@ -62,7 +62,7 @@
<application android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:allowBackup="true"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:theme="@style/AppTheme"
android:hardwareAccelerated="true" >
<!-- Example of setting SDL hints from AndroidManifest.xml:
@@ -277,6 +277,7 @@ public class HIDDeviceManager {
0x044f, // Thrustmaster
0x045e, // Microsoft
0x0738, // Mad Catz
0x0b05, // ASUS
0x0e6f, // PDP
0x0f0d, // Hori
0x10f5, // Turtle Beach
@@ -590,7 +591,13 @@ public class HIDDeviceManager {
} 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);
@@ -38,6 +38,10 @@ public class SDL {
}
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 class SDL {
// 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 class SDL {
// 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
@@ -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 = 2;
private static final int SDL_MICRO_VERSION = 8;
/*
// Display InputType.SOURCE/CLASS of events and devices
//
@@ -89,7 +89,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
| InputDevice.SOURCE_CLASS_POSITION
| InputDevice.SOURCE_CLASS_TRACKBALL);
if (s2 != 0) cls += "Some_Unkown";
if (s2 != 0) cls += "Some_Unknown";
s2 = s_copy & InputDevice.SOURCE_ANY; // keep source only, no class;
@@ -163,7 +163,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
if (s == FLAG_TAINTED) src += " FLAG_TAINTED";
s2 &= ~FLAG_TAINTED;
if (s2 != 0) src += " Some_Unkown";
if (s2 != 0) src += " Some_Unknown";
Log.v(TAG, prefix + "int=" + s_copy + " CLASS={" + cls + " } source(s):" + src);
}
@@ -281,7 +281,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
// Load the .so
public void loadLibraries() {
for (String lib : getLibraries()) {
SDL.loadLibrary(lib);
SDL.loadLibrary(lib, this);
}
}
@@ -995,8 +995,8 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
/* 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 class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
/* 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);
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<style name="AppTheme" parent="android:Theme.NoTitleBar.Fullscreen">
<!-- Customize your theme here. -->
</style>
</resources>
+642
View File
@@ -0,0 +1,642 @@
#!/usr/bin/env python
import argparse
import collections
import contextlib
import datetime
import glob
import io
import json
import logging
import os
from pathlib import Path
import platform
import re
import shutil
import subprocess
import sys
import tarfile
import tempfile
import textwrap
import typing
import zipfile
logger = logging.getLogger(__name__)
VcArchDevel = collections.namedtuple("VcArchDevel", ("dll", "pdb", "imp", "main", "test"))
GIT_HASH_FILENAME = ".git-hash"
ANDROID_AVAILABLE_ABIS = [
"armeabi-v7a",
"arm64-v8a",
"x86",
"x86_64",
]
ANDROID_MINIMUM_API = 19
ANDROID_TARGET_API = 29
ANDROID_MINIMUM_NDK = 21
class Executer:
def __init__(self, root: Path, dry: bool=False):
self.root = root
self.dry = dry
def run(self, cmd, stdout=False, dry_out=None, force=False):
sys.stdout.flush()
logger.info("Executing args=%r", cmd)
if self.dry and not force:
if stdout:
return subprocess.run(["echo", "-E", dry_out or ""], stdout=subprocess.PIPE if stdout else None, text=True, check=True, cwd=self.root)
else:
return subprocess.run(cmd, stdout=subprocess.PIPE if stdout else None, text=True, check=True, cwd=self.root)
class SectionPrinter:
@contextlib.contextmanager
def group(self, title: str):
print(f"{title}:")
yield
class GitHubSectionPrinter(SectionPrinter):
def __init__(self):
super().__init__()
self.in_group = False
@contextlib.contextmanager
def group(self, title: str):
print(f"::group::{title}")
assert not self.in_group, "Can enter a group only once"
self.in_group = True
yield
self.in_group = False
print("::endgroup::")
class VisualStudio:
def __init__(self, executer: Executer, year: typing.Optional[str]=None):
self.executer = executer
self.vsdevcmd = self.find_vsdevcmd(year)
self.msbuild = self.find_msbuild()
@property
def dry(self) -> bool:
return self.executer.dry
VS_YEAR_TO_VERSION = {
"2022": 17,
"2019": 16,
"2017": 15,
"2015": 14,
"2013": 12,
}
def find_vsdevcmd(self, year: typing.Optional[str]=None) -> typing.Optional[Path]:
vswhere_spec = ["-latest"]
if year is not None:
try:
version = self.VS_YEAR_TO_VERSION[year]
except KeyError:
logger.error("Invalid Visual Studio year")
return None
vswhere_spec.extend(["-version", f"[{version},{version+1})"])
vswhere_cmd = ["vswhere"] + vswhere_spec + ["-property", "installationPath"]
vs_install_path = Path(self.executer.run(vswhere_cmd, stdout=True, dry_out="/tmp").stdout.strip())
logger.info("VS install_path = %s", vs_install_path)
assert vs_install_path.is_dir(), "VS installation path does not exist"
vsdevcmd_path = vs_install_path / "Common7/Tools/vsdevcmd.bat"
logger.info("vsdevcmd path = %s", vsdevcmd_path)
if self.dry:
vsdevcmd_path.parent.mkdir(parents=True, exist_ok=True)
vsdevcmd_path.touch(exist_ok=True)
assert vsdevcmd_path.is_file(), "vsdevcmd.bat batch file does not exist"
return vsdevcmd_path
def find_msbuild(self) -> typing.Optional[Path]:
vswhere_cmd = ["vswhere", "-latest", "-requires", "Microsoft.Component.MSBuild", "-find", r"MSBuild\**\Bin\MSBuild.exe"]
msbuild_path = Path(self.executer.run(vswhere_cmd, stdout=True, dry_out="/tmp/MSBuild.exe").stdout.strip())
logger.info("MSBuild path = %s", msbuild_path)
if self.dry:
msbuild_path.parent.mkdir(parents=True, exist_ok=True)
msbuild_path.touch(exist_ok=True)
assert msbuild_path.is_file(), "MSBuild.exe does not exist"
return msbuild_path
def build(self, arch: str, platform: str, configuration: str, projects: list[Path]):
assert projects, "Need at least one project to build"
vsdev_cmd_str = f"\"{self.vsdevcmd}\" -arch={arch}"
msbuild_cmd_str = " && ".join([f"\"{self.msbuild}\" \"{project}\" /m /p:BuildInParallel=true /p:Platform={platform} /p:Configuration={configuration}" for project in projects])
bat_contents = f"{vsdev_cmd_str} && {msbuild_cmd_str}\n"
bat_path = Path(tempfile.gettempdir()) / "cmd.bat"
with bat_path.open("w") as f:
f.write(bat_contents)
logger.info("Running cmd.exe script (%s): %s", bat_path, bat_contents)
cmd = ["cmd.exe", "/D", "/E:ON", "/V:OFF", "/S", "/C", f"CALL {str(bat_path)}"]
self.executer.run(cmd)
class Releaser:
def __init__(self, project: str, commit: str, root: Path, dist_path: Path, section_printer: SectionPrinter, executer: Executer, cmake_generator: str):
self.project = project
self.version = self.extract_sdl_version(root=root, project=project)
self.root = root
self.commit = commit
self.dist_path = dist_path
self.section_printer = section_printer
self.executer = executer
self.cmake_generator = cmake_generator
self.artifacts: dict[str, Path] = {}
@property
def dry(self) -> bool:
return self.executer.dry
def prepare(self):
logger.debug("Creating dist folder")
self.dist_path.mkdir(parents=True, exist_ok=True)
TreeItem = collections.namedtuple("TreeItem", ("path", "mode", "data", "time"))
def _get_file_times(self, paths: tuple[str, ...]) -> dict[str, datetime.datetime]:
dry_out = textwrap.dedent("""\
time=2024-03-14T15:40:25-07:00
M\tCMakeLists.txt
""")
git_log_out = self.executer.run(["git", "log", "--name-status", '--pretty=time=%cI', self.commit], stdout=True, dry_out=dry_out).stdout.splitlines(keepends=False)
current_time = None
set_paths = set(paths)
path_times: dict[str, datetime.datetime] = {}
for line in git_log_out:
if not line:
continue
if line.startswith("time="):
current_time = datetime.datetime.fromisoformat(line.removeprefix("time="))
continue
mod_type, file_paths = line.split(maxsplit=1)
assert current_time is not None
for file_path in file_paths.split("\t"):
if file_path in set_paths and file_path not in path_times:
path_times[file_path] = current_time
assert set(path_times.keys()) == set_paths
return path_times
@staticmethod
def _path_filter(path: str):
if path.startswith(".git"):
return False
return True
def _get_git_contents(self) -> dict[str, TreeItem]:
contents_tgz = subprocess.check_output(["git", "archive", "--format=tar.gz", self.commit, "-o", "/dev/stdout"], text=False)
contents = tarfile.open(fileobj=io.BytesIO(contents_tgz), mode="r:gz")
filenames = tuple(m.name for m in contents if m.isfile())
assert "src/SDL.c" in filenames
assert "include/SDL.h" in filenames
file_times = self._get_file_times(filenames)
git_contents = {}
for ti in contents:
if not ti.isfile():
continue
if not self._path_filter(ti.name):
continue
contents_file = contents.extractfile(ti.name)
assert contents_file, f"{ti.name} is not a file"
git_contents[ti.name] = self.TreeItem(path=ti.name, mode=ti.mode, data=contents_file.read(), time=file_times[ti.name])
return git_contents
def create_source_archives(self) -> None:
archive_base = f"{self.project}-{self.version}"
git_contents = self._get_git_contents()
git_files = list(git_contents.values())
assert len(git_contents) == len(git_files)
latest_mod_time = max(item.time for item in git_files)
git_files.append(self.TreeItem(path="VERSION.txt", data=f"{self.version}\n".encode(), mode=0o100644, time=latest_mod_time))
git_files.append(self.TreeItem(path=GIT_HASH_FILENAME, data=f"{self.commit}\n".encode(), mode=0o100644, time=latest_mod_time))
git_files.sort(key=lambda v: v.time)
zip_path = self.dist_path / f"{archive_base}.zip"
logger.info("Creating .zip source archive (%s)...", zip_path)
if self.dry:
zip_path.touch()
else:
with zipfile.ZipFile(zip_path, "w", compression=zipfile.ZIP_DEFLATED) as zip_object:
for git_file in git_files:
file_data_time = (git_file.time.year, git_file.time.month, git_file.time.day, git_file.time.hour, git_file.time.minute, git_file.time.second)
zip_info = zipfile.ZipInfo(filename=f"{archive_base}/{git_file.path}", date_time=file_data_time)
zip_info.external_attr = git_file.mode << 16
zip_info.compress_type = zipfile.ZIP_DEFLATED
zip_object.writestr(zip_info, data=git_file.data)
self.artifacts["src-zip"] = zip_path
tar_types = (
(".tar.gz", "gz"),
(".tar.xz", "xz"),
)
for ext, comp in tar_types:
tar_path = self.dist_path / f"{archive_base}{ext}"
logger.info("Creating %s source archive (%s)...", ext, tar_path)
if self.dry:
tar_path.touch()
else:
with tarfile.open(tar_path, f"w:{comp}") as tar_object:
for git_file in git_files:
tar_info = tarfile.TarInfo(f"{archive_base}/{git_file.path}")
tar_info.mode = git_file.mode
tar_info.size = len(git_file.data)
tar_info.mtime = git_file.time.timestamp()
tar_object.addfile(tar_info, fileobj=io.BytesIO(git_file.data))
if tar_path.suffix == ".gz":
# Zero the embedded timestamp in the gzip'ed tarball
with open(tar_path, "r+b") as f:
f.seek(4, 0)
f.write(b"\x00\x00\x00\x00")
self.artifacts[f"src-tar-{comp}"] = tar_path
def create_framework(self, configuration: str="Release") -> None:
dmg_in = self.root / f"Xcode/SDL/build/{self.project}.dmg"
dmg_in.unlink(missing_ok=True)
self.executer.run(["xcodebuild", "-project", str(self.root / "Xcode/SDL/SDL.xcodeproj"), "-target", "Standard DMG", "-configuration", configuration])
if self.dry:
dmg_in.parent.mkdir(parents=True, exist_ok=True)
dmg_in.touch()
assert dmg_in.is_file(), f"{self.project}.dmg was not created by xcodebuild"
dmg_out = self.dist_path / f"{self.project}-{self.version}.dmg"
shutil.copy(dmg_in, dmg_out)
self.artifacts["dmg"] = dmg_out
@property
def git_hash_data(self) -> bytes:
return f"{self.commit}\n".encode()
def _tar_add_git_hash(self, tar_object: tarfile.TarFile, root: typing.Optional[str]=None, time: typing.Optional[datetime.datetime]=None):
if not time:
time = datetime.datetime(year=2024, month=4, day=1)
path = GIT_HASH_FILENAME
if root:
path = f"{root}/{path}"
tar_info = tarfile.TarInfo(path)
tar_info.mode = 0o100644
tar_info.size = len(self.git_hash_data)
tar_info.mtime = int(time.timestamp())
tar_object.addfile(tar_info, fileobj=io.BytesIO(self.git_hash_data))
def _zip_add_git_hash(self, zip_file: zipfile.ZipFile, root: typing.Optional[str]=None, time: typing.Optional[datetime.datetime]=None):
if not time:
time = datetime.datetime(year=2024, month=4, day=1)
path = GIT_HASH_FILENAME
if root:
path = f"{root}/{path}"
file_data_time = (time.year, time.month, time.day, time.hour, time.minute, time.second)
zip_info = zipfile.ZipInfo(filename=path, date_time=file_data_time)
zip_info.external_attr = 0o100644 << 16
zip_info.compress_type = zipfile.ZIP_DEFLATED
zip_file.writestr(zip_info, data=self.git_hash_data)
def create_mingw_archives(self) -> None:
build_type = "Release"
mingw_archs = ("i686", "x86_64")
build_parent_dir = self.root / "build-mingw"
zip_path = self.dist_path / f"{self.project}-devel-{self.version}-mingw.zip"
tar_exts = ("gz", "xz")
tar_paths = { ext: self.dist_path / f"{self.project}-devel-{self.version}-mingw.tar.{ext}" for ext in tar_exts}
arch_install_paths = {}
arch_files = {}
for arch in mingw_archs:
build_path = build_parent_dir / f"build-{arch}"
install_path = build_parent_dir / f"install-{arch}"
arch_install_paths[arch] = install_path
shutil.rmtree(install_path, ignore_errors=True)
build_path.mkdir(parents=True, exist_ok=True)
with self.section_printer.group(f"Configuring MinGW {arch}"):
self.executer.run([
"cmake", "-S", str(self.root), "-B", str(build_path),
"--fresh",
f'''-DCMAKE_C_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
f'''-DCMAKE_CXX_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
"-DSDL_SHARED=ON",
"-DSDL_STATIC=ON",
"-DSDL_DISABLE_INSTALL_DOCS=ON",
"-DSDL_TEST_LIBRARY=ON",
"-DSDL_TESTS=OFF",
"-DCMAKE_INSTALL_BINDIR=bin",
"-DCMAKE_INSTALL_DATAROOTDIR=share",
"-DCMAKE_INSTALL_INCLUDEDIR=include",
"-DCMAKE_INSTALL_LIBDIR=lib",
f"-DCMAKE_BUILD_TYPE={build_type}",
f"-DCMAKE_TOOLCHAIN_FILE={self.root}/build-scripts/cmake-toolchain-mingw64-{arch}.cmake",
f"-G{self.cmake_generator}",
f"-DCMAKE_INSTALL_PREFIX={install_path}",
])
with self.section_printer.group(f"Build MinGW {arch}"):
self.executer.run(["cmake", "--build", str(build_path), "--verbose", "--config", build_type])
with self.section_printer.group(f"Install MinGW {arch}"):
self.executer.run(["cmake", "--install", str(build_path), "--strip", "--config", build_type])
arch_files[arch] = list(Path(r) / f for r, _, files in os.walk(install_path) for f in files)
extra_files = (
("mingw/pkg-support/INSTALL.txt", ""),
("mingw/pkg-support/Makefile", ""),
("mingw/pkg-support/cmake/sdl2-config.cmake", "cmake/"),
("mingw/pkg-support/cmake/sdl2-config-version.cmake", "cmake/"),
("BUGS.txt", ""),
("CREDITS.txt", ""),
("README-SDL.txt", ""),
("WhatsNew.txt", ""),
("LICENSE.txt", ""),
("README.md", ""),
("docs/*.md", "docs/"),
)
test_files = list(Path(r) / f for r, _, files in os.walk(self.root / "test") for f in files)
# FIXME: split SDL2.dll debug information into debug library
# objcopy --only-keep-debug SDL2.dll SDL2.debug.dll
# objcopy --add-gnu-debuglink=SDL2.debug.dll SDL2.dll
# objcopy --strip-debug SDL2.dll
for comp in tar_exts:
logger.info("Creating %s...", tar_paths[comp])
with tarfile.open(tar_paths[comp], f"w:{comp}") as tar_object:
arc_root = f"{self.project}-{self.version}"
for file_path_glob, arcdirname in extra_files:
assert not arcdirname or arcdirname[-1] == "/"
for file_path in glob.glob(file_path_glob, root_dir=self.root):
arcname = f"{arc_root}/{arcdirname}{Path(file_path).name}"
tar_object.add(self.root / file_path, arcname=arcname)
for arch in mingw_archs:
install_path = arch_install_paths[arch]
arcname_parent = f"{arc_root}/{arch}-w64-mingw32"
for file in arch_files[arch]:
arcname = os.path.join(arcname_parent, file.relative_to(install_path))
tar_object.add(file, arcname=arcname)
for test_file in test_files:
arcname = f"{arc_root}/test/{test_file.relative_to(self.root/'test')}"
tar_object.add(test_file, arcname=arcname)
self._tar_add_git_hash(tar_object=tar_object, root=arc_root)
self.artifacts[f"mingw-devel-tar-{comp}"] = tar_paths[comp]
def build_vs(self, arch: str, platform: str, vs: VisualStudio, configuration: str="Release") -> VcArchDevel:
dll_path = self.root / f"VisualC/SDL/{platform}/{configuration}/{self.project}.dll"
pdb_path = self.root / f"VisualC/SDL/{platform}/{configuration}/{self.project}.pdb"
imp_path = self.root / f"VisualC/SDL/{platform}/{configuration}/{self.project}.lib"
test_path = self.root / f"VisualC/SDLtest/{platform}/{configuration}/{self.project}test.lib"
main_path = self.root / f"VisualC/SDLmain/{platform}/{configuration}/{self.project}main.lib"
dll_path.unlink(missing_ok=True)
pdb_path.unlink(missing_ok=True)
imp_path.unlink(missing_ok=True)
test_path.unlink(missing_ok=True)
main_path.unlink(missing_ok=True)
projects = [
self.root / "VisualC/SDL/SDL.vcxproj",
self.root / "VisualC/SDLmain/SDLmain.vcxproj",
self.root / "VisualC/SDLtest/SDLtest.vcxproj",
]
with self.section_printer.group(f"Build {arch} VS binary"):
vs.build(arch=arch, platform=platform, configuration=configuration, projects=projects)
if self.dry:
dll_path.parent.mkdir(parents=True, exist_ok=True)
dll_path.touch()
pdb_path.touch()
imp_path.touch()
main_path.parent.mkdir(parents=True, exist_ok=True)
main_path.touch()
test_path.parent.mkdir(parents=True, exist_ok=True)
test_path.touch()
assert dll_path.is_file(), f"{self.project}.dll has not been created"
assert pdb_path.is_file(), f"{self.project}.pdb has not been created"
assert imp_path.is_file(), f"{self.project}.lib has not been created"
assert main_path.is_file(), f"{self.project}main.lib has not been created"
assert test_path.is_file(), f"{self.project}est.lib has not been created"
zip_path = self.dist_path / f"{self.project}-{self.version}-win32-{arch}.zip"
zip_path.unlink(missing_ok=True)
logger.info("Creating %s", zip_path)
with zipfile.ZipFile(zip_path, mode="w", compression=zipfile.ZIP_DEFLATED) as zf:
logger.debug("Adding %s", dll_path.name)
zf.write(dll_path, arcname=dll_path.name)
logger.debug("Adding %s", "README-SDL.txt")
zf.write(self.root / "README-SDL.txt", arcname="README-SDL.txt")
self._zip_add_git_hash(zip_file=zf)
self.artifacts[f"VC-{arch}"] = zip_path
return VcArchDevel(dll=dll_path, pdb=pdb_path, imp=imp_path, main=main_path, test=test_path)
def build_vs_devel(self, arch_vc: dict[str, VcArchDevel]) -> None:
zip_path = self.dist_path / f"{self.project}-devel-{self.version}-VC.zip"
archive_prefix = f"{self.project}-{self.version}"
def zip_file(zf: zipfile.ZipFile, path: Path, arcrelpath: str):
arcname = f"{archive_prefix}/{arcrelpath}"
logger.debug("Adding %s to %s", path, arcname)
zf.write(path, arcname=arcname)
def zip_directory(zf: zipfile.ZipFile, directory: Path, arcrelpath: str):
for f in directory.iterdir():
if f.is_file():
arcname = f"{archive_prefix}/{arcrelpath}/{f.name}"
logger.debug("Adding %s to %s", f, arcname)
zf.write(f, arcname=arcname)
with zipfile.ZipFile(zip_path, mode="w", compression=zipfile.ZIP_DEFLATED) as zf:
for arch, binaries in arch_vc.items():
zip_file(zf, path=binaries.dll, arcrelpath=f"lib/{arch}/{binaries.dll.name}")
zip_file(zf, path=binaries.imp, arcrelpath=f"lib/{arch}/{binaries.imp.name}")
zip_file(zf, path=binaries.pdb, arcrelpath=f"lib/{arch}/{binaries.pdb.name}")
zip_file(zf, path=binaries.main, arcrelpath=f"lib/{arch}/{binaries.main.name}")
zip_file(zf, path=binaries.test, arcrelpath=f"lib/{arch}/{binaries.test.name}")
zip_directory(zf, directory=self.root / "include", arcrelpath="include")
zip_directory(zf, directory=self.root / "docs", arcrelpath="docs")
zip_directory(zf, directory=self.root / "VisualC/pkg-support/cmake", arcrelpath="cmake")
for txt in ("BUGS.txt", "README-SDL.txt", "WhatsNew.txt"):
zip_file(zf, path=self.root / txt, arcrelpath=txt)
zip_file(zf, path=self.root / "LICENSE.txt", arcrelpath="COPYING.txt")
zip_file(zf, path=self.root / "README.md", arcrelpath="README.txt")
self._zip_add_git_hash(zip_file=zf, root=archive_prefix)
self.artifacts["VC-devel"] = zip_path
@classmethod
def extract_sdl_version(cls, root: Path, project: str) -> str:
with open(root / f"include/SDL_version.h", "r") as f:
text = f.read()
major = next(re.finditer(r"^#define SDL_MAJOR_VERSION\s+([0-9]+)$", text, flags=re.M)).group(1)
minor = next(re.finditer(r"^#define SDL_MINOR_VERSION\s+([0-9]+)$", text, flags=re.M)).group(1)
micro = next(re.finditer(r"^#define SDL_PATCHLEVEL\s+([0-9]+)$", text, flags=re.M)).group(1)
return f"{major}.{minor}.{micro}"
def main(argv=None) -> int:
parser = argparse.ArgumentParser(allow_abbrev=False, description="Create SDL release artifacts")
parser.add_argument("--root", metavar="DIR", type=Path, default=Path(__file__).absolute().parents[1], help="Root of SDL")
parser.add_argument("--out", "-o", metavar="DIR", dest="dist_path", type=Path, default="dist", help="Output directory")
parser.add_argument("--github", action="store_true", help="Script is running on a GitHub runner")
parser.add_argument("--commit", default="HEAD", help="Git commit/tag of which a release should be created")
parser.add_argument("--project", required=True, help="Name of the project (e.g. SDL2")
parser.add_argument("--create", choices=["source", "mingw", "win32", "framework", "android"], required=True, action="append", dest="actions", help="What to do")
parser.set_defaults(loglevel=logging.INFO)
parser.add_argument('--vs-year', dest="vs_year", help="Visual Studio year")
parser.add_argument('--android-api', type=int, dest="android_api", help="Android API version")
parser.add_argument('--android-home', dest="android_home", default=os.environ.get("ANDROID_HOME"), help="Android Home folder")
parser.add_argument('--android-ndk-home', dest="android_ndk_home", default=os.environ.get("ANDROID_NDK_HOME"), help="Android NDK Home folder")
parser.add_argument('--android-abis', dest="android_abis", nargs="*", choices=ANDROID_AVAILABLE_ABIS, default=list(ANDROID_AVAILABLE_ABIS), help="Android NDK Home folder")
parser.add_argument('--cmake-generator', dest="cmake_generator", default="Ninja", help="CMake Generator")
parser.add_argument('--debug', action='store_const', const=logging.DEBUG, dest="loglevel", help="Print script debug information")
parser.add_argument('--dry-run', action='store_true', dest="dry", help="Don't execute anything")
parser.add_argument('--force', action='store_true', dest="force", help="Ignore a non-clean git tree")
args = parser.parse_args(argv)
logging.basicConfig(level=args.loglevel, format='[%(levelname)s] %(message)s')
args.actions = set(args.actions)
args.dist_path = args.dist_path.absolute()
args.root = args.root.absolute()
args.dist_path = args.dist_path.absolute()
if args.dry:
args.dist_path = args.dist_path / "dry"
if args.github:
section_printer: SectionPrinter = GitHubSectionPrinter()
else:
section_printer = SectionPrinter()
executer = Executer(root=args.root, dry=args.dry)
root_git_hash_path = args.root / GIT_HASH_FILENAME
root_is_maybe_archive = root_git_hash_path.is_file()
if root_is_maybe_archive:
logger.warning("%s detected: Building from archive", GIT_HASH_FILENAME)
archive_commit = root_git_hash_path.read_text().strip()
if args.commit != archive_commit:
logger.warning("Commit argument is %s, but archive commit is %s. Using %s.", args.commit, archive_commit, archive_commit)
args.commit = archive_commit
else:
args.commit = executer.run(["git", "rev-parse", args.commit], stdout=True, dry_out="e5812a9fd2cda317b503325a702ba3c1c37861d9").stdout.strip()
logger.info("Using commit %s", args.commit)
releaser = Releaser(
project=args.project,
commit=args.commit,
root=args.root,
dist_path=args.dist_path,
executer=executer,
section_printer=section_printer,
cmake_generator=args.cmake_generator,
)
if root_is_maybe_archive:
logger.warning("Building from archive. Skipping clean git tree check.")
else:
porcelain_status = executer.run(["git", "status", "--ignored", "--porcelain"], stdout=True, dry_out="\n").stdout.strip()
if porcelain_status:
print(porcelain_status)
logger.warning("The tree is dirty! Do not publish any generated artifacts!")
if not args.force:
raise Exception("The git repo contains modified and/or non-committed files. Run with --force to ignore.")
with section_printer.group("Arguments"):
print(f"project = {args.project}")
print(f"version = {releaser.version}")
print(f"commit = {args.commit}")
print(f"out = {args.dist_path}")
print(f"actions = {args.actions}")
print(f"dry = {args.dry}")
print(f"force = {args.force}")
print(f"cmake_generator = {args.cmake_generator}")
releaser.prepare()
if "source" in args.actions:
if root_is_maybe_archive:
raise Exception("Cannot build source archive from source archive")
with section_printer.group("Create source archives"):
releaser.create_source_archives()
if "framework" in args.actions:
if platform.system() != "Darwin" and not args.dry:
parser.error("framework artifact(s) can only be built on Darwin")
releaser.create_framework()
if "win32" in args.actions:
if platform.system() != "Windows" and not args.dry:
parser.error("win32 artifact(s) can only be built on Windows")
with section_printer.group("Find Visual Studio"):
vs = VisualStudio(executer=executer)
x86 = releaser.build_vs(arch="x86", platform="Win32", vs=vs)
x64 = releaser.build_vs(arch="x64", platform="x64", vs=vs)
with section_printer.group("Create SDL VC development zip"):
arch_vc = {
"x86": x86,
"x64": x64,
}
releaser.build_vs_devel(arch_vc)
if "mingw" in args.actions:
releaser.create_mingw_archives()
if "android" in args.actions:
if args.android_home is None or not Path(args.android_home).is_dir():
parser.error("Invalid $ANDROID_HOME or --android-home: must be a directory containing the Android SDK")
if args.android_ndk_home is None or not Path(args.android_ndk_home).is_dir():
parser.error("Invalid $ANDROID_NDK_HOME or --android_ndk_home: must be a directory containing the Android NDK")
if args.android_api is None:
with section_printer.group("Detect Android APIS"):
args.android_api = releaser.detect_android_api(android_home=args.android_home)
if args.android_api is None or not (Path(args.android_home) / f"platforms/android-{args.android_api}").is_dir():
parser.error("Invalid --android-api, and/or could not be detected")
if not args.android_abis:
parser.error("Need at least one Android ABI")
with section_printer.group("Android arguments"):
print(f"android_home = {args.android_home}")
print(f"android_ndk_home = {args.android_ndk_home}")
print(f"android_api = {args.android_api}")
print(f"android_abis = {args.android_abis}")
releaser.create_android_archives(
android_api=args.android_api,
android_home=args.android_home,
android_ndk_home=args.android_ndk_home,
android_abis=args.android_abis,
)
with section_printer.group("Summary"):
print(f"artifacts = {releaser.artifacts}")
if args.github:
if args.dry:
os.environ["GITHUB_OUTPUT"] = "/tmp/github_output.txt"
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write(f"project={releaser.project}\n")
f.write(f"version={releaser.version}\n")
for k, v in releaser.artifacts.items():
f.write(f"{k}={v.name}\n")
return 0
if __name__ == "__main__":
raise SystemExit(main())
@@ -0,0 +1,18 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86)
find_program(CMAKE_C_COMPILER NAMES i686-w64-mingw32-gcc)
find_program(CMAKE_CXX_COMPILER NAMES i686-w64-mingw32-g++)
find_program(CMAKE_RC_COMPILER NAMES i686-w64-mingw32-windres windres)
if(NOT CMAKE_C_COMPILER)
message(FATAL_ERROR "Failed to find CMAKE_C_COMPILER.")
endif()
if(NOT CMAKE_CXX_COMPILER)
message(FATAL_ERROR "Failed to find CMAKE_CXX_COMPILER.")
endif()
if(NOT CMAKE_RC_COMPILER)
message(FATAL_ERROR "Failed to find CMAKE_RC_COMPILER.")
endif()
@@ -0,0 +1,18 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
find_program(CMAKE_C_COMPILER NAMES x86_64-w64-mingw32-gcc)
find_program(CMAKE_CXX_COMPILER NAMES x86_64-w64-mingw32-g++)
find_program(CMAKE_RC_COMPILER NAMES x86_64-w64-mingw32-windres windres)
if(NOT CMAKE_C_COMPILER)
message(FATAL_ERROR "Failed to find CMAKE_C_COMPILER.")
endif()
if(NOT CMAKE_CXX_COMPILER)
message(FATAL_ERROR "Failed to find CMAKE_CXX_COMPILER.")
endif()
if(NOT CMAKE_RC_COMPILER)
message(FATAL_ERROR "Failed to find CMAKE_RC_COMPILER.")
endif()
+41
View File
@@ -0,0 +1,41 @@
#!/usr/bin/env python
import argparse
from pathlib import Path
import logging
import re
import subprocess
ROOT = Path(__file__).resolve().parents[1]
def determine_project() -> str:
text = (ROOT / "CMakeLists.txt").read_text()
match = next(re.finditer(r"project\((?P<project>[a-zA-Z0-9_]+)\s+", text, flags=re.M))
project_with_version = match["project"]
project, _ = re.subn("([^a-zA-Z_])", "", project_with_version)
return project
def main():
project = determine_project()
default_remote = f"libsdl-org/{project}"
current_commit = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=ROOT, text=True).strip()
parser = argparse.ArgumentParser(allow_abbrev=False)
parser.add_argument("--ref", required=True, help=f"Name of branch or tag containing release.yml")
parser.add_argument("--remote", "-R", default=default_remote, help=f"Remote repo (default={default_remote})")
parser.add_argument("--commit", default=current_commit, help=f"Commit (default={current_commit})")
args = parser.parse_args()
print(f"Running release.yml workflow:")
print(f" commit = {args.commit}")
print(f" remote = {args.remote}")
subprocess.check_call(["gh", "-R", args.remote, "workflow", "run", "release.yml", "--ref", args.ref, "-f", f"commit={args.commit}"], cwd=ROOT)
if __name__ == "__main__":
raise SystemExit(main())
+3 -2
View File
@@ -1352,12 +1352,13 @@ endmacro()
macro(CheckLibUDev)
if(SDL_LIBUDEV)
check_include_file("libudev.h" have_libudev_header)
if(have_libudev_header)
check_include_file("libudev.h" HAVE_LIBUDEV_HEADER)
if(HAVE_LIBUDEV_HEADER)
set(HAVE_LIBUDEV_H TRUE)
FindLibraryAndSONAME(udev)
if(UDEV_LIB_SONAME)
set(SDL_UDEV_DYNAMIC "\"${UDEV_LIB_SONAME}\"")
set(HAVE_LIBUDEV TRUE)
endif()
endif()
endif()
+26
View File
@@ -27,6 +27,12 @@ add_feature_info("TEST_SHARED" TEST_SHARED "Test linking with shared library")
option(TEST_STATIC "Test linking to static SDL2 library" ON)
add_feature_info("TEST_STATIC" TEST_STATIC "Test linking with static library")
option(TEST_TEST "Test linking to SDL3_test library" ON)
add_feature_info("TEST_TEST" TEST_STATIC "Test linking to SDL test library")
option(TEST_FULL "Run complete SDL test suite" OFF)
add_feature_info("TEST_FULL" TEST_FULL "Build full SDL testsuite")
if(TEST_SHARED)
find_package(SDL2 REQUIRED CONFIG COMPONENTS SDL2)
if(EMSCRIPTEN OR (WIN32 AND NOT WINDOWS_STORE))
@@ -75,6 +81,11 @@ if(TEST_SHARED)
generate_export_header(sharedlib-shared-vars EXPORT_MACRO_NAME MYLIBRARY_EXPORT)
target_compile_definitions(sharedlib-shared-vars PRIVATE "EXPORT_HEADER=\"${CMAKE_CURRENT_BINARY_DIR}/sharedlib-shared-vars_export.h\"")
set_target_properties(sharedlib-shared-vars PROPERTIES C_VISIBILITY_PRESET "hidden")
if(TEST_TEST)
add_executable(sdltest-shared sdltest.c)
target_link_libraries(sdltest-shared PRIVATE SDL2::SDL2main SDL2::SDL2test SDL2::SDL2)
endif()
endif()
if(TEST_STATIC)
@@ -111,6 +122,21 @@ if(TEST_STATIC)
target_link_libraries(cli-static-vars PRIVATE ${SDL2_STATIC_LIBRARIES})
target_include_directories(cli-static-vars PRIVATE ${SDL2_INCLUDE_DIRS})
endif()
if(CMAKE_Swift_COMPILER)
add_executable(swift-static main.swift)
target_include_directories(swift-static PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/swift")
target_link_libraries(swift-static PRIVATE SDL2::SDL2-static)
endif()
endif()
if(TEST_FULL)
enable_testing()
set(SDL_TESTS_TIMEOUT_MULTIPLIER "1" CACHE STRING "Test timeout multiplier")
set(SDL_TESTS_LINK_SHARED ${TEST_SHARED})
add_definitions(-DNO_BUILD_CONFIG)
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../../test" SDL_test)
endif()
message(STATUS "SDL2_PREFIX: ${SDL2_PREFIX}")
+9
View File
@@ -0,0 +1,9 @@
#include "SDL.h"
#include "SDL_test.h"
int main(int argc, char *argv[]) {
SDLTest_CommonState state;
SDLTest_CommonDefaultArgs(&state, argc, argv);
return 0;
}
Vendored
+6 -85
View File
@@ -873,7 +873,6 @@ enable_sse2
enable_sse3
enable_altivec
enable_lsx
enable_lasx
enable_oss
enable_alsa
with_alsa_prefix
@@ -1675,7 +1674,6 @@ Optional Features:
--enable-sse3 use SSE3 assembly routines [default=maybe]
--enable-altivec use Altivec assembly routines [default=yes]
--enable-lsx use LSX assembly routines [default=yes]
--enable-lasx use LASX assembly routines [default=yes]
--enable-oss support the OSS audio API [default=maybe]
--enable-alsa support the ALSA audio API [default=yes]
--disable-alsatest Do not try to compile and run a test Alsa program
@@ -3510,7 +3508,7 @@ orig_CFLAGS="$CFLAGS"
# See docs/release_checklist.md
SDL_MAJOR_VERSION=2
SDL_MINOR_VERSION=30
SDL_MICRO_VERSION=2
SDL_MICRO_VERSION=8
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
@@ -18818,7 +18816,7 @@ fi
enable_system_iconv_default=yes
case "$host" in
*-*-cygwin*|*-*-mingw*)
*-*-cygwin*|*-*-mingw*|*-*-darwin*|*-ios-*)
enable_system_iconv_default=no
;;
esac
@@ -21112,80 +21110,6 @@ printf "%s\n" "#define HAVE_LSXINTRIN_H 1" >>confdefs.h
fi
# Check whether --enable-lasx was given.
if test ${enable_lasx+y}
then :
enableval=$enable_lasx;
else $as_nop
enable_LASX=yes
fi
if test x$enable_LASX = xyes; then
save_CFLAGS="$CFLAGS"
have_gcc_lasx=no
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -mlasx option" >&5
printf %s "checking for GCC -mlasx option... " >&6; }
lasx_CFLAGS="-mlasx"
CFLAGS="$save_CFLAGS $lasx_CFLAGS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#ifndef __loongarch_asx
#error Assembler CPP flag not enabled
#endif
int
main (void)
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
have_gcc_lasx=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_lasx" >&5
printf "%s\n" "$have_gcc_lasx" >&6; }
CFLAGS="$save_CFLAGS"
if test x$have_gcc_lasx = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS $lasx_CFLAGS"
SUMMARY_math="${SUMMARY_math} lasx"
fi
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for lasxintrin.h" >&5
printf %s "checking for lasxintrin.h... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <lasxintrin.h>
int
main (void)
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
have_lasxintrin_h_hdr=yes
else $as_nop
have_lasxintrin_h_hdr=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_lasxintrin_h_hdr" >&5
printf "%s\n" "$have_lasxintrin_h_hdr" >&6; }
if test x$have_lasxintrin_h_hdr = xyes; then
printf "%s\n" "#define HAVE_LASXINTRIN_H 1" >>confdefs.h
fi
CheckOSS()
{
# Check whether --enable-oss was given.
@@ -27589,18 +27513,14 @@ 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; }
{ 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 <winsdkver.h>
#include <sdkddkver.h>
#include <d3d12.h>
#include <d3d12sdklayers.h>
ID3D12Device1 *device;
#if WDK_NTDDI_VERSION <= 0x0A000008
asdf
#endif
int
main (void)
@@ -27619,6 +27539,7 @@ 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 :
+5 -40
View File
@@ -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=2
SDL_MICRO_VERSION=8
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
@@ -322,7 +322,7 @@ AC_ARG_ENABLE(libc,
dnl See whether we are allowed to use system iconv
enable_system_iconv_default=yes
case "$host" in
*-*-cygwin*|*-*-mingw*)
*-*-cygwin*|*-*-mingw*|*-*-darwin*|*-ios-*)
enable_system_iconv_default=no
;;
esac
@@ -938,38 +938,6 @@ fi
AC_DEFINE(HAVE_LSXINTRIN_H, 1, [ ])
fi
AC_ARG_ENABLE(lasx,
[AS_HELP_STRING([--enable-lasx], [use LASX assembly routines [default=yes]])],
, enable_LASX=yes)
if test x$enable_LASX = xyes; then
save_CFLAGS="$CFLAGS"
have_gcc_lasx=no
AC_MSG_CHECKING(for GCC -mlasx option)
lasx_CFLAGS="-mlasx"
CFLAGS="$save_CFLAGS $lasx_CFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifndef __loongarch_asx
#error Assembler CPP flag not enabled
#endif
]], [])], [have_gcc_lasx=yes], [])
AC_MSG_RESULT($have_gcc_lasx)
CFLAGS="$save_CFLAGS"
if test x$have_gcc_lasx = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS $lasx_CFLAGS"
SUMMARY_math="${SUMMARY_math} lasx"
fi
fi
AC_MSG_CHECKING(for lasxintrin.h)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <lasxintrin.h>]])],
[have_lasxintrin_h_hdr=yes],[have_lasxintrin_h_hdr=no])
AC_MSG_RESULT($have_lasxintrin_h_hdr)
if test x$have_lasxintrin_h_hdr = xyes; then
AC_DEFINE(HAVE_LASXINTRIN_H, 1, [ ])
fi
dnl See if the OSS audio interface is supported
CheckOSS()
{
@@ -3375,17 +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_MSG_CHECKING(for d3d12 Windows SDK version)
AC_MSG_CHECKING(for compatible d3d12 headers)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <winsdkver.h>
#include <sdkddkver.h>
#include <d3d12.h>
#include <d3d12sdklayers.h>
ID3D12Device1 *device;
#if WDK_NTDDI_VERSION <= 0x0A000008
asdf
#endif
]])], [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)
+4 -4
View File
@@ -261,10 +261,10 @@ Some things that may be of interest about how it all works...
## Working directory
In SDL 1.2, the working directory of your SDL app is by default set to its
parent, but this is no longer the case in SDL 2.0. SDL2 does change the
working directory, which means it'll be whatever the command line prompt
that launched the program was using, or if launched by double-clicking in
the finger, it will be "/", the _root of the filesystem_. Plan accordingly!
parent, but this is no longer the case in SDL 2.0 and later. SDL2 does not
change the working directory, which means it'll be whatever the command line
prompt that launched the program was using, or if launched by double-clicking
in the Finder, it will be "/", the _root of the filesystem_. Plan accordingly!
You can use SDL_GetBasePath() to find where the program is running from and
chdir() there directly.
-3
View File
@@ -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
+3 -1
View File
@@ -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(<d3d12.h>) && __has_include(<d3d12sdklayers.h>)
#define HAVE_D3D12_H 1
#endif
#endif
#if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0603 /* Windows 8.1 SDK */
#define HAVE_SHELLSCALINGAPI_H 1
#endif
+14 -1
View File
@@ -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)
@@ -1900,6 +1912,7 @@ extern "C" {
* Since it's driver-specific, it's only supported where possible and
* implemented. Currently supported the following drivers:
*
* - Wayland (wayland)
* - KMSDRM (kmsdrm)
* - Raspberry Pi (raspberrypi)
*/
+10 -5
View File
@@ -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.
*
+6
View File
@@ -73,7 +73,13 @@
#if defined(__APPLE__)
/* lets us know what version of Mac OS X we're compiling on */
#include <AvailabilityMacros.h>
#ifndef __has_extension /* Older compilers don't support this */
#define __has_extension(x) 0
#include <TargetConditionals.h>
#undef __has_extension
#else
#include <TargetConditionals.h>
#endif
/* Fix building with older SDKs that don't define these
See this for more information:
+16 -13
View File
@@ -107,7 +107,7 @@
# elif defined(__MRC__)
void *alloca(unsigned);
# else
char *alloca();
void *alloca(size_t);
# endif
#endif
@@ -253,10 +253,10 @@ typedef uint64_t Uint64;
* <stdint.h> 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
@@ -377,9 +377,12 @@ typedef uint64_t Uint64;
#ifndef SDL_COMPILE_TIME_ASSERT
#if defined(__cplusplus)
/* Keep C++ case alone: Some versions of gcc will define __STDC_VERSION__ even when compiling in C++ mode. */
#if (__cplusplus >= 201103L)
#define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x)
#endif
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L)
#define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x)
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
#define SDL_COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x)
#endif
+1 -1
View File
@@ -59,7 +59,7 @@ typedef struct SDL_version
*/
#define SDL_MAJOR_VERSION 2
#define SDL_MINOR_VERSION 30
#define SDL_PATCHLEVEL 2
#define SDL_PATCHLEVEL 8
/**
* Macro to determine SDL version program was compiled against.
+18
View File
@@ -0,0 +1,18 @@
The 32-bit files are in i686-w64-mingw32
The 64-bit files are in x86_64-w64-mingw32
To install SDL for native development:
make native
To install SDL for cross-compiling development:
make cross
Look at the example programs in ./test, and check out online documentation:
http://wiki.libsdl.org/
Join the SDL developer mailing list if you want to join the community:
http://www.libsdl.org/mailing-list.php
That's it!
Sam Lantinga <slouken@libsdl.org>
+28
View File
@@ -0,0 +1,28 @@
#
# Makefile for installing the mingw32 version of the SDL library
CROSS_PATH := /usr/local
ARCHITECTURES := i686-w64-mingw32 x86_64-w64-mingw32
all install:
@echo "Type \"make native\" to install 32-bit to /usr"
@echo "Type \"make cross\" to install 32-bit and 64-bit to $(CROSS_PATH)"
native:
make install-package arch=i686-w64-mingw32 prefix=/usr
cross:
for arch in $(ARCHITECTURES); do \
make install-package arch=$$arch prefix=$(CROSS_PATH)/$$arch; \
done
install-package:
@if test -d $(arch) && test -d $(prefix); then \
(cd $(arch) && cp -rv bin include lib share $(prefix)/); \
sed "s|^prefix=.*|prefix=$(prefix)|" <$(arch)/bin/sdl2-config >$(prefix)/bin/sdl2-config; \
chmod 755 $(prefix)/bin/sdl2-config; \
sed "s|^prefix=.*|prefix=$(prefix)|" <$(arch)/lib/pkgconfig/sdl2.pc >$(prefix)/lib/pkgconfig/sdl2.pc; \
else \
echo "*** ERROR: $(arch) or $(prefix) does not exist!"; \
exit 1; \
fi
@@ -2,9 +2,9 @@
# This file is meant to be placed in a cmake subfolder of SDL2-devel-2.x.y-mingw
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL2/sdl2-config-version.cmake")
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL2/SDL2ConfigVersion.cmake")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL2/sdl2-config-version.cmake")
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL2/SDL2ConfigVersion.cmake")
else()
set(PACKAGE_VERSION_UNSUITABLE TRUE)
return()
+2 -2
View File
@@ -2,9 +2,9 @@
# This file is meant to be placed in a cmake subfolder of SDL2-devel-2.x.y-mingw
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL2/sdl2-config.cmake")
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL2/SDL2Config.cmake")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL2/sdl2-config.cmake")
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL2/SDL2Config.cmake")
else()
set(SDL2_FOUND FALSE)
return()
+33 -23
View File
@@ -29,9 +29,6 @@
#endif
#if defined(__OS2__)
#include "core/os2/SDL_os2.h"
#ifdef SDL_THREAD_OS2
#include "thread/os2/SDL_systls_c.h"
#endif
#endif
/* this checks for HAVE_DBUS_DBUS_H internally. */
@@ -52,6 +49,7 @@
#include "haptic/SDL_haptic_c.h"
#include "joystick/SDL_joystick_c.h"
#include "sensor/SDL_sensor_c.h"
#include "thread/SDL_thread_c.h"
/* Initialization/Cleanup routines */
#ifndef SDL_TIMERS_DISABLED
@@ -116,6 +114,7 @@ static SDL_bool SDL_MainIsReady = SDL_FALSE;
#else
static SDL_bool SDL_MainIsReady = SDL_TRUE;
#endif
static SDL_bool SDL_main_thread_initialized = SDL_FALSE;
static SDL_bool SDL_bInMainQuit = SDL_FALSE;
static Uint8 SDL_SubsystemRefCount[32];
@@ -181,6 +180,36 @@ void SDL_SetMainReady(void)
SDL_MainIsReady = SDL_TRUE;
}
void SDL_InitMainThread(void)
{
if (SDL_main_thread_initialized) {
return;
}
SDL_InitTLSData();
#ifndef SDL_TIMERS_DISABLED
SDL_TicksInit();
#endif
SDL_LogInit();
SDL_main_thread_initialized = SDL_TRUE;
}
static void SDL_QuitMainThread(void)
{
if (!SDL_main_thread_initialized) {
return;
}
SDL_LogQuit();
#ifndef SDL_TIMERS_DISABLED
SDL_TicksQuit();
#endif
SDL_QuitTLSData();
SDL_main_thread_initialized = SDL_FALSE;
}
int SDL_InitSubSystem(Uint32 flags)
{
Uint32 flags_initialized = 0;
@@ -189,8 +218,6 @@ int SDL_InitSubSystem(Uint32 flags)
return SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?");
}
SDL_LogInit();
/* Clear the error message */
SDL_ClearError();
@@ -198,10 +225,6 @@ int SDL_InitSubSystem(Uint32 flags)
SDL_DBus_Init();
#endif
#ifdef SDL_THREAD_OS2
SDL_OS2TLSAlloc(); /* thread/os2/SDL_systls.c */
#endif
#ifdef SDL_VIDEO_DRIVER_WINDOWS
if (flags & (SDL_INIT_HAPTIC | SDL_INIT_JOYSTICK)) {
if (SDL_HelperWindowCreate() < 0) {
@@ -210,10 +233,6 @@ int SDL_InitSubSystem(Uint32 flags)
}
#endif
#ifndef SDL_TIMERS_DISABLED
SDL_TicksInit();
#endif
/* Initialize the event subsystem */
if (flags & SDL_INIT_EVENTS) {
#ifndef SDL_EVENTS_DISABLED
@@ -378,9 +397,6 @@ int SDL_Init(Uint32 flags)
void SDL_QuitSubSystem(Uint32 flags)
{
#if defined(__OS2__)
#ifdef SDL_THREAD_OS2
SDL_OS2TLSFree(); /* thread/os2/SDL_systls.c */
#endif
SDL_OS2Quit();
#endif
@@ -504,10 +520,6 @@ void SDL_Quit(void)
#endif
SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
#ifndef SDL_TIMERS_DISABLED
SDL_TicksQuit();
#endif
#ifdef SDL_USE_LIBDBUS
SDL_DBus_Quit();
#endif
@@ -515,14 +527,12 @@ void SDL_Quit(void)
SDL_ClearHints();
SDL_AssertionsQuit();
SDL_LogQuit();
/* Now that every subsystem has been quit, we reset the subsystem refcount
* and the list of initialized subsystems.
*/
SDL_memset(SDL_SubsystemRefCount, 0x0, sizeof(SDL_SubsystemRefCount));
SDL_TLSCleanup();
SDL_QuitMainThread();
SDL_bInMainQuit = SDL_FALSE;
}
+4
View File
@@ -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) {
+2
View File
@@ -208,6 +208,8 @@
#include "SDL_assert.h"
#include "SDL_log.h"
extern void SDL_InitMainThread(void);
#endif /* SDL_internal_h_ */
/* vi: set ts=4 sw=4 expandtab: */
+2 -2
View File
@@ -86,7 +86,7 @@ static struct
#undef SDL_ARTS_SYM
static void UnloadARTSLibrary()
static void UnloadARTSLibrary(void)
{
if (arts_handle) {
SDL_UnloadObject(arts_handle);
@@ -119,7 +119,7 @@ static int LoadARTSLibrary(void)
#else
static void UnloadARTSLibrary()
static void UnloadARTSLibrary(void)
{
return;
}
+2 -2
View File
@@ -64,7 +64,7 @@ static struct
#undef SDL_ESD_SYM
static void UnloadESDLibrary()
static void UnloadESDLibrary(void)
{
if (esd_handle) {
SDL_UnloadObject(esd_handle);
@@ -96,7 +96,7 @@ static int LoadESDLibrary(void)
#else
static void UnloadESDLibrary()
static void UnloadESDLibrary(void)
{
return;
}
+2 -2
View File
@@ -77,7 +77,7 @@ static struct
#undef SDL_FS_SYM
static void UnloadFusionSoundLibrary()
static void UnloadFusionSoundLibrary(void)
{
if (fs_handle) {
SDL_UnloadObject(fs_handle);
@@ -110,7 +110,7 @@ static int LoadFusionSoundLibrary(void)
#else
static void UnloadFusionSoundLibrary()
static void UnloadFusionSoundLibrary(void)
{
return;
}
+14 -14
View File
@@ -142,13 +142,13 @@ static int pipewire_dlsym(const char *fn, void **addr)
return -1; \
}
static int load_pipewire_library()
static int load_pipewire_library(void)
{
pipewire_handle = SDL_LoadObject(pipewire_library);
return pipewire_handle ? 0 : -1;
}
static void unload_pipewire_library()
static void unload_pipewire_library(void)
{
if (pipewire_handle) {
SDL_UnloadObject(pipewire_handle);
@@ -160,18 +160,18 @@ static void unload_pipewire_library()
#define SDL_PIPEWIRE_SYM(x) PIPEWIRE_##x = x
static int load_pipewire_library()
static int load_pipewire_library(void)
{
return 0;
}
static void unload_pipewire_library()
static void unload_pipewire_library(void)
{ /* Nothing to do */
}
#endif /* SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC */
static int load_pipewire_syms()
static int load_pipewire_syms(void)
{
SDL_PIPEWIRE_SYM(pw_get_library_version);
SDL_PIPEWIRE_SYM(pw_init);
@@ -212,7 +212,7 @@ SDL_FORCE_INLINE SDL_bool pipewire_version_at_least(int major, int minor, int pa
(pipewire_version_major > major || pipewire_version_minor > minor || pipewire_version_patch >= patch);
}
static int init_pipewire_library()
static int init_pipewire_library(void)
{
if (!load_pipewire_library()) {
if (!load_pipewire_syms()) {
@@ -234,7 +234,7 @@ static int init_pipewire_library()
return -1;
}
static void deinit_pipewire_library()
static void deinit_pipewire_library(void)
{
PIPEWIRE_pw_deinit();
unload_pipewire_library();
@@ -340,7 +340,7 @@ static void io_list_remove(Uint32 id)
}
}
static void io_list_sort()
static void io_list_sort(void)
{
struct io_node *default_sink = NULL, *default_source = NULL;
struct io_node *n, *temp;
@@ -365,7 +365,7 @@ static void io_list_sort()
}
}
static void io_list_clear()
static void io_list_clear(void)
{
struct io_node *n, *temp;
@@ -426,7 +426,7 @@ static void pending_list_remove(Uint32 id)
}
}
static void pending_list_clear()
static void pending_list_clear(void)
{
struct node_object *node, *temp;
@@ -751,7 +751,7 @@ static const struct pw_registry_events registry_events = { PW_VERSION_REGISTRY_E
.global_remove = registry_event_remove_callback };
/* The hotplug thread */
static int hotplug_loop_init()
static int hotplug_loop_init(void)
{
int res;
@@ -794,7 +794,7 @@ static int hotplug_loop_init()
return 0;
}
static void hotplug_loop_destroy()
static void hotplug_loop_destroy(void)
{
if (hotplug_loop) {
PIPEWIRE_pw_thread_loop_stop(hotplug_loop);
@@ -836,7 +836,7 @@ static void hotplug_loop_destroy()
}
}
static void PIPEWIRE_DetectDevices()
static void PIPEWIRE_DetectDevices(void)
{
struct io_node *io;
@@ -1342,7 +1342,7 @@ failed:
return ret;
}
static void PIPEWIRE_Deinitialize()
static void PIPEWIRE_Deinitialize(void)
{
if (pipewire_initialized) {
hotplug_loop_destroy();
+7 -3
View File
@@ -885,7 +885,7 @@ static int SDLCALL HotplugThread(void *data)
return 0;
}
static void PULSEAUDIO_DetectDevices()
static void PULSEAUDIO_DetectDevices(void)
{
SDL_sem *ready_sem = SDL_CreateSemaphore(0);
@@ -897,8 +897,12 @@ static void PULSEAUDIO_DetectDevices()
/* ok, we have a sane list, let's set up hotplug notifications now... */
SDL_AtomicSet(&pulseaudio_hotplug_thread_active, 1);
pulseaudio_hotplug_thread = SDL_CreateThreadInternal(HotplugThread, "PulseHotplug", 256 * 1024, ready_sem); /* !!! FIXME: this can probably survive in significantly less stack space. */
SDL_SemWait(ready_sem);
pulseaudio_hotplug_thread = SDL_CreateThreadInternal(HotplugThread, "PulseHotplug", 0, ready_sem);
if (pulseaudio_hotplug_thread) {
SDL_SemWait(ready_sem);
} else {
SDL_AtomicSet(&pulseaudio_hotplug_thread_active, 0); // thread failed to start, we'll go on without hotplug.
}
SDL_DestroySemaphore(ready_sem);
}
+8 -8
View File
@@ -842,18 +842,18 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)(
}
/* Lock / Unlock Mutex */
void Android_ActivityMutex_Lock()
void Android_ActivityMutex_Lock(void)
{
SDL_LockMutex(Android_ActivityMutex);
}
void Android_ActivityMutex_Unlock()
void Android_ActivityMutex_Unlock(void)
{
SDL_UnlockMutex(Android_ActivityMutex);
}
/* Lock the Mutex when the Activity is in its 'Running' state */
void Android_ActivityMutex_Lock_Running()
void Android_ActivityMutex_Lock_Running(void)
{
int pauseSignaled = 0;
int resumeSignaled = 0;
@@ -1439,13 +1439,13 @@ void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint)
(*env)->DeleteLocalRef(env, jhint);
}
void Android_JNI_MinizeWindow()
void Android_JNI_MinizeWindow(void)
{
JNIEnv *env = Android_JNI_GetEnv();
(*env)->CallStaticVoidMethod(env, mActivityClass, midMinimizeWindow);
}
SDL_bool Android_JNI_ShouldMinimizeOnFocusLoss()
SDL_bool Android_JNI_ShouldMinimizeOnFocusLoss(void)
{
JNIEnv *env = Android_JNI_GetEnv();
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midShouldMinimizeOnFocusLoss);
@@ -1879,7 +1879,7 @@ static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent)
return SDL_FALSE;
}
static void Internal_Android_Create_AssetManager()
static void Internal_Android_Create_AssetManager(void)
{
struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
@@ -1918,7 +1918,7 @@ static void Internal_Android_Create_AssetManager()
LocalReferenceHolder_Cleanup(&refs);
}
static void Internal_Android_Destroy_AssetManager()
static void Internal_Android_Destroy_AssetManager(void)
{
JNIEnv *env = Android_JNI_GetEnv();
@@ -2153,7 +2153,7 @@ int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seco
}
/* Add all touch devices */
void Android_JNI_InitTouch()
void Android_JNI_InitTouch(void)
{
JNIEnv *env = Android_JNI_GetEnv();
(*env)->CallStaticVoidMethod(env, mActivityClass, midInitTouch);
+1 -1
View File
@@ -134,7 +134,7 @@ static void kbd_cleanup_signal_action(int signum, siginfo_t *info, void *ucontex
SDL_EVDEV_kbd_reraise_signal(signum);
}
static void kbd_unregister_emerg_cleanup()
static void kbd_unregister_emerg_cleanup(void)
{
int tabidx, signum;
+21
View File
@@ -36,6 +36,7 @@ extern "C" {
static XTaskQueueHandle GDK_GlobalTaskQueue;
PAPPSTATE_REGISTRATION hPLM = {};
PAPPCONSTRAIN_REGISTRATION hCPLM = {};
HANDLE plmSuspendComplete = nullptr;
extern "C" DECLSPEC int
@@ -177,6 +178,23 @@ SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved)
return -1;
}
/* Register constrain/unconstrain handling */
auto raccn = [](BOOLEAN constrained, PVOID context) {
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "[GDK] in RegisterAppConstrainedChangeNotification handler");
SDL_VideoDevice *_this = SDL_GetVideoDevice();
if (_this) {
if (constrained) {
SDL_SetKeyboardFocus(NULL);
} else {
SDL_SetKeyboardFocus(_this->windows);
}
}
};
if (RegisterAppConstrainedChangeNotification(raccn, NULL, &hCPLM)) {
SDL_SetError("[GDK] Unable to call RegisterAppConstrainedChangeNotification");
return -1;
}
/* Run the application main() code */
result = mainFunction(argc, argv);
@@ -184,6 +202,9 @@ SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved)
UnregisterAppStateChangeNotification(hPLM);
CloseHandle(plmSuspendComplete);
/* Unregister constrain/unconstrain handling */
UnregisterAppConstrainedChangeNotification(hCPLM);
/* !!! FIXME: This follows the docs exactly, but for some reason still leaks handles on exit? */
/* Terminate the task queue and dispatch any pending tasks */
XTaskQueueTerminate(taskQueue, false, nullptr, nullptr);
+1 -1
View File
@@ -214,7 +214,7 @@ static void kbd_cleanup_signal_action(int signum, siginfo_t *info, void *ucontex
SDL_EVDEV_kbd_reraise_signal(signum);
}
static void kbd_unregister_emerg_cleanup()
static void kbd_unregister_emerg_cleanup(void)
{
int tabidx, signum;
+3 -4
View File
@@ -55,7 +55,7 @@ typedef struct _FcitxClient
static FcitxClient fcitx_client;
static char *GetAppName()
static char *GetAppName(void)
{
#if defined(__LINUX__) || defined(__FREEBSD__)
char *spot;
@@ -368,7 +368,7 @@ static Uint32 Fcitx_ModState(void)
return fcitx_mods;
}
SDL_bool SDL_Fcitx_Init()
SDL_bool SDL_Fcitx_Init(void)
{
fcitx_client.dbus = SDL_DBus_GetContext();
@@ -380,7 +380,7 @@ SDL_bool SDL_Fcitx_Init()
return FcitxClientCreateIC(&fcitx_client);
}
void SDL_Fcitx_Quit()
void SDL_Fcitx_Quit(void)
{
FcitxClientICCallMethod(&fcitx_client, "DestroyIC");
if (fcitx_client.ic_path) {
@@ -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);
}
}
+2 -2
View File
@@ -40,7 +40,7 @@ static _SDL_IME_ProcessKeyEvent SDL_IME_ProcessKeyEvent_Real = NULL;
static _SDL_IME_UpdateTextRect SDL_IME_UpdateTextRect_Real = NULL;
static _SDL_IME_PumpEvents SDL_IME_PumpEvents_Real = NULL;
static void InitIME()
static void InitIME(void)
{
static SDL_bool inited = SDL_FALSE;
#ifdef HAVE_FCITX
@@ -142,7 +142,7 @@ void SDL_IME_UpdateTextRect(const SDL_Rect *rect)
}
}
void SDL_IME_PumpEvents()
void SDL_IME_PumpEvents(void)
{
if (SDL_IME_PumpEvents_Real) {
SDL_IME_PumpEvents_Real();
+3 -3
View File
@@ -79,7 +79,7 @@ static SDL_bool realtime_portal_supported(DBusConnection *conn)
"RTTimeUSecMax", DBUS_TYPE_INT64, &res);
}
static void set_rtkit_interface()
static void set_rtkit_interface(void)
{
SDL_DBusContext *dbus = SDL_DBus_GetContext();
@@ -108,7 +108,7 @@ static DBusConnection *get_rtkit_dbus_connection()
return NULL;
}
static void rtkit_initialize()
static void rtkit_initialize(void)
{
DBusConnection *dbus_conn;
@@ -134,7 +134,7 @@ static void rtkit_initialize()
}
}
static SDL_bool rtkit_initialize_realtime_thread()
static SDL_bool rtkit_initialize_realtime_thread(void)
{
// Following is an excerpt from rtkit README that outlines the requirements
// a thread must meet before making rtkit requests:
+3 -3
View File
@@ -449,7 +449,7 @@ static SDL_WSCONS_input_data *SDL_WSCONS_Init_Keyboard(const char *dev)
return input;
}
void SDL_WSCONS_Init()
void SDL_WSCONS_Init(void)
{
inputs[0] = SDL_WSCONS_Init_Keyboard("/dev/wskbd0");
inputs[1] = SDL_WSCONS_Init_Keyboard("/dev/wskbd1");
@@ -460,7 +460,7 @@ void SDL_WSCONS_Init()
return;
}
void SDL_WSCONS_Quit()
void SDL_WSCONS_Quit(void)
{
int i = 0;
SDL_WSCONS_input_data *input = NULL;
@@ -921,7 +921,7 @@ static void updateKeyboard(SDL_WSCONS_input_data *input)
}
}
void SDL_WSCONS_PumpEvents()
void SDL_WSCONS_PumpEvents(void)
{
int i = 0;
for (i = 0; i < 4; i++) {
+1 -1
View File
@@ -1239,7 +1239,7 @@ void SDL_SIMDFree(void *ptr)
#include <stdio.h>
int main()
int main(void)
{
printf("CPU count: %d\n", SDL_GetCPUCount());
printf("CPU type: %s\n", SDL_GetCPUType());
+5 -12
View File
@@ -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;
+14 -1
View File
@@ -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);
}
+1
View File
@@ -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;
+2 -1
View File
@@ -36,6 +36,7 @@
#ifdef HAVE_STDIO_H
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#endif
#ifdef HAVE_LIMITS_H
@@ -632,7 +633,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode)
FILE *fp = fopen(file, mode);
#endif
if (!fp) {
SDL_SetError("Couldn't open %s", file);
SDL_SetError("Couldn't open %s: %s", file, strerror(errno));
} else if (!IsRegularFileOrPipe(fp)) {
fclose(fp);
fp = NULL;
-2
View File
@@ -20,7 +20,6 @@
*/
#include "../../SDL_internal.h"
#ifdef SDL_FILESYSTEM_XBOX
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* System dependent filesystem routines */
@@ -135,6 +134,5 @@ SDL_GetPrefPath(const char *org, const char *app)
return folderPath;
}
#endif /* SDL_FILESYSTEM_XBOX */
/* vi: set ts=4 sw=4 expandtab: */
+47
View File
@@ -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
#define use_libusb_whitelist_default SDL_TRUE
#else
#define 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);
+3 -2
View File
@@ -519,7 +519,7 @@ static struct usb_string_cache_entry *usb_string_cache = NULL;
static size_t usb_string_cache_size = 0;
static size_t usb_string_cache_insert_pos = 0;
static int usb_string_cache_grow()
static int usb_string_cache_grow(void)
{
struct usb_string_cache_entry *new_cache;
size_t allocSize;
@@ -537,7 +537,7 @@ static int usb_string_cache_grow()
return 0;
}
static void usb_string_cache_destroy()
static void usb_string_cache_destroy(void)
{
size_t i;
for (i = 0; i < usb_string_cache_insert_pos; i++) {
@@ -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 */
+1 -1
View File
@@ -504,7 +504,7 @@ int HID_API_EXPORT hid_exit(void)
return 0;
}
static void process_pending_events() {
static void process_pending_events(void) {
SInt32 res;
do {
res = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.001, FALSE);
+1 -1
View File
@@ -264,7 +264,7 @@ static void register_error(hid_device *device, const char *op)
}
#ifndef HIDAPI_USE_DDK
static int lookup_functions()
static int lookup_functions(void)
{
lib_handle = LoadLibrary(TEXT("hid.dll"));
if (lib_handle) {
+23 -37
View File
@@ -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;
}
@@ -1391,9 +1377,6 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForNameAndGUID(const
}
#endif /* __LINUX__ */
if (!mapping) {
mapping = s_pDefaultMapping;
}
return mapping;
}
@@ -1506,6 +1489,9 @@ static ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index)
}
}
if (!mapping) {
mapping = s_pDefaultMapping;
}
return mapping;
}
@@ -2059,7 +2045,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;
+4
View File
@@ -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,",
@@ -323,6 +324,7 @@ static const char *s_ControllerMappings[] = {
"030000009b2800000500000000000000,Saturn_Adapter_2.0,a:b1,b:b2,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b0,y:b3,",
"030000008f0e00000800000000000000,SpeedLink Strike FX,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:a3,start:b9,x:b3,y:b0,",
"03000000c01100000591000000000000,Speedlink Torid,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:a3,start:b9,x:b3,y:b0,",
"030000004c0500006802000000000000,SplitFish Game Controller,crc:5628,a:b0,b:b16,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,leftshoulder:b17,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b10,",
"03000000de280000ff11000000000000,Steam Virtual Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"03000000110100003114000000000000,SteelSeries Stratus Duo,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,",
"03000000381000001814000000000000,SteelSeries Stratus XL,a:b0,b:b1,back:b18,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,guide:b19,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b2,y:b3,",
@@ -771,6 +773,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,",
+35 -9
View File
@@ -370,7 +370,11 @@ static Uint32 initial_wheel_devices[] = {
MAKE_VIDPID(0x044f, 0xb65e), /* Thrustmaster T500RS */
MAKE_VIDPID(0x044f, 0xb664), /* Thrustmaster TX (initial mode) */
MAKE_VIDPID(0x044f, 0xb669), /* Thrustmaster TX (active mode) */
MAKE_VIDPID(0x044f, 0xb67f), /* Thrustmaster TMX */
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) */
@@ -383,10 +387,21 @@ 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 */
MAKE_VIDPID(0x2433, 0xf306), /* Asetek SimSports Tony Kannan Wheelbase */
MAKE_VIDPID(0x3416, 0x0301), /* Cammus C5 Wheelbase */
MAKE_VIDPID(0x3416, 0x0302), /* Cammus C12 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,
@@ -1399,9 +1414,13 @@ int SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint
retval = 0;
} else {
retval = joystick->driver->Rumble(joystick, low_frequency_rumble, high_frequency_rumble);
joystick->rumble_resend = SDL_GetTicks() + SDL_RUMBLE_RESEND_MS;
if (!joystick->rumble_resend) {
joystick->rumble_resend = 1;
if (retval == 0) {
joystick->rumble_resend = SDL_GetTicks() + SDL_RUMBLE_RESEND_MS;
if (joystick->rumble_resend == 0) {
joystick->rumble_resend = 1;
}
} else {
joystick->rumble_resend = 0;
}
}
@@ -2164,12 +2183,14 @@ void SDL_JoystickUpdate(void)
#endif /* SDL_JOYSTICK_HIDAPI */
for (joystick = SDL_joysticks; joystick; joystick = joystick->next) {
if (joystick->attached) {
joystick->driver->Update(joystick);
if (!joystick->attached) {
continue;
}
if (joystick->delayed_guide_button) {
SDL_GameControllerHandleDelayedGuideButton(joystick);
}
joystick->driver->Update(joystick);
if (joystick->delayed_guide_button) {
SDL_GameControllerHandleDelayedGuideButton(joystick);
}
now = SDL_GetTicks();
@@ -2207,7 +2228,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,
@@ -2735,6 +2756,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;
}
+4 -2
View File
@@ -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
@@ -68,7 +69,7 @@ static const ControllerDescription_t arrControllers[] = {
{ MAKE_CONTROLLER_ID( 0x20d6, 0x576d ), k_eControllerType_PS3Controller, NULL }, // Power A PS3
{ MAKE_CONTROLLER_ID( 0x20d6, 0xca6d ), k_eControllerType_PS3Controller, NULL }, // From SDL
{ MAKE_CONTROLLER_ID( 0x2563, 0x0523 ), k_eControllerType_PS3Controller, NULL }, // Digiflip GP006
{ MAKE_CONTROLLER_ID( 0x2563, 0x0575 ), k_eControllerType_PS3Controller, NULL }, // From SDL
{ MAKE_CONTROLLER_ID( 0x2563, 0x0575 ), k_eControllerType_PS3Controller, "Retro-bit Controller" }, // SWITCH CO., LTD. Retro-bit Controller
{ MAKE_CONTROLLER_ID( 0x25f0, 0x83c3 ), k_eControllerType_PS3Controller, NULL }, // gioteck vx2
{ MAKE_CONTROLLER_ID( 0x25f0, 0xc121 ), k_eControllerType_PS3Controller, NULL }, //
{ MAKE_CONTROLLER_ID( 0x2c22, 0x2003 ), k_eControllerType_PS3Controller, NULL }, // Qanba Drone
@@ -157,6 +158,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
@@ -593,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)
+91 -50
View File
@@ -50,6 +50,7 @@ typedef struct
SDL_HIDAPI_Device *device;
SDL_Joystick *joystick;
SDL_bool is_shanwan;
SDL_bool has_analog_buttons;
SDL_bool report_sensors;
SDL_bool effects_updated;
int player_index;
@@ -145,6 +146,7 @@ static SDL_bool HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device)
}
ctx->device = device;
ctx->is_shanwan = is_shanwan;
ctx->has_analog_buttons = SDL_TRUE;
device->context = ctx;
@@ -247,7 +249,10 @@ static SDL_bool HIDAPI_DriverPS3_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy
/* Initialize the joystick capabilities */
joystick->nbuttons = 15;
joystick->naxes = 16;
joystick->naxes = 6;
if (ctx->has_analog_buttons) {
joystick->naxes += 10;
}
joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 100.0f);
@@ -432,7 +437,7 @@ static void HIDAPI_DriverPS3_HandleStatePacket(SDL_Joystick *joystick, SDL_Drive
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, axis);
/* Buttons are mapped as axes in the order they appear in the button enumeration */
{
if (ctx->has_analog_buttons) {
static int button_axis_offsets[] = {
24, /* SDL_CONTROLLER_BUTTON_A */
23, /* SDL_CONTROLLER_BUTTON_B */
@@ -584,7 +589,13 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_IsSupportedDevice(SDL_HIDAPI_Device *
Uint8 data[USB_PACKET_LENGTH];
int size;
if (HIDAPI_SupportsPlaystationDetection(vendor_id, product_id)) {
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) {
size = ReadFeatureReport(device->dev, 0x03, data, sizeof(data));
if (size == 8 && data[2] == 0x26) {
@@ -611,6 +622,11 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_InitDevice(SDL_HIDAPI_Device *device)
return SDL_FALSE;
}
ctx->device = device;
if (device->vendor_id == USB_VENDOR_SWITCH && device->product_id == USB_PRODUCT_SWITCH_RETROBIT_CONTROLLER) {
ctx->has_analog_buttons = SDL_FALSE;
} else {
ctx->has_analog_buttons = SDL_TRUE;
}
device->context = ctx;
@@ -644,8 +660,17 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_OpenJoystick(SDL_HIDAPI_Device *devic
/* Initialize the joystick capabilities */
joystick->nbuttons = 15;
joystick->naxes = 16;
joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
joystick->naxes = 6;
if (ctx->has_analog_buttons) {
joystick->naxes += 10;
}
if (device->vendor_id == USB_VENDOR_SWITCH && device->product_id == USB_PRODUCT_SWITCH_RETROBIT_CONTROLLER) {
// This is a wireless controller using a USB dongle
joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
} else {
joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
}
return SDL_TRUE;
}
@@ -756,7 +781,7 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket18(SDL_Joystick *joystic
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, axis);
/* Buttons are mapped as axes in the order they appear in the button enumeration */
{
if (ctx->has_analog_buttons) {
static int button_axis_offsets[] = {
12, /* SDL_GAMEPAD_BUTTON_A */
11, /* SDL_GAMEPAD_BUTTON_B */
@@ -768,7 +793,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 */
@@ -813,53 +838,69 @@ 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;
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;
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;
if (data[0] & 0x40) {
axis = 32767;
} else {
axis = ((int)data[17] * 257) - 32768;
}
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis);
axis = ((int)data[18] * 257) - 32768;
if (data[0] & 0x80) {
axis = 32767;
} else {
axis = ((int)data[18] * 257) - 32768;
}
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, axis);
axis = ((int)data[3] * 257) - 32768;
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, axis);
@@ -871,7 +912,7 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket19(SDL_Joystick *joystic
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, axis);
/* Buttons are mapped as axes in the order they appear in the button enumeration */
{
if (ctx->has_analog_buttons) {
static int button_axis_offsets[] = {
13, /* SDL_CONTROLLER_BUTTON_A */
12, /* SDL_CONTROLLER_BUTTON_B */
+1
View File
@@ -1208,6 +1208,7 @@ static SDL_bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device)
if (SDL_TICKS_PASSED(now, ctx->last_packet + BLUETOOTH_DISCONNECT_TIMEOUT_MS)) {
/* Send an empty output report to tickle the Bluetooth stack */
HIDAPI_DriverPS4_TickleBluetooth(device);
ctx->last_packet = now;
}
} else {
/* Reconnect the Bluetooth device once the USB device is gone */
+7
View File
@@ -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);
@@ -1494,6 +1500,7 @@ static SDL_bool HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device)
if (SDL_TICKS_PASSED(now, ctx->last_packet + BLUETOOTH_DISCONNECT_TIMEOUT_MS)) {
/* Send an empty output report to tickle the Bluetooth stack */
HIDAPI_DriverPS5_TickleBluetooth(device);
ctx->last_packet = now;
}
} else {
/* Reconnect the Bluetooth device once the USB device is gone */
+119 -111
View File
@@ -134,119 +134,12 @@ static SDL_bool FeedDeckLizardWatchdog(SDL_hid_device *dev)
return SDL_TRUE;
}
/*****************************************************************************************************/
static void HIDAPI_DriverSteamDeck_RegisterHints(SDL_HintCallback callback, void *userdata)
static void HIDAPI_DriverSteamDeck_HandleState(SDL_HIDAPI_Device *device,
SDL_Joystick *joystick,
ValveInReport_t *pInReport)
{
SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_STEAMDECK, callback, userdata);
}
static void HIDAPI_DriverSteamDeck_UnregisterHints(SDL_HintCallback callback, void *userdata)
{
SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_STEAMDECK, callback, userdata);
}
static SDL_bool HIDAPI_DriverSteamDeck_IsEnabled(void)
{
return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_STEAMDECK,
SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT));
}
static SDL_bool HIDAPI_DriverSteamDeck_IsSupportedDevice(
SDL_HIDAPI_Device *device,
const char *name,
SDL_GameControllerType type,
Uint16 vendor_id,
Uint16 product_id,
Uint16 version,
int interface_number,
int interface_class,
int interface_subclass,
int interface_protocol)
{
return SDL_IsJoystickSteamDeck(vendor_id, product_id);
}
static SDL_bool HIDAPI_DriverSteamDeck_InitDevice(SDL_HIDAPI_Device *device)
{
int size;
Uint8 data[64];
SDL_DriverSteamDeck_Context *ctx;
ctx = (SDL_DriverSteamDeck_Context *)SDL_calloc(1, sizeof(*ctx));
if (ctx == NULL) {
SDL_OutOfMemory();
return SDL_FALSE;
}
// Always 1kHz according to USB descriptor
ctx->update_rate_us = 1000;
device->context = ctx;
// Read a report to see if this is the correct endpoint.
// Mouse, Keyboard and Controller have the same VID/PID but
// only the controller hidraw device receives hid reports.
size = SDL_hid_read_timeout(device->dev, data, sizeof(data), 16);
if (size == 0)
return SDL_FALSE;
if (!DisableDeckLizardMode(device->dev))
return SDL_FALSE;
HIDAPI_SetDeviceName(device, "Steam Deck");
return HIDAPI_JoystickConnected(device, NULL);
}
static int HIDAPI_DriverSteamDeck_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id)
{
return -1;
}
static void HIDAPI_DriverSteamDeck_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index)
{
}
static SDL_bool HIDAPI_DriverSteamDeck_UpdateDevice(SDL_HIDAPI_Device *device)
{
SDL_DriverSteamDeck_Context *ctx = (SDL_DriverSteamDeck_Context *)device->context;
SDL_Joystick *joystick = NULL;
int r;
uint8_t data[64];
float values[3];
ValveInReport_t *pInReport = (ValveInReport_t *)data;
if (device->num_joysticks > 0) {
joystick = SDL_JoystickFromInstanceID(device->joysticks[0]);
if (joystick == NULL) {
return SDL_FALSE;
}
} else {
return SDL_FALSE;
}
if (ctx->watchdog_counter++ > 200) {
ctx->watchdog_counter = 0;
if (!FeedDeckLizardWatchdog(device->dev))
return SDL_FALSE;
}
SDL_memset(data, 0, sizeof(data));
r = SDL_hid_read(device->dev, data, sizeof(data));
if (r == 0) {
return SDL_FALSE;
} else if (r <= 0) {
/* Failed to read from controller */
HIDAPI_JoystickDisconnected(device, device->joysticks[0]);
return SDL_FALSE;
}
if (!(r == 64 && pInReport->header.unReportVersion == k_ValveInReportMsgVersion && pInReport->header.ucType == ID_CONTROLLER_DECK_STATE && pInReport->header.ucLength == 64)) {
return SDL_FALSE;
}
// Uint64 timestamp = SDL_GetTicksNS();
SDL_DriverSteamDeck_Context *ctx = (SDL_DriverSteamDeck_Context *)device->context;
if (pInReport->payload.deckState.ulButtons != ctx->last_button_state) {
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_A,
@@ -322,6 +215,121 @@ static SDL_bool HIDAPI_DriverSteamDeck_UpdateDevice(SDL_HIDAPI_Device *device)
values[1] = (pInReport->payload.deckState.sAccelZ / 32768.0f) * 2.0f * SDL_STANDARD_GRAVITY;
values[2] = (-pInReport->payload.deckState.sAccelY / 32768.0f) * 2.0f * SDL_STANDARD_GRAVITY;
SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_ACCEL, ctx->sensor_timestamp_us, values, 3);
}
/*****************************************************************************************************/
static void HIDAPI_DriverSteamDeck_RegisterHints(SDL_HintCallback callback, void *userdata)
{
SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_STEAMDECK, callback, userdata);
}
static void HIDAPI_DriverSteamDeck_UnregisterHints(SDL_HintCallback callback, void *userdata)
{
SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_STEAMDECK, callback, userdata);
}
static SDL_bool HIDAPI_DriverSteamDeck_IsEnabled(void)
{
return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_STEAMDECK,
SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT));
}
static SDL_bool HIDAPI_DriverSteamDeck_IsSupportedDevice(
SDL_HIDAPI_Device *device,
const char *name,
SDL_GameControllerType type,
Uint16 vendor_id,
Uint16 product_id,
Uint16 version,
int interface_number,
int interface_class,
int interface_subclass,
int interface_protocol)
{
return SDL_IsJoystickSteamDeck(vendor_id, product_id);
}
static SDL_bool HIDAPI_DriverSteamDeck_InitDevice(SDL_HIDAPI_Device *device)
{
int size;
Uint8 data[64];
SDL_DriverSteamDeck_Context *ctx;
ctx = (SDL_DriverSteamDeck_Context *)SDL_calloc(1, sizeof(*ctx));
if (ctx == NULL) {
SDL_OutOfMemory();
return SDL_FALSE;
}
// Always 1kHz according to USB descriptor, but actually about 4 ms.
ctx->update_rate_us = 4000;
device->context = ctx;
// Read a report to see if this is the correct endpoint.
// Mouse, Keyboard and Controller have the same VID/PID but
// only the controller hidraw device receives hid reports.
size = SDL_hid_read_timeout(device->dev, data, sizeof(data), 16);
if (size == 0)
return SDL_FALSE;
if (!DisableDeckLizardMode(device->dev))
return SDL_FALSE;
HIDAPI_SetDeviceName(device, "Steam Deck");
return HIDAPI_JoystickConnected(device, NULL);
}
static int HIDAPI_DriverSteamDeck_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id)
{
return -1;
}
static void HIDAPI_DriverSteamDeck_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index)
{
}
static SDL_bool HIDAPI_DriverSteamDeck_UpdateDevice(SDL_HIDAPI_Device *device)
{
SDL_DriverSteamDeck_Context *ctx = (SDL_DriverSteamDeck_Context *)device->context;
SDL_Joystick *joystick = NULL;
int r;
uint8_t data[64];
ValveInReport_t *pInReport = (ValveInReport_t *)data;
if (device->num_joysticks > 0) {
joystick = SDL_JoystickFromInstanceID(device->joysticks[0]);
if (joystick == NULL) {
return SDL_FALSE;
}
} else {
return SDL_FALSE;
}
if (ctx->watchdog_counter++ > 200) {
ctx->watchdog_counter = 0;
if (!FeedDeckLizardWatchdog(device->dev))
return SDL_FALSE;
}
SDL_memset(data, 0, sizeof(data));
do {
r = SDL_hid_read(device->dev, data, sizeof(data));
if (r < 0) {
/* Failed to read from controller */
HIDAPI_JoystickDisconnected(device, device->joysticks[0]);
return SDL_FALSE;
} else if (r == 64 &&
pInReport->header.unReportVersion == k_ValveInReportMsgVersion &&
pInReport->header.ucType == ID_CONTROLLER_DECK_STATE &&
pInReport->header.ucLength == 64) {
HIDAPI_DriverSteamDeck_HandleState(device, joystick, pInReport);
}
} while (r > 0);
return SDL_TRUE;
}
+58 -8
View File
@@ -332,12 +332,28 @@ typedef struct
static int ReadInput(SDL_DriverSwitch_Context *ctx)
{
int result;
/* Make sure we don't try to read at the same time a write is happening */
if (SDL_AtomicGet(&ctx->device->rumble_pending) > 0) {
return 0;
}
return SDL_hid_read_timeout(ctx->device->dev, ctx->m_rgucReadBuffer, sizeof(ctx->m_rgucReadBuffer), 0);
result = SDL_hid_read_timeout(ctx->device->dev, ctx->m_rgucReadBuffer, sizeof(ctx->m_rgucReadBuffer), 0);
/* See if we can guess the initial input mode */
if (result > 0 && !ctx->m_bInputOnly && !ctx->m_nInitialInputMode) {
switch (ctx->m_rgucReadBuffer[0]) {
case k_eSwitchInputReportIDs_FullControllerState:
case k_eSwitchInputReportIDs_FullControllerAndMcuState:
case k_eSwitchInputReportIDs_SimpleControllerState:
ctx->m_nInitialInputMode = ctx->m_rgucReadBuffer[0];
break;
default:
break;
}
}
return result;
}
static int WriteOutput(SDL_DriverSwitch_Context *ctx, const Uint8 *data, int size)
@@ -727,14 +743,12 @@ static void SDLCALL SDL_PlayerLEDHintChanged(void *userdata, const char *name, c
}
}
static Uint8 GetInitialInputMode(SDL_DriverSwitch_Context *ctx)
static void GetInitialInputMode(SDL_DriverSwitch_Context *ctx)
{
Uint8 input_mode = 0;
if (ReadInput(ctx) > 0) {
input_mode = ctx->m_rgucReadBuffer[0];
if (!ctx->m_nInitialInputMode) {
/* This will set the initial input mode if it can */
ReadInput(ctx);
}
return input_mode;
}
static Uint8 GetDefaultInputMode(SDL_DriverSwitch_Context *ctx)
@@ -758,7 +772,18 @@ 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
/* 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;
}
@@ -1292,6 +1317,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;
@@ -1380,7 +1426,7 @@ static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_
ctx->m_bSyncWrite = SDL_TRUE;
if (!ctx->m_bInputOnly) {
ctx->m_nInitialInputMode = GetInitialInputMode(ctx);
GetInitialInputMode(ctx);
ctx->m_nCurrentInputMode = ctx->m_nInitialInputMode;
/* Initialize rumble data */
@@ -2211,6 +2257,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 {
+12 -15
View File
@@ -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_type.c
/* 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
@@ -284,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 */
@@ -1011,7 +1008,7 @@ static void HIDAPI_DelDevice(SDL_HIDAPI_Device *device)
}
}
static SDL_bool HIDAPI_CreateCombinedJoyCons()
static SDL_bool HIDAPI_CreateCombinedJoyCons(void)
{
SDL_HIDAPI_Device *device, *combined;
SDL_HIDAPI_Device *joycons[2] = { NULL, NULL };
@@ -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
+63 -20
View File
@@ -273,7 +273,7 @@ static int GuessIsSensor(int fd)
return 0;
}
static int IsJoystick(const char *path, int fd, char **name_return, Uint16 *vendor_return, Uint16 *product_return, SDL_JoystickGUID *guid)
static int IsJoystick(const char *path, int *fd, char **name_return, Uint16 *vendor_return, Uint16 *product_return, SDL_JoystickGUID *guid)
{
struct input_id inpid;
char *name;
@@ -282,21 +282,32 @@ static int IsJoystick(const char *path, int fd, char **name_return, Uint16 *vend
SDL_zero(inpid);
#ifdef SDL_USE_LIBUDEV
SDL_UDEV_GetProductInfo(path, &inpid.vendor, &inpid.product, &inpid.version, &class);
/* Opening input devices can generate synchronous device I/O, so avoid it if we can */
if (SDL_UDEV_GetProductInfo(path, &inpid.vendor, &inpid.product, &inpid.version, &class) &&
!(class & SDL_UDEV_DEVICE_JOYSTICK)) {
return 0;
}
#endif
if (ioctl(fd, JSIOCGNAME(sizeof(product_string)), product_string) <= 0) {
/* When udev is enabled we only get joystick devices here, so there's no need to test them */
if (enumeration_method != ENUMERATION_LIBUDEV &&
!(class & SDL_UDEV_DEVICE_JOYSTICK) && ( class || !GuessIsJoystick(fd))) {
if (fd && *fd < 0) {
*fd = open(path, O_RDONLY | O_CLOEXEC, 0);
}
if (!fd || *fd < 0) {
return 0;
}
if (ioctl(*fd, JSIOCGNAME(sizeof(product_string)), product_string) <= 0) {
/* When udev enumeration or classification, we only got joysticks here, so no need to test */
if (enumeration_method != ENUMERATION_LIBUDEV && !class && !GuessIsJoystick(*fd)) {
return 0;
}
/* Could have vendor and product already from udev, but should agree with evdev */
if (ioctl(fd, EVIOCGID, &inpid) < 0) {
if (ioctl(*fd, EVIOCGID, &inpid) < 0) {
return 0;
}
if (ioctl(fd, EVIOCGNAME(sizeof(product_string)), product_string) < 0) {
if (ioctl(*fd, EVIOCGNAME(sizeof(product_string)), product_string) < 0) {
return 0;
}
}
@@ -315,7 +326,7 @@ static int IsJoystick(const char *path, int fd, char **name_return, Uint16 *vend
}
#endif
FixupDeviceInfoForMapping(fd, &inpid);
FixupDeviceInfoForMapping(*fd, &inpid);
#ifdef DEBUG_JOYSTICK
SDL_Log("Joystick: %s, bustype = %d, vendor = 0x%.4x, product = 0x%.4x, version = %d\n", name, inpid.bustype, inpid.vendor, inpid.product, inpid.version);
@@ -333,11 +344,32 @@ static int IsJoystick(const char *path, int fd, char **name_return, Uint16 *vend
return 1;
}
static int IsSensor(const char *path, int fd)
static int IsSensor(const char *path, int *fd)
{
struct input_id inpid;
int class = 0;
if (ioctl(fd, EVIOCGID, &inpid) < 0) {
SDL_zero(inpid);
#ifdef SDL_USE_LIBUDEV
/* Opening input devices can generate synchronous device I/O, so avoid it if we can */
if (SDL_UDEV_GetProductInfo(path, &inpid.vendor, &inpid.product, &inpid.version, &class) &&
!(class & SDL_UDEV_DEVICE_ACCELEROMETER)) {
return 0;
}
#endif
if (fd && *fd < 0) {
*fd = open(path, O_RDONLY | O_CLOEXEC, 0);
}
if (!fd || *fd < 0) {
return 0;
}
if (!class && !GuessIsSensor(*fd)) {
return 0;
}
if (ioctl(*fd, EVIOCGID, &inpid) < 0) {
return 0;
}
@@ -347,7 +379,7 @@ static int IsSensor(const char *path, int fd)
return 0;
}
return GuessIsSensor(fd);
return 1;
}
#ifdef SDL_USE_LIBUDEV
@@ -434,16 +466,11 @@ static void MaybeAddDevice(const char *path)
}
}
fd = open(path, O_RDONLY | O_CLOEXEC, 0);
if (fd < 0) {
goto done;
}
#ifdef DEBUG_INPUT_EVENTS
SDL_Log("Checking %s\n", path);
#endif
if (IsJoystick(path, fd, &name, &vendor, &product, &guid)) {
if (IsJoystick(path, &fd, &name, &vendor, &product, &guid)) {
#ifdef DEBUG_INPUT_EVENTS
SDL_Log("found joystick: %s\n", path);
#endif
@@ -484,7 +511,7 @@ static void MaybeAddDevice(const char *path)
goto done;
}
if (IsSensor(path, fd)) {
if (IsSensor(path, &fd)) {
#ifdef DEBUG_INPUT_EVENTS
SDL_Log("found sensor: %s\n", path);
#endif
@@ -880,11 +907,24 @@ static void LINUX_ScanSteamVirtualGamepads(void)
int num_virtual_gamepads = 0;
int virtual_gamepad_slot;
VirtualGamepadEntry *virtual_gamepads = NULL;
#ifdef SDL_USE_LIBUDEV
int class;
#endif
count = scandir("/dev/input", &entries, filter_entries, NULL);
for (i = 0; i < count; ++i) {
(void)SDL_snprintf(path, SDL_arraysize(path), "/dev/input/%s", entries[i]->d_name);
#ifdef SDL_USE_LIBUDEV
/* Opening input devices can generate synchronous device I/O, so avoid it if we can */
class = 0;
SDL_zero(inpid);
if (SDL_UDEV_GetProductInfo(path, &inpid.vendor, &inpid.product, &inpid.version, &class) &&
(inpid.vendor != USB_VENDOR_VALVE || inpid.product != USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD)) {
free(entries[i]); /* This should NOT be SDL_free() */
continue;
}
#endif
fd = open(path, O_RDONLY | O_CLOEXEC, 0);
if (fd >= 0) {
if (ioctl(fd, EVIOCGID, &inpid) == 0 &&
@@ -986,6 +1026,9 @@ static void LINUX_JoystickDetect(void)
static int LINUX_JoystickInit(void)
{
const char *devices = SDL_GetHint(SDL_HINT_JOYSTICK_DEVICE);
#ifdef SDL_USE_LIBUDEV
int udev_status = SDL_UDEV_Init();
#endif
SDL_classic_joysticks = SDL_GetHintBoolean(SDL_HINT_LINUX_JOYSTICK_CLASSIC, SDL_FALSE);
@@ -1036,7 +1079,7 @@ static int LINUX_JoystickInit(void)
}
if (enumeration_method == ENUMERATION_LIBUDEV) {
if (SDL_UDEV_Init() == 0) {
if (udev_status == 0) {
/* Set up the udev callback */
if (SDL_UDEV_AddCallback(joystick_udev_callback) < 0) {
SDL_UDEV_Quit();
+2 -2
View File
@@ -133,13 +133,13 @@ static int PS2_JoystickInit(void)
}
/* Function to return the number of joystick devices plugged in right now */
static int PS2_JoystickGetCount()
static int PS2_JoystickGetCount(void)
{
return (int)enabled_pads;
}
/* Function to cause any queued joystick insertions to be processed */
static void PS2_JoystickDetect()
static void PS2_JoystickDetect(void)
{
}
+3
View File
@@ -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;
}
+7
View File
@@ -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
@@ -47,11 +48,13 @@
#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
#define USB_VENDOR_THRUSTMASTER 0x044f
#define USB_VENDOR_TURTLE_BEACH 0x10f5
#define USB_VENDOR_SWITCH 0x2563
#define USB_VENDOR_VALVE 0x28de
#define USB_VENDOR_ZEROPLUS 0x0c12
@@ -90,6 +93,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
@@ -103,6 +107,8 @@
#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
#define USB_PRODUCT_SONY_DS4 0x05c4
@@ -111,6 +117,7 @@
#define USB_PRODUCT_SONY_DS4_STRIKEPAD 0x05c5
#define USB_PRODUCT_SONY_DS5 0x0ce6
#define USB_PRODUCT_SONY_DS5_EDGE 0x0df2
#define USB_PRODUCT_SWITCH_RETROBIT_CONTROLLER 0x0575
#define USB_PRODUCT_THRUSTMASTER_ESWAPX_PRO 0xd012
#define USB_PRODUCT_TURTLE_BEACH_SERIES_X_REACT_R 0x7013
#define USB_PRODUCT_TURTLE_BEACH_SERIES_X_RECON 0x7009
+2 -2
View File
@@ -145,12 +145,12 @@ int VITA_JoystickInit(void)
return SDL_numjoysticks;
}
int VITA_JoystickGetCount()
int VITA_JoystickGetCount(void)
{
return SDL_numjoysticks;
}
void VITA_JoystickDetect()
void VITA_JoystickDetect(void)
{
}
+15 -6
View File
@@ -331,7 +331,7 @@ static struct
static SDL_bool xinput_device_change = SDL_TRUE;
static SDL_bool xinput_state_dirty = SDL_TRUE;
static void RAWINPUT_UpdateXInput()
static void RAWINPUT_UpdateXInput(void)
{
DWORD user_index;
if (xinput_device_change) {
@@ -371,7 +371,7 @@ static void RAWINPUT_MarkXInputSlotFree(Uint8 xinput_slot)
xinput_state[xinput_slot].used = SDL_FALSE;
}
}
static SDL_bool RAWINPUT_MissingXInputSlot()
static SDL_bool RAWINPUT_MissingXInputSlot(void)
{
int ii;
for (ii = 0; ii < SDL_arraysize(xinput_state); ii++) {
@@ -556,7 +556,7 @@ static void RAWINPUT_MarkWindowsGamingInputSlotFree(WindowsGamingInputGamepadSta
wgi_slot->correlated_context = NULL;
}
static SDL_bool RAWINPUT_MissingWindowsGamingInputSlot()
static SDL_bool RAWINPUT_MissingWindowsGamingInputSlot(void)
{
int ii;
for (ii = 0; ii < wgi_state.per_gamepad_count; ii++) {
@@ -567,7 +567,7 @@ static SDL_bool RAWINPUT_MissingWindowsGamingInputSlot()
return SDL_FALSE;
}
static void RAWINPUT_UpdateWindowsGamingInput()
static void RAWINPUT_UpdateWindowsGamingInput(void)
{
int ii;
if (!wgi_state.gamepad_statics) {
@@ -1050,7 +1050,7 @@ static int RAWINPUT_JoystickGetCount(void)
return SDL_RAWINPUT_numjoysticks;
}
SDL_bool RAWINPUT_IsEnabled()
SDL_bool RAWINPUT_IsEnabled(void)
{
return SDL_RAWINPUT_inited && !SDL_RAWINPUT_remote_desktop;
}
@@ -1290,6 +1290,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
value_caps = SDL_stack_alloc(HIDP_VALUE_CAPS, caps.NumberInputValueCaps);
if (SDL_HidP_GetValueCaps(HidP_Input, value_caps, &caps.NumberInputValueCaps, ctx->preparsed_data) != HIDP_STATUS_SUCCESS) {
RAWINPUT_JoystickClose(joystick);
SDL_stack_free(button_caps);
return SDL_SetError("Couldn't get device value capabilities");
}
@@ -1318,6 +1319,8 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
ctx->button_indices = (USHORT *)SDL_malloc(joystick->nbuttons * sizeof(*ctx->button_indices));
if (!ctx->button_indices) {
RAWINPUT_JoystickClose(joystick);
SDL_stack_free(value_caps);
SDL_stack_free(button_caps);
return SDL_OutOfMemory();
}
@@ -1342,6 +1345,8 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
joystick->nbuttons += 1;
}
SDL_stack_free(button_caps);
for (i = 0; i < caps.NumberInputValueCaps; ++i) {
HIDP_VALUE_CAPS *cap = &value_caps[i];
@@ -1371,6 +1376,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
ctx->axis_indices = (USHORT *)SDL_malloc(joystick->naxes * sizeof(*ctx->axis_indices));
if (!ctx->axis_indices) {
RAWINPUT_JoystickClose(joystick);
SDL_stack_free(value_caps);
return SDL_OutOfMemory();
}
@@ -1404,6 +1410,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
ctx->hat_indices = (USHORT *)SDL_malloc(joystick->nhats * sizeof(*ctx->hat_indices));
if (!ctx->hat_indices) {
RAWINPUT_JoystickClose(joystick);
SDL_stack_free(value_caps);
return SDL_OutOfMemory();
}
@@ -1422,6 +1429,8 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
}
}
SDL_stack_free(value_caps);
joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
return 0;
@@ -2087,7 +2096,7 @@ int RAWINPUT_RegisterNotifications(HWND hWnd)
return 0;
}
int RAWINPUT_UnregisterNotifications()
int RAWINPUT_UnregisterNotifications(void)
{
int i;
RAWINPUTDEVICE rid[SDL_arraysize(subscribed_devices)];
@@ -216,7 +216,7 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product)
return SDL_FALSE;
}
static void WGI_LoadRawGameControllerStatics()
static void WGI_LoadRawGameControllerStatics(void)
{
WindowsCreateStringReference_t WindowsCreateStringReferenceFunc = NULL;
RoGetActivationFactory_t RoGetActivationFactoryFunc = NULL;
@@ -247,7 +247,7 @@ static void WGI_LoadRawGameControllerStatics()
}
}
static void WGI_LoadOtherControllerStatics()
static void WGI_LoadOtherControllerStatics(void)
{
WindowsCreateStringReference_t WindowsCreateStringReferenceFunc = NULL;
RoGetActivationFactory_t RoGetActivationFactoryFunc = NULL;
+3 -3
View File
@@ -377,7 +377,7 @@ static int SDLCALL SDL_JoystickThread(void *_data)
#ifdef SDL_JOYSTICK_XINPUT
/* WM_DEVICECHANGE not working, poll for new XINPUT controllers */
SDL_CondWaitTimeout(s_condJoystickThread, s_mutexJoyStickEnum, 1000);
if (SDL_XINPUT_Enabled() && XINPUTGETCAPABILITIES) {
if (SDL_XINPUT_Enabled()) {
/* scan for any change in XInput devices */
Uint8 userId;
for (userId = 0; userId < XUSER_MAX_COUNT; userId++) {
@@ -473,12 +473,12 @@ void WINDOWS_JoystickQuit(void);
*/
static int WINDOWS_JoystickInit(void)
{
if (SDL_DINPUT_JoystickInit() < 0) {
if (SDL_XINPUT_JoystickInit() < 0) {
WINDOWS_JoystickQuit();
return -1;
}
if (SDL_XINPUT_JoystickInit() < 0) {
if (SDL_DINPUT_JoystickInit() < 0) {
WINDOWS_JoystickQuit();
return -1;
}
+8 -5
View File
@@ -39,9 +39,9 @@ extern "C" {
/*
* Internal stuff.
*/
static SDL_bool s_bXInputEnabled = SDL_TRUE;
static SDL_bool s_bXInputEnabled = SDL_FALSE;
static SDL_bool SDL_XInputUseOldJoystickMapping()
static SDL_bool SDL_XInputUseOldJoystickMapping(void)
{
#ifdef __WINRT__
/* TODO: remove this __WINRT__ block, but only after integrating with UWP/WinRT's HID API */
@@ -65,11 +65,13 @@ SDL_bool SDL_XINPUT_Enabled(void)
int SDL_XINPUT_JoystickInit(void)
{
s_bXInputEnabled = SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE);
SDL_bool enabled = SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE);
if (s_bXInputEnabled && WIN_LoadXInputDLL() < 0) {
s_bXInputEnabled = SDL_FALSE; /* oh well. */
if (enabled && WIN_LoadXInputDLL() < 0) {
enabled = SDL_FALSE; /* oh well. */
}
s_bXInputEnabled = enabled;
return 0;
}
@@ -458,6 +460,7 @@ void SDL_XINPUT_JoystickClose(SDL_Joystick *joystick)
void SDL_XINPUT_JoystickQuit(void)
{
if (s_bXInputEnabled) {
s_bXInputEnabled = SDL_FALSE;
WIN_UnloadXInputDLL();
}
}
+4 -4
View File
@@ -23,7 +23,7 @@
#undef main
#endif
__attribute__((weak)) void reset_IOP()
__attribute__((weak)) void reset_IOP(void)
{
SifInitRpc(0);
while (!SifIopReset(NULL, 0)) {
@@ -32,7 +32,7 @@ __attribute__((weak)) void reset_IOP()
}
}
static void prepare_IOP()
static void prepare_IOP(void)
{
reset_IOP();
SifInitRpc(0);
@@ -41,12 +41,12 @@ static void prepare_IOP()
sbv_patch_fileio();
}
static void init_drivers()
static void init_drivers(void)
{
init_ps2_filesystem_driver();
}
static void deinit_drivers()
static void deinit_drivers(void)
{
deinit_ps2_filesystem_driver();
}
+4 -4
View File
@@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,30,2,0
PRODUCTVERSION 2,30,2,0
FILEVERSION 2,30,8,0
PRODUCTVERSION 2,30,8,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x40004L
@@ -23,12 +23,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "SDL\0"
VALUE "FileVersion", "2, 30, 2, 0\0"
VALUE "FileVersion", "2, 30, 8, 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, 2, 0\0"
VALUE "ProductVersion", "2, 30, 8, 0\0"
END
END
BLOCK "VarFileInfo"
+6 -1
View File
@@ -1610,7 +1610,12 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, Uint32 flags)
renderer->driverdata = data;
SDL_VERSION(&windowinfo.version);
SDL_GetWindowWMInfo(window, &windowinfo);
if (!SDL_GetWindowWMInfo(window, &windowinfo) ||
windowinfo.subsystem != SDL_SYSWM_WINDOWS) {
SDL_free(data);
SDL_SetError("Couldn't get window handle");
return NULL;
}
window_flags = SDL_GetWindowFlags(window);
SDL_GetWindowSizeInPixels(window, &w, &h);
+6 -1
View File
@@ -813,7 +813,12 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
#if defined(__WIN32__) || defined(__WINGDK__)
SDL_SysWMinfo windowinfo;
SDL_VERSION(&windowinfo.version);
SDL_GetWindowWMInfo(renderer->window, &windowinfo);
if (!SDL_GetWindowWMInfo(renderer->window, &windowinfo) ||
windowinfo.subsystem != SDL_SYSWM_WINDOWS) {
SDL_SetError("Couldn't get window handle");
result = E_FAIL;
goto done;
}
result = IDXGIFactory2_CreateSwapChainForHwnd(data->dxgiFactory,
(IUnknown *)data->d3dDevice,
+68 -14
View File
@@ -48,6 +48,7 @@
#include <dxgi1_6.h>
#include <dxgidebug.h>
#include <d3d12sdklayers.h>
#include <sdkddkver.h>
#endif
#include "SDL_shaders_d3d12.h"
@@ -58,6 +59,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) { \
@@ -78,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" {
@@ -393,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;
@@ -427,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;
}
@@ -1047,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;
@@ -1336,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);
}
@@ -1550,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,
@@ -1559,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,
@@ -1567,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,
@@ -1581,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,
@@ -1598,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,
@@ -1663,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;
@@ -1919,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;
@@ -2028,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;
@@ -2739,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;
+1 -1
View File
@@ -55,7 +55,7 @@ typedef struct
static int vsync_sema_id = 0;
/* PRIVATE METHODS */
static int vsync_handler()
static int vsync_handler(void)
{
iSignalSema(vsync_sema_id);
+1 -1
View File
@@ -161,7 +161,7 @@ static void SDL_ANDROID_SensorUpdate(SDL_Sensor *sensor)
ASensorEvent event;
struct android_poll_source *source;
if (ALooper_pollAll(0, NULL, &events, (void **)&source) == LOOPER_ID_USER) {
if (ALooper_pollOnce(0, NULL, &events, (void **)&source) == LOOPER_ID_USER) {
SDL_zero(event);
while (ASensorEventQueue_getEvents(sensor->hwdata->eventqueue, &event, 1) > 0) {
SDL_PrivateSensorUpdate(sensor, 0, event.data, SDL_arraysize(event.data));
+3 -2
View File
@@ -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;
}
+1 -1
View File
@@ -4472,7 +4472,7 @@ struct mallinfo dlmallinfo(void) {
}
#endif /* NO_MALLINFO */
void dlmalloc_stats() {
void dlmalloc_stats(void) {
internal_malloc_stats(gm);
}
+27 -20
View File
@@ -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;
@@ -65,7 +65,7 @@ void SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void
/*
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 <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#undef DEBUG_QSORT
static char _ID[]="<qsort.c gjm 1.15 2016-03-10>";
static char _ID[]="<qsort.c gjm 1.16 2021-02-20>";
#endif
/* END SDL CHANGE ... commented this out with an #if 0 block. --ryan. */
@@ -168,7 +174,8 @@ static char _ID[]="<qsort.c gjm 1.15 2016-03-10>";
#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 \
}
@@ -368,7 +376,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 +417,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 +448,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 +479,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,10 +531,10 @@ 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))
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);
@@ -536,7 +544,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 +577,3 @@ void *SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size,
}
/* vi: set ts=4 sw=4 expandtab: */
+17 -9
View File
@@ -1529,7 +1529,7 @@ typedef enum
typedef struct
{
SDL_bool left_justify; /* for now: ignored. */
SDL_bool left_justify;
SDL_bool force_sign;
SDL_bool force_type; /* for now: used only by float printer, ignored otherwise. */
SDL_bool pad_zeroes;
@@ -1541,6 +1541,9 @@ typedef struct
static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string)
{
const char fill = (info && info->pad_zeroes) ? '0' : ' ';
size_t width = 0;
size_t filllen = 0;
size_t length = 0;
size_t slen, sz;
@@ -1550,24 +1553,29 @@ static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, c
sz = SDL_strlen(string);
if (info && info->width > 0 && (size_t)info->width > sz) {
const char fill = info->pad_zeroes ? '0' : ' ';
size_t width = info->width - sz;
size_t filllen;
width = info->width - sz;
if (info->precision >= 0 && (size_t)info->precision < sz) {
width += sz - (size_t)info->precision;
}
filllen = SDL_min(width, maxlen);
SDL_memset(text, fill, filllen);
text += filllen;
maxlen -= filllen;
length += width;
if (!info->left_justify) {
SDL_memset(text, fill, filllen);
text += filllen;
maxlen -= filllen;
length += width;
filllen = 0;
}
}
SDL_strlcpy(text, string, maxlen);
length += sz;
if (filllen > 0) {
SDL_memset(text + sz, fill, filllen);
length += width;
}
if (info) {
if (info->precision >= 0 && (size_t)info->precision < sz) {
slen = (size_t)info->precision;
Loaded 100 of 196 files, more files were not shown because too many files have changed in this diff. Show more