Skip to content

Commit fb9e665

Browse files
committed
Merge tag 'release-2.32.2'
2 parents 9754dbf + e11183e commit fb9e665

File tree

16 files changed

+194
-31
lines changed

16 files changed

+194
-31
lines changed

android-project/app/src/main/java/org/libsdl/app/SDLActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
6161
private static final String TAG = "SDL";
6262
private static final int SDL_MAJOR_VERSION = 2;
6363
private static final int SDL_MINOR_VERSION = 32;
64-
private static final int SDL_MICRO_VERSION = 0;
64+
private static final int SDL_MICRO_VERSION = 2;
6565
/*
6666
// Display InputType.SOURCE/CLASS of events and devices
6767
//

build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub fn build(b: *std.Build) void {
159159
.style = .{ .cmake = b.path("include/SDL_revision.h.cmake") },
160160
.include_path = "SDL_revision.h",
161161
}, .{
162-
.SDL_REVISION = "SDL-2.32.0",
162+
.SDL_REVISION = "SDL-2.32.2",
163163
.SDL_VENDOR_INFO = "allyourcodebase.com",
164164
});
165165
lib.addConfigHeader(revision_header);

build.zig.zon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.{
22
.name = "SDL",
3-
.version = "2.32.0",
3+
.version = "2.32.2",
44
.minimum_zig_version = "0.13.0",
55
.dependencies = .{},
66
.paths = .{

include/SDL_hints.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,6 +1423,27 @@ extern "C" {
14231423
*/
14241424
#define SDL_HINT_JOYSTICK_DEVICE "SDL_JOYSTICK_DEVICE"
14251425

1426+
1427+
/**
1428+
* A variable containing a list of devices and their desired number of haptic
1429+
* (force feedback) enabled axis.
1430+
*
1431+
* The format of the string is a comma separated list of USB VID/PID pairs in
1432+
* hexadecimal form plus the number of desired axes, e.g.
1433+
*
1434+
* `0xAAAA/0xBBBB/1,0xCCCC/0xDDDD/3`
1435+
*
1436+
* This hint supports a "wildcard" device that will set the number of haptic
1437+
* axes on all initialized haptic devices which were not defined explicitly in
1438+
* this hint.
1439+
*
1440+
* `0xFFFF/0xFFFF/1`
1441+
*
1442+
* This hint should be set before a controller is opened. The number of haptic
1443+
* axes won't exceed the number of real axes found on the device.
1444+
*/
1445+
#define SDL_HINT_JOYSTICK_HAPTIC_AXES "SDL_JOYSTICK_HAPTIC_AXES"
1446+
14261447
/**
14271448
* A variable controlling whether joysticks on Linux will always treat 'hat'
14281449
* axis inputs (ABS_HAT0X - ABS_HAT3Y) as 8-way digital hats without checking

include/SDL_keyboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name);
255255
* On some platforms using this function activates the screen keyboard.
256256
*
257257
* On desktop platforms, SDL_StartTextInput() is implicitly called on SDL
258-
* window creation which will cause events SDL_TextInputEvent and
258+
* video subsystem initialization which will cause SDL_TextInputEvent and
259259
* SDL_TextEditingEvent to begin emitting.
260260
*
261261
* \since This function is available since SDL 2.0.0.

include/SDL_version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ typedef struct SDL_version
5858
*/
5959
#define SDL_MAJOR_VERSION 2
6060
#define SDL_MINOR_VERSION 32
61-
#define SDL_PATCHLEVEL 0
61+
#define SDL_PATCHLEVEL 2
6262

6363
/**
6464
* Macro to determine SDL version program was compiled against.

src/audio/emscripten/SDL_emscriptenaudio.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
310310
if ((SDL2 === undefined) || (SDL2.capture === undefined)) { return; }
311311
audioProcessingEvent.outputBuffer.getChannelData(0).fill(0.0);
312312
SDL2.capture.currentCaptureBuffer = audioProcessingEvent.inputBuffer;
313-
dynCall('vi', $2, [$3]);
313+
dynCall('vp', $2, [$3]);
314314
};
315315
SDL2.capture.mediaStreamNode.connect(SDL2.capture.scriptProcessorNode);
316316
SDL2.capture.scriptProcessorNode.connect(SDL2.audioContext.destination);
@@ -326,7 +326,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
326326
SDL2.capture.silenceBuffer.getChannelData(0).fill(0.0);
327327
var silence_callback = function() {
328328
SDL2.capture.currentCaptureBuffer = SDL2.capture.silenceBuffer;
329-
dynCall('vi', $2, [$3]);
329+
dynCall('vp', $2, [$3]);
330330
};
331331

332332
SDL2.capture.silenceTimer = setInterval(silence_callback, ($1 / SDL2.audioContext.sampleRate) * 1000);
@@ -351,7 +351,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
351351
SDL2.audio.silenceBuffer = undefined;
352352
}
353353
SDL2.audio.currentOutputBuffer = e['outputBuffer'];
354-
dynCall('vi', $2, [$3]);
354+
dynCall('vp', $2, [$3]);
355355
};
356356

357357
SDL2.audio.scriptProcessorNode['connect'](SDL2.audioContext['destination']);
@@ -369,7 +369,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
369369
// the buffer that gets filled here just gets ignored, so the app can make progress
370370
// and/or avoid flooding audio queues until we can actually play audio.
371371
SDL2.audio.currentOutputBuffer = SDL2.audio.silenceBuffer;
372-
dynCall('vi', $2, [$3]);
372+
dynCall('vp', $2, [$3]);
373373
SDL2.audio.currentOutputBuffer = undefined;
374374
};
375375

src/audio/pulseaudio/SDL_pulseaudio.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ static void PULSEAUDIO_FlushCapture(_THIS)
497497
{
498498
struct SDL_PrivateAudioData *h = this->hidden;
499499
const void *data = NULL;
500-
size_t nbytes = 0;
500+
size_t nbytes = 0, buflen = 0;
501501

502502
PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop);
503503

@@ -507,19 +507,19 @@ static void PULSEAUDIO_FlushCapture(_THIS)
507507
h->capturelen = 0;
508508
}
509509

510-
while (SDL_AtomicGet(&this->enabled) && (PULSEAUDIO_pa_stream_readable_size(h->stream) > 0)) {
510+
buflen = PULSEAUDIO_pa_stream_readable_size(h->stream);
511+
while (SDL_AtomicGet(&this->enabled) && (buflen > 0)) {
511512
PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop);
512513
if ((PULSEAUDIO_pa_context_get_state(pulseaudio_context) != PA_CONTEXT_READY) || (PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY)) {
513514
/*printf("PULSEAUDIO DEVICE FAILURE IN FLUSHCAPTURE!\n");*/
514515
SDL_OpenedAudioDeviceDisconnected(this);
515516
break;
516517
}
517-
518-
if (PULSEAUDIO_pa_stream_readable_size(h->stream) > 0) {
519-
/* a new fragment is available! Just dump it. */
520-
PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes);
521-
PULSEAUDIO_pa_stream_drop(h->stream); /* drop this fragment. */
522-
}
518+
/* a fragment of audio present before FlushCapture was call is
519+
available! Just drop it. */
520+
PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes);
521+
PULSEAUDIO_pa_stream_drop(h->stream);
522+
buflen -= nbytes;
523523
}
524524

525525
PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop);

src/dynapi/SDL_dynapi.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,19 +440,24 @@ extern SDL_NORETURN void SDL_ExitProcess(int exitcode);
440440

441441
static void SDL_InitDynamicAPILocked(void)
442442
{
443+
SDL_DYNAPI_ENTRYFN entry = NULL; /* funcs from here by default. */
444+
SDL_bool use_internal = SDL_TRUE;
445+
443446
/* this can't use SDL_getenv_REAL, because it might allocate memory before the app can set their allocator */
444447
#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
445448
/* We've always used LoadLibraryA for this, so this has never worked with Unicode paths on Windows. Sorry. */
446449
char envbuf[512]; /* overflows will just report as environment variable being unset, but LoadLibraryA has a MAX_PATH of 260 anyhow, apparently. */
447450
const DWORD rc = GetEnvironmentVariableA(SDL_DYNAMIC_API_ENVVAR, envbuf, (DWORD) sizeof (envbuf));
448451
char *libname = ((rc != 0) && (rc < sizeof (envbuf))) ? envbuf : NULL;
452+
#elif defined(__OS2__)
453+
char * libname;
454+
if (DosScanEnv(SDL_DYNAMIC_API_ENVVAR, &libname) != NO_ERROR) {
455+
libname = NULL;
456+
}
449457
#else
450458
char *libname = getenv(SDL_DYNAMIC_API_ENVVAR);
451459
#endif
452460

453-
SDL_DYNAPI_ENTRYFN entry = NULL; /* funcs from here by default. */
454-
SDL_bool use_internal = SDL_TRUE;
455-
456461
if (libname) {
457462
while (*libname && !entry) {
458463
char *ptr = libname;

src/haptic/SDL_haptic.c

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,85 @@
2323
#include "SDL_syshaptic.h"
2424
#include "SDL_haptic_c.h"
2525
#include "../joystick/SDL_joystick_c.h" /* For SDL_PrivateJoystickValid */
26+
#include "SDL_hints.h"
27+
#include "../SDL_hints_c.h"
28+
29+
typedef struct SDL_Haptic_VIDPID_Naxes {
30+
Uint16 vid;
31+
Uint16 pid;
32+
Uint16 naxes;
33+
} SDL_Haptic_VIDPID_Naxes;
34+
35+
static void SDL_HapticLoadAxesList(SDL_Haptic_VIDPID_Naxes **entries, int *num_entries)
36+
{
37+
SDL_Haptic_VIDPID_Naxes entry;
38+
const char *spot;
39+
int length = 0;
40+
41+
spot = SDL_GetHint(SDL_HINT_JOYSTICK_HAPTIC_AXES);
42+
if (!spot)
43+
return;
44+
45+
while (SDL_sscanf(spot, "0x%hx/0x%hx/%hu%n", &entry.vid, &entry.pid, &entry.naxes, &length) == 3) {
46+
SDL_assert(length > 0);
47+
spot += length;
48+
length = 0;
49+
50+
if ((*num_entries % 8) == 0) {
51+
int new_max = *num_entries + 8;
52+
SDL_Haptic_VIDPID_Naxes *new_entries =
53+
(SDL_Haptic_VIDPID_Naxes *)SDL_realloc(*entries, new_max * sizeof(**entries));
54+
55+
// Out of memory, go with what we have already
56+
if (!new_entries)
57+
break;
58+
59+
*entries = new_entries;
60+
}
61+
(*entries)[(*num_entries)++] = entry;
62+
63+
if (spot[0] == ',')
64+
spot++;
65+
}
66+
}
67+
68+
// /* Return -1 if not found */
69+
static int SDL_HapticNaxesListIndex(struct SDL_Haptic_VIDPID_Naxes *entries, int num_entries, Uint16 vid, Uint16 pid)
70+
{
71+
int i;
72+
if (!entries)
73+
return -1;
74+
75+
for (i = 0; i < num_entries; ++i) {
76+
if (entries[i].vid == vid && entries[i].pid == pid)
77+
return i;
78+
}
79+
80+
return -1;
81+
}
82+
83+
// Check if device needs a custom number of naxes
84+
static int SDL_HapticGetNaxes(Uint16 vid, Uint16 pid)
85+
{
86+
int num_entries = 0, index = 0, naxes = -1;
87+
SDL_Haptic_VIDPID_Naxes *naxes_list = NULL;
88+
89+
SDL_HapticLoadAxesList(&naxes_list, &num_entries);
90+
if (!num_entries || !naxes_list)
91+
return -1;
92+
93+
// Perform "wildcard" pass
94+
index = SDL_HapticNaxesListIndex(naxes_list, num_entries, 0xffff, 0xffff);
95+
if (index >= 0)
96+
naxes = naxes_list[index].naxes;
97+
98+
index = SDL_HapticNaxesListIndex(naxes_list, num_entries, vid, pid);
99+
if (index >= 0)
100+
naxes = naxes_list[index].naxes;
101+
102+
SDL_free(naxes_list);
103+
return naxes;
104+
}
26105

27106
/* Global for SDL_windowshaptic.c */
28107
#if defined(SDL_HAPTIC_DINPUT) || defined(SDL_HAPTIC_XINPUT)
@@ -258,6 +337,8 @@ SDL_Haptic *SDL_HapticOpenFromJoystick(SDL_Joystick *joystick)
258337
{
259338
SDL_Haptic *haptic;
260339
SDL_Haptic *hapticlist;
340+
int naxes, general_axes;
341+
Uint16 vid, pid;
261342

262343
/* Make sure there is room. */
263344
if (SDL_NumHaptics() <= 0) {
@@ -314,6 +395,18 @@ SDL_Haptic *SDL_HapticOpenFromJoystick(SDL_Joystick *joystick)
314395
}
315396
SDL_UnlockJoysticks();
316397

398+
vid = SDL_JoystickGetVendor(joystick);
399+
pid = SDL_JoystickGetProduct(joystick);
400+
general_axes = SDL_JoystickNumAxes(joystick);
401+
402+
naxes = SDL_HapticGetNaxes(vid, pid);
403+
if (naxes > 0)
404+
haptic->naxes = naxes;
405+
406+
// Limit to the actual number of axes found on the device
407+
if (general_axes >= 0 && naxes > general_axes)
408+
haptic->naxes = general_axes;
409+
317410
/* Add haptic to list */
318411
++haptic->ref_count;
319412
/* Link the haptic in the list */

0 commit comments

Comments
 (0)