mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-11 16:28:12 +08:00
committed by
Sam Lantinga
parent
e29c0661cc
commit
d0bbfdbfb8
+6
-6
@@ -1008,12 +1008,12 @@ typedef struct _SDL_AudioStream SDL_AudioStream;
|
||||
* \sa SDL_AudioStreamClear
|
||||
* \sa SDL_FreeAudioStream
|
||||
*/
|
||||
extern DECLSPEC SDL_AudioStream * SDLCALL SDL_NewAudioStream(const SDL_AudioFormat src_format,
|
||||
const Uint8 src_channels,
|
||||
const int src_rate,
|
||||
const SDL_AudioFormat dst_format,
|
||||
const Uint8 dst_channels,
|
||||
const int dst_rate);
|
||||
extern DECLSPEC SDL_AudioStream *SDLCALL SDL_NewAudioStream(SDL_AudioFormat src_format,
|
||||
Uint8 src_channels,
|
||||
int src_rate,
|
||||
SDL_AudioFormat dst_format,
|
||||
Uint8 dst_channels,
|
||||
int dst_rate);
|
||||
|
||||
/**
|
||||
* Add data to be converted/resampled to the stream.
|
||||
|
||||
+2
-2
@@ -276,7 +276,7 @@ extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem);
|
||||
* successful it will atomically decrement the semaphore value.
|
||||
*
|
||||
* \param sem the semaphore to wait on
|
||||
* \param ms the length of the timeout, in milliseconds
|
||||
* \param timeout the length of the timeout, in milliseconds
|
||||
* \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait does not
|
||||
* succeed in the allotted time, or a negative error code on failure;
|
||||
* call SDL_GetError() for more information.
|
||||
@@ -290,7 +290,7 @@ extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem);
|
||||
* \sa SDL_SemValue
|
||||
* \sa SDL_SemWait
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms);
|
||||
extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout);
|
||||
|
||||
/**
|
||||
* Atomically increment a semaphore's value and wake waiting threads.
|
||||
|
||||
+3
-4
@@ -48,7 +48,6 @@ typedef enum
|
||||
SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */
|
||||
} SDL_PowerState;
|
||||
|
||||
|
||||
/**
|
||||
* Get the current power supply details.
|
||||
*
|
||||
@@ -65,17 +64,17 @@ typedef enum
|
||||
* It's possible a platform can only report battery percentage or time left
|
||||
* but not both.
|
||||
*
|
||||
* \param secs seconds of battery life left, you can pass a NULL here if you
|
||||
* \param seconds seconds of battery life left, you can pass a NULL here if you
|
||||
* don't care, will return -1 if we can't determine a value, or
|
||||
* we're not running on a battery
|
||||
* \param pct percentage of battery life left, between 0 and 100, you can pass
|
||||
* \param percent percentage of battery life left, between 0 and 100, you can pass
|
||||
* a NULL here if you don't care, will return -1 if we can't
|
||||
* determine a value, or we're not running on a battery
|
||||
* \returns an SDL_PowerState enum representing the current battery state.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*/
|
||||
extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct);
|
||||
extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *seconds, int *percent);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -683,7 +683,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
|
||||
* it might be easier to call but it doesn't have access to palette
|
||||
* information for the destination surface, in case that would be important.
|
||||
*
|
||||
* \param src the existing SDL_Surface structure to convert
|
||||
* \param surface the existing SDL_Surface structure to convert
|
||||
* \param pixel_format the SDL_PixelFormatEnum that the new surface is
|
||||
* optimized for
|
||||
* \param flags the flags are unused and should be set to 0; this is a
|
||||
|
||||
+2
-2
@@ -288,8 +288,8 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data,
|
||||
/* this is a little hacky. */
|
||||
for (;;) {
|
||||
char buf[32];
|
||||
fprintf(stderr, "Abort/Break/Retry/Ignore/AlwaysIgnore? [abriA] : ");
|
||||
fflush(stderr);
|
||||
(void)fprintf(stderr, "Abort/Break/Retry/Ignore/AlwaysIgnore? [abriA] : ");
|
||||
(void)fflush(stderr);
|
||||
if (fgets(buf, sizeof(buf), stdin) == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||
error->str = str;
|
||||
error->len = len;
|
||||
va_start(ap, fmt);
|
||||
SDL_vsnprintf(error->str, error->len, fmt, ap);
|
||||
(void)SDL_vsnprintf(error->str, error->len, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
|
||||
+13
-7
@@ -415,7 +415,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
|
||||
|
||||
length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1 + 1 + 1;
|
||||
output = SDL_small_alloc(char, length, &isstack);
|
||||
SDL_snprintf(output, length, "%s: %s\r\n", SDL_priority_prefixes[priority], message);
|
||||
(void)SDL_snprintf(output, length, "%s: %s\r\n", SDL_priority_prefixes[priority], message);
|
||||
tstr = WIN_UTF8ToString(output);
|
||||
|
||||
/* Output to debugger */
|
||||
@@ -460,22 +460,28 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
|
||||
{
|
||||
FILE *pFile;
|
||||
pFile = fopen("SDL_Log.txt", "a");
|
||||
fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
||||
fclose(pFile);
|
||||
if (pFile != NULL) {
|
||||
(void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
||||
(void)fclose(pFile);
|
||||
}
|
||||
}
|
||||
#elif defined(__VITA__)
|
||||
{
|
||||
FILE *pFile;
|
||||
pFile = fopen("ux0:/data/SDL_Log.txt", "a");
|
||||
fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
||||
fclose(pFile);
|
||||
if (pFile != NULL) {
|
||||
(void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
||||
(void)fclose(pFile);
|
||||
}
|
||||
}
|
||||
#elif defined(__3DS__)
|
||||
{
|
||||
FILE *pFile;
|
||||
pFile = fopen("sdmc:/3ds/SDL_Log.txt", "a");
|
||||
fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
||||
fclose(pFile);
|
||||
if (pFile != NULL) {
|
||||
(void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
||||
(void)fclose(pFile);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if HAVE_STDIO_H && \
|
||||
|
||||
+40
-19
@@ -394,7 +394,7 @@ static int add_audio_device(const char *name, SDL_AudioSpec *spec, void *handle,
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
SDL_snprintf(replacement, len, "%s (%d)", name, dupenum + 1);
|
||||
(void)SDL_snprintf(replacement, len, "%s (%d)", name, dupenum + 1);
|
||||
item->dupenum = dupenum;
|
||||
item->name = replacement;
|
||||
}
|
||||
@@ -658,6 +658,10 @@ void SDL_ClearQueuedAudio(SDL_AudioDeviceID devid)
|
||||
current_audio.impl.UnlockDevice(device);
|
||||
}
|
||||
|
||||
#if SDL_AUDIO_DRIVER_ANDROID
|
||||
extern void Android_JNI_AudioSetThreadPriority(int, int);
|
||||
#endif
|
||||
|
||||
/* The general mixing thread function */
|
||||
static int SDLCALL SDL_RunAudio(void *devicep)
|
||||
{
|
||||
@@ -672,7 +676,6 @@ static int SDLCALL SDL_RunAudio(void *devicep)
|
||||
#if SDL_AUDIO_DRIVER_ANDROID
|
||||
{
|
||||
/* Set thread priority to THREAD_PRIORITY_AUDIO */
|
||||
extern void Android_JNI_AudioSetThreadPriority(int, int);
|
||||
Android_JNI_AudioSetThreadPriority(device->iscapture, device->id);
|
||||
}
|
||||
#else
|
||||
@@ -773,7 +776,6 @@ static int SDLCALL SDL_CaptureAudio(void *devicep)
|
||||
#if SDL_AUDIO_DRIVER_ANDROID
|
||||
{
|
||||
/* Set thread priority to THREAD_PRIORITY_AUDIO */
|
||||
extern void Android_JNI_AudioSetThreadPriority(int, int);
|
||||
Android_JNI_AudioSetThreadPriority(device->iscapture, device->id);
|
||||
}
|
||||
#else
|
||||
@@ -1187,6 +1189,19 @@ static void close_audio_device(SDL_AudioDevice *device)
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
static Uint16
|
||||
GetDefaultSamplesFromFreq(int freq)
|
||||
{
|
||||
/* Pick a default of ~46 ms at desired frequency */
|
||||
/* !!! FIXME: remove this when the non-Po2 resampling is in. */
|
||||
const Uint16 max_sample = (freq / 1000) * 46;
|
||||
Uint16 current_sample = 1;
|
||||
while (current_sample < max_sample) {
|
||||
current_sample *= 2;
|
||||
}
|
||||
return current_sample;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sanity check desired AudioSpec for SDL_OpenAudio() in (orig).
|
||||
* Fills in a sanitized copy in (prepared).
|
||||
@@ -1197,23 +1212,33 @@ static int prepare_audiospec(const SDL_AudioSpec *orig, SDL_AudioSpec *prepared)
|
||||
SDL_copyp(prepared, orig);
|
||||
|
||||
if (orig->freq == 0) {
|
||||
static const int DEFAULT_FREQ = 22050;
|
||||
const char *env = SDL_getenv("SDL_AUDIO_FREQUENCY");
|
||||
if ((!env) || ((prepared->freq = SDL_atoi(env)) == 0)) {
|
||||
prepared->freq = 22050; /* a reasonable default */
|
||||
if (env != NULL) {
|
||||
int freq = SDL_atoi(env);
|
||||
prepared->freq = freq != 0 ? freq : DEFAULT_FREQ;
|
||||
} else {
|
||||
prepared->freq = DEFAULT_FREQ;
|
||||
}
|
||||
}
|
||||
|
||||
if (orig->format == 0) {
|
||||
const char *env = SDL_getenv("SDL_AUDIO_FORMAT");
|
||||
if ((!env) || ((prepared->format = SDL_ParseAudioFormat(env)) == 0)) {
|
||||
prepared->format = AUDIO_S16; /* a reasonable default */
|
||||
if (env != NULL) {
|
||||
const SDL_AudioFormat format = SDL_ParseAudioFormat(env);
|
||||
prepared->format = format != 0 ? format : AUDIO_S16;
|
||||
} else {
|
||||
prepared->format = AUDIO_S16;
|
||||
}
|
||||
}
|
||||
|
||||
if (orig->channels == 0) {
|
||||
const char *env = SDL_getenv("SDL_AUDIO_CHANNELS");
|
||||
if ((!env) || ((prepared->channels = (Uint8)SDL_atoi(env)) == 0)) {
|
||||
prepared->channels = 2; /* a reasonable default */
|
||||
if (env != NULL) {
|
||||
Uint8 channels = (Uint8)SDL_atoi(env);
|
||||
prepared->channels = channels != 0 ? channels : 2;
|
||||
} else {
|
||||
prepared->channels = 2;
|
||||
}
|
||||
} else if (orig->channels > 8) {
|
||||
SDL_SetError("Unsupported number of audio channels.");
|
||||
@@ -1222,15 +1247,11 @@ static int prepare_audiospec(const SDL_AudioSpec *orig, SDL_AudioSpec *prepared)
|
||||
|
||||
if (orig->samples == 0) {
|
||||
const char *env = SDL_getenv("SDL_AUDIO_SAMPLES");
|
||||
if ((!env) || ((prepared->samples = (Uint16)SDL_atoi(env)) == 0)) {
|
||||
/* Pick a default of ~46 ms at desired frequency */
|
||||
/* !!! FIXME: remove this when the non-Po2 resampling is in. */
|
||||
const int samples = (prepared->freq / 1000) * 46;
|
||||
int power2 = 1;
|
||||
while (power2 < samples) {
|
||||
power2 *= 2;
|
||||
}
|
||||
prepared->samples = power2;
|
||||
if (env != NULL) {
|
||||
Uint16 samples = (Uint16)SDL_atoi(env);
|
||||
prepared->samples = samples != 0 ? samples : GetDefaultSamplesFromFreq(prepared->freq);
|
||||
} else {
|
||||
prepared->samples = GetDefaultSamplesFromFreq(prepared->freq);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1488,7 +1509,7 @@ static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture,
|
||||
const size_t stacksize = is_internal_thread ? 64 * 1024 : 0;
|
||||
char threadname[64];
|
||||
|
||||
SDL_snprintf(threadname, sizeof(threadname), "SDLAudio%c%d", (iscapture) ? 'C' : 'P', (int)device->id);
|
||||
(void)SDL_snprintf(threadname, sizeof threadname, "SDLAudio%c%" SDL_PRIu32, (iscapture) ? 'C' : 'P', device->id);
|
||||
device->thread = SDL_CreateThreadInternal(iscapture ? SDL_CaptureAudio : SDL_RunAudio, threadname, stacksize, device);
|
||||
|
||||
if (device->thread == NULL) {
|
||||
|
||||
+23
-22
@@ -208,7 +208,7 @@ static int SDL_ResampleAudio(const int chans, const int inrate, const int outrat
|
||||
const int paddinglen = ResamplerPadding(inrate, outrate);
|
||||
const int framelen = chans * (int)sizeof(float);
|
||||
const int inframes = inbuflen / framelen;
|
||||
const int wantedoutframes = (int)((inbuflen / framelen) * ratio); /* outbuflen isn't total to write, it's total available. */
|
||||
const int wantedoutframes = (int)(inframes * ratio); /* outbuflen isn't total to write, it's total available. */
|
||||
const int maxoutframes = outbuflen / framelen;
|
||||
const int outframes = SDL_min(wantedoutframes, maxoutframes);
|
||||
ResampleFloatType outtime = 0.0f;
|
||||
@@ -233,7 +233,7 @@ static int SDL_ResampleAudio(const int chans, const int inrate, const int outrat
|
||||
const int srcframe = srcindex - j;
|
||||
/* !!! FIXME: we can bubble this conditional out of here by doing a pre loop. */
|
||||
const float insample = (srcframe < 0) ? lpadding[((paddinglen + srcframe) * chans) + chan] : inbuf[(srcframe * chans) + chan];
|
||||
outsample += (float)(insample * (ResamplerFilter[filterindex1 + (j * RESAMPLER_SAMPLES_PER_ZERO_CROSSING)] + (interpolation1 * ResamplerFilterDifference[filterindex1 + (j * RESAMPLER_SAMPLES_PER_ZERO_CROSSING)])));
|
||||
outsample += (insample * (ResamplerFilter[filterindex1 + (j * RESAMPLER_SAMPLES_PER_ZERO_CROSSING)] + (interpolation1 * ResamplerFilterDifference[filterindex1 + (j * RESAMPLER_SAMPLES_PER_ZERO_CROSSING)])));
|
||||
}
|
||||
|
||||
/* Do the right wing! */
|
||||
@@ -242,7 +242,7 @@ static int SDL_ResampleAudio(const int chans, const int inrate, const int outrat
|
||||
const int srcframe = srcindex + 1 + j;
|
||||
/* !!! FIXME: we can bubble this conditional out of here by doing a post loop. */
|
||||
const float insample = (srcframe >= inframes) ? rpadding[((srcframe - inframes) * chans) + chan] : inbuf[(srcframe * chans) + chan];
|
||||
outsample += (float)(insample * (ResamplerFilter[filterindex2 + jsamples] + (interpolation2 * ResamplerFilterDifference[filterindex2 + jsamples])));
|
||||
outsample += (insample * (ResamplerFilter[filterindex2 + jsamples] + (interpolation2 * ResamplerFilterDifference[filterindex2 + jsamples])));
|
||||
}
|
||||
|
||||
*(dst++) = outsample;
|
||||
@@ -316,7 +316,7 @@ static void SDLCALL SDL_Convert_Byteswap(SDL_AudioCVT *cvt, SDL_AudioFormat form
|
||||
}
|
||||
}
|
||||
|
||||
static int SDL_AddAudioCVTFilter(SDL_AudioCVT *cvt, const SDL_AudioFilter filter)
|
||||
static int SDL_AddAudioCVTFilter(SDL_AudioCVT *cvt, SDL_AudioFilter filter)
|
||||
{
|
||||
if (cvt->filter_index >= SDL_AUDIOCVT_MAX_FILTERS) {
|
||||
return SDL_SetError("Too many filters needed for conversion, exceeded maximum of %d", SDL_AUDIOCVT_MAX_FILTERS);
|
||||
@@ -376,7 +376,8 @@ static int SDL_BuildAudioTypeCVTToFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat
|
||||
cvt->len_mult *= mult;
|
||||
cvt->len_ratio *= mult;
|
||||
} else if (src_bitsize > dst_bitsize) {
|
||||
cvt->len_ratio /= (src_bitsize / dst_bitsize);
|
||||
const int div = (src_bitsize / dst_bitsize);
|
||||
cvt->len_ratio /= div;
|
||||
}
|
||||
|
||||
retval = 1; /* added a converter. */
|
||||
@@ -674,8 +675,8 @@ static SDL_bool SDL_SupportedChannelCount(const int channels)
|
||||
*/
|
||||
|
||||
int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
||||
SDL_AudioFormat src_fmt, Uint8 src_channels, int src_rate,
|
||||
SDL_AudioFormat dst_fmt, Uint8 dst_channels, int dst_rate)
|
||||
SDL_AudioFormat src_format, Uint8 src_channels, int src_rate,
|
||||
SDL_AudioFormat dst_format, Uint8 dst_channels, int dst_rate)
|
||||
{
|
||||
SDL_AudioFilter channel_converter = NULL;
|
||||
|
||||
@@ -687,10 +688,10 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
||||
/* Make sure we zero out the audio conversion before error checking */
|
||||
SDL_zerop(cvt);
|
||||
|
||||
if (!SDL_SupportedAudioFormat(src_fmt)) {
|
||||
if (!SDL_SupportedAudioFormat(src_format)) {
|
||||
return SDL_SetError("Invalid source format");
|
||||
}
|
||||
if (!SDL_SupportedAudioFormat(dst_fmt)) {
|
||||
if (!SDL_SupportedAudioFormat(dst_format)) {
|
||||
return SDL_SetError("Invalid destination format");
|
||||
}
|
||||
if (!SDL_SupportedChannelCount(src_channels)) {
|
||||
@@ -714,12 +715,12 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
||||
|
||||
#if DEBUG_CONVERT
|
||||
SDL_Log("SDL_AUDIO_CONVERT: Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
|
||||
src_fmt, dst_fmt, src_channels, dst_channels, src_rate, dst_rate);
|
||||
src_format, dst_format, src_channels, dst_channels, src_rate, dst_rate);
|
||||
#endif
|
||||
|
||||
/* Start off with no conversion necessary */
|
||||
cvt->src_format = src_fmt;
|
||||
cvt->dst_format = dst_fmt;
|
||||
cvt->src_format = src_format;
|
||||
cvt->dst_format = dst_format;
|
||||
cvt->needed = 0;
|
||||
cvt->filter_index = 0;
|
||||
SDL_zeroa(cvt->filters);
|
||||
@@ -746,13 +747,13 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
||||
|
||||
/* see if we can skip float conversion entirely. */
|
||||
if (src_rate == dst_rate && src_channels == dst_channels) {
|
||||
if (src_fmt == dst_fmt) {
|
||||
if (src_format == dst_format) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* just a byteswap needed? */
|
||||
if ((src_fmt & ~SDL_AUDIO_MASK_ENDIAN) == (dst_fmt & ~SDL_AUDIO_MASK_ENDIAN)) {
|
||||
if (SDL_AUDIO_BITSIZE(dst_fmt) == 8) {
|
||||
if ((src_format & ~SDL_AUDIO_MASK_ENDIAN) == (dst_format & ~SDL_AUDIO_MASK_ENDIAN)) {
|
||||
if (SDL_AUDIO_BITSIZE(dst_format) == 8) {
|
||||
return 0;
|
||||
}
|
||||
if (SDL_AddAudioCVTFilter(cvt, SDL_Convert_Byteswap) < 0) {
|
||||
@@ -764,7 +765,7 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
||||
}
|
||||
|
||||
/* Convert data types, if necessary. Updates (cvt). */
|
||||
if (SDL_BuildAudioTypeCVTToFloat(cvt, src_fmt) < 0) {
|
||||
if (SDL_BuildAudioTypeCVTToFloat(cvt, src_format) < 0) {
|
||||
return -1; /* shouldn't happen, but just in case... */
|
||||
}
|
||||
|
||||
@@ -820,7 +821,7 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
||||
}
|
||||
|
||||
/* Move to final data type. */
|
||||
if (SDL_BuildAudioTypeCVTFromFloat(cvt, dst_fmt) < 0) {
|
||||
if (SDL_BuildAudioTypeCVTFromFloat(cvt, dst_format) < 0) {
|
||||
return -1; /* shouldn't happen, but just in case... */
|
||||
}
|
||||
|
||||
@@ -862,7 +863,7 @@ struct _SDL_AudioStream
|
||||
SDL_CleanupAudioStreamResamplerFunc cleanup_resampler_func;
|
||||
};
|
||||
|
||||
static Uint8 *EnsureStreamBufferSize(SDL_AudioStream *stream, const int newlen)
|
||||
static Uint8 *EnsureStreamBufferSize(SDL_AudioStream *stream, int newlen)
|
||||
{
|
||||
Uint8 *ptr;
|
||||
size_t offset;
|
||||
@@ -870,7 +871,7 @@ static Uint8 *EnsureStreamBufferSize(SDL_AudioStream *stream, const int newlen)
|
||||
if (stream->work_buffer_len >= newlen) {
|
||||
ptr = stream->work_buffer_base;
|
||||
} else {
|
||||
ptr = (Uint8 *)SDL_realloc(stream->work_buffer_base, newlen + 32);
|
||||
ptr = (Uint8 *)SDL_realloc(stream->work_buffer_base, (size_t)newlen + 32);
|
||||
if (ptr == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
@@ -1006,7 +1007,7 @@ SDL_NewAudioStream(const SDL_AudioFormat src_format,
|
||||
const Uint8 dst_channels,
|
||||
const int dst_rate)
|
||||
{
|
||||
const int packetlen = 4096; /* !!! FIXME: good enough for now. */
|
||||
int packetlen = 4096; /* !!! FIXME: good enough for now. */
|
||||
Uint8 pre_resample_channels;
|
||||
SDL_AudioStream *retval;
|
||||
|
||||
@@ -1092,7 +1093,7 @@ SDL_NewAudioStream(const SDL_AudioFormat src_format,
|
||||
}
|
||||
}
|
||||
|
||||
retval->queue = SDL_NewDataQueue(packetlen, packetlen * 2);
|
||||
retval->queue = SDL_NewDataQueue(packetlen, (size_t)packetlen * 2);
|
||||
if (!retval->queue) {
|
||||
SDL_FreeAudioStream(retval);
|
||||
return NULL; /* SDL_NewDataQueue should have called SDL_SetError. */
|
||||
@@ -1384,7 +1385,7 @@ void SDL_AudioStreamClear(SDL_AudioStream *stream)
|
||||
if (stream == NULL) {
|
||||
SDL_InvalidParamError("stream");
|
||||
} else {
|
||||
SDL_ClearDataQueue(stream->queue, stream->packetlen * 2);
|
||||
SDL_ClearDataQueue(stream->queue, (size_t)stream->packetlen * 2);
|
||||
if (stream->reset_resampler_func) {
|
||||
stream->reset_resampler_func(stream);
|
||||
}
|
||||
|
||||
@@ -86,8 +86,11 @@ static void SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int cla
|
||||
}
|
||||
|
||||
/* Figure out what our audio device is */
|
||||
if (((audiodev = SDL_getenv("SDL_PATH_DSP")) == NULL) &&
|
||||
((audiodev = SDL_getenv("AUDIODEV")) == NULL)) {
|
||||
audiodev = SDL_getenv("SDL_PATH_DSP");
|
||||
if (audiodev == NULL) {
|
||||
audiodev = SDL_getenv("AUDIODEV");
|
||||
}
|
||||
if (audiodev == NULL) {
|
||||
if (classic) {
|
||||
audiodev = _PATH_DEV_AUDIO;
|
||||
} else {
|
||||
@@ -106,8 +109,8 @@ static void SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int cla
|
||||
if (SDL_strlen(audiodev) < (sizeof(audiopath) - 3)) {
|
||||
int instance = 0;
|
||||
while (instance <= 64) {
|
||||
SDL_snprintf(audiopath, SDL_arraysize(audiopath),
|
||||
"%s%d", audiodev, instance);
|
||||
(void)SDL_snprintf(audiopath, SDL_arraysize(audiopath),
|
||||
"%s%d", audiodev, instance);
|
||||
instance++;
|
||||
test_device(iscapture, audiopath, flags, test);
|
||||
}
|
||||
|
||||
@@ -1198,7 +1198,7 @@ static void SDLCALL SDL_Convert_F32_to_S8_NEON(SDL_AudioCVT *cvt, SDL_AudioForma
|
||||
static void SDLCALL SDL_Convert_F32_to_U8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||
{
|
||||
const float *src = (const float *)cvt->buf;
|
||||
Uint8 *dst = (Uint8 *)cvt->buf;
|
||||
Uint8 *dst = cvt->buf;
|
||||
int i;
|
||||
|
||||
LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_U8 (using NEON)");
|
||||
|
||||
@@ -549,20 +549,20 @@ static int MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
|
||||
cstate[c].coeff2 = ddata->coeff[coeffindex * 2 + 1];
|
||||
|
||||
/* Initial delta value. */
|
||||
o = channels + c * 2;
|
||||
o = (size_t)channels + c * 2;
|
||||
cstate[c].delta = state->block.data[o] | ((Uint16)state->block.data[o + 1] << 8);
|
||||
|
||||
/* Load the samples from the header. Interestingly, the sample later in
|
||||
* the output stream comes first.
|
||||
*/
|
||||
o = channels * 3 + c * 2;
|
||||
o = (size_t)channels * 3 + c * 2;
|
||||
sample = state->block.data[o] | ((Sint32)state->block.data[o + 1] << 8);
|
||||
if (sample >= 0x8000) {
|
||||
sample -= 0x10000;
|
||||
}
|
||||
state->output.data[state->output.pos + channels] = (Sint16)sample;
|
||||
|
||||
o = channels * 5 + c * 2;
|
||||
o = (size_t)channels * 5 + c * 2;
|
||||
sample = state->block.data[o] | ((Sint32)state->block.data[o + 1] << 8);
|
||||
if (sample >= 0x8000) {
|
||||
sample -= 0x10000;
|
||||
@@ -965,7 +965,7 @@ static int IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
|
||||
size_t i;
|
||||
int retval = 0;
|
||||
const Uint32 channels = state->channels;
|
||||
const size_t subblockframesize = channels * 4;
|
||||
const size_t subblockframesize = (size_t)channels * 4;
|
||||
Uint64 bytesrequired;
|
||||
Uint32 c;
|
||||
|
||||
|
||||
@@ -379,8 +379,9 @@ static void ALSA_PlayDevice(_THIS)
|
||||
status = ALSA_snd_pcm_recover(this->hidden->pcm_handle, status, 0);
|
||||
if (status < 0) {
|
||||
/* Hmm, not much we can do - abort */
|
||||
fprintf(stderr, "ALSA write failed (unrecoverable): %s\n",
|
||||
ALSA_snd_strerror(status));
|
||||
SDL_LogError(SDL_LOG_CATEGORY_AUDIO,
|
||||
"ALSA write failed (unrecoverable): %s\n",
|
||||
ALSA_snd_strerror(status));
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
return;
|
||||
}
|
||||
@@ -427,8 +428,9 @@ static int ALSA_CaptureFromDevice(_THIS, void *buffer, int buflen)
|
||||
status = ALSA_snd_pcm_recover(this->hidden->pcm_handle, status, 0);
|
||||
if (status < 0) {
|
||||
/* Hmm, not much we can do - abort */
|
||||
fprintf(stderr, "ALSA read failed (unrecoverable): %s\n",
|
||||
ALSA_snd_strerror(status));
|
||||
SDL_LogError(SDL_LOG_CATEGORY_AUDIO,
|
||||
"ALSA read failed (unrecoverable): %s\n",
|
||||
ALSA_snd_strerror(status));
|
||||
return -1;
|
||||
}
|
||||
continue;
|
||||
@@ -511,9 +513,9 @@ static int ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params)
|
||||
|
||||
ALSA_snd_pcm_hw_params_get_buffer_size(hwparams, &bufsize);
|
||||
|
||||
fprintf(stderr,
|
||||
"ALSA: period size = %ld, periods = %u, buffer size = %lu\n",
|
||||
persize, periods, bufsize);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_AUDIO,
|
||||
"ALSA: period size = %ld, periods = %u, buffer size = %lu\n",
|
||||
persize, periods, bufsize);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -739,7 +741,8 @@ static void add_device(const int iscapture, const char *name, void *hint, ALSA_D
|
||||
/* some strings have newlines, like "HDA NVidia, HDMI 0\nHDMI Audio Output".
|
||||
just chop the extra lines off, this seems to get a reasonable device
|
||||
name without extra details. */
|
||||
if ((ptr = SDL_strchr(desc, '\n')) != NULL) {
|
||||
ptr = SDL_strchr(desc, '\n');
|
||||
if (ptr != NULL) {
|
||||
*ptr = '\0';
|
||||
}
|
||||
|
||||
|
||||
@@ -102,17 +102,20 @@ static void build_device_list(int iscapture, addDevFn addfn, void *addfndata)
|
||||
|
||||
result = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject,
|
||||
&devlist_address, 0, NULL, &size);
|
||||
if (result != kAudioHardwareNoError)
|
||||
if (result != kAudioHardwareNoError) {
|
||||
return;
|
||||
}
|
||||
|
||||
devs = (AudioDeviceID *)alloca(size);
|
||||
if (devs == NULL)
|
||||
if (devs == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
||||
&devlist_address, 0, NULL, &size, devs);
|
||||
if (result != kAudioHardwareNoError)
|
||||
if (result != kAudioHardwareNoError) {
|
||||
return;
|
||||
}
|
||||
|
||||
max = size / sizeof(AudioDeviceID);
|
||||
for (i = 0; i < max; i++) {
|
||||
@@ -141,12 +144,14 @@ static void build_device_list(int iscapture, addDevFn addfn, void *addfndata)
|
||||
};
|
||||
|
||||
result = AudioObjectGetPropertyDataSize(dev, &addr, 0, NULL, &size);
|
||||
if (result != noErr)
|
||||
if (result != noErr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
buflist = (AudioBufferList *)SDL_malloc(size);
|
||||
if (buflist == NULL)
|
||||
if (buflist == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result = AudioObjectGetPropertyData(dev, &addr, 0, NULL,
|
||||
&size, buflist);
|
||||
@@ -161,8 +166,9 @@ static void build_device_list(int iscapture, addDevFn addfn, void *addfndata)
|
||||
|
||||
SDL_free(buflist);
|
||||
|
||||
if (spec.channels == 0)
|
||||
if (spec.channels == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
size = sizeof(sampleRate);
|
||||
result = AudioObjectGetPropertyData(dev, &freqaddr, 0, NULL, &size, &sampleRate);
|
||||
@@ -172,8 +178,9 @@ static void build_device_list(int iscapture, addDevFn addfn, void *addfndata)
|
||||
|
||||
size = sizeof(CFStringRef);
|
||||
result = AudioObjectGetPropertyData(dev, &nameaddr, 0, NULL, &size, &cfstr);
|
||||
if (result != kAudioHardwareNoError)
|
||||
if (result != kAudioHardwareNoError) {
|
||||
continue;
|
||||
}
|
||||
|
||||
len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(cfstr),
|
||||
kCFStringEncodingUTF8);
|
||||
@@ -540,8 +547,9 @@ static void outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBuffe
|
||||
if (SDL_AudioStreamAvailable(this->stream) > 0) {
|
||||
int got;
|
||||
UInt32 len = SDL_AudioStreamAvailable(this->stream);
|
||||
if (len > remaining)
|
||||
if (len > remaining) {
|
||||
len = remaining;
|
||||
}
|
||||
got = SDL_AudioStreamGet(this->stream, ptr, len);
|
||||
SDL_assert((got < 0) || (got == len));
|
||||
if (got != len) {
|
||||
@@ -985,7 +993,7 @@ static int audioqueue_thread(void *arg)
|
||||
}
|
||||
|
||||
if (!this->iscapture) { /* Drain off any pending playback. */
|
||||
const CFTimeInterval secs = (((this->spec.size / (SDL_AUDIO_BITSIZE(this->spec.format) / 8)) / this->spec.channels) / ((CFTimeInterval)this->spec.freq)) * 2.0;
|
||||
const CFTimeInterval secs = (((this->spec.size / (SDL_AUDIO_BITSIZE(this->spec.format) / 8.0)) / this->spec.channels) / ((CFTimeInterval)this->spec.freq)) * 2.0;
|
||||
CFRunLoopRunInMode(kCFRunLoopDefaultMode, secs, 0);
|
||||
}
|
||||
|
||||
@@ -1084,13 +1092,15 @@ static int COREAUDIO_OpenDevice(_THIS, const char *devname)
|
||||
}
|
||||
this->spec.format = test_format;
|
||||
strdesc->mBitsPerChannel = SDL_AUDIO_BITSIZE(test_format);
|
||||
if (SDL_AUDIO_ISBIGENDIAN(test_format))
|
||||
if (SDL_AUDIO_ISBIGENDIAN(test_format)) {
|
||||
strdesc->mFormatFlags |= kLinearPCMFormatFlagIsBigEndian;
|
||||
}
|
||||
|
||||
if (SDL_AUDIO_ISFLOAT(test_format))
|
||||
if (SDL_AUDIO_ISFLOAT(test_format)) {
|
||||
strdesc->mFormatFlags |= kLinearPCMFormatFlagIsFloat;
|
||||
else if (SDL_AUDIO_ISSIGNED(test_format))
|
||||
} else if (SDL_AUDIO_ISSIGNED(test_format)) {
|
||||
strdesc->mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger;
|
||||
}
|
||||
|
||||
strdesc->mBytesPerFrame = strdesc->mChannelsPerFrame * strdesc->mBitsPerChannel / 8;
|
||||
strdesc->mBytesPerPacket = strdesc->mBytesPerFrame * strdesc->mFramesPerPacket;
|
||||
@@ -1230,12 +1240,14 @@ static int COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int i
|
||||
spec->freq = (int)sampleRate;
|
||||
|
||||
result = AudioObjectGetPropertyDataSize(devid, &bufaddr, 0, NULL, &size);
|
||||
if (result != noErr)
|
||||
if (result != noErr) {
|
||||
return SDL_SetError("%s: Default Device Data Size not found", "coreaudio");
|
||||
}
|
||||
|
||||
buflist = (AudioBufferList *)SDL_malloc(size);
|
||||
if (buflist == NULL)
|
||||
if (buflist == NULL) {
|
||||
return SDL_SetError("%s: Default Device Buffer List not found", "coreaudio");
|
||||
}
|
||||
|
||||
result = AudioObjectGetPropertyData(devid, &bufaddr, 0, NULL,
|
||||
&size, buflist);
|
||||
|
||||
@@ -199,8 +199,8 @@ static int DSP_OpenDevice(_THIS, const char *devname)
|
||||
SDL_CalculateAudioSpec(&this->spec);
|
||||
|
||||
/* Determine the power of two of the fragment size */
|
||||
for (frag_spec = 0; (0x01U << frag_spec) < this->spec.size; ++frag_spec)
|
||||
;
|
||||
for (frag_spec = 0; (0x01U << frag_spec) < this->spec.size; ++frag_spec) {
|
||||
}
|
||||
if ((0x01U << frag_spec) != this->spec.size) {
|
||||
return SDL_SetError("Fragment size must be a power of two");
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ static int jackProcessPlaybackCallback(jack_nframes_t nframes, void *arg)
|
||||
for (channelsi = 0; channelsi < total_channels; channelsi++) {
|
||||
float *dst = (float *)JACK_jack_port_get_buffer(ports[channelsi], nframes);
|
||||
if (dst) {
|
||||
const float *src = ((float *)this->hidden->iobuffer) + channelsi;
|
||||
const float *src = this->hidden->iobuffer + channelsi;
|
||||
int framesi;
|
||||
for (framesi = 0; framesi < total_frames; framesi++) {
|
||||
*(dst++) = *src;
|
||||
@@ -202,7 +202,7 @@ static int jackProcessCaptureCallback(jack_nframes_t nframes, void *arg)
|
||||
for (channelsi = 0; channelsi < total_channels; channelsi++) {
|
||||
const float *src = (const float *)JACK_jack_port_get_buffer(ports[channelsi], nframes);
|
||||
if (src) {
|
||||
float *dst = ((float *)this->hidden->iobuffer) + channelsi;
|
||||
float *dst = this->hidden->iobuffer + channelsi;
|
||||
int framesi;
|
||||
for (framesi = 0; framesi < total_frames; framesi++) {
|
||||
*dst = *(src++);
|
||||
@@ -312,6 +312,7 @@ static int JACK_OpenDevice(_THIS, const char *devname)
|
||||
}
|
||||
}
|
||||
if (channels == 0) {
|
||||
SDL_free(audio_ports);
|
||||
return SDL_SetError("No physical JACK ports available");
|
||||
}
|
||||
|
||||
@@ -327,36 +328,42 @@ static int JACK_OpenDevice(_THIS, const char *devname)
|
||||
|
||||
this->hidden->iosem = SDL_CreateSemaphore(0);
|
||||
if (!this->hidden->iosem) {
|
||||
SDL_free(audio_ports);
|
||||
return -1; /* error was set by SDL_CreateSemaphore */
|
||||
}
|
||||
|
||||
this->hidden->iobuffer = (float *)SDL_calloc(1, this->spec.size);
|
||||
if (!this->hidden->iobuffer) {
|
||||
SDL_free(audio_ports);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
/* Build SDL's ports, which we will connect to the device ports. */
|
||||
this->hidden->sdlports = (jack_port_t **)SDL_calloc(channels, sizeof(jack_port_t *));
|
||||
if (this->hidden->sdlports == NULL) {
|
||||
SDL_free(audio_ports);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
for (i = 0; i < channels; i++) {
|
||||
char portname[32];
|
||||
SDL_snprintf(portname, sizeof(portname), "sdl_jack_%s_%d", sdlportstr, i);
|
||||
(void)SDL_snprintf(portname, sizeof(portname), "sdl_jack_%s_%d", sdlportstr, i);
|
||||
this->hidden->sdlports[i] = JACK_jack_port_register(client, portname, JACK_DEFAULT_AUDIO_TYPE, sdlportflags, 0);
|
||||
if (this->hidden->sdlports[i] == NULL) {
|
||||
SDL_free(audio_ports);
|
||||
return SDL_SetError("jack_port_register failed");
|
||||
}
|
||||
}
|
||||
|
||||
if (JACK_jack_set_process_callback(client, callback, this) != 0) {
|
||||
SDL_free(audio_ports);
|
||||
return SDL_SetError("JACK: Couldn't set process callback");
|
||||
}
|
||||
|
||||
JACK_jack_on_shutdown(client, jackShutdownCallback, this);
|
||||
|
||||
if (JACK_jack_activate(client) != 0) {
|
||||
SDL_free(audio_ports);
|
||||
return SDL_SetError("Failed to activate JACK client");
|
||||
}
|
||||
|
||||
@@ -366,6 +373,7 @@ static int JACK_OpenDevice(_THIS, const char *devname)
|
||||
const char *srcport = iscapture ? devports[audio_ports[i]] : sdlport;
|
||||
const char *dstport = iscapture ? sdlport : devports[audio_ports[i]];
|
||||
if (JACK_jack_connect(client, srcport, dstport) != 0) {
|
||||
SDL_free(audio_ports);
|
||||
return SDL_SetError("Couldn't connect JACK ports: %s => %s", srcport, dstport);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,11 +144,8 @@ static int pipewire_dlsym(const char *fn, void **addr)
|
||||
|
||||
static int load_pipewire_library()
|
||||
{
|
||||
if ((pipewire_handle = SDL_LoadObject(pipewire_library))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
pipewire_handle = SDL_LoadObject(pipewire_library);
|
||||
return pipewire_handle != NULL ? 0 : -1;
|
||||
}
|
||||
|
||||
static void unload_pipewire_library()
|
||||
@@ -966,7 +963,8 @@ static void output_callback(void *data)
|
||||
}
|
||||
|
||||
/* See if a buffer is available */
|
||||
if ((pw_buf = PIPEWIRE_pw_stream_dequeue_buffer(stream)) == NULL) {
|
||||
pw_buf = PIPEWIRE_pw_stream_dequeue_buffer(stream);
|
||||
if (pw_buf == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1035,8 +1033,8 @@ static void input_callback(void *data)
|
||||
}
|
||||
|
||||
spa_buf = pw_buf->buffer;
|
||||
|
||||
if ((src = (Uint8 *)spa_buf->datas[0].data) == NULL) {
|
||||
(src = (Uint8 *)spa_buf->datas[0].data);
|
||||
if (src == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1179,7 +1177,9 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
|
||||
return SDL_SetError("Pipewire: Failed to set audio format parameters");
|
||||
}
|
||||
|
||||
if ((this->hidden = priv = SDL_calloc(1, sizeof(struct SDL_PrivateAudioData))) == NULL) {
|
||||
priv = SDL_calloc(1, sizeof(struct SDL_PrivateAudioData));
|
||||
this->hidden = priv;
|
||||
if (priv == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -1191,7 +1191,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
|
||||
this->spec.size = this->spec.samples * priv->stride;
|
||||
}
|
||||
|
||||
SDL_snprintf(thread_name, sizeof(thread_name), "SDLAudio%c%ld", (iscapture) ? 'C' : 'P', (long)this->handle);
|
||||
(void)SDL_snprintf(thread_name, sizeof(thread_name), "SDLAudio%c%ld", (iscapture) ? 'C' : 'P', (long)this->handle);
|
||||
priv->loop = PIPEWIRE_pw_thread_loop_new(thread_name, NULL);
|
||||
if (priv->loop == NULL) {
|
||||
return SDL_SetError("Pipewire: Failed to create stream loop (%i)", errno);
|
||||
@@ -1234,7 +1234,8 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
|
||||
const struct io_node *node;
|
||||
|
||||
PIPEWIRE_pw_thread_loop_lock(hotplug_loop);
|
||||
if ((node = io_list_get_by_id(node_id))) {
|
||||
node = io_list_get_by_id(node_id);
|
||||
if (node != NULL) {
|
||||
PIPEWIRE_pw_properties_set(props, PW_KEY_TARGET_OBJECT, node->path);
|
||||
}
|
||||
PIPEWIRE_pw_thread_loop_unlock(hotplug_loop);
|
||||
|
||||
@@ -180,7 +180,8 @@ static int SNDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
|
||||
/* Emulate a blocking read */
|
||||
r = SNDIO_sio_read(this->hidden->dev, buffer, buflen);
|
||||
while (r == 0 && !SNDIO_sio_eof(this->hidden->dev)) {
|
||||
if ((nfds = SNDIO_sio_pollfd(this->hidden->dev, this->hidden->pfd, POLLIN)) <= 0 || poll(this->hidden->pfd, nfds, INFTIM) < 0) {
|
||||
nfds = SNDIO_sio_pollfd(this->hidden->dev, this->hidden->pfd, POLLIN);
|
||||
if (nfds <= 0 || poll(this->hidden->pfd, nfds, INFTIM) < 0) {
|
||||
return -1;
|
||||
}
|
||||
revents = SNDIO_sio_revents(this->hidden->dev, this->hidden->pfd);
|
||||
@@ -237,16 +238,18 @@ static int SNDIO_OpenDevice(_THIS, const char *devname)
|
||||
this->hidden->mixlen = this->spec.size;
|
||||
|
||||
/* Capture devices must be non-blocking for SNDIO_FlushCapture */
|
||||
if ((this->hidden->dev =
|
||||
SNDIO_sio_open(devname != NULL ? devname : SIO_DEVANY,
|
||||
iscapture ? SIO_REC : SIO_PLAY, iscapture)) == NULL) {
|
||||
this->hidden->dev = SNDIO_sio_open(devname != NULL ? devname : SIO_DEVANY,
|
||||
iscapture ? SIO_REC : SIO_PLAY, iscapture);
|
||||
if (this->hidden->dev == NULL) {
|
||||
return SDL_SetError("sio_open() failed");
|
||||
}
|
||||
|
||||
/* Allocate the pollfd array for capture devices */
|
||||
if (iscapture && (this->hidden->pfd =
|
||||
SDL_malloc(sizeof(struct pollfd) * SNDIO_sio_nfds(this->hidden->dev))) == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
if (iscapture) {
|
||||
this->hidden->pfd = SDL_malloc(sizeof(struct pollfd) * SNDIO_sio_nfds(this->hidden->dev));
|
||||
if (this->hidden->pfd == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
}
|
||||
|
||||
SNDIO_sio_initpar(&par);
|
||||
@@ -282,23 +285,23 @@ static int SNDIO_OpenDevice(_THIS, const char *devname)
|
||||
return SDL_SetError("%s: Unsupported audio format", "sndio");
|
||||
}
|
||||
|
||||
if ((par.bps == 4) && (par.sig) && (par.le))
|
||||
if ((par.bps == 4) && (par.sig) && (par.le)) {
|
||||
this->spec.format = AUDIO_S32LSB;
|
||||
else if ((par.bps == 4) && (par.sig) && (!par.le))
|
||||
} else if ((par.bps == 4) && (par.sig) && (!par.le)) {
|
||||
this->spec.format = AUDIO_S32MSB;
|
||||
else if ((par.bps == 2) && (par.sig) && (par.le))
|
||||
} else if ((par.bps == 2) && (par.sig) && (par.le)) {
|
||||
this->spec.format = AUDIO_S16LSB;
|
||||
else if ((par.bps == 2) && (par.sig) && (!par.le))
|
||||
} else if ((par.bps == 2) && (par.sig) && (!par.le)) {
|
||||
this->spec.format = AUDIO_S16MSB;
|
||||
else if ((par.bps == 2) && (!par.sig) && (par.le))
|
||||
} else if ((par.bps == 2) && (!par.sig) && (par.le)) {
|
||||
this->spec.format = AUDIO_U16LSB;
|
||||
else if ((par.bps == 2) && (!par.sig) && (!par.le))
|
||||
} else if ((par.bps == 2) && (!par.sig) && (!par.le)) {
|
||||
this->spec.format = AUDIO_U16MSB;
|
||||
else if ((par.bps == 1) && (par.sig))
|
||||
} else if ((par.bps == 1) && (par.sig)) {
|
||||
this->spec.format = AUDIO_S8;
|
||||
else if ((par.bps == 1) && (!par.sig))
|
||||
} else if ((par.bps == 1) && (!par.sig)) {
|
||||
this->spec.format = AUDIO_U8;
|
||||
else {
|
||||
} else {
|
||||
return SDL_SetError("sndio: Got unsupported hardware audio format.");
|
||||
}
|
||||
|
||||
|
||||
@@ -2480,7 +2480,6 @@ void Android_JNI_DestroyCustomCursor(int cursorID)
|
||||
{
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
(*env)->CallStaticVoidMethod(env, mActivityClass, midDestroyCustomCursor, cursorID);
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_bool Android_JNI_SetCustomCursor(int cursorID)
|
||||
|
||||
@@ -128,8 +128,7 @@ static int SDL_EVDEV_device_removed(const char *dev_path);
|
||||
|
||||
static int SDL_EVDEV_device_added(const char *dev_path, int udev_class);
|
||||
#if SDL_USE_LIBUDEV
|
||||
static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class,
|
||||
const char *dev_path);
|
||||
static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_class, const char *dev_path);
|
||||
#endif /* SDL_USE_LIBUDEV */
|
||||
|
||||
static Uint8 EVDEV_MouseButtons[] = {
|
||||
@@ -319,10 +318,11 @@ void SDL_EVDEV_Poll(void)
|
||||
next finger after earlist is released) */
|
||||
if (item->is_touchscreen && events[i].code == BTN_TOUCH) {
|
||||
if (item->touchscreen_data->max_slots == 1) {
|
||||
if (events[i].value)
|
||||
if (events[i].value) {
|
||||
item->touchscreen_data->slots[0].delta = EVDEV_TOUCH_SLOTDELTA_DOWN;
|
||||
else
|
||||
} else {
|
||||
item->touchscreen_data->slots[0].delta = EVDEV_TOUCH_SLOTDELTA_UP;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -820,8 +820,8 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
||||
/* For now, we just treat a touchpad like a touchscreen */
|
||||
if (udev_class & (SDL_UDEV_DEVICE_TOUCHSCREEN | SDL_UDEV_DEVICE_TOUCHPAD)) {
|
||||
item->is_touchscreen = SDL_TRUE;
|
||||
|
||||
if ((ret = SDL_EVDEV_init_touchscreen(item, udev_class)) < 0) {
|
||||
ret = SDL_EVDEV_init_touchscreen(item, udev_class);
|
||||
if (ret < 0) {
|
||||
close(item->fd);
|
||||
SDL_free(item->path);
|
||||
SDL_free(item);
|
||||
|
||||
@@ -37,10 +37,10 @@
|
||||
#endif
|
||||
|
||||
extern int
|
||||
SDL_EVDEV_GuessDeviceClass(unsigned long bitmask_ev[NBITS(EV_MAX)],
|
||||
unsigned long bitmask_abs[NBITS(ABS_MAX)],
|
||||
unsigned long bitmask_key[NBITS(KEY_MAX)],
|
||||
unsigned long bitmask_rel[NBITS(REL_MAX)])
|
||||
SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_ev[NBITS(EV_MAX)],
|
||||
const unsigned long bitmask_abs[NBITS(ABS_MAX)],
|
||||
const unsigned long bitmask_key[NBITS(KEY_MAX)],
|
||||
const unsigned long bitmask_rel[NBITS(REL_MAX)])
|
||||
{
|
||||
struct range
|
||||
{
|
||||
|
||||
@@ -47,10 +47,10 @@ typedef enum
|
||||
#define EVDEV_LONG(x) ((x) / BITS_PER_LONG)
|
||||
#define test_bit(bit, array) ((array[EVDEV_LONG(bit)] >> EVDEV_OFF(bit)) & 1)
|
||||
|
||||
extern int SDL_EVDEV_GuessDeviceClass(unsigned long bitmask_ev[NBITS(EV_MAX)],
|
||||
unsigned long bitmask_abs[NBITS(ABS_MAX)],
|
||||
unsigned long bitmask_key[NBITS(KEY_MAX)],
|
||||
unsigned long bitmask_rel[NBITS(REL_MAX)]);
|
||||
extern int SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_ev[NBITS(EV_MAX)],
|
||||
const unsigned long bitmask_abs[NBITS(ABS_MAX)],
|
||||
const unsigned long bitmask_key[NBITS(KEY_MAX)],
|
||||
const unsigned long bitmask_rel[NBITS(REL_MAX)]);
|
||||
|
||||
#endif /* HAVE_LINUX_INPUT_H */
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ static void kbd_cleanup(void)
|
||||
|
||||
static void SDL_EVDEV_kbd_reraise_signal(int sig)
|
||||
{
|
||||
raise(sig);
|
||||
(void)raise(sig);
|
||||
}
|
||||
|
||||
siginfo_t *SDL_EVDEV_kdb_cleanup_siginfo = NULL;
|
||||
@@ -303,7 +303,7 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd)
|
||||
* functions that are called when the shared library is unloaded.
|
||||
* -- man atexit(3)
|
||||
*/
|
||||
atexit(kbd_cleanup_atexit);
|
||||
(void)atexit(kbd_cleanup_atexit);
|
||||
kbd_cleanup_atexit_installed = 1;
|
||||
}
|
||||
|
||||
@@ -407,33 +407,33 @@ SDL_EVDEV_kbd_init(void)
|
||||
return kbd;
|
||||
}
|
||||
|
||||
void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd)
|
||||
void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state)
|
||||
{
|
||||
if (kbd == NULL) {
|
||||
if (state == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
kbd_unregister_emerg_cleanup();
|
||||
|
||||
if (kbd->console_fd >= 0) {
|
||||
if (state->console_fd >= 0) {
|
||||
/* Restore the original keyboard mode */
|
||||
ioctl(kbd->console_fd, KDSKBMODE, kbd->old_kbd_mode);
|
||||
ioctl(state->console_fd, KDSKBMODE, state->old_kbd_mode);
|
||||
|
||||
close(kbd->console_fd);
|
||||
kbd->console_fd = -1;
|
||||
close(state->console_fd);
|
||||
state->console_fd = -1;
|
||||
}
|
||||
|
||||
if (kbd->key_maps && kbd->key_maps != default_key_maps) {
|
||||
if (state->key_maps && state->key_maps != default_key_maps) {
|
||||
int i;
|
||||
for (i = 0; i < MAX_NR_KEYMAPS; ++i) {
|
||||
if (kbd->key_maps[i]) {
|
||||
SDL_free(kbd->key_maps[i]);
|
||||
if (state->key_maps[i]) {
|
||||
SDL_free(state->key_maps[i]);
|
||||
}
|
||||
}
|
||||
SDL_free(kbd->key_maps);
|
||||
SDL_free(state->key_maps);
|
||||
}
|
||||
|
||||
SDL_free(kbd);
|
||||
SDL_free(state);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -449,10 +449,9 @@ static void put_queue(SDL_EVDEV_keyboard_state *kbd, uint c)
|
||||
|
||||
static void put_utf8(SDL_EVDEV_keyboard_state *kbd, uint c)
|
||||
{
|
||||
if (c < 0x80)
|
||||
/* 0******* */
|
||||
put_queue(kbd, c);
|
||||
else if (c < 0x800) {
|
||||
if (c < 0x80) {
|
||||
put_queue(kbd, c); /* 0******* */
|
||||
} else if (c < 0x800) {
|
||||
/* 110***** 10****** */
|
||||
put_queue(kbd, 0xc0 | (c >> 6));
|
||||
put_queue(kbd, 0x80 | (c & 0x3f));
|
||||
@@ -626,8 +625,9 @@ static void k_self(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_f
|
||||
|
||||
static void k_deadunicode(SDL_EVDEV_keyboard_state *kbd, unsigned int value, char up_flag)
|
||||
{
|
||||
if (up_flag)
|
||||
if (up_flag) {
|
||||
return;
|
||||
}
|
||||
|
||||
kbd->diacr = (kbd->diacr ? handle_diacr(kbd, value) : value);
|
||||
}
|
||||
@@ -660,8 +660,9 @@ static void k_pad(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_fl
|
||||
{
|
||||
static const char pad_chars[] = "0123456789+-*/\015,.?()#";
|
||||
|
||||
if (up_flag)
|
||||
if (up_flag) {
|
||||
return; /* no action, if this is a key release */
|
||||
}
|
||||
|
||||
if (!vc_kbd_led(kbd, K_NUMLOCK)) {
|
||||
/* unprintable action */
|
||||
@@ -675,8 +676,9 @@ static void k_shift(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
|
||||
{
|
||||
int old_state = kbd->shift_state;
|
||||
|
||||
if (kbd->rep)
|
||||
if (kbd->rep) {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* Mimic typewriter:
|
||||
* a CapsShift key acts like Shift but undoes CapsLock
|
||||
@@ -696,13 +698,15 @@ static void k_shift(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
|
||||
if (kbd->shift_down[value]) {
|
||||
kbd->shift_down[value]--;
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
kbd->shift_down[value]++;
|
||||
}
|
||||
|
||||
if (kbd->shift_down[value])
|
||||
if (kbd->shift_down[value]) {
|
||||
kbd->shift_state |= (1 << value);
|
||||
else
|
||||
} else {
|
||||
kbd->shift_state &= ~(1 << value);
|
||||
}
|
||||
|
||||
/* kludge */
|
||||
if (up_flag && kbd->shift_state != old_state && kbd->npadch != -1) {
|
||||
@@ -719,8 +723,9 @@ static void k_ascii(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
|
||||
{
|
||||
int base;
|
||||
|
||||
if (up_flag)
|
||||
if (up_flag) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (value < 10) {
|
||||
/* decimal input of code, while Alt depressed */
|
||||
@@ -731,16 +736,18 @@ static void k_ascii(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
|
||||
base = 16;
|
||||
}
|
||||
|
||||
if (kbd->npadch == -1)
|
||||
if (kbd->npadch == -1) {
|
||||
kbd->npadch = value;
|
||||
else
|
||||
} else {
|
||||
kbd->npadch = kbd->npadch * base + value;
|
||||
}
|
||||
}
|
||||
|
||||
static void k_lock(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag)
|
||||
{
|
||||
if (up_flag || kbd->rep)
|
||||
if (up_flag || kbd->rep) {
|
||||
return;
|
||||
}
|
||||
|
||||
chg_vc_kbd_lock(kbd, value);
|
||||
}
|
||||
@@ -748,8 +755,9 @@ static void k_lock(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_f
|
||||
static void k_slock(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag)
|
||||
{
|
||||
k_shift(kbd, value, up_flag);
|
||||
if (up_flag || kbd->rep)
|
||||
if (up_flag || kbd->rep) {
|
||||
return;
|
||||
}
|
||||
|
||||
chg_vc_kbd_slock(kbd, value);
|
||||
/* try to make Alt, oops, AltGr and such work */
|
||||
@@ -763,26 +771,26 @@ static void k_brl(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_fl
|
||||
{
|
||||
}
|
||||
|
||||
void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, int down)
|
||||
void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down)
|
||||
{
|
||||
unsigned char shift_final;
|
||||
unsigned char type;
|
||||
unsigned short *key_map;
|
||||
unsigned short keysym;
|
||||
|
||||
if (kbd == NULL) {
|
||||
if (state == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
kbd->rep = (down == 2);
|
||||
state->rep = (down == 2);
|
||||
|
||||
shift_final = (kbd->shift_state | kbd->slockstate) ^ kbd->lockstate;
|
||||
key_map = kbd->key_maps[shift_final];
|
||||
shift_final = (state->shift_state | state->slockstate) ^ state->lockstate;
|
||||
key_map = state->key_maps[shift_final];
|
||||
if (key_map == NULL) {
|
||||
/* Unsupported shift state (e.g. ctrl = 4, alt = 8), just reset to the default state */
|
||||
kbd->shift_state = 0;
|
||||
kbd->slockstate = 0;
|
||||
kbd->lockstate = 0;
|
||||
state->shift_state = 0;
|
||||
state->slockstate = 0;
|
||||
state->lockstate = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -796,7 +804,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode,
|
||||
|
||||
if (type < 0xf0) {
|
||||
if (down) {
|
||||
put_utf8(kbd, keysym);
|
||||
put_utf8(state, keysym);
|
||||
}
|
||||
} else {
|
||||
type -= 0xf0;
|
||||
@@ -805,25 +813,25 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode,
|
||||
if (type == KT_LETTER) {
|
||||
type = KT_LATIN;
|
||||
|
||||
if (vc_kbd_led(kbd, K_CAPSLOCK)) {
|
||||
key_map = kbd->key_maps[shift_final ^ (1 << KG_SHIFT)];
|
||||
if (vc_kbd_led(state, K_CAPSLOCK)) {
|
||||
key_map = state->key_maps[shift_final ^ (1 << KG_SHIFT)];
|
||||
if (key_map) {
|
||||
keysym = key_map[keycode];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(*k_handler[type])(kbd, keysym & 0xff, !down);
|
||||
(*k_handler[type])(state, keysym & 0xff, !down);
|
||||
|
||||
if (type != KT_SLOCK) {
|
||||
kbd->slockstate = 0;
|
||||
state->slockstate = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (kbd->text_len > 0) {
|
||||
kbd->text[kbd->text_len] = '\0';
|
||||
SDL_SendKeyboardText(kbd->text);
|
||||
kbd->text_len = 0;
|
||||
if (state->text_len > 0) {
|
||||
state->text[state->text_len] = '\0';
|
||||
SDL_SendKeyboardText(state->text);
|
||||
state->text_len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,9 +64,9 @@ static char *GetAppName()
|
||||
int linksize;
|
||||
|
||||
#if defined(__LINUX__)
|
||||
SDL_snprintf(procfile, sizeof(procfile), "/proc/%d/exe", getpid());
|
||||
(void)SDL_snprintf(procfile, sizeof procfile, "/proc/%d/exe", getpid());
|
||||
#elif defined(__FREEBSD__)
|
||||
SDL_snprintf(procfile, sizeof(procfile), "/proc/%d/file", getpid());
|
||||
(void)SDL_snprintf(procfile, sizeof procfile, "/proc/%d/file", getpid());
|
||||
#endif
|
||||
linksize = readlink(procfile, linkfile, sizeof(linkfile) - 1);
|
||||
if (linksize > 0) {
|
||||
|
||||
@@ -324,7 +324,7 @@ static char *IBus_ReadAddressFromFile(const char *file_path)
|
||||
}
|
||||
}
|
||||
|
||||
fclose(addr_file);
|
||||
(void)fclose(addr_file);
|
||||
|
||||
if (success) {
|
||||
return SDL_strdup(addr_buf + (sizeof("IBUS_ADDRESS=") - 1));
|
||||
@@ -407,14 +407,14 @@ static char *IBus_GetDBusAddressFilename(void)
|
||||
SDL_free(display);
|
||||
return NULL;
|
||||
}
|
||||
SDL_snprintf(config_dir, sizeof(config_dir), "%s/.config", home_env);
|
||||
(void)SDL_snprintf(config_dir, sizeof config_dir, "%s/.config", home_env);
|
||||
}
|
||||
|
||||
key = dbus->get_local_machine_id();
|
||||
|
||||
SDL_memset(file_path, 0, sizeof(file_path));
|
||||
SDL_snprintf(file_path, sizeof(file_path), "%s/ibus/bus/%s-%s-%s",
|
||||
config_dir, key, host, disp_num);
|
||||
(void)SDL_snprintf(file_path, sizeof file_path, "%s/ibus/bus/%s-%s-%s",
|
||||
config_dir, key, host, disp_num);
|
||||
dbus->free(key);
|
||||
SDL_free(display);
|
||||
|
||||
@@ -488,7 +488,7 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
|
||||
|
||||
if (result) {
|
||||
char matchstr[128];
|
||||
SDL_snprintf(matchstr, sizeof(matchstr), "type='signal',interface='%s'", ibus_input_interface);
|
||||
(void)SDL_snprintf(matchstr, sizeof matchstr, "type='signal',interface='%s'", ibus_input_interface);
|
||||
SDL_free(input_ctx_path);
|
||||
input_ctx_path = SDL_strdup(path);
|
||||
SDL_AddHintCallback(SDL_HINT_IME_INTERNAL_EDITING, IBus_SetCapabilities, NULL);
|
||||
|
||||
@@ -268,10 +268,10 @@ WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
|
||||
}
|
||||
|
||||
ptr = (const unsigned char *)guid;
|
||||
SDL_snprintf(keystr, sizeof(keystr),
|
||||
"System\\CurrentControlSet\\Control\\MediaCategories\\{%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
|
||||
ptr[3], ptr[2], ptr[1], ptr[0], ptr[5], ptr[4], ptr[7], ptr[6],
|
||||
ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13], ptr[14], ptr[15]);
|
||||
(void)SDL_snprintf(keystr, sizeof keystr,
|
||||
"System\\CurrentControlSet\\Control\\MediaCategories\\{%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
|
||||
ptr[3], ptr[2], ptr[1], ptr[0], ptr[5], ptr[4], ptr[7], ptr[6],
|
||||
ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13], ptr[14], ptr[15]);
|
||||
|
||||
strw = WIN_UTF8ToString(keystr);
|
||||
rc = (RegOpenKeyExW(HKEY_LOCAL_MACHINE, strw, 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS);
|
||||
|
||||
+90
-90
@@ -179,7 +179,7 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
return;
|
||||
}
|
||||
|
||||
/* this is to make SDL_snprintf() calls cleaner. */
|
||||
/* this is to make (void)SDL_snprintf() calls cleaner. */
|
||||
#define uint unsigned int
|
||||
|
||||
name[0] = '\0';
|
||||
@@ -191,13 +191,13 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
char plusstr[16];
|
||||
SDL_strlcpy(name, "SDL_USEREVENT", sizeof(name));
|
||||
if (event->type > SDL_USEREVENT) {
|
||||
SDL_snprintf(plusstr, sizeof(plusstr), "+%u", ((uint)event->type) - SDL_USEREVENT);
|
||||
(void)SDL_snprintf(plusstr, sizeof(plusstr), "+%u", ((uint)event->type) - SDL_USEREVENT);
|
||||
} else {
|
||||
plusstr[0] = '\0';
|
||||
}
|
||||
SDL_snprintf(details, sizeof(details), "%s (timestamp=%u windowid=%u code=%d data1=%p data2=%p)",
|
||||
plusstr, (uint)event->user.timestamp, (uint)event->user.windowID,
|
||||
(int)event->user.code, event->user.data1, event->user.data2);
|
||||
(void)SDL_snprintf(details, sizeof(details), "%s (timestamp=%u windowid=%u code=%d data1=%p data2=%p)",
|
||||
plusstr, (uint)event->user.timestamp, (uint)event->user.windowID,
|
||||
(int)event->user.code, event->user.data1, event->user.data2);
|
||||
}
|
||||
|
||||
switch (event->type) {
|
||||
@@ -208,7 +208,7 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
SDL_strlcpy(details, " (THIS IS PROBABLY A BUG!)", sizeof(details));
|
||||
break;
|
||||
SDL_EVENT_CASE(SDL_QUIT)
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u)", (uint)event->quit.timestamp);
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u)", (uint)event->quit.timestamp);
|
||||
break;
|
||||
SDL_EVENT_CASE(SDL_APP_TERMINATING)
|
||||
break;
|
||||
@@ -252,8 +252,8 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
SDL_strlcpy(name2, "UNKNOWN (bug? fixme?)", sizeof(name2));
|
||||
break;
|
||||
}
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u display=%u event=%s data1=%d)",
|
||||
(uint)event->display.timestamp, (uint)event->display.display, name2, (int)event->display.data1);
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u display=%u event=%s data1=%d)",
|
||||
(uint)event->display.timestamp, (uint)event->display.display, name2, (int)event->display.data1);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -291,24 +291,24 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
SDL_strlcpy(name2, "UNKNOWN (bug? fixme?)", sizeof(name2));
|
||||
break;
|
||||
}
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u event=%s data1=%d data2=%d)",
|
||||
(uint)event->window.timestamp, (uint)event->window.windowID, name2, (int)event->window.data1, (int)event->window.data2);
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u event=%s data1=%d data2=%d)",
|
||||
(uint)event->window.timestamp, (uint)event->window.windowID, name2, (int)event->window.data1, (int)event->window.data2);
|
||||
break;
|
||||
}
|
||||
|
||||
SDL_EVENT_CASE(SDL_SYSWMEVENT)
|
||||
/* !!! FIXME: we don't delve further at the moment. */
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u)", (uint)event->syswm.timestamp);
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u)", (uint)event->syswm.timestamp);
|
||||
break;
|
||||
|
||||
#define PRINT_KEY_EVENT(event) \
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u state=%s repeat=%s scancode=%u keycode=%u mod=%u)", \
|
||||
(uint)event->key.timestamp, (uint)event->key.windowID, \
|
||||
event->key.state == SDL_PRESSED ? "pressed" : "released", \
|
||||
event->key.repeat ? "true" : "false", \
|
||||
(uint)event->key.keysym.scancode, \
|
||||
(uint)event->key.keysym.sym, \
|
||||
(uint)event->key.keysym.mod)
|
||||
#define PRINT_KEY_EVENT(event) \
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u state=%s repeat=%s scancode=%u keycode=%u mod=%u)", \
|
||||
(uint)event->key.timestamp, (uint)event->key.windowID, \
|
||||
event->key.state == SDL_PRESSED ? "pressed" : "released", \
|
||||
event->key.repeat ? "true" : "false", \
|
||||
(uint)event->key.keysym.scancode, \
|
||||
(uint)event->key.keysym.sym, \
|
||||
(uint)event->key.keysym.mod)
|
||||
SDL_EVENT_CASE(SDL_KEYDOWN)
|
||||
PRINT_KEY_EVENT(event);
|
||||
break;
|
||||
@@ -318,29 +318,29 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
#undef PRINT_KEY_EVENT
|
||||
|
||||
SDL_EVENT_CASE(SDL_TEXTEDITING)
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u text='%s' start=%d length=%d)",
|
||||
(uint)event->edit.timestamp, (uint)event->edit.windowID,
|
||||
event->edit.text, (int)event->edit.start, (int)event->edit.length);
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u text='%s' start=%d length=%d)",
|
||||
(uint)event->edit.timestamp, (uint)event->edit.windowID,
|
||||
event->edit.text, (int)event->edit.start, (int)event->edit.length);
|
||||
break;
|
||||
|
||||
SDL_EVENT_CASE(SDL_TEXTINPUT)
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u text='%s')", (uint)event->text.timestamp, (uint)event->text.windowID, event->text.text);
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u text='%s')", (uint)event->text.timestamp, (uint)event->text.windowID, event->text.text);
|
||||
break;
|
||||
|
||||
SDL_EVENT_CASE(SDL_MOUSEMOTION)
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u which=%u state=%u x=%d y=%d xrel=%d yrel=%d)",
|
||||
(uint)event->motion.timestamp, (uint)event->motion.windowID,
|
||||
(uint)event->motion.which, (uint)event->motion.state,
|
||||
(int)event->motion.x, (int)event->motion.y,
|
||||
(int)event->motion.xrel, (int)event->motion.yrel);
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u which=%u state=%u x=%d y=%d xrel=%d yrel=%d)",
|
||||
(uint)event->motion.timestamp, (uint)event->motion.windowID,
|
||||
(uint)event->motion.which, (uint)event->motion.state,
|
||||
(int)event->motion.x, (int)event->motion.y,
|
||||
(int)event->motion.xrel, (int)event->motion.yrel);
|
||||
break;
|
||||
|
||||
#define PRINT_MBUTTON_EVENT(event) \
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u which=%u button=%u state=%s clicks=%u x=%d y=%d)", \
|
||||
(uint)event->button.timestamp, (uint)event->button.windowID, \
|
||||
(uint)event->button.which, (uint)event->button.button, \
|
||||
event->button.state == SDL_PRESSED ? "pressed" : "released", \
|
||||
(uint)event->button.clicks, (int)event->button.x, (int)event->button.y)
|
||||
#define PRINT_MBUTTON_EVENT(event) \
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u which=%u button=%u state=%s clicks=%u x=%d y=%d)", \
|
||||
(uint)event->button.timestamp, (uint)event->button.windowID, \
|
||||
(uint)event->button.which, (uint)event->button.button, \
|
||||
event->button.state == SDL_PRESSED ? "pressed" : "released", \
|
||||
(uint)event->button.clicks, (int)event->button.x, (int)event->button.y)
|
||||
SDL_EVENT_CASE(SDL_MOUSEBUTTONDOWN)
|
||||
PRINT_MBUTTON_EVENT(event);
|
||||
break;
|
||||
@@ -350,35 +350,35 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
#undef PRINT_MBUTTON_EVENT
|
||||
|
||||
SDL_EVENT_CASE(SDL_MOUSEWHEEL)
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u which=%u x=%d y=%d preciseX=%f preciseY=%f direction=%s)",
|
||||
(uint)event->wheel.timestamp, (uint)event->wheel.windowID,
|
||||
(uint)event->wheel.which, (int)event->wheel.x, (int)event->wheel.y,
|
||||
event->wheel.preciseX, event->wheel.preciseY,
|
||||
event->wheel.direction == SDL_MOUSEWHEEL_NORMAL ? "normal" : "flipped");
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u which=%u x=%d y=%d preciseX=%f preciseY=%f direction=%s)",
|
||||
(uint)event->wheel.timestamp, (uint)event->wheel.windowID,
|
||||
(uint)event->wheel.which, (int)event->wheel.x, (int)event->wheel.y,
|
||||
event->wheel.preciseX, event->wheel.preciseY,
|
||||
event->wheel.direction == SDL_MOUSEWHEEL_NORMAL ? "normal" : "flipped");
|
||||
break;
|
||||
|
||||
SDL_EVENT_CASE(SDL_JOYAXISMOTION)
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d axis=%u value=%d)",
|
||||
(uint)event->jaxis.timestamp, (int)event->jaxis.which,
|
||||
(uint)event->jaxis.axis, (int)event->jaxis.value);
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d axis=%u value=%d)",
|
||||
(uint)event->jaxis.timestamp, (int)event->jaxis.which,
|
||||
(uint)event->jaxis.axis, (int)event->jaxis.value);
|
||||
break;
|
||||
|
||||
SDL_EVENT_CASE(SDL_JOYBALLMOTION)
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d ball=%u xrel=%d yrel=%d)",
|
||||
(uint)event->jball.timestamp, (int)event->jball.which,
|
||||
(uint)event->jball.ball, (int)event->jball.xrel, (int)event->jball.yrel);
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d ball=%u xrel=%d yrel=%d)",
|
||||
(uint)event->jball.timestamp, (int)event->jball.which,
|
||||
(uint)event->jball.ball, (int)event->jball.xrel, (int)event->jball.yrel);
|
||||
break;
|
||||
|
||||
SDL_EVENT_CASE(SDL_JOYHATMOTION)
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d hat=%u value=%u)",
|
||||
(uint)event->jhat.timestamp, (int)event->jhat.which,
|
||||
(uint)event->jhat.hat, (uint)event->jhat.value);
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d hat=%u value=%u)",
|
||||
(uint)event->jhat.timestamp, (int)event->jhat.which,
|
||||
(uint)event->jhat.hat, (uint)event->jhat.value);
|
||||
break;
|
||||
|
||||
#define PRINT_JBUTTON_EVENT(event) \
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d button=%u state=%s)", \
|
||||
(uint)event->jbutton.timestamp, (int)event->jbutton.which, \
|
||||
(uint)event->jbutton.button, event->jbutton.state == SDL_PRESSED ? "pressed" : "released")
|
||||
#define PRINT_JBUTTON_EVENT(event) \
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d button=%u state=%s)", \
|
||||
(uint)event->jbutton.timestamp, (int)event->jbutton.which, \
|
||||
(uint)event->jbutton.button, event->jbutton.state == SDL_PRESSED ? "pressed" : "released")
|
||||
SDL_EVENT_CASE(SDL_JOYBUTTONDOWN)
|
||||
PRINT_JBUTTON_EVENT(event);
|
||||
break;
|
||||
@@ -387,7 +387,7 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
break;
|
||||
#undef PRINT_JBUTTON_EVENT
|
||||
|
||||
#define PRINT_JOYDEV_EVENT(event) SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d)", (uint)event->jdevice.timestamp, (int)event->jdevice.which)
|
||||
#define PRINT_JOYDEV_EVENT(event) (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d)", (uint)event->jdevice.timestamp, (int)event->jdevice.which)
|
||||
SDL_EVENT_CASE(SDL_JOYDEVICEADDED)
|
||||
PRINT_JOYDEV_EVENT(event);
|
||||
break;
|
||||
@@ -397,15 +397,15 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
#undef PRINT_JOYDEV_EVENT
|
||||
|
||||
SDL_EVENT_CASE(SDL_CONTROLLERAXISMOTION)
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d axis=%u value=%d)",
|
||||
(uint)event->caxis.timestamp, (int)event->caxis.which,
|
||||
(uint)event->caxis.axis, (int)event->caxis.value);
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d axis=%u value=%d)",
|
||||
(uint)event->caxis.timestamp, (int)event->caxis.which,
|
||||
(uint)event->caxis.axis, (int)event->caxis.value);
|
||||
break;
|
||||
|
||||
#define PRINT_CBUTTON_EVENT(event) \
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d button=%u state=%s)", \
|
||||
(uint)event->cbutton.timestamp, (int)event->cbutton.which, \
|
||||
(uint)event->cbutton.button, event->cbutton.state == SDL_PRESSED ? "pressed" : "released")
|
||||
#define PRINT_CBUTTON_EVENT(event) \
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d button=%u state=%s)", \
|
||||
(uint)event->cbutton.timestamp, (int)event->cbutton.which, \
|
||||
(uint)event->cbutton.button, event->cbutton.state == SDL_PRESSED ? "pressed" : "released")
|
||||
SDL_EVENT_CASE(SDL_CONTROLLERBUTTONDOWN)
|
||||
PRINT_CBUTTON_EVENT(event);
|
||||
break;
|
||||
@@ -414,7 +414,7 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
break;
|
||||
#undef PRINT_CBUTTON_EVENT
|
||||
|
||||
#define PRINT_CONTROLLERDEV_EVENT(event) SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d)", (uint)event->cdevice.timestamp, (int)event->cdevice.which)
|
||||
#define PRINT_CONTROLLERDEV_EVENT(event) (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d)", (uint)event->cdevice.timestamp, (int)event->cdevice.which)
|
||||
SDL_EVENT_CASE(SDL_CONTROLLERDEVICEADDED)
|
||||
PRINT_CONTROLLERDEV_EVENT(event);
|
||||
break;
|
||||
@@ -426,11 +426,11 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
break;
|
||||
#undef PRINT_CONTROLLERDEV_EVENT
|
||||
|
||||
#define PRINT_CTOUCHPAD_EVENT(event) \
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d touchpad=%d finger=%d x=%f y=%f pressure=%f)", \
|
||||
(uint)event->ctouchpad.timestamp, (int)event->ctouchpad.which, \
|
||||
(int)event->ctouchpad.touchpad, (int)event->ctouchpad.finger, \
|
||||
event->ctouchpad.x, event->ctouchpad.y, event->ctouchpad.pressure)
|
||||
#define PRINT_CTOUCHPAD_EVENT(event) \
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d touchpad=%d finger=%d x=%f y=%f pressure=%f)", \
|
||||
(uint)event->ctouchpad.timestamp, (int)event->ctouchpad.which, \
|
||||
(int)event->ctouchpad.touchpad, (int)event->ctouchpad.finger, \
|
||||
event->ctouchpad.x, event->ctouchpad.y, event->ctouchpad.pressure)
|
||||
SDL_EVENT_CASE(SDL_CONTROLLERTOUCHPADDOWN)
|
||||
PRINT_CTOUCHPAD_EVENT(event);
|
||||
break;
|
||||
@@ -443,16 +443,16 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
#undef PRINT_CTOUCHPAD_EVENT
|
||||
|
||||
SDL_EVENT_CASE(SDL_CONTROLLERSENSORUPDATE)
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d sensor=%d data[0]=%f data[1]=%f data[2]=%f)",
|
||||
(uint)event->csensor.timestamp, (int)event->csensor.which, (int)event->csensor.sensor,
|
||||
event->csensor.data[0], event->csensor.data[1], event->csensor.data[2]);
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d sensor=%d data[0]=%f data[1]=%f data[2]=%f)",
|
||||
(uint)event->csensor.timestamp, (int)event->csensor.which, (int)event->csensor.sensor,
|
||||
event->csensor.data[0], event->csensor.data[1], event->csensor.data[2]);
|
||||
break;
|
||||
|
||||
#define PRINT_FINGER_EVENT(event) \
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u touchid=%" SDL_PRIs64 " fingerid=%" SDL_PRIs64 " x=%f y=%f dx=%f dy=%f pressure=%f)", \
|
||||
(uint)event->tfinger.timestamp, (long long)event->tfinger.touchId, \
|
||||
(long long)event->tfinger.fingerId, event->tfinger.x, event->tfinger.y, \
|
||||
event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure)
|
||||
#define PRINT_FINGER_EVENT(event) \
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u touchid=%" SDL_PRIs64 " fingerid=%" SDL_PRIs64 " x=%f y=%f dx=%f dy=%f pressure=%f)", \
|
||||
(uint)event->tfinger.timestamp, (long long)event->tfinger.touchId, \
|
||||
(long long)event->tfinger.fingerId, event->tfinger.x, event->tfinger.y, \
|
||||
event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure)
|
||||
SDL_EVENT_CASE(SDL_FINGERDOWN)
|
||||
PRINT_FINGER_EVENT(event);
|
||||
break;
|
||||
@@ -464,11 +464,11 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
break;
|
||||
#undef PRINT_FINGER_EVENT
|
||||
|
||||
#define PRINT_DOLLAR_EVENT(event) \
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u touchid=%" SDL_PRIs64 " gestureid=%" SDL_PRIs64 " numfingers=%u error=%f x=%f y=%f)", \
|
||||
(uint)event->dgesture.timestamp, (long long)event->dgesture.touchId, \
|
||||
(long long)event->dgesture.gestureId, (uint)event->dgesture.numFingers, \
|
||||
event->dgesture.error, event->dgesture.x, event->dgesture.y)
|
||||
#define PRINT_DOLLAR_EVENT(event) \
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u touchid=%" SDL_PRIs64 " gestureid=%" SDL_PRIs64 " numfingers=%u error=%f x=%f y=%f)", \
|
||||
(uint)event->dgesture.timestamp, (long long)event->dgesture.touchId, \
|
||||
(long long)event->dgesture.gestureId, (uint)event->dgesture.numFingers, \
|
||||
event->dgesture.error, event->dgesture.x, event->dgesture.y)
|
||||
SDL_EVENT_CASE(SDL_DOLLARGESTURE)
|
||||
PRINT_DOLLAR_EVENT(event);
|
||||
break;
|
||||
@@ -478,13 +478,13 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
#undef PRINT_DOLLAR_EVENT
|
||||
|
||||
SDL_EVENT_CASE(SDL_MULTIGESTURE)
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u touchid=%" SDL_PRIs64 " dtheta=%f ddist=%f x=%f y=%f numfingers=%u)",
|
||||
(uint)event->mgesture.timestamp, (long long)event->mgesture.touchId,
|
||||
event->mgesture.dTheta, event->mgesture.dDist,
|
||||
event->mgesture.x, event->mgesture.y, (uint)event->mgesture.numFingers);
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u touchid=%" SDL_PRIs64 " dtheta=%f ddist=%f x=%f y=%f numfingers=%u)",
|
||||
(uint)event->mgesture.timestamp, (long long)event->mgesture.touchId,
|
||||
event->mgesture.dTheta, event->mgesture.dDist,
|
||||
event->mgesture.x, event->mgesture.y, (uint)event->mgesture.numFingers);
|
||||
break;
|
||||
|
||||
#define PRINT_DROP_EVENT(event) SDL_snprintf(details, sizeof(details), " (file='%s' timestamp=%u windowid=%u)", event->drop.file, (uint)event->drop.timestamp, (uint)event->drop.windowID)
|
||||
#define PRINT_DROP_EVENT(event) (void)SDL_snprintf(details, sizeof(details), " (file='%s' timestamp=%u windowid=%u)", event->drop.file, (uint)event->drop.timestamp, (uint)event->drop.windowID)
|
||||
SDL_EVENT_CASE(SDL_DROPFILE)
|
||||
PRINT_DROP_EVENT(event);
|
||||
break;
|
||||
@@ -499,7 +499,7 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
break;
|
||||
#undef PRINT_DROP_EVENT
|
||||
|
||||
#define PRINT_AUDIODEV_EVENT(event) SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%u iscapture=%s)", (uint)event->adevice.timestamp, (uint)event->adevice.which, event->adevice.iscapture ? "true" : "false")
|
||||
#define PRINT_AUDIODEV_EVENT(event) (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%u iscapture=%s)", (uint)event->adevice.timestamp, (uint)event->adevice.which, event->adevice.iscapture ? "true" : "false")
|
||||
SDL_EVENT_CASE(SDL_AUDIODEVICEADDED)
|
||||
PRINT_AUDIODEV_EVENT(event);
|
||||
break;
|
||||
@@ -509,10 +509,10 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
#undef PRINT_AUDIODEV_EVENT
|
||||
|
||||
SDL_EVENT_CASE(SDL_SENSORUPDATE)
|
||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d data[0]=%f data[1]=%f data[2]=%f data[3]=%f data[4]=%f data[5]=%f)",
|
||||
(uint)event->sensor.timestamp, (int)event->sensor.which,
|
||||
event->sensor.data[0], event->sensor.data[1], event->sensor.data[2],
|
||||
event->sensor.data[3], event->sensor.data[4], event->sensor.data[5]);
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d data[0]=%f data[1]=%f data[2]=%f data[3]=%f data[4]=%f data[5]=%f)",
|
||||
(uint)event->sensor.timestamp, (int)event->sensor.which,
|
||||
event->sensor.data[0], event->sensor.data[1], event->sensor.data[2],
|
||||
event->sensor.data[3], event->sensor.data[4], event->sensor.data[5]);
|
||||
break;
|
||||
|
||||
#undef SDL_EVENT_CASE
|
||||
@@ -524,7 +524,7 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
default:
|
||||
if (!name[0]) {
|
||||
SDL_strlcpy(name, "UNKNOWN", sizeof(name));
|
||||
SDL_snprintf(details, sizeof(details), " #%u! (Bug? FIXME?)", (uint)event->type);
|
||||
(void)SDL_snprintf(details, sizeof(details), " #%u! (Bug? FIXME?)", (uint)event->type);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1154,10 +1154,11 @@ SDL_GetScancodeName(SDL_Scancode scancode)
|
||||
}
|
||||
|
||||
name = SDL_scancode_names[scancode];
|
||||
if (name)
|
||||
if (name != NULL) {
|
||||
return name;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
SDL_Scancode SDL_GetScancodeFromName(const char *name)
|
||||
|
||||
@@ -70,7 +70,7 @@ extern SDL_bool SDL_HardwareKeyboardKeyPressed(void);
|
||||
extern int SDL_SendKeyboardText(const char *text);
|
||||
|
||||
/* Send editing text for selected range from start to end */
|
||||
extern int SDL_SendEditingText(const char *text, int start, int end);
|
||||
extern int SDL_SendEditingText(const char *text, int start, int length);
|
||||
|
||||
/* Shutdown the keyboard subsystem */
|
||||
extern void SDL_KeyboardQuit(void);
|
||||
|
||||
@@ -381,7 +381,7 @@ static int GetScaledMouseDelta(float scale, int value, float *accum)
|
||||
return value;
|
||||
}
|
||||
|
||||
static float CalculateSystemScale(SDL_Mouse *mouse, int *x, int *y)
|
||||
static float CalculateSystemScale(SDL_Mouse *mouse, const int *x, const int *y)
|
||||
{
|
||||
int i;
|
||||
int n = mouse->num_system_scale_values;
|
||||
|
||||
@@ -50,7 +50,7 @@ static SDL_bool send_foregrounding_pending = SDL_FALSE;
|
||||
static void SDL_HandleSIG(int sig)
|
||||
{
|
||||
/* Reset the signal handler */
|
||||
signal(sig, SDL_HandleSIG);
|
||||
(void)signal(sig, SDL_HandleSIG);
|
||||
|
||||
/* Send a quit event next time the event loop pumps. */
|
||||
/* We can't send it in signal handler; SDL_malloc() might be interrupted! */
|
||||
|
||||
@@ -722,7 +722,7 @@ void SDL_FreeRW(SDL_RWops *area)
|
||||
void *
|
||||
SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, int freesrc)
|
||||
{
|
||||
const int FILE_CHUNK_SIZE = 1024;
|
||||
static const Sint64 FILE_CHUNK_SIZE = 1024;
|
||||
Sint64 size;
|
||||
size_t size_read, size_total;
|
||||
void *data = NULL, *newdata;
|
||||
|
||||
@@ -42,7 +42,7 @@ FILE *SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode)
|
||||
NSString *full_path_with_file_to_try;
|
||||
|
||||
/* If the file mode is writable, skip all the bundle stuff because generally the bundle is read-only. */
|
||||
if (strcmp("r", mode) && strcmp("rb", mode)) {
|
||||
if (SDL_strchr(mode, 'r') == NULL) {
|
||||
return fopen(file, mode);
|
||||
}
|
||||
|
||||
|
||||
@@ -321,9 +321,9 @@ SDL_GetPrefPath(const char *org, const char *app)
|
||||
}
|
||||
|
||||
if (*org) {
|
||||
SDL_snprintf(retval, len, "%s%s%s/%s/", envr, append, org, app);
|
||||
(void)SDL_snprintf(retval, len, "%s%s%s/%s/", envr, append, org, app);
|
||||
} else {
|
||||
SDL_snprintf(retval, len, "%s%s%s/", envr, append, app);
|
||||
(void)SDL_snprintf(retval, len, "%s%s%s/", envr, append, app);
|
||||
}
|
||||
|
||||
for (ptr = retval + 1; *ptr; ptr++) {
|
||||
|
||||
@@ -240,12 +240,13 @@ int SDL_JoystickIsHaptic(SDL_Joystick *joystick)
|
||||
|
||||
ret = SDL_SYS_JoystickIsHaptic(joystick);
|
||||
|
||||
if (ret > 0)
|
||||
if (ret > 0) {
|
||||
return SDL_TRUE;
|
||||
else if (ret == 0)
|
||||
} else if (ret == 0) {
|
||||
return SDL_FALSE;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -167,7 +167,6 @@ void SDL_SYS_HapticClose(SDL_Haptic *haptic)
|
||||
{
|
||||
((SDL_hapticlist_item *)haptic->hwdata)->haptic = NULL;
|
||||
haptic->hwdata = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
void SDL_SYS_HapticQuit(void)
|
||||
@@ -223,11 +222,9 @@ int SDL_SYS_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
|
||||
|
||||
void SDL_SYS_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic,
|
||||
struct haptic_effect *effect)
|
||||
int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *effect)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1204,8 +1204,9 @@ int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
|
||||
/* Check if it's infinite. */
|
||||
if (iterations == SDL_HAPTIC_INFINITY) {
|
||||
iter = FF_INFINITE;
|
||||
} else
|
||||
} else {
|
||||
iter = iterations;
|
||||
}
|
||||
|
||||
/* Run the effect. */
|
||||
ret = FFEffectStart(effect->hweffect->ref, iter, 0);
|
||||
|
||||
@@ -160,8 +160,7 @@ int SDL_SYS_HapticInit(void)
|
||||
*/
|
||||
i = 0;
|
||||
for (j = 0; j < MAX_HAPTICS; ++j) {
|
||||
|
||||
SDL_snprintf(path, PATH_MAX, joydev_pattern, i++);
|
||||
(void)SDL_snprintf(path, PATH_MAX, joydev_pattern, i++);
|
||||
MaybeAddDevice(path);
|
||||
}
|
||||
|
||||
@@ -673,9 +672,9 @@ static int SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection *src)
|
||||
break;
|
||||
|
||||
case SDL_HAPTIC_CARTESIAN:
|
||||
if (!src->dir[1])
|
||||
if (!src->dir[1]) {
|
||||
*dest = (src->dir[0] >= 0 ? 0x4000 : 0xC000);
|
||||
else if (!src->dir[0])
|
||||
} else if (!src->dir[0]) {
|
||||
*dest = (src->dir[1] >= 0 ? 0x8000 : 0);
|
||||
else {
|
||||
float f = SDL_atan2(src->dir[1], src->dir[0]); /* Ideally we'd use fixed point math instead of floats... */
|
||||
|
||||
@@ -664,10 +664,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||
dest->lpvTypeSpecificParams = constant;
|
||||
|
||||
/* Generics */
|
||||
dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */
|
||||
dest->dwDuration = hap_constant->length * 1000UL; /* In microseconds. */
|
||||
dest->dwTriggerButton = DIGetTriggerButton(hap_constant->button);
|
||||
dest->dwTriggerRepeatInterval = hap_constant->interval;
|
||||
dest->dwStartDelay = hap_constant->delay * 1000; /* In microseconds. */
|
||||
dest->dwStartDelay = hap_constant->delay * 1000UL; /* In microseconds. */
|
||||
|
||||
/* Direction. */
|
||||
if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) {
|
||||
@@ -680,9 +680,9 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||
dest->lpEnvelope = NULL;
|
||||
} else {
|
||||
envelope->dwAttackLevel = CCONVERT(hap_constant->attack_level);
|
||||
envelope->dwAttackTime = hap_constant->attack_length * 1000;
|
||||
envelope->dwAttackTime = hap_constant->attack_length * 1000UL;
|
||||
envelope->dwFadeLevel = CCONVERT(hap_constant->fade_level);
|
||||
envelope->dwFadeTime = hap_constant->fade_length * 1000;
|
||||
envelope->dwFadeTime = hap_constant->fade_length * 1000UL;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -710,10 +710,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||
dest->lpvTypeSpecificParams = periodic;
|
||||
|
||||
/* Generics */
|
||||
dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */
|
||||
dest->dwDuration = hap_periodic->length * 1000UL; /* In microseconds. */
|
||||
dest->dwTriggerButton = DIGetTriggerButton(hap_periodic->button);
|
||||
dest->dwTriggerRepeatInterval = hap_periodic->interval;
|
||||
dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */
|
||||
dest->dwStartDelay = hap_periodic->delay * 1000UL; /* In microseconds. */
|
||||
|
||||
/* Direction. */
|
||||
if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) {
|
||||
@@ -726,9 +726,9 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||
dest->lpEnvelope = NULL;
|
||||
} else {
|
||||
envelope->dwAttackLevel = CCONVERT(hap_periodic->attack_level);
|
||||
envelope->dwAttackTime = hap_periodic->attack_length * 1000;
|
||||
envelope->dwAttackTime = hap_periodic->attack_length * 1000UL;
|
||||
envelope->dwFadeLevel = CCONVERT(hap_periodic->fade_level);
|
||||
envelope->dwFadeTime = hap_periodic->fade_length * 1000;
|
||||
envelope->dwFadeTime = hap_periodic->fade_length * 1000UL;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -761,10 +761,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||
dest->lpvTypeSpecificParams = condition;
|
||||
|
||||
/* Generics */
|
||||
dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */
|
||||
dest->dwDuration = hap_condition->length * 1000UL; /* In microseconds. */
|
||||
dest->dwTriggerButton = DIGetTriggerButton(hap_condition->button);
|
||||
dest->dwTriggerRepeatInterval = hap_condition->interval;
|
||||
dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */
|
||||
dest->dwStartDelay = hap_condition->delay * 1000UL; /* In microseconds. */
|
||||
|
||||
/* Direction. */
|
||||
if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) {
|
||||
@@ -792,10 +792,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||
dest->lpvTypeSpecificParams = ramp;
|
||||
|
||||
/* Generics */
|
||||
dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */
|
||||
dest->dwDuration = hap_ramp->length * 1000UL; /* In microseconds. */
|
||||
dest->dwTriggerButton = DIGetTriggerButton(hap_ramp->button);
|
||||
dest->dwTriggerRepeatInterval = hap_ramp->interval;
|
||||
dest->dwStartDelay = hap_ramp->delay * 1000; /* In microseconds. */
|
||||
dest->dwStartDelay = hap_ramp->delay * 1000UL; /* In microseconds. */
|
||||
|
||||
/* Direction. */
|
||||
if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) {
|
||||
@@ -808,9 +808,9 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||
dest->lpEnvelope = NULL;
|
||||
} else {
|
||||
envelope->dwAttackLevel = CCONVERT(hap_ramp->attack_level);
|
||||
envelope->dwAttackTime = hap_ramp->attack_length * 1000;
|
||||
envelope->dwAttackTime = hap_ramp->attack_length * 1000UL;
|
||||
envelope->dwFadeLevel = CCONVERT(hap_ramp->fade_level);
|
||||
envelope->dwFadeTime = hap_ramp->fade_length * 1000;
|
||||
envelope->dwFadeTime = hap_ramp->fade_length * 1000UL;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -825,7 +825,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||
|
||||
/* Specifics */
|
||||
custom->cChannels = hap_custom->channels;
|
||||
custom->dwSamplePeriod = hap_custom->period * 1000;
|
||||
custom->dwSamplePeriod = hap_custom->period * 1000UL;
|
||||
custom->cSamples = hap_custom->samples;
|
||||
custom->rglForceData =
|
||||
SDL_malloc(sizeof(LONG) * custom->cSamples * custom->cChannels);
|
||||
@@ -836,10 +836,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||
dest->lpvTypeSpecificParams = custom;
|
||||
|
||||
/* Generics */
|
||||
dest->dwDuration = hap_custom->length * 1000; /* In microseconds. */
|
||||
dest->dwDuration = hap_custom->length * 1000UL; /* In microseconds. */
|
||||
dest->dwTriggerButton = DIGetTriggerButton(hap_custom->button);
|
||||
dest->dwTriggerRepeatInterval = hap_custom->interval;
|
||||
dest->dwStartDelay = hap_custom->delay * 1000; /* In microseconds. */
|
||||
dest->dwStartDelay = hap_custom->delay * 1000UL; /* In microseconds. */
|
||||
|
||||
/* Direction. */
|
||||
if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) < 0) {
|
||||
@@ -852,9 +852,9 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||
dest->lpEnvelope = NULL;
|
||||
} else {
|
||||
envelope->dwAttackLevel = CCONVERT(hap_custom->attack_level);
|
||||
envelope->dwAttackTime = hap_custom->attack_length * 1000;
|
||||
envelope->dwAttackTime = hap_custom->attack_length * 1000UL;
|
||||
envelope->dwFadeLevel = CCONVERT(hap_custom->fade_level);
|
||||
envelope->dwFadeTime = hap_custom->fade_length * 1000;
|
||||
envelope->dwFadeTime = hap_custom->fade_length * 1000UL;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -893,6 +893,7 @@ static void SDL_SYS_HapticFreeDIEFFECT(DIEFFECT *effect, int type)
|
||||
/*
|
||||
* Gets the effect type from the generic SDL haptic effect wrapper.
|
||||
*/
|
||||
/* NOLINTNEXTLINE(readability-const-return-type): Can't fix Windows' headers */
|
||||
static REFGUID SDL_SYS_HapticEffectType(SDL_HapticEffect *effect)
|
||||
{
|
||||
switch (effect->type) {
|
||||
@@ -1088,7 +1089,7 @@ int SDL_DINPUT_HapticSetGain(SDL_Haptic *haptic, int gain)
|
||||
dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
||||
dipdw.diph.dwObj = 0;
|
||||
dipdw.diph.dwHow = DIPH_DEVICE;
|
||||
dipdw.dwData = gain * 100; /* 0 to 10,000 */
|
||||
dipdw.dwData = (DWORD)gain * 100; /* 0 to 10,000 */
|
||||
|
||||
/* Try to set the autocenter. */
|
||||
ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device,
|
||||
|
||||
@@ -93,7 +93,7 @@ int SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid)
|
||||
/* !!! FIXME: I'm not bothering to query for a real name right now (can we even?) */
|
||||
{
|
||||
char buf[64];
|
||||
SDL_snprintf(buf, sizeof(buf), "XInput Controller #%u", (unsigned int)(userid + 1));
|
||||
(void)SDL_snprintf(buf, sizeof buf, "XInput Controller #%u", userid + 1);
|
||||
item->name = SDL_strdup(buf);
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us
|
||||
return SDL_SetError("Couldn't create XInput haptic mutex");
|
||||
}
|
||||
|
||||
SDL_snprintf(threadName, sizeof(threadName), "SDLXInputDev%d", (int)userid);
|
||||
(void)SDL_snprintf(threadName, sizeof threadName, "SDLXInputDev%u", userid);
|
||||
haptic->hwdata->thread = SDL_CreateThreadInternal(SDL_RunXInputHaptic, threadName, 64 * 1024, haptic->hwdata);
|
||||
|
||||
if (haptic->hwdata->thread == NULL) {
|
||||
|
||||
+36
-23
@@ -57,7 +57,6 @@
|
||||
#include "../core/linux/SDL_udev.h"
|
||||
#ifdef SDL_USE_LIBUDEV
|
||||
#include <poll.h>
|
||||
#include <unistd.h>
|
||||
#include "../core/linux/SDL_sandbox.h"
|
||||
#endif
|
||||
|
||||
@@ -69,6 +68,10 @@
|
||||
#include <sys/inotify.h>
|
||||
#endif
|
||||
|
||||
#if defined(SDL_USE_LIBUDEV) || defined(HAVE_INOTIFY)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(SDL_USE_LIBUDEV)
|
||||
typedef enum
|
||||
{
|
||||
@@ -316,15 +319,15 @@ HIDAPI_InitializeDiscovery()
|
||||
SDL_HIDAPI_discovery.m_nUdevFd = -1;
|
||||
|
||||
usyms = SDL_UDEV_GetUdevSyms();
|
||||
if (usyms) {
|
||||
if (usyms != NULL) {
|
||||
SDL_HIDAPI_discovery.m_pUdev = usyms->udev_new();
|
||||
}
|
||||
if (SDL_HIDAPI_discovery.m_pUdev) {
|
||||
SDL_HIDAPI_discovery.m_pUdevMonitor = usyms->udev_monitor_new_from_netlink(SDL_HIDAPI_discovery.m_pUdev, "udev");
|
||||
if (SDL_HIDAPI_discovery.m_pUdevMonitor) {
|
||||
usyms->udev_monitor_enable_receiving(SDL_HIDAPI_discovery.m_pUdevMonitor);
|
||||
SDL_HIDAPI_discovery.m_nUdevFd = usyms->udev_monitor_get_fd(SDL_HIDAPI_discovery.m_pUdevMonitor);
|
||||
SDL_HIDAPI_discovery.m_bCanGetNotifications = SDL_TRUE;
|
||||
if (SDL_HIDAPI_discovery.m_pUdev != NULL) {
|
||||
SDL_HIDAPI_discovery.m_pUdevMonitor = usyms->udev_monitor_new_from_netlink(SDL_HIDAPI_discovery.m_pUdev, "udev");
|
||||
if (SDL_HIDAPI_discovery.m_pUdevMonitor != NULL) {
|
||||
usyms->udev_monitor_enable_receiving(SDL_HIDAPI_discovery.m_pUdevMonitor);
|
||||
SDL_HIDAPI_discovery.m_nUdevFd = usyms->udev_monitor_get_fd(SDL_HIDAPI_discovery.m_pUdevMonitor);
|
||||
SDL_HIDAPI_discovery.m_bCanGetNotifications = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
@@ -1378,22 +1381,27 @@ SDL_hid_device *SDL_hid_open(unsigned short vendor_id, unsigned short product_id
|
||||
}
|
||||
|
||||
#if HAVE_PLATFORM_BACKEND
|
||||
if (udev_ctx &&
|
||||
(pDevice = PLATFORM_hid_open(vendor_id, product_id, serial_number)) != NULL) {
|
||||
return CreateHIDDeviceWrapper(pDevice, &PLATFORM_Backend);
|
||||
if (udev_ctx) {
|
||||
pDevice = PLATFORM_hid_open(vendor_id, product_id, serial_number);
|
||||
if (pDevice != NULL) {
|
||||
return CreateHIDDeviceWrapper(pDevice, &PLATFORM_Backend);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_PLATFORM_BACKEND */
|
||||
|
||||
#if HAVE_DRIVER_BACKEND
|
||||
if ((pDevice = DRIVER_hid_open(vendor_id, product_id, serial_number)) != NULL) {
|
||||
pDevice = DRIVER_hid_open(vendor_id, product_id, serial_number);
|
||||
if (pDevice != NULL) {
|
||||
return CreateHIDDeviceWrapper(pDevice, &DRIVER_Backend);
|
||||
}
|
||||
#endif /* HAVE_DRIVER_BACKEND */
|
||||
|
||||
#ifdef HAVE_LIBUSB
|
||||
if (libusb_ctx.libhandle &&
|
||||
(pDevice = LIBUSB_hid_open(vendor_id, product_id, serial_number)) != NULL) {
|
||||
return CreateHIDDeviceWrapper(pDevice, &LIBUSB_Backend);
|
||||
if (libusb_ctx.libhandle != NULL) {
|
||||
pDevice = LIBUSB_hid_open(vendor_id, product_id, serial_number);
|
||||
if (pDevice != NULL) {
|
||||
return CreateHIDDeviceWrapper(pDevice, &LIBUSB_Backend);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_LIBUSB */
|
||||
|
||||
@@ -1412,22 +1420,27 @@ SDL_hid_device *SDL_hid_open_path(const char *path, int bExclusive /* = false */
|
||||
}
|
||||
|
||||
#if HAVE_PLATFORM_BACKEND
|
||||
if (udev_ctx &&
|
||||
(pDevice = PLATFORM_hid_open_path(path, bExclusive)) != NULL) {
|
||||
return CreateHIDDeviceWrapper(pDevice, &PLATFORM_Backend);
|
||||
if (udev_ctx) {
|
||||
pDevice = PLATFORM_hid_open_path(path, bExclusive);
|
||||
if (pDevice != NULL) {
|
||||
return CreateHIDDeviceWrapper(pDevice, &PLATFORM_Backend);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_PLATFORM_BACKEND */
|
||||
|
||||
#if HAVE_DRIVER_BACKEND
|
||||
if ((pDevice = DRIVER_hid_open_path(path, bExclusive)) != NULL) {
|
||||
pDevice = DRIVER_hid_open_path(path, bExclusive);
|
||||
if (pDevice != NULL) {
|
||||
return CreateHIDDeviceWrapper(pDevice, &DRIVER_Backend);
|
||||
}
|
||||
#endif /* HAVE_DRIVER_BACKEND */
|
||||
|
||||
#ifdef HAVE_LIBUSB
|
||||
if (libusb_ctx.libhandle &&
|
||||
(pDevice = LIBUSB_hid_open_path(path, bExclusive)) != NULL) {
|
||||
return CreateHIDDeviceWrapper(pDevice, &LIBUSB_Backend);
|
||||
if (libusb_ctx.libhandle != NULL) {
|
||||
pDevice = LIBUSB_hid_open_path(path, bExclusive);
|
||||
if (pDevice != NULL) {
|
||||
return CreateHIDDeviceWrapper(pDevice, &LIBUSB_Backend);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_LIBUSB */
|
||||
|
||||
|
||||
@@ -825,20 +825,21 @@ static const char *map_StringForControllerAxis[] = {
|
||||
/*
|
||||
* convert a string to its enum equivalent
|
||||
*/
|
||||
SDL_GameControllerAxis SDL_GameControllerGetAxisFromString(const char *pchString)
|
||||
SDL_GameControllerAxis
|
||||
SDL_GameControllerGetAxisFromString(const char *str)
|
||||
{
|
||||
int entry;
|
||||
|
||||
if (pchString && (*pchString == '+' || *pchString == '-')) {
|
||||
++pchString;
|
||||
}
|
||||
|
||||
if (pchString == NULL || !pchString[0]) {
|
||||
if (str == NULL || str[0] == '\0') {
|
||||
return SDL_CONTROLLER_AXIS_INVALID;
|
||||
}
|
||||
|
||||
if (*str == '+' || *str == '-') {
|
||||
++str;
|
||||
}
|
||||
|
||||
for (entry = 0; map_StringForControllerAxis[entry]; ++entry) {
|
||||
if (!SDL_strcasecmp(pchString, map_StringForControllerAxis[entry])) {
|
||||
if (SDL_strcasecmp(str, map_StringForControllerAxis[entry]) == 0) {
|
||||
return (SDL_GameControllerAxis)entry;
|
||||
}
|
||||
}
|
||||
@@ -884,15 +885,16 @@ static const char *map_StringForControllerButton[] = {
|
||||
/*
|
||||
* convert a string to its enum equivalent
|
||||
*/
|
||||
SDL_GameControllerButton SDL_GameControllerGetButtonFromString(const char *pchString)
|
||||
SDL_GameControllerButton
|
||||
SDL_GameControllerGetButtonFromString(const char *str)
|
||||
{
|
||||
int entry;
|
||||
if (pchString == NULL || !pchString[0]) {
|
||||
if (str == NULL || str[0] == '\0') {
|
||||
return SDL_CONTROLLER_BUTTON_INVALID;
|
||||
}
|
||||
|
||||
for (entry = 0; map_StringForControllerButton[entry]; ++entry) {
|
||||
if (SDL_strcasecmp(pchString, map_StringForControllerButton[entry]) == 0) {
|
||||
if (SDL_strcasecmp(str, map_StringForControllerButton[entry]) == 0) {
|
||||
return (SDL_GameControllerButton)entry;
|
||||
}
|
||||
}
|
||||
@@ -902,10 +904,10 @@ SDL_GameControllerButton SDL_GameControllerGetButtonFromString(const char *pchSt
|
||||
/*
|
||||
* convert an enum to its string equivalent
|
||||
*/
|
||||
const char *SDL_GameControllerGetStringForButton(SDL_GameControllerButton axis)
|
||||
const char *SDL_GameControllerGetStringForButton(SDL_GameControllerButton button)
|
||||
{
|
||||
if (axis > SDL_CONTROLLER_BUTTON_INVALID && axis < SDL_CONTROLLER_BUTTON_MAX) {
|
||||
return map_StringForControllerButton[axis];
|
||||
if (button > SDL_CONTROLLER_BUTTON_INVALID && button < SDL_CONTROLLER_BUTTON_MAX) {
|
||||
return map_StringForControllerButton[button];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -1071,7 +1073,7 @@ static void SDL_PrivateLoadButtonMapping(SDL_GameController *gamecontroller, Con
|
||||
gamecontroller->name = pControllerMapping->name;
|
||||
gamecontroller->num_bindings = 0;
|
||||
gamecontroller->mapping = pControllerMapping;
|
||||
if (gamecontroller->joystick->naxes) {
|
||||
if (gamecontroller->joystick->naxes != 0 && gamecontroller->last_match_axis != NULL) {
|
||||
SDL_memset(gamecontroller->last_match_axis, 0, gamecontroller->joystick->naxes * sizeof(*gamecontroller->last_match_axis));
|
||||
}
|
||||
|
||||
@@ -1351,13 +1353,13 @@ static void SDL_PrivateAppendToMappingString(char *mapping_string,
|
||||
SDL_strlcat(mapping_string, ":", mapping_string_len);
|
||||
switch (mapping->kind) {
|
||||
case EMappingKind_Button:
|
||||
SDL_snprintf(buffer, sizeof(buffer), "b%i", mapping->target);
|
||||
(void)SDL_snprintf(buffer, sizeof buffer, "b%i", mapping->target);
|
||||
break;
|
||||
case EMappingKind_Axis:
|
||||
SDL_snprintf(buffer, sizeof(buffer), "a%i", mapping->target);
|
||||
(void)SDL_snprintf(buffer, sizeof buffer, "a%i", mapping->target);
|
||||
break;
|
||||
case EMappingKind_Hat:
|
||||
SDL_snprintf(buffer, sizeof(buffer), "h%i.%i", mapping->target >> 4, mapping->target & 0x0F);
|
||||
(void)SDL_snprintf(buffer, sizeof buffer, "h%i.%i", mapping->target >> 4, mapping->target & 0x0F);
|
||||
break;
|
||||
default:
|
||||
SDL_assert(SDL_FALSE);
|
||||
@@ -1385,7 +1387,7 @@ static ControllerMapping_t *SDL_PrivateGenerateAutomaticControllerMapping(const
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_snprintf(mapping, sizeof(mapping), "none,%s,", name_string);
|
||||
(void)SDL_snprintf(mapping, sizeof mapping, "none,%s,", name_string);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "a", &raw_map->a);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "b", &raw_map->b);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "x", &raw_map->x);
|
||||
@@ -1677,7 +1679,7 @@ static char *CreateMappingString(ControllerMapping_t *mapping, SDL_JoystickGUID
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_snprintf(pMappingString, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping);
|
||||
(void)SDL_snprintf(pMappingString, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping);
|
||||
|
||||
if (!SDL_strstr(mapping->mapping, SDL_CONTROLLER_PLATFORM_FIELD)) {
|
||||
if (mapping->mapping[SDL_strlen(mapping->mapping) - 1] != ',') {
|
||||
@@ -1848,12 +1850,12 @@ int SDL_GameControllerInit(void)
|
||||
* Get the implementation dependent name of a controller
|
||||
*/
|
||||
const char *
|
||||
SDL_GameControllerNameForIndex(int device_index)
|
||||
SDL_GameControllerNameForIndex(int joystick_index)
|
||||
{
|
||||
ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(device_index);
|
||||
if (pSupportedController) {
|
||||
ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(joystick_index);
|
||||
if (pSupportedController != NULL) {
|
||||
if (SDL_strcmp(pSupportedController->name, "*") == 0) {
|
||||
return SDL_JoystickNameForIndex(device_index);
|
||||
return SDL_JoystickNameForIndex(joystick_index);
|
||||
} else {
|
||||
return pSupportedController->name;
|
||||
}
|
||||
@@ -1865,11 +1867,11 @@ SDL_GameControllerNameForIndex(int device_index)
|
||||
* Get the implementation dependent path of a controller
|
||||
*/
|
||||
const char *
|
||||
SDL_GameControllerPathForIndex(int device_index)
|
||||
SDL_GameControllerPathForIndex(int joystick_index)
|
||||
{
|
||||
ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(device_index);
|
||||
if (pSupportedController) {
|
||||
return SDL_JoystickPathForIndex(device_index);
|
||||
ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(joystick_index);
|
||||
if (pSupportedController != NULL) {
|
||||
return SDL_JoystickPathForIndex(joystick_index);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -1910,7 +1912,7 @@ SDL_GameControllerMappingForDeviceIndex(int joystick_index)
|
||||
SDL_UnlockJoysticks();
|
||||
return NULL;
|
||||
}
|
||||
SDL_snprintf(pMappingString, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping);
|
||||
(void)SDL_snprintf(pMappingString, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping);
|
||||
}
|
||||
SDL_UnlockJoysticks();
|
||||
return pMappingString;
|
||||
@@ -1933,10 +1935,10 @@ SDL_IsGameControllerNameAndGUID(const char *name, SDL_JoystickGUID guid)
|
||||
* Return 1 if the joystick at this device index is a supported controller
|
||||
*/
|
||||
SDL_bool
|
||||
SDL_IsGameController(int device_index)
|
||||
SDL_IsGameController(int joystick_index)
|
||||
{
|
||||
ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(device_index);
|
||||
if (pSupportedController) {
|
||||
ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(joystick_index);
|
||||
if (pSupportedController != NULL) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
return SDL_FALSE;
|
||||
@@ -2042,7 +2044,7 @@ SDL_bool SDL_ShouldIgnoreGameController(const char *name, SDL_JoystickGUID guid)
|
||||
* This function returns a controller identifier, or NULL if an error occurred.
|
||||
*/
|
||||
SDL_GameController *
|
||||
SDL_GameControllerOpen(int device_index)
|
||||
SDL_GameControllerOpen(int joystick_index)
|
||||
{
|
||||
SDL_JoystickID instance_id;
|
||||
SDL_GameController *gamecontroller;
|
||||
@@ -2053,8 +2055,8 @@ SDL_GameControllerOpen(int device_index)
|
||||
|
||||
gamecontrollerlist = SDL_gamecontrollers;
|
||||
/* If the controller is already open, return it */
|
||||
instance_id = SDL_JoystickGetDeviceInstanceID(device_index);
|
||||
while (gamecontrollerlist) {
|
||||
instance_id = SDL_JoystickGetDeviceInstanceID(joystick_index);
|
||||
while (gamecontrollerlist != NULL) {
|
||||
if (instance_id == gamecontrollerlist->joystick->instance_id) {
|
||||
gamecontroller = gamecontrollerlist;
|
||||
++gamecontroller->ref_count;
|
||||
@@ -2065,9 +2067,9 @@ SDL_GameControllerOpen(int device_index)
|
||||
}
|
||||
|
||||
/* Find a controller mapping */
|
||||
pSupportedController = SDL_PrivateGetControllerMapping(device_index);
|
||||
pSupportedController = SDL_PrivateGetControllerMapping(joystick_index);
|
||||
if (pSupportedController == NULL) {
|
||||
SDL_SetError("Couldn't find mapping for device (%d)", device_index);
|
||||
SDL_SetError("Couldn't find mapping for device (%d)", joystick_index);
|
||||
SDL_UnlockJoysticks();
|
||||
return NULL;
|
||||
}
|
||||
@@ -2081,8 +2083,8 @@ SDL_GameControllerOpen(int device_index)
|
||||
}
|
||||
gamecontroller->magic = &gamecontroller_magic;
|
||||
|
||||
gamecontroller->joystick = SDL_JoystickOpen(device_index);
|
||||
if (!gamecontroller->joystick) {
|
||||
gamecontroller->joystick = SDL_JoystickOpen(joystick_index);
|
||||
if (gamecontroller->joystick == NULL) {
|
||||
SDL_free(gamecontroller);
|
||||
SDL_UnlockJoysticks();
|
||||
return NULL;
|
||||
|
||||
@@ -1881,7 +1881,7 @@ SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_name, c
|
||||
len = (SDL_strlen(vendor_name) + 1 + SDL_strlen(product_name) + 1);
|
||||
name = (char *)SDL_malloc(len);
|
||||
if (name) {
|
||||
SDL_snprintf(name, len, "%s %s", vendor_name, product_name);
|
||||
(void)SDL_snprintf(name, len, "%s %s", vendor_name, product_name);
|
||||
}
|
||||
} else if (*product_name) {
|
||||
name = SDL_strdup(product_name);
|
||||
@@ -1909,8 +1909,8 @@ SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_name, c
|
||||
default:
|
||||
len = (6 + 1 + 6 + 1);
|
||||
name = (char *)SDL_malloc(len);
|
||||
if (name) {
|
||||
SDL_snprintf(name, len, "0x%.4x/0x%.4x", vendor, product);
|
||||
if (name != NULL) {
|
||||
(void)SDL_snprintf(name, len, "0x%.4x/0x%.4x", vendor, product);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -519,7 +519,6 @@ static SDL_bool JoystickAlreadyKnown(IOHIDDeviceRef ioHIDDeviceObject)
|
||||
static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDeviceRef ioHIDDeviceObject)
|
||||
{
|
||||
recDevice *device;
|
||||
int device_index = 0;
|
||||
io_service_t ioservice;
|
||||
|
||||
if (res != kIOReturnSuccess) {
|
||||
@@ -570,12 +569,10 @@ static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender
|
||||
recDevice *curdevice;
|
||||
|
||||
curdevice = gpDeviceList;
|
||||
while (curdevice->pNext) {
|
||||
++device_index;
|
||||
while (curdevice->pNext != NULL) {
|
||||
curdevice = curdevice->pNext;
|
||||
}
|
||||
curdevice->pNext = device;
|
||||
++device_index; /* bump by one since we counted by pNext. */
|
||||
}
|
||||
|
||||
SDL_PrivateJoystickAdded(device->instance_id);
|
||||
|
||||
@@ -233,7 +233,7 @@ static void HIDAPI_DriverGameCube_SetDevicePlayerIndex(SDL_HIDAPI_Device *device
|
||||
{
|
||||
}
|
||||
|
||||
static void HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device, SDL_DriverGameCube_Context *ctx, Uint8 *packet, int size)
|
||||
static void HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device, SDL_DriverGameCube_Context *ctx, const Uint8 *packet, int size)
|
||||
{
|
||||
SDL_Joystick *joystick;
|
||||
Uint8 i, v;
|
||||
|
||||
@@ -158,9 +158,9 @@ static SDL_bool HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device)
|
||||
/* Set the controller into report mode over USB */
|
||||
{
|
||||
Uint8 data[USB_PACKET_LENGTH];
|
||||
int size;
|
||||
|
||||
if ((size = ReadFeatureReport(device->dev, 0xf2, data, 17)) < 0) {
|
||||
int size = ReadFeatureReport(device->dev, 0xf2, data, 17);
|
||||
if (size < 0) {
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
|
||||
"HIDAPI_DriverPS3_InitDevice(): Couldn't read feature report 0xf2");
|
||||
return SDL_FALSE;
|
||||
@@ -168,7 +168,8 @@ static SDL_bool HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device)
|
||||
#ifdef DEBUG_PS3_PROTOCOL
|
||||
HIDAPI_DumpPacket("PS3 0xF2 packet: size = %d", data, size);
|
||||
#endif
|
||||
if ((size = ReadFeatureReport(device->dev, 0xf5, data, 8)) < 0) {
|
||||
size = ReadFeatureReport(device->dev, 0xf5, data, 8);
|
||||
if (size < 0) {
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
|
||||
"HIDAPI_DriverPS3_InitDevice(): Couldn't read feature report 0xf5");
|
||||
return SDL_FALSE;
|
||||
@@ -583,8 +584,8 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_IsSupportedDevice(SDL_HIDAPI_Device *
|
||||
|
||||
if (SONY_THIRDPARTY_VENDOR(vendor_id)) {
|
||||
if (device && device->dev) {
|
||||
if ((size = ReadFeatureReport(device->dev, 0x03, data, sizeof(data))) == 8 &&
|
||||
data[2] == 0x26) {
|
||||
size = ReadFeatureReport(device->dev, 0x03, data, sizeof data);
|
||||
if (size == 8 && data[2] == 0x26) {
|
||||
/* Supported third party controller */
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
|
||||
@@ -189,8 +189,8 @@ static SDL_bool HIDAPI_DriverPS4_IsSupportedDevice(SDL_HIDAPI_Device *device, co
|
||||
|
||||
if (SONY_THIRDPARTY_VENDOR(vendor_id)) {
|
||||
if (device && device->dev) {
|
||||
if ((size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdCapabilities, data, sizeof(data))) == 48 &&
|
||||
data[2] == 0x27) {
|
||||
size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdCapabilities, data, sizeof data);
|
||||
if (size == 48 && data[2] == 0x27) {
|
||||
/* Supported third party controller */
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
@@ -268,8 +268,8 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
|
||||
if (ctx->is_dongle) {
|
||||
size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdSerialNumber, data, sizeof(data));
|
||||
if (size >= 7 && (data[1] || data[2] || data[3] || data[4] || data[5] || data[6])) {
|
||||
SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
|
||||
data[6], data[5], data[4], data[3], data[2], data[1]);
|
||||
(void)SDL_snprintf(serial, sizeof serial, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
|
||||
data[6], data[5], data[4], data[3], data[2], data[1]);
|
||||
}
|
||||
device->is_bluetooth = SDL_FALSE;
|
||||
ctx->enhanced_mode = SDL_TRUE;
|
||||
@@ -277,8 +277,8 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
|
||||
/* This will fail if we're on Bluetooth */
|
||||
size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdSerialNumber, data, sizeof(data));
|
||||
if (size >= 7 && (data[1] || data[2] || data[3] || data[4] || data[5] || data[6])) {
|
||||
SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
|
||||
data[6], data[5], data[4], data[3], data[2], data[1]);
|
||||
(void)SDL_snprintf(serial, sizeof serial, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
|
||||
data[6], data[5], data[4], data[3], data[2], data[1]);
|
||||
device->is_bluetooth = SDL_FALSE;
|
||||
ctx->enhanced_mode = SDL_TRUE;
|
||||
} else {
|
||||
@@ -308,6 +308,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
|
||||
SDL_Log("PS4 dongle = %s, bluetooth = %s\n", ctx->is_dongle ? "TRUE" : "FALSE", device->is_bluetooth ? "TRUE" : "FALSE");
|
||||
#endif
|
||||
|
||||
size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdCapabilities, data, sizeof data);
|
||||
/* Get the device capabilities */
|
||||
if (device->vendor_id == USB_VENDOR_SONY) {
|
||||
ctx->official_controller = SDL_TRUE;
|
||||
@@ -315,8 +316,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
|
||||
ctx->lightbar_supported = SDL_TRUE;
|
||||
ctx->vibration_supported = SDL_TRUE;
|
||||
ctx->touchpad_supported = SDL_TRUE;
|
||||
} else if ((size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdCapabilities, data, sizeof(data))) == 48 &&
|
||||
data[2] == 0x27) {
|
||||
} else if (size == 48 && data[2] == 0x27) {
|
||||
Uint8 capabilities = data[4];
|
||||
Uint8 device_type = data[5];
|
||||
|
||||
@@ -1119,8 +1119,8 @@ static SDL_bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
char serial[18];
|
||||
size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdSerialNumber, data, sizeof(data));
|
||||
if (size >= 7 && (data[1] || data[2] || data[3] || data[4] || data[5] || data[6])) {
|
||||
SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
|
||||
data[6], data[5], data[4], data[3], data[2], data[1]);
|
||||
(void)SDL_snprintf(serial, sizeof serial, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
|
||||
data[6], data[5], data[4], data[3], data[2], data[1]);
|
||||
HIDAPI_SetDeviceSerial(device, serial);
|
||||
}
|
||||
HIDAPI_JoystickConnected(device, NULL);
|
||||
|
||||
@@ -275,8 +275,8 @@ static SDL_bool HIDAPI_DriverPS5_IsSupportedDevice(SDL_HIDAPI_Device *device, co
|
||||
|
||||
if (SONY_THIRDPARTY_VENDOR(vendor_id)) {
|
||||
if (device && device->dev) {
|
||||
if ((size = ReadFeatureReport(device->dev, k_EPS5FeatureReportIdCapabilities, data, sizeof(data))) == 48 &&
|
||||
data[2] == 0x28) {
|
||||
size = ReadFeatureReport(device->dev, k_EPS5FeatureReportIdCapabilities, data, sizeof data);
|
||||
if (size == 48 && data[2] == 0x28) {
|
||||
/* Supported third party controller */
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
@@ -400,8 +400,8 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
|
||||
This will also enable enhanced reports over Bluetooth
|
||||
*/
|
||||
if (ReadFeatureReport(device->dev, k_EPS5FeatureReportIdSerialNumber, data, sizeof(data)) >= 7) {
|
||||
SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
|
||||
data[6], data[5], data[4], data[3], data[2], data[1]);
|
||||
(void)SDL_snprintf(serial, sizeof serial, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
|
||||
data[6], data[5], data[4], data[3], data[2], data[1]);
|
||||
}
|
||||
|
||||
/* Read the firmware version
|
||||
@@ -412,6 +412,7 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
|
||||
}
|
||||
}
|
||||
|
||||
size = ReadFeatureReport(device->dev, k_EPS5FeatureReportIdCapabilities, data, sizeof data);
|
||||
/* Get the device capabilities */
|
||||
if (device->vendor_id == USB_VENDOR_SONY) {
|
||||
ctx->sensors_supported = SDL_TRUE;
|
||||
@@ -419,8 +420,7 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
|
||||
ctx->vibration_supported = SDL_TRUE;
|
||||
ctx->playerled_supported = SDL_TRUE;
|
||||
ctx->touchpad_supported = SDL_TRUE;
|
||||
} else if ((size = ReadFeatureReport(device->dev, k_EPS5FeatureReportIdCapabilities, data, sizeof(data))) == 48 &&
|
||||
data[2] == 0x28) {
|
||||
} else if (size == 48 && data[2] == 0x28) {
|
||||
Uint8 capabilities = data[4];
|
||||
Uint8 capabilities2 = data[20];
|
||||
Uint8 device_type = data[5];
|
||||
|
||||
@@ -368,7 +368,7 @@ static void HIDAPI_DriverShield_HandleStatePacketV103(SDL_Joystick *joystick, SD
|
||||
#undef clamp
|
||||
#define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
|
||||
|
||||
static void HIDAPI_DriverShield_HandleTouchPacketV103(SDL_Joystick *joystick, SDL_DriverShield_Context *ctx, Uint8 *data, int size)
|
||||
static void HIDAPI_DriverShield_HandleTouchPacketV103(SDL_Joystick *joystick, SDL_DriverShield_Context *ctx, const Uint8 *data, int size)
|
||||
{
|
||||
Uint8 touchpad_state;
|
||||
float touchpad_x, touchpad_y;
|
||||
|
||||
@@ -244,7 +244,7 @@ static int WriteSegmentToSteamControllerPacketAssembler(SteamControllerPacketAss
|
||||
}
|
||||
|
||||
if (nSegmentLength != MAX_REPORT_SEGMENT_SIZE) {
|
||||
printf("Bad segment size! %d\n", (int)nSegmentLength);
|
||||
printf("Bad segment size! %d\n", nSegmentLength);
|
||||
hexdump(pSegment, nSegmentLength);
|
||||
ResetSteamControllerPacketAssembler(pAssembler);
|
||||
return -1;
|
||||
@@ -365,10 +365,11 @@ static int GetFeatureReport(SDL_hid_device *dev, unsigned char uBuffer[65])
|
||||
HEXDUMP(uSegmentBuffer, nRet);
|
||||
|
||||
// Zero retry counter if we got data
|
||||
if (nRet > 2 && (uSegmentBuffer[ucDataStartOffset + 1] & REPORT_SEGMENT_DATA_FLAG))
|
||||
if (nRet > 2 && (uSegmentBuffer[ucDataStartOffset + 1] & REPORT_SEGMENT_DATA_FLAG)) {
|
||||
nRetries = 0;
|
||||
else
|
||||
} else {
|
||||
nRetries++;
|
||||
}
|
||||
|
||||
if (nRet > 0) {
|
||||
int nPacketLength = WriteSegmentToSteamControllerPacketAssembler(&assembler,
|
||||
@@ -752,19 +753,21 @@ static void FormatStatePacketUntilGyro(SteamControllerStateInternal_t *pState, V
|
||||
RotatePad(&nLeftPadX, &nLeftPadY, -flRotationAngle);
|
||||
RotatePad(&nRightPadX, &nRightPadY, flRotationAngle);
|
||||
|
||||
if (pState->ulButtons & STEAM_LEFTPAD_FINGERDOWN_MASK)
|
||||
if (pState->ulButtons & STEAM_LEFTPAD_FINGERDOWN_MASK) {
|
||||
nPadOffset = 1000;
|
||||
else
|
||||
} else {
|
||||
nPadOffset = 0;
|
||||
}
|
||||
|
||||
pState->sLeftPadX = clamp(nLeftPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
pState->sLeftPadY = clamp(nLeftPadY + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
|
||||
nPadOffset = 0;
|
||||
if (pState->ulButtons & STEAM_RIGHTPAD_FINGERDOWN_MASK)
|
||||
if (pState->ulButtons & STEAM_RIGHTPAD_FINGERDOWN_MASK) {
|
||||
nPadOffset = 1000;
|
||||
else
|
||||
} else {
|
||||
nPadOffset = 0;
|
||||
}
|
||||
|
||||
pState->sRightPadX = clamp(nRightPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
pState->sRightPadY = clamp(nRightPadY + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
@@ -811,10 +814,11 @@ static bool UpdateBLESteamControllerState(const uint8_t *pData, int nDataSize, S
|
||||
int nLength = sizeof(pState->sLeftPadX) + sizeof(pState->sLeftPadY);
|
||||
int nPadOffset;
|
||||
SDL_memcpy(&pState->sLeftPadX, pData, nLength);
|
||||
if (pState->ulButtons & STEAM_LEFTPAD_FINGERDOWN_MASK)
|
||||
if (pState->ulButtons & STEAM_LEFTPAD_FINGERDOWN_MASK) {
|
||||
nPadOffset = 1000;
|
||||
else
|
||||
} else {
|
||||
nPadOffset = 0;
|
||||
}
|
||||
|
||||
RotatePadShort(&pState->sLeftPadX, &pState->sLeftPadY, -flRotationAngle);
|
||||
pState->sLeftPadX = clamp(pState->sLeftPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
@@ -827,10 +831,11 @@ static bool UpdateBLESteamControllerState(const uint8_t *pData, int nDataSize, S
|
||||
|
||||
SDL_memcpy(&pState->sRightPadX, pData, nLength);
|
||||
|
||||
if (pState->ulButtons & STEAM_RIGHTPAD_FINGERDOWN_MASK)
|
||||
if (pState->ulButtons & STEAM_RIGHTPAD_FINGERDOWN_MASK) {
|
||||
nPadOffset = 1000;
|
||||
else
|
||||
} else {
|
||||
nPadOffset = 0;
|
||||
}
|
||||
|
||||
RotatePadShort(&pState->sRightPadX, &pState->sRightPadY, flRotationAngle);
|
||||
pState->sRightPadX = clamp(pState->sRightPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user