Compare commits

..
Author SHA1 Message Date
Sam Lantinga c98c4fbff6 Updated to version 2.30.9 for release 2024-11-01 14:24:51 -07:00
Sam Lantinga 4d4f004968 Fixed the PS5 controller face buttons on Amazon Fire TV, Android 11
(cherry picked from commit 09495059df)
(cherry picked from commit 3b7a45853c)
2024-10-30 05:24:08 -07:00
Sam Lantinga 5d7a023430 Revert "aaudio: Set low-latency audio mode."
This reverts commit 1e016fd5ea.

In order to use low latency mode, you need to set low latency callbacks. This has always been recommended and is apparently required on Android 15. SDL3 has these implemented correctly but SDL2 does not, so we should revert this for now.

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

(cherry picked from commit d2b9ecd281)
2024-10-29 22:36:54 -07:00
dv-senna 3e272e73d6 SDL_vulkan.h: undefine VK_DEFINE_HANDLER and VK_DEFINE_NON_DISPATCHABLE_HANDLE
Allows including vulkan.hpp in user code in C++ before SDL_vulkan.h w/o errors.
Fixes:  https://github.com/libsdl-org/SDL/issues/11328 .

(cherry picked from commit 149ecffd6f)
(cherry picked from commit 478dff3585)
2024-10-29 22:36:24 -07:00
Ryan C. Gordon cc2352f842 wasapi: Deal with device buffer sizes changing.
Otherwise, it would fill the previous size's worth of data into the current
size's buffer.

Fixes #11122.

(cherry picked from commit 5b0e838a74)
2024-10-29 22:36:19 -07:00
Ryan C. Gordon f170ced2a7 cocoa: Patched to compile.
(cherry picked from commit e5348c611d)
2024-10-25 10:23:36 -04:00
Ryan C. Gordon dcdb763de8 cocoa: Make sure GL context destruction happens on the main thread.
Fixes #10900.

(cherry picked from commit 5cb87ff99f)
2024-10-25 10:17:47 -04:00
Ryan C. Gordon 5c9f37080e emscripten: scale mousewheel X coordinates correctly, not just Y coordinates.
Fixes #10454.

(cherry picked from commit 00f15dd215)
2024-10-23 23:41:10 -04:00
Ivan Epifanov 257d75429d VITA: fix SDL_ShowMessageBox by using different memory type
(cherry picked from commit 52714d5063)
2024-10-22 12:22:20 -07:00
Frank Praznik c1adfb4c94 wayland: Always create a viewport for the window if available
Viewports decouple the buffer from the window size and avoids the window geometry hacks used to prevent problems if a buffer with an old size in the pipeline ends up being committed.

Fixes an invalid geometry warning and incorrect overview size for fullscreen windows on GNOME, and avoids flicker when entering/exiting fullscreen or moving the window between scaled and non-scaled displays.

(cherry picked from commit 849c905d8c)
2024-10-21 15:22:24 -04:00
Ivan Epifanov 217bc17a21 VITA: fix yuv texture update
(cherry picked from commit 86fd4ed83c)
2024-10-17 07:54:41 -07:00
Sam Lantinga 7107e02315 Only use Steam Virtual Gamepads if we're running under Steam
Fixes https://github.com/libsdl-org/SDL/issues/11214
Fixes https://github.com/libsdl-org/SDL/issues/11215

(cherry picked from commit 8a30def5f2)
(cherry picked from commit b6fa4dc794)
2024-10-16 17:53:01 -07:00
Sam Lantinga 062a777240 Added support for the Steam Virtual Gamepad on macOS Sequoia
(cherry picked from commit d7b1ba1bfc)
(cherry picked from commit cfb3db01dc)
2024-10-16 17:53:01 -07:00
Pierre Wendling 1842745c9c VisualC: Set the correct component to false.
When SDL2_main would not be found, it would incorrectly flag the shared SDL2 library as not found.

(cherry picked from commit 378234437f)
2024-10-13 09:03:22 -07:00
Cameron Cawley bbcc9421d6 3DS: Support simple message boxes
(cherry picked from commit 23d456e146)
2024-10-13 09:03:22 -07:00
Cameron Cawley b58a1c7f33 3DS: Only bundle resources with tests that need them
(cherry picked from commit d7bb56f163)
2024-10-13 09:03:22 -07:00
Cameron Cawley 79a8f7b3a0 Reduce the size of the SDL_blit_0 alpha code
(cherry picked from commit 90f792f83c)
2024-10-13 09:03:22 -07:00
Cameron Cawley 302ab09178 testdrawchessboard: Allow using the standard render API
(cherry picked from commit e2f27362cb)
2024-10-13 09:03:22 -07:00
Guldoman e1e38e2250 x11: Set correct clipboard target type in SelectionRequest handling
(cherry picked from commit 5fe010270a)
2024-10-13 09:02:49 -07:00
Sam Lantinga 2638809c50 Fixed typo in SDL_audio.h
(cherry picked from commit da4608ed03)
2024-10-10 08:50:19 -07:00
Sam Clegg 36853f923e [emscripten] Fixes for data addresses above 2gb
This includes both wasm64 and wasm32 when addressing more than 2gb of
memory.

Fixes: #9052
(cherry picked from commit 3deb07ea39)
2024-10-08 15:17:44 -07:00
Sam Lantinga 63aff8e3d0 Added support for wired XBox controllers on macOS 15.0 Sequoia
Fixes https://github.com/libsdl-org/SDL/issues/11002

(cherry picked from commit 7da728a642)
(cherry picked from commit da19244f7f)
2024-10-07 16:41:47 -07:00
Sam Lantinga 7eebc2ad4d Fixed detecting the Steam Virtual Gamepad on macOS
(cherry picked from commit bb33eb409e)
2024-10-07 16:22:03 -07:00
Frank Praznik 0f695adb03 Reapply "wayland: Don't initialize OpenGL when the window flags didn't specify it"
This reverts commit 120b8d4189.

The issue this was patching over in Vanilla-Conquer was the lack of an exposure event when showing a window, which has since been remedied.

Attaching EGL window objects can also cause protocol violations now that the explicit sync protocol is in use, if SDL creates one and then the client tries to attach one itself, so they really shouldn't be created unless the client specifically requested it.

(cherry picked from commit 643437f5b0)
2024-10-02 13:52:59 -04:00
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
193 changed files with 2452 additions and 889 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
+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.*
+18 -9
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 5)
set(SDL_MICRO_VERSION 9)
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
# Set defaults preventing destination file conflicts
@@ -1777,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)
@@ -3527,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
@@ -15,7 +15,7 @@
LIBNAME = SDL2
MAJOR_VERSION = 2
MINOR_VERSION = 30
MICRO_VERSION = 5
MICRO_VERSION = 9
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 = 5
MICRO_VERSION = 9
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
LIBHOME = .
-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>
+4 -2
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)
@@ -92,7 +94,7 @@ if(EXISTS "${_sdl2main_library}")
endif()
set(SDL2_SDL2main_FOUND TRUE)
else()
set(SDL2_SDL2_FOUND FALSE)
set(SDL2_SDL2main_FOUND FALSE)
endif()
unset(_sdl2main_library)
@@ -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.5</string>
<string>2.30.9</string>
<key>CFBundleSignature</key>
<string>SDLX</string>
<key>CFBundleVersion</key>
<string>2.30.5</string>
<string>2.30.9</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.5.0;
DYLIB_CURRENT_VERSION = 3001.9.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.5;
MARKETING_VERSION = 2.30.9;
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.5.0;
DYLIB_CURRENT_VERSION = 3001.9.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.5;
MARKETING_VERSION = 2.30.9;
OTHER_LDFLAGS = "-liconv";
};
name = Debug;
@@ -10063,7 +10063,7 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 3001.0.0;
DYLIB_CURRENT_VERSION = 3001.5.0;
DYLIB_CURRENT_VERSION = 3001.9.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.5.0;
DYLIB_CURRENT_VERSION = 3001.9.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.5
Title SDL 2.30.9
Version 1
Description SDL Library for Mac OS X (http://www.libsdl.org)
DefaultLocation /Library/Frameworks
@@ -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 = 5;
private static final int SDL_MICRO_VERSION = 9;
/*
// 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);
}
+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
+1 -1
View File
@@ -3508,7 +3508,7 @@ orig_CFLAGS="$CFLAGS"
# See docs/release_checklist.md
SDL_MAJOR_VERSION=2
SDL_MINOR_VERSION=30
SDL_MICRO_VERSION=5
SDL_MICRO_VERSION=9
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
+1 -1
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=5
SDL_MICRO_VERSION=9
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
+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.
+1 -1
View File
@@ -594,7 +594,7 @@ extern DECLSPEC int SDLCALL SDL_GetDefaultAudioInfo(char **name,
* frames_ (with stereo output, two samples--left and right--would make a
* single sample frame). This number should be a power of two, and may be
* adjusted by the audio driver to a value more suitable for the hardware.
* Good values seem to range between 512 and 8096 inclusive, depending on
* Good values seem to range between 512 and 4096 inclusive, depending on
* the application and CPU speed. Smaller values reduce latency, but can
* lead to underflow if the application is doing heavy processing and cannot
* fill the audio buffer in time. Note that the number of sample frames is
+1
View File
@@ -1912,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)
*/
+4 -1
View File
@@ -257,7 +257,7 @@ typedef uint64_t Uint64;
#define SDL_PRIs64 "I64d"
#elif defined(PRIs64)
#define SDL_PRIs64 PRIs64
#elif defined(__LP64__) && !defined(__APPLE__)
#elif defined(__LP64__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__)
#define SDL_PRIs64 "ld"
#else
#define SDL_PRIs64 "lld"
@@ -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 5
#define SDL_PATCHLEVEL 9
/**
* Macro to determine SDL version program was compiled against.
+4
View File
@@ -52,6 +52,10 @@ extern "C" {
VK_DEFINE_HANDLE(VkInstance)
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR)
/* Make sure to undef to avoid issues in case of later vulkan include */
#undef VK_DEFINE_HANDLE
#undef VK_DEFINE_NON_DISPATCHABLE_HANDLE
#endif /* !NO_SDL_VULKAN_TYPEDEFS */
typedef VkInstance SDL_vulkanInstance;
+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;
}
+3 -1
View File
@@ -292,7 +292,7 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data,
break;
}
}
#elif defined(HAVE_STDIO_H)
#elif defined(HAVE_STDIO_H) && !defined(__3DS__)
/* this is a little hacky. */
for (;;) {
char buf[32];
@@ -319,6 +319,8 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data,
break;
}
}
#else
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Assertion Failed", message, window);
#endif /* HAVE_STDIO_H */
}
+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
View File
@@ -116,7 +116,6 @@ static int aaudio_OpenDevice(_THIS, const char *devname)
}
ctx.AAudioStreamBuilder_setErrorCallback(ctx.builder, aaudio_errorCallback, private);
ctx.AAudioStreamBuilder_setPerformanceMode(ctx.builder, AAUDIO_PERFORMANCE_MODE_LOW_LATENCY);
LOGI("AAudio Try to open %u hz %u bit chan %u %s samples %u",
this->spec.freq, SDL_AUDIO_BITSIZE(this->spec.format),
@@ -239,7 +238,6 @@ static int RebuildAAudioStream(SDL_AudioDevice *device)
}
ctx.AAudioStreamBuilder_setErrorCallback(ctx.builder, aaudio_errorCallback, hidden);
ctx.AAudioStreamBuilder_setPerformanceMode(ctx.builder, AAUDIO_PERFORMANCE_MODE_LOW_LATENCY);
LOGI("AAudio Try to reopen %u hz %u bit chan %u %s samples %u",
device->spec.freq, SDL_AUDIO_BITSIZE(device->spec.format),
+1 -1
View File
@@ -32,7 +32,7 @@ SDL_PROC(void, AAudioStreamBuilder_setFormat, (AAudioStreamBuilder * builder, aa
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setSharingMode, (AAudioStreamBuilder * builder, aaudio_sharing_mode_t sharingMode))
SDL_PROC(void, AAudioStreamBuilder_setDirection, (AAudioStreamBuilder * builder, aaudio_direction_t direction))
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setBufferCapacityInFrames, (AAudioStreamBuilder * builder, int32_t numFrames))
SDL_PROC(void, AAudioStreamBuilder_setPerformanceMode, (AAudioStreamBuilder * builder, aaudio_performance_mode_t mode))
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setPerformanceMode, (AAudioStreamBuilder * builder, aaudio_performance_mode_t mode))
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setUsage, (AAudioStreamBuilder * builder, aaudio_usage_t usage)) /* API 28 */
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setContentType, (AAudioStreamBuilder * builder, aaudio_content_type_t contentType)) /* API 28 */
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setInputPreset, (AAudioStreamBuilder * builder, aaudio_input_preset_t inputPreset)) /* API 28 */
+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;
}
+7 -1
View File
@@ -39,6 +39,12 @@ static void FeedAudioDevice(_THIS, const void *buf, const int buflen)
/* *INDENT-OFF* */ /* clang-format off */
MAIN_THREAD_EM_ASM({
var SDL2 = Module['SDL2'];
/* Convert incoming buf pointer to a HEAPF32 offset. */
#ifdef __wasm64__
var buf = $0 / 4;
#else
var buf = $0 >>> 2;
#endif
var numChannels = SDL2.audio.currentOutputBuffer['numberOfChannels'];
for (var c = 0; c < numChannels; ++c) {
var channelData = SDL2.audio.currentOutputBuffer['getChannelData'](c);
@@ -47,7 +53,7 @@ static void FeedAudioDevice(_THIS, const void *buf, const int buflen)
}
for (var j = 0; j < $1; ++j) {
channelData[j] = HEAPF32[$0 + ((j*numChannels + c) << 2) >> 2]; /* !!! FIXME: why are these shifts here? */
channelData[j] = HEAPF32[buf + (j*numChannels + c)];
}
}
}, buf, buflen / framelen);
+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);
}
+6
View File
@@ -111,6 +111,12 @@ static int UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec)
}
}
/* if the device sample size changed, make sure we're asking for enough data. */
if (this->callbackspec.samples != this->spec.samples) {
this->callbackspec.samples = this->spec.samples;
SDL_CalculateAudioSpec(&this->callbackspec);
}
/* make sure our scratch buffer can cover the new device spec. */
if (this->spec.size > this->work_buffer_len) {
Uint8 *ptr = (Uint8 *)SDL_realloc(this->work_buffer, this->spec.size);
+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;
+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 -3
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) {
+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());
+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 -2
View File
@@ -906,9 +906,9 @@ IsInWhitelist(Uint16 vendor, Uint16 product)
}
#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND
static const SDL_bool use_libusb_whitelist_default = SDL_TRUE;
#define use_libusb_whitelist_default SDL_TRUE
#else
static const SDL_bool use_libusb_whitelist_default = SDL_FALSE;
#define use_libusb_whitelist_default SDL_FALSE
#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND */
static SDL_bool use_libusb_whitelist = use_libusb_whitelist_default;
+2 -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++) {
+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) {
+2 -20
View File
@@ -2123,28 +2123,10 @@ SDL_bool SDL_ShouldIgnoreGameController(const char *name, SDL_JoystickGUID guid)
return SDL_TRUE;
}
if (SDL_allowed_controllers.num_included_entries == 0 &&
SDL_ignored_controllers.num_included_entries == 0) {
return SDL_FALSE;
}
SDL_GetJoystickGUIDInfo(guid, &vendor, &product, &version, NULL);
if (SDL_GetHintBoolean("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD", SDL_FALSE)) {
/* We shouldn't ignore Steam's virtual gamepad since it's using the hints to filter out the real controllers so it can remap input for the virtual controller */
/* https://partner.steamgames.com/doc/features/steam_controller/steam_input_gamepad_emulation_bestpractices */
SDL_bool bSteamVirtualGamepad = SDL_FALSE;
#if defined(__LINUX__)
bSteamVirtualGamepad = (vendor == USB_VENDOR_VALVE && product == USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD);
#elif defined(__MACOSX__)
bSteamVirtualGamepad = (vendor == USB_VENDOR_MICROSOFT && product == USB_PRODUCT_XBOX360_WIRED_CONTROLLER && version == 1);
#elif defined(__WIN32__)
/* We can't tell on Windows, but Steam will block others in input hooks */
bSteamVirtualGamepad = SDL_TRUE;
#endif
if (bSteamVirtualGamepad) {
return SDL_FALSE;
}
if (SDL_IsJoystickSteamVirtualGamepad(vendor, product, version)) {
return !SDL_GetHintBoolean("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD", SDL_FALSE);
}
if (SDL_allowed_controllers.num_included_entries > 0) {
+3 -2
View File
@@ -324,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,",
@@ -772,8 +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,",
"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,",
"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,",
@@ -924,7 +925,7 @@ static const char *s_ControllerMappings[] = {
"050000004c050000c4050000ffff3f00,PS4 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
"050000004c050000cc090000fffe3f80,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:a3,rightx:a4,righty:a5,start:b16,x:b0,y:b2,",
"050000004c050000cc090000ffff3f00,PS4 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
"050000004c050000e60c0000fffe3f80,PS5 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:a3,rightx:a4,righty:a5,start:b16,x:b0,y:b2,",
"050000004c050000e60c0000fffe3f80,PS5 Controller,a:b0,b:b1,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:a3,rightx:a4,righty:a5,start:b16,x:b2,y:b17,",
"050000004c050000e60c0000ffff3f00,PS5 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
"05000000f8270000bf0b0000ffff3f00,Razer Kishi,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
"050000003215000005070000ffff3f00,Razer Raiju Mobile,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
+26 -9
View File
@@ -370,6 +370,7 @@ 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) */
@@ -394,7 +395,8 @@ static Uint32 initial_wheel_devices[] = {
MAKE_VIDPID(0x2433, 0xf301), /* Asetek SimSports Forte Wheelbase */
MAKE_VIDPID(0x2433, 0xf303), /* Asetek SimSports La Prima Wheelbase */
MAKE_VIDPID(0x2433, 0xf306), /* Asetek SimSports Tony Kannan Wheelbase */
MAKE_VIDPID(0x3416, 0x0301), /* Cammus C5 Wheelbase */
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 */
@@ -1412,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;
}
}
@@ -2177,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();
@@ -2835,6 +2843,15 @@ SDL_bool SDL_IsJoystickNintendoSwitchJoyConPair(Uint16 vendor_id, Uint16 product
return vendor_id == USB_VENDOR_NINTENDO && product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_PAIR;
}
SDL_bool SDL_IsJoystickSteamVirtualGamepad(Uint16 vendor_id, Uint16 product_id, Uint16 version)
{
#ifdef __MACOSX__
return (vendor_id == USB_VENDOR_MICROSOFT && product_id == USB_PRODUCT_XBOX360_WIRED_CONTROLLER && version == 0);
#else
return (vendor_id == USB_VENDOR_VALVE && product_id == USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD);
#endif
}
SDL_bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id)
{
EControllerType eType = GuessControllerType(vendor_id, product_id);
+3
View File
@@ -123,6 +123,9 @@ extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConRight(Uint16 vendor_id, Uint16
extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConGrip(Uint16 vendor_id, Uint16 product_id);
extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConPair(Uint16 vendor_id, Uint16 product_id);
/* Function to return whether a joystick is a Steam Virtual Gamepad */
extern SDL_bool SDL_IsJoystickSteamVirtualGamepad(Uint16 vendor_id, Uint16 product_id, Uint16 version);
/* Function to return whether a joystick is a Steam Controller */
extern SDL_bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id);
+1 -1
View File
@@ -69,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
+5
View File
@@ -477,6 +477,11 @@ static SDL_bool GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice)
CFNumberGetValue(refCF, kCFNumberSInt32Type, &version);
}
if (SDL_IsJoystickXboxOne(vendor, product)) {
/* We can't actually use this API for Xbox controllers */
return false;
}
/* get device name */
refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDManufacturerKey));
if ((!refCF) || (!CFStringGetCString(refCF, manufacturer_string, sizeof(manufacturer_string), kCFStringEncodingUTF8))) {
+35 -8
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 */
@@ -617,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;
@@ -650,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;
}
@@ -762,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 */
@@ -871,9 +890,17 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket19(SDL_Joystick *joystic
}
}
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);
@@ -885,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 */
+1
View File
@@ -1500,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;
}
+22 -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)
@@ -1412,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 */
+15 -38
View File
@@ -84,21 +84,16 @@ static SDL_bool HIDAPI_DriverXbox360_IsSupportedDevice(SDL_HIDAPI_Device *device
/* This is the chatpad or other input interface, not the Xbox 360 interface */
return SDL_FALSE;
}
#ifdef __MACOSX__
if (vendor_id == USB_VENDOR_MICROSOFT && product_id == USB_PRODUCT_XBOX360_WIRED_CONTROLLER && version == 1) {
/* This is the Steam Virtual Gamepad, which isn't supported by this driver */
#if defined(__MACOSX__) && defined(SDL_JOYSTICK_MFI)
if (SDL_IsJoystickSteamVirtualGamepad(vendor_id, product_id, version)) {
/* GCController support doesn't work with the Steam Virtual Gamepad */
return SDL_TRUE;
} else {
/* On macOS you can't write output reports to wired XBox controllers,
so we'll just use the GCController support instead.
*/
return SDL_FALSE;
}
/* Wired Xbox One controllers are handled by this driver, interfacing with
the 360Controller driver available from:
https://github.com/360Controller/360Controller/releases
Bluetooth Xbox One controllers are handled by the SDL Xbox One driver
*/
if (SDL_IsJoystickBluetoothXboxOne(vendor_id, product_id)) {
return SDL_FALSE;
}
return (type == SDL_CONTROLLER_TYPE_XBOX360 || type == SDL_CONTROLLER_TYPE_XBOXONE) ? SDL_TRUE : SDL_FALSE;
#else
return (type == SDL_CONTROLLER_TYPE_XBOX360) ? SDL_TRUE : SDL_FALSE;
#endif
@@ -153,6 +148,13 @@ static SDL_bool HIDAPI_DriverXbox360_InitDevice(SDL_HIDAPI_Device *device)
device->type = SDL_CONTROLLER_TYPE_XBOX360;
if (SDL_IsJoystickSteamVirtualGamepad(device->vendor_id, device->product_id, device->version) &&
device->product_string && SDL_strncmp(device->product_string, "GamePad-", 8) == 0) {
int slot = 0;
SDL_sscanf(device->product_string, "GamePad-%d", &slot);
device->steam_virtual_gamepad_slot = (slot - 1);
}
return HIDAPI_JoystickConnected(device, NULL);
}
@@ -201,30 +203,6 @@ static SDL_bool HIDAPI_DriverXbox360_OpenJoystick(SDL_HIDAPI_Device *device, SDL
static int HIDAPI_DriverXbox360_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
{
#ifdef __MACOSX__
if (SDL_IsJoystickBluetoothXboxOne(device->vendor_id, device->product_id)) {
Uint8 rumble_packet[] = { 0x03, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00 };
rumble_packet[4] = (low_frequency_rumble >> 8);
rumble_packet[5] = (high_frequency_rumble >> 8);
if (SDL_HIDAPI_SendRumble(device, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) {
return SDL_SetError("Couldn't send rumble packet");
}
} else {
/* On Mac OS X the 360Controller driver uses this short report,
and we need to prefix it with a magic token so hidapi passes it through untouched
*/
Uint8 rumble_packet[] = { 'M', 'A', 'G', 'I', 'C', '0', 0x00, 0x04, 0x00, 0x00 };
rumble_packet[6 + 2] = (low_frequency_rumble >> 8);
rumble_packet[6 + 3] = (high_frequency_rumble >> 8);
if (SDL_HIDAPI_SendRumble(device, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) {
return SDL_SetError("Couldn't send rumble packet");
}
}
#else
Uint8 rumble_packet[] = { 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
rumble_packet[3] = (low_frequency_rumble >> 8);
@@ -233,7 +211,6 @@ static int HIDAPI_DriverXbox360_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Jo
if (SDL_HIDAPI_SendRumble(device, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) {
return SDL_SetError("Couldn't send rumble packet");
}
#endif
return 0;
}
+5 -2
View File
@@ -354,9 +354,12 @@ static SDL_bool HIDAPI_DriverXboxOne_IsEnabled(void)
static SDL_bool HIDAPI_DriverXboxOne_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)
{
#ifdef __MACOSX__
/* Wired Xbox One controllers are handled by the 360Controller driver */
#if defined(__MACOSX__) && defined(SDL_JOYSTICK_MFI)
if (!SDL_IsJoystickBluetoothXboxOne(vendor_id, product_id)) {
/* On macOS we get a shortened version of the real report and
you can't write output reports for wired controllers, so
we'll just use the GCController support instead.
*/
return SDL_FALSE;
}
#endif
+8 -1
View File
@@ -929,6 +929,7 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf
device->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, device->vendor_id, device->product_id, device->version, device->manufacturer_string, device->product_string, 'h', 0);
device->joystick_type = SDL_JOYSTICK_TYPE_GAMECONTROLLER;
device->type = SDL_GetJoystickGameControllerProtocol(device->name, device->vendor_id, device->product_id, device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol);
device->steam_virtual_gamepad_slot = -1;
if (num_children > 0) {
int i;
@@ -1008,7 +1009,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 };
@@ -1380,6 +1381,12 @@ static const char *HIDAPI_JoystickGetDevicePath(int device_index)
static int HIDAPI_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index)
{
SDL_HIDAPI_Device *device;
device = HIDAPI_GetDeviceByIndex(device_index, NULL);
if (device) {
return device->steam_virtual_gamepad_slot;
}
return -1;
}
@@ -83,6 +83,7 @@ typedef struct _SDL_HIDAPI_Device
SDL_bool is_bluetooth;
SDL_JoystickType joystick_type;
SDL_GameControllerType type;
int steam_virtual_gamepad_slot;
struct _SDL_HIDAPI_DeviceDriver *driver;
void *context;
+7 -2
View File
@@ -406,7 +406,8 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
device->is_switch_joyconL = IsControllerSwitchJoyConL(controller);
device->is_switch_joyconR = IsControllerSwitchJoyConR(controller);
#ifdef SDL_JOYSTICK_HIDAPI
if ((device->is_xbox && HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_XBOXONE)) ||
if ((device->is_xbox && (HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_XBOXONE) ||
HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_XBOX360))) ||
(device->is_ps4 && HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_PS4)) ||
(device->is_ps5 && HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_PS5)) ||
(device->is_switch_pro && HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO)) ||
@@ -418,6 +419,10 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
return FALSE;
}
#endif
if (device->is_xbox && SDL_strncmp(name, "GamePad-", 8) == 0) {
/* This is a Steam Virtual Gamepad, which isn't supported by GCController */
return FALSE;
}
CheckControllerSiriRemote(controller, &device->is_siri_remote);
if (device->is_siri_remote && !SDL_GetHintBoolean(SDL_HINT_TV_REMOTE_AS_JOYSTICK, SDL_TRUE)) {
@@ -437,7 +442,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
device->has_xbox_share_button = TRUE;
}
}
#endif // ENABLE_PHYSICAL_INPUT_PROFILE
#endif /* ENABLE_PHYSICAL_INPUT_PROFILE */
if (device->is_backbone_one) {
vendor = USB_VENDOR_BACKBONE;
+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)
{
}
+2
View File
@@ -54,6 +54,7 @@
#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
@@ -116,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;
}
+7 -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;
}
+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,5,0
PRODUCTVERSION 2,30,5,0
FILEVERSION 2,30,9,0
PRODUCTVERSION 2,30,9,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x40004L
@@ -23,12 +23,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "SDL\0"
VALUE "FileVersion", "2, 30, 5, 0\0"
VALUE "FileVersion", "2, 30, 9, 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, 5, 0\0"
VALUE "ProductVersion", "2, 30, 9, 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,
+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);
+2
View File
@@ -366,6 +366,7 @@ static int VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
length = rect->w * SDL_BYTESPERPIXEL(texture->format);
if (length == pitch && length == dpitch) {
SDL_memcpy(dst, pixels, length * rect->h);
pixels += pitch * rect->h;
} else {
for (row = 0; row < rect->h; ++row) {
SDL_memcpy(dst, pixels, length);
@@ -393,6 +394,7 @@ static int VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
// U plane
if (length == uv_src_pitch && length == uv_pitch) {
SDL_memcpy(Udst, pixels, length * UVrect.h);
pixels += uv_src_pitch * UVrect.h;
} else {
for (row = 0; row < UVrect.h; ++row) {
SDL_memcpy(Udst, pixels, length);
@@ -31,6 +31,8 @@ void *vita_mem_alloc(unsigned int type, unsigned int size, unsigned int alignmen
if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW) {
size = ALIGN(size, 256 * 1024);
} else if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW) {
size = ALIGN(size, 1024 * 1024);
} else {
size = ALIGN(size, 4 * 1024);
}
@@ -1162,7 +1162,7 @@ void gxm_init_for_common_dialog(void)
for (int i = 0; i < VITA_GXM_BUFFERS; i += 1) {
buffer_for_common_dialog[i].displayData.wait_vblank = SDL_TRUE;
buffer_for_common_dialog[i].displayData.address = vita_mem_alloc(
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW,
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW,
4 * VITA_GXM_SCREEN_STRIDE * VITA_GXM_SCREEN_HEIGHT,
SCE_GXM_COLOR_SURFACE_ALIGNMENT,
SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
+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));
+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);
}
+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;
+3 -3
View File
@@ -107,7 +107,7 @@ void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,
/*
* Resets the assert summary counters to zero.
*/
void SDLTest_ResetAssertSummary()
void SDLTest_ResetAssertSummary(void)
{
SDLTest_AssertsPassed = 0;
SDLTest_AssertsFailed = 0;
@@ -117,7 +117,7 @@ void SDLTest_ResetAssertSummary()
* Logs summary of all assertions (total, pass, fail) since last reset
* as INFO (failed==0) or ERROR (failed > 0).
*/
void SDLTest_LogAssertSummary()
void SDLTest_LogAssertSummary(void)
{
int totalAsserts = SDLTest_AssertsPassed + SDLTest_AssertsFailed;
if (SDLTest_AssertsFailed == 0) {
@@ -130,7 +130,7 @@ void SDLTest_LogAssertSummary()
/*
* Converts the current assert state into a test result
*/
int SDLTest_AssertSummaryToTestResult()
int SDLTest_AssertSummaryToTestResult(void)
{
if (SDLTest_AssertsFailed > 0) {
return TEST_RESULT_FAILED;
+14 -14
View File
@@ -68,54 +68,54 @@ void SDLTest_FuzzerInit(Uint64 execKey)
fuzzerInvocationCounter = 0;
}
int SDLTest_GetFuzzerInvocationCount()
int SDLTest_GetFuzzerInvocationCount(void)
{
return fuzzerInvocationCounter;
}
Uint8 SDLTest_RandomUint8()
Uint8 SDLTest_RandomUint8(void)
{
fuzzerInvocationCounter++;
return (Uint8)SDLTest_RandomInt(&rndContext) & 0x000000FF;
}
Sint8 SDLTest_RandomSint8()
Sint8 SDLTest_RandomSint8(void)
{
fuzzerInvocationCounter++;
return (Sint8)SDLTest_RandomInt(&rndContext) & 0x000000FF;
}
Uint16 SDLTest_RandomUint16()
Uint16 SDLTest_RandomUint16(void)
{
fuzzerInvocationCounter++;
return (Uint16)SDLTest_RandomInt(&rndContext) & 0x0000FFFF;
}
Sint16 SDLTest_RandomSint16()
Sint16 SDLTest_RandomSint16(void)
{
fuzzerInvocationCounter++;
return (Sint16)SDLTest_RandomInt(&rndContext) & 0x0000FFFF;
}
Sint32 SDLTest_RandomSint32()
Sint32 SDLTest_RandomSint32(void)
{
fuzzerInvocationCounter++;
return (Sint32)SDLTest_RandomInt(&rndContext);
}
Uint32 SDLTest_RandomUint32()
Uint32 SDLTest_RandomUint32(void)
{
fuzzerInvocationCounter++;
return (Uint32)SDLTest_RandomInt(&rndContext);
}
Uint64 SDLTest_RandomUint64()
Uint64 SDLTest_RandomUint64(void)
{
union
{
@@ -132,7 +132,7 @@ Uint64 SDLTest_RandomUint64()
return value.v64;
}
Sint64 SDLTest_RandomSint64()
Sint64 SDLTest_RandomSint64(void)
{
union
{
@@ -425,24 +425,24 @@ Sint64 SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL
validDomain);
}
float SDLTest_RandomUnitFloat()
float SDLTest_RandomUnitFloat(void)
{
return SDLTest_RandomUint32() / (float)UINT_MAX;
}
float SDLTest_RandomFloat()
float SDLTest_RandomFloat(void)
{
return (float)(SDLTest_RandomUnitDouble() * 2.0 * (double)FLT_MAX - (double)(FLT_MAX));
}
double
SDLTest_RandomUnitDouble()
SDLTest_RandomUnitDouble(void)
{
return (double)(SDLTest_RandomUint64() >> 11) * (1.0 / 9007199254740992.0);
}
double
SDLTest_RandomDouble()
SDLTest_RandomDouble(void)
{
double r = 0.0;
double s = 1.0;
@@ -456,7 +456,7 @@ SDLTest_RandomDouble()
return r;
}
char *SDLTest_RandomAsciiString()
char *SDLTest_RandomAsciiString(void)
{
return SDLTest_RandomAsciiStringWithMaximumLength(255);
}
+1 -1
View File
@@ -339,7 +339,7 @@ static void SDLTest_LogTestSuiteSummary(SDLTest_TestSuiteReference *testSuites)
#endif
/* Gets a timer value in seconds */
static float GetClock()
static float GetClock(void)
{
float currentClock = SDL_GetPerformanceCounter() / (float)SDL_GetPerformanceFrequency();
return currentClock;
+3 -3
View File
@@ -540,7 +540,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlit = {
/**
* \brief Returns the Blit test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImageBlit()
SDL_Surface *SDLTest_ImageBlit(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imageBlit.pixel_data,
@@ -1014,7 +1014,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitColor = {
/**
* \brief Returns the BlitColor test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImageBlitColor()
SDL_Surface *SDLTest_ImageBlitColor(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imageBlitColor.pixel_data,
@@ -1651,7 +1651,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitAlpha = {
/**
* \brief Returns the BlitAlpha test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImageBlitAlpha()
SDL_Surface *SDLTest_ImageBlitAlpha(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imageBlitAlpha.pixel_data,
+5 -5
View File
@@ -580,7 +580,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAdd = {
/**
* \brief Returns the BlitBlendAdd test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImageBlitBlendAdd()
SDL_Surface *SDLTest_ImageBlitBlendAdd(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imageBlitBlendAdd.pixel_data,
@@ -1171,7 +1171,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlend = {
/**
* \brief Returns the BlitBlend test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImageBlitBlend()
SDL_Surface *SDLTest_ImageBlitBlend(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imageBlitBlend.pixel_data,
@@ -1592,7 +1592,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendMod = {
/**
* \brief Returns the BlitBlendMod test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImageBlitBlendMod()
SDL_Surface *SDLTest_ImageBlitBlendMod(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imageBlitBlendMod.pixel_data,
@@ -2396,7 +2396,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendNone = {
/**
* \brief Returns the BlitBlendNone test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImageBlitBlendNone()
SDL_Surface *SDLTest_ImageBlitBlendNone(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imageBlitBlendNone.pixel_data,
@@ -2932,7 +2932,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAll = {
/**
* \brief Returns the BlitBlendAll test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImageBlitBlendAll()
SDL_Surface *SDLTest_ImageBlitBlendAll(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imageBlitBlendAll.pixel_data,
+1 -1
View File
@@ -223,7 +223,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageFace = {
/**
* \brief Returns the Face test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImageFace()
SDL_Surface *SDLTest_ImageFace(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imageFace.pixel_data,
+1 -1
View File
@@ -504,7 +504,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imagePrimitives = {
/**
* \brief Returns the Primitives test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImagePrimitives()
SDL_Surface *SDLTest_ImagePrimitives(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imagePrimitives.pixel_data,
Loaded 100 of 193 files, more files were not shown because too many files have changed in this diff. Show more