Clang-Tidy fixes (#6725)
parent
c2ce44bead
commit
3c501b963d
|
@ -1008,12 +1008,12 @@ typedef struct _SDL_AudioStream SDL_AudioStream;
|
||||||
* \sa SDL_AudioStreamClear
|
* \sa SDL_AudioStreamClear
|
||||||
* \sa SDL_FreeAudioStream
|
* \sa SDL_FreeAudioStream
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC SDL_AudioStream * SDLCALL SDL_NewAudioStream(const SDL_AudioFormat src_format,
|
extern DECLSPEC SDL_AudioStream *SDLCALL SDL_NewAudioStream(SDL_AudioFormat src_format,
|
||||||
const Uint8 src_channels,
|
Uint8 src_channels,
|
||||||
const int src_rate,
|
int src_rate,
|
||||||
const SDL_AudioFormat dst_format,
|
SDL_AudioFormat dst_format,
|
||||||
const Uint8 dst_channels,
|
Uint8 dst_channels,
|
||||||
const int dst_rate);
|
int dst_rate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add data to be converted/resampled to the stream.
|
* Add data to be converted/resampled to the stream.
|
||||||
|
|
|
@ -276,7 +276,7 @@ extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem);
|
||||||
* successful it will atomically decrement the semaphore value.
|
* successful it will atomically decrement the semaphore value.
|
||||||
*
|
*
|
||||||
* \param sem the semaphore to wait on
|
* \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
|
* \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;
|
* succeed in the allotted time, or a negative error code on failure;
|
||||||
* call SDL_GetError() for more information.
|
* call SDL_GetError() for more information.
|
||||||
|
@ -290,7 +290,7 @@ extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem);
|
||||||
* \sa SDL_SemValue
|
* \sa SDL_SemValue
|
||||||
* \sa SDL_SemWait
|
* \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.
|
* Atomically increment a semaphore's value and wake waiting threads.
|
||||||
|
|
|
@ -48,7 +48,6 @@ typedef enum
|
||||||
SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */
|
SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */
|
||||||
} SDL_PowerState;
|
} SDL_PowerState;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current power supply details.
|
* 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
|
* It's possible a platform can only report battery percentage or time left
|
||||||
* but not both.
|
* 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
|
* don't care, will return -1 if we can't determine a value, or
|
||||||
* we're not running on a battery
|
* 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
|
* 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
|
* determine a value, or we're not running on a battery
|
||||||
* \returns an SDL_PowerState enum representing the current battery state.
|
* \returns an SDL_PowerState enum representing the current battery state.
|
||||||
*
|
*
|
||||||
* \since This function is available since SDL 3.0.0.
|
* \since This function is available since SDL 3.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++ */
|
/* Ends C function definitions when using C++ */
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -554,9 +554,9 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface * surface)
|
||||||
* surface. The new, optimized surface can then be used as the source for
|
* surface. The new, optimized surface can then be used as the source for
|
||||||
* future blits, making them faster.
|
* future blits, making them faster.
|
||||||
*
|
*
|
||||||
* \param src the existing SDL_Surface structure to convert
|
* \param surface the existing SDL_Surface structure to convert
|
||||||
* \param fmt the SDL_PixelFormat structure that the new surface is optimized
|
* \param format the SDL_PixelFormat structure that the new surface is
|
||||||
* for
|
* optimized for
|
||||||
* \returns the new SDL_Surface structure that is created or NULL if it fails;
|
* \returns the new SDL_Surface structure that is created or NULL if it fails;
|
||||||
* call SDL_GetError() for more information.
|
* call SDL_GetError() for more information.
|
||||||
*
|
*
|
||||||
|
@ -566,8 +566,8 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface * surface)
|
||||||
* \sa SDL_ConvertSurfaceFormat
|
* \sa SDL_ConvertSurfaceFormat
|
||||||
* \sa SDL_CreateSurface
|
* \sa SDL_CreateSurface
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
|
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface(SDL_Surface *surface,
|
||||||
(SDL_Surface * src, const SDL_PixelFormat * fmt);
|
const SDL_PixelFormat *format);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy an existing surface to a new surface of the specified format enum.
|
* Copy an existing surface to a new surface of the specified format enum.
|
||||||
|
@ -577,7 +577,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
|
||||||
* it might be easier to call but it doesn't have access to palette
|
* 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.
|
* 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
|
* \param pixel_format the SDL_PixelFormatEnum that the new surface is
|
||||||
* optimized for
|
* optimized for
|
||||||
* \returns the new SDL_Surface structure that is created or NULL if it fails;
|
* \returns the new SDL_Surface structure that is created or NULL if it fails;
|
||||||
|
@ -589,8 +589,8 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
|
||||||
* \sa SDL_ConvertSurface
|
* \sa SDL_ConvertSurface
|
||||||
* \sa SDL_CreateSurface
|
* \sa SDL_CreateSurface
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat
|
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat(SDL_Surface *surface,
|
||||||
(SDL_Surface * src, Uint32 pixel_format);
|
Uint32 pixel_format);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy a block of pixels of one format to another format.
|
* Copy a block of pixels of one format to another format.
|
||||||
|
|
|
@ -280,8 +280,8 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data,
|
||||||
/* this is a little hacky. */
|
/* this is a little hacky. */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
char buf[32];
|
char buf[32];
|
||||||
fprintf(stderr, "Abort/Break/Retry/Ignore/AlwaysIgnore? [abriA] : ");
|
(void)fprintf(stderr, "Abort/Break/Retry/Ignore/AlwaysIgnore? [abriA] : ");
|
||||||
fflush(stderr);
|
(void)fflush(stderr);
|
||||||
if (fgets(buf, sizeof(buf), stdin) == NULL) {
|
if (fgets(buf, sizeof(buf), stdin) == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||||
error->str = str;
|
error->str = str;
|
||||||
error->len = len;
|
error->len = len;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
SDL_vsnprintf(error->str, error->len, fmt, ap);
|
(void)SDL_vsnprintf(error->str, error->len, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -412,7 +412,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;
|
length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1 + 1 + 1;
|
||||||
output = SDL_small_alloc(char, length, &isstack);
|
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);
|
tstr = WIN_UTF8ToString(output);
|
||||||
|
|
||||||
/* Output to debugger */
|
/* Output to debugger */
|
||||||
|
@ -457,27 +457,33 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
|
||||||
{
|
{
|
||||||
FILE *pFile;
|
FILE *pFile;
|
||||||
pFile = fopen("SDL_Log.txt", "a");
|
pFile = fopen("SDL_Log.txt", "a");
|
||||||
fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
if (pFile != NULL) {
|
||||||
fclose(pFile);
|
(void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
||||||
|
(void)fclose(pFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#elif defined(__VITA__)
|
#elif defined(__VITA__)
|
||||||
{
|
{
|
||||||
FILE *pFile;
|
FILE *pFile;
|
||||||
pFile = fopen("ux0:/data/SDL_Log.txt", "a");
|
pFile = fopen("ux0:/data/SDL_Log.txt", "a");
|
||||||
fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
if (pFile != NULL) {
|
||||||
fclose(pFile);
|
(void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
||||||
|
(void)fclose(pFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#elif defined(__3DS__)
|
#elif defined(__3DS__)
|
||||||
{
|
{
|
||||||
FILE *pFile;
|
FILE *pFile;
|
||||||
pFile = fopen("sdmc:/3ds/SDL_Log.txt", "a");
|
pFile = fopen("sdmc:/3ds/SDL_Log.txt", "a");
|
||||||
fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
if (pFile != NULL) {
|
||||||
fclose(pFile);
|
(void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
||||||
|
(void)fclose(pFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_STDIO_H && \
|
#if HAVE_STDIO_H && \
|
||||||
!(defined(__APPLE__) && (defined(SDL_VIDEO_DRIVER_COCOA) || defined(SDL_VIDEO_DRIVER_UIKIT)))
|
!(defined(__APPLE__) && (defined(SDL_VIDEO_DRIVER_COCOA) || defined(SDL_VIDEO_DRIVER_UIKIT)))
|
||||||
fprintf(stderr, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
(void)fprintf(stderr, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
||||||
#else
|
#else
|
||||||
/* We won't print anything, but reference the priority prefix anyway
|
/* We won't print anything, but reference the priority prefix anyway
|
||||||
to avoid a compiler warning.
|
to avoid a compiler warning.
|
||||||
|
|
|
@ -362,7 +362,7 @@ static int add_audio_device(const char *name, SDL_AudioSpec *spec, void *handle,
|
||||||
return SDL_OutOfMemory();
|
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->dupenum = dupenum;
|
||||||
item->name = replacement;
|
item->name = replacement;
|
||||||
}
|
}
|
||||||
|
@ -626,6 +626,10 @@ void SDL_ClearQueuedAudio(SDL_AudioDeviceID devid)
|
||||||
current_audio.impl.UnlockDevice(device);
|
current_audio.impl.UnlockDevice(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SDL_AUDIO_DRIVER_ANDROID
|
||||||
|
extern void Android_JNI_AudioSetThreadPriority(int, int);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The general mixing thread function */
|
/* The general mixing thread function */
|
||||||
static int SDLCALL SDL_RunAudio(void *devicep)
|
static int SDLCALL SDL_RunAudio(void *devicep)
|
||||||
{
|
{
|
||||||
|
@ -640,7 +644,6 @@ static int SDLCALL SDL_RunAudio(void *devicep)
|
||||||
#if SDL_AUDIO_DRIVER_ANDROID
|
#if SDL_AUDIO_DRIVER_ANDROID
|
||||||
{
|
{
|
||||||
/* Set thread priority to THREAD_PRIORITY_AUDIO */
|
/* Set thread priority to THREAD_PRIORITY_AUDIO */
|
||||||
extern void Android_JNI_AudioSetThreadPriority(int, int);
|
|
||||||
Android_JNI_AudioSetThreadPriority(device->iscapture, device->id);
|
Android_JNI_AudioSetThreadPriority(device->iscapture, device->id);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -741,7 +744,6 @@ static int SDLCALL SDL_CaptureAudio(void *devicep)
|
||||||
#if SDL_AUDIO_DRIVER_ANDROID
|
#if SDL_AUDIO_DRIVER_ANDROID
|
||||||
{
|
{
|
||||||
/* Set thread priority to THREAD_PRIORITY_AUDIO */
|
/* Set thread priority to THREAD_PRIORITY_AUDIO */
|
||||||
extern void Android_JNI_AudioSetThreadPriority(int, int);
|
|
||||||
Android_JNI_AudioSetThreadPriority(device->iscapture, device->id);
|
Android_JNI_AudioSetThreadPriority(device->iscapture, device->id);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -1155,6 +1157,19 @@ static void close_audio_device(SDL_AudioDevice *device)
|
||||||
SDL_free(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).
|
* Sanity check desired AudioSpec for SDL_OpenAudio() in (orig).
|
||||||
* Fills in a sanitized copy in (prepared).
|
* Fills in a sanitized copy in (prepared).
|
||||||
|
@ -1165,23 +1180,33 @@ static int prepare_audiospec(const SDL_AudioSpec *orig, SDL_AudioSpec *prepared)
|
||||||
SDL_copyp(prepared, orig);
|
SDL_copyp(prepared, orig);
|
||||||
|
|
||||||
if (orig->freq == 0) {
|
if (orig->freq == 0) {
|
||||||
|
static const int DEFAULT_FREQ = 22050;
|
||||||
const char *env = SDL_getenv("SDL_AUDIO_FREQUENCY");
|
const char *env = SDL_getenv("SDL_AUDIO_FREQUENCY");
|
||||||
if ((!env) || ((prepared->freq = SDL_atoi(env)) == 0)) {
|
if (env != NULL) {
|
||||||
prepared->freq = 22050; /* a reasonable default */
|
int freq = SDL_atoi(env);
|
||||||
|
prepared->freq = freq != 0 ? freq : DEFAULT_FREQ;
|
||||||
|
} else {
|
||||||
|
prepared->freq = DEFAULT_FREQ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orig->format == 0) {
|
if (orig->format == 0) {
|
||||||
const char *env = SDL_getenv("SDL_AUDIO_FORMAT");
|
const char *env = SDL_getenv("SDL_AUDIO_FORMAT");
|
||||||
if ((!env) || ((prepared->format = SDL_ParseAudioFormat(env)) == 0)) {
|
if (env != NULL) {
|
||||||
prepared->format = AUDIO_S16; /* a reasonable default */
|
const SDL_AudioFormat format = SDL_ParseAudioFormat(env);
|
||||||
|
prepared->format = format != 0 ? format : AUDIO_S16;
|
||||||
|
} else {
|
||||||
|
prepared->format = AUDIO_S16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orig->channels == 0) {
|
if (orig->channels == 0) {
|
||||||
const char *env = SDL_getenv("SDL_AUDIO_CHANNELS");
|
const char *env = SDL_getenv("SDL_AUDIO_CHANNELS");
|
||||||
if ((!env) || ((prepared->channels = (Uint8)SDL_atoi(env)) == 0)) {
|
if (env != NULL) {
|
||||||
prepared->channels = 2; /* a reasonable default */
|
Uint8 channels = (Uint8)SDL_atoi(env);
|
||||||
|
prepared->channels = channels != 0 ? channels : 2;
|
||||||
|
} else {
|
||||||
|
prepared->channels = 2;
|
||||||
}
|
}
|
||||||
} else if (orig->channels > 8) {
|
} else if (orig->channels > 8) {
|
||||||
SDL_SetError("Unsupported number of audio channels.");
|
SDL_SetError("Unsupported number of audio channels.");
|
||||||
|
@ -1190,15 +1215,11 @@ static int prepare_audiospec(const SDL_AudioSpec *orig, SDL_AudioSpec *prepared)
|
||||||
|
|
||||||
if (orig->samples == 0) {
|
if (orig->samples == 0) {
|
||||||
const char *env = SDL_getenv("SDL_AUDIO_SAMPLES");
|
const char *env = SDL_getenv("SDL_AUDIO_SAMPLES");
|
||||||
if ((!env) || ((prepared->samples = (Uint16)SDL_atoi(env)) == 0)) {
|
if (env != NULL) {
|
||||||
/* Pick a default of ~46 ms at desired frequency */
|
Uint16 samples = (Uint16)SDL_atoi(env);
|
||||||
/* !!! FIXME: remove this when the non-Po2 resampling is in. */
|
prepared->samples = samples != 0 ? samples : GetDefaultSamplesFromFreq(prepared->freq);
|
||||||
const int samples = (prepared->freq / 1000) * 46;
|
} else {
|
||||||
int power2 = 1;
|
prepared->samples = GetDefaultSamplesFromFreq(prepared->freq);
|
||||||
while (power2 < samples) {
|
|
||||||
power2 *= 2;
|
|
||||||
}
|
|
||||||
prepared->samples = power2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1456,7 +1477,7 @@ static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture,
|
||||||
const size_t stacksize = is_internal_thread ? 64 * 1024 : 0;
|
const size_t stacksize = is_internal_thread ? 64 * 1024 : 0;
|
||||||
char threadname[64];
|
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);
|
device->thread = SDL_CreateThreadInternal(iscapture ? SDL_CaptureAudio : SDL_RunAudio, threadname, stacksize, device);
|
||||||
|
|
||||||
if (device->thread == NULL) {
|
if (device->thread == NULL) {
|
||||||
|
|
|
@ -204,7 +204,7 @@ static int SDL_ResampleAudio(const int chans, const int inrate, const int outrat
|
||||||
const int paddinglen = ResamplerPadding(inrate, outrate);
|
const int paddinglen = ResamplerPadding(inrate, outrate);
|
||||||
const int framelen = chans * (int)sizeof(float);
|
const int framelen = chans * (int)sizeof(float);
|
||||||
const int inframes = inbuflen / framelen;
|
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 maxoutframes = outbuflen / framelen;
|
||||||
const int outframes = SDL_min(wantedoutframes, maxoutframes);
|
const int outframes = SDL_min(wantedoutframes, maxoutframes);
|
||||||
ResampleFloatType outtime = 0.0f;
|
ResampleFloatType outtime = 0.0f;
|
||||||
|
@ -229,7 +229,7 @@ static int SDL_ResampleAudio(const int chans, const int inrate, const int outrat
|
||||||
const int srcframe = srcindex - j;
|
const int srcframe = srcindex - j;
|
||||||
/* !!! FIXME: we can bubble this conditional out of here by doing a pre loop. */
|
/* !!! 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];
|
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! */
|
/* Do the right wing! */
|
||||||
|
@ -238,7 +238,7 @@ static int SDL_ResampleAudio(const int chans, const int inrate, const int outrat
|
||||||
const int srcframe = srcindex + 1 + j;
|
const int srcframe = srcindex + 1 + j;
|
||||||
/* !!! FIXME: we can bubble this conditional out of here by doing a post loop. */
|
/* !!! 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];
|
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;
|
*(dst++) = outsample;
|
||||||
|
@ -312,7 +312,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) {
|
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);
|
return SDL_SetError("Too many filters needed for conversion, exceeded maximum of %d", SDL_AUDIOCVT_MAX_FILTERS);
|
||||||
|
@ -372,7 +372,8 @@ static int SDL_BuildAudioTypeCVTToFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat
|
||||||
cvt->len_mult *= mult;
|
cvt->len_mult *= mult;
|
||||||
cvt->len_ratio *= mult;
|
cvt->len_ratio *= mult;
|
||||||
} else if (src_bitsize > dst_bitsize) {
|
} 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. */
|
retval = 1; /* added a converter. */
|
||||||
|
@ -670,8 +671,8 @@ static SDL_bool SDL_SupportedChannelCount(const int channels)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
||||||
SDL_AudioFormat src_fmt, Uint8 src_channels, int src_rate,
|
SDL_AudioFormat src_format, Uint8 src_channels, int src_rate,
|
||||||
SDL_AudioFormat dst_fmt, Uint8 dst_channels, int dst_rate)
|
SDL_AudioFormat dst_format, Uint8 dst_channels, int dst_rate)
|
||||||
{
|
{
|
||||||
SDL_AudioFilter channel_converter = NULL;
|
SDL_AudioFilter channel_converter = NULL;
|
||||||
|
|
||||||
|
@ -683,10 +684,10 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
||||||
/* Make sure we zero out the audio conversion before error checking */
|
/* Make sure we zero out the audio conversion before error checking */
|
||||||
SDL_zerop(cvt);
|
SDL_zerop(cvt);
|
||||||
|
|
||||||
if (!SDL_SupportedAudioFormat(src_fmt)) {
|
if (!SDL_SupportedAudioFormat(src_format)) {
|
||||||
return SDL_SetError("Invalid source format");
|
return SDL_SetError("Invalid source format");
|
||||||
}
|
}
|
||||||
if (!SDL_SupportedAudioFormat(dst_fmt)) {
|
if (!SDL_SupportedAudioFormat(dst_format)) {
|
||||||
return SDL_SetError("Invalid destination format");
|
return SDL_SetError("Invalid destination format");
|
||||||
}
|
}
|
||||||
if (!SDL_SupportedChannelCount(src_channels)) {
|
if (!SDL_SupportedChannelCount(src_channels)) {
|
||||||
|
@ -710,12 +711,12 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
||||||
|
|
||||||
#if DEBUG_CONVERT
|
#if DEBUG_CONVERT
|
||||||
SDL_Log("SDL_AUDIO_CONVERT: Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
|
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
|
#endif
|
||||||
|
|
||||||
/* Start off with no conversion necessary */
|
/* Start off with no conversion necessary */
|
||||||
cvt->src_format = src_fmt;
|
cvt->src_format = src_format;
|
||||||
cvt->dst_format = dst_fmt;
|
cvt->dst_format = dst_format;
|
||||||
cvt->needed = 0;
|
cvt->needed = 0;
|
||||||
cvt->filter_index = 0;
|
cvt->filter_index = 0;
|
||||||
SDL_zeroa(cvt->filters);
|
SDL_zeroa(cvt->filters);
|
||||||
|
@ -742,13 +743,13 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
||||||
|
|
||||||
/* see if we can skip float conversion entirely. */
|
/* see if we can skip float conversion entirely. */
|
||||||
if (src_rate == dst_rate && src_channels == dst_channels) {
|
if (src_rate == dst_rate && src_channels == dst_channels) {
|
||||||
if (src_fmt == dst_fmt) {
|
if (src_format == dst_format) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* just a byteswap needed? */
|
/* just a byteswap needed? */
|
||||||
if ((src_fmt & ~SDL_AUDIO_MASK_ENDIAN) == (dst_fmt & ~SDL_AUDIO_MASK_ENDIAN)) {
|
if ((src_format & ~SDL_AUDIO_MASK_ENDIAN) == (dst_format & ~SDL_AUDIO_MASK_ENDIAN)) {
|
||||||
if (SDL_AUDIO_BITSIZE(dst_fmt) == 8) {
|
if (SDL_AUDIO_BITSIZE(dst_format) == 8) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (SDL_AddAudioCVTFilter(cvt, SDL_Convert_Byteswap) < 0) {
|
if (SDL_AddAudioCVTFilter(cvt, SDL_Convert_Byteswap) < 0) {
|
||||||
|
@ -760,7 +761,7 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert data types, if necessary. Updates (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... */
|
return -1; /* shouldn't happen, but just in case... */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -816,7 +817,7 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move to final data type. */
|
/* 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... */
|
return -1; /* shouldn't happen, but just in case... */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -858,7 +859,7 @@ struct _SDL_AudioStream
|
||||||
SDL_CleanupAudioStreamResamplerFunc cleanup_resampler_func;
|
SDL_CleanupAudioStreamResamplerFunc cleanup_resampler_func;
|
||||||
};
|
};
|
||||||
|
|
||||||
static Uint8 *EnsureStreamBufferSize(SDL_AudioStream *stream, const int newlen)
|
static Uint8 *EnsureStreamBufferSize(SDL_AudioStream *stream, int newlen)
|
||||||
{
|
{
|
||||||
Uint8 *ptr;
|
Uint8 *ptr;
|
||||||
size_t offset;
|
size_t offset;
|
||||||
|
@ -866,7 +867,7 @@ static Uint8 *EnsureStreamBufferSize(SDL_AudioStream *stream, const int newlen)
|
||||||
if (stream->work_buffer_len >= newlen) {
|
if (stream->work_buffer_len >= newlen) {
|
||||||
ptr = stream->work_buffer_base;
|
ptr = stream->work_buffer_base;
|
||||||
} else {
|
} 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) {
|
if (ptr == NULL) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1002,7 +1003,7 @@ SDL_NewAudioStream(const SDL_AudioFormat src_format,
|
||||||
const Uint8 dst_channels,
|
const Uint8 dst_channels,
|
||||||
const int dst_rate)
|
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;
|
Uint8 pre_resample_channels;
|
||||||
SDL_AudioStream *retval;
|
SDL_AudioStream *retval;
|
||||||
|
|
||||||
|
@ -1088,7 +1089,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) {
|
if (!retval->queue) {
|
||||||
SDL_FreeAudioStream(retval);
|
SDL_FreeAudioStream(retval);
|
||||||
return NULL; /* SDL_NewDataQueue should have called SDL_SetError. */
|
return NULL; /* SDL_NewDataQueue should have called SDL_SetError. */
|
||||||
|
@ -1380,7 +1381,7 @@ void SDL_AudioStreamClear(SDL_AudioStream *stream)
|
||||||
if (stream == NULL) {
|
if (stream == NULL) {
|
||||||
SDL_InvalidParamError("stream");
|
SDL_InvalidParamError("stream");
|
||||||
} else {
|
} else {
|
||||||
SDL_ClearDataQueue(stream->queue, stream->packetlen * 2);
|
SDL_ClearDataQueue(stream->queue, (size_t)stream->packetlen * 2);
|
||||||
if (stream->reset_resampler_func) {
|
if (stream->reset_resampler_func) {
|
||||||
stream->reset_resampler_func(stream);
|
stream->reset_resampler_func(stream);
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,8 +85,11 @@ static void SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int cla
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Figure out what our audio device is */
|
/* Figure out what our audio device is */
|
||||||
if (((audiodev = SDL_getenv("SDL_PATH_DSP")) == NULL) &&
|
audiodev = SDL_getenv("SDL_PATH_DSP");
|
||||||
((audiodev = SDL_getenv("AUDIODEV")) == NULL)) {
|
if (audiodev == NULL) {
|
||||||
|
audiodev = SDL_getenv("AUDIODEV");
|
||||||
|
}
|
||||||
|
if (audiodev == NULL) {
|
||||||
if (classic) {
|
if (classic) {
|
||||||
audiodev = _PATH_DEV_AUDIO;
|
audiodev = _PATH_DEV_AUDIO;
|
||||||
} else {
|
} else {
|
||||||
|
@ -105,8 +108,8 @@ static void SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int cla
|
||||||
if (SDL_strlen(audiodev) < (sizeof(audiopath) - 3)) {
|
if (SDL_strlen(audiodev) < (sizeof(audiopath) - 3)) {
|
||||||
int instance = 0;
|
int instance = 0;
|
||||||
while (instance <= 64) {
|
while (instance <= 64) {
|
||||||
SDL_snprintf(audiopath, SDL_arraysize(audiopath),
|
(void)SDL_snprintf(audiopath, SDL_arraysize(audiopath),
|
||||||
"%s%d", audiodev, instance);
|
"%s%d", audiodev, instance);
|
||||||
instance++;
|
instance++;
|
||||||
test_device(iscapture, audiopath, flags, test);
|
test_device(iscapture, audiopath, flags, test);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1196,7 +1196,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)
|
static void SDLCALL SDL_Convert_F32_to_U8_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
const float *src = (const float *)cvt->buf;
|
const float *src = (const float *)cvt->buf;
|
||||||
Uint8 *dst = (Uint8 *)cvt->buf;
|
Uint8 *dst = cvt->buf;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_U8 (using NEON)");
|
LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_U8 (using NEON)");
|
||||||
|
|
|
@ -547,20 +547,20 @@ static int MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
|
||||||
cstate[c].coeff2 = ddata->coeff[coeffindex * 2 + 1];
|
cstate[c].coeff2 = ddata->coeff[coeffindex * 2 + 1];
|
||||||
|
|
||||||
/* Initial delta value. */
|
/* 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);
|
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
|
/* Load the samples from the header. Interestingly, the sample later in
|
||||||
* the output stream comes first.
|
* 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);
|
sample = state->block.data[o] | ((Sint32)state->block.data[o + 1] << 8);
|
||||||
if (sample >= 0x8000) {
|
if (sample >= 0x8000) {
|
||||||
sample -= 0x10000;
|
sample -= 0x10000;
|
||||||
}
|
}
|
||||||
state->output.data[state->output.pos + channels] = (Sint16)sample;
|
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);
|
sample = state->block.data[o] | ((Sint32)state->block.data[o + 1] << 8);
|
||||||
if (sample >= 0x8000) {
|
if (sample >= 0x8000) {
|
||||||
sample -= 0x10000;
|
sample -= 0x10000;
|
||||||
|
@ -963,7 +963,7 @@ static int IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
|
||||||
size_t i;
|
size_t i;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
const Uint32 channels = state->channels;
|
const Uint32 channels = state->channels;
|
||||||
const size_t subblockframesize = channels * 4;
|
const size_t subblockframesize = (size_t)channels * 4;
|
||||||
Uint64 bytesrequired;
|
Uint64 bytesrequired;
|
||||||
Uint32 c;
|
Uint32 c;
|
||||||
|
|
||||||
|
|
|
@ -376,8 +376,9 @@ static void ALSA_PlayDevice(_THIS)
|
||||||
status = ALSA_snd_pcm_recover(this->hidden->pcm_handle, status, 0);
|
status = ALSA_snd_pcm_recover(this->hidden->pcm_handle, status, 0);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
/* Hmm, not much we can do - abort */
|
/* Hmm, not much we can do - abort */
|
||||||
fprintf(stderr, "ALSA write failed (unrecoverable): %s\n",
|
SDL_LogError(SDL_LOG_CATEGORY_AUDIO,
|
||||||
ALSA_snd_strerror(status));
|
"ALSA write failed (unrecoverable): %s\n",
|
||||||
|
ALSA_snd_strerror(status));
|
||||||
SDL_OpenedAudioDeviceDisconnected(this);
|
SDL_OpenedAudioDeviceDisconnected(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -424,8 +425,9 @@ static int ALSA_CaptureFromDevice(_THIS, void *buffer, int buflen)
|
||||||
status = ALSA_snd_pcm_recover(this->hidden->pcm_handle, status, 0);
|
status = ALSA_snd_pcm_recover(this->hidden->pcm_handle, status, 0);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
/* Hmm, not much we can do - abort */
|
/* Hmm, not much we can do - abort */
|
||||||
fprintf(stderr, "ALSA read failed (unrecoverable): %s\n",
|
SDL_LogError(SDL_LOG_CATEGORY_AUDIO,
|
||||||
ALSA_snd_strerror(status));
|
"ALSA read failed (unrecoverable): %s\n",
|
||||||
|
ALSA_snd_strerror(status));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -508,9 +510,9 @@ static int ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params)
|
||||||
|
|
||||||
ALSA_snd_pcm_hw_params_get_buffer_size(hwparams, &bufsize);
|
ALSA_snd_pcm_hw_params_get_buffer_size(hwparams, &bufsize);
|
||||||
|
|
||||||
fprintf(stderr,
|
SDL_LogError(SDL_LOG_CATEGORY_AUDIO,
|
||||||
"ALSA: period size = %ld, periods = %u, buffer size = %lu\n",
|
"ALSA: period size = %ld, periods = %u, buffer size = %lu\n",
|
||||||
persize, periods, bufsize);
|
persize, periods, bufsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -736,7 +738,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".
|
/* 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
|
just chop the extra lines off, this seems to get a reasonable device
|
||||||
name without extra details. */
|
name without extra details. */
|
||||||
if ((ptr = SDL_strchr(desc, '\n')) != NULL) {
|
ptr = SDL_strchr(desc, '\n');
|
||||||
|
if (ptr != NULL) {
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,17 +100,20 @@ static void build_device_list(int iscapture, addDevFn addfn, void *addfndata)
|
||||||
|
|
||||||
result = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject,
|
result = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject,
|
||||||
&devlist_address, 0, NULL, &size);
|
&devlist_address, 0, NULL, &size);
|
||||||
if (result != kAudioHardwareNoError)
|
if (result != kAudioHardwareNoError) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
devs = (AudioDeviceID *)alloca(size);
|
devs = (AudioDeviceID *)alloca(size);
|
||||||
if (devs == NULL)
|
if (devs == NULL) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
||||||
&devlist_address, 0, NULL, &size, devs);
|
&devlist_address, 0, NULL, &size, devs);
|
||||||
if (result != kAudioHardwareNoError)
|
if (result != kAudioHardwareNoError) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
max = size / sizeof(AudioDeviceID);
|
max = size / sizeof(AudioDeviceID);
|
||||||
for (i = 0; i < max; i++) {
|
for (i = 0; i < max; i++) {
|
||||||
|
@ -139,12 +142,14 @@ static void build_device_list(int iscapture, addDevFn addfn, void *addfndata)
|
||||||
};
|
};
|
||||||
|
|
||||||
result = AudioObjectGetPropertyDataSize(dev, &addr, 0, NULL, &size);
|
result = AudioObjectGetPropertyDataSize(dev, &addr, 0, NULL, &size);
|
||||||
if (result != noErr)
|
if (result != noErr) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
buflist = (AudioBufferList *)SDL_malloc(size);
|
buflist = (AudioBufferList *)SDL_malloc(size);
|
||||||
if (buflist == NULL)
|
if (buflist == NULL) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
result = AudioObjectGetPropertyData(dev, &addr, 0, NULL,
|
result = AudioObjectGetPropertyData(dev, &addr, 0, NULL,
|
||||||
&size, buflist);
|
&size, buflist);
|
||||||
|
@ -159,8 +164,9 @@ static void build_device_list(int iscapture, addDevFn addfn, void *addfndata)
|
||||||
|
|
||||||
SDL_free(buflist);
|
SDL_free(buflist);
|
||||||
|
|
||||||
if (spec.channels == 0)
|
if (spec.channels == 0) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
size = sizeof(sampleRate);
|
size = sizeof(sampleRate);
|
||||||
result = AudioObjectGetPropertyData(dev, &freqaddr, 0, NULL, &size, &sampleRate);
|
result = AudioObjectGetPropertyData(dev, &freqaddr, 0, NULL, &size, &sampleRate);
|
||||||
|
@ -170,8 +176,9 @@ static void build_device_list(int iscapture, addDevFn addfn, void *addfndata)
|
||||||
|
|
||||||
size = sizeof(CFStringRef);
|
size = sizeof(CFStringRef);
|
||||||
result = AudioObjectGetPropertyData(dev, &nameaddr, 0, NULL, &size, &cfstr);
|
result = AudioObjectGetPropertyData(dev, &nameaddr, 0, NULL, &size, &cfstr);
|
||||||
if (result != kAudioHardwareNoError)
|
if (result != kAudioHardwareNoError) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(cfstr),
|
len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(cfstr),
|
||||||
kCFStringEncodingUTF8);
|
kCFStringEncodingUTF8);
|
||||||
|
@ -538,8 +545,9 @@ static void outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBuffe
|
||||||
if (SDL_AudioStreamAvailable(this->stream) > 0) {
|
if (SDL_AudioStreamAvailable(this->stream) > 0) {
|
||||||
int got;
|
int got;
|
||||||
UInt32 len = SDL_AudioStreamAvailable(this->stream);
|
UInt32 len = SDL_AudioStreamAvailable(this->stream);
|
||||||
if (len > remaining)
|
if (len > remaining) {
|
||||||
len = remaining;
|
len = remaining;
|
||||||
|
}
|
||||||
got = SDL_AudioStreamGet(this->stream, ptr, len);
|
got = SDL_AudioStreamGet(this->stream, ptr, len);
|
||||||
SDL_assert((got < 0) || (got == len));
|
SDL_assert((got < 0) || (got == len));
|
||||||
if (got != len) {
|
if (got != len) {
|
||||||
|
@ -983,7 +991,7 @@ static int audioqueue_thread(void *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->iscapture) { /* Drain off any pending playback. */
|
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);
|
CFRunLoopRunInMode(kCFRunLoopDefaultMode, secs, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1082,13 +1090,15 @@ static int COREAUDIO_OpenDevice(_THIS, const char *devname)
|
||||||
}
|
}
|
||||||
this->spec.format = test_format;
|
this->spec.format = test_format;
|
||||||
strdesc->mBitsPerChannel = SDL_AUDIO_BITSIZE(test_format);
|
strdesc->mBitsPerChannel = SDL_AUDIO_BITSIZE(test_format);
|
||||||
if (SDL_AUDIO_ISBIGENDIAN(test_format))
|
if (SDL_AUDIO_ISBIGENDIAN(test_format)) {
|
||||||
strdesc->mFormatFlags |= kLinearPCMFormatFlagIsBigEndian;
|
strdesc->mFormatFlags |= kLinearPCMFormatFlagIsBigEndian;
|
||||||
|
}
|
||||||
|
|
||||||
if (SDL_AUDIO_ISFLOAT(test_format))
|
if (SDL_AUDIO_ISFLOAT(test_format)) {
|
||||||
strdesc->mFormatFlags |= kLinearPCMFormatFlagIsFloat;
|
strdesc->mFormatFlags |= kLinearPCMFormatFlagIsFloat;
|
||||||
else if (SDL_AUDIO_ISSIGNED(test_format))
|
} else if (SDL_AUDIO_ISSIGNED(test_format)) {
|
||||||
strdesc->mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger;
|
strdesc->mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger;
|
||||||
|
}
|
||||||
|
|
||||||
strdesc->mBytesPerFrame = strdesc->mChannelsPerFrame * strdesc->mBitsPerChannel / 8;
|
strdesc->mBytesPerFrame = strdesc->mChannelsPerFrame * strdesc->mBitsPerChannel / 8;
|
||||||
strdesc->mBytesPerPacket = strdesc->mBytesPerFrame * strdesc->mFramesPerPacket;
|
strdesc->mBytesPerPacket = strdesc->mBytesPerFrame * strdesc->mFramesPerPacket;
|
||||||
|
@ -1228,12 +1238,14 @@ static int COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int i
|
||||||
spec->freq = (int)sampleRate;
|
spec->freq = (int)sampleRate;
|
||||||
|
|
||||||
result = AudioObjectGetPropertyDataSize(devid, &bufaddr, 0, NULL, &size);
|
result = AudioObjectGetPropertyDataSize(devid, &bufaddr, 0, NULL, &size);
|
||||||
if (result != noErr)
|
if (result != noErr) {
|
||||||
return SDL_SetError("%s: Default Device Data Size not found", "coreaudio");
|
return SDL_SetError("%s: Default Device Data Size not found", "coreaudio");
|
||||||
|
}
|
||||||
|
|
||||||
buflist = (AudioBufferList *)SDL_malloc(size);
|
buflist = (AudioBufferList *)SDL_malloc(size);
|
||||||
if (buflist == NULL)
|
if (buflist == NULL) {
|
||||||
return SDL_SetError("%s: Default Device Buffer List not found", "coreaudio");
|
return SDL_SetError("%s: Default Device Buffer List not found", "coreaudio");
|
||||||
|
}
|
||||||
|
|
||||||
result = AudioObjectGetPropertyData(devid, &bufaddr, 0, NULL,
|
result = AudioObjectGetPropertyData(devid, &bufaddr, 0, NULL,
|
||||||
&size, buflist);
|
&size, buflist);
|
||||||
|
|
|
@ -197,8 +197,8 @@ static int DSP_OpenDevice(_THIS, const char *devname)
|
||||||
SDL_CalculateAudioSpec(&this->spec);
|
SDL_CalculateAudioSpec(&this->spec);
|
||||||
|
|
||||||
/* Determine the power of two of the fragment size */
|
/* 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) {
|
if ((0x01U << frag_spec) != this->spec.size) {
|
||||||
return SDL_SetError("Fragment size must be a power of two");
|
return SDL_SetError("Fragment size must be a power of two");
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,7 +159,7 @@ static int jackProcessPlaybackCallback(jack_nframes_t nframes, void *arg)
|
||||||
for (channelsi = 0; channelsi < total_channels; channelsi++) {
|
for (channelsi = 0; channelsi < total_channels; channelsi++) {
|
||||||
float *dst = (float *)JACK_jack_port_get_buffer(ports[channelsi], nframes);
|
float *dst = (float *)JACK_jack_port_get_buffer(ports[channelsi], nframes);
|
||||||
if (dst) {
|
if (dst) {
|
||||||
const float *src = ((float *)this->hidden->iobuffer) + channelsi;
|
const float *src = this->hidden->iobuffer + channelsi;
|
||||||
int framesi;
|
int framesi;
|
||||||
for (framesi = 0; framesi < total_frames; framesi++) {
|
for (framesi = 0; framesi < total_frames; framesi++) {
|
||||||
*(dst++) = *src;
|
*(dst++) = *src;
|
||||||
|
@ -199,7 +199,7 @@ static int jackProcessCaptureCallback(jack_nframes_t nframes, void *arg)
|
||||||
for (channelsi = 0; channelsi < total_channels; channelsi++) {
|
for (channelsi = 0; channelsi < total_channels; channelsi++) {
|
||||||
const float *src = (const float *)JACK_jack_port_get_buffer(ports[channelsi], nframes);
|
const float *src = (const float *)JACK_jack_port_get_buffer(ports[channelsi], nframes);
|
||||||
if (src) {
|
if (src) {
|
||||||
float *dst = ((float *)this->hidden->iobuffer) + channelsi;
|
float *dst = this->hidden->iobuffer + channelsi;
|
||||||
int framesi;
|
int framesi;
|
||||||
for (framesi = 0; framesi < total_frames; framesi++) {
|
for (framesi = 0; framesi < total_frames; framesi++) {
|
||||||
*dst = *(src++);
|
*dst = *(src++);
|
||||||
|
@ -309,6 +309,7 @@ static int JACK_OpenDevice(_THIS, const char *devname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (channels == 0) {
|
if (channels == 0) {
|
||||||
|
SDL_free(audio_ports);
|
||||||
return SDL_SetError("No physical JACK ports available");
|
return SDL_SetError("No physical JACK ports available");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,36 +325,42 @@ static int JACK_OpenDevice(_THIS, const char *devname)
|
||||||
|
|
||||||
this->hidden->iosem = SDL_CreateSemaphore(0);
|
this->hidden->iosem = SDL_CreateSemaphore(0);
|
||||||
if (!this->hidden->iosem) {
|
if (!this->hidden->iosem) {
|
||||||
|
SDL_free(audio_ports);
|
||||||
return -1; /* error was set by SDL_CreateSemaphore */
|
return -1; /* error was set by SDL_CreateSemaphore */
|
||||||
}
|
}
|
||||||
|
|
||||||
this->hidden->iobuffer = (float *)SDL_calloc(1, this->spec.size);
|
this->hidden->iobuffer = (float *)SDL_calloc(1, this->spec.size);
|
||||||
if (!this->hidden->iobuffer) {
|
if (!this->hidden->iobuffer) {
|
||||||
|
SDL_free(audio_ports);
|
||||||
return SDL_OutOfMemory();
|
return SDL_OutOfMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Build SDL's ports, which we will connect to the device ports. */
|
/* 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 *));
|
this->hidden->sdlports = (jack_port_t **)SDL_calloc(channels, sizeof(jack_port_t *));
|
||||||
if (this->hidden->sdlports == NULL) {
|
if (this->hidden->sdlports == NULL) {
|
||||||
|
SDL_free(audio_ports);
|
||||||
return SDL_OutOfMemory();
|
return SDL_OutOfMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < channels; i++) {
|
for (i = 0; i < channels; i++) {
|
||||||
char portname[32];
|
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);
|
this->hidden->sdlports[i] = JACK_jack_port_register(client, portname, JACK_DEFAULT_AUDIO_TYPE, sdlportflags, 0);
|
||||||
if (this->hidden->sdlports[i] == NULL) {
|
if (this->hidden->sdlports[i] == NULL) {
|
||||||
|
SDL_free(audio_ports);
|
||||||
return SDL_SetError("jack_port_register failed");
|
return SDL_SetError("jack_port_register failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JACK_jack_set_process_callback(client, callback, this) != 0) {
|
if (JACK_jack_set_process_callback(client, callback, this) != 0) {
|
||||||
|
SDL_free(audio_ports);
|
||||||
return SDL_SetError("JACK: Couldn't set process callback");
|
return SDL_SetError("JACK: Couldn't set process callback");
|
||||||
}
|
}
|
||||||
|
|
||||||
JACK_jack_on_shutdown(client, jackShutdownCallback, this);
|
JACK_jack_on_shutdown(client, jackShutdownCallback, this);
|
||||||
|
|
||||||
if (JACK_jack_activate(client) != 0) {
|
if (JACK_jack_activate(client) != 0) {
|
||||||
|
SDL_free(audio_ports);
|
||||||
return SDL_SetError("Failed to activate JACK client");
|
return SDL_SetError("Failed to activate JACK client");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,6 +370,7 @@ static int JACK_OpenDevice(_THIS, const char *devname)
|
||||||
const char *srcport = iscapture ? devports[audio_ports[i]] : sdlport;
|
const char *srcport = iscapture ? devports[audio_ports[i]] : sdlport;
|
||||||
const char *dstport = iscapture ? sdlport : devports[audio_ports[i]];
|
const char *dstport = iscapture ? sdlport : devports[audio_ports[i]];
|
||||||
if (JACK_jack_connect(client, srcport, dstport) != 0) {
|
if (JACK_jack_connect(client, srcport, dstport) != 0) {
|
||||||
|
SDL_free(audio_ports);
|
||||||
return SDL_SetError("Couldn't connect JACK ports: %s => %s", srcport, dstport);
|
return SDL_SetError("Couldn't connect JACK ports: %s => %s", srcport, dstport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,11 +141,8 @@ static int pipewire_dlsym(const char *fn, void **addr)
|
||||||
|
|
||||||
static int load_pipewire_library()
|
static int load_pipewire_library()
|
||||||
{
|
{
|
||||||
if ((pipewire_handle = SDL_LoadObject(pipewire_library))) {
|
pipewire_handle = SDL_LoadObject(pipewire_library);
|
||||||
return 0;
|
return pipewire_handle != NULL ? 0 : -1;
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unload_pipewire_library()
|
static void unload_pipewire_library()
|
||||||
|
@ -963,7 +960,8 @@ static void output_callback(void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See if a buffer is available */
|
/* 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1032,8 +1030,8 @@ static void input_callback(void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
spa_buf = pw_buf->buffer;
|
spa_buf = pw_buf->buffer;
|
||||||
|
(src = (Uint8 *)spa_buf->datas[0].data);
|
||||||
if ((src = (Uint8 *)spa_buf->datas[0].data) == NULL) {
|
if (src == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1176,7 +1174,9 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
|
||||||
return SDL_SetError("Pipewire: Failed to set audio format parameters");
|
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();
|
return SDL_OutOfMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1188,7 +1188,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
|
||||||
this->spec.size = this->spec.samples * priv->stride;
|
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);
|
priv->loop = PIPEWIRE_pw_thread_loop_new(thread_name, NULL);
|
||||||
if (priv->loop == NULL) {
|
if (priv->loop == NULL) {
|
||||||
return SDL_SetError("Pipewire: Failed to create stream loop (%i)", errno);
|
return SDL_SetError("Pipewire: Failed to create stream loop (%i)", errno);
|
||||||
|
@ -1231,7 +1231,8 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
|
||||||
const struct io_node *node;
|
const struct io_node *node;
|
||||||
|
|
||||||
PIPEWIRE_pw_thread_loop_lock(hotplug_loop);
|
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_properties_set(props, PW_KEY_TARGET_OBJECT, node->path);
|
||||||
}
|
}
|
||||||
PIPEWIRE_pw_thread_loop_unlock(hotplug_loop);
|
PIPEWIRE_pw_thread_loop_unlock(hotplug_loop);
|
||||||
|
|
|
@ -178,7 +178,8 @@ static int SNDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
|
||||||
/* Emulate a blocking read */
|
/* Emulate a blocking read */
|
||||||
r = SNDIO_sio_read(this->hidden->dev, buffer, buflen);
|
r = SNDIO_sio_read(this->hidden->dev, buffer, buflen);
|
||||||
while (r == 0 && !SNDIO_sio_eof(this->hidden->dev)) {
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
revents = SNDIO_sio_revents(this->hidden->dev, this->hidden->pfd);
|
revents = SNDIO_sio_revents(this->hidden->dev, this->hidden->pfd);
|
||||||
|
@ -235,16 +236,18 @@ static int SNDIO_OpenDevice(_THIS, const char *devname)
|
||||||
this->hidden->mixlen = this->spec.size;
|
this->hidden->mixlen = this->spec.size;
|
||||||
|
|
||||||
/* Capture devices must be non-blocking for SNDIO_FlushCapture */
|
/* Capture devices must be non-blocking for SNDIO_FlushCapture */
|
||||||
if ((this->hidden->dev =
|
this->hidden->dev = SNDIO_sio_open(devname != NULL ? devname : SIO_DEVANY,
|
||||||
SNDIO_sio_open(devname != NULL ? devname : SIO_DEVANY,
|
iscapture ? SIO_REC : SIO_PLAY, iscapture);
|
||||||
iscapture ? SIO_REC : SIO_PLAY, iscapture)) == NULL) {
|
if (this->hidden->dev == NULL) {
|
||||||
return SDL_SetError("sio_open() failed");
|
return SDL_SetError("sio_open() failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate the pollfd array for capture devices */
|
/* Allocate the pollfd array for capture devices */
|
||||||
if (iscapture && (this->hidden->pfd =
|
if (iscapture) {
|
||||||
SDL_malloc(sizeof(struct pollfd) * SNDIO_sio_nfds(this->hidden->dev))) == NULL) {
|
this->hidden->pfd = SDL_malloc(sizeof(struct pollfd) * SNDIO_sio_nfds(this->hidden->dev));
|
||||||
return SDL_OutOfMemory();
|
if (this->hidden->pfd == NULL) {
|
||||||
|
return SDL_OutOfMemory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SNDIO_sio_initpar(&par);
|
SNDIO_sio_initpar(&par);
|
||||||
|
@ -280,23 +283,23 @@ static int SNDIO_OpenDevice(_THIS, const char *devname)
|
||||||
return SDL_SetError("%s: Unsupported audio format", "sndio");
|
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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
this->spec.format = AUDIO_U16MSB;
|
||||||
else if ((par.bps == 1) && (par.sig))
|
} else if ((par.bps == 1) && (par.sig)) {
|
||||||
this->spec.format = AUDIO_S8;
|
this->spec.format = AUDIO_S8;
|
||||||
else if ((par.bps == 1) && (!par.sig))
|
} else if ((par.bps == 1) && (!par.sig)) {
|
||||||
this->spec.format = AUDIO_U8;
|
this->spec.format = AUDIO_U8;
|
||||||
else {
|
} else {
|
||||||
return SDL_SetError("sndio: Got unsupported hardware audio format.");
|
return SDL_SetError("sndio: Got unsupported hardware audio format.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2472,7 +2472,6 @@ void Android_JNI_DestroyCustomCursor(int cursorID)
|
||||||
{
|
{
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
(*env)->CallStaticVoidMethod(env, mActivityClass, midDestroyCustomCursor, cursorID);
|
(*env)->CallStaticVoidMethod(env, mActivityClass, midDestroyCustomCursor, cursorID);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool Android_JNI_SetCustomCursor(int cursorID)
|
SDL_bool Android_JNI_SetCustomCursor(int cursorID)
|
||||||
|
|
|
@ -125,8 +125,7 @@ static int SDL_EVDEV_device_removed(const char *dev_path);
|
||||||
|
|
||||||
static int SDL_EVDEV_device_added(const char *dev_path, int udev_class);
|
static int SDL_EVDEV_device_added(const char *dev_path, int udev_class);
|
||||||
#if SDL_USE_LIBUDEV
|
#if SDL_USE_LIBUDEV
|
||||||
static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class,
|
static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_class, const char *dev_path);
|
||||||
const char *dev_path);
|
|
||||||
#endif /* SDL_USE_LIBUDEV */
|
#endif /* SDL_USE_LIBUDEV */
|
||||||
|
|
||||||
static Uint8 EVDEV_MouseButtons[] = {
|
static Uint8 EVDEV_MouseButtons[] = {
|
||||||
|
@ -316,10 +315,11 @@ void SDL_EVDEV_Poll(void)
|
||||||
next finger after earlist is released) */
|
next finger after earlist is released) */
|
||||||
if (item->is_touchscreen && events[i].code == BTN_TOUCH) {
|
if (item->is_touchscreen && events[i].code == BTN_TOUCH) {
|
||||||
if (item->touchscreen_data->max_slots == 1) {
|
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;
|
item->touchscreen_data->slots[0].delta = EVDEV_TOUCH_SLOTDELTA_DOWN;
|
||||||
else
|
} else {
|
||||||
item->touchscreen_data->slots[0].delta = EVDEV_TOUCH_SLOTDELTA_UP;
|
item->touchscreen_data->slots[0].delta = EVDEV_TOUCH_SLOTDELTA_UP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -817,8 +817,8 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
||||||
/* For now, we just treat a touchpad like a touchscreen */
|
/* For now, we just treat a touchpad like a touchscreen */
|
||||||
if (udev_class & (SDL_UDEV_DEVICE_TOUCHSCREEN | SDL_UDEV_DEVICE_TOUCHPAD)) {
|
if (udev_class & (SDL_UDEV_DEVICE_TOUCHSCREEN | SDL_UDEV_DEVICE_TOUCHPAD)) {
|
||||||
item->is_touchscreen = SDL_TRUE;
|
item->is_touchscreen = SDL_TRUE;
|
||||||
|
ret = SDL_EVDEV_init_touchscreen(item, udev_class);
|
||||||
if ((ret = SDL_EVDEV_init_touchscreen(item, udev_class)) < 0) {
|
if (ret < 0) {
|
||||||
close(item->fd);
|
close(item->fd);
|
||||||
SDL_free(item->path);
|
SDL_free(item->path);
|
||||||
SDL_free(item);
|
SDL_free(item);
|
||||||
|
|
|
@ -37,10 +37,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
SDL_EVDEV_GuessDeviceClass(unsigned long bitmask_ev[NBITS(EV_MAX)],
|
SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_ev[NBITS(EV_MAX)],
|
||||||
unsigned long bitmask_abs[NBITS(ABS_MAX)],
|
const unsigned long bitmask_abs[NBITS(ABS_MAX)],
|
||||||
unsigned long bitmask_key[NBITS(KEY_MAX)],
|
const unsigned long bitmask_key[NBITS(KEY_MAX)],
|
||||||
unsigned long bitmask_rel[NBITS(REL_MAX)])
|
const unsigned long bitmask_rel[NBITS(REL_MAX)])
|
||||||
{
|
{
|
||||||
struct range
|
struct range
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,10 +47,10 @@ typedef enum
|
||||||
#define EVDEV_LONG(x) ((x) / BITS_PER_LONG)
|
#define EVDEV_LONG(x) ((x) / BITS_PER_LONG)
|
||||||
#define test_bit(bit, array) ((array[EVDEV_LONG(bit)] >> EVDEV_OFF(bit)) & 1)
|
#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)],
|
extern int SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_ev[NBITS(EV_MAX)],
|
||||||
unsigned long bitmask_abs[NBITS(ABS_MAX)],
|
const unsigned long bitmask_abs[NBITS(ABS_MAX)],
|
||||||
unsigned long bitmask_key[NBITS(KEY_MAX)],
|
const unsigned long bitmask_key[NBITS(KEY_MAX)],
|
||||||
unsigned long bitmask_rel[NBITS(REL_MAX)]);
|
const unsigned long bitmask_rel[NBITS(REL_MAX)]);
|
||||||
|
|
||||||
#endif /* HAVE_LINUX_INPUT_H */
|
#endif /* HAVE_LINUX_INPUT_H */
|
||||||
|
|
||||||
|
|
|
@ -217,7 +217,7 @@ static void kbd_cleanup(void)
|
||||||
|
|
||||||
static void SDL_EVDEV_kbd_reraise_signal(int sig)
|
static void SDL_EVDEV_kbd_reraise_signal(int sig)
|
||||||
{
|
{
|
||||||
raise(sig);
|
(void)raise(sig);
|
||||||
}
|
}
|
||||||
|
|
||||||
siginfo_t *SDL_EVDEV_kdb_cleanup_siginfo = NULL;
|
siginfo_t *SDL_EVDEV_kdb_cleanup_siginfo = NULL;
|
||||||
|
@ -302,7 +302,7 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd)
|
||||||
* functions that are called when the shared library is unloaded.
|
* functions that are called when the shared library is unloaded.
|
||||||
* -- man atexit(3)
|
* -- man atexit(3)
|
||||||
*/
|
*/
|
||||||
atexit(kbd_cleanup_atexit);
|
(void)atexit(kbd_cleanup_atexit);
|
||||||
kbd_cleanup_atexit_installed = 1;
|
kbd_cleanup_atexit_installed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,33 +406,33 @@ SDL_EVDEV_kbd_init(void)
|
||||||
return kbd;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
kbd_unregister_emerg_cleanup();
|
kbd_unregister_emerg_cleanup();
|
||||||
|
|
||||||
if (kbd->console_fd >= 0) {
|
if (state->console_fd >= 0) {
|
||||||
/* Restore the original keyboard mode */
|
/* 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);
|
close(state->console_fd);
|
||||||
kbd->console_fd = -1;
|
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;
|
int i;
|
||||||
for (i = 0; i < MAX_NR_KEYMAPS; ++i) {
|
for (i = 0; i < MAX_NR_KEYMAPS; ++i) {
|
||||||
if (kbd->key_maps[i]) {
|
if (state->key_maps[i]) {
|
||||||
SDL_free(kbd->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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -448,10 +448,9 @@ static void put_queue(SDL_EVDEV_keyboard_state *kbd, uint c)
|
||||||
|
|
||||||
static void put_utf8(SDL_EVDEV_keyboard_state *kbd, uint c)
|
static void put_utf8(SDL_EVDEV_keyboard_state *kbd, uint c)
|
||||||
{
|
{
|
||||||
if (c < 0x80)
|
if (c < 0x80) {
|
||||||
/* 0******* */
|
put_queue(kbd, c); /* 0******* */
|
||||||
put_queue(kbd, c);
|
} else if (c < 0x800) {
|
||||||
else if (c < 0x800) {
|
|
||||||
/* 110***** 10****** */
|
/* 110***** 10****** */
|
||||||
put_queue(kbd, 0xc0 | (c >> 6));
|
put_queue(kbd, 0xc0 | (c >> 6));
|
||||||
put_queue(kbd, 0x80 | (c & 0x3f));
|
put_queue(kbd, 0x80 | (c & 0x3f));
|
||||||
|
@ -625,8 +624,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)
|
static void k_deadunicode(SDL_EVDEV_keyboard_state *kbd, unsigned int value, char up_flag)
|
||||||
{
|
{
|
||||||
if (up_flag)
|
if (up_flag) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
kbd->diacr = (kbd->diacr ? handle_diacr(kbd, value) : value);
|
kbd->diacr = (kbd->diacr ? handle_diacr(kbd, value) : value);
|
||||||
}
|
}
|
||||||
|
@ -659,8 +659,9 @@ static void k_pad(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_fl
|
||||||
{
|
{
|
||||||
static const char pad_chars[] = "0123456789+-*/\015,.?()#";
|
static const char pad_chars[] = "0123456789+-*/\015,.?()#";
|
||||||
|
|
||||||
if (up_flag)
|
if (up_flag) {
|
||||||
return; /* no action, if this is a key release */
|
return; /* no action, if this is a key release */
|
||||||
|
}
|
||||||
|
|
||||||
if (!vc_kbd_led(kbd, K_NUMLOCK)) {
|
if (!vc_kbd_led(kbd, K_NUMLOCK)) {
|
||||||
/* unprintable action */
|
/* unprintable action */
|
||||||
|
@ -674,8 +675,9 @@ static void k_shift(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
|
||||||
{
|
{
|
||||||
int old_state = kbd->shift_state;
|
int old_state = kbd->shift_state;
|
||||||
|
|
||||||
if (kbd->rep)
|
if (kbd->rep) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Mimic typewriter:
|
* Mimic typewriter:
|
||||||
* a CapsShift key acts like Shift but undoes CapsLock
|
* a CapsShift key acts like Shift but undoes CapsLock
|
||||||
|
@ -695,13 +697,15 @@ static void k_shift(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
|
||||||
if (kbd->shift_down[value]) {
|
if (kbd->shift_down[value]) {
|
||||||
kbd->shift_down[value]--;
|
kbd->shift_down[value]--;
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
kbd->shift_down[value]++;
|
kbd->shift_down[value]++;
|
||||||
|
}
|
||||||
|
|
||||||
if (kbd->shift_down[value])
|
if (kbd->shift_down[value]) {
|
||||||
kbd->shift_state |= (1 << value);
|
kbd->shift_state |= (1 << value);
|
||||||
else
|
} else {
|
||||||
kbd->shift_state &= ~(1 << value);
|
kbd->shift_state &= ~(1 << value);
|
||||||
|
}
|
||||||
|
|
||||||
/* kludge */
|
/* kludge */
|
||||||
if (up_flag && kbd->shift_state != old_state && kbd->npadch != -1) {
|
if (up_flag && kbd->shift_state != old_state && kbd->npadch != -1) {
|
||||||
|
@ -718,8 +722,9 @@ static void k_ascii(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
|
||||||
{
|
{
|
||||||
int base;
|
int base;
|
||||||
|
|
||||||
if (up_flag)
|
if (up_flag) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (value < 10) {
|
if (value < 10) {
|
||||||
/* decimal input of code, while Alt depressed */
|
/* decimal input of code, while Alt depressed */
|
||||||
|
@ -730,16 +735,18 @@ static void k_ascii(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
|
||||||
base = 16;
|
base = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kbd->npadch == -1)
|
if (kbd->npadch == -1) {
|
||||||
kbd->npadch = value;
|
kbd->npadch = value;
|
||||||
else
|
} else {
|
||||||
kbd->npadch = kbd->npadch * base + value;
|
kbd->npadch = kbd->npadch * base + value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void k_lock(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag)
|
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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
chg_vc_kbd_lock(kbd, value);
|
chg_vc_kbd_lock(kbd, value);
|
||||||
}
|
}
|
||||||
|
@ -747,8 +754,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)
|
static void k_slock(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag)
|
||||||
{
|
{
|
||||||
k_shift(kbd, value, up_flag);
|
k_shift(kbd, value, up_flag);
|
||||||
if (up_flag || kbd->rep)
|
if (up_flag || kbd->rep) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
chg_vc_kbd_slock(kbd, value);
|
chg_vc_kbd_slock(kbd, value);
|
||||||
/* try to make Alt, oops, AltGr and such work */
|
/* try to make Alt, oops, AltGr and such work */
|
||||||
|
@ -762,26 +770,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 shift_final;
|
||||||
unsigned char type;
|
unsigned char type;
|
||||||
unsigned short *key_map;
|
unsigned short *key_map;
|
||||||
unsigned short keysym;
|
unsigned short keysym;
|
||||||
|
|
||||||
if (kbd == NULL) {
|
if (state == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
kbd->rep = (down == 2);
|
state->rep = (down == 2);
|
||||||
|
|
||||||
shift_final = (kbd->shift_state | kbd->slockstate) ^ kbd->lockstate;
|
shift_final = (state->shift_state | state->slockstate) ^ state->lockstate;
|
||||||
key_map = kbd->key_maps[shift_final];
|
key_map = state->key_maps[shift_final];
|
||||||
if (key_map == NULL) {
|
if (key_map == NULL) {
|
||||||
/* Unsupported shift state (e.g. ctrl = 4, alt = 8), just reset to the default state */
|
/* Unsupported shift state (e.g. ctrl = 4, alt = 8), just reset to the default state */
|
||||||
kbd->shift_state = 0;
|
state->shift_state = 0;
|
||||||
kbd->slockstate = 0;
|
state->slockstate = 0;
|
||||||
kbd->lockstate = 0;
|
state->lockstate = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -795,7 +803,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode,
|
||||||
|
|
||||||
if (type < 0xf0) {
|
if (type < 0xf0) {
|
||||||
if (down) {
|
if (down) {
|
||||||
put_utf8(kbd, keysym);
|
put_utf8(state, keysym);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
type -= 0xf0;
|
type -= 0xf0;
|
||||||
|
@ -804,25 +812,25 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode,
|
||||||
if (type == KT_LETTER) {
|
if (type == KT_LETTER) {
|
||||||
type = KT_LATIN;
|
type = KT_LATIN;
|
||||||
|
|
||||||
if (vc_kbd_led(kbd, K_CAPSLOCK)) {
|
if (vc_kbd_led(state, K_CAPSLOCK)) {
|
||||||
key_map = kbd->key_maps[shift_final ^ (1 << KG_SHIFT)];
|
key_map = state->key_maps[shift_final ^ (1 << KG_SHIFT)];
|
||||||
if (key_map) {
|
if (key_map) {
|
||||||
keysym = key_map[keycode];
|
keysym = key_map[keycode];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(*k_handler[type])(kbd, keysym & 0xff, !down);
|
(*k_handler[type])(state, keysym & 0xff, !down);
|
||||||
|
|
||||||
if (type != KT_SLOCK) {
|
if (type != KT_SLOCK) {
|
||||||
kbd->slockstate = 0;
|
state->slockstate = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kbd->text_len > 0) {
|
if (state->text_len > 0) {
|
||||||
kbd->text[kbd->text_len] = '\0';
|
state->text[state->text_len] = '\0';
|
||||||
SDL_SendKeyboardText(kbd->text);
|
SDL_SendKeyboardText(state->text);
|
||||||
kbd->text_len = 0;
|
state->text_len = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,9 +63,9 @@ static char *GetAppName()
|
||||||
int linksize;
|
int linksize;
|
||||||
|
|
||||||
#if defined(__LINUX__)
|
#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__)
|
#elif defined(__FREEBSD__)
|
||||||
SDL_snprintf(procfile, sizeof(procfile), "/proc/%d/file", getpid());
|
(void)SDL_snprintf(procfile, sizeof procfile, "/proc/%d/file", getpid());
|
||||||
#endif
|
#endif
|
||||||
linksize = readlink(procfile, linkfile, sizeof(linkfile) - 1);
|
linksize = readlink(procfile, linkfile, sizeof(linkfile) - 1);
|
||||||
if (linksize > 0) {
|
if (linksize > 0) {
|
||||||
|
|
|
@ -323,7 +323,7 @@ static char *IBus_ReadAddressFromFile(const char *file_path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(addr_file);
|
(void)fclose(addr_file);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
return SDL_strdup(addr_buf + (sizeof("IBUS_ADDRESS=") - 1));
|
return SDL_strdup(addr_buf + (sizeof("IBUS_ADDRESS=") - 1));
|
||||||
|
@ -406,14 +406,14 @@ static char *IBus_GetDBusAddressFilename(void)
|
||||||
SDL_free(display);
|
SDL_free(display);
|
||||||
return NULL;
|
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();
|
key = dbus->get_local_machine_id();
|
||||||
|
|
||||||
SDL_memset(file_path, 0, sizeof(file_path));
|
SDL_memset(file_path, 0, sizeof(file_path));
|
||||||
SDL_snprintf(file_path, sizeof(file_path), "%s/ibus/bus/%s-%s-%s",
|
(void)SDL_snprintf(file_path, sizeof file_path, "%s/ibus/bus/%s-%s-%s",
|
||||||
config_dir, key, host, disp_num);
|
config_dir, key, host, disp_num);
|
||||||
dbus->free(key);
|
dbus->free(key);
|
||||||
SDL_free(display);
|
SDL_free(display);
|
||||||
|
|
||||||
|
@ -487,7 +487,7 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
char matchstr[128];
|
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);
|
SDL_free(input_ctx_path);
|
||||||
input_ctx_path = SDL_strdup(path);
|
input_ctx_path = SDL_strdup(path);
|
||||||
SDL_AddHintCallback(SDL_HINT_IME_INTERNAL_EDITING, IBus_SetCapabilities, NULL);
|
SDL_AddHintCallback(SDL_HINT_IME_INTERNAL_EDITING, IBus_SetCapabilities, NULL);
|
||||||
|
|
|
@ -266,10 +266,10 @@ WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr = (const unsigned char *)guid;
|
ptr = (const unsigned char *)guid;
|
||||||
SDL_snprintf(keystr, sizeof(keystr),
|
(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}",
|
"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[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]);
|
ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13], ptr[14], ptr[15]);
|
||||||
|
|
||||||
strw = WIN_UTF8ToString(keystr);
|
strw = WIN_UTF8ToString(keystr);
|
||||||
rc = (RegOpenKeyExW(HKEY_LOCAL_MACHINE, strw, 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS);
|
rc = (RegOpenKeyExW(HKEY_LOCAL_MACHINE, strw, 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS);
|
||||||
|
|
|
@ -176,7 +176,7 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this is to make SDL_snprintf() calls cleaner. */
|
/* this is to make (void)SDL_snprintf() calls cleaner. */
|
||||||
#define uint unsigned int
|
#define uint unsigned int
|
||||||
|
|
||||||
name[0] = '\0';
|
name[0] = '\0';
|
||||||
|
@ -188,13 +188,13 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||||
char plusstr[16];
|
char plusstr[16];
|
||||||
SDL_strlcpy(name, "SDL_USEREVENT", sizeof(name));
|
SDL_strlcpy(name, "SDL_USEREVENT", sizeof(name));
|
||||||
if (event->type > SDL_USEREVENT) {
|
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 {
|
} else {
|
||||||
plusstr[0] = '\0';
|
plusstr[0] = '\0';
|
||||||
}
|
}
|
||||||
SDL_snprintf(details, sizeof(details), "%s (timestamp=%u windowid=%u code=%d data1=%p data2=%p)",
|
(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,
|
plusstr, (uint)event->user.timestamp, (uint)event->user.windowID,
|
||||||
(int)event->user.code, event->user.data1, event->user.data2);
|
(int)event->user.code, event->user.data1, event->user.data2);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
|
@ -205,7 +205,7 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||||
SDL_strlcpy(details, " (THIS IS PROBABLY A BUG!)", sizeof(details));
|
SDL_strlcpy(details, " (THIS IS PROBABLY A BUG!)", sizeof(details));
|
||||||
break;
|
break;
|
||||||
SDL_EVENT_CASE(SDL_QUIT)
|
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;
|
break;
|
||||||
SDL_EVENT_CASE(SDL_APP_TERMINATING)
|
SDL_EVENT_CASE(SDL_APP_TERMINATING)
|
||||||
break;
|
break;
|
||||||
|
@ -249,8 +249,8 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||||
SDL_strlcpy(name2, "UNKNOWN (bug? fixme?)", sizeof(name2));
|
SDL_strlcpy(name2, "UNKNOWN (bug? fixme?)", sizeof(name2));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u display=%u event=%s data1=%d)",
|
(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);
|
(uint)event->display.timestamp, (uint)event->display.display, name2, (int)event->display.data1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,24 +288,24 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||||
SDL_strlcpy(name2, "UNKNOWN (bug? fixme?)", sizeof(name2));
|
SDL_strlcpy(name2, "UNKNOWN (bug? fixme?)", sizeof(name2));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u event=%s data1=%d data2=%d)",
|
(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);
|
(uint)event->window.timestamp, (uint)event->window.windowID, name2, (int)event->window.data1, (int)event->window.data2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_EVENT_CASE(SDL_SYSWMEVENT)
|
SDL_EVENT_CASE(SDL_SYSWMEVENT)
|
||||||
/* !!! FIXME: we don't delve further at the moment. */
|
/* !!! 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;
|
break;
|
||||||
|
|
||||||
#define PRINT_KEY_EVENT(event) \
|
#define PRINT_KEY_EVENT(event) \
|
||||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u state=%s repeat=%s scancode=%u keycode=%u mod=%u)", \
|
(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, \
|
(uint)event->key.timestamp, (uint)event->key.windowID, \
|
||||||
event->key.state == SDL_PRESSED ? "pressed" : "released", \
|
event->key.state == SDL_PRESSED ? "pressed" : "released", \
|
||||||
event->key.repeat ? "true" : "false", \
|
event->key.repeat ? "true" : "false", \
|
||||||
(uint)event->key.keysym.scancode, \
|
(uint)event->key.keysym.scancode, \
|
||||||
(uint)event->key.keysym.sym, \
|
(uint)event->key.keysym.sym, \
|
||||||
(uint)event->key.keysym.mod)
|
(uint)event->key.keysym.mod)
|
||||||
SDL_EVENT_CASE(SDL_KEYDOWN)
|
SDL_EVENT_CASE(SDL_KEYDOWN)
|
||||||
PRINT_KEY_EVENT(event);
|
PRINT_KEY_EVENT(event);
|
||||||
break;
|
break;
|
||||||
|
@ -315,29 +315,29 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||||
#undef PRINT_KEY_EVENT
|
#undef PRINT_KEY_EVENT
|
||||||
|
|
||||||
SDL_EVENT_CASE(SDL_TEXTEDITING)
|
SDL_EVENT_CASE(SDL_TEXTEDITING)
|
||||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u text='%s' start=%d length=%d)",
|
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u text='%s' start=%d length=%d)",
|
||||||
(uint)event->edit.timestamp, (uint)event->edit.windowID,
|
(uint)event->edit.timestamp, (uint)event->edit.windowID,
|
||||||
event->edit.text, (int)event->edit.start, (int)event->edit.length);
|
event->edit.text, (int)event->edit.start, (int)event->edit.length);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
SDL_EVENT_CASE(SDL_TEXTINPUT)
|
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;
|
break;
|
||||||
|
|
||||||
SDL_EVENT_CASE(SDL_MOUSEMOTION)
|
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)",
|
(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.timestamp, (uint)event->motion.windowID,
|
||||||
(uint)event->motion.which, (uint)event->motion.state,
|
(uint)event->motion.which, (uint)event->motion.state,
|
||||||
(int)event->motion.x, (int)event->motion.y,
|
(int)event->motion.x, (int)event->motion.y,
|
||||||
(int)event->motion.xrel, (int)event->motion.yrel);
|
(int)event->motion.xrel, (int)event->motion.yrel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#define PRINT_MBUTTON_EVENT(event) \
|
#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)", \
|
(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.timestamp, (uint)event->button.windowID, \
|
||||||
(uint)event->button.which, (uint)event->button.button, \
|
(uint)event->button.which, (uint)event->button.button, \
|
||||||
event->button.state == SDL_PRESSED ? "pressed" : "released", \
|
event->button.state == SDL_PRESSED ? "pressed" : "released", \
|
||||||
(uint)event->button.clicks, (int)event->button.x, (int)event->button.y)
|
(uint)event->button.clicks, (int)event->button.x, (int)event->button.y)
|
||||||
SDL_EVENT_CASE(SDL_MOUSEBUTTONDOWN)
|
SDL_EVENT_CASE(SDL_MOUSEBUTTONDOWN)
|
||||||
PRINT_MBUTTON_EVENT(event);
|
PRINT_MBUTTON_EVENT(event);
|
||||||
break;
|
break;
|
||||||
|
@ -347,35 +347,35 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||||
#undef PRINT_MBUTTON_EVENT
|
#undef PRINT_MBUTTON_EVENT
|
||||||
|
|
||||||
SDL_EVENT_CASE(SDL_MOUSEWHEEL)
|
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)",
|
(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.timestamp, (uint)event->wheel.windowID,
|
||||||
(uint)event->wheel.which, (int)event->wheel.x, (int)event->wheel.y,
|
(uint)event->wheel.which, (int)event->wheel.x, (int)event->wheel.y,
|
||||||
event->wheel.preciseX, event->wheel.preciseY,
|
event->wheel.preciseX, event->wheel.preciseY,
|
||||||
event->wheel.direction == SDL_MOUSEWHEEL_NORMAL ? "normal" : "flipped");
|
event->wheel.direction == SDL_MOUSEWHEEL_NORMAL ? "normal" : "flipped");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
SDL_EVENT_CASE(SDL_JOYAXISMOTION)
|
SDL_EVENT_CASE(SDL_JOYAXISMOTION)
|
||||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d axis=%u value=%d)",
|
(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.timestamp, (int)event->jaxis.which,
|
||||||
(uint)event->jaxis.axis, (int)event->jaxis.value);
|
(uint)event->jaxis.axis, (int)event->jaxis.value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
SDL_EVENT_CASE(SDL_JOYBALLMOTION)
|
SDL_EVENT_CASE(SDL_JOYBALLMOTION)
|
||||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d ball=%u xrel=%d yrel=%d)",
|
(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.timestamp, (int)event->jball.which,
|
||||||
(uint)event->jball.ball, (int)event->jball.xrel, (int)event->jball.yrel);
|
(uint)event->jball.ball, (int)event->jball.xrel, (int)event->jball.yrel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
SDL_EVENT_CASE(SDL_JOYHATMOTION)
|
SDL_EVENT_CASE(SDL_JOYHATMOTION)
|
||||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d hat=%u value=%u)",
|
(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.timestamp, (int)event->jhat.which,
|
||||||
(uint)event->jhat.hat, (uint)event->jhat.value);
|
(uint)event->jhat.hat, (uint)event->jhat.value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#define PRINT_JBUTTON_EVENT(event) \
|
#define PRINT_JBUTTON_EVENT(event) \
|
||||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d button=%u state=%s)", \
|
(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.timestamp, (int)event->jbutton.which, \
|
||||||
(uint)event->jbutton.button, event->jbutton.state == SDL_PRESSED ? "pressed" : "released")
|
(uint)event->jbutton.button, event->jbutton.state == SDL_PRESSED ? "pressed" : "released")
|
||||||
SDL_EVENT_CASE(SDL_JOYBUTTONDOWN)
|
SDL_EVENT_CASE(SDL_JOYBUTTONDOWN)
|
||||||
PRINT_JBUTTON_EVENT(event);
|
PRINT_JBUTTON_EVENT(event);
|
||||||
break;
|
break;
|
||||||
|
@ -384,7 +384,7 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||||
break;
|
break;
|
||||||
#undef PRINT_JBUTTON_EVENT
|
#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)
|
SDL_EVENT_CASE(SDL_JOYDEVICEADDED)
|
||||||
PRINT_JOYDEV_EVENT(event);
|
PRINT_JOYDEV_EVENT(event);
|
||||||
break;
|
break;
|
||||||
|
@ -394,15 +394,15 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||||
#undef PRINT_JOYDEV_EVENT
|
#undef PRINT_JOYDEV_EVENT
|
||||||
|
|
||||||
SDL_EVENT_CASE(SDL_CONTROLLERAXISMOTION)
|
SDL_EVENT_CASE(SDL_CONTROLLERAXISMOTION)
|
||||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d axis=%u value=%d)",
|
(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.timestamp, (int)event->caxis.which,
|
||||||
(uint)event->caxis.axis, (int)event->caxis.value);
|
(uint)event->caxis.axis, (int)event->caxis.value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#define PRINT_CBUTTON_EVENT(event) \
|
#define PRINT_CBUTTON_EVENT(event) \
|
||||||
SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d button=%u state=%s)", \
|
(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.timestamp, (int)event->cbutton.which, \
|
||||||
(uint)event->cbutton.button, event->cbutton.state == SDL_PRESSED ? "pressed" : "released")
|
(uint)event->cbutton.button, event->cbutton.state == SDL_PRESSED ? "pressed" : "released")
|
||||||
SDL_EVENT_CASE(SDL_CONTROLLERBUTTONDOWN)
|
SDL_EVENT_CASE(SDL_CONTROLLERBUTTONDOWN)
|
||||||
PRINT_CBUTTON_EVENT(event);
|
PRINT_CBUTTON_EVENT(event);
|
||||||
break;
|
break;
|
||||||
|
@ -411,7 +411,7 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||||
break;
|
break;
|
||||||
#undef PRINT_CBUTTON_EVENT
|
#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)
|
SDL_EVENT_CASE(SDL_CONTROLLERDEVICEADDED)
|
||||||
PRINT_CONTROLLERDEV_EVENT(event);
|
PRINT_CONTROLLERDEV_EVENT(event);
|
||||||
break;
|
break;
|
||||||
|
@ -423,11 +423,11 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||||
break;
|
break;
|
||||||
#undef PRINT_CONTROLLERDEV_EVENT
|
#undef PRINT_CONTROLLERDEV_EVENT
|
||||||
|
|
||||||
#define PRINT_CTOUCHPAD_EVENT(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)", \
|
(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, \
|
(uint)event->ctouchpad.timestamp, (int)event->ctouchpad.which, \
|
||||||
(int)event->ctouchpad.touchpad, (int)event->ctouchpad.finger, \
|
(int)event->ctouchpad.touchpad, (int)event->ctouchpad.finger, \
|
||||||
event->ctouchpad.x, event->ctouchpad.y, event->ctouchpad.pressure)
|
event->ctouchpad.x, event->ctouchpad.y, event->ctouchpad.pressure)
|
||||||
SDL_EVENT_CASE(SDL_CONTROLLERTOUCHPADDOWN)
|
SDL_EVENT_CASE(SDL_CONTROLLERTOUCHPADDOWN)
|
||||||
PRINT_CTOUCHPAD_EVENT(event);
|
PRINT_CTOUCHPAD_EVENT(event);
|
||||||
break;
|
break;
|
||||||
|
@ -440,16 +440,16 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||||
#undef PRINT_CTOUCHPAD_EVENT
|
#undef PRINT_CTOUCHPAD_EVENT
|
||||||
|
|
||||||
SDL_EVENT_CASE(SDL_CONTROLLERSENSORUPDATE)
|
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)",
|
(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,
|
(uint)event->csensor.timestamp, (int)event->csensor.which, (int)event->csensor.sensor,
|
||||||
event->csensor.data[0], event->csensor.data[1], event->csensor.data[2]);
|
event->csensor.data[0], event->csensor.data[1], event->csensor.data[2]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#define PRINT_FINGER_EVENT(event) \
|
#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)", \
|
(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, \
|
(uint)event->tfinger.timestamp, (long long)event->tfinger.touchId, \
|
||||||
(long long)event->tfinger.fingerId, event->tfinger.x, event->tfinger.y, \
|
(long long)event->tfinger.fingerId, event->tfinger.x, event->tfinger.y, \
|
||||||
event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure)
|
event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure)
|
||||||
SDL_EVENT_CASE(SDL_FINGERDOWN)
|
SDL_EVENT_CASE(SDL_FINGERDOWN)
|
||||||
PRINT_FINGER_EVENT(event);
|
PRINT_FINGER_EVENT(event);
|
||||||
break;
|
break;
|
||||||
|
@ -461,11 +461,11 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||||
break;
|
break;
|
||||||
#undef PRINT_FINGER_EVENT
|
#undef PRINT_FINGER_EVENT
|
||||||
|
|
||||||
#define PRINT_DOLLAR_EVENT(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)", \
|
(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, \
|
(uint)event->dgesture.timestamp, (long long)event->dgesture.touchId, \
|
||||||
(long long)event->dgesture.gestureId, (uint)event->dgesture.numFingers, \
|
(long long)event->dgesture.gestureId, (uint)event->dgesture.numFingers, \
|
||||||
event->dgesture.error, event->dgesture.x, event->dgesture.y)
|
event->dgesture.error, event->dgesture.x, event->dgesture.y)
|
||||||
SDL_EVENT_CASE(SDL_DOLLARGESTURE)
|
SDL_EVENT_CASE(SDL_DOLLARGESTURE)
|
||||||
PRINT_DOLLAR_EVENT(event);
|
PRINT_DOLLAR_EVENT(event);
|
||||||
break;
|
break;
|
||||||
|
@ -475,13 +475,13 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||||
#undef PRINT_DOLLAR_EVENT
|
#undef PRINT_DOLLAR_EVENT
|
||||||
|
|
||||||
SDL_EVENT_CASE(SDL_MULTIGESTURE)
|
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)",
|
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u touchid=%" SDL_PRIs64 " dtheta=%f ddist=%f x=%f y=%f numfingers=%u)",
|
||||||
(uint)event->mgesture.timestamp, (long long)event->mgesture.touchId,
|
(uint)event->mgesture.timestamp, (long long)event->mgesture.touchId,
|
||||||
event->mgesture.dTheta, event->mgesture.dDist,
|
event->mgesture.dTheta, event->mgesture.dDist,
|
||||||
event->mgesture.x, event->mgesture.y, (uint)event->mgesture.numFingers);
|
event->mgesture.x, event->mgesture.y, (uint)event->mgesture.numFingers);
|
||||||
break;
|
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)
|
SDL_EVENT_CASE(SDL_DROPFILE)
|
||||||
PRINT_DROP_EVENT(event);
|
PRINT_DROP_EVENT(event);
|
||||||
break;
|
break;
|
||||||
|
@ -496,7 +496,7 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||||
break;
|
break;
|
||||||
#undef PRINT_DROP_EVENT
|
#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)
|
SDL_EVENT_CASE(SDL_AUDIODEVICEADDED)
|
||||||
PRINT_AUDIODEV_EVENT(event);
|
PRINT_AUDIODEV_EVENT(event);
|
||||||
break;
|
break;
|
||||||
|
@ -506,10 +506,10 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||||
#undef PRINT_AUDIODEV_EVENT
|
#undef PRINT_AUDIODEV_EVENT
|
||||||
|
|
||||||
SDL_EVENT_CASE(SDL_SENSORUPDATE)
|
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)",
|
(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,
|
(uint)event->sensor.timestamp, (int)event->sensor.which,
|
||||||
event->sensor.data[0], event->sensor.data[1], event->sensor.data[2],
|
event->sensor.data[0], event->sensor.data[1], event->sensor.data[2],
|
||||||
event->sensor.data[3], event->sensor.data[4], event->sensor.data[5]);
|
event->sensor.data[3], event->sensor.data[4], event->sensor.data[5]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#undef SDL_EVENT_CASE
|
#undef SDL_EVENT_CASE
|
||||||
|
@ -521,7 +521,7 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||||
default:
|
default:
|
||||||
if (!name[0]) {
|
if (!name[0]) {
|
||||||
SDL_strlcpy(name, "UNKNOWN", sizeof(name));
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1151,10 +1151,11 @@ SDL_GetScancodeName(SDL_Scancode scancode)
|
||||||
}
|
}
|
||||||
|
|
||||||
name = SDL_scancode_names[scancode];
|
name = SDL_scancode_names[scancode];
|
||||||
if (name)
|
if (name != NULL) {
|
||||||
return name;
|
return name;
|
||||||
else
|
}
|
||||||
return "";
|
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Scancode SDL_GetScancodeFromName(const char *name)
|
SDL_Scancode SDL_GetScancodeFromName(const char *name)
|
||||||
|
|
|
@ -67,7 +67,7 @@ extern SDL_bool SDL_HardwareKeyboardKeyPressed(void);
|
||||||
extern int SDL_SendKeyboardText(const char *text);
|
extern int SDL_SendKeyboardText(const char *text);
|
||||||
|
|
||||||
/* Send editing text for selected range from start to end */
|
/* 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 */
|
/* Shutdown the keyboard subsystem */
|
||||||
extern void SDL_KeyboardQuit(void);
|
extern void SDL_KeyboardQuit(void);
|
||||||
|
|
|
@ -372,7 +372,7 @@ static int GetScaledMouseDelta(float scale, int value, float *accum)
|
||||||
return value;
|
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 i;
|
||||||
int n = mouse->num_system_scale_values;
|
int n = mouse->num_system_scale_values;
|
||||||
|
|
|
@ -47,7 +47,7 @@ static SDL_bool send_foregrounding_pending = SDL_FALSE;
|
||||||
static void SDL_HandleSIG(int sig)
|
static void SDL_HandleSIG(int sig)
|
||||||
{
|
{
|
||||||
/* Reset the signal handler */
|
/* Reset the signal handler */
|
||||||
signal(sig, SDL_HandleSIG);
|
(void)signal(sig, SDL_HandleSIG);
|
||||||
|
|
||||||
/* Send a quit event next time the event loop pumps. */
|
/* Send a quit event next time the event loop pumps. */
|
||||||
/* We can't send it in signal handler; SDL_malloc() might be interrupted! */
|
/* We can't send it in signal handler; SDL_malloc() might be interrupted! */
|
||||||
|
|
|
@ -691,7 +691,7 @@ void SDL_FreeRW(SDL_RWops *area)
|
||||||
void *
|
void *
|
||||||
SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, int freesrc)
|
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;
|
Sint64 size;
|
||||||
size_t size_read, size_total;
|
size_t size_read, size_total;
|
||||||
void *data = NULL, *newdata;
|
void *data = NULL, *newdata;
|
||||||
|
|
|
@ -42,7 +42,7 @@ FILE *SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode)
|
||||||
NSString *full_path_with_file_to_try;
|
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 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);
|
return fopen(file, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -307,9 +307,9 @@ SDL_GetPrefPath(const char *org, const char *app)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*org) {
|
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 {
|
} 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++) {
|
for (ptr = retval + 1; *ptr; ptr++) {
|
||||||
|
|
|
@ -240,12 +240,13 @@ int SDL_JoystickIsHaptic(SDL_Joystick *joystick)
|
||||||
|
|
||||||
ret = SDL_SYS_JoystickIsHaptic(joystick);
|
ret = SDL_SYS_JoystickIsHaptic(joystick);
|
||||||
|
|
||||||
if (ret > 0)
|
if (ret > 0) {
|
||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
else if (ret == 0)
|
} else if (ret == 0) {
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
else
|
}
|
||||||
return -1;
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -163,7 +163,6 @@ void SDL_SYS_HapticClose(SDL_Haptic *haptic)
|
||||||
{
|
{
|
||||||
((SDL_hapticlist_item *)haptic->hwdata)->haptic = NULL;
|
((SDL_hapticlist_item *)haptic->hwdata)->haptic = NULL;
|
||||||
haptic->hwdata = NULL;
|
haptic->hwdata = NULL;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_SYS_HapticQuit(void)
|
void SDL_SYS_HapticQuit(void)
|
||||||
|
@ -219,11 +218,9 @@ int SDL_SYS_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
|
||||||
|
|
||||||
void SDL_SYS_HapticDestroyEffect(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,
|
int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *effect)
|
||||||
struct haptic_effect *effect)
|
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1201,8 +1201,9 @@ int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
|
||||||
/* Check if it's infinite. */
|
/* Check if it's infinite. */
|
||||||
if (iterations == SDL_HAPTIC_INFINITY) {
|
if (iterations == SDL_HAPTIC_INFINITY) {
|
||||||
iter = FF_INFINITE;
|
iter = FF_INFINITE;
|
||||||
} else
|
} else {
|
||||||
iter = iterations;
|
iter = iterations;
|
||||||
|
}
|
||||||
|
|
||||||
/* Run the effect. */
|
/* Run the effect. */
|
||||||
ret = FFEffectStart(effect->hweffect->ref, iter, 0);
|
ret = FFEffectStart(effect->hweffect->ref, iter, 0);
|
||||||
|
|
|
@ -152,8 +152,7 @@ int SDL_SYS_HapticInit(void)
|
||||||
*/
|
*/
|
||||||
i = 0;
|
i = 0;
|
||||||
for (j = 0; j < MAX_HAPTICS; ++j) {
|
for (j = 0; j < MAX_HAPTICS; ++j) {
|
||||||
|
(void)SDL_snprintf(path, PATH_MAX, joydev_pattern, i++);
|
||||||
SDL_snprintf(path, PATH_MAX, joydev_pattern, i++);
|
|
||||||
MaybeAddDevice(path);
|
MaybeAddDevice(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -665,11 +664,11 @@ static int SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection *src)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_HAPTIC_CARTESIAN:
|
case SDL_HAPTIC_CARTESIAN:
|
||||||
if (!src->dir[1])
|
if (!src->dir[1]) {
|
||||||
*dest = (src->dir[0] >= 0 ? 0x4000 : 0xC000);
|
*dest = (src->dir[0] >= 0 ? 0x4000 : 0xC000);
|
||||||
else if (!src->dir[0])
|
} else if (!src->dir[0]) {
|
||||||
*dest = (src->dir[1] >= 0 ? 0x8000 : 0);
|
*dest = (src->dir[1] >= 0 ? 0x8000 : 0);
|
||||||
else {
|
} else {
|
||||||
float f = SDL_atan2(src->dir[1], src->dir[0]); /* Ideally we'd use fixed point math instead of floats... */
|
float f = SDL_atan2(src->dir[1], src->dir[0]); /* Ideally we'd use fixed point math instead of floats... */
|
||||||
/*
|
/*
|
||||||
SDL_atan2 takes the parameters: Y-axis-value and X-axis-value (in that order)
|
SDL_atan2 takes the parameters: Y-axis-value and X-axis-value (in that order)
|
||||||
|
|
|
@ -658,10 +658,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||||
dest->lpvTypeSpecificParams = constant;
|
dest->lpvTypeSpecificParams = constant;
|
||||||
|
|
||||||
/* Generics */
|
/* Generics */
|
||||||
dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */
|
dest->dwDuration = hap_constant->length * 1000UL; /* In microseconds. */
|
||||||
dest->dwTriggerButton = DIGetTriggerButton(hap_constant->button);
|
dest->dwTriggerButton = DIGetTriggerButton(hap_constant->button);
|
||||||
dest->dwTriggerRepeatInterval = hap_constant->interval;
|
dest->dwTriggerRepeatInterval = hap_constant->interval;
|
||||||
dest->dwStartDelay = hap_constant->delay * 1000; /* In microseconds. */
|
dest->dwStartDelay = hap_constant->delay * 1000UL; /* In microseconds. */
|
||||||
|
|
||||||
/* Direction. */
|
/* Direction. */
|
||||||
if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) {
|
if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) {
|
||||||
|
@ -674,9 +674,9 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||||
dest->lpEnvelope = NULL;
|
dest->lpEnvelope = NULL;
|
||||||
} else {
|
} else {
|
||||||
envelope->dwAttackLevel = CCONVERT(hap_constant->attack_level);
|
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->dwFadeLevel = CCONVERT(hap_constant->fade_level);
|
||||||
envelope->dwFadeTime = hap_constant->fade_length * 1000;
|
envelope->dwFadeTime = hap_constant->fade_length * 1000UL;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -704,10 +704,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||||
dest->lpvTypeSpecificParams = periodic;
|
dest->lpvTypeSpecificParams = periodic;
|
||||||
|
|
||||||
/* Generics */
|
/* Generics */
|
||||||
dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */
|
dest->dwDuration = hap_periodic->length * 1000UL; /* In microseconds. */
|
||||||
dest->dwTriggerButton = DIGetTriggerButton(hap_periodic->button);
|
dest->dwTriggerButton = DIGetTriggerButton(hap_periodic->button);
|
||||||
dest->dwTriggerRepeatInterval = hap_periodic->interval;
|
dest->dwTriggerRepeatInterval = hap_periodic->interval;
|
||||||
dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */
|
dest->dwStartDelay = hap_periodic->delay * 1000UL; /* In microseconds. */
|
||||||
|
|
||||||
/* Direction. */
|
/* Direction. */
|
||||||
if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) {
|
if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) {
|
||||||
|
@ -720,9 +720,9 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||||
dest->lpEnvelope = NULL;
|
dest->lpEnvelope = NULL;
|
||||||
} else {
|
} else {
|
||||||
envelope->dwAttackLevel = CCONVERT(hap_periodic->attack_level);
|
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->dwFadeLevel = CCONVERT(hap_periodic->fade_level);
|
||||||
envelope->dwFadeTime = hap_periodic->fade_length * 1000;
|
envelope->dwFadeTime = hap_periodic->fade_length * 1000UL;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -755,10 +755,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||||
dest->lpvTypeSpecificParams = condition;
|
dest->lpvTypeSpecificParams = condition;
|
||||||
|
|
||||||
/* Generics */
|
/* Generics */
|
||||||
dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */
|
dest->dwDuration = hap_condition->length * 1000UL; /* In microseconds. */
|
||||||
dest->dwTriggerButton = DIGetTriggerButton(hap_condition->button);
|
dest->dwTriggerButton = DIGetTriggerButton(hap_condition->button);
|
||||||
dest->dwTriggerRepeatInterval = hap_condition->interval;
|
dest->dwTriggerRepeatInterval = hap_condition->interval;
|
||||||
dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */
|
dest->dwStartDelay = hap_condition->delay * 1000UL; /* In microseconds. */
|
||||||
|
|
||||||
/* Direction. */
|
/* Direction. */
|
||||||
if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) {
|
if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) {
|
||||||
|
@ -786,10 +786,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||||
dest->lpvTypeSpecificParams = ramp;
|
dest->lpvTypeSpecificParams = ramp;
|
||||||
|
|
||||||
/* Generics */
|
/* Generics */
|
||||||
dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */
|
dest->dwDuration = hap_ramp->length * 1000UL; /* In microseconds. */
|
||||||
dest->dwTriggerButton = DIGetTriggerButton(hap_ramp->button);
|
dest->dwTriggerButton = DIGetTriggerButton(hap_ramp->button);
|
||||||
dest->dwTriggerRepeatInterval = hap_ramp->interval;
|
dest->dwTriggerRepeatInterval = hap_ramp->interval;
|
||||||
dest->dwStartDelay = hap_ramp->delay * 1000; /* In microseconds. */
|
dest->dwStartDelay = hap_ramp->delay * 1000UL; /* In microseconds. */
|
||||||
|
|
||||||
/* Direction. */
|
/* Direction. */
|
||||||
if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) {
|
if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) {
|
||||||
|
@ -802,9 +802,9 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||||
dest->lpEnvelope = NULL;
|
dest->lpEnvelope = NULL;
|
||||||
} else {
|
} else {
|
||||||
envelope->dwAttackLevel = CCONVERT(hap_ramp->attack_level);
|
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->dwFadeLevel = CCONVERT(hap_ramp->fade_level);
|
||||||
envelope->dwFadeTime = hap_ramp->fade_length * 1000;
|
envelope->dwFadeTime = hap_ramp->fade_length * 1000UL;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -819,7 +819,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||||
|
|
||||||
/* Specifics */
|
/* Specifics */
|
||||||
custom->cChannels = hap_custom->channels;
|
custom->cChannels = hap_custom->channels;
|
||||||
custom->dwSamplePeriod = hap_custom->period * 1000;
|
custom->dwSamplePeriod = hap_custom->period * 1000UL;
|
||||||
custom->cSamples = hap_custom->samples;
|
custom->cSamples = hap_custom->samples;
|
||||||
custom->rglForceData =
|
custom->rglForceData =
|
||||||
SDL_malloc(sizeof(LONG) * custom->cSamples * custom->cChannels);
|
SDL_malloc(sizeof(LONG) * custom->cSamples * custom->cChannels);
|
||||||
|
@ -830,10 +830,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||||
dest->lpvTypeSpecificParams = custom;
|
dest->lpvTypeSpecificParams = custom;
|
||||||
|
|
||||||
/* Generics */
|
/* Generics */
|
||||||
dest->dwDuration = hap_custom->length * 1000; /* In microseconds. */
|
dest->dwDuration = hap_custom->length * 1000UL; /* In microseconds. */
|
||||||
dest->dwTriggerButton = DIGetTriggerButton(hap_custom->button);
|
dest->dwTriggerButton = DIGetTriggerButton(hap_custom->button);
|
||||||
dest->dwTriggerRepeatInterval = hap_custom->interval;
|
dest->dwTriggerRepeatInterval = hap_custom->interval;
|
||||||
dest->dwStartDelay = hap_custom->delay * 1000; /* In microseconds. */
|
dest->dwStartDelay = hap_custom->delay * 1000UL; /* In microseconds. */
|
||||||
|
|
||||||
/* Direction. */
|
/* Direction. */
|
||||||
if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) < 0) {
|
if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) < 0) {
|
||||||
|
@ -846,9 +846,9 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||||
dest->lpEnvelope = NULL;
|
dest->lpEnvelope = NULL;
|
||||||
} else {
|
} else {
|
||||||
envelope->dwAttackLevel = CCONVERT(hap_custom->attack_level);
|
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->dwFadeLevel = CCONVERT(hap_custom->fade_level);
|
||||||
envelope->dwFadeTime = hap_custom->fade_length * 1000;
|
envelope->dwFadeTime = hap_custom->fade_length * 1000UL;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -887,6 +887,7 @@ static void SDL_SYS_HapticFreeDIEFFECT(DIEFFECT *effect, int type)
|
||||||
/*
|
/*
|
||||||
* Gets the effect type from the generic SDL haptic effect wrapper.
|
* 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)
|
static REFGUID SDL_SYS_HapticEffectType(SDL_HapticEffect *effect)
|
||||||
{
|
{
|
||||||
switch (effect->type) {
|
switch (effect->type) {
|
||||||
|
@ -1082,7 +1083,7 @@ int SDL_DINPUT_HapticSetGain(SDL_Haptic *haptic, int gain)
|
||||||
dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
||||||
dipdw.diph.dwObj = 0;
|
dipdw.diph.dwObj = 0;
|
||||||
dipdw.diph.dwHow = DIPH_DEVICE;
|
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. */
|
/* Try to set the autocenter. */
|
||||||
ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device,
|
ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device,
|
||||||
|
|
|
@ -88,7 +88,7 @@ int SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid)
|
||||||
/* !!! FIXME: I'm not bothering to query for a real name right now (can we even?) */
|
/* !!! FIXME: I'm not bothering to query for a real name right now (can we even?) */
|
||||||
{
|
{
|
||||||
char buf[64];
|
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);
|
item->name = SDL_strdup(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us
|
||||||
return SDL_SetError("Couldn't create XInput haptic mutex");
|
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);
|
haptic->hwdata->thread = SDL_CreateThreadInternal(SDL_RunXInputHaptic, threadName, 64 * 1024, haptic->hwdata);
|
||||||
|
|
||||||
if (haptic->hwdata->thread == NULL) {
|
if (haptic->hwdata->thread == NULL) {
|
||||||
|
|
|
@ -53,12 +53,10 @@
|
||||||
#include "../core/linux/SDL_udev.h"
|
#include "../core/linux/SDL_udev.h"
|
||||||
#ifdef SDL_USE_LIBUDEV
|
#ifdef SDL_USE_LIBUDEV
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include "../core/linux/SDL_sandbox.h"
|
#include "../core/linux/SDL_sandbox.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_INOTIFY
|
#ifdef HAVE_INOTIFY
|
||||||
#include <unistd.h> /* just in case we didn't use that SDL_USE_LIBUDEV block... */
|
|
||||||
#include <string.h> /* strerror */
|
#include <string.h> /* strerror */
|
||||||
#include <errno.h> /* errno */
|
#include <errno.h> /* errno */
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -66,6 +64,10 @@
|
||||||
#include <sys/inotify.h>
|
#include <sys/inotify.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(SDL_USE_LIBUDEV) || defined(HAVE_INOTIFY)
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(SDL_USE_LIBUDEV)
|
#if defined(SDL_USE_LIBUDEV)
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
@ -312,15 +314,15 @@ HIDAPI_InitializeDiscovery()
|
||||||
SDL_HIDAPI_discovery.m_nUdevFd = -1;
|
SDL_HIDAPI_discovery.m_nUdevFd = -1;
|
||||||
|
|
||||||
usyms = SDL_UDEV_GetUdevSyms();
|
usyms = SDL_UDEV_GetUdevSyms();
|
||||||
if (usyms) {
|
if (usyms != NULL) {
|
||||||
SDL_HIDAPI_discovery.m_pUdev = usyms->udev_new();
|
SDL_HIDAPI_discovery.m_pUdev = usyms->udev_new();
|
||||||
}
|
if (SDL_HIDAPI_discovery.m_pUdev != NULL) {
|
||||||
if (SDL_HIDAPI_discovery.m_pUdev) {
|
SDL_HIDAPI_discovery.m_pUdevMonitor = usyms->udev_monitor_new_from_netlink(SDL_HIDAPI_discovery.m_pUdev, "udev");
|
||||||
SDL_HIDAPI_discovery.m_pUdevMonitor = usyms->udev_monitor_new_from_netlink(SDL_HIDAPI_discovery.m_pUdev, "udev");
|
if (SDL_HIDAPI_discovery.m_pUdevMonitor != NULL) {
|
||||||
if (SDL_HIDAPI_discovery.m_pUdevMonitor) {
|
usyms->udev_monitor_enable_receiving(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_nUdevFd = usyms->udev_monitor_get_fd(SDL_HIDAPI_discovery.m_pUdevMonitor);
|
SDL_HIDAPI_discovery.m_bCanGetNotifications = SDL_TRUE;
|
||||||
SDL_HIDAPI_discovery.m_bCanGetNotifications = SDL_TRUE;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
@ -1374,22 +1376,27 @@ SDL_hid_device *SDL_hid_open(unsigned short vendor_id, unsigned short product_id
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_PLATFORM_BACKEND
|
#if HAVE_PLATFORM_BACKEND
|
||||||
if (udev_ctx &&
|
if (udev_ctx) {
|
||||||
(pDevice = PLATFORM_hid_open(vendor_id, product_id, serial_number)) != NULL) {
|
pDevice = PLATFORM_hid_open(vendor_id, product_id, serial_number);
|
||||||
return CreateHIDDeviceWrapper(pDevice, &PLATFORM_Backend);
|
if (pDevice != NULL) {
|
||||||
|
return CreateHIDDeviceWrapper(pDevice, &PLATFORM_Backend);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* HAVE_PLATFORM_BACKEND */
|
#endif /* HAVE_PLATFORM_BACKEND */
|
||||||
|
|
||||||
#if HAVE_DRIVER_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);
|
return CreateHIDDeviceWrapper(pDevice, &DRIVER_Backend);
|
||||||
}
|
}
|
||||||
#endif /* HAVE_DRIVER_BACKEND */
|
#endif /* HAVE_DRIVER_BACKEND */
|
||||||
|
|
||||||
#ifdef HAVE_LIBUSB
|
#ifdef HAVE_LIBUSB
|
||||||
if (libusb_ctx.libhandle &&
|
if (libusb_ctx.libhandle != NULL) {
|
||||||
(pDevice = LIBUSB_hid_open(vendor_id, product_id, serial_number)) != NULL) {
|
pDevice = LIBUSB_hid_open(vendor_id, product_id, serial_number);
|
||||||
return CreateHIDDeviceWrapper(pDevice, &LIBUSB_Backend);
|
if (pDevice != NULL) {
|
||||||
|
return CreateHIDDeviceWrapper(pDevice, &LIBUSB_Backend);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* HAVE_LIBUSB */
|
#endif /* HAVE_LIBUSB */
|
||||||
|
|
||||||
|
@ -1408,22 +1415,27 @@ SDL_hid_device *SDL_hid_open_path(const char *path, int bExclusive /* = false */
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_PLATFORM_BACKEND
|
#if HAVE_PLATFORM_BACKEND
|
||||||
if (udev_ctx &&
|
if (udev_ctx) {
|
||||||
(pDevice = PLATFORM_hid_open_path(path, bExclusive)) != NULL) {
|
pDevice = PLATFORM_hid_open_path(path, bExclusive);
|
||||||
return CreateHIDDeviceWrapper(pDevice, &PLATFORM_Backend);
|
if (pDevice != NULL) {
|
||||||
|
return CreateHIDDeviceWrapper(pDevice, &PLATFORM_Backend);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* HAVE_PLATFORM_BACKEND */
|
#endif /* HAVE_PLATFORM_BACKEND */
|
||||||
|
|
||||||
#if HAVE_DRIVER_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);
|
return CreateHIDDeviceWrapper(pDevice, &DRIVER_Backend);
|
||||||
}
|
}
|
||||||
#endif /* HAVE_DRIVER_BACKEND */
|
#endif /* HAVE_DRIVER_BACKEND */
|
||||||
|
|
||||||
#ifdef HAVE_LIBUSB
|
#ifdef HAVE_LIBUSB
|
||||||
if (libusb_ctx.libhandle &&
|
if (libusb_ctx.libhandle != NULL) {
|
||||||
(pDevice = LIBUSB_hid_open_path(path, bExclusive)) != NULL) {
|
pDevice = LIBUSB_hid_open_path(path, bExclusive);
|
||||||
return CreateHIDDeviceWrapper(pDevice, &LIBUSB_Backend);
|
if (pDevice != NULL) {
|
||||||
|
return CreateHIDDeviceWrapper(pDevice, &LIBUSB_Backend);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* HAVE_LIBUSB */
|
#endif /* HAVE_LIBUSB */
|
||||||
|
|
||||||
|
|
|
@ -821,20 +821,21 @@ static const char *map_StringForControllerAxis[] = {
|
||||||
/*
|
/*
|
||||||
* convert a string to its enum equivalent
|
* convert a string to its enum equivalent
|
||||||
*/
|
*/
|
||||||
SDL_GameControllerAxis SDL_GameControllerGetAxisFromString(const char *pchString)
|
SDL_GameControllerAxis
|
||||||
|
SDL_GameControllerGetAxisFromString(const char *str)
|
||||||
{
|
{
|
||||||
int entry;
|
int entry;
|
||||||
|
|
||||||
if (pchString && (*pchString == '+' || *pchString == '-')) {
|
if (str == NULL || str[0] == '\0') {
|
||||||
++pchString;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pchString == NULL || !pchString[0]) {
|
|
||||||
return SDL_CONTROLLER_AXIS_INVALID;
|
return SDL_CONTROLLER_AXIS_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (*str == '+' || *str == '-') {
|
||||||
|
++str;
|
||||||
|
}
|
||||||
|
|
||||||
for (entry = 0; map_StringForControllerAxis[entry]; ++entry) {
|
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;
|
return (SDL_GameControllerAxis)entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -880,15 +881,16 @@ static const char *map_StringForControllerButton[] = {
|
||||||
/*
|
/*
|
||||||
* convert a string to its enum equivalent
|
* convert a string to its enum equivalent
|
||||||
*/
|
*/
|
||||||
SDL_GameControllerButton SDL_GameControllerGetButtonFromString(const char *pchString)
|
SDL_GameControllerButton
|
||||||
|
SDL_GameControllerGetButtonFromString(const char *str)
|
||||||
{
|
{
|
||||||
int entry;
|
int entry;
|
||||||
if (pchString == NULL || !pchString[0]) {
|
if (str == NULL || str[0] == '\0') {
|
||||||
return SDL_CONTROLLER_BUTTON_INVALID;
|
return SDL_CONTROLLER_BUTTON_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (entry = 0; map_StringForControllerButton[entry]; ++entry) {
|
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;
|
return (SDL_GameControllerButton)entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -898,10 +900,10 @@ SDL_GameControllerButton SDL_GameControllerGetButtonFromString(const char *pchSt
|
||||||
/*
|
/*
|
||||||
* convert an enum to its string equivalent
|
* 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) {
|
if (button > SDL_CONTROLLER_BUTTON_INVALID && button < SDL_CONTROLLER_BUTTON_MAX) {
|
||||||
return map_StringForControllerButton[axis];
|
return map_StringForControllerButton[button];
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1067,7 +1069,7 @@ static void SDL_PrivateLoadButtonMapping(SDL_GameController *gamecontroller, Con
|
||||||
gamecontroller->name = pControllerMapping->name;
|
gamecontroller->name = pControllerMapping->name;
|
||||||
gamecontroller->num_bindings = 0;
|
gamecontroller->num_bindings = 0;
|
||||||
gamecontroller->mapping = pControllerMapping;
|
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));
|
SDL_memset(gamecontroller->last_match_axis, 0, gamecontroller->joystick->naxes * sizeof(*gamecontroller->last_match_axis));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1347,13 +1349,13 @@ static void SDL_PrivateAppendToMappingString(char *mapping_string,
|
||||||
SDL_strlcat(mapping_string, ":", mapping_string_len);
|
SDL_strlcat(mapping_string, ":", mapping_string_len);
|
||||||
switch (mapping->kind) {
|
switch (mapping->kind) {
|
||||||
case EMappingKind_Button:
|
case EMappingKind_Button:
|
||||||
SDL_snprintf(buffer, sizeof(buffer), "b%i", mapping->target);
|
(void)SDL_snprintf(buffer, sizeof buffer, "b%i", mapping->target);
|
||||||
break;
|
break;
|
||||||
case EMappingKind_Axis:
|
case EMappingKind_Axis:
|
||||||
SDL_snprintf(buffer, sizeof(buffer), "a%i", mapping->target);
|
(void)SDL_snprintf(buffer, sizeof buffer, "a%i", mapping->target);
|
||||||
break;
|
break;
|
||||||
case EMappingKind_Hat:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
SDL_assert(SDL_FALSE);
|
SDL_assert(SDL_FALSE);
|
||||||
|
@ -1381,7 +1383,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), "a", &raw_map->a);
|
||||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "b", &raw_map->b);
|
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "b", &raw_map->b);
|
||||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "x", &raw_map->x);
|
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "x", &raw_map->x);
|
||||||
|
@ -1673,7 +1675,7 @@ static char *CreateMappingString(ControllerMapping_t *mapping, SDL_JoystickGUID
|
||||||
return NULL;
|
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 (!SDL_strstr(mapping->mapping, SDL_CONTROLLER_PLATFORM_FIELD)) {
|
||||||
if (mapping->mapping[SDL_strlen(mapping->mapping) - 1] != ',') {
|
if (mapping->mapping[SDL_strlen(mapping->mapping) - 1] != ',') {
|
||||||
|
@ -1844,12 +1846,12 @@ int SDL_GameControllerInit(void)
|
||||||
* Get the implementation dependent name of a controller
|
* Get the implementation dependent name of a controller
|
||||||
*/
|
*/
|
||||||
const char *
|
const char *
|
||||||
SDL_GameControllerNameForIndex(int device_index)
|
SDL_GameControllerNameForIndex(int joystick_index)
|
||||||
{
|
{
|
||||||
ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(device_index);
|
ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(joystick_index);
|
||||||
if (pSupportedController) {
|
if (pSupportedController != NULL) {
|
||||||
if (SDL_strcmp(pSupportedController->name, "*") == 0) {
|
if (SDL_strcmp(pSupportedController->name, "*") == 0) {
|
||||||
return SDL_JoystickNameForIndex(device_index);
|
return SDL_JoystickNameForIndex(joystick_index);
|
||||||
} else {
|
} else {
|
||||||
return pSupportedController->name;
|
return pSupportedController->name;
|
||||||
}
|
}
|
||||||
|
@ -1861,11 +1863,11 @@ SDL_GameControllerNameForIndex(int device_index)
|
||||||
* Get the implementation dependent path of a controller
|
* Get the implementation dependent path of a controller
|
||||||
*/
|
*/
|
||||||
const char *
|
const char *
|
||||||
SDL_GameControllerPathForIndex(int device_index)
|
SDL_GameControllerPathForIndex(int joystick_index)
|
||||||
{
|
{
|
||||||
ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(device_index);
|
ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(joystick_index);
|
||||||
if (pSupportedController) {
|
if (pSupportedController != NULL) {
|
||||||
return SDL_JoystickPathForIndex(device_index);
|
return SDL_JoystickPathForIndex(joystick_index);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1906,7 +1908,7 @@ SDL_GameControllerMappingForDeviceIndex(int joystick_index)
|
||||||
SDL_UnlockJoysticks();
|
SDL_UnlockJoysticks();
|
||||||
return NULL;
|
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();
|
SDL_UnlockJoysticks();
|
||||||
return pMappingString;
|
return pMappingString;
|
||||||
|
@ -1929,10 +1931,10 @@ SDL_IsGameControllerNameAndGUID(const char *name, SDL_JoystickGUID guid)
|
||||||
* Return 1 if the joystick at this device index is a supported controller
|
* Return 1 if the joystick at this device index is a supported controller
|
||||||
*/
|
*/
|
||||||
SDL_bool
|
SDL_bool
|
||||||
SDL_IsGameController(int device_index)
|
SDL_IsGameController(int joystick_index)
|
||||||
{
|
{
|
||||||
ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(device_index);
|
ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(joystick_index);
|
||||||
if (pSupportedController) {
|
if (pSupportedController != NULL) {
|
||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
}
|
}
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
|
@ -2038,7 +2040,7 @@ SDL_bool SDL_ShouldIgnoreGameController(const char *name, SDL_JoystickGUID guid)
|
||||||
* This function returns a controller identifier, or NULL if an error occurred.
|
* This function returns a controller identifier, or NULL if an error occurred.
|
||||||
*/
|
*/
|
||||||
SDL_GameController *
|
SDL_GameController *
|
||||||
SDL_GameControllerOpen(int device_index)
|
SDL_GameControllerOpen(int joystick_index)
|
||||||
{
|
{
|
||||||
SDL_JoystickID instance_id;
|
SDL_JoystickID instance_id;
|
||||||
SDL_GameController *gamecontroller;
|
SDL_GameController *gamecontroller;
|
||||||
|
@ -2049,8 +2051,8 @@ SDL_GameControllerOpen(int device_index)
|
||||||
|
|
||||||
gamecontrollerlist = SDL_gamecontrollers;
|
gamecontrollerlist = SDL_gamecontrollers;
|
||||||
/* If the controller is already open, return it */
|
/* If the controller is already open, return it */
|
||||||
instance_id = SDL_JoystickGetDeviceInstanceID(device_index);
|
instance_id = SDL_JoystickGetDeviceInstanceID(joystick_index);
|
||||||
while (gamecontrollerlist) {
|
while (gamecontrollerlist != NULL) {
|
||||||
if (instance_id == gamecontrollerlist->joystick->instance_id) {
|
if (instance_id == gamecontrollerlist->joystick->instance_id) {
|
||||||
gamecontroller = gamecontrollerlist;
|
gamecontroller = gamecontrollerlist;
|
||||||
++gamecontroller->ref_count;
|
++gamecontroller->ref_count;
|
||||||
|
@ -2061,9 +2063,9 @@ SDL_GameControllerOpen(int device_index)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find a controller mapping */
|
/* Find a controller mapping */
|
||||||
pSupportedController = SDL_PrivateGetControllerMapping(device_index);
|
pSupportedController = SDL_PrivateGetControllerMapping(joystick_index);
|
||||||
if (pSupportedController == NULL) {
|
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();
|
SDL_UnlockJoysticks();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -2077,8 +2079,8 @@ SDL_GameControllerOpen(int device_index)
|
||||||
}
|
}
|
||||||
gamecontroller->magic = &gamecontroller_magic;
|
gamecontroller->magic = &gamecontroller_magic;
|
||||||
|
|
||||||
gamecontroller->joystick = SDL_JoystickOpen(device_index);
|
gamecontroller->joystick = SDL_JoystickOpen(joystick_index);
|
||||||
if (!gamecontroller->joystick) {
|
if (gamecontroller->joystick == NULL) {
|
||||||
SDL_free(gamecontroller);
|
SDL_free(gamecontroller);
|
||||||
SDL_UnlockJoysticks();
|
SDL_UnlockJoysticks();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -1874,7 +1874,7 @@ SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_name, c
|
||||||
len = (SDL_strlen(vendor_name) + 1 + SDL_strlen(product_name) + 1);
|
len = (SDL_strlen(vendor_name) + 1 + SDL_strlen(product_name) + 1);
|
||||||
name = (char *)SDL_malloc(len);
|
name = (char *)SDL_malloc(len);
|
||||||
if (name) {
|
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) {
|
} else if (*product_name) {
|
||||||
name = SDL_strdup(product_name);
|
name = SDL_strdup(product_name);
|
||||||
|
@ -1902,8 +1902,8 @@ SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_name, c
|
||||||
default:
|
default:
|
||||||
len = (6 + 1 + 6 + 1);
|
len = (6 + 1 + 6 + 1);
|
||||||
name = (char *)SDL_malloc(len);
|
name = (char *)SDL_malloc(len);
|
||||||
if (name) {
|
if (name != NULL) {
|
||||||
SDL_snprintf(name, len, "0x%.4x/0x%.4x", vendor, product);
|
(void)SDL_snprintf(name, len, "0x%.4x/0x%.4x", vendor, product);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1306,10 +1306,10 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface SDL_RumbleContext : NSObject
|
@interface SDL_RumbleContext : NSObject
|
||||||
@property(nonatomic, strong) SDL_RumbleMotor *m_low_frequency_motor;
|
@property(nonatomic, strong) SDL_RumbleMotor *lowFrequencyMotor;
|
||||||
@property(nonatomic, strong) SDL_RumbleMotor *m_high_frequency_motor;
|
@property(nonatomic, strong) SDL_RumbleMotor *highFrequencyMotor;
|
||||||
@property(nonatomic, strong) SDL_RumbleMotor *m_left_trigger_motor;
|
@property(nonatomic, strong) SDL_RumbleMotor *leftTriggerMotor;
|
||||||
@property(nonatomic, strong) SDL_RumbleMotor *m_right_trigger_motor;
|
@property(nonatomic, strong) SDL_RumbleMotor *rightTriggerMotor;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation SDL_RumbleContext
|
@implementation SDL_RumbleContext
|
||||||
|
@ -1322,10 +1322,10 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
||||||
RightTriggerMotor:(SDL_RumbleMotor *)right_trigger_motor
|
RightTriggerMotor:(SDL_RumbleMotor *)right_trigger_motor
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
self.m_low_frequency_motor = low_frequency_motor;
|
self.lowFrequencyMotor = low_frequency_motor;
|
||||||
self.m_high_frequency_motor = high_frequency_motor;
|
self.highFrequencyMotor = high_frequency_motor;
|
||||||
self.m_left_trigger_motor = left_trigger_motor;
|
self.leftTriggerMotor = left_trigger_motor;
|
||||||
self.m_right_trigger_motor = right_trigger_motor;
|
self.rightTriggerMotor = right_trigger_motor;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1333,8 +1333,8 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
result += [self.m_low_frequency_motor setIntensity:((float)low_frequency_rumble / 65535.0f)];
|
result += [self.lowFrequencyMotor setIntensity:((float)low_frequency_rumble / 65535.0f)];
|
||||||
result += [self.m_high_frequency_motor setIntensity:((float)high_frequency_rumble / 65535.0f)];
|
result += [self.highFrequencyMotor setIntensity:((float)high_frequency_rumble / 65535.0f)];
|
||||||
return ((result < 0) ? -1 : 0);
|
return ((result < 0) ? -1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1342,9 +1342,9 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
if (self.m_left_trigger_motor && self.m_right_trigger_motor) {
|
if (self.leftTriggerMotor && self.rightTriggerMotor) {
|
||||||
result += [self.m_left_trigger_motor setIntensity:((float)left_rumble / 65535.0f)];
|
result += [self.leftTriggerMotor setIntensity:((float)left_rumble / 65535.0f)];
|
||||||
result += [self.m_right_trigger_motor setIntensity:((float)right_rumble / 65535.0f)];
|
result += [self.rightTriggerMotor setIntensity:((float)right_rumble / 65535.0f)];
|
||||||
} else {
|
} else {
|
||||||
result = SDL_Unsupported();
|
result = SDL_Unsupported();
|
||||||
}
|
}
|
||||||
|
@ -1353,8 +1353,8 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
||||||
|
|
||||||
- (void)cleanup
|
- (void)cleanup
|
||||||
{
|
{
|
||||||
[self.m_low_frequency_motor cleanup];
|
[self.lowFrequencyMotor cleanup];
|
||||||
[self.m_high_frequency_motor cleanup];
|
[self.highFrequencyMotor cleanup];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -1671,6 +1671,7 @@ SDL_bool IOS_SupportedHIDDevice(IOHIDDeviceRef device)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SDL_JOYSTICK_MFI) && defined(ENABLE_PHYSICAL_INPUT_PROFILE)
|
#if defined(SDL_JOYSTICK_MFI) && defined(ENABLE_PHYSICAL_INPUT_PROFILE)
|
||||||
|
/* NOLINTNEXTLINE(readability-non-const-parameter): getCString takes a non-const char* */
|
||||||
static void GetAppleSFSymbolsNameForElement(GCControllerElement *element, char *name)
|
static void GetAppleSFSymbolsNameForElement(GCControllerElement *element, char *name)
|
||||||
{
|
{
|
||||||
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
|
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
|
||||||
|
|
|
@ -517,7 +517,6 @@ static SDL_bool JoystickAlreadyKnown(IOHIDDeviceRef ioHIDDeviceObject)
|
||||||
static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDeviceRef ioHIDDeviceObject)
|
static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDeviceRef ioHIDDeviceObject)
|
||||||
{
|
{
|
||||||
recDevice *device;
|
recDevice *device;
|
||||||
int device_index = 0;
|
|
||||||
io_service_t ioservice;
|
io_service_t ioservice;
|
||||||
|
|
||||||
if (res != kIOReturnSuccess) {
|
if (res != kIOReturnSuccess) {
|
||||||
|
@ -568,12 +567,10 @@ static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender
|
||||||
recDevice *curdevice;
|
recDevice *curdevice;
|
||||||
|
|
||||||
curdevice = gpDeviceList;
|
curdevice = gpDeviceList;
|
||||||
while (curdevice->pNext) {
|
while (curdevice->pNext != NULL) {
|
||||||
++device_index;
|
|
||||||
curdevice = curdevice->pNext;
|
curdevice = curdevice->pNext;
|
||||||
}
|
}
|
||||||
curdevice->pNext = device;
|
curdevice->pNext = device;
|
||||||
++device_index; /* bump by one since we counted by pNext. */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_PrivateJoystickAdded(device->instance_id);
|
SDL_PrivateJoystickAdded(device->instance_id);
|
||||||
|
|
|
@ -228,7 +228,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;
|
SDL_Joystick *joystick;
|
||||||
Uint8 i, v;
|
Uint8 i, v;
|
||||||
|
|
|
@ -153,9 +153,9 @@ static SDL_bool HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device)
|
||||||
/* Set the controller into report mode over USB */
|
/* Set the controller into report mode over USB */
|
||||||
{
|
{
|
||||||
Uint8 data[USB_PACKET_LENGTH];
|
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,
|
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
|
||||||
"HIDAPI_DriverPS3_InitDevice(): Couldn't read feature report 0xf2");
|
"HIDAPI_DriverPS3_InitDevice(): Couldn't read feature report 0xf2");
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
|
@ -163,7 +163,8 @@ static SDL_bool HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device)
|
||||||
#ifdef DEBUG_PS3_PROTOCOL
|
#ifdef DEBUG_PS3_PROTOCOL
|
||||||
HIDAPI_DumpPacket("PS3 0xF2 packet: size = %d", data, size);
|
HIDAPI_DumpPacket("PS3 0xF2 packet: size = %d", data, size);
|
||||||
#endif
|
#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,
|
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
|
||||||
"HIDAPI_DriverPS3_InitDevice(): Couldn't read feature report 0xf5");
|
"HIDAPI_DriverPS3_InitDevice(): Couldn't read feature report 0xf5");
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
|
@ -578,8 +579,8 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_IsSupportedDevice(SDL_HIDAPI_Device *
|
||||||
|
|
||||||
if (SONY_THIRDPARTY_VENDOR(vendor_id)) {
|
if (SONY_THIRDPARTY_VENDOR(vendor_id)) {
|
||||||
if (device && device->dev) {
|
if (device && device->dev) {
|
||||||
if ((size = ReadFeatureReport(device->dev, 0x03, data, sizeof(data))) == 8 &&
|
size = ReadFeatureReport(device->dev, 0x03, data, sizeof data);
|
||||||
data[2] == 0x26) {
|
if (size == 8 && data[2] == 0x26) {
|
||||||
/* Supported third party controller */
|
/* Supported third party controller */
|
||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -185,8 +185,8 @@ static SDL_bool HIDAPI_DriverPS4_IsSupportedDevice(SDL_HIDAPI_Device *device, co
|
||||||
|
|
||||||
if (SONY_THIRDPARTY_VENDOR(vendor_id)) {
|
if (SONY_THIRDPARTY_VENDOR(vendor_id)) {
|
||||||
if (device && device->dev) {
|
if (device && device->dev) {
|
||||||
if ((size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdCapabilities, data, sizeof(data))) == 48 &&
|
size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdCapabilities, data, sizeof data);
|
||||||
data[2] == 0x27) {
|
if (size == 48 && data[2] == 0x27) {
|
||||||
/* Supported third party controller */
|
/* Supported third party controller */
|
||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -264,8 +264,8 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
|
||||||
if (ctx->is_dongle) {
|
if (ctx->is_dongle) {
|
||||||
size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdSerialNumber, data, sizeof(data));
|
size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdSerialNumber, data, sizeof(data));
|
||||||
if (size >= 7 && (data[1] || data[2] || data[3] || data[4] || data[5] || data[6])) {
|
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",
|
(void)SDL_snprintf(serial, sizeof serial, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
|
||||||
data[6], data[5], data[4], data[3], data[2], data[1]);
|
data[6], data[5], data[4], data[3], data[2], data[1]);
|
||||||
}
|
}
|
||||||
device->is_bluetooth = SDL_FALSE;
|
device->is_bluetooth = SDL_FALSE;
|
||||||
ctx->enhanced_mode = SDL_TRUE;
|
ctx->enhanced_mode = SDL_TRUE;
|
||||||
|
@ -273,8 +273,8 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
|
||||||
/* This will fail if we're on Bluetooth */
|
/* This will fail if we're on Bluetooth */
|
||||||
size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdSerialNumber, data, sizeof(data));
|
size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdSerialNumber, data, sizeof(data));
|
||||||
if (size >= 7 && (data[1] || data[2] || data[3] || data[4] || data[5] || data[6])) {
|
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",
|
(void)SDL_snprintf(serial, sizeof serial, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
|
||||||
data[6], data[5], data[4], data[3], data[2], data[1]);
|
data[6], data[5], data[4], data[3], data[2], data[1]);
|
||||||
device->is_bluetooth = SDL_FALSE;
|
device->is_bluetooth = SDL_FALSE;
|
||||||
ctx->enhanced_mode = SDL_TRUE;
|
ctx->enhanced_mode = SDL_TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -304,6 +304,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");
|
SDL_Log("PS4 dongle = %s, bluetooth = %s\n", ctx->is_dongle ? "TRUE" : "FALSE", device->is_bluetooth ? "TRUE" : "FALSE");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdCapabilities, data, sizeof data);
|
||||||
/* Get the device capabilities */
|
/* Get the device capabilities */
|
||||||
if (device->vendor_id == USB_VENDOR_SONY) {
|
if (device->vendor_id == USB_VENDOR_SONY) {
|
||||||
ctx->official_controller = SDL_TRUE;
|
ctx->official_controller = SDL_TRUE;
|
||||||
|
@ -311,8 +312,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
|
||||||
ctx->lightbar_supported = SDL_TRUE;
|
ctx->lightbar_supported = SDL_TRUE;
|
||||||
ctx->vibration_supported = SDL_TRUE;
|
ctx->vibration_supported = SDL_TRUE;
|
||||||
ctx->touchpad_supported = SDL_TRUE;
|
ctx->touchpad_supported = SDL_TRUE;
|
||||||
} else if ((size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdCapabilities, data, sizeof(data))) == 48 &&
|
} else if (size == 48 && data[2] == 0x27) {
|
||||||
data[2] == 0x27) {
|
|
||||||
Uint8 capabilities = data[4];
|
Uint8 capabilities = data[4];
|
||||||
Uint8 device_type = data[5];
|
Uint8 device_type = data[5];
|
||||||
|
|
||||||
|
@ -1115,8 +1115,8 @@ static SDL_bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||||
char serial[18];
|
char serial[18];
|
||||||
size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdSerialNumber, data, sizeof(data));
|
size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdSerialNumber, data, sizeof(data));
|
||||||
if (size >= 7 && (data[1] || data[2] || data[3] || data[4] || data[5] || data[6])) {
|
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",
|
(void)SDL_snprintf(serial, sizeof serial, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
|
||||||
data[6], data[5], data[4], data[3], data[2], data[1]);
|
data[6], data[5], data[4], data[3], data[2], data[1]);
|
||||||
HIDAPI_SetDeviceSerial(device, serial);
|
HIDAPI_SetDeviceSerial(device, serial);
|
||||||
}
|
}
|
||||||
HIDAPI_JoystickConnected(device, NULL);
|
HIDAPI_JoystickConnected(device, NULL);
|
||||||
|
|
|
@ -271,8 +271,8 @@ static SDL_bool HIDAPI_DriverPS5_IsSupportedDevice(SDL_HIDAPI_Device *device, co
|
||||||
|
|
||||||
if (SONY_THIRDPARTY_VENDOR(vendor_id)) {
|
if (SONY_THIRDPARTY_VENDOR(vendor_id)) {
|
||||||
if (device && device->dev) {
|
if (device && device->dev) {
|
||||||
if ((size = ReadFeatureReport(device->dev, k_EPS5FeatureReportIdCapabilities, data, sizeof(data))) == 48 &&
|
size = ReadFeatureReport(device->dev, k_EPS5FeatureReportIdCapabilities, data, sizeof data);
|
||||||
data[2] == 0x28) {
|
if (size == 48 && data[2] == 0x28) {
|
||||||
/* Supported third party controller */
|
/* Supported third party controller */
|
||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -396,8 +396,8 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
|
||||||
This will also enable enhanced reports over Bluetooth
|
This will also enable enhanced reports over Bluetooth
|
||||||
*/
|
*/
|
||||||
if (ReadFeatureReport(device->dev, k_EPS5FeatureReportIdSerialNumber, data, sizeof(data)) >= 7) {
|
if (ReadFeatureReport(device->dev, k_EPS5FeatureReportIdSerialNumber, data, sizeof(data)) >= 7) {
|
||||||
SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
|
(void)SDL_snprintf(serial, sizeof serial, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
|
||||||
data[6], data[5], data[4], data[3], data[2], data[1]);
|
data[6], data[5], data[4], data[3], data[2], data[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the firmware version
|
/* Read the firmware version
|
||||||
|
@ -408,6 +408,7 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size = ReadFeatureReport(device->dev, k_EPS5FeatureReportIdCapabilities, data, sizeof data);
|
||||||
/* Get the device capabilities */
|
/* Get the device capabilities */
|
||||||
if (device->vendor_id == USB_VENDOR_SONY) {
|
if (device->vendor_id == USB_VENDOR_SONY) {
|
||||||
ctx->sensors_supported = SDL_TRUE;
|
ctx->sensors_supported = SDL_TRUE;
|
||||||
|
@ -415,8 +416,7 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
|
||||||
ctx->vibration_supported = SDL_TRUE;
|
ctx->vibration_supported = SDL_TRUE;
|
||||||
ctx->playerled_supported = SDL_TRUE;
|
ctx->playerled_supported = SDL_TRUE;
|
||||||
ctx->touchpad_supported = SDL_TRUE;
|
ctx->touchpad_supported = SDL_TRUE;
|
||||||
} else if ((size = ReadFeatureReport(device->dev, k_EPS5FeatureReportIdCapabilities, data, sizeof(data))) == 48 &&
|
} else if (size == 48 && data[2] == 0x28) {
|
||||||
data[2] == 0x28) {
|
|
||||||
Uint8 capabilities = data[4];
|
Uint8 capabilities = data[4];
|
||||||
Uint8 capabilities2 = data[20];
|
Uint8 capabilities2 = data[20];
|
||||||
Uint8 device_type = data[5];
|
Uint8 device_type = data[5];
|
||||||
|
|
|
@ -364,7 +364,7 @@ static void HIDAPI_DriverShield_HandleStatePacketV103(SDL_Joystick *joystick, SD
|
||||||
#undef clamp
|
#undef clamp
|
||||||
#define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
|
#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;
|
Uint8 touchpad_state;
|
||||||
float touchpad_x, touchpad_y;
|
float touchpad_x, touchpad_y;
|
||||||
|
|
|
@ -240,7 +240,7 @@ static int WriteSegmentToSteamControllerPacketAssembler(SteamControllerPacketAss
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nSegmentLength != MAX_REPORT_SEGMENT_SIZE) {
|
if (nSegmentLength != MAX_REPORT_SEGMENT_SIZE) {
|
||||||
printf("Bad segment size! %d\n", (int)nSegmentLength);
|
printf("Bad segment size! %d\n", nSegmentLength);
|
||||||
hexdump(pSegment, nSegmentLength);
|
hexdump(pSegment, nSegmentLength);
|
||||||
ResetSteamControllerPacketAssembler(pAssembler);
|
ResetSteamControllerPacketAssembler(pAssembler);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -361,10 +361,11 @@ static int GetFeatureReport(SDL_hid_device *dev, unsigned char uBuffer[65])
|
||||||
HEXDUMP(uSegmentBuffer, nRet);
|
HEXDUMP(uSegmentBuffer, nRet);
|
||||||
|
|
||||||
// Zero retry counter if we got data
|
// 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;
|
nRetries = 0;
|
||||||
else
|
} else {
|
||||||
nRetries++;
|
nRetries++;
|
||||||
|
}
|
||||||
|
|
||||||
if (nRet > 0) {
|
if (nRet > 0) {
|
||||||
int nPacketLength = WriteSegmentToSteamControllerPacketAssembler(&assembler,
|
int nPacketLength = WriteSegmentToSteamControllerPacketAssembler(&assembler,
|
||||||
|
@ -748,19 +749,21 @@ static void FormatStatePacketUntilGyro(SteamControllerStateInternal_t *pState, V
|
||||||
RotatePad(&nLeftPadX, &nLeftPadY, -flRotationAngle);
|
RotatePad(&nLeftPadX, &nLeftPadY, -flRotationAngle);
|
||||||
RotatePad(&nRightPadX, &nRightPadY, flRotationAngle);
|
RotatePad(&nRightPadX, &nRightPadY, flRotationAngle);
|
||||||
|
|
||||||
if (pState->ulButtons & STEAM_LEFTPAD_FINGERDOWN_MASK)
|
if (pState->ulButtons & STEAM_LEFTPAD_FINGERDOWN_MASK) {
|
||||||
nPadOffset = 1000;
|
nPadOffset = 1000;
|
||||||
else
|
} else {
|
||||||
nPadOffset = 0;
|
nPadOffset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
pState->sLeftPadX = clamp(nLeftPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
pState->sLeftPadX = clamp(nLeftPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||||
pState->sLeftPadY = clamp(nLeftPadY + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
pState->sLeftPadY = clamp(nLeftPadY + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||||
|
|
||||||
nPadOffset = 0;
|
nPadOffset = 0;
|
||||||
if (pState->ulButtons & STEAM_RIGHTPAD_FINGERDOWN_MASK)
|
if (pState->ulButtons & STEAM_RIGHTPAD_FINGERDOWN_MASK) {
|
||||||
nPadOffset = 1000;
|
nPadOffset = 1000;
|
||||||
else
|
} else {
|
||||||
nPadOffset = 0;
|
nPadOffset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
pState->sRightPadX = clamp(nRightPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
pState->sRightPadX = clamp(nRightPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||||
pState->sRightPadY = clamp(nRightPadY + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
pState->sRightPadY = clamp(nRightPadY + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||||
|
@ -807,10 +810,11 @@ static bool UpdateBLESteamControllerState(const uint8_t *pData, int nDataSize, S
|
||||||
int nLength = sizeof(pState->sLeftPadX) + sizeof(pState->sLeftPadY);
|
int nLength = sizeof(pState->sLeftPadX) + sizeof(pState->sLeftPadY);
|
||||||
int nPadOffset;
|
int nPadOffset;
|
||||||
SDL_memcpy(&pState->sLeftPadX, pData, nLength);
|
SDL_memcpy(&pState->sLeftPadX, pData, nLength);
|
||||||
if (pState->ulButtons & STEAM_LEFTPAD_FINGERDOWN_MASK)
|
if (pState->ulButtons & STEAM_LEFTPAD_FINGERDOWN_MASK) {
|
||||||
nPadOffset = 1000;
|
nPadOffset = 1000;
|
||||||
else
|
} else {
|
||||||
nPadOffset = 0;
|
nPadOffset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
RotatePadShort(&pState->sLeftPadX, &pState->sLeftPadY, -flRotationAngle);
|
RotatePadShort(&pState->sLeftPadX, &pState->sLeftPadY, -flRotationAngle);
|
||||||
pState->sLeftPadX = clamp(pState->sLeftPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
pState->sLeftPadX = clamp(pState->sLeftPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||||
|
@ -823,10 +827,11 @@ static bool UpdateBLESteamControllerState(const uint8_t *pData, int nDataSize, S
|
||||||
|
|
||||||
SDL_memcpy(&pState->sRightPadX, pData, nLength);
|
SDL_memcpy(&pState->sRightPadX, pData, nLength);
|
||||||
|
|
||||||
if (pState->ulButtons & STEAM_RIGHTPAD_FINGERDOWN_MASK)
|
if (pState->ulButtons & STEAM_RIGHTPAD_FINGERDOWN_MASK) {
|
||||||
nPadOffset = 1000;
|
nPadOffset = 1000;
|
||||||
else
|
} else {
|
||||||
nPadOffset = 0;
|
nPadOffset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
RotatePadShort(&pState->sRightPadX, &pState->sRightPadY, flRotationAngle);
|
RotatePadShort(&pState->sRightPadX, &pState->sRightPadY, flRotationAngle);
|
||||||
pState->sRightPadX = clamp(pState->sRightPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
pState->sRightPadX = clamp(pState->sRightPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||||
|
|
|
@ -825,14 +825,14 @@ static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context *ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Accelerometer scale */
|
/* Accelerometer scale */
|
||||||
ctx->m_IMUScaleData.fAccelScaleX = SWITCH_ACCEL_SCALE_MULT / (float)(SWITCH_ACCEL_SCALE_OFFSET - (float)sAccelRawX) * SDL_STANDARD_GRAVITY;
|
ctx->m_IMUScaleData.fAccelScaleX = SWITCH_ACCEL_SCALE_MULT / (SWITCH_ACCEL_SCALE_OFFSET - (float)sAccelRawX) * SDL_STANDARD_GRAVITY;
|
||||||
ctx->m_IMUScaleData.fAccelScaleY = SWITCH_ACCEL_SCALE_MULT / (float)(SWITCH_ACCEL_SCALE_OFFSET - (float)sAccelRawY) * SDL_STANDARD_GRAVITY;
|
ctx->m_IMUScaleData.fAccelScaleY = SWITCH_ACCEL_SCALE_MULT / (SWITCH_ACCEL_SCALE_OFFSET - (float)sAccelRawY) * SDL_STANDARD_GRAVITY;
|
||||||
ctx->m_IMUScaleData.fAccelScaleZ = SWITCH_ACCEL_SCALE_MULT / (float)(SWITCH_ACCEL_SCALE_OFFSET - (float)sAccelRawZ) * SDL_STANDARD_GRAVITY;
|
ctx->m_IMUScaleData.fAccelScaleZ = SWITCH_ACCEL_SCALE_MULT / (SWITCH_ACCEL_SCALE_OFFSET - (float)sAccelRawZ) * SDL_STANDARD_GRAVITY;
|
||||||
|
|
||||||
/* Gyro scale */
|
/* Gyro scale */
|
||||||
ctx->m_IMUScaleData.fGyroScaleX = SWITCH_GYRO_SCALE_MULT / (float)(SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawX) * SDL_PI_F / 180.0f;
|
ctx->m_IMUScaleData.fGyroScaleX = SWITCH_GYRO_SCALE_MULT / (SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawX) * SDL_PI_F / 180.0f;
|
||||||
ctx->m_IMUScaleData.fGyroScaleY = SWITCH_GYRO_SCALE_MULT / (float)(SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawY) * SDL_PI_F / 180.0f;
|
ctx->m_IMUScaleData.fGyroScaleY = SWITCH_GYRO_SCALE_MULT / (SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawY) * SDL_PI_F / 180.0f;
|
||||||
ctx->m_IMUScaleData.fGyroScaleZ = SWITCH_GYRO_SCALE_MULT / (float)(SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawZ) * SDL_PI_F / 180.0f;
|
ctx->m_IMUScaleData.fGyroScaleZ = SWITCH_GYRO_SCALE_MULT / (SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawZ) * SDL_PI_F / 180.0f;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1173,13 +1173,13 @@ static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device)
|
||||||
}
|
}
|
||||||
device->guid.data[15] = ctx->m_eControllerType;
|
device->guid.data[15] = ctx->m_eControllerType;
|
||||||
|
|
||||||
SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
|
(void)SDL_snprintf(serial, sizeof serial, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
|
||||||
ctx->m_rgucMACAddress[0],
|
ctx->m_rgucMACAddress[0],
|
||||||
ctx->m_rgucMACAddress[1],
|
ctx->m_rgucMACAddress[1],
|
||||||
ctx->m_rgucMACAddress[2],
|
ctx->m_rgucMACAddress[2],
|
||||||
ctx->m_rgucMACAddress[3],
|
ctx->m_rgucMACAddress[3],
|
||||||
ctx->m_rgucMACAddress[4],
|
ctx->m_rgucMACAddress[4],
|
||||||
ctx->m_rgucMACAddress[5]);
|
ctx->m_rgucMACAddress[5]);
|
||||||
HIDAPI_SetDeviceSerial(device, serial);
|
HIDAPI_SetDeviceSerial(device, serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1713,7 +1713,8 @@ static void HandleSimpleControllerState(SDL_Joystick *joystick, SDL_DriverSwitch
|
||||||
ctx->m_lastSimpleState = *packet;
|
ctx->m_lastSimpleState = *packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SendSensorUpdate(SDL_Joystick *joystick, SDL_DriverSwitch_Context *ctx, SDL_SensorType type, Uint64 timestamp_us, Sint16 *values)
|
static void
|
||||||
|
SendSensorUpdate(SDL_Joystick *joystick, SDL_DriverSwitch_Context *ctx, SDL_SensorType type, Uint64 timestamp_us, const Sint16 *values)
|
||||||
{
|
{
|
||||||
float data[3];
|
float data[3];
|
||||||
|
|
||||||
|
|
|
@ -210,7 +210,7 @@ static void SetInitState(SDL_DriverXboxOne_Context *ctx, SDL_XboxOneInitState st
|
||||||
ctx->init_state = state;
|
ctx->init_state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SendAckIfNeeded(SDL_HIDAPI_Device *device, Uint8 *data, int size)
|
static void SendAckIfNeeded(SDL_HIDAPI_Device *device, const Uint8 *data, int size)
|
||||||
{
|
{
|
||||||
#if defined(__WIN32__) || defined(__WINGDK__)
|
#if defined(__WIN32__) || defined(__WINGDK__)
|
||||||
/* The Windows driver is taking care of acks */
|
/* The Windows driver is taking care of acks */
|
||||||
|
@ -808,7 +808,7 @@ static void HIDAPI_DriverXboxOne_HandleStatusPacket(SDL_Joystick *joystick, SDL_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HIDAPI_DriverXboxOne_HandleModePacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size)
|
static void HIDAPI_DriverXboxOne_HandleModePacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, const Uint8 *data, int size)
|
||||||
{
|
{
|
||||||
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data[4] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data[4] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||||
}
|
}
|
||||||
|
@ -816,7 +816,7 @@ static void HIDAPI_DriverXboxOne_HandleModePacket(SDL_Joystick *joystick, SDL_Dr
|
||||||
/*
|
/*
|
||||||
* Xbox One S with firmware 3.1.1221 uses a 16 byte packet and the GUIDE button in a separate packet
|
* Xbox One S with firmware 3.1.1221 uses a 16 byte packet and the GUIDE button in a separate packet
|
||||||
*/
|
*/
|
||||||
static void HIDAPI_DriverXboxOneBluetooth_HandleButtons16(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size)
|
static void HIDAPI_DriverXboxOneBluetooth_HandleButtons16(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, const Uint8 *data, int size)
|
||||||
{
|
{
|
||||||
if (ctx->last_state[14] != data[14]) {
|
if (ctx->last_state[14] != data[14]) {
|
||||||
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_A, (data[14] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_A, (data[14] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||||
|
@ -1018,13 +1018,13 @@ static void HIDAPI_DriverXboxOneBluetooth_HandleStatePacket(SDL_Joystick *joysti
|
||||||
SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state)));
|
SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HIDAPI_DriverXboxOneBluetooth_HandleGuidePacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size)
|
static void HIDAPI_DriverXboxOneBluetooth_HandleGuidePacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, const Uint8 *data, int size)
|
||||||
{
|
{
|
||||||
ctx->has_guide_packet = SDL_TRUE;
|
ctx->has_guide_packet = SDL_TRUE;
|
||||||
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HIDAPI_DriverXboxOneBluetooth_HandleBatteryPacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size)
|
static void HIDAPI_DriverXboxOneBluetooth_HandleBatteryPacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, const Uint8 *data, int size)
|
||||||
{
|
{
|
||||||
Uint8 flags = data[1];
|
Uint8 flags = data[1];
|
||||||
SDL_bool on_usb = (((flags & 0x0C) >> 2) == 0);
|
SDL_bool on_usb = (((flags & 0x0C) >> 2) == 0);
|
||||||
|
|
|
@ -100,12 +100,13 @@ void HIDAPI_DumpPacket(const char *prefix, const Uint8 *data, int size)
|
||||||
int start = 0, amount = size;
|
int start = 0, amount = size;
|
||||||
|
|
||||||
buffer = (char *)SDL_malloc(length);
|
buffer = (char *)SDL_malloc(length);
|
||||||
SDL_snprintf(buffer, length, prefix, size);
|
(void)SDL_snprintf(buffer, length, prefix, size);
|
||||||
for (i = start; i < start + amount; ++i) {
|
for (i = start; i < start + amount; ++i) {
|
||||||
|
size_t current_len = SDL_strlen(buffer);
|
||||||
if ((i % 8) == 0) {
|
if ((i % 8) == 0) {
|
||||||
SDL_snprintf(&buffer[SDL_strlen(buffer)], length - SDL_strlen(buffer), "\n%.2d: ", i);
|
(void)SDL_snprintf(&buffer[current_len], length - current_len, "\n%.2d: ", i);
|
||||||
}
|
}
|
||||||
SDL_snprintf(&buffer[SDL_strlen(buffer)], length - SDL_strlen(buffer), " 0x%.2x", data[i]);
|
(void)SDL_snprintf(&buffer[current_len], length - current_len, " 0x%.2x", data[i]);
|
||||||
}
|
}
|
||||||
SDL_strlcat(buffer, "\n", length);
|
SDL_strlcat(buffer, "\n", length);
|
||||||
SDL_Log("%s", buffer);
|
SDL_Log("%s", buffer);
|
||||||
|
@ -379,7 +380,6 @@ static void HIDAPI_SetupDeviceDriver(SDL_HIDAPI_Device *device, SDL_bool *remove
|
||||||
|
|
||||||
/* Make sure the device didn't get removed while opening the HID path */
|
/* Make sure the device didn't get removed while opening the HID path */
|
||||||
for (curr = SDL_HIDAPI_devices; curr && curr != device; curr = curr->next) {
|
for (curr = SDL_HIDAPI_devices; curr && curr != device; curr = curr->next) {
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
if (curr == NULL) {
|
if (curr == NULL) {
|
||||||
*removed = SDL_TRUE;
|
*removed = SDL_TRUE;
|
||||||
|
@ -713,7 +713,6 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf
|
||||||
SDL_bool removed;
|
SDL_bool removed;
|
||||||
|
|
||||||
for (curr = SDL_HIDAPI_devices, last = NULL; curr; last = curr, curr = curr->next) {
|
for (curr = SDL_HIDAPI_devices, last = NULL; curr; last = curr, curr = curr->next) {
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
device = (SDL_HIDAPI_Device *)SDL_calloc(1, sizeof(*device));
|
device = (SDL_HIDAPI_Device *)SDL_calloc(1, sizeof(*device));
|
||||||
|
@ -980,7 +979,6 @@ check_removed:
|
||||||
|
|
||||||
/* See if we can create any combined Joy-Con controllers */
|
/* See if we can create any combined Joy-Con controllers */
|
||||||
while (HIDAPI_CreateCombinedJoyCons()) {
|
while (HIDAPI_CreateCombinedJoyCons()) {
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UnlockJoysticks();
|
SDL_UnlockJoysticks();
|
||||||
|
|
|
@ -560,7 +560,7 @@ static void LINUX_InotifyJoystickDetect(void)
|
||||||
while (remain > 0) {
|
while (remain > 0) {
|
||||||
if (buf.event.len > 0) {
|
if (buf.event.len > 0) {
|
||||||
if (IsJoystickDeviceNode(buf.event.name)) {
|
if (IsJoystickDeviceNode(buf.event.name)) {
|
||||||
SDL_snprintf(path, SDL_arraysize(path), "/dev/input/%s", buf.event.name);
|
(void)SDL_snprintf(path, SDL_arraysize(path), "/dev/input/%s", buf.event.name);
|
||||||
|
|
||||||
if (buf.event.mask & (IN_CREATE | IN_MOVED_TO | IN_ATTRIB)) {
|
if (buf.event.mask & (IN_CREATE | IN_MOVED_TO | IN_ATTRIB)) {
|
||||||
MaybeAddDevice(path);
|
MaybeAddDevice(path);
|
||||||
|
@ -587,7 +587,7 @@ static int get_event_joystick_index(int event)
|
||||||
struct dirent **entries = NULL;
|
struct dirent **entries = NULL;
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
|
|
||||||
SDL_snprintf(path, SDL_arraysize(path), "/sys/class/input/event%d/device", event);
|
(void)SDL_snprintf(path, SDL_arraysize(path), "/sys/class/input/event%d/device", event);
|
||||||
count = scandir(path, &entries, NULL, alphasort);
|
count = scandir(path, &entries, NULL, alphasort);
|
||||||
for (i = 0; i < count; ++i) {
|
for (i = 0; i < count; ++i) {
|
||||||
if (SDL_strncmp(entries[i]->d_name, "js", 2) == 0) {
|
if (SDL_strncmp(entries[i]->d_name, "js", 2) == 0) {
|
||||||
|
@ -660,7 +660,7 @@ static void LINUX_FallbackJoystickDetect(void)
|
||||||
qsort(entries, count, sizeof(*entries), sort_entries);
|
qsort(entries, count, sizeof(*entries), sort_entries);
|
||||||
}
|
}
|
||||||
for (i = 0; i < count; ++i) {
|
for (i = 0; i < count; ++i) {
|
||||||
SDL_snprintf(path, SDL_arraysize(path), "/dev/input/%s", entries[i]->d_name);
|
(void)SDL_snprintf(path, SDL_arraysize(path), "/dev/input/%s", entries[i]->d_name);
|
||||||
MaybeAddDevice(path);
|
MaybeAddDevice(path);
|
||||||
|
|
||||||
free(entries[i]); /* This should NOT be SDL_free() */
|
free(entries[i]); /* This should NOT be SDL_free() */
|
||||||
|
|
|
@ -227,7 +227,6 @@ int SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *desc)
|
||||||
joystick_hwdata *last;
|
joystick_hwdata *last;
|
||||||
|
|
||||||
for (last = g_VJoys; last->next; last = last->next) {
|
for (last = g_VJoys; last->next; last = last->next) {
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
last->next = hwdata;
|
last->next = hwdata;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -621,19 +621,19 @@ static BOOL CALLBACK EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE pDeviceObj
|
||||||
|
|
||||||
in->type = AXIS;
|
in->type = AXIS;
|
||||||
in->num = joystick->naxes;
|
in->num = joystick->naxes;
|
||||||
if (!SDL_memcmp(&pDeviceObject->guidType, &GUID_XAxis, sizeof(pDeviceObject->guidType)))
|
if (SDL_memcmp(&pDeviceObject->guidType, &GUID_XAxis, sizeof pDeviceObject->guidType) == 0) {
|
||||||
in->ofs = DIJOFS_X;
|
in->ofs = DIJOFS_X;
|
||||||
else if (!SDL_memcmp(&pDeviceObject->guidType, &GUID_YAxis, sizeof(pDeviceObject->guidType)))
|
} else if (SDL_memcmp(&pDeviceObject->guidType, &GUID_YAxis, sizeof pDeviceObject->guidType) == 0) {
|
||||||
in->ofs = DIJOFS_Y;
|
in->ofs = DIJOFS_Y;
|
||||||
else if (!SDL_memcmp(&pDeviceObject->guidType, &GUID_ZAxis, sizeof(pDeviceObject->guidType)))
|
} else if (SDL_memcmp(&pDeviceObject->guidType, &GUID_ZAxis, sizeof pDeviceObject->guidType) == 0) {
|
||||||
in->ofs = DIJOFS_Z;
|
in->ofs = DIJOFS_Z;
|
||||||
else if (!SDL_memcmp(&pDeviceObject->guidType, &GUID_RxAxis, sizeof(pDeviceObject->guidType)))
|
} else if (SDL_memcmp(&pDeviceObject->guidType, &GUID_RxAxis, sizeof pDeviceObject->guidType) == 0) {
|
||||||
in->ofs = DIJOFS_RX;
|
in->ofs = DIJOFS_RX;
|
||||||
else if (!SDL_memcmp(&pDeviceObject->guidType, &GUID_RyAxis, sizeof(pDeviceObject->guidType)))
|
} else if (SDL_memcmp(&pDeviceObject->guidType, &GUID_RyAxis, sizeof pDeviceObject->guidType) == 0) {
|
||||||
in->ofs = DIJOFS_RY;
|
in->ofs = DIJOFS_RY;
|
||||||
else if (!SDL_memcmp(&pDeviceObject->guidType, &GUID_RzAxis, sizeof(pDeviceObject->guidType)))
|
} else if (SDL_memcmp(&pDeviceObject->guidType, &GUID_RzAxis, sizeof pDeviceObject->guidType) == 0) {
|
||||||
in->ofs = DIJOFS_RZ;
|
in->ofs = DIJOFS_RZ;
|
||||||
else if (!SDL_memcmp(&pDeviceObject->guidType, &GUID_Slider, sizeof(pDeviceObject->guidType))) {
|
} else if (SDL_memcmp(&pDeviceObject->guidType, &GUID_Slider, sizeof pDeviceObject->guidType) == 0) {
|
||||||
in->ofs = DIJOFS_SLIDER(joystick->hwdata->NumSliders);
|
in->ofs = DIJOFS_SLIDER(joystick->hwdata->NumSliders);
|
||||||
++joystick->hwdata->NumSliders;
|
++joystick->hwdata->NumSliders;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -726,8 +726,8 @@ static void RAWINPUT_AddDevice(HANDLE hDevice)
|
||||||
/* Don't take devices handled by HIDAPI */
|
/* Don't take devices handled by HIDAPI */
|
||||||
CHECK(!HIDAPI_IsDevicePresent((Uint16)rdi.hid.dwVendorId, (Uint16)rdi.hid.dwProductId, (Uint16)rdi.hid.dwVersionNumber, ""));
|
CHECK(!HIDAPI_IsDevicePresent((Uint16)rdi.hid.dwVendorId, (Uint16)rdi.hid.dwProductId, (Uint16)rdi.hid.dwVersionNumber, ""));
|
||||||
#endif
|
#endif
|
||||||
|
device = (SDL_RAWINPUT_Device *)SDL_calloc(1, sizeof(SDL_RAWINPUT_Device));
|
||||||
CHECK(device = (SDL_RAWINPUT_Device *)SDL_calloc(1, sizeof(SDL_RAWINPUT_Device)));
|
CHECK(device);
|
||||||
device->hDevice = hDevice;
|
device->hDevice = hDevice;
|
||||||
device->vendor_id = (Uint16)rdi.hid.dwVendorId;
|
device->vendor_id = (Uint16)rdi.hid.dwVendorId;
|
||||||
device->product_id = (Uint16)rdi.hid.dwProductId;
|
device->product_id = (Uint16)rdi.hid.dwProductId;
|
||||||
|
@ -738,7 +738,8 @@ static void RAWINPUT_AddDevice(HANDLE hDevice)
|
||||||
/* Get HID Top-Level Collection Preparsed Data */
|
/* Get HID Top-Level Collection Preparsed Data */
|
||||||
size = 0;
|
size = 0;
|
||||||
CHECK(GetRawInputDeviceInfoA(hDevice, RIDI_PREPARSEDDATA, NULL, &size) != (UINT)-1);
|
CHECK(GetRawInputDeviceInfoA(hDevice, RIDI_PREPARSEDDATA, NULL, &size) != (UINT)-1);
|
||||||
CHECK(device->preparsed_data = (PHIDP_PREPARSED_DATA)SDL_calloc(size, sizeof(BYTE)));
|
device->preparsed_data = (PHIDP_PREPARSED_DATA)SDL_calloc(size, sizeof(BYTE));
|
||||||
|
CHECK(device->preparsed_data);
|
||||||
CHECK(GetRawInputDeviceInfoA(hDevice, RIDI_PREPARSEDDATA, device->preparsed_data, &size) != (UINT)-1);
|
CHECK(GetRawInputDeviceInfoA(hDevice, RIDI_PREPARSEDDATA, device->preparsed_data, &size) != (UINT)-1);
|
||||||
|
|
||||||
hFile = CreateFileA(dev_name, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
|
hFile = CreateFileA(dev_name, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
|
||||||
|
@ -782,7 +783,6 @@ static void RAWINPUT_AddDevice(HANDLE hDevice)
|
||||||
/* Add it to the list */
|
/* Add it to the list */
|
||||||
RAWINPUT_AcquireDevice(device);
|
RAWINPUT_AcquireDevice(device);
|
||||||
for (curr = SDL_RAWINPUT_devices, last = NULL; curr; last = curr, curr = curr->next) {
|
for (curr = SDL_RAWINPUT_devices, last = NULL; curr; last = curr, curr = curr->next) {
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
if (last) {
|
if (last) {
|
||||||
last->next = device;
|
last->next = device;
|
||||||
|
|
|
@ -185,7 +185,7 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_snprintf(devVidPidString, sizeof(devVidPidString), "VID_%04X&PID_%04X", vendor, product);
|
(void)SDL_snprintf(devVidPidString, sizeof devVidPidString, "VID_%04X&PID_%04X", vendor, product);
|
||||||
|
|
||||||
while (CM_Get_Parent(&devNode, devNode, 0) == CR_SUCCESS) {
|
while (CM_Get_Parent(&devNode, devNode, 0) == CR_SUCCESS) {
|
||||||
char deviceId[MAX_DEVICE_ID_LEN];
|
char deviceId[MAX_DEVICE_ID_LEN];
|
||||||
|
@ -233,7 +233,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_QueryInter
|
||||||
static ULONG STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_AddRef(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController *This)
|
static ULONG STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_AddRef(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController *This)
|
||||||
{
|
{
|
||||||
RawGameControllerDelegate *self = (RawGameControllerDelegate *)This;
|
RawGameControllerDelegate *self = (RawGameControllerDelegate *)This;
|
||||||
return SDL_AtomicAdd(&self->refcount, 1) + 1;
|
return SDL_AtomicAdd(&self->refcount, 1) + 1UL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_Release(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController *This)
|
static ULONG STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_Release(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController *This)
|
||||||
|
@ -389,6 +389,8 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde
|
||||||
wgi.controllers = controllers;
|
wgi.controllers = controllers;
|
||||||
|
|
||||||
SDL_PrivateJoystickAdded(joystickID);
|
SDL_PrivateJoystickAdded(joystickID);
|
||||||
|
} else {
|
||||||
|
SDL_free(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -171,7 +171,7 @@ static DWORD CALLBACK SDL_DeviceNotificationFunc(HCMNOTIFICATION hNotify, PVOID
|
||||||
static void SDL_CleanupDeviceNotificationFunc(void)
|
static void SDL_CleanupDeviceNotificationFunc(void)
|
||||||
{
|
{
|
||||||
if (cfgmgr32_lib_handle) {
|
if (cfgmgr32_lib_handle) {
|
||||||
if (s_DeviceNotificationFuncHandle) {
|
if (s_DeviceNotificationFuncHandle != NULL && CM_Unregister_Notification != NULL) {
|
||||||
CM_Unregister_Notification(s_DeviceNotificationFuncHandle);
|
CM_Unregister_Notification(s_DeviceNotificationFuncHandle);
|
||||||
s_DeviceNotificationFuncHandle = NULL;
|
s_DeviceNotificationFuncHandle = NULL;
|
||||||
}
|
}
|
||||||
|
@ -288,8 +288,8 @@ static int SDL_CreateDeviceNotification(SDL_DeviceNotificationData *data)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
data->messageWindow = (HWND)CreateWindowEx(0, TEXT("Message"), NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL);
|
data->messageWindow = CreateWindowEx(0, TEXT("Message"), NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL);
|
||||||
if (!data->messageWindow) {
|
if (data->messageWindow == NULL) {
|
||||||
WIN_SetError("Failed to create message window for joystick autodetect");
|
WIN_SetError("Failed to create message window for joystick autodetect");
|
||||||
SDL_CleanupDeviceNotification(data);
|
SDL_CleanupDeviceNotification(data);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -84,37 +84,37 @@ static const char *GetXInputName(const Uint8 userid, BYTE SubType)
|
||||||
static char name[32];
|
static char name[32];
|
||||||
|
|
||||||
if (SDL_XInputUseOldJoystickMapping()) {
|
if (SDL_XInputUseOldJoystickMapping()) {
|
||||||
SDL_snprintf(name, sizeof(name), "X360 Controller #%u", 1 + userid);
|
(void)SDL_snprintf(name, sizeof name, "X360 Controller #%u", 1 + userid);
|
||||||
} else {
|
} else {
|
||||||
switch (SubType) {
|
switch (SubType) {
|
||||||
case XINPUT_DEVSUBTYPE_GAMEPAD:
|
case XINPUT_DEVSUBTYPE_GAMEPAD:
|
||||||
SDL_snprintf(name, sizeof(name), "XInput Controller #%u", 1 + userid);
|
(void)SDL_snprintf(name, sizeof name, "XInput Controller #%u", 1 + userid);
|
||||||
break;
|
break;
|
||||||
case XINPUT_DEVSUBTYPE_WHEEL:
|
case XINPUT_DEVSUBTYPE_WHEEL:
|
||||||
SDL_snprintf(name, sizeof(name), "XInput Wheel #%u", 1 + userid);
|
(void)SDL_snprintf(name, sizeof name, "XInput Wheel #%u", 1 + userid);
|
||||||
break;
|
break;
|
||||||
case XINPUT_DEVSUBTYPE_ARCADE_STICK:
|
case XINPUT_DEVSUBTYPE_ARCADE_STICK:
|
||||||
SDL_snprintf(name, sizeof(name), "XInput ArcadeStick #%u", 1 + userid);
|
(void)SDL_snprintf(name, sizeof name, "XInput ArcadeStick #%u", 1 + userid);
|
||||||
break;
|
break;
|
||||||
case XINPUT_DEVSUBTYPE_FLIGHT_STICK:
|
case XINPUT_DEVSUBTYPE_FLIGHT_STICK:
|
||||||
SDL_snprintf(name, sizeof(name), "XInput FlightStick #%u", 1 + userid);
|
(void)SDL_snprintf(name, sizeof name, "XInput FlightStick #%u", 1 + userid);
|
||||||
break;
|
break;
|
||||||
case XINPUT_DEVSUBTYPE_DANCE_PAD:
|
case XINPUT_DEVSUBTYPE_DANCE_PAD:
|
||||||
SDL_snprintf(name, sizeof(name), "XInput DancePad #%u", 1 + userid);
|
(void)SDL_snprintf(name, sizeof name, "XInput DancePad #%u", 1 + userid);
|
||||||
break;
|
break;
|
||||||
case XINPUT_DEVSUBTYPE_GUITAR:
|
case XINPUT_DEVSUBTYPE_GUITAR:
|
||||||
case XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE:
|
case XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE:
|
||||||
case XINPUT_DEVSUBTYPE_GUITAR_BASS:
|
case XINPUT_DEVSUBTYPE_GUITAR_BASS:
|
||||||
SDL_snprintf(name, sizeof(name), "XInput Guitar #%u", 1 + userid);
|
(void)SDL_snprintf(name, sizeof name, "XInput Guitar #%u", 1 + userid);
|
||||||
break;
|
break;
|
||||||
case XINPUT_DEVSUBTYPE_DRUM_KIT:
|
case XINPUT_DEVSUBTYPE_DRUM_KIT:
|
||||||
SDL_snprintf(name, sizeof(name), "XInput DrumKit #%u", 1 + userid);
|
(void)SDL_snprintf(name, sizeof name, "XInput DrumKit #%u", 1 + userid);
|
||||||
break;
|
break;
|
||||||
case XINPUT_DEVSUBTYPE_ARCADE_PAD:
|
case XINPUT_DEVSUBTYPE_ARCADE_PAD:
|
||||||
SDL_snprintf(name, sizeof(name), "XInput ArcadePad #%u", 1 + userid);
|
(void)SDL_snprintf(name, sizeof name, "XInput ArcadePad #%u", 1 + userid);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SDL_snprintf(name, sizeof(name), "XInput Device #%u", 1 + userid);
|
(void)SDL_snprintf(name, sizeof name, "XInput Device #%u", 1 + userid);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ static void GuessXInputDevice(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 *
|
||||||
/* Steam encodes the real device in the path */
|
/* Steam encodes the real device in the path */
|
||||||
int realVID = rdi.hid.dwVendorId;
|
int realVID = rdi.hid.dwVendorId;
|
||||||
int realPID = rdi.hid.dwProductId;
|
int realPID = rdi.hid.dwProductId;
|
||||||
SDL_sscanf(devName, "\\\\.\\pipe\\HID#VID_045E&PID_028E&IG_00#%x&%x&", &realVID, &realPID);
|
(void)SDL_sscanf(devName, "\\\\.\\pipe\\HID#VID_045E&PID_028E&IG_00#%x&%x&", &realVID, &realPID);
|
||||||
*pVID = (Uint16)realVID;
|
*pVID = (Uint16)realVID;
|
||||||
*pPID = (Uint16)realPID;
|
*pPID = (Uint16)realPID;
|
||||||
*pVersion = 0;
|
*pVersion = 0;
|
||||||
|
@ -277,7 +277,7 @@ static void AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pC
|
||||||
SDL_free(pNewJoystick);
|
SDL_free(pNewJoystick);
|
||||||
return; /* better luck next time? */
|
return; /* better luck next time? */
|
||||||
}
|
}
|
||||||
SDL_snprintf(pNewJoystick->path, sizeof(pNewJoystick->path), "XInput#%d", userid);
|
(void)SDL_snprintf(pNewJoystick->path, sizeof pNewJoystick->path, "XInput#%d", userid);
|
||||||
if (!SDL_XInputUseOldJoystickMapping()) {
|
if (!SDL_XInputUseOldJoystickMapping()) {
|
||||||
GuessXInputDevice(userid, &vendor, &product, &version);
|
GuessXInputDevice(userid, &vendor, &product, &version);
|
||||||
|
|
||||||
|
@ -432,7 +432,7 @@ static void UpdateXInputJoystickState_OLD(SDL_Joystick *joystick, XINPUT_STATE_E
|
||||||
SDL_PrivateJoystickAxis(joystick, 4, (Sint16)(((int)pXInputState->Gamepad.bLeftTrigger * 65535 / 255) - 32768));
|
SDL_PrivateJoystickAxis(joystick, 4, (Sint16)(((int)pXInputState->Gamepad.bLeftTrigger * 65535 / 255) - 32768));
|
||||||
SDL_PrivateJoystickAxis(joystick, 5, (Sint16)(((int)pXInputState->Gamepad.bRightTrigger * 65535 / 255) - 32768));
|
SDL_PrivateJoystickAxis(joystick, 5, (Sint16)(((int)pXInputState->Gamepad.bRightTrigger * 65535 / 255) - 32768));
|
||||||
|
|
||||||
for (button = 0; button < SDL_arraysize(s_XInputButtons); ++button) {
|
for (button = 0; button < (Uint8)SDL_arraysize(s_XInputButtons); ++button) {
|
||||||
SDL_PrivateJoystickButton(joystick, button, (wButtons & s_XInputButtons[button]) ? SDL_PRESSED : SDL_RELEASED);
|
SDL_PrivateJoystickButton(joystick, button, (wButtons & s_XInputButtons[button]) ? SDL_PRESSED : SDL_RELEASED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,7 +458,7 @@ static void UpdateXInputJoystickState(SDL_Joystick *joystick, XINPUT_STATE_EX *p
|
||||||
SDL_PrivateJoystickAxis(joystick, 4, ~pXInputState->Gamepad.sThumbRY);
|
SDL_PrivateJoystickAxis(joystick, 4, ~pXInputState->Gamepad.sThumbRY);
|
||||||
SDL_PrivateJoystickAxis(joystick, 5, ((int)pXInputState->Gamepad.bRightTrigger * 257) - 32768);
|
SDL_PrivateJoystickAxis(joystick, 5, ((int)pXInputState->Gamepad.bRightTrigger * 257) - 32768);
|
||||||
|
|
||||||
for (button = 0; button < SDL_arraysize(s_XInputButtons); ++button) {
|
for (button = 0; button < (Uint8)SDL_arraysize(s_XInputButtons); ++button) {
|
||||||
SDL_PrivateJoystickButton(joystick, button, (wButtons & s_XInputButtons[button]) ? SDL_PRESSED : SDL_RELEASED);
|
SDL_PrivateJoystickButton(joystick, button, (wButtons & s_XInputButtons[button]) ? SDL_PRESSED : SDL_RELEASED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,8 @@ void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen)
|
||||||
// convert '-' to '_'...
|
// convert '-' to '_'...
|
||||||
// These are always full lang-COUNTRY, so we search from the back,
|
// These are always full lang-COUNTRY, so we search from the back,
|
||||||
// so things like zh-Hant-CN find the right '-' to convert.
|
// so things like zh-Hant-CN find the right '-' to convert.
|
||||||
if ((ptr = SDL_strrchr(buf, '-')) != NULL) {
|
ptr = SDL_strrchr(buf, '-');
|
||||||
|
if (ptr != NULL) {
|
||||||
*ptr = '_';
|
*ptr = '_';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ static void SDL_SYS_GetPreferredLocales_winxp(char *buf, size_t buflen)
|
||||||
if (langrc == 0) {
|
if (langrc == 0) {
|
||||||
SDL_SetError("Couldn't obtain language info");
|
SDL_SetError("Couldn't obtain language info");
|
||||||
} else {
|
} else {
|
||||||
SDL_snprintf(buf, buflen, "%s%s%s", lang, ctryrc ? "_" : "", ctryrc ? country : "");
|
(void)SDL_snprintf(buf, buflen, "%s%s%s", lang, ctryrc ? "_" : "", ctryrc ? country : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ static int main_getcmdline(void)
|
||||||
return OutOfMemory();
|
return OutOfMemory();
|
||||||
}
|
}
|
||||||
len = (DWORD)SDL_strlen(arg);
|
len = (DWORD)SDL_strlen(arg);
|
||||||
argv[i] = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len + 1);
|
argv[i] = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (size_t)len + 1);
|
||||||
if (!argv[i]) {
|
if (!argv[i]) {
|
||||||
return OutOfMemory();
|
return OutOfMemory();
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ int console_wmain(int argc, wchar_t *wargv[], wchar_t *wenvp)
|
||||||
|
|
||||||
/* This is where execution begins [windowed apps] */
|
/* This is where execution begins [windowed apps] */
|
||||||
int WINAPI
|
int WINAPI
|
||||||
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
|
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) /* NOLINT(readability-inconsistent-declaration-parameter-name) */
|
||||||
{
|
{
|
||||||
return main_getcmdline();
|
return main_getcmdline();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
|
|
||||||
#include "SDL_sysurl.h"
|
#include "SDL_sysurl.h"
|
||||||
|
|
||||||
extern int SDL_SYS_OpenURL(const char *url);
|
|
||||||
|
|
||||||
int SDL_OpenURL(const char *url)
|
int SDL_OpenURL(const char *url)
|
||||||
{
|
{
|
||||||
if (url == NULL) {
|
if (url == NULL) {
|
||||||
|
|
|
@ -49,7 +49,7 @@ static int open_power_file(const char *base, const char *node, const char *key)
|
||||||
return -1; /* oh well. */
|
return -1; /* oh well. */
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_snprintf(path, pathlen, "%s/%s/%s", base, node, key);
|
(void)SDL_snprintf(path, pathlen, "%s/%s/%s", base, node, key);
|
||||||
fd = open(path, O_RDONLY | O_CLOEXEC);
|
fd = open(path, O_RDONLY | O_CLOEXEC);
|
||||||
SDL_stack_free(path);
|
SDL_stack_free(path);
|
||||||
return fd;
|
return fd;
|
||||||
|
|
|
@ -1331,7 +1331,7 @@ SDL_CreateTexture(SDL_Renderer *renderer, Uint32 format, int access, int w, int
|
||||||
} else if (access == SDL_TEXTUREACCESS_STREAMING) {
|
} else if (access == SDL_TEXTUREACCESS_STREAMING) {
|
||||||
/* The pitch is 4 byte aligned */
|
/* The pitch is 4 byte aligned */
|
||||||
texture->pitch = (((w * SDL_BYTESPERPIXEL(format)) + 3) & ~3);
|
texture->pitch = (((w * SDL_BYTESPERPIXEL(format)) + 3) & ~3);
|
||||||
texture->pixels = SDL_calloc(1, texture->pitch * h);
|
texture->pixels = SDL_calloc(1, (size_t)texture->pitch * h);
|
||||||
if (!texture->pixels) {
|
if (!texture->pixels) {
|
||||||
SDL_DestroyTexture(texture);
|
SDL_DestroyTexture(texture);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1666,7 +1666,7 @@ static int SDL_UpdateTextureYUV(SDL_Texture *texture, const SDL_Rect *rect,
|
||||||
} else {
|
} else {
|
||||||
/* Use a temporary buffer for updating */
|
/* Use a temporary buffer for updating */
|
||||||
const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
|
const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
|
||||||
const size_t alloclen = rect->h * temp_pitch;
|
const size_t alloclen = (size_t)rect->h * temp_pitch;
|
||||||
if (alloclen > 0) {
|
if (alloclen > 0) {
|
||||||
void *temp_pixels = SDL_malloc(alloclen);
|
void *temp_pixels = SDL_malloc(alloclen);
|
||||||
if (temp_pixels == NULL) {
|
if (temp_pixels == NULL) {
|
||||||
|
@ -1706,7 +1706,7 @@ static int SDL_UpdateTextureNative(SDL_Texture *texture, const SDL_Rect *rect,
|
||||||
} else {
|
} else {
|
||||||
/* Use a temporary buffer for updating */
|
/* Use a temporary buffer for updating */
|
||||||
const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
|
const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
|
||||||
const size_t alloclen = rect->h * temp_pitch;
|
const size_t alloclen = (size_t)rect->h * temp_pitch;
|
||||||
if (alloclen > 0) {
|
if (alloclen > 0) {
|
||||||
void *temp_pixels = SDL_malloc(alloclen);
|
void *temp_pixels = SDL_malloc(alloclen);
|
||||||
if (temp_pixels == NULL) {
|
if (temp_pixels == NULL) {
|
||||||
|
@ -1800,7 +1800,7 @@ static int SDL_UpdateTextureYUVPlanar(SDL_Texture *texture, const SDL_Rect *rect
|
||||||
} else {
|
} else {
|
||||||
/* Use a temporary buffer for updating */
|
/* Use a temporary buffer for updating */
|
||||||
const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
|
const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
|
||||||
const size_t alloclen = rect->h * temp_pitch;
|
const size_t alloclen = (size_t)rect->h * temp_pitch;
|
||||||
if (alloclen > 0) {
|
if (alloclen > 0) {
|
||||||
void *temp_pixels = SDL_malloc(alloclen);
|
void *temp_pixels = SDL_malloc(alloclen);
|
||||||
if (temp_pixels == NULL) {
|
if (temp_pixels == NULL) {
|
||||||
|
@ -1850,7 +1850,7 @@ static int SDL_UpdateTextureNVPlanar(SDL_Texture *texture, const SDL_Rect *rect,
|
||||||
} else {
|
} else {
|
||||||
/* Use a temporary buffer for updating */
|
/* Use a temporary buffer for updating */
|
||||||
const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
|
const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
|
||||||
const size_t alloclen = rect->h * temp_pitch;
|
const size_t alloclen = (size_t)rect->h * temp_pitch;
|
||||||
if (alloclen > 0) {
|
if (alloclen > 0) {
|
||||||
void *temp_pixels = SDL_malloc(alloclen);
|
void *temp_pixels = SDL_malloc(alloclen);
|
||||||
if (temp_pixels == NULL) {
|
if (temp_pixels == NULL) {
|
||||||
|
@ -2292,9 +2292,9 @@ static int UpdateLogicalSize(SDL_Renderer *renderer, SDL_bool flush_viewport_cmd
|
||||||
|
|
||||||
if (renderer->integer_scale) {
|
if (renderer->integer_scale) {
|
||||||
if (want_aspect > real_aspect) {
|
if (want_aspect > real_aspect) {
|
||||||
scale = (float)(w / renderer->logical_w);
|
scale = (float)(w) / renderer->logical_w;
|
||||||
} else {
|
} else {
|
||||||
scale = (float)(h / renderer->logical_h);
|
scale = (float)(h) / renderer->logical_h;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scale < 1.0f) {
|
if (scale < 1.0f) {
|
||||||
|
@ -2431,10 +2431,12 @@ int SDL_RenderSetViewport(SDL_Renderer *renderer, const SDL_Rect *rect)
|
||||||
if (SDL_GetRendererOutputSize(renderer, &w, &h) < 0) {
|
if (SDL_GetRendererOutputSize(renderer, &w, &h) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
renderer->viewport.x = (double)0;
|
renderer->viewport.x = 0.0;
|
||||||
renderer->viewport.y = (double)0;
|
renderer->viewport.y = 0.0;
|
||||||
|
/* NOLINTBEGIN(clang-analyzer-core.uninitialized.Assign): SDL_GetRendererOutputSize cannot fail */
|
||||||
renderer->viewport.w = (double)w;
|
renderer->viewport.w = (double)w;
|
||||||
renderer->viewport.h = (double)h;
|
renderer->viewport.h = (double)h;
|
||||||
|
/* NOLINTEND(clang-analyzer-core.uninitialized.Assign) */
|
||||||
}
|
}
|
||||||
retval = QueueCmdSetViewport(renderer);
|
retval = QueueCmdSetViewport(renderer);
|
||||||
return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer);
|
return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer);
|
||||||
|
|
|
@ -141,7 +141,7 @@ int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||||
if (rect->x == 0 && rect->y == 0 &&
|
if (rect->x == 0 && rect->y == 0 &&
|
||||||
rect->w == swdata->w && rect->h == swdata->h) {
|
rect->w == swdata->w && rect->h == swdata->h) {
|
||||||
SDL_memcpy(swdata->pixels, pixels,
|
SDL_memcpy(swdata->pixels, pixels,
|
||||||
(swdata->h * swdata->w) + 2 * ((swdata->h + 1) / 2) * ((swdata->w + 1) / 2));
|
(size_t)(swdata->h * swdata->w) + 2 * ((swdata->h + 1) / 2) * ((swdata->w + 1) / 2));
|
||||||
} else {
|
} else {
|
||||||
Uint8 *src, *dst;
|
Uint8 *src, *dst;
|
||||||
int row;
|
int row;
|
||||||
|
@ -193,7 +193,7 @@ int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||||
dst =
|
dst =
|
||||||
swdata->planes[0] + rect->y * swdata->pitches[0] +
|
swdata->planes[0] + rect->y * swdata->pitches[0] +
|
||||||
rect->x * 2;
|
rect->x * 2;
|
||||||
length = 4 * ((rect->w + 1) / 2);
|
length = 4 * (((size_t)rect->w + 1) / 2);
|
||||||
for (row = 0; row < rect->h; ++row) {
|
for (row = 0; row < rect->h; ++row) {
|
||||||
SDL_memcpy(dst, src, length);
|
SDL_memcpy(dst, src, length);
|
||||||
src += pitch;
|
src += pitch;
|
||||||
|
@ -205,7 +205,7 @@ int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||||
{
|
{
|
||||||
if (rect->x == 0 && rect->y == 0 && rect->w == swdata->w && rect->h == swdata->h) {
|
if (rect->x == 0 && rect->y == 0 && rect->w == swdata->w && rect->h == swdata->h) {
|
||||||
SDL_memcpy(swdata->pixels, pixels,
|
SDL_memcpy(swdata->pixels, pixels,
|
||||||
(swdata->h * swdata->w) + 2 * ((swdata->h + 1) / 2) * ((swdata->w + 1) / 2));
|
(size_t)(swdata->h * swdata->w) + 2 * ((swdata->h + 1) / 2) * ((swdata->w + 1) / 2));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Uint8 *src, *dst;
|
Uint8 *src, *dst;
|
||||||
|
@ -226,7 +226,7 @@ int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||||
src = (Uint8 *)pixels + rect->h * pitch;
|
src = (Uint8 *)pixels + rect->h * pitch;
|
||||||
dst = swdata->pixels + swdata->h * swdata->w;
|
dst = swdata->pixels + swdata->h * swdata->w;
|
||||||
dst += 2 * ((rect->y + 1) / 2) * ((swdata->w + 1) / 2) + 2 * (rect->x / 2);
|
dst += 2 * ((rect->y + 1) / 2) * ((swdata->w + 1) / 2) + 2 * (rect->x / 2);
|
||||||
length = 2 * ((rect->w + 1) / 2);
|
length = 2 * (((size_t)rect->w + 1) / 2);
|
||||||
for (row = 0; row < (rect->h + 1) / 2; ++row) {
|
for (row = 0; row < (rect->h + 1) / 2; ++row) {
|
||||||
SDL_memcpy(dst, src, length);
|
SDL_memcpy(dst, src, length);
|
||||||
src += 2 * ((pitch + 1) / 2);
|
src += 2 * ((pitch + 1) / 2);
|
||||||
|
|
|
@ -477,9 +477,9 @@ static int D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *textur
|
||||||
}
|
}
|
||||||
|
|
||||||
d3drect.left = x;
|
d3drect.left = x;
|
||||||
d3drect.right = x + w;
|
d3drect.right = (LONG)x + w;
|
||||||
d3drect.top = y;
|
d3drect.top = y;
|
||||||
d3drect.bottom = y + h;
|
d3drect.bottom = (LONG)y + h;
|
||||||
|
|
||||||
result = IDirect3DTexture9_LockRect(texture->staging, 0, &locked, &d3drect, 0);
|
result = IDirect3DTexture9_LockRect(texture->staging, 0, &locked, &d3drect, 0);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
|
@ -490,7 +490,7 @@ static int D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *textur
|
||||||
dst = (Uint8 *)locked.pBits;
|
dst = (Uint8 *)locked.pBits;
|
||||||
length = w * SDL_BYTESPERPIXEL(texture->format);
|
length = w * SDL_BYTESPERPIXEL(texture->format);
|
||||||
if (length == pitch && length == locked.Pitch) {
|
if (length == pitch && length == locked.Pitch) {
|
||||||
SDL_memcpy(dst, src, length * h);
|
SDL_memcpy(dst, src, (size_t)length * h);
|
||||||
} else {
|
} else {
|
||||||
if (length > pitch) {
|
if (length > pitch) {
|
||||||
length = pitch;
|
length = pitch;
|
||||||
|
@ -673,7 +673,7 @@ static int D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*pixels =
|
*pixels =
|
||||||
(void *)((Uint8 *)texturedata->pixels + rect->y * texturedata->pitch +
|
(void *)(texturedata->pixels + rect->y * texturedata->pitch +
|
||||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||||
*pitch = texturedata->pitch;
|
*pitch = texturedata->pitch;
|
||||||
} else
|
} else
|
||||||
|
@ -688,9 +688,9 @@ static int D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||||
}
|
}
|
||||||
|
|
||||||
d3drect.left = rect->x;
|
d3drect.left = rect->x;
|
||||||
d3drect.right = rect->x + rect->w;
|
d3drect.right = (LONG)rect->x + rect->w;
|
||||||
d3drect.top = rect->y;
|
d3drect.top = rect->y;
|
||||||
d3drect.bottom = rect->y + rect->h;
|
d3drect.bottom = (LONG)rect->y + rect->h;
|
||||||
|
|
||||||
result = IDirect3DTexture9_LockRect(texturedata->texture.staging, 0, &locked, &d3drect, 0);
|
result = IDirect3DTexture9_LockRect(texturedata->texture.staging, 0, &locked, &d3drect, 0);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
|
@ -714,7 +714,7 @@ static void D3D_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||||
if (texturedata->yuv) {
|
if (texturedata->yuv) {
|
||||||
const SDL_Rect *rect = &texturedata->locked_rect;
|
const SDL_Rect *rect = &texturedata->locked_rect;
|
||||||
void *pixels =
|
void *pixels =
|
||||||
(void *)((Uint8 *)texturedata->pixels + rect->y * texturedata->pitch +
|
(void *)(texturedata->pixels + rect->y * texturedata->pitch +
|
||||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||||
D3D_UpdateTexture(renderer, texture, rect, pixels, texturedata->pitch);
|
D3D_UpdateTexture(renderer, texture, rect, pixels, texturedata->pitch);
|
||||||
} else
|
} else
|
||||||
|
@ -1083,10 +1083,10 @@ static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
|
||||||
const SDL_Rect *viewport = &data->drawstate.viewport;
|
const SDL_Rect *viewport = &data->drawstate.viewport;
|
||||||
const SDL_Rect *rect = &data->drawstate.cliprect;
|
const SDL_Rect *rect = &data->drawstate.cliprect;
|
||||||
RECT d3drect;
|
RECT d3drect;
|
||||||
d3drect.left = viewport->x + rect->x;
|
d3drect.left = (LONG)viewport->x + rect->x;
|
||||||
d3drect.top = viewport->y + rect->y;
|
d3drect.top = (LONG)viewport->y + rect->y;
|
||||||
d3drect.right = viewport->x + rect->x + rect->w;
|
d3drect.right = (LONG)viewport->x + rect->x + rect->w;
|
||||||
d3drect.bottom = viewport->y + rect->y + rect->h;
|
d3drect.bottom = (LONG)viewport->y + rect->y + rect->h;
|
||||||
IDirect3DDevice9_SetScissorRect(data->device, &d3drect);
|
IDirect3DDevice9_SetScissorRect(data->device, &d3drect);
|
||||||
data->drawstate.cliprect_dirty = SDL_FALSE;
|
data->drawstate.cliprect_dirty = SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1236,7 +1236,8 @@ static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
|
||||||
const Vertex *verts = (Vertex *)(((Uint8 *)vertices) + first);
|
const Vertex *verts = (Vertex *)(((Uint8 *)vertices) + first);
|
||||||
|
|
||||||
/* DirectX 9 has the same line rasterization semantics as GDI,
|
/* DirectX 9 has the same line rasterization semantics as GDI,
|
||||||
so we need to close the endpoint of the line with a second draw call. */
|
so we need to close the endpoint of the line with a second draw call.
|
||||||
|
NOLINTNEXTLINE(clang-analyzer-core.NullDereference): FIXME: Can verts truly not be NULL ? */
|
||||||
const SDL_bool close_endpoint = ((count == 2) || (verts[0].x != verts[count - 1].x) || (verts[0].y != verts[count - 1].y));
|
const SDL_bool close_endpoint = ((count == 2) || (verts[0].x != verts[count - 1].x) || (verts[0].y != verts[count - 1].y));
|
||||||
|
|
||||||
SetDrawState(data, cmd);
|
SetDrawState(data, cmd);
|
||||||
|
@ -1323,9 +1324,9 @@ static int D3D_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
|
||||||
}
|
}
|
||||||
|
|
||||||
d3drect.left = rect->x;
|
d3drect.left = rect->x;
|
||||||
d3drect.right = rect->x + rect->w;
|
d3drect.right = (LONG)rect->x + rect->w;
|
||||||
d3drect.top = rect->y;
|
d3drect.top = rect->y;
|
||||||
d3drect.bottom = rect->y + rect->h;
|
d3drect.bottom = (LONG)rect->y + rect->h;
|
||||||
|
|
||||||
result = IDirect3DSurface9_LockRect(surface, &locked, &d3drect, D3DLOCK_READONLY);
|
result = IDirect3DSurface9_LockRect(surface, &locked, &d3drect, D3DLOCK_READONLY);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
|
|
|
@ -699,9 +699,9 @@ static int D3D11_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rec
|
||||||
switch (rotation) {
|
switch (rotation) {
|
||||||
case DXGI_MODE_ROTATION_IDENTITY:
|
case DXGI_MODE_ROTATION_IDENTITY:
|
||||||
outRect->left = sdlRect->x;
|
outRect->left = sdlRect->x;
|
||||||
outRect->right = sdlRect->x + sdlRect->w;
|
outRect->right = (LONG)sdlRect->x + sdlRect->w;
|
||||||
outRect->top = sdlRect->y;
|
outRect->top = sdlRect->y;
|
||||||
outRect->bottom = sdlRect->y + sdlRect->h;
|
outRect->bottom = (LONG)sdlRect->y + sdlRect->h;
|
||||||
if (includeViewportOffset) {
|
if (includeViewportOffset) {
|
||||||
outRect->left += viewport->x;
|
outRect->left += viewport->x;
|
||||||
outRect->right += viewport->x;
|
outRect->right += viewport->x;
|
||||||
|
@ -711,7 +711,7 @@ static int D3D11_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rec
|
||||||
break;
|
break;
|
||||||
case DXGI_MODE_ROTATION_ROTATE270:
|
case DXGI_MODE_ROTATION_ROTATE270:
|
||||||
outRect->left = sdlRect->y;
|
outRect->left = sdlRect->y;
|
||||||
outRect->right = sdlRect->y + sdlRect->h;
|
outRect->right = (LONG)sdlRect->y + sdlRect->h;
|
||||||
outRect->top = viewport->w - sdlRect->x - sdlRect->w;
|
outRect->top = viewport->w - sdlRect->x - sdlRect->w;
|
||||||
outRect->bottom = viewport->w - sdlRect->x;
|
outRect->bottom = viewport->w - sdlRect->x;
|
||||||
break;
|
break;
|
||||||
|
@ -725,7 +725,7 @@ static int D3D11_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rec
|
||||||
outRect->left = viewport->h - sdlRect->y - sdlRect->h;
|
outRect->left = viewport->h - sdlRect->y - sdlRect->h;
|
||||||
outRect->right = viewport->h - sdlRect->y;
|
outRect->right = viewport->h - sdlRect->y;
|
||||||
outRect->top = sdlRect->x;
|
outRect->top = sdlRect->x;
|
||||||
outRect->bottom = sdlRect->x + sdlRect->h;
|
outRect->bottom = (LONG)sdlRect->x + sdlRect->h;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return SDL_SetError("The physical display is in an unknown or unsupported rotation");
|
return SDL_SetError("The physical display is in an unknown or unsupported rotation");
|
||||||
|
@ -932,7 +932,7 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer)
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
result = D3D11_CreateSwapChain(renderer, w, h);
|
result = D3D11_CreateSwapChain(renderer, w, h);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result) || data->swapChain == NULL) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1299,7 +1299,7 @@ static int D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Tex
|
||||||
dst = textureMemory.pData;
|
dst = textureMemory.pData;
|
||||||
length = w * bpp;
|
length = w * bpp;
|
||||||
if (length == pitch && length == textureMemory.RowPitch) {
|
if (length == pitch && length == textureMemory.RowPitch) {
|
||||||
SDL_memcpy(dst, src, length * h);
|
SDL_memcpy(dst, src, (size_t)length * h);
|
||||||
} else {
|
} else {
|
||||||
if (length > (UINT)pitch) {
|
if (length > (UINT)pitch) {
|
||||||
length = pitch;
|
length = pitch;
|
||||||
|
@ -1450,7 +1450,7 @@ static int D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||||
}
|
}
|
||||||
textureData->locked_rect = *rect;
|
textureData->locked_rect = *rect;
|
||||||
*pixels =
|
*pixels =
|
||||||
(void *)((Uint8 *)textureData->pixels + rect->y * textureData->pitch +
|
(void *)(textureData->pixels + rect->y * textureData->pitch +
|
||||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||||
*pitch = textureData->pitch;
|
*pitch = textureData->pitch;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1521,7 +1521,7 @@ static void D3D11_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||||
if (textureData->yuv || textureData->nv12) {
|
if (textureData->yuv || textureData->nv12) {
|
||||||
const SDL_Rect *rect = &textureData->locked_rect;
|
const SDL_Rect *rect = &textureData->locked_rect;
|
||||||
void *pixels =
|
void *pixels =
|
||||||
(void *)((Uint8 *)textureData->pixels + rect->y * textureData->pitch +
|
(void *)(textureData->pixels + rect->y * textureData->pitch +
|
||||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||||
D3D11_UpdateTexture(renderer, texture, rect, pixels, textureData->pitch);
|
D3D11_UpdateTexture(renderer, texture, rect, pixels, textureData->pitch);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1101,9 +1101,9 @@ static int D3D12_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rec
|
||||||
switch (rotation) {
|
switch (rotation) {
|
||||||
case DXGI_MODE_ROTATION_IDENTITY:
|
case DXGI_MODE_ROTATION_IDENTITY:
|
||||||
outRect->left = sdlRect->x;
|
outRect->left = sdlRect->x;
|
||||||
outRect->right = sdlRect->x + sdlRect->w;
|
outRect->right = (LONG)sdlRect->x + sdlRect->w;
|
||||||
outRect->top = sdlRect->y;
|
outRect->top = sdlRect->y;
|
||||||
outRect->bottom = sdlRect->y + sdlRect->h;
|
outRect->bottom = (LONG)sdlRect->y + sdlRect->h;
|
||||||
if (includeViewportOffset) {
|
if (includeViewportOffset) {
|
||||||
outRect->left += viewport->x;
|
outRect->left += viewport->x;
|
||||||
outRect->right += viewport->x;
|
outRect->right += viewport->x;
|
||||||
|
@ -1113,7 +1113,7 @@ static int D3D12_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rec
|
||||||
break;
|
break;
|
||||||
case DXGI_MODE_ROTATION_ROTATE270:
|
case DXGI_MODE_ROTATION_ROTATE270:
|
||||||
outRect->left = sdlRect->y;
|
outRect->left = sdlRect->y;
|
||||||
outRect->right = sdlRect->y + sdlRect->h;
|
outRect->right = (LONG)sdlRect->y + sdlRect->h;
|
||||||
outRect->top = viewport->w - sdlRect->x - sdlRect->w;
|
outRect->top = viewport->w - sdlRect->x - sdlRect->w;
|
||||||
outRect->bottom = viewport->w - sdlRect->x;
|
outRect->bottom = viewport->w - sdlRect->x;
|
||||||
break;
|
break;
|
||||||
|
@ -1127,7 +1127,7 @@ static int D3D12_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rec
|
||||||
outRect->left = viewport->h - sdlRect->y - sdlRect->h;
|
outRect->left = viewport->h - sdlRect->y - sdlRect->h;
|
||||||
outRect->right = viewport->h - sdlRect->y;
|
outRect->right = viewport->h - sdlRect->y;
|
||||||
outRect->top = sdlRect->x;
|
outRect->top = sdlRect->x;
|
||||||
outRect->bottom = sdlRect->x + sdlRect->h;
|
outRect->bottom = (LONG)sdlRect->x + sdlRect->h;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return SDL_SetError("The physical display is in an unknown or unsupported rotation");
|
return SDL_SetError("The physical display is in an unknown or unsupported rotation");
|
||||||
|
@ -1299,7 +1299,7 @@ static HRESULT D3D12_CreateWindowSizeDependentResources(SDL_Renderer *renderer)
|
||||||
/* Set the proper rotation for the swap chain. */
|
/* Set the proper rotation for the swap chain. */
|
||||||
if (WIN_IsWindows8OrGreater()) {
|
if (WIN_IsWindows8OrGreater()) {
|
||||||
if (data->swapEffect == DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL) {
|
if (data->swapEffect == DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL) {
|
||||||
result = D3D_CALL(data->swapChain, SetRotation, data->rotation);
|
result = D3D_CALL(data->swapChain, SetRotation, data->rotation); /* NOLINT(clang-analyzer-core.NullDereference) */
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain4::SetRotation"), result);
|
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain4::SetRotation"), result);
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -1317,7 +1317,7 @@ static HRESULT D3D12_CreateWindowSizeDependentResources(SDL_Renderer *renderer)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
result = D3D_CALL(data->swapChain, GetBuffer,
|
result = D3D_CALL(data->swapChain, GetBuffer, /* NOLINT(clang-analyzer-core.NullDereference) */
|
||||||
i,
|
i,
|
||||||
D3D_GUID(SDL_IID_ID3D12Resource),
|
D3D_GUID(SDL_IID_ID3D12Resource),
|
||||||
(void **)&data->renderTargets[i]);
|
(void **)&data->renderTargets[i]);
|
||||||
|
@ -1730,7 +1730,7 @@ static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Res
|
||||||
dst = textureMemory;
|
dst = textureMemory;
|
||||||
length = w * bpp;
|
length = w * bpp;
|
||||||
if (length == pitch && length == pitchedDesc.RowPitch) {
|
if (length == pitch && length == pitchedDesc.RowPitch) {
|
||||||
SDL_memcpy(dst, src, length * h);
|
SDL_memcpy(dst, src, (size_t)length * h);
|
||||||
} else {
|
} else {
|
||||||
if (length > (UINT)pitch) {
|
if (length > (UINT)pitch) {
|
||||||
length = pitch;
|
length = pitch;
|
||||||
|
@ -1903,7 +1903,7 @@ static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||||
}
|
}
|
||||||
textureData->lockedRect = *rect;
|
textureData->lockedRect = *rect;
|
||||||
*pixels =
|
*pixels =
|
||||||
(void *)((Uint8 *)textureData->pixels + rect->y * textureData->pitch +
|
(void *)(textureData->pixels + rect->y * textureData->pitch +
|
||||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||||
*pitch = textureData->pitch;
|
*pitch = textureData->pitch;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2014,7 +2014,7 @@ static void D3D12_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||||
if (textureData->yuv || textureData->nv12) {
|
if (textureData->yuv || textureData->nv12) {
|
||||||
const SDL_Rect *rect = &textureData->lockedRect;
|
const SDL_Rect *rect = &textureData->lockedRect;
|
||||||
void *pixels =
|
void *pixels =
|
||||||
(void *)((Uint8 *)textureData->pixels + rect->y * textureData->pitch +
|
(void *)(textureData->pixels + rect->y * textureData->pitch +
|
||||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||||
D3D12_UpdateTexture(renderer, texture, rect, pixels, textureData->pitch);
|
D3D12_UpdateTexture(renderer, texture, rect, pixels, textureData->pitch);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -146,7 +146,7 @@ typedef struct METAL_ShaderPipelines
|
||||||
|
|
||||||
@interface METAL_TextureData : NSObject
|
@interface METAL_TextureData : NSObject
|
||||||
@property(nonatomic, retain) id<MTLTexture> mtltexture;
|
@property(nonatomic, retain) id<MTLTexture> mtltexture;
|
||||||
@property(nonatomic, retain) id<MTLTexture> mtltexture_uv;
|
@property(nonatomic, retain) id<MTLTexture> mtltextureUv;
|
||||||
@property(nonatomic, retain) id<MTLSamplerState> mtlsampler;
|
@property(nonatomic, retain) id<MTLSamplerState> mtlsampler;
|
||||||
@property(nonatomic, assign) SDL_MetalFragmentFunction fragmentFunction;
|
@property(nonatomic, assign) SDL_MetalFragmentFunction fragmentFunction;
|
||||||
#if SDL_HAVE_YUV
|
#if SDL_HAVE_YUV
|
||||||
|
@ -551,13 +551,14 @@ static SDL_bool METAL_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode bl
|
||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int METAL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
static int
|
||||||
|
METAL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
METAL_RenderData *data = (__bridge METAL_RenderData *)renderer->driverdata;
|
METAL_RenderData *data = (__bridge METAL_RenderData *)renderer->driverdata;
|
||||||
MTLPixelFormat pixfmt;
|
MTLPixelFormat pixfmt;
|
||||||
MTLTextureDescriptor *mtltexdesc;
|
MTLTextureDescriptor *mtltexdesc;
|
||||||
id<MTLTexture> mtltexture, mtltexture_uv;
|
id<MTLTexture> mtltexture, mtltextureUv;
|
||||||
BOOL yuv, nv12;
|
BOOL yuv, nv12;
|
||||||
METAL_TextureData *texturedata;
|
METAL_TextureData *texturedata;
|
||||||
|
|
||||||
|
@ -597,7 +598,7 @@ static int METAL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||||
return SDL_SetError("Texture allocation failed");
|
return SDL_SetError("Texture allocation failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
mtltexture_uv = nil;
|
mtltextureUv = nil;
|
||||||
#if SDL_HAVE_YUV
|
#if SDL_HAVE_YUV
|
||||||
yuv = (texture->format == SDL_PIXELFORMAT_IYUV) || (texture->format == SDL_PIXELFORMAT_YV12);
|
yuv = (texture->format == SDL_PIXELFORMAT_IYUV) || (texture->format == SDL_PIXELFORMAT_YV12);
|
||||||
nv12 = (texture->format == SDL_PIXELFORMAT_NV12) || (texture->format == SDL_PIXELFORMAT_NV21);
|
nv12 = (texture->format == SDL_PIXELFORMAT_NV12) || (texture->format == SDL_PIXELFORMAT_NV21);
|
||||||
|
@ -615,8 +616,8 @@ static int METAL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yuv || nv12) {
|
if (yuv || nv12) {
|
||||||
mtltexture_uv = [data.mtldevice newTextureWithDescriptor:mtltexdesc];
|
mtltextureUv = [data.mtldevice newTextureWithDescriptor:mtltexdesc];
|
||||||
if (mtltexture_uv == nil) {
|
if (mtltextureUv == nil) {
|
||||||
return SDL_SetError("Texture allocation failed");
|
return SDL_SetError("Texture allocation failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -628,7 +629,7 @@ static int METAL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||||
texturedata.mtlsampler = data.mtlsamplerlinear;
|
texturedata.mtlsampler = data.mtlsamplerlinear;
|
||||||
}
|
}
|
||||||
texturedata.mtltexture = mtltexture;
|
texturedata.mtltexture = mtltexture;
|
||||||
texturedata.mtltexture_uv = mtltexture_uv;
|
texturedata.mtltextureUv = mtltextureUv;
|
||||||
#if SDL_HAVE_YUV
|
#if SDL_HAVE_YUV
|
||||||
texturedata.yuv = yuv;
|
texturedata.yuv = yuv;
|
||||||
texturedata.nv12 = nv12;
|
texturedata.nv12 = nv12;
|
||||||
|
@ -777,13 +778,13 @@ static int METAL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||||
|
|
||||||
/* Skip to the correct offset into the next texture */
|
/* Skip to the correct offset into the next texture */
|
||||||
pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch);
|
pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch);
|
||||||
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture_uv, UVrect, Uslice, pixels, UVpitch) < 0) {
|
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, Uslice, pixels, UVpitch) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Skip to the correct offset into the next texture */
|
/* Skip to the correct offset into the next texture */
|
||||||
pixels = (const void *)((const Uint8 *)pixels + UVrect.h * UVpitch);
|
pixels = (const void *)((const Uint8 *)pixels + UVrect.h * UVpitch);
|
||||||
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture_uv, UVrect, Vslice, pixels, UVpitch) < 0) {
|
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, Vslice, pixels, UVpitch) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -794,7 +795,7 @@ static int METAL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||||
|
|
||||||
/* Skip to the correct offset into the next texture */
|
/* Skip to the correct offset into the next texture */
|
||||||
pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch);
|
pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch);
|
||||||
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture_uv, UVrect, 0, pixels, UVpitch) < 0) {
|
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, 0, pixels, UVpitch) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -826,10 +827,10 @@ static int METAL_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||||
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture, *rect, 0, Yplane, Ypitch) < 0) {
|
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture, *rect, 0, Yplane, Ypitch) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture_uv, UVrect, Uslice, Uplane, Upitch)) {
|
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, Uslice, Uplane, Upitch)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture_uv, UVrect, Vslice, Vplane, Vpitch)) {
|
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, Vslice, Vplane, Vpitch)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -857,7 +858,7 @@ static int METAL_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture_uv, UVrect, 0, UVplane, UVpitch) < 0) {
|
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, 0, UVplane, UVpitch) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -949,7 +950,7 @@ static void METAL_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||||
sourceBytesPerRow:UVpitch
|
sourceBytesPerRow:UVpitch
|
||||||
sourceBytesPerImage:UVpitch * UVrect.h
|
sourceBytesPerImage:UVpitch * UVrect.h
|
||||||
sourceSize:MTLSizeMake(UVrect.w, UVrect.h, 1)
|
sourceSize:MTLSizeMake(UVrect.w, UVrect.h, 1)
|
||||||
toTexture:texturedata.mtltexture_uv
|
toTexture:texturedata.mtltextureUv
|
||||||
destinationSlice:Uslice
|
destinationSlice:Uslice
|
||||||
destinationLevel:0
|
destinationLevel:0
|
||||||
destinationOrigin:MTLOriginMake(UVrect.x, UVrect.y, 0)];
|
destinationOrigin:MTLOriginMake(UVrect.x, UVrect.y, 0)];
|
||||||
|
@ -959,7 +960,7 @@ static void METAL_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||||
sourceBytesPerRow:UVpitch
|
sourceBytesPerRow:UVpitch
|
||||||
sourceBytesPerImage:UVpitch * UVrect.h
|
sourceBytesPerImage:UVpitch * UVrect.h
|
||||||
sourceSize:MTLSizeMake(UVrect.w, UVrect.h, 1)
|
sourceSize:MTLSizeMake(UVrect.w, UVrect.h, 1)
|
||||||
toTexture:texturedata.mtltexture_uv
|
toTexture:texturedata.mtltextureUv
|
||||||
destinationSlice:Vslice
|
destinationSlice:Vslice
|
||||||
destinationLevel:0
|
destinationLevel:0
|
||||||
destinationOrigin:MTLOriginMake(UVrect.x, UVrect.y, 0)];
|
destinationOrigin:MTLOriginMake(UVrect.x, UVrect.y, 0)];
|
||||||
|
@ -973,7 +974,7 @@ static void METAL_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||||
sourceBytesPerRow:UVpitch
|
sourceBytesPerRow:UVpitch
|
||||||
sourceBytesPerImage:0
|
sourceBytesPerImage:0
|
||||||
sourceSize:MTLSizeMake(UVrect.w, UVrect.h, 1)
|
sourceSize:MTLSizeMake(UVrect.w, UVrect.h, 1)
|
||||||
toTexture:texturedata.mtltexture_uv
|
toTexture:texturedata.mtltextureUv
|
||||||
destinationSlice:0
|
destinationSlice:0
|
||||||
destinationLevel:0
|
destinationLevel:0
|
||||||
destinationOrigin:MTLOriginMake(UVrect.x, UVrect.y, 0)];
|
destinationOrigin:MTLOriginMake(UVrect.x, UVrect.y, 0)];
|
||||||
|
@ -1308,7 +1309,7 @@ static SDL_bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cm
|
||||||
[data.mtlcmdencoder setFragmentTexture:texturedata.mtltexture atIndex:0];
|
[data.mtlcmdencoder setFragmentTexture:texturedata.mtltexture atIndex:0];
|
||||||
#if SDL_HAVE_YUV
|
#if SDL_HAVE_YUV
|
||||||
if (texturedata.yuv || texturedata.nv12) {
|
if (texturedata.yuv || texturedata.nv12) {
|
||||||
[data.mtlcmdencoder setFragmentTexture:texturedata.mtltexture_uv atIndex:1];
|
[data.mtlcmdencoder setFragmentTexture:texturedata.mtltextureUv atIndex:1];
|
||||||
[data.mtlcmdencoder setFragmentBuffer:data.mtlbufconstants offset:texturedata.conversionBufferOffset atIndex:1];
|
[data.mtlcmdencoder setFragmentBuffer:data.mtlbufconstants offset:texturedata.conversionBufferOffset atIndex:1];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1466,14 +1467,16 @@ static int METAL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int METAL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
|
static int
|
||||||
Uint32 pixel_format, void *pixels, int pitch)
|
METAL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
|
||||||
|
Uint32 pixel_format, void *pixels, int pitch)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
METAL_RenderData *data = (__bridge METAL_RenderData *)renderer->driverdata;
|
METAL_RenderData *data = (__bridge METAL_RenderData *)renderer->driverdata;
|
||||||
id<MTLTexture> mtltexture;
|
id<MTLTexture> mtltexture;
|
||||||
MTLRegion mtlregion;
|
MTLRegion mtlregion;
|
||||||
int temp_pitch, status;
|
size_t temp_pitch;
|
||||||
|
int status;
|
||||||
Uint32 temp_format;
|
Uint32 temp_format;
|
||||||
void *temp_pixels;
|
void *temp_pixels;
|
||||||
if (!METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionLoad, NULL, nil)) {
|
if (!METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionLoad, NULL, nil)) {
|
||||||
|
@ -1505,7 +1508,7 @@ static int METAL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
|
||||||
mtlregion = MTLRegionMake2D(rect->x, rect->y, rect->w, rect->h);
|
mtlregion = MTLRegionMake2D(rect->x, rect->y, rect->w, rect->h);
|
||||||
|
|
||||||
// we only do BGRA8 or RGBA8 at the moment, so 4 will do.
|
// we only do BGRA8 or RGBA8 at the moment, so 4 will do.
|
||||||
temp_pitch = rect->w * 4;
|
temp_pitch = rect->w * 4UL;
|
||||||
temp_pixels = SDL_malloc(temp_pitch * rect->h);
|
temp_pixels = SDL_malloc(temp_pitch * rect->h);
|
||||||
if (!temp_pixels) {
|
if (!temp_pixels) {
|
||||||
return SDL_OutOfMemory();
|
return SDL_OutOfMemory();
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
|
|
||||||
#if SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED
|
#if SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED
|
||||||
#include "../../video/SDL_sysvideo.h" /* For SDL_GL_SwapWindowWithResult */
|
#include "../../video/SDL_sysvideo.h" /* For SDL_GL_SwapWindowWithResult and SDL_RecreateWindow */
|
||||||
#include <SDL3/SDL_opengl.h>
|
#include <SDL3/SDL_opengl.h>
|
||||||
#include "../SDL_sysrender.h"
|
#include "../SDL_sysrender.h"
|
||||||
#include "SDL_shaders_gl.h"
|
#include "SDL_shaders_gl.h"
|
||||||
|
@ -49,9 +49,6 @@
|
||||||
http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_texturedata/opengl_texturedata.html
|
http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_texturedata/opengl_texturedata.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Used to re-create the window with OpenGL capability */
|
|
||||||
extern int SDL_RecreateWindow(SDL_Window *window, Uint32 flags);
|
|
||||||
|
|
||||||
static const float inv255f = 1.0f / 255.0f;
|
static const float inv255f = 1.0f / 255.0f;
|
||||||
|
|
||||||
typedef struct GL_FBOList GL_FBOList;
|
typedef struct GL_FBOList GL_FBOList;
|
||||||
|
@ -476,7 +473,7 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||||
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
|
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
|
||||||
size_t size;
|
size_t size;
|
||||||
data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
|
data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
|
||||||
size = texture->h * data->pitch;
|
size = (size_t)texture->h * data->pitch;
|
||||||
if (texture->format == SDL_PIXELFORMAT_YV12 ||
|
if (texture->format == SDL_PIXELFORMAT_YV12 ||
|
||||||
texture->format == SDL_PIXELFORMAT_IYUV) {
|
texture->format == SDL_PIXELFORMAT_IYUV) {
|
||||||
/* Need to add size for the U and V planes */
|
/* Need to add size for the U and V planes */
|
||||||
|
@ -694,7 +691,7 @@ static int GL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||||
GL_TextureData *data = (GL_TextureData *)texture->driverdata;
|
GL_TextureData *data = (GL_TextureData *)texture->driverdata;
|
||||||
const int texturebpp = SDL_BYTESPERPIXEL(texture->format);
|
const int texturebpp = SDL_BYTESPERPIXEL(texture->format);
|
||||||
|
|
||||||
SDL_assert(texturebpp != 0); /* otherwise, division by zero later. */
|
SDL_assert_release(texturebpp != 0); /* otherwise, division by zero later. */
|
||||||
|
|
||||||
GL_ActivateRenderer(renderer);
|
GL_ActivateRenderer(renderer);
|
||||||
|
|
||||||
|
@ -1429,12 +1426,12 @@ static int GL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
|
||||||
SDL_GetPixelFormatName(temp_format));
|
SDL_GetPixelFormatName(temp_format));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rect->w || !rect->h) {
|
if (rect->w == 0 || rect->h == 0) {
|
||||||
return 0; /* nothing to do. */
|
return 0; /* nothing to do. */
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
||||||
temp_pixels = SDL_malloc(rect->h * temp_pitch);
|
temp_pixels = SDL_malloc((size_t)rect->h * temp_pitch);
|
||||||
if (temp_pixels == NULL) {
|
if (temp_pixels == NULL) {
|
||||||
return SDL_OutOfMemory();
|
return SDL_OutOfMemory();
|
||||||
}
|
}
|
||||||
|
|
|
@ -470,7 +470,7 @@ static SDL_bool CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_Shader
|
||||||
ctx->glUseProgramObjectARB(data->program);
|
ctx->glUseProgramObjectARB(data->program);
|
||||||
for (i = 0; i < num_tmus_bound; ++i) {
|
for (i = 0; i < num_tmus_bound; ++i) {
|
||||||
char tex_name[10];
|
char tex_name[10];
|
||||||
SDL_snprintf(tex_name, SDL_arraysize(tex_name), "tex%d", i);
|
(void)SDL_snprintf(tex_name, SDL_arraysize(tex_name), "tex%d", i);
|
||||||
location = ctx->glGetUniformLocationARB(data->program, tex_name);
|
location = ctx->glGetUniformLocationARB(data->program, tex_name);
|
||||||
if (location >= 0) {
|
if (location >= 0) {
|
||||||
ctx->glUniform1iARB(location, i);
|
ctx->glUniform1iARB(location, i);
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#if SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED
|
#if SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED
|
||||||
|
|
||||||
#include "../../video/SDL_sysvideo.h" /* For SDL_GL_SwapWindowWithResult */
|
#include "../../video/SDL_sysvideo.h" /* For SDL_GL_SwapWindowWithResult and SDL_RecreateWindow */
|
||||||
#include <SDL3/SDL_opengles2.h>
|
#include <SDL3/SDL_opengles2.h>
|
||||||
#include "../SDL_sysrender.h"
|
#include "../SDL_sysrender.h"
|
||||||
#include "../../video/SDL_blit.h"
|
#include "../../video/SDL_blit.h"
|
||||||
|
@ -45,9 +45,6 @@
|
||||||
#define RENDERER_CONTEXT_MAJOR 2
|
#define RENDERER_CONTEXT_MAJOR 2
|
||||||
#define RENDERER_CONTEXT_MINOR 0
|
#define RENDERER_CONTEXT_MINOR 0
|
||||||
|
|
||||||
/* Used to re-create the window with OpenGL ES capability */
|
|
||||||
extern int SDL_RecreateWindow(SDL_Window *window, Uint32 flags);
|
|
||||||
|
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
* Context structures *
|
* Context structures *
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
|
@ -1462,7 +1459,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||||
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
|
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
|
||||||
size_t size;
|
size_t size;
|
||||||
data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
|
data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
|
||||||
size = texture->h * data->pitch;
|
size = (size_t)texture->h * data->pitch;
|
||||||
#if SDL_HAVE_YUV
|
#if SDL_HAVE_YUV
|
||||||
if (data->yuv) {
|
if (data->yuv) {
|
||||||
/* Need to add size for the U and V planes */
|
/* Need to add size for the U and V planes */
|
||||||
|
@ -1562,7 +1559,7 @@ static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoff
|
||||||
Uint32 *blob2 = NULL;
|
Uint32 *blob2 = NULL;
|
||||||
#endif
|
#endif
|
||||||
Uint8 *src;
|
Uint8 *src;
|
||||||
int src_pitch;
|
size_t src_pitch;
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
if ((width == 0) || (height == 0) || (bpp == 0)) {
|
if ((width == 0) || (height == 0) || (bpp == 0)) {
|
||||||
|
@ -1570,7 +1567,7 @@ static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoff
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reformat the texture data into a tightly packed array */
|
/* Reformat the texture data into a tightly packed array */
|
||||||
src_pitch = width * bpp;
|
src_pitch = (size_t)width * bpp;
|
||||||
src = (Uint8 *)pixels;
|
src = (Uint8 *)pixels;
|
||||||
if (pitch != src_pitch) {
|
if (pitch != src_pitch) {
|
||||||
blob = (Uint8 *)SDL_malloc(src_pitch * height);
|
blob = (Uint8 *)SDL_malloc(src_pitch * height);
|
||||||
|
@ -1912,7 +1909,7 @@ static int GLES2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
||||||
buflen = rect->h * temp_pitch;
|
buflen = (size_t)rect->h * temp_pitch;
|
||||||
if (buflen == 0) {
|
if (buflen == 0) {
|
||||||
return 0; /* nothing to do. */
|
return 0; /* nothing to do. */
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ static int SW_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||||
dst = (Uint8 *)surface->pixels +
|
dst = (Uint8 *)surface->pixels +
|
||||||
rect->y * surface->pitch +
|
rect->y * surface->pitch +
|
||||||
rect->x * surface->format->BytesPerPixel;
|
rect->x * surface->format->BytesPerPixel;
|
||||||
length = rect->w * surface->format->BytesPerPixel;
|
length = (size_t)rect->w * surface->format->BytesPerPixel;
|
||||||
for (row = 0; row < rect->h; ++row) {
|
for (row = 0; row < rect->h; ++row) {
|
||||||
SDL_memcpy(dst, src, length);
|
SDL_memcpy(dst, src, length);
|
||||||
src += pitch;
|
src += pitch;
|
||||||
|
@ -533,9 +533,9 @@ static int SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_
|
||||||
int i;
|
int i;
|
||||||
int count = indices ? num_indices : num_vertices;
|
int count = indices ? num_indices : num_vertices;
|
||||||
void *verts;
|
void *verts;
|
||||||
int sz = texture ? sizeof(GeometryCopyData) : sizeof(GeometryFillData);
|
size_t sz = texture != NULL ? sizeof(GeometryCopyData) : sizeof(GeometryFillData);
|
||||||
|
|
||||||
verts = (void *)SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first);
|
verts = SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first);
|
||||||
if (verts == NULL) {
|
if (verts == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -636,7 +636,7 @@ static void SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate)
|
||||||
if (drawstate->surface_cliprect_dirty) {
|
if (drawstate->surface_cliprect_dirty) {
|
||||||
const SDL_Rect *viewport = drawstate->viewport;
|
const SDL_Rect *viewport = drawstate->viewport;
|
||||||
const SDL_Rect *cliprect = drawstate->cliprect;
|
const SDL_Rect *cliprect = drawstate->cliprect;
|
||||||
SDL_assert(viewport != NULL); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */
|
SDL_assert_release(viewport != NULL); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */
|
||||||
|
|
||||||
if (cliprect != NULL) {
|
if (cliprect != NULL) {
|
||||||
SDL_Rect clip_rect;
|
SDL_Rect clip_rect;
|
||||||
|
|
|
@ -431,7 +431,7 @@ static void transformSurfaceY(SDL_Surface *src, SDL_Surface *dst, int isin, int
|
||||||
/*
|
/*
|
||||||
* Clear surface to colorkey
|
* Clear surface to colorkey
|
||||||
*/
|
*/
|
||||||
SDL_memset(pc, (int)(get_colorkey(src) & 0xff), dst->pitch * dst->h);
|
SDL_memset(pc, (int)(get_colorkey(src) & 0xff), (size_t)dst->pitch * dst->h);
|
||||||
/*
|
/*
|
||||||
* Iterate through destination surface
|
* Iterate through destination surface
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -658,7 +658,7 @@ int SDL_SW_BlitTriangle(
|
||||||
tmp_info.src_pitch = src_pitch;
|
tmp_info.src_pitch = src_pitch;
|
||||||
|
|
||||||
/* dst */
|
/* dst */
|
||||||
tmp_info.dst = (Uint8 *)dst_ptr;
|
tmp_info.dst = dst_ptr;
|
||||||
tmp_info.dst_pitch = dst_pitch;
|
tmp_info.dst_pitch = dst_pitch;
|
||||||
|
|
||||||
SDL_BlitTriangle_Slow(&tmp_info, s2_x_area, dstrect, area, bias_w0, bias_w1, bias_w2,
|
SDL_BlitTriangle_Slow(&tmp_info, s2_x_area, dstrect, area, bias_w0, bias_w1, bias_w2,
|
||||||
|
@ -681,7 +681,7 @@ int SDL_SW_BlitTriangle(
|
||||||
TRIANGLE_BEGIN_LOOP
|
TRIANGLE_BEGIN_LOOP
|
||||||
{
|
{
|
||||||
TRIANGLE_GET_TEXTCOORD
|
TRIANGLE_GET_TEXTCOORD
|
||||||
Uint8 *sptr = (Uint8 *)((Uint8 *)src_ptr + srcy * src_pitch);
|
Uint8 *sptr = (Uint8 *)src_ptr + srcy * src_pitch;
|
||||||
dptr[0] = sptr[3 * srcx];
|
dptr[0] = sptr[3 * srcx];
|
||||||
dptr[1] = sptr[3 * srcx + 1];
|
dptr[1] = sptr[3 * srcx + 1];
|
||||||
dptr[2] = sptr[3 * srcx + 2];
|
dptr[2] = sptr[3 * srcx + 2];
|
||||||
|
@ -699,7 +699,7 @@ int SDL_SW_BlitTriangle(
|
||||||
TRIANGLE_BEGIN_LOOP
|
TRIANGLE_BEGIN_LOOP
|
||||||
{
|
{
|
||||||
TRIANGLE_GET_TEXTCOORD
|
TRIANGLE_GET_TEXTCOORD
|
||||||
Uint8 *sptr = (Uint8 *)((Uint8 *)src_ptr + srcy * src_pitch);
|
Uint8 *sptr = (Uint8 *)src_ptr + srcy * src_pitch;
|
||||||
*dptr = sptr[srcx];
|
*dptr = sptr[srcx];
|
||||||
}
|
}
|
||||||
TRIANGLE_END_LOOP
|
TRIANGLE_END_LOOP
|
||||||
|
@ -838,14 +838,17 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||||
break;
|
break;
|
||||||
case SDL_COPY_ADD:
|
case SDL_COPY_ADD:
|
||||||
dstR = srcR + dstR;
|
dstR = srcR + dstR;
|
||||||
if (dstR > 255)
|
if (dstR > 255) {
|
||||||
dstR = 255;
|
dstR = 255;
|
||||||
|
}
|
||||||
dstG = srcG + dstG;
|
dstG = srcG + dstG;
|
||||||
if (dstG > 255)
|
if (dstG > 255) {
|
||||||
dstG = 255;
|
dstG = 255;
|
||||||
|
}
|
||||||
dstB = srcB + dstB;
|
dstB = srcB + dstB;
|
||||||
if (dstB > 255)
|
if (dstB > 255) {
|
||||||
dstB = 255;
|
dstB = 255;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_COPY_MOD:
|
case SDL_COPY_MOD:
|
||||||
dstR = (srcR * dstR) / 255;
|
dstR = (srcR * dstR) / 255;
|
||||||
|
@ -854,17 +857,21 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||||
break;
|
break;
|
||||||
case SDL_COPY_MUL:
|
case SDL_COPY_MUL:
|
||||||
dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255;
|
dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255;
|
||||||
if (dstR > 255)
|
if (dstR > 255) {
|
||||||
dstR = 255;
|
dstR = 255;
|
||||||
|
}
|
||||||
dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255;
|
dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255;
|
||||||
if (dstG > 255)
|
if (dstG > 255) {
|
||||||
dstG = 255;
|
dstG = 255;
|
||||||
|
}
|
||||||
dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255;
|
dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255;
|
||||||
if (dstB > 255)
|
if (dstB > 255) {
|
||||||
dstB = 255;
|
dstB = 255;
|
||||||
|
}
|
||||||
dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255;
|
dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255;
|
||||||
if (dstA > 255)
|
if (dstA > 255) {
|
||||||
dstA = 255;
|
dstA = 255;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (FORMAT_HAS_ALPHA(dstfmt_val)) {
|
if (FORMAT_HAS_ALPHA(dstfmt_val)) {
|
||||||
|
|
|
@ -36,23 +36,27 @@ __declspec(selectany) int _fltused = 1;
|
||||||
/* The optimizer on Visual Studio 2005 and later generates memcpy() and memset() calls.
|
/* The optimizer on Visual Studio 2005 and later generates memcpy() and memset() calls.
|
||||||
Always provide it for the SDL3 DLL, but skip it when building static lib w/ static runtime. */
|
Always provide it for the SDL3 DLL, but skip it when building static lib w/ static runtime. */
|
||||||
#if (_MSC_VER >= 1400) && (!defined(_MT) || defined(DLL_EXPORT))
|
#if (_MSC_VER >= 1400) && (!defined(_MT) || defined(DLL_EXPORT))
|
||||||
|
/* NOLINTNEXTLINE(readability-redundant-declaration) */
|
||||||
extern void *memcpy(void *dst, const void *src, size_t len);
|
extern void *memcpy(void *dst, const void *src, size_t len);
|
||||||
#pragma intrinsic(memcpy)
|
#pragma intrinsic(memcpy)
|
||||||
|
|
||||||
#if !defined(__clang__)
|
#if !defined(__clang__)
|
||||||
#pragma function(memcpy)
|
#pragma function(memcpy)
|
||||||
#endif
|
#endif
|
||||||
|
/* NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) */
|
||||||
void *memcpy(void *dst, const void *src, size_t len)
|
void *memcpy(void *dst, const void *src, size_t len)
|
||||||
{
|
{
|
||||||
return SDL_memcpy(dst, src, len);
|
return SDL_memcpy(dst, src, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* NOLINTNEXTLINE(readability-redundant-declaration) */
|
||||||
extern void *memset(void *dst, int c, size_t len);
|
extern void *memset(void *dst, int c, size_t len);
|
||||||
#pragma intrinsic(memset)
|
#pragma intrinsic(memset)
|
||||||
|
|
||||||
#if !defined(__clang__)
|
#if !defined(__clang__)
|
||||||
#pragma function(memset)
|
#pragma function(memset)
|
||||||
#endif
|
#endif
|
||||||
|
/* NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) */
|
||||||
void *memset(void *dst, int c, size_t len)
|
void *memset(void *dst, int c, size_t len)
|
||||||
{
|
{
|
||||||
return SDL_memset(dst, c, len);
|
return SDL_memset(dst, c, len);
|
||||||
|
|
|
@ -38,14 +38,15 @@
|
||||||
|
|
||||||
static unsigned UTF8_TrailingBytes(unsigned char c)
|
static unsigned UTF8_TrailingBytes(unsigned char c)
|
||||||
{
|
{
|
||||||
if (c >= 0xC0 && c <= 0xDF)
|
if (c >= 0xC0 && c <= 0xDF) {
|
||||||
return 1;
|
return 1;
|
||||||
else if (c >= 0xE0 && c <= 0xEF)
|
} else if (c >= 0xE0 && c <= 0xEF) {
|
||||||
return 2;
|
return 2;
|
||||||
else if (c >= 0xF0 && c <= 0xF4)
|
} else if (c >= 0xF0 && c <= 0xF4) {
|
||||||
return 3;
|
return 3;
|
||||||
else
|
}
|
||||||
return 0;
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOL) || !defined(HAVE_STRTOUL) || !defined(HAVE_STRTOD)
|
#if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOL) || !defined(HAVE_STRTOUL) || !defined(HAVE_STRTOD)
|
||||||
|
@ -438,7 +439,7 @@ int SDL_wcscmp(const wchar_t *str1, const wchar_t *str2)
|
||||||
++str1;
|
++str1;
|
||||||
++str2;
|
++str2;
|
||||||
}
|
}
|
||||||
return (int)(*str1 - *str2);
|
return *str1 - *str2;
|
||||||
#endif /* HAVE_WCSCMP */
|
#endif /* HAVE_WCSCMP */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,7 +459,7 @@ int SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen)
|
||||||
if (!maxlen) {
|
if (!maxlen) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return (int)(*str1 - *str2);
|
return *str1 - *str2;
|
||||||
|
|
||||||
#endif /* HAVE_WCSNCMP */
|
#endif /* HAVE_WCSNCMP */
|
||||||
}
|
}
|
||||||
|
@ -661,7 +662,7 @@ SDL_strrev(char *string)
|
||||||
char *b = &string[len - 1];
|
char *b = &string[len - 1];
|
||||||
len /= 2;
|
len /= 2;
|
||||||
while (len--) {
|
while (len--) {
|
||||||
char c = *a;
|
char c = *a; /* NOLINT(clang-analyzer-core.uninitialized.Assign) */
|
||||||
*a++ = *b;
|
*a++ = *b;
|
||||||
*b-- = c;
|
*b-- = c;
|
||||||
}
|
}
|
||||||
|
@ -1033,7 +1034,7 @@ int SDL_strcmp(const char *str1, const char *str2)
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
result = (int)((unsigned char)*str1 - (unsigned char)*str2);
|
result = ((unsigned char)*str1 - (unsigned char)*str2);
|
||||||
if (result != 0 || (*str1 == '\0' /* && *str2 == '\0'*/)) {
|
if (result != 0 || (*str1 == '\0' /* && *str2 == '\0'*/)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1133,6 +1134,7 @@ int SDL_vsscanf(const char *text, const char *fmt, va_list ap)
|
||||||
return vsscanf(text, fmt, ap);
|
return vsscanf(text, fmt, ap);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
/* NOLINTNEXTLINE(readability-non-const-parameter) */
|
||||||
int SDL_vsscanf(const char *text, const char *fmt, va_list ap)
|
int SDL_vsscanf(const char *text, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
@ -1673,6 +1675,7 @@ SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg)
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* NOLINTNEXTLINE(readability-non-const-parameter) */
|
||||||
int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap)
|
int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
size_t length = 0;
|
size_t length = 0;
|
||||||
|
|
|
@ -49,7 +49,7 @@ void SDLTest_Assert(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *as
|
||||||
/* Print assert description into a buffer */
|
/* Print assert description into a buffer */
|
||||||
SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
|
SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
|
||||||
va_start(list, assertDescription);
|
va_start(list, assertDescription);
|
||||||
SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
|
(void)SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
|
|
||||||
/* Log, then assert and break on failure */
|
/* Log, then assert and break on failure */
|
||||||
|
@ -67,7 +67,7 @@ int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char
|
||||||
/* Print assert description into a buffer */
|
/* Print assert description into a buffer */
|
||||||
SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
|
SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
|
||||||
va_start(list, assertDescription);
|
va_start(list, assertDescription);
|
||||||
SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
|
(void)SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
|
|
||||||
/* Log pass or fail message */
|
/* Log pass or fail message */
|
||||||
|
@ -93,7 +93,7 @@ void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,
|
||||||
/* Print assert description into a buffer */
|
/* Print assert description into a buffer */
|
||||||
SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
|
SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
|
||||||
va_start(list, assertDescription);
|
va_start(list, assertDescription);
|
||||||
SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
|
(void)SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
|
|
||||||
/* Log pass message */
|
/* Log pass message */
|
||||||
|
|
|
@ -50,7 +50,7 @@ static void SDL_snprintfcat(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
text += length;
|
text += length;
|
||||||
maxlen -= length;
|
maxlen -= length;
|
||||||
SDL_vsnprintf(text, maxlen, fmt, ap);
|
(void)SDL_vsnprintf(text, maxlen, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -953,28 +953,28 @@ static void SDLTest_PrintRenderer(SDL_RendererInfo *info)
|
||||||
|
|
||||||
SDL_Log(" Renderer %s:\n", info->name);
|
SDL_Log(" Renderer %s:\n", info->name);
|
||||||
|
|
||||||
SDL_snprintf(text, sizeof(text), " Flags: 0x%8.8" SDL_PRIX32, info->flags);
|
(void)SDL_snprintf(text, sizeof text, " Flags: 0x%8.8" SDL_PRIX32, info->flags);
|
||||||
SDL_snprintfcat(text, sizeof(text), " (");
|
SDL_snprintfcat(text, sizeof text, " (");
|
||||||
count = 0;
|
count = 0;
|
||||||
for (i = 0; i < sizeof(info->flags) * 8; ++i) {
|
for (i = 0; i < 8 * sizeof info->flags; ++i) {
|
||||||
Uint32 flag = (1 << i);
|
Uint32 flag = (1 << i);
|
||||||
if (info->flags & flag) {
|
if (info->flags & flag) {
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
SDL_snprintfcat(text, sizeof(text), " | ");
|
SDL_snprintfcat(text, sizeof text, " | ");
|
||||||
}
|
}
|
||||||
SDLTest_PrintRendererFlag(text, sizeof(text), flag);
|
SDLTest_PrintRendererFlag(text, sizeof text, flag);
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_snprintfcat(text, sizeof(text), ")");
|
SDL_snprintfcat(text, sizeof text, ")");
|
||||||
SDL_Log("%s\n", text);
|
SDL_Log("%s\n", text);
|
||||||
|
|
||||||
SDL_snprintf(text, sizeof(text), " Texture formats (%" SDL_PRIu32 "): ", info->num_texture_formats);
|
(void)SDL_snprintf(text, sizeof text, " Texture formats (%" SDL_PRIu32 "): ", info->num_texture_formats);
|
||||||
for (i = 0; i < (int)info->num_texture_formats; ++i) {
|
for (i = 0; i < (int)info->num_texture_formats; ++i) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
SDL_snprintfcat(text, sizeof(text), ", ");
|
SDL_snprintfcat(text, sizeof text, ", ");
|
||||||
}
|
}
|
||||||
SDLTest_PrintPixelFormat(text, sizeof(text), info->texture_formats[i]);
|
SDLTest_PrintPixelFormat(text, sizeof text, info->texture_formats[i]);
|
||||||
}
|
}
|
||||||
SDL_Log("%s\n", text);
|
SDL_Log("%s\n", text);
|
||||||
|
|
||||||
|
@ -1061,12 +1061,12 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
SDL_Log("No built-in video drivers\n");
|
SDL_Log("No built-in video drivers\n");
|
||||||
} else {
|
} else {
|
||||||
SDL_snprintf(text, sizeof(text), "Built-in video drivers:");
|
(void)SDL_snprintf(text, sizeof text, "Built-in video drivers:");
|
||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
SDL_snprintfcat(text, sizeof(text), ",");
|
SDL_snprintfcat(text, sizeof text, ",");
|
||||||
}
|
}
|
||||||
SDL_snprintfcat(text, sizeof(text), " %s", SDL_GetVideoDriver(i));
|
SDL_snprintfcat(text, sizeof text, " %s", SDL_GetVideoDriver(i));
|
||||||
}
|
}
|
||||||
SDL_Log("%s\n", text);
|
SDL_Log("%s\n", text);
|
||||||
}
|
}
|
||||||
|
@ -1258,8 +1258,8 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->num_windows > 1) {
|
if (state->num_windows > 1) {
|
||||||
SDL_snprintf(title, SDL_arraysize(title), "%s %d",
|
(void)SDL_snprintf(title, SDL_arraysize(title), "%s %d",
|
||||||
state->window_title, i + 1);
|
state->window_title, i + 1);
|
||||||
} else {
|
} else {
|
||||||
SDL_strlcpy(title, state->window_title, SDL_arraysize(title));
|
SDL_strlcpy(title, state->window_title, SDL_arraysize(title));
|
||||||
}
|
}
|
||||||
|
@ -1356,12 +1356,12 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
SDL_Log("No built-in audio drivers\n");
|
SDL_Log("No built-in audio drivers\n");
|
||||||
} else {
|
} else {
|
||||||
SDL_snprintf(text, sizeof(text), "Built-in audio drivers:");
|
(void)SDL_snprintf(text, sizeof text, "Built-in audio drivers:");
|
||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
SDL_snprintfcat(text, sizeof(text), ",");
|
SDL_snprintfcat(text, sizeof text, ",");
|
||||||
}
|
}
|
||||||
SDL_snprintfcat(text, sizeof(text), " %s", SDL_GetAudioDriver(i));
|
SDL_snprintfcat(text, sizeof text, " %s", SDL_GetAudioDriver(i));
|
||||||
}
|
}
|
||||||
SDL_Log("%s\n", text);
|
SDL_Log("%s\n", text);
|
||||||
}
|
}
|
||||||
|
@ -2153,8 +2153,8 @@ void SDLTest_CommonEvent(SDLTest_CommonState *state, SDL_Event *event, int *done
|
||||||
char message[256];
|
char message[256];
|
||||||
SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
|
SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
|
||||||
|
|
||||||
SDL_snprintf(message, sizeof(message), "(%" SDL_PRIs32 ", %" SDL_PRIs32 "), rel (%" SDL_PRIs32 ", %" SDL_PRIs32 ")\n",
|
(void)SDL_snprintf(message, sizeof message, "(%" SDL_PRIs32 ", %" SDL_PRIs32 "), rel (%" SDL_PRIs32 ", %" SDL_PRIs32 ")\n",
|
||||||
lastEvent.x, lastEvent.y, lastEvent.xrel, lastEvent.yrel);
|
lastEvent.x, lastEvent.y, lastEvent.xrel, lastEvent.yrel);
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Last mouse position", message, window);
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Last mouse position", message, window);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2238,7 +2238,7 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, in
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255);
|
SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255);
|
||||||
|
|
||||||
SDL_snprintf(text, sizeof(text), "SDL_GetCurrentVideoDriver: %s", SDL_GetCurrentVideoDriver());
|
(void)SDL_snprintf(text, sizeof text, "SDL_GetCurrentVideoDriver: %s", SDL_GetCurrentVideoDriver());
|
||||||
SDLTest_DrawString(renderer, 0, textY, text);
|
SDLTest_DrawString(renderer, 0, textY, text);
|
||||||
textY += lineHeight;
|
textY += lineHeight;
|
||||||
|
|
||||||
|
@ -2251,31 +2251,31 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, in
|
||||||
SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255);
|
SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255);
|
||||||
|
|
||||||
if (0 == SDL_GetRendererInfo(renderer, &info)) {
|
if (0 == SDL_GetRendererInfo(renderer, &info)) {
|
||||||
SDL_snprintf(text, sizeof(text), "SDL_GetRendererInfo: name: %s", info.name);
|
(void)SDL_snprintf(text, sizeof text, "SDL_GetRendererInfo: name: %s", info.name);
|
||||||
SDLTest_DrawString(renderer, 0, textY, text);
|
SDLTest_DrawString(renderer, 0, textY, text);
|
||||||
textY += lineHeight;
|
textY += lineHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == SDL_GetRendererOutputSize(renderer, &w, &h)) {
|
if (0 == SDL_GetRendererOutputSize(renderer, &w, &h)) {
|
||||||
SDL_snprintf(text, sizeof(text), "SDL_GetRendererOutputSize: %dx%d", w, h);
|
(void)SDL_snprintf(text, sizeof text, "SDL_GetRendererOutputSize: %dx%d", w, h);
|
||||||
SDLTest_DrawString(renderer, 0, textY, text);
|
SDLTest_DrawString(renderer, 0, textY, text);
|
||||||
textY += lineHeight;
|
textY += lineHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_RenderGetViewport(renderer, &rect);
|
SDL_RenderGetViewport(renderer, &rect);
|
||||||
SDL_snprintf(text, sizeof(text), "SDL_RenderGetViewport: %d,%d, %dx%d",
|
(void)SDL_snprintf(text, sizeof text, "SDL_RenderGetViewport: %d,%d, %dx%d",
|
||||||
rect.x, rect.y, rect.w, rect.h);
|
rect.x, rect.y, rect.w, rect.h);
|
||||||
SDLTest_DrawString(renderer, 0, textY, text);
|
SDLTest_DrawString(renderer, 0, textY, text);
|
||||||
textY += lineHeight;
|
textY += lineHeight;
|
||||||
|
|
||||||
SDL_RenderGetScale(renderer, &scaleX, &scaleY);
|
SDL_RenderGetScale(renderer, &scaleX, &scaleY);
|
||||||
SDL_snprintf(text, sizeof(text), "SDL_RenderGetScale: %f,%f",
|
(void)SDL_snprintf(text, sizeof text, "SDL_RenderGetScale: %f,%f",
|
||||||
scaleX, scaleY);
|
scaleX, scaleY);
|
||||||
SDLTest_DrawString(renderer, 0, textY, text);
|
SDLTest_DrawString(renderer, 0, textY, text);
|
||||||
textY += lineHeight;
|
textY += lineHeight;
|
||||||
|
|
||||||
SDL_RenderGetLogicalSize(renderer, &w, &h);
|
SDL_RenderGetLogicalSize(renderer, &w, &h);
|
||||||
SDL_snprintf(text, sizeof(text), "SDL_RenderGetLogicalSize: %dx%d", w, h);
|
(void)SDL_snprintf(text, sizeof text, "SDL_RenderGetLogicalSize: %dx%d", w, h);
|
||||||
SDLTest_DrawString(renderer, 0, textY, text);
|
SDLTest_DrawString(renderer, 0, textY, text);
|
||||||
textY += lineHeight;
|
textY += lineHeight;
|
||||||
|
|
||||||
|
@ -2288,23 +2288,23 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, in
|
||||||
SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255);
|
SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255);
|
||||||
|
|
||||||
SDL_GetWindowPosition(window, &x, &y);
|
SDL_GetWindowPosition(window, &x, &y);
|
||||||
SDL_snprintf(text, sizeof(text), "SDL_GetWindowPosition: %d,%d", x, y);
|
(void)SDL_snprintf(text, sizeof text, "SDL_GetWindowPosition: %d,%d", x, y);
|
||||||
SDLTest_DrawString(renderer, 0, textY, text);
|
SDLTest_DrawString(renderer, 0, textY, text);
|
||||||
textY += lineHeight;
|
textY += lineHeight;
|
||||||
|
|
||||||
SDL_GetWindowSize(window, &w, &h);
|
SDL_GetWindowSize(window, &w, &h);
|
||||||
SDL_snprintf(text, sizeof(text), "SDL_GetWindowSize: %dx%d", w, h);
|
(void)SDL_snprintf(text, sizeof text, "SDL_GetWindowSize: %dx%d", w, h);
|
||||||
SDLTest_DrawString(renderer, 0, textY, text);
|
SDLTest_DrawString(renderer, 0, textY, text);
|
||||||
textY += lineHeight;
|
textY += lineHeight;
|
||||||
|
|
||||||
SDL_snprintf(text, sizeof(text), "SDL_GetWindowFlags: ");
|
(void)SDL_snprintf(text, sizeof text, "SDL_GetWindowFlags: ");
|
||||||
SDLTest_PrintWindowFlags(text, sizeof(text), SDL_GetWindowFlags(window));
|
SDLTest_PrintWindowFlags(text, sizeof text, SDL_GetWindowFlags(window));
|
||||||
SDLTest_DrawString(renderer, 0, textY, text);
|
SDLTest_DrawString(renderer, 0, textY, text);
|
||||||
textY += lineHeight;
|
textY += lineHeight;
|
||||||
|
|
||||||
if (0 == SDL_GetWindowDisplayMode(window, &mode)) {
|
if (0 == SDL_GetWindowDisplayMode(window, &mode)) {
|
||||||
SDL_snprintf(text, sizeof(text), "SDL_GetWindowDisplayMode: %dx%d@%dHz (%s)",
|
(void)SDL_snprintf(text, sizeof text, "SDL_GetWindowDisplayMode: %dx%d@%dHz (%s)",
|
||||||
mode.w, mode.h, mode.refresh_rate, SDL_GetPixelFormatName(mode.format));
|
mode.w, mode.h, mode.refresh_rate, SDL_GetPixelFormatName(mode.format));
|
||||||
SDLTest_DrawString(renderer, 0, textY, text);
|
SDLTest_DrawString(renderer, 0, textY, text);
|
||||||
textY += lineHeight;
|
textY += lineHeight;
|
||||||
}
|
}
|
||||||
|
@ -2317,44 +2317,44 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, in
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255);
|
SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255);
|
||||||
|
|
||||||
SDL_snprintf(text, sizeof(text), "SDL_GetWindowDisplayIndex: %d", windowDisplayIndex);
|
(void)SDL_snprintf(text, sizeof text, "SDL_GetWindowDisplayIndex: %d", windowDisplayIndex);
|
||||||
SDLTest_DrawString(renderer, 0, textY, text);
|
SDLTest_DrawString(renderer, 0, textY, text);
|
||||||
textY += lineHeight;
|
textY += lineHeight;
|
||||||
|
|
||||||
SDL_snprintf(text, sizeof(text), "SDL_GetDisplayName: %s", SDL_GetDisplayName(windowDisplayIndex));
|
(void)SDL_snprintf(text, sizeof text, "SDL_GetDisplayName: %s", SDL_GetDisplayName(windowDisplayIndex));
|
||||||
SDLTest_DrawString(renderer, 0, textY, text);
|
SDLTest_DrawString(renderer, 0, textY, text);
|
||||||
textY += lineHeight;
|
textY += lineHeight;
|
||||||
|
|
||||||
if (0 == SDL_GetDisplayBounds(windowDisplayIndex, &rect)) {
|
if (0 == SDL_GetDisplayBounds(windowDisplayIndex, &rect)) {
|
||||||
SDL_snprintf(text, sizeof(text), "SDL_GetDisplayBounds: %d,%d, %dx%d",
|
(void)SDL_snprintf(text, sizeof text, "SDL_GetDisplayBounds: %d,%d, %dx%d",
|
||||||
rect.x, rect.y, rect.w, rect.h);
|
rect.x, rect.y, rect.w, rect.h);
|
||||||
SDLTest_DrawString(renderer, 0, textY, text);
|
SDLTest_DrawString(renderer, 0, textY, text);
|
||||||
textY += lineHeight;
|
textY += lineHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == SDL_GetCurrentDisplayMode(windowDisplayIndex, &mode)) {
|
if (0 == SDL_GetCurrentDisplayMode(windowDisplayIndex, &mode)) {
|
||||||
SDL_snprintf(text, sizeof(text), "SDL_GetCurrentDisplayMode: %dx%d@%d",
|
(void)SDL_snprintf(text, sizeof text, "SDL_GetCurrentDisplayMode: %dx%d@%d",
|
||||||
mode.w, mode.h, mode.refresh_rate);
|
mode.w, mode.h, mode.refresh_rate);
|
||||||
SDLTest_DrawString(renderer, 0, textY, text);
|
SDLTest_DrawString(renderer, 0, textY, text);
|
||||||
textY += lineHeight;
|
textY += lineHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == SDL_GetDesktopDisplayMode(windowDisplayIndex, &mode)) {
|
if (0 == SDL_GetDesktopDisplayMode(windowDisplayIndex, &mode)) {
|
||||||
SDL_snprintf(text, sizeof(text), "SDL_GetDesktopDisplayMode: %dx%d@%d",
|
(void)SDL_snprintf(text, sizeof text, "SDL_GetDesktopDisplayMode: %dx%d@%d",
|
||||||
mode.w, mode.h, mode.refresh_rate);
|
mode.w, mode.h, mode.refresh_rate);
|
||||||
SDLTest_DrawString(renderer, 0, textY, text);
|
SDLTest_DrawString(renderer, 0, textY, text);
|
||||||
textY += lineHeight;
|
textY += lineHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == SDL_GetDisplayDPI(windowDisplayIndex, &ddpi, &hdpi, &vdpi)) {
|
if (0 == SDL_GetDisplayDPI(windowDisplayIndex, &ddpi, &hdpi, &vdpi)) {
|
||||||
SDL_snprintf(text, sizeof(text), "SDL_GetDisplayDPI: ddpi: %f, hdpi: %f, vdpi: %f",
|
(void)SDL_snprintf(text, sizeof text, "SDL_GetDisplayDPI: ddpi: %f, hdpi: %f, vdpi: %f",
|
||||||
ddpi, hdpi, vdpi);
|
ddpi, hdpi, vdpi);
|
||||||
SDLTest_DrawString(renderer, 0, textY, text);
|
SDLTest_DrawString(renderer, 0, textY, text);
|
||||||
textY += lineHeight;
|
textY += lineHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_snprintf(text, sizeof(text), "SDL_GetDisplayOrientation: ");
|
(void)SDL_snprintf(text, sizeof text, "SDL_GetDisplayOrientation: ");
|
||||||
SDLTest_PrintDisplayOrientation(text, sizeof(text), SDL_GetDisplayOrientation(windowDisplayIndex));
|
SDLTest_PrintDisplayOrientation(text, sizeof text, SDL_GetDisplayOrientation(windowDisplayIndex));
|
||||||
SDLTest_DrawString(renderer, 0, textY, text);
|
SDLTest_DrawString(renderer, 0, textY, text);
|
||||||
textY += lineHeight;
|
textY += lineHeight;
|
||||||
|
|
||||||
|
@ -2367,14 +2367,14 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, in
|
||||||
SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255);
|
SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255);
|
||||||
|
|
||||||
flags = SDL_GetMouseState(&x, &y);
|
flags = SDL_GetMouseState(&x, &y);
|
||||||
SDL_snprintf(text, sizeof(text), "SDL_GetMouseState: %d,%d ", x, y);
|
(void)SDL_snprintf(text, sizeof text, "SDL_GetMouseState: %d,%d ", x, y);
|
||||||
SDLTest_PrintButtonMask(text, sizeof(text), flags);
|
SDLTest_PrintButtonMask(text, sizeof text, flags);
|
||||||
SDLTest_DrawString(renderer, 0, textY, text);
|
SDLTest_DrawString(renderer, 0, textY, text);
|
||||||
textY += lineHeight;
|
textY += lineHeight;
|
||||||
|
|
||||||
flags = SDL_GetGlobalMouseState(&x, &y);
|
flags = SDL_GetGlobalMouseState(&x, &y);
|
||||||
SDL_snprintf(text, sizeof(text), "SDL_GetGlobalMouseState: %d,%d ", x, y);
|
(void)SDL_snprintf(text, sizeof text, "SDL_GetGlobalMouseState: %d,%d ", x, y);
|
||||||
SDLTest_PrintButtonMask(text, sizeof(text), flags);
|
SDLTest_PrintButtonMask(text, sizeof text, flags);
|
||||||
SDLTest_DrawString(renderer, 0, textY, text);
|
SDLTest_DrawString(renderer, 0, textY, text);
|
||||||
textY += lineHeight;
|
textY += lineHeight;
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
*/
|
*/
|
||||||
#include <SDL3/SDL_test.h>
|
#include <SDL3/SDL_test.h>
|
||||||
|
|
||||||
|
#define FILENAME_SIZE 128
|
||||||
|
|
||||||
/* Counter for _CompareSurface calls; used for filename creation when comparisons fail */
|
/* Counter for _CompareSurface calls; used for filename creation when comparisons fail */
|
||||||
static int _CompareSurfaceCount = 0;
|
static int _CompareSurfaceCount = 0;
|
||||||
|
|
||||||
|
@ -42,8 +44,8 @@ int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface,
|
||||||
int sampleErrorX = 0, sampleErrorY = 0, sampleDist = 0;
|
int sampleErrorX = 0, sampleErrorY = 0, sampleDist = 0;
|
||||||
Uint8 R, G, B, A;
|
Uint8 R, G, B, A;
|
||||||
Uint8 Rd, Gd, Bd, Ad;
|
Uint8 Rd, Gd, Bd, Ad;
|
||||||
char imageFilename[128];
|
char imageFilename[FILENAME_SIZE];
|
||||||
char referenceFilename[128];
|
char referenceFilename[FILENAME_SIZE];
|
||||||
|
|
||||||
/* Validate input surfaces */
|
/* Validate input surfaces */
|
||||||
if (surface == NULL || referenceSurface == NULL) {
|
if (surface == NULL || referenceSurface == NULL) {
|
||||||
|
@ -100,9 +102,9 @@ int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface,
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
SDLTest_LogError("Comparison of pixels with allowable error of %i failed %i times.", allowable_error, ret);
|
SDLTest_LogError("Comparison of pixels with allowable error of %i failed %i times.", allowable_error, ret);
|
||||||
SDLTest_LogError("First detected occurrence at position %i,%i with a squared RGB-difference of %i.", sampleErrorX, sampleErrorY, sampleDist);
|
SDLTest_LogError("First detected occurrence at position %i,%i with a squared RGB-difference of %i.", sampleErrorX, sampleErrorY, sampleDist);
|
||||||
SDL_snprintf(imageFilename, 127, "CompareSurfaces%04d_TestOutput.bmp", _CompareSurfaceCount);
|
(void)SDL_snprintf(imageFilename, FILENAME_SIZE - 1, "CompareSurfaces%04d_TestOutput.bmp", _CompareSurfaceCount);
|
||||||
SDL_SaveBMP(surface, imageFilename);
|
SDL_SaveBMP(surface, imageFilename);
|
||||||
SDL_snprintf(referenceFilename, 127, "CompareSurfaces%04d_Reference.bmp", _CompareSurfaceCount);
|
(void)SDL_snprintf(referenceFilename, FILENAME_SIZE - 1, "CompareSurfaces%04d_Reference.bmp", _CompareSurfaceCount);
|
||||||
SDL_SaveBMP(referenceSurface, referenceFilename);
|
SDL_SaveBMP(referenceSurface, referenceFilename);
|
||||||
SDLTest_LogError("Surfaces from failed comparison saved as '%s' and '%s'", imageFilename, referenceFilename);
|
SDLTest_LogError("Surfaces from failed comparison saved as '%s' and '%s'", imageFilename, referenceFilename);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3389,7 +3389,7 @@ void SDLTest_TextWindowAddText(SDLTest_TextWindow *textwin, const char *fmt, ...
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
SDL_vsnprintf(text, sizeof(text), fmt, ap);
|
(void)SDL_vsnprintf(text, sizeof text, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
SDLTest_TextWindowAddTextWithLength(textwin, text, SDL_strlen(text));
|
SDLTest_TextWindowAddTextWithLength(textwin, text, SDL_strlen(text));
|
||||||
|
|
|
@ -124,8 +124,8 @@ static Uint64 SDLTest_GenerateExecKey(const char *runSeed, const char *suiteName
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert iteration number into a string */
|
/* Convert iteration number into a string */
|
||||||
SDL_memset(iterationString, 0, sizeof(iterationString));
|
SDL_memset(iterationString, 0, sizeof iterationString);
|
||||||
SDL_snprintf(iterationString, sizeof(iterationString) - 1, "%d", iteration);
|
(void)SDL_snprintf(iterationString, sizeof iterationString - 1, "%d", iteration);
|
||||||
|
|
||||||
/* Combine the parameters into single string */
|
/* Combine the parameters into single string */
|
||||||
runSeedLength = SDL_strlen(runSeed);
|
runSeedLength = SDL_strlen(runSeed);
|
||||||
|
@ -139,7 +139,7 @@ static Uint64 SDLTest_GenerateExecKey(const char *runSeed, const char *suiteName
|
||||||
SDL_Error(SDL_ENOMEM);
|
SDL_Error(SDL_ENOMEM);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
SDL_snprintf(buffer, entireStringLength, "%s%s%s%d", runSeed, suiteName, testName, iteration);
|
(void)SDL_snprintf(buffer, entireStringLength, "%s%s%s%d", runSeed, suiteName, testName, iteration);
|
||||||
|
|
||||||
/* Hash string and use half of the digest as 64bit exec key */
|
/* Hash string and use half of the digest as 64bit exec key */
|
||||||
SDLTest_Md5Init(&md5Context);
|
SDLTest_Md5Init(&md5Context);
|
||||||
|
|
|
@ -57,16 +57,21 @@ strftime_gcc2_workaround(char *s, size_t max, const char *fmt, const struct tm *
|
||||||
*
|
*
|
||||||
* \return Ascii representation of the timestamp in localtime in the format '08/23/01 14:55:02'
|
* \return Ascii representation of the timestamp in localtime in the format '08/23/01 14:55:02'
|
||||||
*/
|
*/
|
||||||
static char *SDLTest_TimestampToString(const time_t timestamp)
|
static const char *
|
||||||
|
SDLTest_TimestampToString(const time_t timestamp)
|
||||||
{
|
{
|
||||||
time_t copy;
|
time_t copy;
|
||||||
static char buffer[64];
|
static char buffer[64];
|
||||||
struct tm *local;
|
struct tm *local;
|
||||||
|
size_t result = 0;
|
||||||
|
|
||||||
SDL_memset(buffer, 0, sizeof(buffer));
|
SDL_memset(buffer, 0, sizeof(buffer));
|
||||||
copy = timestamp;
|
copy = timestamp;
|
||||||
local = localtime(©);
|
local = localtime(©);
|
||||||
strftime(buffer, sizeof(buffer), "%x %X", local);
|
result = strftime(buffer, sizeof buffer, "%x %X", local);
|
||||||
|
if (result == 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +87,7 @@ void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||||
/* Print log message into a buffer */
|
/* Print log message into a buffer */
|
||||||
SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
|
SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
|
||||||
va_start(list, fmt);
|
va_start(list, fmt);
|
||||||
SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, fmt, list);
|
(void)SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, fmt, list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
|
|
||||||
/* Log with timestamp and newline */
|
/* Log with timestamp and newline */
|
||||||
|
@ -100,7 +105,7 @@ void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||||
/* Print log message into a buffer */
|
/* Print log message into a buffer */
|
||||||
SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
|
SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
|
||||||
va_start(list, fmt);
|
va_start(list, fmt);
|
||||||
SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, fmt, list);
|
(void)SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, fmt, list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
|
|
||||||
/* Log with timestamp and newline */
|
/* Log with timestamp and newline */
|
||||||
|
|
|
@ -237,30 +237,30 @@ void SDLTest_LogAllocations()
|
||||||
message = tmp; \
|
message = tmp; \
|
||||||
SDL_strlcat(message, line, message_size)
|
SDL_strlcat(message, line, message_size)
|
||||||
|
|
||||||
SDL_strlcpy(line, "Memory allocations:\n", sizeof(line));
|
SDL_strlcpy(line, "Memory allocations:\n", sizeof line);
|
||||||
ADD_LINE();
|
ADD_LINE();
|
||||||
SDL_strlcpy(line, "Expect 2 allocations from within SDL_GetErrBuf()\n", sizeof(line));
|
SDL_strlcpy(line, "Expect 2 allocations from within SDL_GetErrBuf()\n", sizeof line);
|
||||||
ADD_LINE();
|
ADD_LINE();
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
total_allocated = 0;
|
total_allocated = 0;
|
||||||
for (index = 0; index < SDL_arraysize(s_tracked_allocations); ++index) {
|
for (index = 0; index < SDL_arraysize(s_tracked_allocations); ++index) {
|
||||||
for (entry = s_tracked_allocations[index]; entry; entry = entry->next) {
|
for (entry = s_tracked_allocations[index]; entry; entry = entry->next) {
|
||||||
SDL_snprintf(line, sizeof(line), "Allocation %d: %d bytes\n", count, (int)entry->size);
|
(void)SDL_snprintf(line, sizeof line, "Allocation %d: %d bytes\n", count, (int)entry->size);
|
||||||
ADD_LINE();
|
ADD_LINE();
|
||||||
/* Start at stack index 1 to skip our tracking functions */
|
/* Start at stack index 1 to skip our tracking functions */
|
||||||
for (stack_index = 1; stack_index < SDL_arraysize(entry->stack); ++stack_index) {
|
for (stack_index = 1; stack_index < SDL_arraysize(entry->stack); ++stack_index) {
|
||||||
if (!entry->stack[stack_index]) {
|
if (!entry->stack[stack_index]) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SDL_snprintf(line, sizeof(line), "\t0x%" SDL_PRIx64 ": %s\n", entry->stack[stack_index], entry->stack_names[stack_index]);
|
(void)SDL_snprintf(line, sizeof line, "\t0x%" SDL_PRIx64 ": %s\n", entry->stack[stack_index], entry->stack_names[stack_index]);
|
||||||
ADD_LINE();
|
ADD_LINE();
|
||||||
}
|
}
|
||||||
total_allocated += entry->size;
|
total_allocated += entry->size;
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_snprintf(line, sizeof(line), "Total: %.2f Kb in %d allocations\n", (float)total_allocated / 1024, count);
|
(void)SDL_snprintf(line, sizeof line, "Total: %.2f Kb in %d allocations\n", total_allocated / 1024.0, count);
|
||||||
ADD_LINE();
|
ADD_LINE();
|
||||||
#undef ADD_LINE
|
#undef ADD_LINE
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ SDL_Generic_GetTLSData(void)
|
||||||
return storage;
|
return storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_Generic_SetTLSData(SDL_TLSData *storage)
|
int SDL_Generic_SetTLSData(SDL_TLSData *data)
|
||||||
{
|
{
|
||||||
SDL_threadID thread = SDL_ThreadID();
|
SDL_threadID thread = SDL_ThreadID();
|
||||||
SDL_TLSEntry *prev, *entry;
|
SDL_TLSEntry *prev, *entry;
|
||||||
|
@ -162,10 +162,10 @@ int SDL_Generic_SetTLSData(SDL_TLSData *storage)
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
for (entry = SDL_generic_TLS; entry; entry = entry->next) {
|
for (entry = SDL_generic_TLS; entry; entry = entry->next) {
|
||||||
if (entry->thread == thread) {
|
if (entry->thread == thread) {
|
||||||
if (storage) {
|
if (data != NULL) {
|
||||||
entry->storage = storage;
|
entry->storage = data;
|
||||||
} else {
|
} else {
|
||||||
if (prev) {
|
if (prev != NULL) {
|
||||||
prev->next = entry->next;
|
prev->next = entry->next;
|
||||||
} else {
|
} else {
|
||||||
SDL_generic_TLS = entry->next;
|
SDL_generic_TLS = entry->next;
|
||||||
|
@ -180,7 +180,7 @@ int SDL_Generic_SetTLSData(SDL_TLSData *storage)
|
||||||
entry = (SDL_TLSEntry *)SDL_malloc(sizeof(*entry));
|
entry = (SDL_TLSEntry *)SDL_malloc(sizeof(*entry));
|
||||||
if (entry) {
|
if (entry) {
|
||||||
entry->thread = thread;
|
entry->thread = thread;
|
||||||
entry->storage = storage;
|
entry->storage = data;
|
||||||
entry->next = SDL_generic_TLS;
|
entry->next = SDL_generic_TLS;
|
||||||
SDL_generic_TLS = entry;
|
SDL_generic_TLS = entry;
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms)
|
||||||
gettimeofday(&delta, NULL);
|
gettimeofday(&delta, NULL);
|
||||||
|
|
||||||
abstime.tv_sec = delta.tv_sec + (ms / 1000);
|
abstime.tv_sec = delta.tv_sec + (ms / 1000);
|
||||||
abstime.tv_nsec = (delta.tv_usec + (ms % 1000) * 1000) * 1000;
|
abstime.tv_nsec = (long)(delta.tv_usec + (ms % 1000) * 1000) * 1000;
|
||||||
#endif
|
#endif
|
||||||
if (abstime.tv_nsec > 1000000000) {
|
if (abstime.tv_nsec > 1000000000) {
|
||||||
abstime.tv_sec += 1;
|
abstime.tv_sec += 1;
|
||||||
|
|
|
@ -704,10 +704,11 @@ static void RLEAlphaClipBlit(int w, Uint8 *srcbuf, SDL_Surface *surf_dst,
|
||||||
|
|
||||||
switch (df->BytesPerPixel) {
|
switch (df->BytesPerPixel) {
|
||||||
case 2:
|
case 2:
|
||||||
if (df->Gmask == 0x07e0 || df->Rmask == 0x07e0 || df->Bmask == 0x07e0)
|
if (df->Gmask == 0x07e0 || df->Rmask == 0x07e0 || df->Bmask == 0x07e0) {
|
||||||
RLEALPHACLIPBLIT(Uint16, Uint8, BLIT_TRANSL_565);
|
RLEALPHACLIPBLIT(Uint16, Uint8, BLIT_TRANSL_565);
|
||||||
else
|
} else {
|
||||||
RLEALPHACLIPBLIT(Uint16, Uint8, BLIT_TRANSL_555);
|
RLEALPHACLIPBLIT(Uint16, Uint8, BLIT_TRANSL_555);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
RLEALPHACLIPBLIT(Uint32, Uint16, BLIT_TRANSL_888);
|
RLEALPHACLIPBLIT(Uint32, Uint16, BLIT_TRANSL_888);
|
||||||
|
@ -754,8 +755,9 @@ static int SDLCALL SDL_RLEAlphaBlit(SDL_Surface *surf_src, SDL_Rect *srcrect,
|
||||||
if (run) {
|
if (run) {
|
||||||
srcbuf += 2 * run;
|
srcbuf += 2 * run;
|
||||||
ofs += run;
|
ofs += run;
|
||||||
} else if (!ofs)
|
} else if (ofs == 0) {
|
||||||
goto done;
|
goto done;
|
||||||
|
}
|
||||||
} while (ofs < w);
|
} while (ofs < w);
|
||||||
|
|
||||||
/* skip padding */
|
/* skip padding */
|
||||||
|
@ -784,8 +786,9 @@ static int SDLCALL SDL_RLEAlphaBlit(SDL_Surface *surf_src, SDL_Rect *srcrect,
|
||||||
if (run) {
|
if (run) {
|
||||||
srcbuf += 4 * run;
|
srcbuf += 4 * run;
|
||||||
ofs += run;
|
ofs += run;
|
||||||
} else if (!ofs)
|
} else if (ofs == 0) {
|
||||||
goto done;
|
goto done;
|
||||||
|
}
|
||||||
} while (ofs < w);
|
} while (ofs < w);
|
||||||
} while (--vskip);
|
} while (--vskip);
|
||||||
}
|
}
|
||||||
|
@ -849,10 +852,11 @@ static int SDLCALL SDL_RLEAlphaBlit(SDL_Surface *surf_src, SDL_Rect *srcrect,
|
||||||
|
|
||||||
switch (df->BytesPerPixel) {
|
switch (df->BytesPerPixel) {
|
||||||
case 2:
|
case 2:
|
||||||
if (df->Gmask == 0x07e0 || df->Rmask == 0x07e0 || df->Bmask == 0x07e0)
|
if (df->Gmask == 0x07e0 || df->Rmask == 0x07e0 || df->Bmask == 0x07e0) {
|
||||||
RLEALPHABLIT(Uint16, Uint8, BLIT_TRANSL_565);
|
RLEALPHABLIT(Uint16, Uint8, BLIT_TRANSL_565);
|
||||||
else
|
} else {
|
||||||
RLEALPHABLIT(Uint16, Uint8, BLIT_TRANSL_555);
|
RLEALPHABLIT(Uint16, Uint8, BLIT_TRANSL_555);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
RLEALPHABLIT(Uint32, Uint16, BLIT_TRANSL_888);
|
RLEALPHABLIT(Uint32, Uint16, BLIT_TRANSL_888);
|
||||||
|
@ -1038,15 +1042,17 @@ static int RLEAlphaSurface(SDL_Surface *surface)
|
||||||
if (df->Gmask == 0x07e0 || df->Rmask == 0x07e0 || df->Bmask == 0x07e0) {
|
if (df->Gmask == 0x07e0 || df->Rmask == 0x07e0 || df->Bmask == 0x07e0) {
|
||||||
copy_opaque = copy_opaque_16;
|
copy_opaque = copy_opaque_16;
|
||||||
copy_transl = copy_transl_565;
|
copy_transl = copy_transl_565;
|
||||||
} else
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 0x7fff:
|
case 0x7fff:
|
||||||
if (df->Gmask == 0x03e0 || df->Rmask == 0x03e0 || df->Bmask == 0x03e0) {
|
if (df->Gmask == 0x03e0 || df->Rmask == 0x03e0 || df->Bmask == 0x03e0) {
|
||||||
copy_opaque = copy_opaque_16;
|
copy_opaque = copy_opaque_16;
|
||||||
copy_transl = copy_transl_555;
|
copy_transl = copy_transl_555;
|
||||||
} else
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1058,8 +1064,9 @@ static int RLEAlphaSurface(SDL_Surface *surface)
|
||||||
maxsize = surface->h * (2 + (4 + 2) * (surface->w + 1)) + 2;
|
maxsize = surface->h * (2 + (4 + 2) * (surface->w + 1)) + 2;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if (masksum != 0x00ffffff)
|
if (masksum != 0x00ffffff) {
|
||||||
return -1; /* requires unused high byte */
|
return -1; /* requires unused high byte */
|
||||||
|
}
|
||||||
copy_opaque = copy_32;
|
copy_opaque = copy_32;
|
||||||
copy_transl = copy_32;
|
copy_transl = copy_32;
|
||||||
max_opaque_run = 255; /* runs stored as short ints */
|
max_opaque_run = 255; /* runs stored as short ints */
|
||||||
|
@ -1127,11 +1134,13 @@ static int RLEAlphaSurface(SDL_Surface *surface)
|
||||||
do {
|
do {
|
||||||
int run, skip, len;
|
int run, skip, len;
|
||||||
skipstart = x;
|
skipstart = x;
|
||||||
while (x < w && !ISOPAQUE(src[x], sf))
|
while (x < w && !ISOPAQUE(src[x], sf)) {
|
||||||
x++;
|
x++;
|
||||||
|
}
|
||||||
runstart = x;
|
runstart = x;
|
||||||
while (x < w && ISOPAQUE(src[x], sf))
|
while (x < w && ISOPAQUE(src[x], sf)) {
|
||||||
x++;
|
x++;
|
||||||
|
}
|
||||||
skip = runstart - skipstart;
|
skip = runstart - skipstart;
|
||||||
if (skip == w) {
|
if (skip == w) {
|
||||||
blankline = 1;
|
blankline = 1;
|
||||||
|
@ -1163,11 +1172,13 @@ static int RLEAlphaSurface(SDL_Surface *surface)
|
||||||
do {
|
do {
|
||||||
int run, skip, len;
|
int run, skip, len;
|
||||||
skipstart = x;
|
skipstart = x;
|
||||||
while (x < w && !ISTRANSL(src[x], sf))
|
while (x < w && !ISTRANSL(src[x], sf)) {
|
||||||
x++;
|
x++;
|
||||||
|
}
|
||||||
runstart = x;
|
runstart = x;
|
||||||
while (x < w && ISTRANSL(src[x], sf))
|
while (x < w && ISTRANSL(src[x], sf)) {
|
||||||
x++;
|
x++;
|
||||||
|
}
|
||||||
skip = runstart - skipstart;
|
skip = runstart - skipstart;
|
||||||
blankline &= (skip == w);
|
blankline &= (skip == w);
|
||||||
run = x - runstart;
|
run = x - runstart;
|
||||||
|
@ -1318,16 +1329,19 @@ static int RLEColorkeySurface(SDL_Surface *surface)
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int blankline = 0;
|
int blankline = 0;
|
||||||
do {
|
do {
|
||||||
int run, skip, len;
|
int run, skip;
|
||||||
|
int len;
|
||||||
int runstart;
|
int runstart;
|
||||||
int skipstart = x;
|
int skipstart = x;
|
||||||
|
|
||||||
/* find run of transparent, then opaque pixels */
|
/* find run of transparent, then opaque pixels */
|
||||||
while (x < w && (getpix(srcbuf + x * bpp) & rgbmask) == ckey)
|
while (x < w && (getpix(srcbuf + x * bpp) & rgbmask) == ckey) {
|
||||||
x++;
|
x++;
|
||||||
|
}
|
||||||
runstart = x;
|
runstart = x;
|
||||||
while (x < w && (getpix(srcbuf + x * bpp) & rgbmask) != ckey)
|
while (x < w && (getpix(srcbuf + x * bpp) & rgbmask) != ckey) {
|
||||||
x++;
|
x++;
|
||||||
|
}
|
||||||
skip = runstart - skipstart;
|
skip = runstart - skipstart;
|
||||||
if (skip == w) {
|
if (skip == w) {
|
||||||
blankline = 1;
|
blankline = 1;
|
||||||
|
@ -1341,14 +1355,14 @@ static int RLEColorkeySurface(SDL_Surface *surface)
|
||||||
}
|
}
|
||||||
len = SDL_min(run, maxn);
|
len = SDL_min(run, maxn);
|
||||||
ADD_COUNTS(skip, len);
|
ADD_COUNTS(skip, len);
|
||||||
SDL_memcpy(dst, srcbuf + runstart * bpp, len * bpp);
|
SDL_memcpy(dst, srcbuf + runstart * bpp, (size_t)len * bpp);
|
||||||
dst += len * bpp;
|
dst += len * bpp;
|
||||||
run -= len;
|
run -= len;
|
||||||
runstart += len;
|
runstart += len;
|
||||||
while (run) {
|
while (run) {
|
||||||
len = SDL_min(run, maxn);
|
len = SDL_min(run, maxn);
|
||||||
ADD_COUNTS(0, len);
|
ADD_COUNTS(0, len);
|
||||||
SDL_memcpy(dst, srcbuf + runstart * bpp, len * bpp);
|
SDL_memcpy(dst, srcbuf + runstart * bpp, (size_t)len * bpp);
|
||||||
dst += len * bpp;
|
dst += len * bpp;
|
||||||
runstart += len;
|
runstart += len;
|
||||||
run -= len;
|
run -= len;
|
||||||
|
@ -1476,13 +1490,13 @@ static SDL_bool UnRLEAlpha(SDL_Surface *surface)
|
||||||
uncopy_opaque = uncopy_transl = uncopy_32;
|
uncopy_opaque = uncopy_transl = uncopy_32;
|
||||||
}
|
}
|
||||||
|
|
||||||
surface->pixels = SDL_SIMDAlloc(surface->h * surface->pitch);
|
surface->pixels = SDL_SIMDAlloc((size_t)surface->h * surface->pitch);
|
||||||
if (!surface->pixels) {
|
if (surface->pixels == NULL) {
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
surface->flags |= SDL_SIMD_ALIGNED;
|
surface->flags |= SDL_SIMD_ALIGNED;
|
||||||
/* fill background with transparent pixels */
|
/* fill background with transparent pixels */
|
||||||
SDL_memset(surface->pixels, 0, surface->h * surface->pitch);
|
SDL_memset(surface->pixels, 0, (size_t)surface->h * surface->pitch);
|
||||||
|
|
||||||
dst = surface->pixels;
|
dst = surface->pixels;
|
||||||
srcbuf = (Uint8 *)(df + 1);
|
srcbuf = (Uint8 *)(df + 1);
|
||||||
|
@ -1542,8 +1556,8 @@ void SDL_UnRLESurface(SDL_Surface *surface, int recode)
|
||||||
SDL_Rect full;
|
SDL_Rect full;
|
||||||
|
|
||||||
/* re-create the original surface */
|
/* re-create the original surface */
|
||||||
surface->pixels = SDL_SIMDAlloc(surface->h * surface->pitch);
|
surface->pixels = SDL_SIMDAlloc((size_t)surface->h * surface->pitch);
|
||||||
if (!surface->pixels) {
|
if (surface->pixels == NULL) {
|
||||||
/* Oh crap... */
|
/* Oh crap... */
|
||||||
surface->flags |= SDL_RLEACCEL;
|
surface->flags |= SDL_RLEACCEL;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -136,7 +136,7 @@ static SDL_BlitFunc SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int
|
||||||
|
|
||||||
/* Allow an override for testing .. */
|
/* Allow an override for testing .. */
|
||||||
if (override) {
|
if (override) {
|
||||||
SDL_sscanf(override, "%u", &features);
|
(void)SDL_sscanf(override, "%u", &features);
|
||||||
} else {
|
} else {
|
||||||
if (SDL_HasMMX()) {
|
if (SDL_HasMMX()) {
|
||||||
features |= SDL_CPU_MMX;
|
features |= SDL_CPU_MMX;
|
||||||
|
|
|
@ -1456,18 +1456,22 @@ SDL_CalculateBlitA(SDL_Surface *surface)
|
||||||
if (surface->map->identity) {
|
if (surface->map->identity) {
|
||||||
if (df->Gmask == 0x7e0) {
|
if (df->Gmask == 0x7e0) {
|
||||||
#ifdef __MMX__
|
#ifdef __MMX__
|
||||||
if (SDL_HasMMX())
|
if (SDL_HasMMX()) {
|
||||||
return Blit565to565SurfaceAlphaMMX;
|
return Blit565to565SurfaceAlphaMMX;
|
||||||
else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
return Blit565to565SurfaceAlpha;
|
return Blit565to565SurfaceAlpha;
|
||||||
|
}
|
||||||
} else if (df->Gmask == 0x3e0) {
|
} else if (df->Gmask == 0x3e0) {
|
||||||
#ifdef __MMX__
|
#ifdef __MMX__
|
||||||
if (SDL_HasMMX())
|
if (SDL_HasMMX()) {
|
||||||
return Blit555to555SurfaceAlphaMMX;
|
return Blit555to555SurfaceAlphaMMX;
|
||||||
else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
return Blit555to555SurfaceAlpha;
|
return Blit555to555SurfaceAlpha;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return BlitNtoNSurfaceAlpha;
|
return BlitNtoNSurfaceAlpha;
|
||||||
|
|
|
@ -3415,11 +3415,11 @@ SDL_CalculateBlitN(SDL_Surface *surface)
|
||||||
because RLE is the preferred fast way to deal with this.
|
because RLE is the preferred fast way to deal with this.
|
||||||
If a particular case turns out to be useful we'll add it. */
|
If a particular case turns out to be useful we'll add it. */
|
||||||
|
|
||||||
if (srcfmt->BytesPerPixel == 2 && surface->map->identity)
|
if (srcfmt->BytesPerPixel == 2 && surface->map->identity != 0) {
|
||||||
return Blit2to2Key;
|
return Blit2to2Key;
|
||||||
else if (dstfmt->BytesPerPixel == 1)
|
} else if (dstfmt->BytesPerPixel == 1) {
|
||||||
return BlitNto1Key;
|
return BlitNto1Key;
|
||||||
else {
|
} else {
|
||||||
#if SDL_ALTIVEC_BLITTERS
|
#if SDL_ALTIVEC_BLITTERS
|
||||||
if ((srcfmt->BytesPerPixel == 4) && (dstfmt->BytesPerPixel == 4) && SDL_HasAltiVec()) {
|
if ((srcfmt->BytesPerPixel == 4) && (dstfmt->BytesPerPixel == 4) && SDL_HasAltiVec()) {
|
||||||
return Blit32to32KeyAltivec;
|
return Blit32to32KeyAltivec;
|
||||||
|
|
|
@ -622,11 +622,11 @@ done:
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_SaveBMP_RW(SDL_Surface *saveme, SDL_RWops *dst, int freedst)
|
int SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst)
|
||||||
{
|
{
|
||||||
Sint64 fp_offset;
|
Sint64 fp_offset;
|
||||||
int i, pad;
|
int i, pad;
|
||||||
SDL_Surface *surface;
|
SDL_Surface *intermediate_surface;
|
||||||
Uint8 *bits;
|
Uint8 *bits;
|
||||||
SDL_bool save32bit = SDL_FALSE;
|
SDL_bool save32bit = SDL_FALSE;
|
||||||
SDL_bool saveLegacyBMP = SDL_FALSE;
|
SDL_bool saveLegacyBMP = SDL_FALSE;
|
||||||
|
@ -663,35 +663,36 @@ int SDL_SaveBMP_RW(SDL_Surface *saveme, SDL_RWops *dst, int freedst)
|
||||||
Uint32 bV4GammaBlue = 0;
|
Uint32 bV4GammaBlue = 0;
|
||||||
|
|
||||||
/* Make sure we have somewhere to save */
|
/* Make sure we have somewhere to save */
|
||||||
surface = NULL;
|
intermediate_surface = NULL;
|
||||||
if (dst) {
|
if (dst) {
|
||||||
#ifdef SAVE_32BIT_BMP
|
#ifdef SAVE_32BIT_BMP
|
||||||
/* We can save alpha information in a 32-bit BMP */
|
/* We can save alpha information in a 32-bit BMP */
|
||||||
if (saveme->format->BitsPerPixel >= 8 && (saveme->format->Amask ||
|
if (surface->format->BitsPerPixel >= 8 &&
|
||||||
saveme->map->info.flags & SDL_COPY_COLORKEY)) {
|
(surface->format->Amask != 0 ||
|
||||||
|
surface->map->info.flags & SDL_COPY_COLORKEY)) {
|
||||||
save32bit = SDL_TRUE;
|
save32bit = SDL_TRUE;
|
||||||
}
|
}
|
||||||
#endif /* SAVE_32BIT_BMP */
|
#endif /* SAVE_32BIT_BMP */
|
||||||
|
|
||||||
if (saveme->format->palette && !save32bit) {
|
if (surface->format->palette != NULL && !save32bit) {
|
||||||
if (saveme->format->BitsPerPixel == 8) {
|
if (surface->format->BitsPerPixel == 8) {
|
||||||
surface = saveme;
|
intermediate_surface = surface;
|
||||||
} else {
|
} else {
|
||||||
SDL_SetError("%d bpp BMP files not supported",
|
SDL_SetError("%d bpp BMP files not supported",
|
||||||
saveme->format->BitsPerPixel);
|
surface->format->BitsPerPixel);
|
||||||
}
|
}
|
||||||
} else if ((saveme->format->BitsPerPixel == 24) && !save32bit &&
|
} else if ((surface->format->BitsPerPixel == 24) && !save32bit &&
|
||||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||||
(saveme->format->Rmask == 0x00FF0000) &&
|
(surface->format->Rmask == 0x00FF0000) &&
|
||||||
(saveme->format->Gmask == 0x0000FF00) &&
|
(surface->format->Gmask == 0x0000FF00) &&
|
||||||
(saveme->format->Bmask == 0x000000FF)
|
(surface->format->Bmask == 0x000000FF)
|
||||||
#else
|
#else
|
||||||
(saveme->format->Rmask == 0x000000FF) &&
|
(surface->format->Rmask == 0x000000FF) &&
|
||||||
(saveme->format->Gmask == 0x0000FF00) &&
|
(surface->format->Gmask == 0x0000FF00) &&
|
||||||
(saveme->format->Bmask == 0x00FF0000)
|
(surface->format->Bmask == 0x00FF0000)
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
surface = saveme;
|
intermediate_surface = surface;
|
||||||
} else {
|
} else {
|
||||||
SDL_PixelFormat format;
|
SDL_PixelFormat format;
|
||||||
|
|
||||||
|
@ -702,8 +703,8 @@ int SDL_SaveBMP_RW(SDL_Surface *saveme, SDL_RWops *dst, int freedst)
|
||||||
} else {
|
} else {
|
||||||
SDL_InitFormat(&format, SDL_PIXELFORMAT_BGR24);
|
SDL_InitFormat(&format, SDL_PIXELFORMAT_BGR24);
|
||||||
}
|
}
|
||||||
surface = SDL_ConvertSurface(saveme, &format);
|
intermediate_surface = SDL_ConvertSurface(surface, &format);
|
||||||
if (surface == NULL) {
|
if (intermediate_surface == NULL) {
|
||||||
SDL_SetError("Couldn't convert image to %d bpp",
|
SDL_SetError("Couldn't convert image to %d bpp",
|
||||||
format.BitsPerPixel);
|
format.BitsPerPixel);
|
||||||
}
|
}
|
||||||
|
@ -718,8 +719,8 @@ int SDL_SaveBMP_RW(SDL_Surface *saveme, SDL_RWops *dst, int freedst)
|
||||||
saveLegacyBMP = SDL_GetHintBoolean(SDL_HINT_BMP_SAVE_LEGACY_FORMAT, SDL_FALSE);
|
saveLegacyBMP = SDL_GetHintBoolean(SDL_HINT_BMP_SAVE_LEGACY_FORMAT, SDL_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (surface && (SDL_LockSurface(surface) == 0)) {
|
if (intermediate_surface && (SDL_LockSurface(intermediate_surface) == 0)) {
|
||||||
const int bw = surface->w * surface->format->BytesPerPixel;
|
const int bw = intermediate_surface->w * intermediate_surface->format->BytesPerPixel;
|
||||||
|
|
||||||
/* Set the BMP file header values */
|
/* Set the BMP file header values */
|
||||||
bfSize = 0; /* We'll write this when we're done */
|
bfSize = 0; /* We'll write this when we're done */
|
||||||
|
@ -738,16 +739,16 @@ int SDL_SaveBMP_RW(SDL_Surface *saveme, SDL_RWops *dst, int freedst)
|
||||||
|
|
||||||
/* Set the BMP info values */
|
/* Set the BMP info values */
|
||||||
biSize = 40;
|
biSize = 40;
|
||||||
biWidth = surface->w;
|
biWidth = intermediate_surface->w;
|
||||||
biHeight = surface->h;
|
biHeight = intermediate_surface->h;
|
||||||
biPlanes = 1;
|
biPlanes = 1;
|
||||||
biBitCount = surface->format->BitsPerPixel;
|
biBitCount = intermediate_surface->format->BitsPerPixel;
|
||||||
biCompression = BI_RGB;
|
biCompression = BI_RGB;
|
||||||
biSizeImage = surface->h * surface->pitch;
|
biSizeImage = intermediate_surface->h * intermediate_surface->pitch;
|
||||||
biXPelsPerMeter = 0;
|
biXPelsPerMeter = 0;
|
||||||
biYPelsPerMeter = 0;
|
biYPelsPerMeter = 0;
|
||||||
if (surface->format->palette) {
|
if (intermediate_surface->format->palette) {
|
||||||
biClrUsed = surface->format->palette->ncolors;
|
biClrUsed = intermediate_surface->format->palette->ncolors;
|
||||||
} else {
|
} else {
|
||||||
biClrUsed = 0;
|
biClrUsed = 0;
|
||||||
}
|
}
|
||||||
|
@ -797,12 +798,12 @@ int SDL_SaveBMP_RW(SDL_Surface *saveme, SDL_RWops *dst, int freedst)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write the palette (in BGR color order) */
|
/* Write the palette (in BGR color order) */
|
||||||
if (surface->format->palette) {
|
if (intermediate_surface->format->palette) {
|
||||||
SDL_Color *colors;
|
SDL_Color *colors;
|
||||||
int ncolors;
|
int ncolors;
|
||||||
|
|
||||||
colors = surface->format->palette->colors;
|
colors = intermediate_surface->format->palette->colors;
|
||||||
ncolors = surface->format->palette->ncolors;
|
ncolors = intermediate_surface->format->palette->ncolors;
|
||||||
for (i = 0; i < ncolors; ++i) {
|
for (i = 0; i < ncolors; ++i) {
|
||||||
SDL_RWwrite(dst, &colors[i].b, 1, 1);
|
SDL_RWwrite(dst, &colors[i].b, 1, 1);
|
||||||
SDL_RWwrite(dst, &colors[i].g, 1, 1);
|
SDL_RWwrite(dst, &colors[i].g, 1, 1);
|
||||||
|
@ -822,10 +823,10 @@ int SDL_SaveBMP_RW(SDL_Surface *saveme, SDL_RWops *dst, int freedst)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write the bitmap image upside down */
|
/* Write the bitmap image upside down */
|
||||||
bits = (Uint8 *)surface->pixels + (surface->h * surface->pitch);
|
bits = (Uint8 *)intermediate_surface->pixels + (intermediate_surface->h * intermediate_surface->pitch);
|
||||||
pad = ((bw % 4) ? (4 - (bw % 4)) : 0);
|
pad = ((bw % 4) ? (4 - (bw % 4)) : 0);
|
||||||
while (bits > (Uint8 *)surface->pixels) {
|
while (bits > (Uint8 *)intermediate_surface->pixels) {
|
||||||
bits -= surface->pitch;
|
bits -= intermediate_surface->pitch;
|
||||||
if (SDL_RWwrite(dst, bits, 1, bw) != bw) {
|
if (SDL_RWwrite(dst, bits, 1, bw) != bw) {
|
||||||
SDL_Error(SDL_EFWRITE);
|
SDL_Error(SDL_EFWRITE);
|
||||||
break;
|
break;
|
||||||
|
@ -849,9 +850,9 @@ int SDL_SaveBMP_RW(SDL_Surface *saveme, SDL_RWops *dst, int freedst)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close it up.. */
|
/* Close it up.. */
|
||||||
SDL_UnlockSurface(surface);
|
SDL_UnlockSurface(intermediate_surface);
|
||||||
if (surface != saveme) {
|
if (intermediate_surface != surface) {
|
||||||
SDL_FreeSurface(surface);
|
SDL_FreeSurface(intermediate_surface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,7 @@ int SDL_EGL_SetErrorEx(const char *message, const char *eglFunctionName, EGLint
|
||||||
char altErrorText[32];
|
char altErrorText[32];
|
||||||
if (errorText[0] == '\0') {
|
if (errorText[0] == '\0') {
|
||||||
/* An unknown-to-SDL error code was reported. Report its hexadecimal value, instead of its name. */
|
/* An unknown-to-SDL error code was reported. Report its hexadecimal value, instead of its name. */
|
||||||
SDL_snprintf(altErrorText, SDL_arraysize(altErrorText), "0x%x", (unsigned int)eglErrorCode);
|
(void)SDL_snprintf(altErrorText, SDL_arraysize(altErrorText), "0x%x", (unsigned int)eglErrorCode);
|
||||||
errorText = altErrorText;
|
errorText = altErrorText;
|
||||||
}
|
}
|
||||||
return SDL_SetError("%s (call to %s failed, reporting an error of %s)", message, eglFunctionName, errorText);
|
return SDL_SetError("%s (call to %s failed, reporting an error of %s)", message, eglFunctionName, errorText);
|
||||||
|
|
|
@ -331,7 +331,7 @@ int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
||||||
if (r->x == 0 && r->y == 0 && r->w == dst->w && r->h == dst->h) {
|
if (r->x == 0 && r->y == 0 && r->w == dst->w && r->h == dst->h) {
|
||||||
if (dst->format->BitsPerPixel == 4) {
|
if (dst->format->BitsPerPixel == 4) {
|
||||||
Uint8 b = (((Uint8)color << 4) | (Uint8)color);
|
Uint8 b = (((Uint8)color << 4) | (Uint8)color);
|
||||||
SDL_memset(dst->pixels, b, dst->h * dst->pitch);
|
SDL_memset(dst->pixels, b, (size_t)dst->h * dst->pitch);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -567,8 +567,9 @@ int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)
|
||||||
for (mask = Rmask; !(mask & 0x01); mask >>= 1) {
|
for (mask = Rmask; !(mask & 0x01); mask >>= 1) {
|
||||||
++format->Rshift;
|
++format->Rshift;
|
||||||
}
|
}
|
||||||
for (; (mask & 0x01); mask >>= 1)
|
for (; (mask & 0x01); mask >>= 1) {
|
||||||
--format->Rloss;
|
--format->Rloss;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
format->Gmask = Gmask;
|
format->Gmask = Gmask;
|
||||||
|
@ -578,8 +579,9 @@ int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)
|
||||||
for (mask = Gmask; !(mask & 0x01); mask >>= 1) {
|
for (mask = Gmask; !(mask & 0x01); mask >>= 1) {
|
||||||
++format->Gshift;
|
++format->Gshift;
|
||||||
}
|
}
|
||||||
for (; (mask & 0x01); mask >>= 1)
|
for (; (mask & 0x01); mask >>= 1) {
|
||||||
--format->Gloss;
|
--format->Gloss;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
format->Bmask = Bmask;
|
format->Bmask = Bmask;
|
||||||
|
@ -589,8 +591,9 @@ int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)
|
||||||
for (mask = Bmask; !(mask & 0x01); mask >>= 1) {
|
for (mask = Bmask; !(mask & 0x01); mask >>= 1) {
|
||||||
++format->Bshift;
|
++format->Bshift;
|
||||||
}
|
}
|
||||||
for (; (mask & 0x01); mask >>= 1)
|
for (; (mask & 0x01); mask >>= 1) {
|
||||||
--format->Bloss;
|
--format->Bloss;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
format->Amask = Amask;
|
format->Amask = Amask;
|
||||||
|
@ -600,8 +603,9 @@ int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)
|
||||||
for (mask = Amask; !(mask & 0x01); mask >>= 1) {
|
for (mask = Amask; !(mask & 0x01); mask >>= 1) {
|
||||||
++format->Ashift;
|
++format->Ashift;
|
||||||
}
|
}
|
||||||
for (; (mask & 0x01); mask >>= 1)
|
for (; (mask & 0x01); mask >>= 1) {
|
||||||
--format->Aloss;
|
--format->Aloss;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
format->palette = NULL;
|
format->palette = NULL;
|
||||||
|
|
|
@ -45,17 +45,17 @@ SDL_CreateShapedWindow(const char *title, unsigned int x, unsigned int y, unsign
|
||||||
SDL_DestroyWindow(result);
|
SDL_DestroyWindow(result);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool
|
SDL_bool
|
||||||
SDL_IsShapedWindow(const SDL_Window *window)
|
SDL_IsShapedWindow(const SDL_Window *window)
|
||||||
{
|
{
|
||||||
if (window == NULL)
|
if (window == NULL) {
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
else
|
}
|
||||||
return (SDL_bool)(window->shaper != NULL);
|
return (SDL_bool)(window->shaper != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* REQUIRES that bitmap point to a w-by-h bitmap with ppb pixels-per-byte. */
|
/* REQUIRES that bitmap point to a w-by-h bitmap with ppb pixels-per-byte. */
|
||||||
|
@ -66,7 +66,7 @@ void SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode, SDL_Surface *shape, Uint
|
||||||
Uint8 r = 0, g = 0, b = 0, alpha = 0;
|
Uint8 r = 0, g = 0, b = 0, alpha = 0;
|
||||||
Uint8 *pixel = NULL;
|
Uint8 *pixel = NULL;
|
||||||
Uint32 pixel_value = 0, mask_value = 0;
|
Uint32 pixel_value = 0, mask_value = 0;
|
||||||
int bytes_per_scanline = (shape->w + (ppb - 1)) / ppb;
|
size_t bytes_per_scanline = (size_t)(shape->w + (ppb - 1)) / ppb;
|
||||||
Uint8 *bitmap_scanline;
|
Uint8 *bitmap_scanline;
|
||||||
SDL_Color key;
|
SDL_Color key;
|
||||||
|
|
||||||
|
@ -236,8 +236,9 @@ void SDL_TraverseShapeTree(SDL_ShapeTree *tree, SDL_TraversalFunction function,
|
||||||
SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upright, function, closure);
|
SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upright, function, closure);
|
||||||
SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.downleft, function, closure);
|
SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.downleft, function, closure);
|
||||||
SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.downright, function, closure);
|
SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.downright, function, closure);
|
||||||
} else
|
} else {
|
||||||
function(tree, closure);
|
function(tree, closure);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_FreeShapeTree(SDL_ShapeTree **shape_tree)
|
void SDL_FreeShapeTree(SDL_ShapeTree **shape_tree)
|
||||||
|
@ -319,17 +320,15 @@ int SDL_GetShapedWindowMode(SDL_Window *window, SDL_WindowShapeMode *shape_mode)
|
||||||
{
|
{
|
||||||
if (window != NULL && SDL_IsShapedWindow(window)) {
|
if (window != NULL && SDL_IsShapedWindow(window)) {
|
||||||
if (shape_mode == NULL) {
|
if (shape_mode == NULL) {
|
||||||
if (SDL_WindowHasAShape(window))
|
if (SDL_WindowHasAShape(window)) {
|
||||||
/* The window given has a shape. */
|
return 0; /* The window given has a shape. */
|
||||||
return 0;
|
} else {
|
||||||
else
|
return SDL_WINDOW_LACKS_SHAPE; /* The window given is shapeable but lacks a shape. */
|
||||||
/* The window given is shapeable but lacks a shape. */
|
}
|
||||||
return SDL_WINDOW_LACKS_SHAPE;
|
|
||||||
} else {
|
} else {
|
||||||
*shape_mode = window->shaper->mode;
|
*shape_mode = window->shaper->mode;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
/* The window given is not a valid shapeable window. */
|
return SDL_NONSHAPEABLE_WINDOW; /* The window given is not a valid shapeable window. */
|
||||||
return SDL_NONSHAPEABLE_WINDOW;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,7 +287,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U
|
||||||
window->w, window->h);
|
window->w, window->h);
|
||||||
if (!data->texture) {
|
if (!data->texture) {
|
||||||
/* codechecker_false_positive [Malloc] Static analyzer doesn't realize allocated `data` is saved to SDL_WINDOWTEXTUREDATA and not leaked here. */
|
/* codechecker_false_positive [Malloc] Static analyzer doesn't realize allocated `data` is saved to SDL_WINDOWTEXTUREDATA and not leaked here. */
|
||||||
return -1;
|
return -1; /* NOLINT(clang-analyzer-unix.Malloc) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create framebuffer data */
|
/* Create framebuffer data */
|
||||||
|
@ -296,7 +296,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U
|
||||||
|
|
||||||
{
|
{
|
||||||
/* Make static analysis happy about potential SDL_malloc(0) calls. */
|
/* Make static analysis happy about potential SDL_malloc(0) calls. */
|
||||||
const size_t allocsize = window->h * data->pitch;
|
const size_t allocsize = (size_t)window->h * data->pitch;
|
||||||
data->pixels = SDL_malloc((allocsize > 0) ? allocsize : 1);
|
data->pixels = SDL_malloc((allocsize > 0) ? allocsize : 1);
|
||||||
if (!data->pixels) {
|
if (!data->pixels) {
|
||||||
return SDL_OutOfMemory();
|
return SDL_OutOfMemory();
|
||||||
|
@ -1559,6 +1559,11 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Make clang-tidy happy */
|
||||||
|
if (_this == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ensure no more than one of these flags is set */
|
/* ensure no more than one of these flags is set */
|
||||||
|
@ -3906,7 +3911,7 @@ SDL_GL_CreateContext(SDL_Window *window)
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext ctx)
|
int SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
|
@ -3915,12 +3920,12 @@ int SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window == SDL_GL_GetCurrentWindow() &&
|
if (window == SDL_GL_GetCurrentWindow() &&
|
||||||
ctx == SDL_GL_GetCurrentContext()) {
|
context == SDL_GL_GetCurrentContext()) {
|
||||||
/* We're already current. */
|
/* We're already current. */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ctx) {
|
if (!context) {
|
||||||
window = NULL;
|
window = NULL;
|
||||||
} else if (window) {
|
} else if (window) {
|
||||||
CHECK_WINDOW_MAGIC(window, -1);
|
CHECK_WINDOW_MAGIC(window, -1);
|
||||||
|
@ -3932,12 +3937,12 @@ int SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext ctx)
|
||||||
return SDL_SetError("Use of OpenGL without a window is not supported on this platform");
|
return SDL_SetError("Use of OpenGL without a window is not supported on this platform");
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = _this->GL_MakeCurrent(_this, window, ctx);
|
retval = _this->GL_MakeCurrent(_this, window, context);
|
||||||
if (retval == 0) {
|
if (retval == 0) {
|
||||||
_this->current_glwin = window;
|
_this->current_glwin = window;
|
||||||
_this->current_glctx = ctx;
|
_this->current_glctx = context;
|
||||||
SDL_TLSSet(_this->current_glwin_tls, window, NULL);
|
SDL_TLSSet(_this->current_glwin_tls, window, NULL);
|
||||||
SDL_TLSSet(_this->current_glctx_tls, ctx, NULL);
|
SDL_TLSSet(_this->current_glctx_tls, context, NULL);
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -4533,7 +4538,7 @@ SDL_ShouldAllowTopmost(void)
|
||||||
return SDL_GetHintBoolean(SDL_HINT_ALLOW_TOPMOST, SDL_TRUE);
|
return SDL_GetHintBoolean(SDL_HINT_ALLOW_TOPMOST, SDL_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_SetWindowHitTest(SDL_Window *window, SDL_HitTest callback, void *userdata)
|
int SDL_SetWindowHitTest(SDL_Window *window, SDL_HitTest callback, void *callback_data)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, -1);
|
CHECK_WINDOW_MAGIC(window, -1);
|
||||||
|
|
||||||
|
@ -4544,7 +4549,7 @@ int SDL_SetWindowHitTest(SDL_Window *window, SDL_HitTest callback, void *userdat
|
||||||
}
|
}
|
||||||
|
|
||||||
window->hit_test = callback;
|
window->hit_test = callback;
|
||||||
window->hit_test_data = userdata;
|
window->hit_test_data = callback_data;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,8 +230,8 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
|
||||||
SDL_SetError(VK_KHR_DISPLAY_EXTENSION_NAME " extension is not enabled in the Vulkan instance.");
|
SDL_SetError(VK_KHR_DISPLAY_EXTENSION_NAME " extension is not enabled in the Vulkan instance.");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
chosenDisplayId = SDL_getenv("SDL_VULKAN_DISPLAY");
|
||||||
if ((chosenDisplayId = SDL_getenv("SDL_VULKAN_DISPLAY")) != NULL) {
|
if (chosenDisplayId != NULL) {
|
||||||
displayId = SDL_atoi(chosenDisplayId);
|
displayId = SDL_atoi(chosenDisplayId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue