Make SDL_SetError and friends unconditionally return -1.
This lets us change things like this... if (Failed) { SDL_SetError("We failed"); return -1; } ...into this... if (Failed) { return SDL_SetError("We failed"); } Fixes Bugzilla #1778.
This commit is contained in:
parent
8c6b9f4743
commit
4f438b70a2
106 changed files with 616 additions and 1189 deletions
|
@ -39,7 +39,8 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/* Public functions */
|
||||
extern DECLSPEC void SDLCALL SDL_SetError(const char *fmt, ...);
|
||||
/* SDL_SetError() unconditionally returns -1. */
|
||||
extern DECLSPEC int SDLCALL SDL_SetError(const char *fmt, ...);
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetError(void);
|
||||
extern DECLSPEC void SDLCALL SDL_ClearError(void);
|
||||
|
||||
|
@ -62,7 +63,8 @@ typedef enum
|
|||
SDL_UNSUPPORTED,
|
||||
SDL_LASTERROR
|
||||
} SDL_errorcode;
|
||||
extern DECLSPEC void SDLCALL SDL_Error(SDL_errorcode code);
|
||||
/* SDL_Error() unconditionally returns -1. */
|
||||
extern DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code);
|
||||
/*@}*//*Internal error functions*/
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
|
|
18
src/SDL.c
18
src/SDL.c
|
@ -109,8 +109,7 @@ SDL_InitSubSystem(Uint32 flags)
|
|||
}
|
||||
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_TIMER);
|
||||
#else
|
||||
SDL_SetError("SDL not built with timer support");
|
||||
return (-1);
|
||||
return SDL_SetError("SDL not built with timer support");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -124,8 +123,7 @@ SDL_InitSubSystem(Uint32 flags)
|
|||
}
|
||||
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_VIDEO);
|
||||
#else
|
||||
SDL_SetError("SDL not built with video support");
|
||||
return (-1);
|
||||
return SDL_SetError("SDL not built with video support");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -139,8 +137,7 @@ SDL_InitSubSystem(Uint32 flags)
|
|||
}
|
||||
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_AUDIO);
|
||||
#else
|
||||
SDL_SetError("SDL not built with audio support");
|
||||
return (-1);
|
||||
return SDL_SetError("SDL not built with audio support");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -159,8 +156,7 @@ SDL_InitSubSystem(Uint32 flags)
|
|||
}
|
||||
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_JOYSTICK);
|
||||
#else
|
||||
SDL_SetError("SDL not built with joystick support");
|
||||
return (-1);
|
||||
return SDL_SetError("SDL not built with joystick support");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -173,8 +169,7 @@ SDL_InitSubSystem(Uint32 flags)
|
|||
}
|
||||
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_GAMECONTROLLER);
|
||||
#else
|
||||
SDL_SetError("SDL not built with joystick support");
|
||||
return (-1);
|
||||
return SDL_SetError("SDL not built with joystick support");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -188,8 +183,7 @@ SDL_InitSubSystem(Uint32 flags)
|
|||
}
|
||||
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC);
|
||||
#else
|
||||
SDL_SetError("SDL not built with haptic (force feedback) support");
|
||||
return (-1);
|
||||
return SDL_SetError("SDL not built with haptic (force feedback) support");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -49,14 +49,14 @@ SDL_LookupString(const char *key)
|
|||
|
||||
/* Public functions */
|
||||
|
||||
void
|
||||
int
|
||||
SDL_SetError(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
SDL_error *error;
|
||||
|
||||
/* Ignore call if invalid format pointer was passed */
|
||||
if (fmt == NULL) return;
|
||||
if (fmt == NULL) return -1;
|
||||
|
||||
/* Copy in the key, mark error as valid */
|
||||
error = SDL_GetErrBuf();
|
||||
|
@ -112,6 +112,8 @@ SDL_SetError(const char *fmt, ...)
|
|||
|
||||
/* If we are in debug mode, print out an error message */
|
||||
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "%s", SDL_GetError());
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* This function has a bit more overhead than most error functions
|
||||
|
@ -216,28 +218,22 @@ SDL_ClearError(void)
|
|||
}
|
||||
|
||||
/* Very common errors go here */
|
||||
void
|
||||
int
|
||||
SDL_Error(SDL_errorcode code)
|
||||
{
|
||||
switch (code) {
|
||||
case SDL_ENOMEM:
|
||||
SDL_SetError("Out of memory");
|
||||
break;
|
||||
return SDL_SetError("Out of memory");
|
||||
case SDL_EFREAD:
|
||||
SDL_SetError("Error reading from datastream");
|
||||
break;
|
||||
return SDL_SetError("Error reading from datastream");
|
||||
case SDL_EFWRITE:
|
||||
SDL_SetError("Error writing to datastream");
|
||||
break;
|
||||
return SDL_SetError("Error writing to datastream");
|
||||
case SDL_EFSEEK:
|
||||
SDL_SetError("Error seeking in datastream");
|
||||
break;
|
||||
return SDL_SetError("Error seeking in datastream");
|
||||
case SDL_UNSUPPORTED:
|
||||
SDL_SetError("That operation is not supported");
|
||||
break;
|
||||
return SDL_SetError("That operation is not supported");
|
||||
default:
|
||||
SDL_SetError("Unknown SDL error");
|
||||
break;
|
||||
return SDL_SetError("Unknown SDL error");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -970,28 +970,23 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
|
|||
|
||||
/* Sanity check target pointer */
|
||||
if (cvt == NULL) {
|
||||
SDL_InvalidParamError("cvt");
|
||||
return -1;
|
||||
return SDL_InvalidParamError("cvt");
|
||||
}
|
||||
|
||||
/* there are no unsigned types over 16 bits, so catch this up front. */
|
||||
if ((SDL_AUDIO_BITSIZE(src_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(src_fmt))) {
|
||||
SDL_SetError("Invalid source format");
|
||||
return -1;
|
||||
return SDL_SetError("Invalid source format");
|
||||
}
|
||||
if ((SDL_AUDIO_BITSIZE(dst_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(dst_fmt))) {
|
||||
SDL_SetError("Invalid destination format");
|
||||
return -1;
|
||||
return SDL_SetError("Invalid destination format");
|
||||
}
|
||||
|
||||
/* prevent possible divisions by zero, etc. */
|
||||
if ((src_channels == 0) || (dst_channels == 0)) {
|
||||
SDL_SetError("Source or destination channels is zero");
|
||||
return -1;
|
||||
return SDL_SetError("Source or destination channels is zero");
|
||||
}
|
||||
if ((src_rate == 0) || (dst_rate == 0)) {
|
||||
SDL_SetError("Source or destination rate is zero");
|
||||
return -1;
|
||||
return SDL_SetError("Source or destination rate is zero");
|
||||
}
|
||||
#ifdef DEBUG_CONVERT
|
||||
printf("Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
|
||||
|
|
|
@ -134,8 +134,7 @@ MS_ADPCM_decode(Uint8 ** audio_buf, Uint32 * audio_len)
|
|||
MS_ADPCM_state.wavefmt.channels * sizeof(Sint16);
|
||||
*audio_buf = (Uint8 *) SDL_malloc(*audio_len);
|
||||
if (*audio_buf == NULL) {
|
||||
SDL_Error(SDL_ENOMEM);
|
||||
return (-1);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
decoded = *audio_buf;
|
||||
|
||||
|
@ -359,8 +358,7 @@ IMA_ADPCM_decode(Uint8 ** audio_buf, Uint32 * audio_len)
|
|||
IMA_ADPCM_state.wavefmt.channels * sizeof(Sint16);
|
||||
*audio_buf = (Uint8 *) SDL_malloc(*audio_len);
|
||||
if (*audio_buf == NULL) {
|
||||
SDL_Error(SDL_ENOMEM);
|
||||
return (-1);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
decoded = *audio_buf;
|
||||
|
||||
|
@ -620,14 +618,12 @@ ReadChunk(SDL_RWops * src, Chunk * chunk)
|
|||
chunk->length = SDL_ReadLE32(src);
|
||||
chunk->data = (Uint8 *) SDL_malloc(chunk->length);
|
||||
if (chunk->data == NULL) {
|
||||
SDL_Error(SDL_ENOMEM);
|
||||
return (-1);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
if (SDL_RWread(src, chunk->data, chunk->length, 1) != 1) {
|
||||
SDL_Error(SDL_EFREAD);
|
||||
SDL_free(chunk->data);
|
||||
chunk->data = NULL;
|
||||
return (-1);
|
||||
return SDL_Error(SDL_EFREAD);
|
||||
}
|
||||
return (chunk->length);
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ utf16_to_utf8(const WCHAR *S)
|
|||
(SDL_wcslen(S)+1)*sizeof(WCHAR));
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
SetDSerror(const char *function, int code)
|
||||
{
|
||||
static const char *error;
|
||||
|
@ -145,8 +145,7 @@ SetDSerror(const char *function, int code)
|
|||
SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function,
|
||||
error);
|
||||
}
|
||||
SDL_SetError("%s", errbuf);
|
||||
return;
|
||||
return SDL_SetError("%s", errbuf);
|
||||
}
|
||||
|
||||
|
||||
|
@ -380,16 +379,14 @@ CreateSecondary(_THIS, HWND focus, WAVEFORMATEX * wavefmt)
|
|||
format.dwBufferBytes = numchunks * chunksize;
|
||||
if ((format.dwBufferBytes < DSBSIZE_MIN) ||
|
||||
(format.dwBufferBytes > DSBSIZE_MAX)) {
|
||||
SDL_SetError("Sound buffer size must be between %d and %d",
|
||||
DSBSIZE_MIN / numchunks, DSBSIZE_MAX / numchunks);
|
||||
return (-1);
|
||||
return SDL_SetError("Sound buffer size must be between %d and %d",
|
||||
DSBSIZE_MIN / numchunks, DSBSIZE_MAX / numchunks);
|
||||
}
|
||||
format.dwReserved = 0;
|
||||
format.lpwfxFormat = wavefmt;
|
||||
result = IDirectSound_CreateSoundBuffer(sndObj, &format, sndbuf, NULL);
|
||||
if (result != DS_OK) {
|
||||
SetDSerror("DirectSound CreateSoundBuffer", result);
|
||||
return (-1);
|
||||
return SetDSerror("DirectSound CreateSoundBuffer", result);
|
||||
}
|
||||
IDirectSoundBuffer_SetFormat(*sndbuf, wavefmt);
|
||||
|
||||
|
|
|
@ -332,8 +332,7 @@ SUNAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
this->hidden->frequency = 8;
|
||||
this->hidden->ulaw_buf = (Uint8 *) SDL_malloc(this->hidden->fragsize);
|
||||
if (this->hidden->ulaw_buf == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return (-1);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
this->spec.channels = 1;
|
||||
} else {
|
||||
|
@ -353,8 +352,7 @@ SUNAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
/* Allocate mixing buffer */
|
||||
this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->spec.size);
|
||||
if (this->hidden->mixbuf == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return (-1);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
|
||||
|
||||
|
|
|
@ -811,8 +811,7 @@ static int Android_JNI_FileClose(SDL_RWops* ctx, bool release)
|
|||
JNIEnv *mEnv = Android_JNI_GetEnv();
|
||||
|
||||
if (!refs.init(mEnv)) {
|
||||
SDL_SetError("Failed to allocate enough JVM local references");
|
||||
return -1;
|
||||
return SDL_SetError("Failed to allocate enough JVM local references");
|
||||
}
|
||||
|
||||
if (ctx) {
|
||||
|
@ -875,8 +874,7 @@ extern "C" Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence
|
|||
offset = ctx->hidden.androidio.offset + ctx->hidden.androidio.size + offset;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unknown value for 'whence'");
|
||||
return -1;
|
||||
return SDL_SetError("Unknown value for 'whence'");
|
||||
}
|
||||
whence = SEEK_SET;
|
||||
|
||||
|
@ -897,14 +895,12 @@ extern "C" Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence
|
|||
newPosition = ctx->hidden.androidio.size + offset;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unknown value for 'whence'");
|
||||
return -1;
|
||||
return SDL_SetError("Unknown value for 'whence'");
|
||||
}
|
||||
|
||||
/* Validate the new position */
|
||||
if (newPosition < 0) {
|
||||
SDL_Error(SDL_EFSEEK);
|
||||
return -1;
|
||||
return SDL_Error(SDL_EFSEEK);
|
||||
}
|
||||
if (newPosition > ctx->hidden.androidio.size) {
|
||||
newPosition = ctx->hidden.androidio.size;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <objbase.h> /* for CoInitialize/CoUninitialize */
|
||||
|
||||
/* Sets an error message based on GetLastError() */
|
||||
void
|
||||
int
|
||||
WIN_SetError(const char *prefix)
|
||||
{
|
||||
TCHAR buffer[1024];
|
||||
|
@ -39,6 +39,7 @@ WIN_SetError(const char *prefix)
|
|||
message = WIN_StringToUTF8(buffer);
|
||||
SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
|
||||
SDL_free(message);
|
||||
return -1;
|
||||
}
|
||||
|
||||
HRESULT
|
||||
|
|
|
@ -43,8 +43,8 @@
|
|||
#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1)
|
||||
#endif
|
||||
|
||||
/* Sets an error message based on GetLastError() */
|
||||
extern void WIN_SetError(const char *prefix);
|
||||
/* Sets an error message based on GetLastError(). Always return -1. */
|
||||
extern int WIN_SetError(const char *prefix);
|
||||
|
||||
/* Wrap up the oddities of CoInitialize() into a common function. */
|
||||
extern HRESULT WIN_CoInitialize(void);
|
||||
|
|
|
@ -244,8 +244,7 @@ SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action,
|
|||
}
|
||||
SDL_UnlockMutex(SDL_EventQ.lock);
|
||||
} else {
|
||||
SDL_SetError("Couldn't lock event queue");
|
||||
used = -1;
|
||||
return SDL_SetError("Couldn't lock event queue");
|
||||
}
|
||||
return (used);
|
||||
}
|
||||
|
|
|
@ -158,8 +158,7 @@ int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *src)
|
|||
}
|
||||
}
|
||||
}
|
||||
SDL_SetError("Unknown gestureId");
|
||||
return -1;
|
||||
return SDL_SetError("Unknown gestureId");
|
||||
}
|
||||
|
||||
//path is an already sampled set of points
|
||||
|
@ -176,8 +175,7 @@ static int SDL_AddDollarGesture_one(SDL_GestureTouch* inTouch, SDL_FloatPoint* p
|
|||
(index + 1) *
|
||||
sizeof(SDL_DollarTemplate));
|
||||
if (!dollarTemplate) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
inTouch->dollarTemplate = dollarTemplate;
|
||||
|
||||
|
@ -419,8 +417,7 @@ int SDL_GestureAddTouch(SDL_TouchID touchId)
|
|||
sizeof(SDL_GestureTouch));
|
||||
|
||||
if (!gestureTouch) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
SDL_gestureTouch = gestureTouch;
|
||||
|
|
|
@ -413,8 +413,7 @@ SDL_SetRelativeMouseMode(SDL_bool enabled)
|
|||
}
|
||||
|
||||
if (!mouse->SetRelativeMouseMode) {
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
if (mouse->SetRelativeMouseMode(enabled) < 0) {
|
||||
|
|
|
@ -141,8 +141,7 @@ SDL_AddTouch(SDL_TouchID touchID, const char *name)
|
|||
touchDevices = (SDL_Touch **) SDL_realloc(SDL_touchDevices,
|
||||
(SDL_num_touch + 1) * sizeof(*touchDevices));
|
||||
if (!touchDevices) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
SDL_touchDevices = touchDevices;
|
||||
|
@ -150,8 +149,7 @@ SDL_AddTouch(SDL_TouchID touchID, const char *name)
|
|||
|
||||
SDL_touchDevices[index] = (SDL_Touch *) SDL_malloc(sizeof(*SDL_touchDevices[index]));
|
||||
if (!SDL_touchDevices[index]) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
/* we're setting the touch properties */
|
||||
|
@ -176,14 +174,12 @@ SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float y, float p
|
|||
SDL_Finger **new_fingers;
|
||||
new_fingers = (SDL_Finger **)SDL_realloc(touch->fingers, (touch->max_fingers+1)*sizeof(*touch->fingers));
|
||||
if (!new_fingers) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
touch->fingers = new_fingers;
|
||||
touch->fingers[touch->max_fingers] = (SDL_Finger *)SDL_malloc(sizeof(*finger));
|
||||
if (!touch->fingers[touch->max_fingers]) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
touch->max_fingers++;
|
||||
}
|
||||
|
|
|
@ -87,8 +87,7 @@ windows_file_open(SDL_RWops * context, const char *filename, const char *mode)
|
|||
context->hidden.windowsio.buffer.data =
|
||||
(char *) SDL_malloc(READAHEAD_BUFFER_SIZE);
|
||||
if (!context->hidden.windowsio.buffer.data) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
/* Do not open a dialog box if failure */
|
||||
old_error_mode =
|
||||
|
@ -124,13 +123,11 @@ windows_file_size(SDL_RWops * context)
|
|||
LARGE_INTEGER size;
|
||||
|
||||
if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
|
||||
SDL_SetError("windows_file_size: invalid context/file not opened");
|
||||
return -1;
|
||||
return SDL_SetError("windows_file_size: invalid context/file not opened");
|
||||
}
|
||||
|
||||
if (!GetFileSizeEx(context->hidden.windowsio.h, &size)) {
|
||||
WIN_SetError("windows_file_size");
|
||||
return -1;
|
||||
return WIN_SetError("windows_file_size");
|
||||
}
|
||||
|
||||
return size.QuadPart;
|
||||
|
@ -143,8 +140,7 @@ windows_file_seek(SDL_RWops * context, Sint64 offset, int whence)
|
|||
LARGE_INTEGER windowsoffset;
|
||||
|
||||
if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
|
||||
SDL_SetError("windows_file_seek: invalid context/file not opened");
|
||||
return -1;
|
||||
return SDL_SetError("windows_file_seek: invalid context/file not opened");
|
||||
}
|
||||
|
||||
/* FIXME: We may be able to satisfy the seek within buffered data */
|
||||
|
@ -164,14 +160,12 @@ windows_file_seek(SDL_RWops * context, Sint64 offset, int whence)
|
|||
windowswhence = FILE_END;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("windows_file_seek: Unknown value for 'whence'");
|
||||
return -1;
|
||||
return SDL_SetError("windows_file_seek: Unknown value for 'whence'");
|
||||
}
|
||||
|
||||
windowsoffset.QuadPart = offset;
|
||||
if (!SetFilePointerEx(context->hidden.windowsio.h, windowsoffset, &windowsoffset, windowswhence)) {
|
||||
WIN_SetError("windows_file_seek");
|
||||
return -1;
|
||||
return WIN_SetError("windows_file_seek");
|
||||
}
|
||||
return windowsoffset.QuadPart;
|
||||
}
|
||||
|
@ -325,8 +319,7 @@ stdio_seek(SDL_RWops * context, Sint64 offset, int whence)
|
|||
return (ftell(context->hidden.stdio.fp));
|
||||
}
|
||||
#endif
|
||||
SDL_Error(SDL_EFSEEK);
|
||||
return (-1);
|
||||
return SDL_Error(SDL_EFSEEK);
|
||||
}
|
||||
|
||||
static size_t SDLCALL
|
||||
|
@ -361,8 +354,7 @@ stdio_close(SDL_RWops * context)
|
|||
if (context->hidden.stdio.autoclose) {
|
||||
/* WARNING: Check the return value here! */
|
||||
if (fclose(context->hidden.stdio.fp) != 0) {
|
||||
SDL_Error(SDL_EFWRITE);
|
||||
status = -1;
|
||||
status = SDL_Error(SDL_EFWRITE);
|
||||
}
|
||||
}
|
||||
SDL_FreeRW(context);
|
||||
|
@ -395,8 +387,7 @@ mem_seek(SDL_RWops * context, Sint64 offset, int whence)
|
|||
newpos = context->hidden.mem.stop + offset;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unknown value for 'whence'");
|
||||
return (-1);
|
||||
return SDL_SetError("Unknown value for 'whence'");
|
||||
}
|
||||
if (newpos < context->hidden.mem.base) {
|
||||
newpos = context->hidden.mem.base;
|
||||
|
|
|
@ -447,8 +447,7 @@ SDL_HapticNewEffect(SDL_Haptic * haptic, SDL_HapticEffect * effect)
|
|||
|
||||
/* Check to see if effect is supported */
|
||||
if (SDL_HapticEffectSupported(haptic, effect) == SDL_FALSE) {
|
||||
SDL_SetError("Haptic: Effect not supported by haptic device.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Effect not supported by haptic device.");
|
||||
}
|
||||
|
||||
/* See if there's a free slot */
|
||||
|
@ -467,8 +466,7 @@ SDL_HapticNewEffect(SDL_Haptic * haptic, SDL_HapticEffect * effect)
|
|||
}
|
||||
}
|
||||
|
||||
SDL_SetError("Haptic: Device has no free space left.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Device has no free space left.");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -497,8 +495,7 @@ SDL_HapticUpdateEffect(SDL_Haptic * haptic, int effect,
|
|||
|
||||
/* Can't change type dynamically. */
|
||||
if (data->type != haptic->effects[effect].effect.type) {
|
||||
SDL_SetError("Haptic: Updating effect type is illegal.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Updating effect type is illegal.");
|
||||
}
|
||||
|
||||
/* Updates the effect */
|
||||
|
@ -579,8 +576,7 @@ SDL_HapticGetEffectStatus(SDL_Haptic * haptic, int effect)
|
|||
}
|
||||
|
||||
if ((haptic->supported & SDL_HAPTIC_STATUS) == 0) {
|
||||
SDL_SetError("Haptic: Device does not support status queries.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Device does not support status queries.");
|
||||
}
|
||||
|
||||
return SDL_SYS_HapticGetEffectStatus(haptic, &haptic->effects[effect]);
|
||||
|
@ -600,13 +596,11 @@ SDL_HapticSetGain(SDL_Haptic * haptic, int gain)
|
|||
}
|
||||
|
||||
if ((haptic->supported & SDL_HAPTIC_GAIN) == 0) {
|
||||
SDL_SetError("Haptic: Device does not support setting gain.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Device does not support setting gain.");
|
||||
}
|
||||
|
||||
if ((gain < 0) || (gain > 100)) {
|
||||
SDL_SetError("Haptic: Gain must be between 0 and 100.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Gain must be between 0 and 100.");
|
||||
}
|
||||
|
||||
/* We use the envvar to get the maximum gain. */
|
||||
|
@ -644,13 +638,11 @@ SDL_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
|
|||
}
|
||||
|
||||
if ((haptic->supported & SDL_HAPTIC_AUTOCENTER) == 0) {
|
||||
SDL_SetError("Haptic: Device does not support setting autocenter.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Device does not support setting autocenter.");
|
||||
}
|
||||
|
||||
if ((autocenter < 0) || (autocenter > 100)) {
|
||||
SDL_SetError("Haptic: Autocenter must be between 0 and 100.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Autocenter must be between 0 and 100.");
|
||||
}
|
||||
|
||||
if (SDL_SYS_HapticSetAutocenter(haptic, autocenter) < 0) {
|
||||
|
@ -671,8 +663,7 @@ SDL_HapticPause(SDL_Haptic * haptic)
|
|||
}
|
||||
|
||||
if ((haptic->supported & SDL_HAPTIC_PAUSE) == 0) {
|
||||
SDL_SetError("Haptic: Device does not support setting pausing.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Device does not support setting pausing.");
|
||||
}
|
||||
|
||||
return SDL_SYS_HapticPause(haptic);
|
||||
|
@ -773,8 +764,7 @@ SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length)
|
|||
}
|
||||
|
||||
if (haptic->rumble_id < 0) {
|
||||
SDL_SetError("Haptic: Rumble effect not initialized on haptic device");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Rumble effect not initialized on haptic device");
|
||||
}
|
||||
|
||||
/* Clamp strength. */
|
||||
|
@ -805,8 +795,7 @@ SDL_HapticRumbleStop(SDL_Haptic * haptic)
|
|||
}
|
||||
|
||||
if (haptic->rumble_id < 0) {
|
||||
SDL_SetError("Haptic: Rumble effect not initialized on haptic device");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Rumble effect not initialized on haptic device");
|
||||
}
|
||||
|
||||
return SDL_HapticStopEffect(haptic, haptic->rumble_id);
|
||||
|
|
|
@ -160,15 +160,13 @@ SDL_SYS_HapticInit(void)
|
|||
/* Get HID devices. */
|
||||
match = IOServiceMatching(kIOHIDDeviceKey);
|
||||
if (match == NULL) {
|
||||
SDL_SetError("Haptic: Failed to get IOServiceMatching.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Failed to get IOServiceMatching.");
|
||||
}
|
||||
|
||||
/* Now search I/O Registry for matching devices. */
|
||||
result = IOServiceGetMatchingServices(kIOMasterPortDefault, match, &iter);
|
||||
if (result != kIOReturnSuccess) {
|
||||
SDL_SetError("Haptic: Couldn't create a HID object iterator.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Couldn't create a HID object iterator.");
|
||||
}
|
||||
/* IOServiceGetMatchingServices consumes dictionary. */
|
||||
|
||||
|
@ -257,8 +255,7 @@ HIDGetDeviceProduct(io_service_t dev, char *name)
|
|||
ret = IORegistryEntryCreateCFProperties(dev, &hidProperties,
|
||||
kCFAllocatorDefault, kNilOptions);
|
||||
if ((ret != KERN_SUCCESS) || !hidProperties) {
|
||||
SDL_SetError("Haptic: Unable to create CFProperties.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Unable to create CFProperties.");
|
||||
}
|
||||
|
||||
/* Mac OS X currently is not mirroring all USB properties to HID page so need to look at USB device page also
|
||||
|
@ -289,17 +286,15 @@ HIDGetDeviceProduct(io_service_t dev, char *name)
|
|||
if (refCF) {
|
||||
if (!CFStringGetCString(refCF, name, 256,
|
||||
CFStringGetSystemEncoding())) {
|
||||
SDL_SetError
|
||||
return SDL_SetError
|
||||
("Haptic: CFStringGetCString error retrieving pDevice->product.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
CFRelease(usbProperties);
|
||||
} else {
|
||||
SDL_SetError
|
||||
return SDL_SetError
|
||||
("Haptic: IORegistryEntryCreateCFProperties failed to create usbProperties.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Release stuff. */
|
||||
|
@ -310,8 +305,7 @@ HIDGetDeviceProduct(io_service_t dev, char *name)
|
|||
SDL_SetError("Haptic: IOObjectRelease error with parent1.");
|
||||
}
|
||||
} else {
|
||||
SDL_SetError("Haptic: Error getting registry entries.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Error getting registry entries.");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -336,8 +330,7 @@ GetSupportedFeatures(SDL_Haptic * haptic)
|
|||
|
||||
ret = FFDeviceGetForceFeedbackCapabilities(device, &features);
|
||||
if (ret != FF_OK) {
|
||||
SDL_SetError("Haptic: Unable to get device's supported features.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Unable to get device's supported features.");
|
||||
}
|
||||
|
||||
supported = 0;
|
||||
|
@ -366,9 +359,8 @@ GetSupportedFeatures(SDL_Haptic * haptic)
|
|||
if (ret == FF_OK)
|
||||
supported |= SDL_HAPTIC_GAIN;
|
||||
else if (ret != FFERR_UNSUPPORTED) {
|
||||
SDL_SetError("Haptic: Unable to get if device supports gain: %s.",
|
||||
FFStrError(ret));
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Unable to get if device supports gain: %s.",
|
||||
FFStrError(ret));
|
||||
}
|
||||
|
||||
/* Checks if supports autocenter. */
|
||||
|
@ -377,10 +369,9 @@ GetSupportedFeatures(SDL_Haptic * haptic)
|
|||
if (ret == FF_OK)
|
||||
supported |= SDL_HAPTIC_AUTOCENTER;
|
||||
else if (ret != FFERR_UNSUPPORTED) {
|
||||
SDL_SetError
|
||||
return SDL_SetError
|
||||
("Haptic: Unable to get if device supports autocenter: %s.",
|
||||
FFStrError(ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Check for axes, we have an artificial limit on axes */
|
||||
|
@ -625,8 +616,7 @@ SDL_SYS_SetDirection(FFEFFECT * effect, SDL_HapticDirection * dir, int naxes)
|
|||
/* Has axes. */
|
||||
rglDir = SDL_malloc(sizeof(LONG) * naxes);
|
||||
if (rglDir == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(rglDir, 0, sizeof(LONG) * naxes);
|
||||
effect->rglDirection = rglDir;
|
||||
|
@ -654,8 +644,7 @@ SDL_SYS_SetDirection(FFEFFECT * effect, SDL_HapticDirection * dir, int naxes)
|
|||
return 0;
|
||||
|
||||
default:
|
||||
SDL_SetError("Haptic: Unknown direction type.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Unknown direction type.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -695,8 +684,7 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest,
|
|||
/* Envelope. */
|
||||
envelope = SDL_malloc(sizeof(FFENVELOPE));
|
||||
if (envelope == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(envelope, 0, sizeof(FFENVELOPE));
|
||||
dest->lpEnvelope = envelope;
|
||||
|
@ -707,8 +695,7 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest,
|
|||
if (dest->cAxes > 0) {
|
||||
axes = SDL_malloc(sizeof(DWORD) * dest->cAxes);
|
||||
if (axes == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */
|
||||
if (dest->cAxes > 1) {
|
||||
|
@ -727,8 +714,7 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest,
|
|||
hap_constant = &src->constant;
|
||||
constant = SDL_malloc(sizeof(FFCONSTANTFORCE));
|
||||
if (constant == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(constant, 0, sizeof(FFCONSTANTFORCE));
|
||||
|
||||
|
@ -771,8 +757,7 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest,
|
|||
hap_periodic = &src->periodic;
|
||||
periodic = SDL_malloc(sizeof(FFPERIODIC));
|
||||
if (periodic == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(periodic, 0, sizeof(FFPERIODIC));
|
||||
|
||||
|
@ -817,8 +802,7 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest,
|
|||
hap_condition = &src->condition;
|
||||
condition = SDL_malloc(sizeof(FFCONDITION) * dest->cAxes);
|
||||
if (condition == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(condition, 0, sizeof(FFCONDITION));
|
||||
|
||||
|
@ -860,8 +844,7 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest,
|
|||
hap_ramp = &src->ramp;
|
||||
ramp = SDL_malloc(sizeof(FFRAMPFORCE));
|
||||
if (ramp == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(ramp, 0, sizeof(FFRAMPFORCE));
|
||||
|
||||
|
@ -899,8 +882,7 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest,
|
|||
hap_custom = &src->custom;
|
||||
custom = SDL_malloc(sizeof(FFCUSTOMFORCE));
|
||||
if (custom == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(custom, 0, sizeof(FFCUSTOMFORCE));
|
||||
|
||||
|
@ -944,8 +926,7 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest,
|
|||
|
||||
|
||||
default:
|
||||
SDL_SetError("Haptic: Unknown effect type.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Unknown effect type.");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1150,9 +1131,8 @@ SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
|
|||
/* Run the effect. */
|
||||
ret = FFEffectStart(effect->hweffect->ref, iter, 0);
|
||||
if (ret != FF_OK) {
|
||||
SDL_SetError("Haptic: Unable to run the effect: %s.",
|
||||
FFStrError(ret));
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Unable to run the effect: %s.",
|
||||
FFStrError(ret));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1169,9 +1149,8 @@ SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
|
|||
|
||||
ret = FFEffectStop(effect->hweffect->ref);
|
||||
if (ret != FF_OK) {
|
||||
SDL_SetError("Haptic: Unable to stop the effect: %s.",
|
||||
FFStrError(ret));
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Unable to stop the effect: %s.",
|
||||
FFStrError(ret));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1236,8 +1215,7 @@ SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain)
|
|||
FFDeviceSetForceFeedbackProperty(haptic->hwdata->device,
|
||||
FFPROP_FFGAIN, &val);
|
||||
if (ret != FF_OK) {
|
||||
SDL_SetError("Haptic: Error setting gain: %s.", FFStrError(ret));
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Error setting gain: %s.", FFStrError(ret));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1262,9 +1240,8 @@ SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
|
|||
ret = FFDeviceSetForceFeedbackProperty(haptic->hwdata->device,
|
||||
FFPROP_AUTOCENTER, &val);
|
||||
if (ret != FF_OK) {
|
||||
SDL_SetError("Haptic: Error setting autocenter: %s.",
|
||||
FFStrError(ret));
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Error setting autocenter: %s.",
|
||||
FFStrError(ret));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1282,8 +1259,7 @@ SDL_SYS_HapticPause(SDL_Haptic * haptic)
|
|||
ret = FFDeviceSendForceFeedbackCommand(haptic->hwdata->device,
|
||||
FFSFFC_PAUSE);
|
||||
if (ret != FF_OK) {
|
||||
SDL_SetError("Haptic: Error pausing device: %s.", FFStrError(ret));
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Error pausing device: %s.", FFStrError(ret));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1301,8 +1277,7 @@ SDL_SYS_HapticUnpause(SDL_Haptic * haptic)
|
|||
ret = FFDeviceSendForceFeedbackCommand(haptic->hwdata->device,
|
||||
FFSFFC_CONTINUE);
|
||||
if (ret != FF_OK) {
|
||||
SDL_SetError("Haptic: Error pausing device: %s.", FFStrError(ret));
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Error pausing device: %s.", FFStrError(ret));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1320,8 +1295,7 @@ SDL_SYS_HapticStopAll(SDL_Haptic * haptic)
|
|||
ret = FFDeviceSendForceFeedbackCommand(haptic->hwdata->device,
|
||||
FFSFFC_STOPALL);
|
||||
if (ret != FF_OK) {
|
||||
SDL_SetError("Haptic: Error stopping device: %s.", FFStrError(ret));
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Error stopping device: %s.", FFStrError(ret));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -92,9 +92,8 @@ EV_IsHaptic(int fd)
|
|||
/* Ask device for what it has. */
|
||||
ret = 0;
|
||||
if (ioctl(fd, EVIOCGBIT(EV_FF, sizeof(features)), features) < 0) {
|
||||
SDL_SetError("Haptic: Unable to get device's features: %s",
|
||||
strerror(errno));
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Unable to get device's features: %s",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
/* Convert supported features to SDL_HAPTIC platform-neutral features. */
|
||||
|
@ -309,9 +308,8 @@ SDL_SYS_HapticOpen(SDL_Haptic * haptic)
|
|||
/* Open the character device */
|
||||
fd = open(SDL_hapticlist[haptic->index].fname, O_RDWR, 0);
|
||||
if (fd < 0) {
|
||||
SDL_SetError("Haptic: Unable to open %s: %s",
|
||||
SDL_hapticlist[haptic->index], strerror(errno));
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Unable to open %s: %s",
|
||||
SDL_hapticlist[haptic->index], strerror(errno));
|
||||
}
|
||||
|
||||
/* Try to create the haptic. */
|
||||
|
@ -340,9 +338,8 @@ SDL_SYS_HapticMouse(void)
|
|||
/* Open the device. */
|
||||
fd = open(SDL_hapticlist[i].fname, O_RDWR, 0);
|
||||
if (fd < 0) {
|
||||
SDL_SetError("Haptic: Unable to open %s: %s",
|
||||
SDL_hapticlist[i], strerror(errno));
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Unable to open %s: %s",
|
||||
SDL_hapticlist[i], strerror(errno));
|
||||
}
|
||||
|
||||
/* Is it a mouse? */
|
||||
|
@ -405,15 +402,13 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
|||
}
|
||||
}
|
||||
if (i >= MAX_HAPTICS) {
|
||||
SDL_SetError("Haptic: Joystick doesn't have Haptic capabilities");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Joystick doesn't have Haptic capabilities");
|
||||
}
|
||||
|
||||
fd = open(joystick->hwdata->fname, O_RDWR, 0);
|
||||
if (fd < 0) {
|
||||
SDL_SetError("Haptic: Unable to open %s: %s",
|
||||
joystick->hwdata->fname, strerror(errno));
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Unable to open %s: %s",
|
||||
joystick->hwdata->fname, strerror(errno));
|
||||
}
|
||||
ret = SDL_SYS_HapticOpenFromFD(haptic, fd); /* Already closes on error. */
|
||||
if (ret < 0) {
|
||||
|
@ -544,8 +539,7 @@ SDL_SYS_ToDirection(SDL_HapticDirection * dir)
|
|||
return (Uint16) tmp;
|
||||
|
||||
default:
|
||||
SDL_SetError("Haptic: Unsupported direction type.");
|
||||
return (Uint16) - 1;
|
||||
return (Uint16) SDL_SetError("Haptic: Unsupported direction type.");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -733,8 +727,7 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src)
|
|||
|
||||
|
||||
default:
|
||||
SDL_SetError("Haptic: Unknown effect type.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Unknown effect type.");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -754,8 +747,7 @@ SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
|
|||
effect->hweffect = (struct haptic_hweffect *)
|
||||
SDL_malloc(sizeof(struct haptic_hweffect));
|
||||
if (effect->hweffect == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
/* Prepare the ff_effect */
|
||||
|
@ -802,9 +794,8 @@ SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
|
|||
|
||||
/* See if it can be uploaded. */
|
||||
if (ioctl(haptic->hwdata->fd, EVIOCSFF, &linux_effect) < 0) {
|
||||
SDL_SetError("Haptic: Error updating the effect: %s",
|
||||
strerror(errno));
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Error updating the effect: %s",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
/* Copy the new effect into memory. */
|
||||
|
@ -831,8 +822,7 @@ SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
|
|||
run.value = (iterations > INT_MAX) ? INT_MAX : iterations;
|
||||
|
||||
if (write(haptic->hwdata->fd, (const void *) &run, sizeof(run)) < 0) {
|
||||
SDL_SetError("Haptic: Unable to run the effect: %s", strerror(errno));
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Unable to run the effect: %s", strerror(errno));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -852,9 +842,8 @@ SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
|
|||
stop.value = 0;
|
||||
|
||||
if (write(haptic->hwdata->fd, (const void *) &stop, sizeof(stop)) < 0) {
|
||||
SDL_SetError("Haptic: Unable to stop the effect: %s",
|
||||
strerror(errno));
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Unable to stop the effect: %s",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -891,8 +880,7 @@ SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic,
|
|||
ie.code = effect->hweffect->effect.id;
|
||||
|
||||
if (write(haptic->hwdata->fd, &ie, sizeof(ie)) < 0) {
|
||||
SDL_SetError("Haptic: Error getting device status.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Error getting device status.");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -915,8 +903,7 @@ SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain)
|
|||
ie.value = (0xFFFFUL * gain) / 100;
|
||||
|
||||
if (write(haptic->hwdata->fd, &ie, sizeof(ie)) < 0) {
|
||||
SDL_SetError("Haptic: Error setting gain: %s", strerror(errno));
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Error setting gain: %s", strerror(errno));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -936,8 +923,7 @@ SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
|
|||
ie.value = (0xFFFFUL * autocenter) / 100;
|
||||
|
||||
if (write(haptic->hwdata->fd, &ie, sizeof(ie)) < 0) {
|
||||
SDL_SetError("Haptic: Error setting autocenter: %s", strerror(errno));
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Error setting autocenter: %s", strerror(errno));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -977,9 +963,8 @@ SDL_SYS_HapticStopAll(SDL_Haptic * haptic)
|
|||
if (haptic->effects[i].hweffect != NULL) {
|
||||
ret = SDL_SYS_HapticStopEffect(haptic, &haptic->effects[i]);
|
||||
if (ret < 0) {
|
||||
SDL_SetError
|
||||
return SDL_SetError
|
||||
("Haptic: Error while trying to stop all playing effects.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ extern HWND SDL_HelperWindow;
|
|||
/*
|
||||
* Prototypes.
|
||||
*/
|
||||
static void DI_SetError(const char *str, HRESULT err);
|
||||
static int DI_SetError(const char *str, HRESULT err);
|
||||
static int DI_GUIDIsSame(const GUID * a, const GUID * b);
|
||||
static int SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic,
|
||||
DIDEVICEINSTANCE instance);
|
||||
|
@ -110,14 +110,14 @@ static BOOL CALLBACK DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv);
|
|||
/*
|
||||
* Like SDL_SetError but for DX error codes.
|
||||
*/
|
||||
static void
|
||||
static int
|
||||
DI_SetError(const char *str, HRESULT err)
|
||||
{
|
||||
/*
|
||||
SDL_SetError("Haptic: %s - %s: %s", str,
|
||||
DXGetErrorString8A(err), DXGetErrorDescription8A(err));
|
||||
*/
|
||||
SDL_SetError("Haptic error %s", str);
|
||||
return SDL_SetError("Haptic error %s", str);
|
||||
}
|
||||
|
||||
|
||||
|
@ -142,8 +142,7 @@ SDL_SYS_HapticInit(void)
|
|||
HINSTANCE instance;
|
||||
|
||||
if (dinput != NULL) { /* Already open. */
|
||||
SDL_SetError("Haptic: SubSystem already open.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: SubSystem already open.");
|
||||
}
|
||||
|
||||
/* Clear all the memory. */
|
||||
|
@ -153,8 +152,7 @@ SDL_SYS_HapticInit(void)
|
|||
|
||||
ret = WIN_CoInitialize();
|
||||
if (FAILED(ret)) {
|
||||
DI_SetError("Coinitialize", ret);
|
||||
return -1;
|
||||
return DI_SetError("Coinitialize", ret);
|
||||
}
|
||||
|
||||
coinitialized = SDL_TRUE;
|
||||
|
@ -163,23 +161,20 @@ SDL_SYS_HapticInit(void)
|
|||
&IID_IDirectInput8, (LPVOID) & dinput);
|
||||
if (FAILED(ret)) {
|
||||
SDL_SYS_HapticQuit();
|
||||
DI_SetError("CoCreateInstance", ret);
|
||||
return -1;
|
||||
return DI_SetError("CoCreateInstance", ret);
|
||||
}
|
||||
|
||||
/* Because we used CoCreateInstance, we need to Initialize it, first. */
|
||||
instance = GetModuleHandle(NULL);
|
||||
if (instance == NULL) {
|
||||
SDL_SYS_HapticQuit();
|
||||
SDL_SetError("GetModuleHandle() failed with error code %d.",
|
||||
GetLastError());
|
||||
return -1;
|
||||
return SDL_SetError("GetModuleHandle() failed with error code %d.",
|
||||
GetLastError());
|
||||
}
|
||||
ret = IDirectInput8_Initialize(dinput, instance, DIRECTINPUT_VERSION);
|
||||
if (FAILED(ret)) {
|
||||
SDL_SYS_HapticQuit();
|
||||
DI_SetError("Initializing DirectInput device", ret);
|
||||
return -1;
|
||||
return DI_SetError("Initializing DirectInput device", ret);
|
||||
}
|
||||
|
||||
/* Look for haptic devices. */
|
||||
|
@ -191,8 +186,7 @@ SDL_SYS_HapticInit(void)
|
|||
DIEDFL_ATTACHEDONLY);
|
||||
if (FAILED(ret)) {
|
||||
SDL_SYS_HapticQuit();
|
||||
DI_SetError("Enumerating DirectInput devices", ret);
|
||||
return -1;
|
||||
return DI_SetError("Enumerating DirectInput devices", ret);
|
||||
}
|
||||
|
||||
if (!env || SDL_atoi(env)) {
|
||||
|
@ -411,8 +405,7 @@ SDL_SYS_HapticOpenFromXInput(SDL_Haptic * haptic, Uint8 userid)
|
|||
haptic->effects = (struct haptic_effect *)
|
||||
SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
|
||||
if (haptic->effects == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
/* Clear the memory */
|
||||
SDL_memset(haptic->effects, 0,
|
||||
|
@ -422,8 +415,7 @@ SDL_SYS_HapticOpenFromXInput(SDL_Haptic * haptic, Uint8 userid)
|
|||
if (haptic->hwdata == NULL) {
|
||||
SDL_free(haptic->effects);
|
||||
haptic->effects = NULL;
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
|
||||
|
||||
|
@ -690,8 +682,7 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
|||
haptic->hwdata = (struct haptic_hwdata *)
|
||||
SDL_malloc(sizeof(*haptic->hwdata));
|
||||
if (haptic->hwdata == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
|
||||
|
||||
|
@ -809,8 +800,7 @@ SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir, int naxes)
|
|||
/* Has axes. */
|
||||
rglDir = SDL_malloc(sizeof(LONG) * naxes);
|
||||
if (rglDir == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(rglDir, 0, sizeof(LONG) * naxes);
|
||||
effect->rglDirection = rglDir;
|
||||
|
@ -838,8 +828,7 @@ SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir, int naxes)
|
|||
return 0;
|
||||
|
||||
default:
|
||||
SDL_SetError("Haptic: Unknown direction type.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Unknown direction type.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -875,8 +864,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
|
|||
/* Envelope. */
|
||||
envelope = SDL_malloc(sizeof(DIENVELOPE));
|
||||
if (envelope == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(envelope, 0, sizeof(DIENVELOPE));
|
||||
dest->lpEnvelope = envelope;
|
||||
|
@ -887,8 +875,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
|
|||
if (dest->cAxes > 0) {
|
||||
axes = SDL_malloc(sizeof(DWORD) * dest->cAxes);
|
||||
if (axes == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */
|
||||
if (dest->cAxes > 1) {
|
||||
|
@ -907,8 +894,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
|
|||
hap_constant = &src->constant;
|
||||
constant = SDL_malloc(sizeof(DICONSTANTFORCE));
|
||||
if (constant == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(constant, 0, sizeof(DICONSTANTFORCE));
|
||||
|
||||
|
@ -951,8 +937,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
|
|||
hap_periodic = &src->periodic;
|
||||
periodic = SDL_malloc(sizeof(DIPERIODIC));
|
||||
if (periodic == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(periodic, 0, sizeof(DIPERIODIC));
|
||||
|
||||
|
@ -997,8 +982,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
|
|||
hap_condition = &src->condition;
|
||||
condition = SDL_malloc(sizeof(DICONDITION) * dest->cAxes);
|
||||
if (condition == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(condition, 0, sizeof(DICONDITION));
|
||||
|
||||
|
@ -1040,8 +1024,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
|
|||
hap_ramp = &src->ramp;
|
||||
ramp = SDL_malloc(sizeof(DIRAMPFORCE));
|
||||
if (ramp == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(ramp, 0, sizeof(DIRAMPFORCE));
|
||||
|
||||
|
@ -1079,8 +1062,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
|
|||
hap_custom = &src->custom;
|
||||
custom = SDL_malloc(sizeof(DICUSTOMFORCE));
|
||||
if (custom == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(custom, 0, sizeof(DICUSTOMFORCE));
|
||||
|
||||
|
@ -1124,8 +1106,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
|
|||
|
||||
|
||||
default:
|
||||
SDL_SetError("Haptic: Unknown effect type.");
|
||||
return -1;
|
||||
return SDL_SetError("Haptic: Unknown effect type.");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1358,8 +1339,7 @@ SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
|
|||
/* Run the effect. */
|
||||
ret = IDirectInputEffect_Start(effect->hweffect->ref, iter, 0);
|
||||
if (FAILED(ret)) {
|
||||
DI_SetError("Running the effect", ret);
|
||||
return -1;
|
||||
return DI_SetError("Running the effect", ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1381,8 +1361,7 @@ SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
|
|||
|
||||
ret = IDirectInputEffect_Stop(effect->hweffect->ref);
|
||||
if (FAILED(ret)) {
|
||||
DI_SetError("Unable to stop effect", ret);
|
||||
return -1;
|
||||
return DI_SetError("Unable to stop effect", ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1424,8 +1403,7 @@ SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic,
|
|||
|
||||
ret = IDirectInputEffect_GetEffectStatus(effect->hweffect->ref, &status);
|
||||
if (FAILED(ret)) {
|
||||
DI_SetError("Getting effect status", ret);
|
||||
return -1;
|
||||
return DI_SetError("Getting effect status", ret);
|
||||
}
|
||||
|
||||
if (status == 0)
|
||||
|
@ -1454,8 +1432,7 @@ SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain)
|
|||
ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device,
|
||||
DIPROP_FFGAIN, &dipdw.diph);
|
||||
if (FAILED(ret)) {
|
||||
DI_SetError("Setting gain", ret);
|
||||
return -1;
|
||||
return DI_SetError("Setting gain", ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1483,8 +1460,7 @@ SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
|
|||
ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device,
|
||||
DIPROP_AUTOCENTER, &dipdw.diph);
|
||||
if (FAILED(ret)) {
|
||||
DI_SetError("Setting autocenter", ret);
|
||||
return -1;
|
||||
return DI_SetError("Setting autocenter", ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1503,8 +1479,7 @@ SDL_SYS_HapticPause(SDL_Haptic * haptic)
|
|||
ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device,
|
||||
DISFFC_PAUSE);
|
||||
if (FAILED(ret)) {
|
||||
DI_SetError("Pausing the device", ret);
|
||||
return -1;
|
||||
return DI_SetError("Pausing the device", ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1523,8 +1498,7 @@ SDL_SYS_HapticUnpause(SDL_Haptic * haptic)
|
|||
ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device,
|
||||
DISFFC_CONTINUE);
|
||||
if (FAILED(ret)) {
|
||||
DI_SetError("Pausing the device", ret);
|
||||
return -1;
|
||||
return DI_SetError("Pausing the device", ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1548,8 +1522,7 @@ SDL_SYS_HapticStopAll(SDL_Haptic * haptic)
|
|||
ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device,
|
||||
DISFFC_STOPALL);
|
||||
if (FAILED(ret)) {
|
||||
DI_SetError("Stopping the device", ret);
|
||||
return -1;
|
||||
return DI_SetError("Stopping the device", ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -722,10 +722,9 @@ SDL_GameControllerAddMapping( const char *mappingString )
|
|||
} else {
|
||||
pControllerMapping = SDL_malloc( sizeof(*pControllerMapping) );
|
||||
if (!pControllerMapping) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_free( pchName );
|
||||
SDL_free( pchMapping );
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
#ifdef SDL_JOYSTICK_DINPUT
|
||||
if ( is_xinput_mapping )
|
||||
|
|
|
@ -303,8 +303,7 @@ SDL_JoystickGetBall(SDL_Joystick * joystick, int ball, int *dx, int *dy)
|
|||
joystick->balls[ball].dx = 0;
|
||||
joystick->balls[ball].dy = 0;
|
||||
} else {
|
||||
SDL_SetError("Joystick only has %d balls", joystick->nballs);
|
||||
retval = -1;
|
||||
return SDL_SetError("Joystick only has %d balls", joystick->nballs);
|
||||
}
|
||||
return (retval);
|
||||
}
|
||||
|
|
|
@ -77,31 +77,26 @@ SDL_SYS_JoystickInit(void)
|
|||
{
|
||||
int i = 0;
|
||||
if (Android_JNI_JoystickInit() < 0)
|
||||
return (-1);
|
||||
return -1;
|
||||
SYS_numjoysticks = Android_JNI_GetNumJoysticks();
|
||||
SYS_Joysticks = (SDL_Joystick **)SDL_malloc(SYS_numjoysticks*sizeof(SDL_Joystick *));
|
||||
if (SYS_Joysticks == NULL)
|
||||
{
|
||||
SDL_OutOfMemory();
|
||||
return (-1);
|
||||
if (SYS_Joysticks == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SYS_JoystickNames = (char **)SDL_malloc(SYS_numjoysticks*sizeof(char *));
|
||||
if (SYS_JoystickNames == NULL)
|
||||
{
|
||||
if (SYS_JoystickNames == NULL) {
|
||||
SDL_free(SYS_Joysticks);
|
||||
SYS_Joysticks = NULL;
|
||||
SDL_OutOfMemory();
|
||||
return (-1);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(SYS_JoystickNames, 0, (SYS_numjoysticks*sizeof(char *)));
|
||||
SDL_memset(SYS_Joysticks, 0, (SYS_numjoysticks*sizeof(SDL_Joystick *)));
|
||||
|
||||
for (i = 0; i < SYS_numjoysticks; i++)
|
||||
{
|
||||
for (i = 0; i < SYS_numjoysticks; i++) {
|
||||
SYS_JoystickNames[i] = Android_JNI_GetJoystickName(i);
|
||||
}
|
||||
|
||||
return (SYS_numjoysticks);
|
||||
return SYS_numjoysticks;
|
||||
}
|
||||
|
||||
int SDL_SYS_NumJoysticks()
|
||||
|
|
|
@ -125,8 +125,7 @@ extern "C"
|
|||
joystick->hwdata = (struct joystick_hwdata *)
|
||||
SDL_malloc(sizeof(*joystick->hwdata));
|
||||
if (joystick->hwdata == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return (-1);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
|
||||
stick = new BJoystick;
|
||||
|
@ -134,9 +133,8 @@ extern "C"
|
|||
|
||||
/* Open the requested joystick for use */
|
||||
if (stick->Open(SDL_joyport[device_index]) == B_ERROR) {
|
||||
SDL_SetError("Unable to open joystick");
|
||||
SDL_SYS_JoystickClose(joystick);
|
||||
return (-1);
|
||||
return SDL_SetError("Unable to open joystick");
|
||||
}
|
||||
|
||||
/* Set the joystick to calibrated mode */
|
||||
|
@ -152,9 +150,8 @@ extern "C"
|
|||
joystick->hwdata->new_hats = (uint8 *)
|
||||
SDL_malloc(joystick->nhats * sizeof(uint8));
|
||||
if (!joystick->hwdata->new_hats || !joystick->hwdata->new_axes) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_SYS_JoystickClose(joystick);
|
||||
return (-1);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
/* We're done! */
|
||||
|
|
|
@ -297,17 +297,15 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joy, int device_index)
|
|||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd == -1) {
|
||||
SDL_SetError("%s: %s", path, strerror(errno));
|
||||
return (-1);
|
||||
return SDL_SetError("%s: %s", path, strerror(errno));
|
||||
}
|
||||
|
||||
joy->instance_id = device_index;
|
||||
hw = (struct joystick_hwdata *)
|
||||
SDL_malloc(sizeof(struct joystick_hwdata));
|
||||
if (hw == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
close(fd);
|
||||
return (-1);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
joy->hwdata = hw;
|
||||
hw->fd = fd;
|
||||
|
@ -634,8 +632,7 @@ report_alloc(struct report *r, struct report_desc *rd, int repind)
|
|||
#endif
|
||||
|
||||
if (len < 0) {
|
||||
SDL_SetError("Negative HID report size");
|
||||
return (-1);
|
||||
return SDL_SetError("Negative HID report size");
|
||||
}
|
||||
r->size = len;
|
||||
|
||||
|
@ -647,15 +644,14 @@ report_alloc(struct report *r, struct report_desc *rd, int repind)
|
|||
r->size);
|
||||
#endif
|
||||
if (r->buf == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return (-1);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
} else {
|
||||
r->buf = NULL;
|
||||
}
|
||||
|
||||
r->status = SREPORT_CLEAN;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -169,7 +169,7 @@ HIDCreateOpenDeviceInterface(io_object_t hidDevice, recDevice * pDevice)
|
|||
&(pDevice->interface));
|
||||
if (S_OK != plugInResult)
|
||||
HIDReportErrorNum
|
||||
("CouldnÕt query HID class device interface from plugInInterface",
|
||||
("Couldn't query HID class device interface from plugInInterface",
|
||||
plugInResult);
|
||||
(*ppPlugInInterface)->Release(ppPlugInInterface);
|
||||
} else
|
||||
|
@ -724,14 +724,12 @@ SDL_SYS_JoystickInit(void)
|
|||
io_iterator_t portIterator = 0;
|
||||
|
||||
if (gpDeviceList) {
|
||||
SDL_SetError("Joystick: Device list already inited.");
|
||||
return -1;
|
||||
return SDL_SetError("Joystick: Device list already inited.");
|
||||
}
|
||||
|
||||
result = IOMasterPort(bootstrap_port, &masterPort);
|
||||
if (kIOReturnSuccess != result) {
|
||||
SDL_SetError("Joystick: IOMasterPort error with bootstrap_port.");
|
||||
return -1;
|
||||
return SDL_SetError("Joystick: IOMasterPort error with bootstrap_port.");
|
||||
}
|
||||
|
||||
/* Set up a matching dictionary to search I/O Registry by class name for all HID class devices. */
|
||||
|
@ -750,9 +748,8 @@ SDL_SYS_JoystickInit(void)
|
|||
CFDictionarySetValue (hidMatchDictionary, CFSTR (kIOHIDPrimaryUsagePageKey), refUsagePage);
|
||||
*/
|
||||
} else {
|
||||
SDL_SetError
|
||||
return SDL_SetError
|
||||
("Joystick: Failed to get HID CFMutableDictionaryRef via IOServiceMatching.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*/ Now search I/O Registry for matching devices. */
|
||||
|
@ -761,8 +758,7 @@ SDL_SYS_JoystickInit(void)
|
|||
&hidObjectIterator);
|
||||
/* Check for errors */
|
||||
if (kIOReturnSuccess != result) {
|
||||
SDL_SetError("Joystick: Couldn't create a HID object iterator.");
|
||||
return -1;
|
||||
return SDL_SetError("Joystick: Couldn't create a HID object iterator.");
|
||||
}
|
||||
if (!hidObjectIterator) { /* there are no joysticks */
|
||||
gpDeviceList = NULL;
|
||||
|
|
|
@ -73,8 +73,7 @@ SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
|
|||
int
|
||||
SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
||||
{
|
||||
SDL_SetError("Logic error: No joysticks available");
|
||||
return (-1);
|
||||
return SDL_SetError("Logic error: No joysticks available");
|
||||
}
|
||||
|
||||
/* Function to determine is this joystick is attached to the system right now */
|
||||
|
|
|
@ -122,15 +122,12 @@ SDL_SYS_JoystickClose(SDL_Joystick * joystick)
|
|||
[[SDLUIAccelerationDelegate sharedDelegate] shutdown];
|
||||
}
|
||||
SDL_SetError("No joystick open with that index");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Function to perform any system-specific joystick related cleanup */
|
||||
void
|
||||
SDL_SYS_JoystickQuit(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
|
||||
|
|
|
@ -387,8 +387,7 @@ JoystickInitWithUdev(void)
|
|||
SDL_assert(udev == NULL);
|
||||
udev = UDEV_udev_new();
|
||||
if (udev == NULL) {
|
||||
SDL_SetError("udev_new() failed");
|
||||
return -1;
|
||||
return SDL_SetError("udev_new() failed");
|
||||
}
|
||||
|
||||
udev_mon = UDEV_udev_monitor_new_from_netlink(udev, "udev");
|
||||
|
@ -400,8 +399,7 @@ JoystickInitWithUdev(void)
|
|||
|
||||
enumerate = UDEV_udev_enumerate_new(udev);
|
||||
if (enumerate == NULL) {
|
||||
SDL_SetError("udev_enumerate_new() failed");
|
||||
return -1;
|
||||
return SDL_SetError("udev_enumerate_new() failed");
|
||||
}
|
||||
|
||||
UDEV_udev_enumerate_add_match_subsystem(enumerate, "input");
|
||||
|
@ -725,15 +723,13 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
|||
int fd = -1;
|
||||
|
||||
if (item == NULL) {
|
||||
SDL_SetError("No such device");
|
||||
return -1;
|
||||
return SDL_SetError("No such device");
|
||||
}
|
||||
|
||||
fname = item->path;
|
||||
fd = open(fname, O_RDONLY, 0);
|
||||
if (fd < 0) {
|
||||
SDL_SetError("Unable to open %s", fname);
|
||||
return -1;
|
||||
return SDL_SetError("Unable to open %s", fname);
|
||||
}
|
||||
|
||||
joystick->instance_id = item->device_instance;
|
||||
|
@ -741,8 +737,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
|||
SDL_malloc(sizeof(*joystick->hwdata));
|
||||
if (joystick->hwdata == NULL) {
|
||||
close(fd);
|
||||
SDL_OutOfMemory();
|
||||
return (-1);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
|
||||
joystick->hwdata->item = item;
|
||||
|
@ -753,8 +748,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
|||
SDL_free(joystick->hwdata);
|
||||
joystick->hwdata = NULL;
|
||||
close(fd);
|
||||
SDL_OutOfMemory();
|
||||
return (-1);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
SDL_assert(item->hwdata == NULL);
|
||||
|
|
|
@ -113,13 +113,11 @@ int SDL_SYS_JoystickInit(void)
|
|||
|
||||
/* Start thread to read data */
|
||||
if((pad_sem = SDL_CreateSemaphore(1)) == NULL) {
|
||||
SDL_SetError("Can't create input semaphore\n");
|
||||
return -1;
|
||||
return SDL_SetError("Can't create input semaphore");
|
||||
}
|
||||
running = 1;
|
||||
if((thread = SDL_CreateThread(JoystickUpdate, "JoySitckThread",NULL)) == NULL) {
|
||||
SDL_SetError("Can't create input thread\n");
|
||||
return -1;
|
||||
return SDL_SetError("Can't create input thread");
|
||||
}
|
||||
|
||||
/* Create an accurate map from analog inputs (0 to 255)
|
||||
|
|
|
@ -159,7 +159,7 @@ typedef struct JoyStick_DeviceData_ JoyStick_DeviceData;
|
|||
static JoyStick_DeviceData *SYS_Joystick; /* array to hold joystick ID values */
|
||||
|
||||
/* local prototypes */
|
||||
static void SetDIerror(const char *function, HRESULT code);
|
||||
static int SetDIerror(const char *function, HRESULT code);
|
||||
static BOOL CALLBACK EnumJoysticksCallback(const DIDEVICEINSTANCE *
|
||||
pdidInstance, VOID * pContext);
|
||||
static BOOL CALLBACK EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE dev,
|
||||
|
@ -352,14 +352,14 @@ const DIDATAFORMAT c_dfDIJoystick2 = {
|
|||
|
||||
|
||||
/* Convert a DirectInput return code to a text message */
|
||||
static void
|
||||
static int
|
||||
SetDIerror(const char *function, HRESULT code)
|
||||
{
|
||||
/*
|
||||
SDL_SetError("%s() [%s]: %s", function,
|
||||
return SDL_SetError("%s() [%s]: %s", function,
|
||||
DXGetErrorString9A(code), DXGetErrorDescription9A(code));
|
||||
*/
|
||||
SDL_SetError("%s() DirectX error %d", function, code);
|
||||
return SDL_SetError("%s() DirectX error %d", function, code);
|
||||
}
|
||||
|
||||
|
||||
|
@ -565,17 +565,13 @@ SDL_JoystickThread(void *_data)
|
|||
|
||||
if (!RegisterClassEx (&wincl))
|
||||
{
|
||||
SDL_SetError("Failed to create register class for joystick autodetect.",
|
||||
GetLastError());
|
||||
return -1;
|
||||
return SDL_SetError("Failed to create register class for joystick autodetect.", GetLastError());
|
||||
}
|
||||
|
||||
messageWindow = (HWND)CreateWindowEx( 0, L"Message", NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL );
|
||||
if ( !messageWindow )
|
||||
{
|
||||
SDL_SetError("Failed to create message window for joystick autodetect.",
|
||||
GetLastError());
|
||||
return -1;
|
||||
return SDL_SetError("Failed to create message window for joystick autodetect.", GetLastError());
|
||||
}
|
||||
|
||||
SDL_memset(&dbh, 0x0, sizeof(dbh));
|
||||
|
@ -587,9 +583,7 @@ SDL_JoystickThread(void *_data)
|
|||
hNotify = RegisterDeviceNotification( messageWindow, &dbh, DEVICE_NOTIFY_WINDOW_HANDLE );
|
||||
if ( !hNotify )
|
||||
{
|
||||
SDL_SetError("Failed to create notify device for joystick autodetect.",
|
||||
GetLastError());
|
||||
return -1;
|
||||
return SDL_SetError("Failed to create notify device for joystick autodetect.", GetLastError());
|
||||
}
|
||||
|
||||
SDL_LockMutex( s_mutexJoyStickEnum );
|
||||
|
@ -674,8 +668,7 @@ SDL_SYS_JoystickInit(void)
|
|||
|
||||
result = WIN_CoInitialize();
|
||||
if (FAILED(result)) {
|
||||
SetDIerror("CoInitialize", result);
|
||||
return (-1);
|
||||
return SetDIerror("CoInitialize", result);
|
||||
}
|
||||
|
||||
coinitialized = SDL_TRUE;
|
||||
|
@ -685,24 +678,20 @@ SDL_SYS_JoystickInit(void)
|
|||
|
||||
if (FAILED(result)) {
|
||||
SDL_SYS_JoystickQuit();
|
||||
SetDIerror("CoCreateInstance", result);
|
||||
return (-1);
|
||||
return SetDIerror("CoCreateInstance", result);
|
||||
}
|
||||
|
||||
/* Because we used CoCreateInstance, we need to Initialize it, first. */
|
||||
instance = GetModuleHandle(NULL);
|
||||
if (instance == NULL) {
|
||||
SDL_SYS_JoystickQuit();
|
||||
SDL_SetError("GetModuleHandle() failed with error code %d.",
|
||||
GetLastError());
|
||||
return (-1);
|
||||
return SDL_SetError("GetModuleHandle() failed with error code %d.", GetLastError());
|
||||
}
|
||||
result = IDirectInput8_Initialize(dinput, instance, DIRECTINPUT_VERSION);
|
||||
|
||||
if (FAILED(result)) {
|
||||
SDL_SYS_JoystickQuit();
|
||||
SetDIerror("IDirectInput::Initialize", result);
|
||||
return (-1);
|
||||
return SetDIerror("IDirectInput::Initialize", result);
|
||||
}
|
||||
|
||||
s_mutexJoyStickEnum = SDL_CreateMutex();
|
||||
|
@ -967,8 +956,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
|||
joystick->hwdata =
|
||||
(struct joystick_hwdata *) SDL_malloc(sizeof(struct joystick_hwdata));
|
||||
if (joystick->hwdata == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return (-1);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(joystick->hwdata, 0, sizeof(struct joystick_hwdata));
|
||||
joystick->hwdata->buffered = 1;
|
||||
|
@ -1040,8 +1028,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
|||
IDirectInput8_CreateDevice(dinput,
|
||||
&(joystickdevice->dxdevice.guidInstance), &device, NULL);
|
||||
if (FAILED(result)) {
|
||||
SetDIerror("IDirectInput::CreateDevice", result);
|
||||
return (-1);
|
||||
return SetDIerror("IDirectInput::CreateDevice", result);
|
||||
}
|
||||
|
||||
/* Now get the IDirectInputDevice8 interface, instead. */
|
||||
|
@ -1053,8 +1040,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
|||
IDirectInputDevice8_Release(device);
|
||||
|
||||
if (FAILED(result)) {
|
||||
SetDIerror("IDirectInputDevice8::QueryInterface", result);
|
||||
return (-1);
|
||||
return SetDIerror("IDirectInputDevice8::QueryInterface", result);
|
||||
}
|
||||
|
||||
/* Aquire shared access. Exclusive access is required for forces,
|
||||
|
@ -1065,8 +1051,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
|||
DISCL_NONEXCLUSIVE |
|
||||
DISCL_BACKGROUND);
|
||||
if (FAILED(result)) {
|
||||
SetDIerror("IDirectInputDevice8::SetCooperativeLevel", result);
|
||||
return (-1);
|
||||
return SetDIerror("IDirectInputDevice8::SetCooperativeLevel", result);
|
||||
}
|
||||
|
||||
/* Use the extended data structure: DIJOYSTATE2. */
|
||||
|
@ -1074,8 +1059,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
|||
IDirectInputDevice8_SetDataFormat(joystick->hwdata->InputDevice,
|
||||
&c_dfDIJoystick2);
|
||||
if (FAILED(result)) {
|
||||
SetDIerror("IDirectInputDevice8::SetDataFormat", result);
|
||||
return (-1);
|
||||
return SetDIerror("IDirectInputDevice8::SetDataFormat", result);
|
||||
}
|
||||
|
||||
/* Get device capabilities */
|
||||
|
@ -1084,8 +1068,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
|||
&joystick->hwdata->Capabilities);
|
||||
|
||||
if (FAILED(result)) {
|
||||
SetDIerror("IDirectInputDevice8::GetCapabilities", result);
|
||||
return (-1);
|
||||
return SetDIerror("IDirectInputDevice8::GetCapabilities", result);
|
||||
}
|
||||
|
||||
/* Force capable? */
|
||||
|
@ -1094,8 +1077,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
|||
result = IDirectInputDevice8_Acquire(joystick->hwdata->InputDevice);
|
||||
|
||||
if (FAILED(result)) {
|
||||
SetDIerror("IDirectInputDevice8::Acquire", result);
|
||||
return (-1);
|
||||
return SetDIerror("IDirectInputDevice8::Acquire", result);
|
||||
}
|
||||
|
||||
/* reset all accuators. */
|
||||
|
@ -1106,17 +1088,14 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
|||
|
||||
/* Not necessarily supported, ignore if not supported.
|
||||
if (FAILED(result)) {
|
||||
SetDIerror("IDirectInputDevice8::SendForceFeedbackCommand",
|
||||
result);
|
||||
return (-1);
|
||||
return SetDIerror("IDirectInputDevice8::SendForceFeedbackCommand", result);
|
||||
}
|
||||
*/
|
||||
|
||||
result = IDirectInputDevice8_Unacquire(joystick->hwdata->InputDevice);
|
||||
|
||||
if (FAILED(result)) {
|
||||
SetDIerror("IDirectInputDevice8::Unacquire", result);
|
||||
return (-1);
|
||||
return SetDIerror("IDirectInputDevice8::Unacquire", result);
|
||||
}
|
||||
|
||||
/* Turn on auto-centering for a ForceFeedback device (until told
|
||||
|
@ -1131,8 +1110,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
|||
|
||||
/* Not necessarily supported, ignore if not supported.
|
||||
if (FAILED(result)) {
|
||||
SetDIerror("IDirectInputDevice8::SetProperty", result);
|
||||
return (-1);
|
||||
return SetDIerror("IDirectInputDevice8::SetProperty", result);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -1160,8 +1138,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
|||
* to use less reliable polling. */
|
||||
joystick->hwdata->buffered = 0;
|
||||
} else if (FAILED(result)) {
|
||||
SetDIerror("IDirectInputDevice8::SetProperty", result);
|
||||
return (-1);
|
||||
return SetDIerror("IDirectInputDevice8::SetProperty", result);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
|
|
|
@ -244,8 +244,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
|||
joystick->hwdata =
|
||||
(struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata));
|
||||
if (joystick->hwdata == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return (-1);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
|
||||
|
||||
|
|
|
@ -64,8 +64,7 @@ SDL_InitBeApp(void)
|
|||
if (SDL_BeAppActive <= 0) {
|
||||
SDL_AppThread = SDL_CreateThread(StartBeApp, "SDLApplication", NULL);
|
||||
if (SDL_AppThread == NULL) {
|
||||
SDL_SetError("Couldn't create BApplication thread");
|
||||
return (-1);
|
||||
return SDL_SetError("Couldn't create BApplication thread");
|
||||
}
|
||||
|
||||
/* Change working to directory to that of executable */
|
||||
|
|
|
@ -82,9 +82,8 @@ int
|
|||
SDL_GetRenderDriverInfo(int index, SDL_RendererInfo * info)
|
||||
{
|
||||
if (index < 0 || index >= SDL_GetNumRenderDrivers()) {
|
||||
SDL_SetError("index must be in the range of 0 - %d",
|
||||
SDL_GetNumRenderDrivers() - 1);
|
||||
return -1;
|
||||
return SDL_SetError("index must be in the range of 0 - %d",
|
||||
SDL_GetNumRenderDrivers() - 1);
|
||||
}
|
||||
*info = render_drivers[index]->info;
|
||||
return 0;
|
||||
|
@ -695,8 +694,7 @@ SDL_UpdateTextureYUV(SDL_Texture * texture, const SDL_Rect * rect,
|
|||
temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
|
||||
temp_pixels = SDL_malloc(rect->h * temp_pitch);
|
||||
if (!temp_pixels) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
|
||||
rect->w, rect->h, temp_pixels, temp_pitch);
|
||||
|
@ -732,8 +730,7 @@ SDL_UpdateTextureNative(SDL_Texture * texture, const SDL_Rect * rect,
|
|||
temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
|
||||
temp_pixels = SDL_malloc(rect->h * temp_pitch);
|
||||
if (!temp_pixels) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_ConvertPixels(rect->w, rect->h,
|
||||
texture->format, pixels, pitch,
|
||||
|
@ -800,8 +797,7 @@ SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect,
|
|||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
|
||||
if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
|
||||
SDL_SetError("SDL_LockTexture(): texture must be streaming");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_LockTexture(): texture must be streaming");
|
||||
}
|
||||
|
||||
if (!rect) {
|
||||
|
@ -897,8 +893,7 @@ int
|
|||
SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
if (!SDL_RenderTargetSupported(renderer)) {
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
if (texture == renderer->target) {
|
||||
/* Nothing to do! */
|
||||
|
@ -909,12 +904,10 @@ SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
if (texture) {
|
||||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
if (renderer != texture->renderer) {
|
||||
SDL_SetError("Texture was not created with this renderer");
|
||||
return -1;
|
||||
return SDL_SetError("Texture was not created with this renderer");
|
||||
}
|
||||
if (texture->access != SDL_TEXTUREACCESS_TARGET) {
|
||||
SDL_SetError("Texture not created with SDL_TEXTUREACCESS_TARGET");
|
||||
return -1;
|
||||
return SDL_SetError("Texture not created with SDL_TEXTUREACCESS_TARGET");
|
||||
}
|
||||
if (texture->native) {
|
||||
/* Always render to the native texture */
|
||||
|
@ -979,8 +972,7 @@ UpdateLogicalSize(SDL_Renderer *renderer)
|
|||
SDL_GetWindowSize(renderer->window, &w, &h);
|
||||
} else {
|
||||
/* FIXME */
|
||||
SDL_SetError("Internal error: No way to get output resolution");
|
||||
return -1;
|
||||
return SDL_SetError("Internal error: No way to get output resolution");
|
||||
}
|
||||
|
||||
want_aspect = (float)renderer->logical_w / renderer->logical_h;
|
||||
|
@ -1198,8 +1190,7 @@ RenderDrawPointsWithRects(SDL_Renderer * renderer,
|
|||
|
||||
frects = SDL_stack_alloc(SDL_FRect, count);
|
||||
if (!frects) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < count; ++i) {
|
||||
frects[i].x = points[i].x * renderer->scale.x;
|
||||
|
@ -1226,8 +1217,7 @@ SDL_RenderDrawPoints(SDL_Renderer * renderer,
|
|||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!points) {
|
||||
SDL_SetError("SDL_RenderDrawPoints(): Passed NULL points");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_RenderDrawPoints(): Passed NULL points");
|
||||
}
|
||||
if (count < 1) {
|
||||
return 0;
|
||||
|
@ -1243,8 +1233,7 @@ SDL_RenderDrawPoints(SDL_Renderer * renderer,
|
|||
|
||||
fpoints = SDL_stack_alloc(SDL_FPoint, count);
|
||||
if (!fpoints) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < count; ++i) {
|
||||
fpoints[i].x = points[i].x * renderer->scale.x;
|
||||
|
@ -1282,8 +1271,7 @@ RenderDrawLinesWithRects(SDL_Renderer * renderer,
|
|||
|
||||
frects = SDL_stack_alloc(SDL_FRect, count-1);
|
||||
if (!frects) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
status = 0;
|
||||
|
@ -1338,8 +1326,7 @@ SDL_RenderDrawLines(SDL_Renderer * renderer,
|
|||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!points) {
|
||||
SDL_SetError("SDL_RenderDrawLines(): Passed NULL points");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_RenderDrawLines(): Passed NULL points");
|
||||
}
|
||||
if (count < 2) {
|
||||
return 0;
|
||||
|
@ -1355,8 +1342,7 @@ SDL_RenderDrawLines(SDL_Renderer * renderer,
|
|||
|
||||
fpoints = SDL_stack_alloc(SDL_FPoint, count);
|
||||
if (!fpoints) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < count; ++i) {
|
||||
fpoints[i].x = points[i].x * renderer->scale.x;
|
||||
|
@ -1408,8 +1394,7 @@ SDL_RenderDrawRects(SDL_Renderer * renderer,
|
|||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!rects) {
|
||||
SDL_SetError("SDL_RenderDrawRects(): Passed NULL rects");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_RenderDrawRects(): Passed NULL rects");
|
||||
}
|
||||
if (count < 1) {
|
||||
return 0;
|
||||
|
@ -1455,8 +1440,7 @@ SDL_RenderFillRects(SDL_Renderer * renderer,
|
|||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!rects) {
|
||||
SDL_SetError("SDL_RenderFillRects(): Passed NULL rects");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_RenderFillRects(): Passed NULL rects");
|
||||
}
|
||||
if (count < 1) {
|
||||
return 0;
|
||||
|
@ -1468,8 +1452,7 @@ SDL_RenderFillRects(SDL_Renderer * renderer,
|
|||
|
||||
frects = SDL_stack_alloc(SDL_FRect, count);
|
||||
if (!frects) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < count; ++i) {
|
||||
frects[i].x = rects[i].x * renderer->scale.x;
|
||||
|
@ -1497,8 +1480,7 @@ SDL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
|
||||
if (renderer != texture->renderer) {
|
||||
SDL_SetError("Texture was not created with this renderer");
|
||||
return -1;
|
||||
return SDL_SetError("Texture was not created with this renderer");
|
||||
}
|
||||
|
||||
real_srcrect.x = 0;
|
||||
|
@ -1566,12 +1548,10 @@ SDL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
|
||||
if (renderer != texture->renderer) {
|
||||
SDL_SetError("Texture was not created with this renderer");
|
||||
return -1;
|
||||
return SDL_SetError("Texture was not created with this renderer");
|
||||
}
|
||||
if (!renderer->RenderCopyEx) {
|
||||
SDL_SetError("Renderer does not support RenderCopyEx");
|
||||
return -1;
|
||||
return SDL_SetError("Renderer does not support RenderCopyEx");
|
||||
}
|
||||
|
||||
real_srcrect.x = 0;
|
||||
|
@ -1623,8 +1603,7 @@ SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!renderer->RenderReadPixels) {
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
if (!format) {
|
||||
|
@ -1729,8 +1708,7 @@ int SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh)
|
|||
return renderer->GL_BindTexture(renderer, texture, texw, texh);
|
||||
}
|
||||
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int SDL_GL_UnbindTexture(SDL_Texture *texture)
|
||||
|
@ -1743,8 +1721,7 @@ int SDL_GL_UnbindTexture(SDL_Texture *texture)
|
|||
return renderer->GL_UnbindTexture(renderer, texture);
|
||||
}
|
||||
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -896,8 +896,7 @@ SDL_SW_SetupYUVDisplay(SDL_SW_YUVTexture * swdata, Uint32 target_format)
|
|||
|
||||
if (!SDL_PixelFormatEnumToMasks
|
||||
(target_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask) || bpp < 15) {
|
||||
SDL_SetError("Unsupported YUV destination format");
|
||||
return -1;
|
||||
return SDL_SetError("Unsupported YUV destination format");
|
||||
}
|
||||
|
||||
swdata->target_format = target_format;
|
||||
|
@ -1057,8 +1056,8 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
|
|||
swdata->colortab = (int *) SDL_malloc(4 * 256 * sizeof(int));
|
||||
swdata->rgb_2_pix = (Uint32 *) SDL_malloc(3 * 768 * sizeof(Uint32));
|
||||
if (!swdata->pixels || !swdata->colortab || !swdata->rgb_2_pix) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_SW_DestroyYUVTexture(swdata);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1197,9 +1196,8 @@ SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
|||
if (rect
|
||||
&& (rect->x != 0 || rect->y != 0 || rect->w != swdata->w
|
||||
|| rect->h != swdata->h)) {
|
||||
SDL_SetError
|
||||
return SDL_SetError
|
||||
("YV12 and IYUV textures only support full surface locks");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1309,8 +1307,7 @@ SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
|
|||
Cb = lum + 3;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unsupported YUV format in copy");
|
||||
return (-1);
|
||||
return SDL_SetError("Unsupported YUV format in copy");
|
||||
}
|
||||
mod = (pitch / SDL_BYTESPERPIXEL(target_format));
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@ typedef struct
|
|||
float u, v;
|
||||
} Vertex;
|
||||
|
||||
static void
|
||||
static int
|
||||
D3D_SetError(const char *prefix, HRESULT result)
|
||||
{
|
||||
const char *error;
|
||||
|
@ -322,7 +322,7 @@ D3D_SetError(const char *prefix, HRESULT result)
|
|||
error = "UNKNOWN";
|
||||
break;
|
||||
}
|
||||
SDL_SetError("%s: %s", prefix, error);
|
||||
return SDL_SetError("%s: %s", prefix, error);
|
||||
}
|
||||
|
||||
static D3DFORMAT
|
||||
|
@ -373,8 +373,7 @@ D3D_Reset(SDL_Renderer * renderer)
|
|||
/* Don't worry about it, we'll reset later... */
|
||||
return 0;
|
||||
} else {
|
||||
D3D_SetError("Reset()", result);
|
||||
return -1;
|
||||
return D3D_SetError("Reset()", result);
|
||||
}
|
||||
}
|
||||
IDirect3DDevice9_SetVertexShader(data->device, NULL);
|
||||
|
@ -422,8 +421,7 @@ D3D_ActivateRenderer(SDL_Renderer * renderer)
|
|||
result = IDirect3DDevice9_BeginScene(data->device);
|
||||
}
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("BeginScene()", result);
|
||||
return -1;
|
||||
return D3D_SetError("BeginScene()", result);
|
||||
}
|
||||
data->beginScene = SDL_FALSE;
|
||||
}
|
||||
|
@ -704,8 +702,7 @@ D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
|
||||
data = (D3D_TextureData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
data->scaleMode = GetScaleQuality();
|
||||
|
||||
|
@ -732,8 +729,7 @@ D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
PixelFormatToD3DFMT(texture->format),
|
||||
pool, &data->texture, NULL);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("CreateTexture()", result);
|
||||
return -1;
|
||||
return D3D_SetError("CreateTexture()", result);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -767,8 +763,7 @@ D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
}
|
||||
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("LockRect()", result);
|
||||
return -1;
|
||||
return D3D_SetError("LockRect()", result);
|
||||
}
|
||||
|
||||
src = pixels;
|
||||
|
@ -804,8 +799,7 @@ D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
|
||||
result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("LockRect()", result);
|
||||
return -1;
|
||||
return D3D_SetError("LockRect()", result);
|
||||
}
|
||||
*pixels = locked.pBits;
|
||||
*pitch = locked.Pitch;
|
||||
|
@ -881,13 +875,11 @@ D3D_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
texturedata = (D3D_TextureData *) texture->driverdata;
|
||||
result = IDirect3DTexture9_GetSurfaceLevel(texturedata->texture, 0, &data->currentRenderTarget);
|
||||
if(FAILED(result)) {
|
||||
D3D_SetError("GetSurfaceLevel()", result);
|
||||
return -1;
|
||||
return D3D_SetError("GetSurfaceLevel()", result);
|
||||
}
|
||||
result = IDirect3DDevice9_SetRenderTarget(data->device, 0, data->currentRenderTarget);
|
||||
if(FAILED(result)) {
|
||||
D3D_SetError("SetRenderTarget()", result);
|
||||
return -1;
|
||||
return D3D_SetError("SetRenderTarget()", result);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -936,8 +928,7 @@ D3D_RenderClear(SDL_Renderer * renderer)
|
|||
}
|
||||
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("Clear()", result);
|
||||
return -1;
|
||||
return D3D_SetError("Clear()", result);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -997,8 +988,7 @@ D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points,
|
|||
IDirect3DDevice9_SetTexture(data->device, 0,
|
||||
(IDirect3DBaseTexture9 *) 0);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("SetTexture()", result);
|
||||
return -1;
|
||||
return D3D_SetError("SetTexture()", result);
|
||||
}
|
||||
|
||||
color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
|
||||
|
@ -1017,8 +1007,7 @@ D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points,
|
|||
vertices, sizeof(*vertices));
|
||||
SDL_stack_free(vertices);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("DrawPrimitiveUP()", result);
|
||||
return -1;
|
||||
return D3D_SetError("DrawPrimitiveUP()", result);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1043,8 +1032,7 @@ D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points,
|
|||
IDirect3DDevice9_SetTexture(data->device, 0,
|
||||
(IDirect3DBaseTexture9 *) 0);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("SetTexture()", result);
|
||||
return -1;
|
||||
return D3D_SetError("SetTexture()", result);
|
||||
}
|
||||
|
||||
color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
|
||||
|
@ -1073,8 +1061,7 @@ D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points,
|
|||
|
||||
SDL_stack_free(vertices);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("DrawPrimitiveUP()", result);
|
||||
return -1;
|
||||
return D3D_SetError("DrawPrimitiveUP()", result);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1100,8 +1087,7 @@ D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects,
|
|||
IDirect3DDevice9_SetTexture(data->device, 0,
|
||||
(IDirect3DBaseTexture9 *) 0);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("SetTexture()", result);
|
||||
return -1;
|
||||
return D3D_SetError("SetTexture()", result);
|
||||
}
|
||||
|
||||
color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
|
||||
|
@ -1146,8 +1132,7 @@ D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects,
|
|||
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN,
|
||||
2, vertices, sizeof(*vertices));
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("DrawPrimitiveUP()", result);
|
||||
return -1;
|
||||
return D3D_SetError("DrawPrimitiveUP()", result);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -1224,28 +1209,24 @@ D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
IDirect3DDevice9_SetTexture(data->device, 0, (IDirect3DBaseTexture9 *)
|
||||
texturedata->texture);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("SetTexture()", result);
|
||||
return -1;
|
||||
return D3D_SetError("SetTexture()", result);
|
||||
}
|
||||
if (shader) {
|
||||
result = IDirect3DDevice9_SetPixelShader(data->device, shader);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("SetShader()", result);
|
||||
return -1;
|
||||
return D3D_SetError("SetShader()", result);
|
||||
}
|
||||
}
|
||||
result =
|
||||
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2,
|
||||
vertices, sizeof(*vertices));
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("DrawPrimitiveUP()", result);
|
||||
return -1;
|
||||
return D3D_SetError("DrawPrimitiveUP()", result);
|
||||
}
|
||||
if (shader) {
|
||||
result = IDirect3DDevice9_SetPixelShader(data->device, NULL);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("SetShader()", result);
|
||||
return -1;
|
||||
return D3D_SetError("SetShader()", result);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -1348,28 +1329,24 @@ D3D_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
IDirect3DDevice9_SetTexture(data->device, 0, (IDirect3DBaseTexture9 *)
|
||||
texturedata->texture);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("SetTexture()", result);
|
||||
return -1;
|
||||
return D3D_SetError("SetTexture()", result);
|
||||
}
|
||||
if (shader) {
|
||||
result = IDirect3DDevice9_SetPixelShader(data->device, shader);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("SetShader()", result);
|
||||
return -1;
|
||||
return D3D_SetError("SetShader()", result);
|
||||
}
|
||||
}
|
||||
result =
|
||||
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2,
|
||||
vertices, sizeof(*vertices));
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("DrawPrimitiveUP()", result);
|
||||
return -1;
|
||||
return D3D_SetError("DrawPrimitiveUP()", result);
|
||||
}
|
||||
if (shader) {
|
||||
result = IDirect3DDevice9_SetPixelShader(data->device, NULL);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("SetShader()", result);
|
||||
return -1;
|
||||
return D3D_SetError("SetShader()", result);
|
||||
}
|
||||
}
|
||||
ID3DXMatrixStack_Pop(data->matrixStack);
|
||||
|
@ -1394,30 +1371,26 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
|
||||
result = IDirect3DDevice9_GetBackBuffer(data->device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("GetBackBuffer()", result);
|
||||
return -1;
|
||||
return D3D_SetError("GetBackBuffer()", result);
|
||||
}
|
||||
|
||||
result = IDirect3DSurface9_GetDesc(backBuffer, &desc);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("GetDesc()", result);
|
||||
IDirect3DSurface9_Release(backBuffer);
|
||||
return -1;
|
||||
return D3D_SetError("GetDesc()", result);
|
||||
}
|
||||
|
||||
result = IDirect3DDevice9_CreateOffscreenPlainSurface(data->device, desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &surface, NULL);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("CreateOffscreenPlainSurface()", result);
|
||||
IDirect3DSurface9_Release(backBuffer);
|
||||
return -1;
|
||||
return D3D_SetError("CreateOffscreenPlainSurface()", result);
|
||||
}
|
||||
|
||||
result = IDirect3DDevice9_GetRenderTargetData(data->device, backBuffer, surface);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("GetRenderTargetData()", result);
|
||||
IDirect3DSurface9_Release(surface);
|
||||
IDirect3DSurface9_Release(backBuffer);
|
||||
return -1;
|
||||
return D3D_SetError("GetRenderTargetData()", result);
|
||||
}
|
||||
|
||||
d3drect.left = rect->x;
|
||||
|
@ -1427,10 +1400,9 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
|
||||
result = IDirect3DSurface9_LockRect(surface, &locked, &d3drect, D3DLOCK_READONLY);
|
||||
if (FAILED(result)) {
|
||||
D3D_SetError("LockRect()", result);
|
||||
IDirect3DSurface9_Release(surface);
|
||||
IDirect3DSurface9_Release(backBuffer);
|
||||
return -1;
|
||||
return D3D_SetError("LockRect()", result);
|
||||
}
|
||||
|
||||
SDL_ConvertPixels(rect->w, rect->h,
|
||||
|
|
|
@ -208,8 +208,7 @@ GL_LoadFunctions(GL_RenderData * data)
|
|||
do { \
|
||||
data->func = SDL_GL_GetProcAddress(#func); \
|
||||
if ( ! data->func ) { \
|
||||
SDL_SetError("Couldn't load GL function %s: %s\n", #func, SDL_GetError()); \
|
||||
return -1; \
|
||||
return SDL_SetError("Couldn't load GL function %s: %s\n", #func, SDL_GetError()); \
|
||||
} \
|
||||
} while ( 0 );
|
||||
#endif /* __SDL_NOGETPROCADDR__ */
|
||||
|
@ -500,15 +499,13 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
|
||||
if (!convert_format(renderdata, texture->format, &internalFormat,
|
||||
&format, &type)) {
|
||||
SDL_SetError("Texture format %s not supported by OpenGL",
|
||||
SDL_GetPixelFormatName(texture->format));
|
||||
return -1;
|
||||
return SDL_SetError("Texture format %s not supported by OpenGL",
|
||||
SDL_GetPixelFormatName(texture->format));
|
||||
}
|
||||
|
||||
data = (GL_TextureData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
|
||||
|
@ -522,9 +519,8 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
}
|
||||
data->pixels = SDL_calloc(1, size);
|
||||
if (!data->pixels) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_free(data);
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -746,8 +742,7 @@ GL_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
/* Check FBO status */
|
||||
status = data->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
|
||||
SDL_SetError("glFramebufferTexture2DEXT() failed");
|
||||
return -1;
|
||||
return SDL_SetError("glFramebufferTexture2DEXT() failed");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1157,8 +1152,7 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
||||
temp_pixels = SDL_malloc(rect->h * temp_pitch);
|
||||
if (!temp_pixels) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
convert_format(data, temp_format, &internalFormat, &format, &type);
|
||||
|
|
|
@ -135,7 +135,7 @@ typedef struct
|
|||
GLES_FBOList *fbo;
|
||||
} GLES_TextureData;
|
||||
|
||||
static void
|
||||
static int
|
||||
GLES_SetError(const char *prefix, GLenum result)
|
||||
{
|
||||
const char *error;
|
||||
|
@ -166,7 +166,7 @@ GLES_SetError(const char *prefix, GLenum result)
|
|||
error = "UNKNOWN";
|
||||
break;
|
||||
}
|
||||
SDL_SetError("%s: %s", prefix, error);
|
||||
return SDL_SetError("%s: %s", prefix, error);
|
||||
}
|
||||
|
||||
static int GLES_LoadFunctions(GLES_RenderData * data)
|
||||
|
@ -186,8 +186,7 @@ static int GLES_LoadFunctions(GLES_RenderData * data)
|
|||
do { \
|
||||
data->func = SDL_GL_GetProcAddress(#func); \
|
||||
if ( ! data->func ) { \
|
||||
SDL_SetError("Couldn't load GLES function %s: %s\n", #func, SDL_GetError()); \
|
||||
return -1; \
|
||||
return SDL_SetError("Couldn't load GLES function %s: %s\n", #func, SDL_GetError()); \
|
||||
} \
|
||||
} while ( 0 );
|
||||
#endif /* _SDL_NOGETPROCADDR_ */
|
||||
|
@ -442,23 +441,20 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Texture format not supported");
|
||||
return -1;
|
||||
return SDL_SetError("Texture format not supported");
|
||||
}
|
||||
|
||||
data = (GLES_TextureData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
|
||||
data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
|
||||
data->pixels = SDL_calloc(1, texture->h * data->pitch);
|
||||
if (!data->pixels) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_free(data);
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -495,8 +491,7 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
|
||||
result = renderdata->glGetError();
|
||||
if (result != GL_NO_ERROR) {
|
||||
GLES_SetError("glTexImage2D()", result);
|
||||
return -1;
|
||||
return GLES_SetError("glTexImage2D()", result);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -521,17 +516,13 @@ GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
/* Reformat the texture data into a tightly packed array */
|
||||
srcPitch = rect->w * SDL_BYTESPERPIXEL(texture->format);
|
||||
src = (Uint8 *)pixels;
|
||||
if (pitch != srcPitch)
|
||||
{
|
||||
if (pitch != srcPitch) {
|
||||
blob = (Uint8 *)SDL_malloc(srcPitch * rect->h);
|
||||
if (!blob)
|
||||
{
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
if (!blob) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
src = blob;
|
||||
for (y = 0; y < rect->h; ++y)
|
||||
{
|
||||
for (y = 0; y < rect->h; ++y) {
|
||||
SDL_memcpy(src, pixels, srcPitch);
|
||||
src += srcPitch;
|
||||
pixels = (Uint8 *)pixels + pitch;
|
||||
|
@ -559,8 +550,7 @@ GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
|
||||
if (renderdata->glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
SDL_SetError("Failed to update texture");
|
||||
return -1;
|
||||
return SDL_SetError("Failed to update texture");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -613,8 +603,7 @@ GLES_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
/* Check FBO status */
|
||||
status = data->glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE_OES) {
|
||||
SDL_SetError("glFramebufferTexture2DOES() failed");
|
||||
return -1;
|
||||
return SDL_SetError("glFramebufferTexture2DOES() failed");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1006,8 +995,7 @@ GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
||||
temp_pixels = SDL_malloc(rect->h * temp_pitch);
|
||||
if (!temp_pixels) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
|
|
|
@ -189,8 +189,7 @@ static int GLES2_LoadFunctions(GLES2_DriverContext * data)
|
|||
do { \
|
||||
data->func = SDL_GL_GetProcAddress(#func); \
|
||||
if ( ! data->func ) { \
|
||||
SDL_SetError("Couldn't load GLES2 function %s: %s\n", #func, SDL_GetError()); \
|
||||
return -1; \
|
||||
return SDL_SetError("Couldn't load GLES2 function %s: %s\n", #func, SDL_GetError()); \
|
||||
} \
|
||||
} while ( 0 );
|
||||
#endif /* _SDL_NOGETPROCADDR_ */
|
||||
|
@ -372,16 +371,13 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Texture format not supported");
|
||||
return -1;
|
||||
return SDL_SetError("Texture format not supported");
|
||||
}
|
||||
|
||||
/* Allocate a texture struct */
|
||||
tdata = (GLES2_TextureData *)SDL_calloc(1, sizeof(GLES2_TextureData));
|
||||
if (!tdata)
|
||||
{
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
if (!tdata) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
tdata->texture = 0;
|
||||
tdata->texture_type = GL_TEXTURE_2D;
|
||||
|
@ -390,15 +386,12 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
scaleMode = GetScaleQuality();
|
||||
|
||||
/* Allocate a blob for image data */
|
||||
if (texture->access == SDL_TEXTUREACCESS_STREAMING)
|
||||
{
|
||||
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
|
||||
tdata->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
|
||||
tdata->pixel_data = SDL_calloc(1, tdata->pitch * texture->h);
|
||||
if (!tdata->pixel_data)
|
||||
{
|
||||
SDL_OutOfMemory();
|
||||
if (!tdata->pixel_data) {
|
||||
SDL_free(tdata);
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -414,10 +407,9 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
rdata->glTexImage2D(tdata->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL);
|
||||
if (rdata->glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
SDL_SetError("Texture creation failed");
|
||||
rdata->glDeleteTextures(1, &tdata->texture);
|
||||
SDL_free(tdata);
|
||||
return -1;
|
||||
return SDL_SetError("Texture creation failed");
|
||||
}
|
||||
texture->driverdata = tdata;
|
||||
|
||||
|
@ -497,13 +489,10 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
|
|||
/* Reformat the texture data into a tightly packed array */
|
||||
srcPitch = rect->w * SDL_BYTESPERPIXEL(texture->format);
|
||||
src = (Uint8 *)pixels;
|
||||
if (pitch != srcPitch)
|
||||
{
|
||||
if (pitch != srcPitch) {
|
||||
blob = (Uint8 *)SDL_malloc(srcPitch * rect->h);
|
||||
if (!blob)
|
||||
{
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
if (!blob) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
src = blob;
|
||||
for (y = 0; y < rect->h; ++y)
|
||||
|
@ -533,10 +522,8 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
|
|||
SDL_free(blob);
|
||||
}
|
||||
|
||||
if (rdata->glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
SDL_SetError("Failed to update texture");
|
||||
return -1;
|
||||
if (rdata->glGetError() != GL_NO_ERROR) {
|
||||
return SDL_SetError("Failed to update texture");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -558,8 +545,7 @@ GLES2_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
/* Check FBO status */
|
||||
status = data->glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE) {
|
||||
SDL_SetError("glFramebufferTexture2D() failed");
|
||||
return -1;
|
||||
return SDL_SetError("glFramebufferTexture2D() failed");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -636,9 +622,9 @@ GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex,
|
|||
rdata->glGetProgramiv(entry->id, GL_LINK_STATUS, &linkSuccessful);
|
||||
if (rdata->glGetError() != GL_NO_ERROR || !linkSuccessful)
|
||||
{
|
||||
SDL_SetError("Failed to link shader program");
|
||||
rdata->glDeleteProgram(entry->id);
|
||||
SDL_free(entry);
|
||||
SDL_SetError("Failed to link shader program");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -930,10 +916,8 @@ GLES2_SetOrthographicProjection(SDL_Renderer *renderer)
|
|||
locProjection = rdata->current_program->uniform_locations[GLES2_UNIFORM_PROJECTION];
|
||||
rdata->glGetError();
|
||||
rdata->glUniformMatrix4fv(locProjection, 1, GL_FALSE, (GLfloat *)projection);
|
||||
if (rdata->glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
SDL_SetError("Failed to set orthographic projection");
|
||||
return -1;
|
||||
if (rdata->glGetError() != GL_NO_ERROR) {
|
||||
return SDL_SetError("Failed to set orthographic projection");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1066,8 +1050,7 @@ GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int cou
|
|||
|
||||
/* Emit the specified vertices as points */
|
||||
vertices = SDL_stack_alloc(GLfloat, count * 2);
|
||||
for (idx = 0; idx < count; ++idx)
|
||||
{
|
||||
for (idx = 0; idx < count; ++idx) {
|
||||
GLfloat x = points[idx].x + 0.5f;
|
||||
GLfloat y = points[idx].y + 0.5f;
|
||||
|
||||
|
@ -1078,10 +1061,8 @@ GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int cou
|
|||
rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
rdata->glDrawArrays(GL_POINTS, 0, count);
|
||||
SDL_stack_free(vertices);
|
||||
if (rdata->glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
SDL_SetError("Failed to render lines");
|
||||
return -1;
|
||||
if (rdata->glGetError() != GL_NO_ERROR) {
|
||||
return SDL_SetError("Failed to render lines");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1099,8 +1080,7 @@ GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, int coun
|
|||
|
||||
/* Emit a line strip including the specified vertices */
|
||||
vertices = SDL_stack_alloc(GLfloat, count * 2);
|
||||
for (idx = 0; idx < count; ++idx)
|
||||
{
|
||||
for (idx = 0; idx < count; ++idx) {
|
||||
GLfloat x = points[idx].x + 0.5f;
|
||||
GLfloat y = points[idx].y + 0.5f;
|
||||
|
||||
|
@ -1117,10 +1097,8 @@ GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, int coun
|
|||
rdata->glDrawArrays(GL_POINTS, count-1, 1);
|
||||
}
|
||||
SDL_stack_free(vertices);
|
||||
if (rdata->glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
SDL_SetError("Failed to render lines");
|
||||
return -1;
|
||||
if (rdata->glGetError() != GL_NO_ERROR) {
|
||||
return SDL_SetError("Failed to render lines");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1157,10 +1135,8 @@ GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count)
|
|||
rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
if (rdata->glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
SDL_SetError("Failed to render lines");
|
||||
return -1;
|
||||
if (rdata->glGetError() != GL_NO_ERROR) {
|
||||
return SDL_SetError("Failed to render lines");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1315,10 +1291,8 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s
|
|||
texCoords[7] = (srcrect->y + srcrect->h) / (GLfloat)texture->h;
|
||||
rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords);
|
||||
rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
if (rdata->glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
SDL_SetError("Failed to render texture");
|
||||
return -1;
|
||||
if (rdata->glGetError() != GL_NO_ERROR) {
|
||||
return SDL_SetError("Failed to render texture");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1499,10 +1473,8 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
|
|||
rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_CENTER);
|
||||
rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE);
|
||||
if (rdata->glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
SDL_SetError("Failed to render texture");
|
||||
return -1;
|
||||
if (rdata->glGetError() != GL_NO_ERROR) {
|
||||
return SDL_SetError("Failed to render texture");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1525,8 +1497,7 @@ GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
||||
temp_pixels = SDL_malloc(rect->h * temp_pitch);
|
||||
if (!temp_pixels) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
|
|
|
@ -493,9 +493,8 @@ PSP_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
|
||||
if(!psp_texture->data)
|
||||
{
|
||||
SDL_OutOfMemory();
|
||||
SDL_free(psp_texture);
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
texture->driverdata = psp_texture;
|
||||
|
||||
|
|
|
@ -159,8 +159,7 @@ SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect,
|
|||
}
|
||||
return 0;
|
||||
default:
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,8 +188,7 @@ SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect,
|
|||
}
|
||||
return 0;
|
||||
default:
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,14 +199,12 @@ SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect,
|
|||
SDL_Rect clipped;
|
||||
|
||||
if (!dst) {
|
||||
SDL_SetError("Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
SDL_SetError("SDL_BlendFillRect(): Unsupported surface format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_BlendFillRect(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* If 'rect' == NULL, then fill the whole surface */
|
||||
|
@ -274,14 +270,12 @@ SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect * rects, int count,
|
|||
int status = 0;
|
||||
|
||||
if (!dst) {
|
||||
SDL_SetError("Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
SDL_SetError("SDL_BlendFillRects(): Unsupported surface format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_BlendFillRects(): Unsupported surface format");
|
||||
}
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
|
|
|
@ -711,14 +711,12 @@ SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
|||
BlendLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
SDL_SetError("SDL_BlendLine(): Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_BlendLine(): Passed NULL destination surface");
|
||||
}
|
||||
|
||||
func = SDL_CalculateBlendLineFunc(dst->format);
|
||||
if (!func) {
|
||||
SDL_SetError("SDL_BlendLine(): Unsupported surface format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_BlendLine(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
|
@ -742,14 +740,12 @@ SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
|||
BlendLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
SDL_SetError("SDL_BlendLines(): Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_BlendLines(): Passed NULL destination surface");
|
||||
}
|
||||
|
||||
func = SDL_CalculateBlendLineFunc(dst->format);
|
||||
if (!func) {
|
||||
SDL_SetError("SDL_BlendLines(): Unsupported surface format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_BlendLines(): Unsupported surface format");
|
||||
}
|
||||
|
||||
for (i = 1; i < count; ++i) {
|
||||
|
|
|
@ -159,8 +159,7 @@ SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uin
|
|||
}
|
||||
return 0;
|
||||
default:
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,8 +188,7 @@ SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Ui
|
|||
}
|
||||
return 0;
|
||||
default:
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,14 +197,12 @@ SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r
|
|||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
if (!dst) {
|
||||
SDL_SetError("Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
SDL_SetError("SDL_BlendPoint(): Unsupported surface format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_BlendPoint(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
|
@ -272,14 +268,12 @@ SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count,
|
|||
int status = 0;
|
||||
|
||||
if (!dst) {
|
||||
SDL_SetError("Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
SDL_SetError("SDL_BlendPoints(): Unsupported surface format");
|
||||
return (-1);
|
||||
return SDL_SetError("SDL_BlendPoints(): Unsupported surface format");
|
||||
}
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
|
|
|
@ -145,14 +145,12 @@ SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color)
|
|||
DrawLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
SDL_SetError("SDL_DrawLine(): Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_DrawLine(): Passed NULL destination surface");
|
||||
}
|
||||
|
||||
func = SDL_CalculateDrawLineFunc(dst->format);
|
||||
if (!func) {
|
||||
SDL_SetError("SDL_DrawLine(): Unsupported surface format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_DrawLine(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
|
@ -176,14 +174,12 @@ SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
|||
DrawLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
SDL_SetError("SDL_DrawLines(): Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_DrawLines(): Passed NULL destination surface");
|
||||
}
|
||||
|
||||
func = SDL_CalculateDrawLineFunc(dst->format);
|
||||
if (!func) {
|
||||
SDL_SetError("SDL_DrawLines(): Unsupported surface format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_DrawLines(): Unsupported surface format");
|
||||
}
|
||||
|
||||
for (i = 1; i < count; ++i) {
|
||||
|
|
|
@ -30,14 +30,12 @@ int
|
|||
SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color)
|
||||
{
|
||||
if (!dst) {
|
||||
SDL_SetError("Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
SDL_SetError("SDL_DrawPoint(): Unsupported surface format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_DrawPoint(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
|
@ -55,8 +53,7 @@ SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color)
|
|||
DRAW_FASTSETPIXELXY2(x, y);
|
||||
break;
|
||||
case 3:
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
case 4:
|
||||
DRAW_FASTSETPIXELXY4(x, y);
|
||||
break;
|
||||
|
@ -74,14 +71,12 @@ SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count,
|
|||
int x, y;
|
||||
|
||||
if (!dst) {
|
||||
SDL_SetError("Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
SDL_SetError("SDL_DrawPoints(): Unsupported surface format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_DrawPoints(): Unsupported surface format");
|
||||
}
|
||||
|
||||
minx = dst->clip_rect.x;
|
||||
|
@ -105,8 +100,7 @@ SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count,
|
|||
DRAW_FASTSETPIXELXY2(x, y);
|
||||
break;
|
||||
case 3:
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
case 4:
|
||||
DRAW_FASTSETPIXELXY4(x, y);
|
||||
break;
|
||||
|
|
|
@ -200,8 +200,7 @@ SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
|
||||
if (!SDL_PixelFormatEnumToMasks
|
||||
(texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
|
||||
SDL_SetError("Unknown texture format");
|
||||
return -1;
|
||||
return SDL_SetError("Unknown texture format");
|
||||
}
|
||||
|
||||
texture->driverdata =
|
||||
|
@ -357,8 +356,7 @@ SW_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points,
|
|||
|
||||
final_points = SDL_stack_alloc(SDL_Point, count);
|
||||
if (!final_points) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
if (renderer->viewport.x || renderer->viewport.y) {
|
||||
int x = renderer->viewport.x;
|
||||
|
@ -407,8 +405,7 @@ SW_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points,
|
|||
|
||||
final_points = SDL_stack_alloc(SDL_Point, count);
|
||||
if (!final_points) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
if (renderer->viewport.x || renderer->viewport.y) {
|
||||
int x = renderer->viewport.x;
|
||||
|
@ -456,8 +453,7 @@ SW_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, int count)
|
|||
|
||||
final_rects = SDL_stack_alloc(SDL_Rect, count);
|
||||
if (!final_rects) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
if (renderer->viewport.x || renderer->viewport.y) {
|
||||
int x = renderer->viewport.x;
|
||||
|
@ -647,8 +643,7 @@ SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
|
||||
if (rect->x < 0 || rect->x+rect->w > surface->w ||
|
||||
rect->y < 0 || rect->y+rect->h > surface->h) {
|
||||
SDL_SetError("Tried to read outside of surface bounds");
|
||||
return -1;
|
||||
return SDL_SetError("Tried to read outside of surface bounds");
|
||||
}
|
||||
|
||||
src_format = surface->format->format;
|
||||
|
|
|
@ -251,7 +251,7 @@ SDLTest_GenerateUnsignedBoundaryValues(const Uint64 maxValue, Uint64 boundary1,
|
|||
|
||||
if (index == 0) {
|
||||
/* There are no valid boundaries */
|
||||
SDL_Error(SDL_UNSUPPORTED);
|
||||
SDL_Unsupported();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -379,7 +379,7 @@ SDLTest_GenerateSignedBoundaryValues(const Sint64 minValue, const Sint64 maxValu
|
|||
|
||||
if (index == 0) {
|
||||
/* There are no valid boundaries */
|
||||
SDL_Error(SDL_UNSUPPORTED);
|
||||
SDL_Unsupported();
|
||||
return minValue;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,8 +73,7 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
|
|||
int retval;
|
||||
|
||||
if (!sem) {
|
||||
SDL_SetError("Passed a NULL semaphore");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL semaphore");
|
||||
}
|
||||
|
||||
tryagain:
|
||||
|
@ -97,8 +96,7 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
|
|||
retval = SDL_MUTEX_TIMEDOUT;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("acquire_sem() failed");
|
||||
retval = -1;
|
||||
retval = SDL_SetError("acquire_sem() failed");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -139,13 +137,11 @@ int
|
|||
SDL_SemPost(SDL_sem * sem)
|
||||
{
|
||||
if (!sem) {
|
||||
SDL_SetError("Passed a NULL semaphore");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL semaphore");
|
||||
}
|
||||
|
||||
if (release_sem(sem->id) != B_NO_ERROR) {
|
||||
SDL_SetError("release_sem() failed");
|
||||
return -1;
|
||||
return SDL_SetError("release_sem() failed");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -77,8 +77,7 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
|
|||
thread->handle = spawn_thread(RunThread, name, B_NORMAL_PRIORITY, args);
|
||||
if ((thread->handle == B_NO_MORE_THREADS) ||
|
||||
(thread->handle == B_NO_MEMORY)) {
|
||||
SDL_SetError("Not enough resources to create thread");
|
||||
return (-1);
|
||||
return SDL_SetError("Not enough resources to create thread");
|
||||
}
|
||||
resume_thread(thread->handle);
|
||||
return (0);
|
||||
|
|
|
@ -82,8 +82,7 @@ int
|
|||
SDL_CondSignal(SDL_cond * cond)
|
||||
{
|
||||
if (!cond) {
|
||||
SDL_SetError("Passed a NULL condition variable");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL condition variable");
|
||||
}
|
||||
|
||||
/* If there are waiting threads not already signalled, then
|
||||
|
@ -107,8 +106,7 @@ int
|
|||
SDL_CondBroadcast(SDL_cond * cond)
|
||||
{
|
||||
if (!cond) {
|
||||
SDL_SetError("Passed a NULL condition variable");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL condition variable");
|
||||
}
|
||||
|
||||
/* If there are waiting threads not already signalled, then
|
||||
|
@ -164,8 +162,7 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
|
|||
int retval;
|
||||
|
||||
if (!cond) {
|
||||
SDL_SetError("Passed a NULL condition variable");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL condition variable");
|
||||
}
|
||||
|
||||
/* Obtain the protection mutex, and increment the number of waiters.
|
||||
|
|
|
@ -78,8 +78,7 @@ SDL_LockMutex(SDL_mutex * mutex)
|
|||
SDL_threadID this_thread;
|
||||
|
||||
if (mutex == NULL) {
|
||||
SDL_SetError("Passed a NULL mutex");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL mutex");
|
||||
}
|
||||
|
||||
this_thread = SDL_ThreadID();
|
||||
|
@ -110,8 +109,7 @@ SDL_TryLockMutex(SDL_mutex * mutex)
|
|||
SDL_threadID this_thread;
|
||||
|
||||
if (mutex == NULL) {
|
||||
SDL_SetError("Passed a NULL mutex");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL mutex");
|
||||
}
|
||||
|
||||
this_thread = SDL_ThreadID();
|
||||
|
@ -141,14 +139,12 @@ SDL_mutexV(SDL_mutex * mutex)
|
|||
return 0;
|
||||
#else
|
||||
if (mutex == NULL) {
|
||||
SDL_SetError("Passed a NULL mutex");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL mutex");
|
||||
}
|
||||
|
||||
/* If we don't own the mutex, we can't unlock it */
|
||||
if (SDL_ThreadID() != mutex->owner) {
|
||||
SDL_SetError("mutex not owned by this thread");
|
||||
return -1;
|
||||
return SDL_SetError("mutex not owned by this thread");
|
||||
}
|
||||
|
||||
if (mutex->recursive) {
|
||||
|
|
|
@ -39,28 +39,24 @@ SDL_CreateSemaphore(Uint32 initial_value)
|
|||
void
|
||||
SDL_DestroySemaphore(SDL_sem * sem)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SemTryWait(SDL_sem * sem)
|
||||
{
|
||||
SDL_SetError("SDL not configured with thread support");
|
||||
return -1;
|
||||
return SDL_SetError("SDL not configured with thread support");
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
|
||||
{
|
||||
SDL_SetError("SDL not configured with thread support");
|
||||
return -1;
|
||||
return SDL_SetError("SDL not configured with thread support");
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SemWait(SDL_sem * sem)
|
||||
{
|
||||
SDL_SetError("SDL not configured with thread support");
|
||||
return -1;
|
||||
return SDL_SetError("SDL not configured with thread support");
|
||||
}
|
||||
|
||||
Uint32
|
||||
|
@ -72,8 +68,7 @@ SDL_SemValue(SDL_sem * sem)
|
|||
int
|
||||
SDL_SemPost(SDL_sem * sem)
|
||||
{
|
||||
SDL_SetError("SDL not configured with thread support");
|
||||
return -1;
|
||||
return SDL_SetError("SDL not configured with thread support");
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -137,8 +132,7 @@ SDL_SemTryWait(SDL_sem * sem)
|
|||
int retval;
|
||||
|
||||
if (!sem) {
|
||||
SDL_SetError("Passed a NULL semaphore");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL semaphore");
|
||||
}
|
||||
|
||||
retval = SDL_MUTEX_TIMEDOUT;
|
||||
|
@ -158,8 +152,7 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
|
|||
int retval;
|
||||
|
||||
if (!sem) {
|
||||
SDL_SetError("Passed a NULL semaphore");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL semaphore");
|
||||
}
|
||||
|
||||
/* A timeout of 0 is an easy case */
|
||||
|
@ -207,8 +200,7 @@ int
|
|||
SDL_SemPost(SDL_sem * sem)
|
||||
{
|
||||
if (!sem) {
|
||||
SDL_SetError("Passed a NULL semaphore");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL semaphore");
|
||||
}
|
||||
|
||||
SDL_LockMutex(sem->count_lock);
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
int
|
||||
SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
|
||||
{
|
||||
SDL_SetError("Threads are not supported on this platform");
|
||||
return (-1);
|
||||
return SDL_SetError("Threads are not supported on this platform");
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -82,8 +82,7 @@ int
|
|||
SDL_CondSignal(SDL_cond * cond)
|
||||
{
|
||||
if (!cond) {
|
||||
SDL_SetError("Passed a NULL condition variable");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL condition variable");
|
||||
}
|
||||
|
||||
/* If there are waiting threads not already signalled, then
|
||||
|
@ -107,8 +106,7 @@ int
|
|||
SDL_CondBroadcast(SDL_cond * cond)
|
||||
{
|
||||
if (!cond) {
|
||||
SDL_SetError("Passed a NULL condition variable");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL condition variable");
|
||||
}
|
||||
|
||||
/* If there are waiting threads not already signalled, then
|
||||
|
@ -164,8 +162,7 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
|
|||
int retval;
|
||||
|
||||
if (!cond) {
|
||||
SDL_SetError("Passed a NULL condition variable");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL condition variable");
|
||||
}
|
||||
|
||||
/* Obtain the protection mutex, and increment the number of waiters.
|
||||
|
|
|
@ -78,8 +78,7 @@ SDL_mutexP(SDL_mutex * mutex)
|
|||
SDL_threadID this_thread;
|
||||
|
||||
if (mutex == NULL) {
|
||||
SDL_SetError("Passed a NULL mutex");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL mutex");
|
||||
}
|
||||
|
||||
this_thread = SDL_ThreadID();
|
||||
|
@ -107,14 +106,12 @@ SDL_mutexV(SDL_mutex * mutex)
|
|||
return 0;
|
||||
#else
|
||||
if (mutex == NULL) {
|
||||
SDL_SetError("Passed a NULL mutex");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL mutex");
|
||||
}
|
||||
|
||||
/* If we don't own the mutex, we can't unlock it */
|
||||
if (SDL_ThreadID() != mutex->owner) {
|
||||
SDL_SetError("mutex not owned by this thread");
|
||||
return -1;
|
||||
return SDL_SetError("mutex not owned by this thread");
|
||||
}
|
||||
|
||||
if (mutex->recursive) {
|
||||
|
|
|
@ -105,8 +105,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
|
|||
case SCE_KERNEL_ERROR_WAIT_TIMEOUT:
|
||||
return SDL_MUTEX_TIMEDOUT;
|
||||
default:
|
||||
SDL_SetError("WaitForSingleObject() failed");
|
||||
return -1;
|
||||
return SDL_SetError("WaitForSingleObject() failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,14 +141,12 @@ int SDL_SemPost(SDL_sem *sem)
|
|||
int res;
|
||||
|
||||
if (sem == NULL) {
|
||||
SDL_SetError("Passed a NULL sem");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL sem");
|
||||
}
|
||||
|
||||
res = sceKernelSignalSema(sem->semid, 1);
|
||||
if (res < 0) {
|
||||
SDL_SetError("sceKernelSignalSema() failed");
|
||||
return -1;
|
||||
return SDL_SetError("sceKernelSignalSema() failed");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -54,8 +54,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
|
|||
priority, 0x8000,
|
||||
PSP_THREAD_ATTR_VFPU, NULL);
|
||||
if (thread->handle < 0) {
|
||||
SDL_SetError("sceKernelCreateThread() failed");
|
||||
return -1;
|
||||
return SDL_SetError("sceKernelCreateThread() failed");
|
||||
}
|
||||
|
||||
sceKernelStartThread(thread->handle, 4, &args);
|
||||
|
|
|
@ -67,14 +67,12 @@ SDL_CondSignal(SDL_cond * cond)
|
|||
int retval;
|
||||
|
||||
if (!cond) {
|
||||
SDL_SetError("Passed a NULL condition variable");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL condition variable");
|
||||
}
|
||||
|
||||
retval = 0;
|
||||
if (pthread_cond_signal(&cond->cond) != 0) {
|
||||
SDL_SetError("pthread_cond_signal() failed");
|
||||
retval = -1;
|
||||
return SDL_SetError("pthread_cond_signal() failed");
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
@ -86,14 +84,12 @@ SDL_CondBroadcast(SDL_cond * cond)
|
|||
int retval;
|
||||
|
||||
if (!cond) {
|
||||
SDL_SetError("Passed a NULL condition variable");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL condition variable");
|
||||
}
|
||||
|
||||
retval = 0;
|
||||
if (pthread_cond_broadcast(&cond->cond) != 0) {
|
||||
SDL_SetError("pthread_cond_broadcast() failed");
|
||||
retval = -1;
|
||||
return SDL_SetError("pthread_cond_broadcast() failed");
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
@ -106,8 +102,7 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
|
|||
struct timespec abstime;
|
||||
|
||||
if (!cond) {
|
||||
SDL_SetError("Passed a NULL condition variable");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL condition variable");
|
||||
}
|
||||
|
||||
gettimeofday(&delta, NULL);
|
||||
|
@ -131,9 +126,7 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
|
|||
case 0:
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("pthread_cond_timedwait() failed");
|
||||
retval = -1;
|
||||
break;
|
||||
retval = SDL_SetError("pthread_cond_timedwait() failed");
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
@ -144,19 +137,12 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
|
|||
int
|
||||
SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex)
|
||||
{
|
||||
int retval;
|
||||
|
||||
if (!cond) {
|
||||
SDL_SetError("Passed a NULL condition variable");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL condition variable");
|
||||
} else if (pthread_cond_wait(&cond->cond, &mutex->id) != 0) {
|
||||
return SDL_SetError("pthread_cond_wait() failed");
|
||||
}
|
||||
|
||||
retval = 0;
|
||||
if (pthread_cond_wait(&cond->cond, &mutex->id) != 0) {
|
||||
SDL_SetError("pthread_cond_wait() failed");
|
||||
retval = -1;
|
||||
}
|
||||
return retval;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -81,17 +81,14 @@ SDL_DestroyMutex(SDL_mutex * mutex)
|
|||
int
|
||||
SDL_LockMutex(SDL_mutex * mutex)
|
||||
{
|
||||
int retval;
|
||||
#if FAKE_RECURSIVE_MUTEX
|
||||
pthread_t this_thread;
|
||||
#endif
|
||||
|
||||
if (mutex == NULL) {
|
||||
SDL_SetError("Passed a NULL mutex");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL mutex");
|
||||
}
|
||||
|
||||
retval = 0;
|
||||
#if FAKE_RECURSIVE_MUTEX
|
||||
this_thread = pthread_self();
|
||||
if (mutex->owner == this_thread) {
|
||||
|
@ -105,17 +102,15 @@ SDL_LockMutex(SDL_mutex * mutex)
|
|||
mutex->owner = this_thread;
|
||||
mutex->recursive = 0;
|
||||
} else {
|
||||
SDL_SetError("pthread_mutex_lock() failed");
|
||||
retval = -1;
|
||||
return SDL_SetError("pthread_mutex_lock() failed");
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (pthread_mutex_lock(&mutex->id) < 0) {
|
||||
SDL_SetError("pthread_mutex_lock() failed");
|
||||
retval = -1;
|
||||
return SDL_SetError("pthread_mutex_lock() failed");
|
||||
}
|
||||
#endif
|
||||
return retval;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -127,8 +122,7 @@ SDL_TryLockMutex(SDL_mutex * mutex)
|
|||
#endif
|
||||
|
||||
if (mutex == NULL) {
|
||||
SDL_SetError("Passed a NULL mutex");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL mutex");
|
||||
}
|
||||
|
||||
retval = 0;
|
||||
|
@ -147,8 +141,7 @@ SDL_TryLockMutex(SDL_mutex * mutex)
|
|||
} else if (errno == EBUSY) {
|
||||
retval = SDL_MUTEX_TIMEDOUT;
|
||||
} else {
|
||||
SDL_SetError("pthread_mutex_trylock() failed");
|
||||
retval = -1;
|
||||
retval = SDL_SetError("pthread_mutex_trylock() failed");
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
@ -156,8 +149,7 @@ SDL_TryLockMutex(SDL_mutex * mutex)
|
|||
if (errno == EBUSY) {
|
||||
retval = SDL_MUTEX_TIMEDOUT;
|
||||
} else {
|
||||
SDL_SetError("pthread_mutex_trylock() failed");
|
||||
retval = -1;
|
||||
retval = SDL_SetError("pthread_mutex_trylock() failed");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -167,14 +159,10 @@ SDL_TryLockMutex(SDL_mutex * mutex)
|
|||
int
|
||||
SDL_UnlockMutex(SDL_mutex * mutex)
|
||||
{
|
||||
int retval;
|
||||
|
||||
if (mutex == NULL) {
|
||||
SDL_SetError("Passed a NULL mutex");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL mutex");
|
||||
}
|
||||
|
||||
retval = 0;
|
||||
#if FAKE_RECURSIVE_MUTEX
|
||||
/* We can only unlock the mutex if we own it */
|
||||
if (pthread_self() == mutex->owner) {
|
||||
|
@ -190,18 +178,16 @@ SDL_UnlockMutex(SDL_mutex * mutex)
|
|||
pthread_mutex_unlock(&mutex->id);
|
||||
}
|
||||
} else {
|
||||
SDL_SetError("mutex not owned by this thread");
|
||||
retval = -1;
|
||||
return SDL_SetError("mutex not owned by this thread");
|
||||
}
|
||||
|
||||
#else
|
||||
if (pthread_mutex_unlock(&mutex->id) < 0) {
|
||||
SDL_SetError("pthread_mutex_unlock() failed");
|
||||
retval = -1;
|
||||
return SDL_SetError("pthread_mutex_unlock() failed");
|
||||
}
|
||||
#endif /* FAKE_RECURSIVE_MUTEX */
|
||||
|
||||
return retval;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -72,8 +72,7 @@ SDL_SemTryWait(SDL_sem * sem)
|
|||
int retval;
|
||||
|
||||
if (!sem) {
|
||||
SDL_SetError("Passed a NULL semaphore");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL semaphore");
|
||||
}
|
||||
retval = SDL_MUTEX_TIMEDOUT;
|
||||
if (sem_trywait(&sem->sem) == 0) {
|
||||
|
@ -88,13 +87,12 @@ SDL_SemWait(SDL_sem * sem)
|
|||
int retval;
|
||||
|
||||
if (!sem) {
|
||||
SDL_SetError("Passed a NULL semaphore");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL semaphore");
|
||||
}
|
||||
|
||||
retval = sem_wait(&sem->sem);
|
||||
if (retval < 0) {
|
||||
SDL_SetError("sem_wait() failed");
|
||||
retval = SDL_SetError("sem_wait() failed");
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
@ -111,8 +109,7 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
|
|||
#endif
|
||||
|
||||
if (!sem) {
|
||||
SDL_SetError("Passed a NULL semaphore");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL semaphore");
|
||||
}
|
||||
|
||||
/* Try the easy cases first */
|
||||
|
@ -188,8 +185,7 @@ SDL_SemPost(SDL_sem * sem)
|
|||
int retval;
|
||||
|
||||
if (!sem) {
|
||||
SDL_SetError("Passed a NULL semaphore");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL semaphore");
|
||||
}
|
||||
|
||||
retval = sem_post(&sem->sem);
|
||||
|
|
|
@ -97,18 +97,16 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
|
|||
|
||||
/* Set the thread attributes */
|
||||
if (pthread_attr_init(&type) != 0) {
|
||||
SDL_SetError("Couldn't initialize pthread attributes");
|
||||
return (-1);
|
||||
return SDL_SetError("Couldn't initialize pthread attributes");
|
||||
}
|
||||
pthread_attr_setdetachstate(&type, PTHREAD_CREATE_JOINABLE);
|
||||
|
||||
/* Create the thread and go! */
|
||||
if (pthread_create(&thread->handle, &type, RunThread, args) != 0) {
|
||||
SDL_SetError("Not enough resources to create thread");
|
||||
return (-1);
|
||||
return SDL_SetError("Not enough resources to create thread");
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -173,8 +171,7 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
|
|||
/* Note that this fails if you're trying to set high priority
|
||||
and you don't have root permission. BUT DON'T RUN AS ROOT!
|
||||
*/
|
||||
SDL_SetError("setpriority() failed");
|
||||
return -1;
|
||||
return SDL_SetError("setpriority() failed");
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
|
@ -183,8 +180,7 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
|
|||
pthread_t thread = pthread_self();
|
||||
|
||||
if (pthread_getschedparam(thread, &policy, &sched) < 0) {
|
||||
SDL_SetError("pthread_getschedparam() failed");
|
||||
return -1;
|
||||
return SDL_SetError("pthread_getschedparam() failed");
|
||||
}
|
||||
if (priority == SDL_THREAD_PRIORITY_LOW) {
|
||||
sched.sched_priority = sched_get_priority_min(policy);
|
||||
|
@ -196,8 +192,7 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
|
|||
sched.sched_priority = (min_priority + (max_priority - min_priority) / 2);
|
||||
}
|
||||
if (pthread_setschedparam(thread, policy, &sched) < 0) {
|
||||
SDL_SetError("pthread_setschedparam() failed");
|
||||
return -1;
|
||||
return SDL_SetError("pthread_setschedparam() failed");
|
||||
}
|
||||
return 0;
|
||||
#endif /* linux */
|
||||
|
|
|
@ -67,8 +67,7 @@ int
|
|||
SDL_LockMutex(SDL_mutex * mutex)
|
||||
{
|
||||
if (mutex == NULL) {
|
||||
SDL_SetError("Passed a NULL mutex");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL mutex");
|
||||
}
|
||||
|
||||
EnterCriticalSection(&mutex->cs);
|
||||
|
@ -81,8 +80,7 @@ SDL_TryLockMutex(SDL_mutex * mutex)
|
|||
{
|
||||
int retval = 0;
|
||||
if (mutex == NULL) {
|
||||
SDL_SetError("Passed a NULL mutex");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL mutex");
|
||||
}
|
||||
|
||||
if (TryEnterCriticalSection(&mutex->cs) == 0) {
|
||||
|
@ -96,8 +94,7 @@ int
|
|||
SDL_UnlockMutex(SDL_mutex * mutex)
|
||||
{
|
||||
if (mutex == NULL) {
|
||||
SDL_SetError("Passed a NULL mutex");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL mutex");
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&mutex->cs);
|
||||
|
|
|
@ -78,8 +78,7 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
|
|||
DWORD dwMilliseconds;
|
||||
|
||||
if (!sem) {
|
||||
SDL_SetError("Passed a NULL sem");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL sem");
|
||||
}
|
||||
|
||||
if (timeout == SDL_MUTEX_MAXWAIT) {
|
||||
|
@ -96,8 +95,7 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
|
|||
retval = SDL_MUTEX_TIMEDOUT;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("WaitForSingleObject() failed");
|
||||
retval = -1;
|
||||
retval = SDL_SetError("WaitForSingleObject() failed");
|
||||
break;
|
||||
}
|
||||
return retval;
|
||||
|
@ -130,8 +128,7 @@ int
|
|||
SDL_SemPost(SDL_sem * sem)
|
||||
{
|
||||
if (!sem) {
|
||||
SDL_SetError("Passed a NULL sem");
|
||||
return -1;
|
||||
return SDL_SetError("Passed a NULL sem");
|
||||
}
|
||||
/* Increase the counter in the first place, because
|
||||
* after a successful release the semaphore may
|
||||
|
@ -141,8 +138,7 @@ SDL_SemPost(SDL_sem * sem)
|
|||
InterlockedIncrement(&sem->count);
|
||||
if (ReleaseSemaphore(sem->id, 1, NULL) == FALSE) {
|
||||
InterlockedDecrement(&sem->count); /* restore */
|
||||
SDL_SetError("ReleaseSemaphore() failed");
|
||||
return -1;
|
||||
return SDL_SetError("ReleaseSemaphore() failed");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -116,8 +116,7 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
|
|||
pThreadStartParms pThreadParms =
|
||||
(pThreadStartParms) SDL_malloc(sizeof(tThreadStartParms));
|
||||
if (!pThreadParms) {
|
||||
SDL_OutOfMemory();
|
||||
return (-1);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
// Save the function which we will have to call to clear the RTL of calling app!
|
||||
pThreadParms->pfnCurrentEndThread = pfnEndThread;
|
||||
|
@ -135,10 +134,9 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
|
|||
pThreadParms, 0, &threadid);
|
||||
}
|
||||
if (thread->handle == NULL) {
|
||||
SDL_SetError("Not enough resources to create thread");
|
||||
return (-1);
|
||||
return SDL_SetError("Not enough resources to create thread");
|
||||
}
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@ -198,8 +196,7 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
|
|||
value = THREAD_PRIORITY_NORMAL;
|
||||
}
|
||||
if (!SetThreadPriority(GetCurrentThread(), value)) {
|
||||
WIN_SetError("SetThreadPriority()");
|
||||
return -1;
|
||||
return WIN_SetError("SetThreadPriority()");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1087,8 +1087,7 @@ RLEAlphaSurface(SDL_Surface * surface)
|
|||
maxsize += sizeof(RLEDestFormat);
|
||||
rlebuf = (Uint8 *) SDL_malloc(maxsize);
|
||||
if (!rlebuf) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
{
|
||||
/* save the destination format so we can undo the encoding later */
|
||||
|
@ -1299,8 +1298,7 @@ RLEColorkeySurface(SDL_Surface * surface)
|
|||
|
||||
rlebuf = (Uint8 *) SDL_malloc(maxsize);
|
||||
if (rlebuf == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return (-1);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
/* Set up the conversion */
|
||||
|
|
|
@ -270,11 +270,10 @@ SDL_CalculateBlit(SDL_Surface * surface)
|
|||
/* Make sure we have a blit function */
|
||||
if (blit == NULL) {
|
||||
SDL_InvalidateMap(map);
|
||||
SDL_SetError("Blit combination not supported");
|
||||
return (-1);
|
||||
return SDL_SetError("Blit combination not supported");
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -315,14 +315,12 @@ SDL_FillRect(SDL_Surface * dst, const SDL_Rect * rect, Uint32 color)
|
|||
Uint8 *pixels;
|
||||
|
||||
if (!dst) {
|
||||
SDL_SetError("Passed NULL destination surface");
|
||||
return -1;
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
SDL_SetError("SDL_FillRect(): Unsupported surface format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_FillRect(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* If 'rect' == NULL, then fill the whole surface */
|
||||
|
@ -338,8 +336,7 @@ SDL_FillRect(SDL_Surface * dst, const SDL_Rect * rect, Uint32 color)
|
|||
|
||||
/* Perform software fill */
|
||||
if (!dst->pixels) {
|
||||
SDL_SetError("SDL_FillRect(): You must lock the surface");
|
||||
return (-1);
|
||||
return SDL_SetError("SDL_FillRect(): You must lock the surface");
|
||||
}
|
||||
|
||||
pixels = (Uint8 *) dst->pixels + rect->y * dst->pitch +
|
||||
|
@ -423,8 +420,7 @@ SDL_FillRects(SDL_Surface * dst, const SDL_Rect * rects, int count,
|
|||
int status = 0;
|
||||
|
||||
if (!rects) {
|
||||
SDL_SetError("SDL_FillRects() passed NULL rects");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_FillRects() passed NULL rects");
|
||||
}
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
|
|
|
@ -638,13 +638,11 @@ int
|
|||
SDL_SetPixelFormatPalette(SDL_PixelFormat * format, SDL_Palette *palette)
|
||||
{
|
||||
if (!format) {
|
||||
SDL_SetError("SDL_SetPixelFormatPalette() passed NULL format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_SetPixelFormatPalette() passed NULL format");
|
||||
}
|
||||
|
||||
if (palette && palette->ncolors != (1 << format->BitsPerPixel)) {
|
||||
SDL_SetError("SDL_SetPixelFormatPalette() passed a palette that doesn't match the format");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_SetPixelFormatPalette() passed a palette that doesn't match the format");
|
||||
}
|
||||
|
||||
if (format->palette == palette) {
|
||||
|
|
|
@ -102,14 +102,12 @@ generate_rowbytes(int src_w, int dst_w, int bpp)
|
|||
store = STORE_WORD;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("ASM stretch of %d bytes isn't supported\n", bpp);
|
||||
return (-1);
|
||||
return SDL_SetError("ASM stretch of %d bytes isn't supported\n", bpp);
|
||||
}
|
||||
#ifdef HAVE_MPROTECT
|
||||
/* Make the code writeable */
|
||||
if (mprotect(copy_row, sizeof(copy_row), PROT_READ | PROT_WRITE) < 0) {
|
||||
SDL_SetError("Couldn't make copy buffer writeable");
|
||||
return (-1);
|
||||
return SDL_SetError("Couldn't make copy buffer writeable");
|
||||
}
|
||||
#endif
|
||||
pos = 0x10000;
|
||||
|
@ -141,8 +139,7 @@ generate_rowbytes(int src_w, int dst_w, int bpp)
|
|||
#ifdef HAVE_MPROTECT
|
||||
/* Make the code executable but not writeable */
|
||||
if (mprotect(copy_row, sizeof(copy_row), PROT_READ | PROT_EXEC) < 0) {
|
||||
SDL_SetError("Couldn't make copy buffer executable");
|
||||
return (-1);
|
||||
return SDL_SetError("Couldn't make copy buffer executable");
|
||||
}
|
||||
#endif
|
||||
last.status = 0;
|
||||
|
@ -224,8 +221,7 @@ SDL_SoftStretch(SDL_Surface * src, const SDL_Rect * srcrect,
|
|||
const int bpp = dst->format->BytesPerPixel;
|
||||
|
||||
if (src->format->BitsPerPixel != dst->format->BitsPerPixel) {
|
||||
SDL_SetError("Only works with same format surfaces");
|
||||
return (-1);
|
||||
return SDL_SetError("Only works with same format surfaces");
|
||||
}
|
||||
|
||||
/* Verify the blit rectangles */
|
||||
|
@ -233,8 +229,7 @@ SDL_SoftStretch(SDL_Surface * src, const SDL_Rect * srcrect,
|
|||
if ((srcrect->x < 0) || (srcrect->y < 0) ||
|
||||
((srcrect->x + srcrect->w) > src->w) ||
|
||||
((srcrect->y + srcrect->h) > src->h)) {
|
||||
SDL_SetError("Invalid source blit rectangle");
|
||||
return (-1);
|
||||
return SDL_SetError("Invalid source blit rectangle");
|
||||
}
|
||||
} else {
|
||||
full_src.x = 0;
|
||||
|
@ -247,8 +242,7 @@ SDL_SoftStretch(SDL_Surface * src, const SDL_Rect * srcrect,
|
|||
if ((dstrect->x < 0) || (dstrect->y < 0) ||
|
||||
((dstrect->x + dstrect->w) > dst->w) ||
|
||||
((dstrect->y + dstrect->h) > dst->h)) {
|
||||
SDL_SetError("Invalid destination blit rectangle");
|
||||
return (-1);
|
||||
return SDL_SetError("Invalid destination blit rectangle");
|
||||
}
|
||||
} else {
|
||||
full_dst.x = 0;
|
||||
|
@ -262,8 +256,7 @@ SDL_SoftStretch(SDL_Surface * src, const SDL_Rect * srcrect,
|
|||
dst_locked = 0;
|
||||
if (SDL_MUSTLOCK(dst)) {
|
||||
if (SDL_LockSurface(dst) < 0) {
|
||||
SDL_SetError("Unable to lock destination surface");
|
||||
return (-1);
|
||||
return SDL_SetError("Unable to lock destination surface");
|
||||
}
|
||||
dst_locked = 1;
|
||||
}
|
||||
|
@ -274,8 +267,7 @@ SDL_SoftStretch(SDL_Surface * src, const SDL_Rect * srcrect,
|
|||
if (dst_locked) {
|
||||
SDL_UnlockSurface(dst);
|
||||
}
|
||||
SDL_SetError("Unable to lock source surface");
|
||||
return (-1);
|
||||
return SDL_SetError("Unable to lock source surface");
|
||||
}
|
||||
src_locked = 1;
|
||||
}
|
||||
|
|
|
@ -143,8 +143,7 @@ int
|
|||
SDL_SetSurfacePalette(SDL_Surface * surface, SDL_Palette * palette)
|
||||
{
|
||||
if (!surface) {
|
||||
SDL_SetError("SDL_SetSurfacePalette() passed a NULL surface");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_SetSurfacePalette() passed a NULL surface");
|
||||
}
|
||||
return SDL_SetPixelFormatPalette(surface->format, palette);
|
||||
}
|
||||
|
@ -402,8 +401,7 @@ SDL_SetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode blendMode)
|
|||
surface->map->info.flags |= SDL_COPY_MOD;
|
||||
break;
|
||||
default:
|
||||
SDL_Unsupported();
|
||||
status = -1;
|
||||
status = SDL_Unsupported();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -518,12 +516,10 @@ SDL_UpperBlit(SDL_Surface * src, const SDL_Rect * srcrect,
|
|||
|
||||
/* Make sure the surfaces aren't locked */
|
||||
if (!src || !dst) {
|
||||
SDL_SetError("SDL_UpperBlit: passed a NULL surface");
|
||||
return (-1);
|
||||
return SDL_SetError("SDL_UpperBlit: passed a NULL surface");
|
||||
}
|
||||
if (src->locked || dst->locked) {
|
||||
SDL_SetError("Surfaces must not be locked during blit");
|
||||
return (-1);
|
||||
return SDL_SetError("Surfaces must not be locked during blit");
|
||||
}
|
||||
|
||||
/* If the destination rectangle is NULL, use the entire dest surface */
|
||||
|
@ -610,12 +606,10 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
|
|||
|
||||
/* Make sure the surfaces aren't locked */
|
||||
if (!src || !dst) {
|
||||
SDL_SetError("SDL_UpperBlitScaled: passed a NULL surface");
|
||||
return (-1);
|
||||
return SDL_SetError("SDL_UpperBlitScaled: passed a NULL surface");
|
||||
}
|
||||
if (src->locked || dst->locked) {
|
||||
SDL_SetError("Surfaces must not be locked during blit");
|
||||
return (-1);
|
||||
return SDL_SetError("Surfaces must not be locked during blit");
|
||||
}
|
||||
|
||||
/* If the destination rectangle is NULL, use the entire dest surface */
|
||||
|
@ -972,12 +966,10 @@ int SDL_ConvertPixels(int width, int height,
|
|||
|
||||
/* Check to make sure we are bliting somewhere, so we don't crash */
|
||||
if (!dst) {
|
||||
SDL_InvalidParamError("dst");
|
||||
return -1;
|
||||
return SDL_InvalidParamError("dst");
|
||||
}
|
||||
if (!dst_pitch) {
|
||||
SDL_InvalidParamError("dst_pitch");
|
||||
return -1;
|
||||
return SDL_InvalidParamError("dst_pitch");
|
||||
}
|
||||
|
||||
/* Fast path for same format copy */
|
||||
|
@ -994,8 +986,7 @@ int SDL_ConvertPixels(int width, int height,
|
|||
bpp = 2;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unknown FOURCC pixel format");
|
||||
return -1;
|
||||
return SDL_SetError("Unknown FOURCC pixel format");
|
||||
}
|
||||
} else {
|
||||
bpp = SDL_BYTESPERPIXEL(src_format);
|
||||
|
|
|
@ -242,16 +242,14 @@ SDL_CreateWindowTexture(_THIS, SDL_Window * window, Uint32 * format, void ** pix
|
|||
}
|
||||
}
|
||||
if (!renderer) {
|
||||
SDL_SetError("No hardware accelerated renderers available");
|
||||
return -1;
|
||||
return SDL_SetError("No hardware accelerated renderers available");
|
||||
}
|
||||
|
||||
/* Create the data after we successfully create the renderer (bug #1116) */
|
||||
data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_SetWindowData(window, SDL_WINDOWTEXTUREDATA, data);
|
||||
|
||||
|
@ -294,8 +292,7 @@ SDL_CreateWindowTexture(_THIS, SDL_Window * window, Uint32 * format, void ** pix
|
|||
data->pitch = (((window->w * data->bytes_per_pixel) + 3) & ~3);
|
||||
data->pixels = SDL_malloc(window->h * data->pitch);
|
||||
if (!data->pixels) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
*pixels = data->pixels;
|
||||
|
@ -316,8 +313,7 @@ SDL_UpdateWindowTexture(_THIS, SDL_Window * window, const SDL_Rect * rects, int
|
|||
|
||||
data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA);
|
||||
if (!data || !data->texture) {
|
||||
SDL_SetError("No window texture data");
|
||||
return -1;
|
||||
return SDL_SetError("No window texture data");
|
||||
}
|
||||
|
||||
/* Update a single rect that contains subrects for best DMA performance */
|
||||
|
@ -384,10 +380,10 @@ cmpmodes(const void *A, const void *B)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
SDL_UninitializedVideo()
|
||||
{
|
||||
SDL_SetError("Video subsystem has not been initialized");
|
||||
return SDL_SetError("Video subsystem has not been initialized");
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -454,11 +450,9 @@ SDL_VideoInit(const char *driver_name)
|
|||
}
|
||||
if (video == NULL) {
|
||||
if (driver_name) {
|
||||
SDL_SetError("%s not available", driver_name);
|
||||
} else {
|
||||
SDL_SetError("No available video device");
|
||||
return SDL_SetError("%s not available", driver_name);
|
||||
}
|
||||
return -1;
|
||||
return SDL_SetError("No available video device");
|
||||
}
|
||||
_this = video;
|
||||
_this->name = bootstrap[i]->name;
|
||||
|
@ -510,9 +504,8 @@ SDL_VideoInit(const char *driver_name)
|
|||
|
||||
/* Make sure some displays were added */
|
||||
if (_this->num_displays == 0) {
|
||||
SDL_SetError("The video driver did not add any displays");
|
||||
SDL_VideoQuit();
|
||||
return (-1);
|
||||
return SDL_SetError("The video driver did not add any displays");
|
||||
}
|
||||
|
||||
/* Add the renderer framebuffer emulation if desired */
|
||||
|
@ -721,9 +714,8 @@ SDL_GetDisplayMode(int displayIndex, int index, SDL_DisplayMode * mode)
|
|||
|
||||
display = &_this->displays[displayIndex];
|
||||
if (index < 0 || index >= SDL_GetNumDisplayModesForDisplay(display)) {
|
||||
SDL_SetError("index must be in the range of 0 - %d",
|
||||
SDL_GetNumDisplayModesForDisplay(display) - 1);
|
||||
return -1;
|
||||
return SDL_SetError("index must be in the range of 0 - %d",
|
||||
SDL_GetNumDisplayModesForDisplay(display) - 1);
|
||||
}
|
||||
if (mode) {
|
||||
*mode = display->display_modes[index];
|
||||
|
@ -904,9 +896,8 @@ SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode *
|
|||
|
||||
/* Get a good video mode, the closest one possible */
|
||||
if (!SDL_GetClosestDisplayModeForDisplay(display, &display_mode, &display_mode)) {
|
||||
SDL_SetError("No video mode large enough for %dx%d",
|
||||
display_mode.w, display_mode.h);
|
||||
return -1;
|
||||
return SDL_SetError("No video mode large enough for %dx%d",
|
||||
display_mode.w, display_mode.h);
|
||||
}
|
||||
} else {
|
||||
display_mode = display->desktop_mode;
|
||||
|
@ -920,8 +911,7 @@ SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode *
|
|||
|
||||
/* Actually change the display mode */
|
||||
if (!_this->SetDisplayMode) {
|
||||
SDL_SetError("Video driver doesn't support changing display mode");
|
||||
return -1;
|
||||
return SDL_SetError("Video driver doesn't support changing display mode");
|
||||
}
|
||||
if (_this->SetDisplayMode(_this, display, &display_mode) < 0) {
|
||||
return -1;
|
||||
|
@ -1021,8 +1011,7 @@ SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode)
|
|||
SDL_VideoDisplay *display;
|
||||
|
||||
if (!mode) {
|
||||
SDL_InvalidParamError("mode");
|
||||
return -1;
|
||||
return SDL_InvalidParamError("mode");
|
||||
}
|
||||
|
||||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
|
@ -1045,8 +1034,7 @@ SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode)
|
|||
else if (!SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayForWindow(window),
|
||||
&fullscreen_mode,
|
||||
&fullscreen_mode)) {
|
||||
SDL_SetError("Couldn't find display mode match");
|
||||
return -1;
|
||||
return SDL_SetError("Couldn't find display mode match");
|
||||
}
|
||||
|
||||
if (mode) {
|
||||
|
@ -1299,8 +1287,7 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
|
|||
char *title = window->title;
|
||||
|
||||
if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) {
|
||||
SDL_SetError("No OpenGL support in video driver");
|
||||
return -1;
|
||||
return SDL_SetError("No OpenGL support in video driver");
|
||||
}
|
||||
|
||||
if (window->flags & SDL_WINDOW_FOREIGN) {
|
||||
|
@ -1847,8 +1834,7 @@ SDL_UpdateWindowSurfaceRects(SDL_Window * window, const SDL_Rect * rects,
|
|||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
|
||||
if (!window->surface_valid) {
|
||||
SDL_SetError("Window surface is invalid, please call SDL_GetWindowSurface() to get a new surface");
|
||||
return -1;
|
||||
return SDL_SetError("Window surface is invalid, please call SDL_GetWindowSurface() to get a new surface");
|
||||
}
|
||||
|
||||
return _this->UpdateWindowFramebuffer(_this, window, rects, numrects);
|
||||
|
@ -1886,8 +1872,7 @@ SDL_SetWindowGammaRamp(SDL_Window * window, const Uint16 * red,
|
|||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
|
||||
if (!_this->SetWindowGammaRamp) {
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
if (!window->gamma) {
|
||||
|
@ -1924,8 +1909,7 @@ SDL_GetWindowGammaRamp(SDL_Window * window, Uint16 * red,
|
|||
|
||||
window->gamma = (Uint16 *)SDL_malloc(256*6*sizeof(Uint16));
|
||||
if (!window->gamma) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
window->saved_gamma = window->gamma + 3*256;
|
||||
|
||||
|
@ -2266,19 +2250,16 @@ SDL_GL_LoadLibrary(const char *path)
|
|||
int retval;
|
||||
|
||||
if (!_this) {
|
||||
SDL_UninitializedVideo();
|
||||
return -1;
|
||||
return SDL_UninitializedVideo();
|
||||
}
|
||||
if (_this->gl_config.driver_loaded) {
|
||||
if (path && SDL_strcmp(path, _this->gl_config.driver_path) != 0) {
|
||||
SDL_SetError("OpenGL library already loaded");
|
||||
return -1;
|
||||
return SDL_SetError("OpenGL library already loaded");
|
||||
}
|
||||
retval = 0;
|
||||
} else {
|
||||
if (!_this->GL_LoadLibrary) {
|
||||
SDL_SetError("No dynamic GL support in video driver");
|
||||
return -1;
|
||||
return SDL_SetError("No dynamic GL support in video driver");
|
||||
}
|
||||
retval = _this->GL_LoadLibrary(_this, path);
|
||||
}
|
||||
|
@ -2388,8 +2369,7 @@ SDL_GL_SetAttribute(SDL_GLattr attr, int value)
|
|||
int retval;
|
||||
|
||||
if (!_this) {
|
||||
SDL_UninitializedVideo();
|
||||
return -1;
|
||||
return SDL_UninitializedVideo();
|
||||
}
|
||||
retval = 0;
|
||||
switch (attr) {
|
||||
|
@ -2458,8 +2438,7 @@ SDL_GL_SetAttribute(SDL_GLattr attr, int value)
|
|||
SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG |
|
||||
SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG |
|
||||
SDL_GL_CONTEXT_RESET_ISOLATION_FLAG) ) {
|
||||
SDL_SetError("Unknown OpenGL context flag %d", value);
|
||||
retval = -1;
|
||||
retval = SDL_SetError("Unknown OpenGL context flag %d", value);
|
||||
break;
|
||||
}
|
||||
_this->gl_config.flags = value;
|
||||
|
@ -2469,8 +2448,7 @@ SDL_GL_SetAttribute(SDL_GLattr attr, int value)
|
|||
value != SDL_GL_CONTEXT_PROFILE_CORE &&
|
||||
value != SDL_GL_CONTEXT_PROFILE_COMPATIBILITY &&
|
||||
value != SDL_GL_CONTEXT_PROFILE_ES ) {
|
||||
SDL_SetError("Unknown OpenGL context profile %d", value);
|
||||
retval = -1;
|
||||
retval = SDL_SetError("Unknown OpenGL context profile %d", value);
|
||||
break;
|
||||
}
|
||||
_this->gl_config.profile_mask = value;
|
||||
|
@ -2479,14 +2457,12 @@ SDL_GL_SetAttribute(SDL_GLattr attr, int value)
|
|||
_this->gl_config.share_with_current_context = value;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unknown OpenGL attribute");
|
||||
retval = -1;
|
||||
retval = SDL_SetError("Unknown OpenGL attribute");
|
||||
break;
|
||||
}
|
||||
return retval;
|
||||
#else
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
#endif /* SDL_VIDEO_OPENGL */
|
||||
}
|
||||
|
||||
|
@ -2645,36 +2621,22 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
|
|||
return 0;
|
||||
}
|
||||
default:
|
||||
SDL_SetError("Unknown OpenGL attribute");
|
||||
return -1;
|
||||
return SDL_SetError("Unknown OpenGL attribute");
|
||||
}
|
||||
|
||||
glGetIntegervFunc(attrib, (GLint *) value);
|
||||
error = glGetErrorFunc();
|
||||
if (error != GL_NO_ERROR) {
|
||||
switch (error) {
|
||||
case GL_INVALID_ENUM:
|
||||
{
|
||||
SDL_SetError("OpenGL error: GL_INVALID_ENUM");
|
||||
}
|
||||
break;
|
||||
case GL_INVALID_VALUE:
|
||||
{
|
||||
SDL_SetError("OpenGL error: GL_INVALID_VALUE");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
SDL_SetError("OpenGL error: %08X", error);
|
||||
}
|
||||
break;
|
||||
if (error == GL_INVALID_ENUM) {
|
||||
return SDL_SetError("OpenGL error: GL_INVALID_ENUM");
|
||||
} else if (error == GL_INVALID_VALUE) {
|
||||
return SDL_SetError("OpenGL error: GL_INVALID_VALUE");
|
||||
}
|
||||
return -1;
|
||||
return SDL_SetError("OpenGL error: %08X", error);
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
#endif /* SDL_VIDEO_OPENGL */
|
||||
}
|
||||
|
||||
|
@ -2706,8 +2668,7 @@ SDL_GL_MakeCurrent(SDL_Window * window, SDL_GLContext ctx)
|
|||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
|
||||
if (!(window->flags & SDL_WINDOW_OPENGL)) {
|
||||
SDL_SetError("The specified window isn't an OpenGL window");
|
||||
return -1;
|
||||
return SDL_SetError("The specified window isn't an OpenGL window");
|
||||
}
|
||||
if (!ctx) {
|
||||
window = NULL;
|
||||
|
@ -2730,16 +2691,13 @@ int
|
|||
SDL_GL_SetSwapInterval(int interval)
|
||||
{
|
||||
if (!_this) {
|
||||
SDL_UninitializedVideo();
|
||||
return -1;
|
||||
return SDL_UninitializedVideo();
|
||||
} else if (_this->current_glctx == NULL) {
|
||||
SDL_SetError("No OpenGL context has been made current");
|
||||
return -1;
|
||||
return SDL_SetError("No OpenGL context has been made current");
|
||||
} else if (_this->GL_SetSwapInterval) {
|
||||
return _this->GL_SetSwapInterval(_this, interval);
|
||||
} else {
|
||||
SDL_SetError("Setting the swap interval is not supported");
|
||||
return -1;
|
||||
return SDL_SetError("Setting the swap interval is not supported");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3025,8 +2983,7 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|||
SDL_ShowCursor( show_cursor_prev );
|
||||
SDL_SetRelativeMouseMode( relative_mode );
|
||||
|
||||
if(retval == -1)
|
||||
{
|
||||
if(retval == -1) {
|
||||
SDL_SetError("No message system available");
|
||||
}
|
||||
return retval;
|
||||
|
|
|
@ -42,8 +42,7 @@ Android_GL_LoadLibrary(_THIS, const char *path)
|
|||
if (!Android_GLHandle) {
|
||||
Android_GLHandle = dlopen("libGLESv1_CM.so",RTLD_GLOBAL);
|
||||
if (!Android_GLHandle) {
|
||||
SDL_SetError("Could not initialize GL ES library\n");
|
||||
return -1;
|
||||
return SDL_SetError("Could not initialize GL ES library\n");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -31,8 +31,7 @@ int
|
|||
Android_CreateWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
if (Android_Window) {
|
||||
SDL_SetError("Android only supports one window");
|
||||
return -1;
|
||||
return SDL_SetError("Android only supports one window");
|
||||
}
|
||||
Android_Window = window;
|
||||
Android_PauseSem = SDL_CreateSemaphore(0);
|
||||
|
|
|
@ -76,8 +76,7 @@ int BE_CreateWindowFramebuffer(_THIS, SDL_Window * window,
|
|||
true); /* Contiguous memory required */
|
||||
|
||||
if(bitmap->InitCheck() != B_OK) {
|
||||
SDL_SetError("Could not initialize back buffer!\n");
|
||||
return -1;
|
||||
return SDL_SetError("Could not initialize back buffer!\n");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -310,8 +310,7 @@ int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){
|
|||
}
|
||||
|
||||
if(bscreen.SetMode(bmode) != B_OK) {
|
||||
SDL_SetError("Bad video mode\n");
|
||||
return -1;
|
||||
return SDL_SetError("Bad video mode\n");
|
||||
}
|
||||
|
||||
free(bmode_list);
|
||||
|
|
|
@ -84,7 +84,7 @@ IS_SNOW_LEOPARD_OR_LATER(_THIS)
|
|||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
CG_SetError(const char *prefix, CGDisplayErr result)
|
||||
{
|
||||
const char *error;
|
||||
|
@ -124,7 +124,7 @@ CG_SetError(const char *prefix, CGDisplayErr result)
|
|||
error = "Unknown Error";
|
||||
break;
|
||||
}
|
||||
SDL_SetError("%s: %s", prefix, error);
|
||||
return SDL_SetError("%s: %s", prefix, error);
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
|
|
|
@ -190,8 +190,7 @@ Cocoa_SetRelativeMouseMode(SDL_bool enabled)
|
|||
result = CGAssociateMouseAndMouseCursorPosition(YES);
|
||||
}
|
||||
if (result != kCGErrorSuccess) {
|
||||
SDL_SetError("CGAssociateMouseAndMouseCursorPosition() failed");
|
||||
return -1;
|
||||
return SDL_SetError("CGAssociateMouseAndMouseCursorPosition() failed");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -274,8 +274,7 @@ Cocoa_GL_SetSwapInterval(_THIS, int interval)
|
|||
[nscontext setValues:&value forParameter:NSOpenGLCPSwapInterval];
|
||||
status = 0;
|
||||
} else {
|
||||
SDL_SetError("No current OpenGL context");
|
||||
status = -1;
|
||||
status = SDL_SetError("No current OpenGL context");
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
|
|
@ -501,8 +501,7 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created
|
|||
/* Allocate the window data */
|
||||
data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
data->window = window;
|
||||
data->nswindow = nswindow;
|
||||
|
@ -954,8 +953,7 @@ Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
|
|||
|
||||
if (CGSetDisplayTransferByTable(display_id, tableSize,
|
||||
redTable, greenTable, blueTable) != CGDisplayNoErr) {
|
||||
SDL_SetError("CGSetDisplayTransferByTable()");
|
||||
return -1;
|
||||
return SDL_SetError("CGSetDisplayTransferByTable()");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -973,8 +971,7 @@ Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp)
|
|||
|
||||
if (CGGetDisplayTransferByTable(display_id, tableSize,
|
||||
redTable, greenTable, blueTable, &tableCopied) != CGDisplayNoErr) {
|
||||
SDL_SetError("CGGetDisplayTransferByTable()");
|
||||
return -1;
|
||||
return SDL_SetError("CGGetDisplayTransferByTable()");
|
||||
}
|
||||
|
||||
for (i = 0; i < tableCopied; i++) {
|
||||
|
|
|
@ -72,8 +72,7 @@ DirectFB_GL_Initialize(_THIS)
|
|||
sizeof(struct
|
||||
SDL_GLDriverData));
|
||||
if (!_this->gl_data) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
_this->gl_data->initialized = 0;
|
||||
|
||||
|
@ -115,8 +114,7 @@ DirectFB_GL_LoadLibrary(_THIS, const char *path)
|
|||
SDL_DFB_DEBUG("Loadlibrary : %s\n", path);
|
||||
|
||||
if (_this->gl_data->gl_active) {
|
||||
SDL_SetError("OpenGL context already created");
|
||||
return -1;
|
||||
return SDL_SetError("OpenGL context already created");
|
||||
}
|
||||
|
||||
|
||||
|
@ -243,8 +241,7 @@ DirectFB_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
|||
int
|
||||
DirectFB_GL_SetSwapInterval(_THIS, int interval)
|
||||
{
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -657,8 +657,7 @@ DirectFB_SetTexturePalette(SDL_Renderer * renderer,
|
|||
palette->SetEntries(data->palette, entries, ncolors, firstcolor));
|
||||
return 0;
|
||||
} else {
|
||||
SDL_SetError("YUV textures don't have a palette");
|
||||
return -1;
|
||||
return SDL_SetError("YUV textures don't have a palette");
|
||||
}
|
||||
error:
|
||||
return -1;
|
||||
|
@ -688,8 +687,7 @@ DirectFB_GetTexturePalette(SDL_Renderer * renderer,
|
|||
}
|
||||
return 0;
|
||||
} else {
|
||||
SDL_SetError("YUV textures don't have a palette");
|
||||
return -1;
|
||||
return SDL_SetError("YUV textures don't have a palette");
|
||||
}
|
||||
error:
|
||||
return -1;
|
||||
|
@ -718,9 +716,8 @@ DirectFB_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
case SDL_BLENDMODE_MOD:
|
||||
return 0;
|
||||
default:
|
||||
SDL_Unsupported();
|
||||
texture->blendMode = SDL_BLENDMODE_NONE;
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -735,9 +732,8 @@ DirectFB_SetDrawBlendMode(SDL_Renderer * renderer)
|
|||
case SDL_BLENDMODE_MOD:
|
||||
return 0;
|
||||
default:
|
||||
SDL_Unsupported();
|
||||
renderer->blendMode = SDL_BLENDMODE_NONE;
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -762,10 +758,9 @@ DirectFB_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
DSRO_SMOOTH_UPSCALE | DSRO_SMOOTH_DOWNSCALE | DSRO_ANTIALIAS;
|
||||
break;
|
||||
default:
|
||||
SDL_Unsupported();
|
||||
data->render_options = DSRO_NONE;
|
||||
texture->scaleMode = SDL_SCALEMODE_NONE;
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
|
|
|
@ -176,8 +176,7 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window)
|
|||
int
|
||||
DirectFB_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
|
||||
{
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -188,8 +187,9 @@ DirectFB_SetWindowTitle(_THIS, SDL_Window * window)
|
|||
if (windata->is_managed) {
|
||||
windata->wm_needs_redraw = 1;
|
||||
DirectFB_WM_RedrawLayout(_this, window);
|
||||
} else
|
||||
} else {
|
||||
SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -65,8 +65,7 @@ int SDL_DUMMY_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect
|
|||
|
||||
surface = (SDL_Surface *) SDL_GetWindowData(window, DUMMY_SURFACE);
|
||||
if (!surface) {
|
||||
SDL_SetError("Couldn't find dummy surface for window");
|
||||
return -1;
|
||||
return SDL_SetError("Couldn't find dummy surface for window");
|
||||
}
|
||||
|
||||
/* Send the data to the display */
|
||||
|
|
|
@ -211,8 +211,7 @@ PND_createwindow(_THIS, SDL_Window * window)
|
|||
/* Allocate window internal data */
|
||||
wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
|
||||
if (wdata == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
/* Setup driver data for this window */
|
||||
|
@ -230,14 +229,12 @@ PND_createwindow(_THIS, SDL_Window * window)
|
|||
if (phdata->egl_display == EGL_NO_DISPLAY) {
|
||||
phdata->egl_display = eglGetDisplay((NativeDisplayType) 0);
|
||||
if (phdata->egl_display == EGL_NO_DISPLAY) {
|
||||
SDL_SetError("PND: Can't get connection to OpenGL ES");
|
||||
return -1;
|
||||
return SDL_SetError("PND: Can't get connection to OpenGL ES");
|
||||
}
|
||||
|
||||
initstatus = eglInitialize(phdata->egl_display, NULL, NULL);
|
||||
if (initstatus != EGL_TRUE) {
|
||||
SDL_SetError("PND: Can't init OpenGL ES library");
|
||||
return -1;
|
||||
return SDL_SetError("PND: Can't init OpenGL ES library");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -356,8 +353,7 @@ PND_gl_loadlibrary(_THIS, const char *path)
|
|||
_this->gl_config.dll_handle = SDL_LoadObject(path);
|
||||
if (!_this->gl_config.dll_handle) {
|
||||
/* Failed to load new GL ES library */
|
||||
SDL_SetError("PND: Failed to locate OpenGL ES library");
|
||||
return -1;
|
||||
return SDL_SetError("PND: Failed to locate OpenGL ES library");
|
||||
}
|
||||
|
||||
/* Store OpenGL ES library path and name */
|
||||
|
@ -726,8 +722,7 @@ PND_gl_makecurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
|||
EGLBoolean status;
|
||||
|
||||
if (phdata->egl_initialized != SDL_TRUE) {
|
||||
SDL_SetError("PND: GF initialization failed, no OpenGL ES support");
|
||||
return -1;
|
||||
return SDL_SetError("PND: GF initialization failed, no OpenGL ES support");
|
||||
}
|
||||
|
||||
if ((window == NULL) && (context == NULL)) {
|
||||
|
@ -736,33 +731,28 @@ PND_gl_makecurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
|||
EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
if (status != EGL_TRUE) {
|
||||
/* Failed to set current GL ES context */
|
||||
SDL_SetError("PND: Can't set OpenGL ES context");
|
||||
return -1;
|
||||
return SDL_SetError("PND: Can't set OpenGL ES context");
|
||||
}
|
||||
} else {
|
||||
wdata = (SDL_WindowData *) window->driverdata;
|
||||
if (wdata->gles_surface == EGL_NO_SURFACE) {
|
||||
SDL_SetError
|
||||
return SDL_SetError
|
||||
("PND: OpenGL ES surface is not initialized for this window");
|
||||
return -1;
|
||||
}
|
||||
if (wdata->gles_context == EGL_NO_CONTEXT) {
|
||||
SDL_SetError
|
||||
return SDL_SetError
|
||||
("PND: OpenGL ES context is not initialized for this window");
|
||||
return -1;
|
||||
}
|
||||
if (wdata->gles_context != context) {
|
||||
SDL_SetError
|
||||
return SDL_SetError
|
||||
("PND: OpenGL ES context is not belong to this window");
|
||||
return -1;
|
||||
}
|
||||
status =
|
||||
eglMakeCurrent(phdata->egl_display, wdata->gles_surface,
|
||||
wdata->gles_surface, wdata->gles_context);
|
||||
if (status != EGL_TRUE) {
|
||||
/* Failed to set current GL ES context */
|
||||
SDL_SetError("PND: Can't set OpenGL ES context");
|
||||
return -1;
|
||||
return SDL_SetError("PND: Can't set OpenGL ES context");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -775,8 +765,7 @@ PND_gl_setswapinterval(_THIS, int interval)
|
|||
EGLBoolean status;
|
||||
|
||||
if (phdata->egl_initialized != SDL_TRUE) {
|
||||
SDL_SetError("PND: EGL initialization failed, no OpenGL ES support");
|
||||
return -1;
|
||||
return SDL_SetError("PND: EGL initialization failed, no OpenGL ES support");
|
||||
}
|
||||
|
||||
/* Check if OpenGL ES connection has been initialized */
|
||||
|
@ -791,8 +780,7 @@ PND_gl_setswapinterval(_THIS, int interval)
|
|||
}
|
||||
|
||||
/* Failed to set swap interval */
|
||||
SDL_SetError("PND: Cannot set swap interval");
|
||||
return -1;
|
||||
return SDL_SetError("PND: Cannot set swap interval");
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -146,8 +146,7 @@ PSP_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
|||
if (!eglMakeCurrent(_this->gl_data->display, _this->gl_data->surface,
|
||||
_this->gl_data->surface, _this->gl_data->context))
|
||||
{
|
||||
SDL_SetError("Unable to make EGL context current");
|
||||
return -1;
|
||||
return SDL_SetError("Unable to make EGL context current");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -163,8 +162,7 @@ PSP_GL_SetSwapInterval(_THIS, int interval)
|
|||
return 0;
|
||||
}
|
||||
/* Failed to set swap interval */
|
||||
SDL_SetError("Unable to set the EGL swap interval");
|
||||
return -1;
|
||||
return SDL_SetError("Unable to set the EGL swap interval");
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -223,8 +223,7 @@ PSP_CreateWindow(_THIS, SDL_Window * window)
|
|||
/* Allocate window internal data */
|
||||
wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
|
||||
if (wdata == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
/* Setup driver data for this window */
|
||||
|
|
|
@ -39,8 +39,7 @@ UIKit_AllocateDisplayModeData(SDL_DisplayMode * mode,
|
|||
/* Allocate the display mode data */
|
||||
data = (SDL_DisplayModeData *) SDL_malloc(sizeof(*data));
|
||||
if (!data) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
data->uiscreenmode = uiscreenmode;
|
||||
|
@ -160,9 +159,8 @@ UIKit_AddDisplay(UIScreen *uiscreen)
|
|||
/* Allocate the display data */
|
||||
SDL_DisplayData *data = (SDL_DisplayData *) SDL_malloc(sizeof(*data));
|
||||
if (!data) {
|
||||
SDL_OutOfMemory();
|
||||
UIKit_FreeDisplayModeData(&display.desktop_mode);
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
[uiscreen retain];
|
||||
|
|
|
@ -72,8 +72,7 @@ UIKit_GL_LoadLibrary(_THIS, const char *path)
|
|||
and because the SDK forbids loading an external SO
|
||||
*/
|
||||
if (path != NULL) {
|
||||
SDL_SetError("iPhone GL Load Library just here for compatibility");
|
||||
return -1;
|
||||
return SDL_SetError("iPhone GL Load Library just here for compatibility");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -63,10 +63,10 @@ UIKit_CreateDevice(int devindex)
|
|||
/* Initialize all variables that we clean on shutdown */
|
||||
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
|
||||
if (!device) {
|
||||
SDL_OutOfMemory();
|
||||
if (device) {
|
||||
SDL_free(device);
|
||||
}
|
||||
SDL_OutOfMemory();
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,8 +54,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
|
|||
/* Allocate the window data */
|
||||
data = (SDL_WindowData *)SDL_malloc(sizeof(*data));
|
||||
if (!data) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
data->uiwindow = uiwindow;
|
||||
data->viewcontroller = nil;
|
||||
|
@ -133,8 +132,7 @@ UIKit_CreateWindow(_THIS, SDL_Window *window)
|
|||
|
||||
/* We currently only handle a single window per display on iOS */
|
||||
if (window->next != NULL) {
|
||||
SDL_SetError("Only one window allowed per display.");
|
||||
return -1;
|
||||
return SDL_SetError("Only one window allowed per display.");
|
||||
}
|
||||
|
||||
// If monitor has a resolution of 0x0 (hasn't been explicitly set by the
|
||||
|
@ -315,8 +313,7 @@ SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callbac
|
|||
SDL_WindowData *data = window ? (SDL_WindowData *)window->driverdata : NULL;
|
||||
|
||||
if (!data || !data->view) {
|
||||
SDL_SetError("Invalid window or view not set");
|
||||
return -1;
|
||||
return SDL_SetError("Invalid window or view not set");
|
||||
}
|
||||
|
||||
[data->view setAnimationCallback:interval callback:callback callbackParam:callbackParam];
|
||||
|
|
|
@ -89,8 +89,7 @@ WIN_SetClipboardText(_THIS, const char *text)
|
|||
|
||||
EmptyClipboard();
|
||||
if (!SetClipboardData(TEXT_FORMAT, hMem)) {
|
||||
WIN_SetError("Couldn't set clipboard data");
|
||||
result = -1;
|
||||
result = WIN_SetError("Couldn't set clipboard data");
|
||||
}
|
||||
data->clipboard_count = GetClipboardSequenceNumber();
|
||||
}
|
||||
|
@ -98,8 +97,7 @@ WIN_SetClipboardText(_THIS, const char *text)
|
|||
|
||||
CloseClipboard();
|
||||
} else {
|
||||
WIN_SetError("Couldn't open clipboard");
|
||||
result = -1;
|
||||
result = WIN_SetError("Couldn't open clipboard");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -809,12 +809,11 @@ SDL_RegisterApp(char *name, Uint32 style, void *hInst)
|
|||
class.cbWndExtra = 0;
|
||||
class.cbClsExtra = 0;
|
||||
if (!RegisterClass(&class)) {
|
||||
SDL_SetError("Couldn't register application class");
|
||||
return (-1);
|
||||
return SDL_SetError("Couldn't register application class");
|
||||
}
|
||||
|
||||
app_registered = 1;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Unregisters the windowclass registered in SDL_RegisterApp above. */
|
||||
|
|
|
@ -85,8 +85,7 @@ int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, voi
|
|||
SDL_stack_free(info);
|
||||
|
||||
if (!data->hbm) {
|
||||
WIN_SetError("Unable to create DIB");
|
||||
return -1;
|
||||
return WIN_SetError("Unable to create DIB");
|
||||
}
|
||||
SelectObject(data->mdc, data->hbm);
|
||||
|
||||
|
|
|
@ -214,8 +214,7 @@ WIN_InitModes(_THIS)
|
|||
}
|
||||
}
|
||||
if (_this->num_displays == 0) {
|
||||
SDL_SetError("No displays available");
|
||||
return -1;
|
||||
return SDL_SetError("No displays available");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -282,8 +281,7 @@ WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
|||
reason = "DISP_CHANGE_FAILED";
|
||||
break;
|
||||
}
|
||||
SDL_SetError("ChangeDisplaySettingsEx() failed: %s", reason);
|
||||
return -1;
|
||||
return SDL_SetError("ChangeDisplaySettingsEx() failed: %s", reason);
|
||||
}
|
||||
EnumDisplaySettings(displaydata->DeviceName, ENUM_CURRENT_SETTINGS, &data->DeviceMode);
|
||||
return 0;
|
||||
|
|
|
@ -196,8 +196,7 @@ WIN_SetRelativeMouseMode(SDL_bool enabled)
|
|||
/* Only return an error when registering. If we unregister and fail, then
|
||||
it's probably that we unregistered twice. That's OK. */
|
||||
if(enabled) {
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,8 +91,7 @@ WIN_GL_LoadLibrary(_THIS, const char *path)
|
|||
char message[1024];
|
||||
SDL_snprintf(message, SDL_arraysize(message), "LoadLibrary(\"%s\")",
|
||||
path);
|
||||
WIN_SetError(message);
|
||||
return -1;
|
||||
return WIN_SetError(message);
|
||||
}
|
||||
SDL_strlcpy(_this->gl_config.driver_path, path,
|
||||
SDL_arraysize(_this->gl_config.driver_path));
|
||||
|
@ -103,8 +102,7 @@ WIN_GL_LoadLibrary(_THIS, const char *path)
|
|||
sizeof(struct
|
||||
SDL_GLDriverData));
|
||||
if (!_this->gl_data) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
/* Load function pointers */
|
||||
|
@ -124,9 +122,8 @@ WIN_GL_LoadLibrary(_THIS, const char *path)
|
|||
!_this->gl_data->wglCreateContext ||
|
||||
!_this->gl_data->wglDeleteContext ||
|
||||
!_this->gl_data->wglMakeCurrent) {
|
||||
SDL_SetError("Could not retrieve OpenGL functions");
|
||||
SDL_UnloadObject(handle);
|
||||
return -1;
|
||||
return SDL_SetError("Could not retrieve OpenGL functions");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -512,12 +509,10 @@ WIN_GL_SetupWindow(_THIS, SDL_Window * window)
|
|||
pixel_format = WIN_GL_ChoosePixelFormat(hdc, &pfd);
|
||||
}
|
||||
if (!pixel_format) {
|
||||
SDL_SetError("No matching GL pixel format available");
|
||||
return -1;
|
||||
return SDL_SetError("No matching GL pixel format available");
|
||||
}
|
||||
if (!SetPixelFormat(hdc, pixel_format, &pfd)) {
|
||||
WIN_SetError("SetPixelFormat()");
|
||||
return (-1);
|
||||
return WIN_SetError("SetPixelFormat()");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -611,11 +606,9 @@ int
|
|||
WIN_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
||||
{
|
||||
HDC hdc;
|
||||
int status;
|
||||
|
||||
if (!_this->gl_data) {
|
||||
SDL_SetError("OpenGL not initialized");
|
||||
return -1;
|
||||
return SDL_SetError("OpenGL not initialized");
|
||||
}
|
||||
|
||||
if (window) {
|
||||
|
@ -624,30 +617,24 @@ WIN_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
|||
hdc = NULL;
|
||||
}
|
||||
if (!_this->gl_data->wglMakeCurrent(hdc, (HGLRC) context)) {
|
||||
WIN_SetError("wglMakeCurrent()");
|
||||
status = -1;
|
||||
} else {
|
||||
status = 0;
|
||||
return WIN_SetError("wglMakeCurrent()");
|
||||
}
|
||||
return status;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
WIN_GL_SetSwapInterval(_THIS, int interval)
|
||||
{
|
||||
int retval = -1;
|
||||
if ((interval < 0) && (!_this->gl_data->HAS_WGL_EXT_swap_control_tear)) {
|
||||
SDL_SetError("Negative swap interval unsupported in this GL");
|
||||
return SDL_SetError("Negative swap interval unsupported in this GL");
|
||||
} else if (_this->gl_data->wglSwapIntervalEXT) {
|
||||
if (_this->gl_data->wglSwapIntervalEXT(interval) == TRUE) {
|
||||
retval = 0;
|
||||
} else {
|
||||
WIN_SetError("wglSwapIntervalEXT()");
|
||||
if (_this->gl_data->wglSwapIntervalEXT(interval) != TRUE) {
|
||||
return WIN_SetError("wglSwapIntervalEXT()");
|
||||
}
|
||||
} else {
|
||||
SDL_Unsupported();
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
return retval;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -75,10 +75,10 @@ WIN_CreateDevice(int devindex)
|
|||
data = NULL;
|
||||
}
|
||||
if (!data) {
|
||||
SDL_OutOfMemory();
|
||||
if (device) {
|
||||
SDL_free(device);
|
||||
}
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
device->driverdata = data;
|
||||
|
|
|
@ -82,8 +82,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
|
|||
/* Allocate the window data */
|
||||
data = (SDL_WindowData *) SDL_malloc(sizeof(*data));
|
||||
if (!data) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
data->window = window;
|
||||
data->hwnd = hwnd;
|
||||
|
@ -98,8 +97,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
|
|||
if (!SetProp(hwnd, TEXT("SDL_WindowData"), data)) {
|
||||
ReleaseDC(hwnd, data->hdc);
|
||||
SDL_free(data);
|
||||
WIN_SetError("SetProp() failed");
|
||||
return -1;
|
||||
return WIN_SetError("SetProp() failed");
|
||||
}
|
||||
|
||||
/* Set up the window proc function */
|
||||
|
@ -221,8 +219,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
|
|||
CreateWindow(SDL_Appname, TEXT(""), style, x, y, w, h, NULL, NULL,
|
||||
SDL_Instance, NULL);
|
||||
if (!hwnd) {
|
||||
WIN_SetError("Couldn't create window");
|
||||
return -1;
|
||||
return WIN_SetError("Couldn't create window");
|
||||
}
|
||||
|
||||
WIN_PumpEvents(_this);
|
||||
|
@ -635,8 +632,7 @@ SDL_HelperWindowCreate(void)
|
|||
/* Register the class. */
|
||||
SDL_HelperWindowClass = RegisterClass(&wce);
|
||||
if (SDL_HelperWindowClass == 0) {
|
||||
WIN_SetError("Unable to create Helper Window Class");
|
||||
return -1;
|
||||
return WIN_SetError("Unable to create Helper Window Class");
|
||||
}
|
||||
|
||||
/* Create the window. */
|
||||
|
@ -648,8 +644,7 @@ SDL_HelperWindowCreate(void)
|
|||
hInstance, NULL);
|
||||
if (SDL_HelperWindow == NULL) {
|
||||
UnregisterClass(SDL_HelperWindowClassName, hInstance);
|
||||
WIN_SetError("Unable to create Helper Window");
|
||||
return -1;
|
||||
return WIN_SetError("Unable to create Helper Window");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -59,8 +59,7 @@ X11_SetClipboardText(_THIS, const char *text)
|
|||
/* Get the SDL window that will own the selection */
|
||||
window = GetWindow(_this);
|
||||
if (window == None) {
|
||||
SDL_SetError("Couldn't find a window to own the selection");
|
||||
return -1;
|
||||
return SDL_SetError("Couldn't find a window to own the selection");
|
||||
}
|
||||
|
||||
/* Save the selection on the root window */
|
||||
|
|
|
@ -68,20 +68,17 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format,
|
|||
gcv.graphics_exposures = False;
|
||||
data->gc = XCreateGC(display, data->xwindow, GCGraphicsExposures, &gcv);
|
||||
if (!data->gc) {
|
||||
SDL_SetError("Couldn't create graphics context");
|
||||
return -1;
|
||||
return SDL_SetError("Couldn't create graphics context");
|
||||
}
|
||||
|
||||
/* Find out the pixel format and depth */
|
||||
if (X11_GetVisualInfoFromVisual(display, data->visual, &vinfo) < 0) {
|
||||
SDL_SetError("Couldn't get window visual information");
|
||||
return -1;
|
||||
return SDL_SetError("Couldn't get window visual information");
|
||||
}
|
||||
|
||||
*format = X11_GetPixelFormatFromVisualInfo(display, &vinfo);
|
||||
if (*format == SDL_PIXELFORMAT_UNKNOWN) {
|
||||
SDL_SetError("Unknown window pixel format");
|
||||
return -1;
|
||||
return SDL_SetError("Unknown window pixel format");
|
||||
}
|
||||
|
||||
/* Calculate pitch */
|
||||
|
@ -132,8 +129,7 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format,
|
|||
|
||||
*pixels = SDL_malloc(window->h*(*pitch));
|
||||
if (*pixels == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
data->ximage = XCreateImage(display, data->visual,
|
||||
|
@ -141,8 +137,7 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format,
|
|||
window->w, window->h, 32, 0);
|
||||
if (!data->ximage) {
|
||||
SDL_free(*pixels);
|
||||
SDL_SetError("Couldn't create XImage");
|
||||
return -1;
|
||||
return SDL_SetError("Couldn't create XImage");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -168,8 +168,7 @@ X11_MessageBoxInit( SDL_MessageBoxDataX11 *data, const SDL_MessageBoxData * mess
|
|||
const SDL_MessageBoxColor *colorhints;
|
||||
|
||||
if ( numbuttons > MAX_BUTTONS ) {
|
||||
SDL_SetError("Too many buttons (%d max allowed)", MAX_BUTTONS);
|
||||
return -1;
|
||||
return SDL_SetError("Too many buttons (%d max allowed)", MAX_BUTTONS);
|
||||
}
|
||||
|
||||
data->dialog_width = MIN_DIALOG_WIDTH;
|
||||
|
@ -181,8 +180,7 @@ X11_MessageBoxInit( SDL_MessageBoxDataX11 *data, const SDL_MessageBoxData * mess
|
|||
|
||||
data->display = XOpenDisplay( NULL );
|
||||
if ( !data->display ) {
|
||||
SDL_SetError("Couldn't open X11 display");
|
||||
return -1;
|
||||
return SDL_SetError("Couldn't open X11 display");
|
||||
}
|
||||
|
||||
if (SDL_X11_HAVE_UTF8) {
|
||||
|
@ -194,14 +192,12 @@ X11_MessageBoxInit( SDL_MessageBoxDataX11 *data, const SDL_MessageBoxData * mess
|
|||
XFreeStringList(missing);
|
||||
}
|
||||
if ( data->font_set == NULL ) {
|
||||
SDL_SetError("Couldn't load font %s", g_MessageBoxFont);
|
||||
return -1;
|
||||
return SDL_SetError("Couldn't load font %s", g_MessageBoxFont);
|
||||
}
|
||||
} else {
|
||||
data->font_struct = XLoadQueryFont( data->display, g_MessageBoxFontLatin1 );
|
||||
if ( data->font_struct == NULL ) {
|
||||
SDL_SetError("Couldn't load font %s", g_MessageBoxFontLatin1);
|
||||
return -1;
|
||||
return SDL_SetError("Couldn't load font %s", g_MessageBoxFontLatin1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -388,8 +384,7 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data )
|
|||
0, CopyFromParent, InputOutput, CopyFromParent,
|
||||
CWEventMask, &wnd_attr );
|
||||
if ( data->window == None ) {
|
||||
SDL_SetError("Couldn't create X window");
|
||||
return -1;
|
||||
return SDL_SetError("Couldn't create X window");
|
||||
}
|
||||
|
||||
if ( windowdata ) {
|
||||
|
@ -520,8 +515,7 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data )
|
|||
|
||||
ctx = XCreateGC( data->display, data->window, gcflags, &ctx_vals );
|
||||
if ( ctx == None ) {
|
||||
SDL_SetError("Couldn't create graphics context");
|
||||
return -1;
|
||||
return SDL_SetError("Couldn't create graphics context");
|
||||
}
|
||||
|
||||
data->button_press_index = -1; /* Reset what button is currently depressed. */
|
||||
|
@ -660,8 +654,7 @@ X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|||
if (origlocale != NULL) {
|
||||
origlocale = SDL_strdup(origlocale);
|
||||
if (origlocale == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
setlocale(LC_ALL, "");
|
||||
}
|
||||
|
@ -739,8 +732,7 @@ X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|||
SDL_assert(rc == pid); /* not sure what to do if this fails. */
|
||||
|
||||
if ((rc == -1) || (!WIFEXITED(status)) || (WEXITSTATUS(status) != 0)) {
|
||||
SDL_SetError("msgbox child process failed");
|
||||
return -1;
|
||||
return SDL_SetError("msgbox child process failed");
|
||||
}
|
||||
|
||||
if (read(fds[0], &status, sizeof (int)) != sizeof (int))
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue