Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.

Commit 54da264

Browse files
committed
Add SDL 2.24.0 support
1 parent 3b86a81 commit 54da264

File tree

108 files changed

+1920
-252
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+1920
-252
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<p align="center">
88
<a href="https://github.com/php-ffi-headers/sdl2-headers/actions"><img src="https://github.com/php-ffi-headers/sdl2-headers/workflows/build/badge.svg"></a>
99
<a href="https://packagist.org/packages/ffi-headers/sdl2-headers"><img src="https://img.shields.io/badge/PHP-8.1.0-ff0140.svg"></a>
10-
<a href="https://packagist.org/packages/ffi-headers/sdl2-headers"><img src="https://img.shields.io/badge/SDL2-2.0.22-cc3c20.svg"></a>
10+
<a href="https://packagist.org/packages/ffi-headers/sdl2-headers"><img src="https://img.shields.io/badge/SDL2-2.24.0-cc3c20.svg"></a>
1111
<a href="https://packagist.org/packages/ffi-headers/sdl2-headers"><img src="https://poser.pugx.org/ffi-headers/sdl2-headers/version" alt="Latest Stable Version"></a>
1212
<a href="https://packagist.org/packages/ffi-headers/sdl2-headers"><img src="https://poser.pugx.org/ffi-headers/sdl2-headers/v/unstable" alt="Latest Unstable Version"></a>
1313
<a href="https://packagist.org/packages/ffi-headers/sdl2-headers"><img src="https://poser.pugx.org/ffi-headers/sdl2-headers/downloads" alt="Total Downloads"></a>
@@ -37,7 +37,7 @@ $ composer require ffi-headers/sdl2-headers
3737
use FFI\Headers\SDL2;
3838

3939
$headers = SDL2::create(
40-
SDL2\Version::V2_0_20, // SDL2 Headers Version
40+
SDL2\Version::V2_24_2, // SDL2 Headers Version
4141
);
4242

4343
echo $headers;

resources/headers/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
*
22
!.gitignore
3-
!2.0.22/
3+
!2.24.0/

resources/headers/2.0.22/SDL_test_font.h

Lines changed: 0 additions & 81 deletions
This file was deleted.

resources/headers/2.0.22/SDL.h renamed to resources/headers/2.24.0/SDL.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "SDL_events.h"
4242
#include "SDL_filesystem.h"
4343
#include "SDL_gamecontroller.h"
44+
#include "SDL_guid.h"
4445
#include "SDL_haptic.h"
4546
#include "SDL_hidapi.h"
4647
#include "SDL_hints.h"

resources/headers/2.0.22/SDL_assert.h renamed to resources/headers/2.24.0/SDL_assert.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#ifndef SDL_assert_h_
2323
#define SDL_assert_h_
2424

25-
#include "SDL_config.h"
25+
#include "SDL_stdinc.h"
2626

2727
#include "begin_code.h"
2828
/* Set up for C function definitions, even when using C++ */
@@ -51,6 +51,8 @@ assert can have unique static variables associated with it.
5151
/* Don't include intrin.h here because it contains C++ code */
5252
extern void __cdecl __debugbreak(void);
5353
#define SDL_TriggerBreakpoint() __debugbreak()
54+
#elif _SDL_HAS_BUILTIN(__builtin_debugtrap)
55+
#define SDL_TriggerBreakpoint() __builtin_debugtrap()
5456
#elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) )
5557
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
5658
#elif ( defined(__APPLE__) && (defined(__arm64__) || defined(__aarch64__)) ) /* this might work on other ARM targets, but this is a known quantity... */
@@ -69,7 +71,7 @@ assert can have unique static variables associated with it.
6971

7072
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */
7173
# define SDL_FUNCTION __func__
72-
#elif ((__GNUC__ >= 2) || defined(_MSC_VER) || defined (__WATCOMC__))
74+
#elif ((defined(__GNUC__) && (__GNUC__ >= 2)) || defined(_MSC_VER) || defined (__WATCOMC__))
7375
# define SDL_FUNCTION __FUNCTION__
7476
#else
7577
# define SDL_FUNCTION "???"

resources/headers/2.0.22/SDL_atomic.h renamed to resources/headers/2.24.0/SDL_atomic.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,26 @@ typedef void (*SDL_KernelMemoryBarrierFunc)();
237237
#endif
238238
#endif
239239

240+
/* "REP NOP" is PAUSE, coded for tools that don't know it by that name. */
241+
#if (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))
242+
#define SDL_CPUPauseInstruction() __asm__ __volatile__("pause\n") /* Some assemblers can't do REP NOP, so go with PAUSE. */
243+
#elif (defined(__arm__) && __ARM_ARCH__ >= 7) || defined(__aarch64__)
244+
#define SDL_CPUPauseInstruction() __asm__ __volatile__("yield" ::: "memory")
245+
#elif (defined(__powerpc__) || defined(__powerpc64__))
246+
#define SDL_CPUPauseInstruction() __asm__ __volatile__("or 27,27,27");
247+
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
248+
#define SDL_CPUPauseInstruction() _mm_pause() /* this is actually "rep nop" and not a SIMD instruction. No inline asm in MSVC x86-64! */
249+
#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
250+
#define SDL_CPUPauseInstruction() __yield()
251+
#elif defined(__WATCOMC__) && defined(__386__)
252+
/* watcom assembler rejects PAUSE if CPU < i686, and it refuses REP NOP as an invalid combination. Hardcode the bytes. */
253+
extern __inline void SDL_CPUPauseInstruction(void);
254+
#pragma aux SDL_CPUPauseInstruction = "db 0f3h,90h"
255+
#else
256+
#define SDL_CPUPauseInstruction()
257+
#endif
258+
259+
240260
/**
241261
* \brief A type representing an atomic integer value. It is a struct
242262
* so people don't accidentally use numeric operations on it.

resources/headers/2.0.22/SDL_audio.h renamed to resources/headers/2.24.0/SDL_audio.h

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream,
172172
* 2: FL FR (stereo)
173173
* 3: FL FR LFE (2.1 surround)
174174
* 4: FL FR BL BR (quad)
175-
* 5: FL FR FC BL BR (quad + center)
175+
* 5: FL FR LFE BL BR (4.1 surround)
176176
* 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR)
177177
* 7: FL FR FC LFE BC SL SR (6.1 surround)
178178
* 8: FL FR FC LFE BL BR SL SR (7.1 surround)
@@ -487,6 +487,7 @@ extern DECLSPEC int SDLCALL SDL_GetNumAudioDevices(int iscapture);
487487
* \since This function is available since SDL 2.0.0.
488488
*
489489
* \sa SDL_GetNumAudioDevices
490+
* \sa SDL_GetDefaultAudioInfo
490491
*/
491492
extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index,
492493
int iscapture);
@@ -512,12 +513,48 @@ extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index,
512513
* \since This function is available since SDL 2.0.16.
513514
*
514515
* \sa SDL_GetNumAudioDevices
516+
* \sa SDL_GetDefaultAudioInfo
515517
*/
516518
extern DECLSPEC int SDLCALL SDL_GetAudioDeviceSpec(int index,
517519
int iscapture,
518520
SDL_AudioSpec *spec);
519521

520522

523+
/**
524+
* Get the name and preferred format of the default audio device.
525+
*
526+
* Some (but not all!) platforms have an isolated mechanism to get information
527+
* about the "default" device. This can actually be a completely different
528+
* device that's not in the list you get from SDL_GetAudioDeviceSpec(). It can
529+
* even be a network address! (This is discussed in SDL_OpenAudioDevice().)
530+
*
531+
* As a result, this call is not guaranteed to be performant, as it can query
532+
* the sound server directly every time, unlike the other query functions. You
533+
* should call this function sparingly!
534+
*
535+
* `spec` will be filled with the sample rate, sample format, and channel
536+
* count, if a default device exists on the system. If `name` is provided,
537+
* will be filled with either a dynamically-allocated UTF-8 string or NULL.
538+
*
539+
* \param name A pointer to be filled with the name of the default device (can
540+
* be NULL). Please call SDL_free() when you are done with this
541+
* pointer!
542+
* \param spec The SDL_AudioSpec to be initialized by this function.
543+
* \param iscapture non-zero to query the default recording device, zero to
544+
* query the default output device.
545+
* \returns 0 on success, nonzero on error
546+
*
547+
* \since This function is available since SDL 2.24.0.
548+
*
549+
* \sa SDL_GetAudioDeviceName
550+
* \sa SDL_GetAudioDeviceSpec
551+
* \sa SDL_OpenAudioDevice
552+
*/
553+
extern DECLSPEC int SDLCALL SDL_GetDefaultAudioInfo(char **name,
554+
SDL_AudioSpec *spec,
555+
int iscapture);
556+
557+
521558
/**
522559
* Open a specific audio device.
523560
*
@@ -584,6 +621,7 @@ extern DECLSPEC int SDLCALL SDL_GetAudioDeviceSpec(int index,
584621
* - `SDL_AUDIO_ALLOW_FREQUENCY_CHANGE`
585622
* - `SDL_AUDIO_ALLOW_FORMAT_CHANGE`
586623
* - `SDL_AUDIO_ALLOW_CHANNELS_CHANGE`
624+
* - `SDL_AUDIO_ALLOW_SAMPLES_CHANGE`
587625
* - `SDL_AUDIO_ALLOW_ANY_CHANGE`
588626
*
589627
* These flags specify how SDL should behave when a device cannot offer a
File renamed without changes.

0 commit comments

Comments
 (0)