mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-15 09:18:27 +00:00
Include stdbool.h when using Visual Studio 2017+
Also cleaned up some incorrect return values from bool functions.
This commit is contained in:
parent
522321b7c9
commit
4fa92d233d
9 changed files with 17 additions and 16 deletions
|
@ -46,6 +46,7 @@
|
||||||
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
|
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
|
||||||
|
(defined(_MSC_VER) && (_MSC_VER >= 1910 /* Visual Studio 2017 */)) || \
|
||||||
defined(SDL_INCLUDE_STDBOOL_H)
|
defined(SDL_INCLUDE_STDBOOL_H)
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#elif !defined(__bool_true_false_are_defined) && !defined(bool)
|
#elif !defined(__bool_true_false_are_defined) && !defined(bool)
|
||||||
|
|
|
@ -306,12 +306,12 @@ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
|
||||||
|
|
||||||
BOOL WIN_IsEqualGUID(const GUID *a, const GUID *b)
|
BOOL WIN_IsEqualGUID(const GUID *a, const GUID *b)
|
||||||
{
|
{
|
||||||
return SDL_memcmp(a, b, sizeof(*a)) == 0;
|
return (SDL_memcmp(a, b, sizeof(*a)) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WIN_IsEqualIID(REFIID a, REFIID b)
|
BOOL WIN_IsEqualIID(REFIID a, REFIID b)
|
||||||
{
|
{
|
||||||
return SDL_memcmp(a, b, sizeof(*a)) == 0;
|
return (SDL_memcmp(a, b, sizeof(*a)) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect)
|
void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect)
|
||||||
|
|
|
@ -45,7 +45,7 @@ bool SDL_SYS_EnumerateDirectory(const char *path, const char *dirname, SDL_Enume
|
||||||
const size_t patternlen = SDL_strlen(path) + 3;
|
const size_t patternlen = SDL_strlen(path) + 3;
|
||||||
char *pattern = (char *) SDL_malloc(patternlen);
|
char *pattern = (char *) SDL_malloc(patternlen);
|
||||||
if (!pattern) {
|
if (!pattern) {
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// you need a wildcard to enumerate through FindFirstFileEx(), but the wildcard is only checked in the
|
// you need a wildcard to enumerate through FindFirstFileEx(), but the wildcard is only checked in the
|
||||||
|
@ -56,15 +56,14 @@ bool SDL_SYS_EnumerateDirectory(const char *path, const char *dirname, SDL_Enume
|
||||||
WCHAR *wpattern = WIN_UTF8ToStringW(pattern);
|
WCHAR *wpattern = WIN_UTF8ToStringW(pattern);
|
||||||
SDL_free(pattern);
|
SDL_free(pattern);
|
||||||
if (!wpattern) {
|
if (!wpattern) {
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
WIN32_FIND_DATAW entw;
|
WIN32_FIND_DATAW entw;
|
||||||
HANDLE dir = FindFirstFileExW(wpattern, FindExInfoStandard, &entw, FindExSearchNameMatch, NULL, 0);
|
HANDLE dir = FindFirstFileExW(wpattern, FindExInfoStandard, &entw, FindExSearchNameMatch, NULL, 0);
|
||||||
SDL_free(wpattern);
|
SDL_free(wpattern);
|
||||||
if (dir == INVALID_HANDLE_VALUE) {
|
if (dir == INVALID_HANDLE_VALUE) {
|
||||||
WIN_SetError("Failed to enumerate directory");
|
return WIN_SetError("Failed to enumerate directory");
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -518,7 +518,7 @@ bool SDL_GetHapticEffectStatus(SDL_Haptic *haptic, int effect)
|
||||||
|
|
||||||
SDL_ClearError();
|
SDL_ClearError();
|
||||||
|
|
||||||
return SDL_SYS_HapticGetEffectStatus(haptic, &haptic->effects[effect]);
|
return (SDL_SYS_HapticGetEffectStatus(haptic, &haptic->effects[effect]) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDL_SetHapticGain(SDL_Haptic *haptic, int gain)
|
bool SDL_SetHapticGain(SDL_Haptic *haptic, int gain)
|
||||||
|
|
|
@ -455,7 +455,7 @@ bool SDL_DINPUT_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return WIN_IsEqualGUID(&hap_instance.guidInstance, &joy_instance.guidInstance);
|
return (WIN_IsEqualGUID(&hap_instance.guidInstance, &joy_instance.guidInstance) == TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
|
bool SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
|
||||||
|
@ -1052,13 +1052,14 @@ int SDL_DINPUT_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *e
|
||||||
|
|
||||||
ret = IDirectInputEffect_GetEffectStatus(effect->hweffect->ref, &status);
|
ret = IDirectInputEffect_GetEffectStatus(effect->hweffect->ref, &status);
|
||||||
if (FAILED(ret)) {
|
if (FAILED(ret)) {
|
||||||
return DI_SetError("Getting effect status", ret);
|
DI_SetError("Getting effect status", ret);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
return true;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDL_DINPUT_HapticSetGain(SDL_Haptic *haptic, int gain)
|
bool SDL_DINPUT_HapticSetGain(SDL_Haptic *haptic, int gain)
|
||||||
|
|
|
@ -1505,7 +1505,7 @@ bool SDL_GetJoystickBall(SDL_Joystick *joystick, int ball, int *dx, int *dy)
|
||||||
|
|
||||||
SDL_LockJoysticks();
|
SDL_LockJoysticks();
|
||||||
{
|
{
|
||||||
CHECK_JOYSTICK_MAGIC(joystick, -1);
|
CHECK_JOYSTICK_MAGIC(joystick, false);
|
||||||
|
|
||||||
if (ball < joystick->nballs) {
|
if (ball < joystick->nballs) {
|
||||||
if (dx) {
|
if (dx) {
|
||||||
|
|
|
@ -95,7 +95,7 @@ static bool STEAM_ReadStorageFile(void *userdata, const char *path, void *destin
|
||||||
|
|
||||||
static bool STEAM_WriteStorageFile(void *userdata, const char *path, const void *source, Uint64 length)
|
static bool STEAM_WriteStorageFile(void *userdata, const char *path, const void *source, Uint64 length)
|
||||||
{
|
{
|
||||||
int result = false;
|
bool result = false;
|
||||||
STEAM_RemoteStorage *steam = (STEAM_RemoteStorage*) userdata;
|
STEAM_RemoteStorage *steam = (STEAM_RemoteStorage*) userdata;
|
||||||
void *steamremotestorage = steam->SteamAPI_SteamRemoteStorage_v016();
|
void *steamremotestorage = steam->SteamAPI_SteamRemoteStorage_v016();
|
||||||
if (steamremotestorage == NULL) {
|
if (steamremotestorage == NULL) {
|
||||||
|
|
|
@ -119,7 +119,7 @@ static bool SDL_WaitConditionTimeoutNS_cv(SDL_Condition *_cond, SDL_Mutex *_mute
|
||||||
mutex->count = 0;
|
mutex->count = 0;
|
||||||
mutex->owner = 0;
|
mutex->owner = 0;
|
||||||
|
|
||||||
result = pSleepConditionVariableSRW(&cond->cond, &mutex->srw, timeout, 0);
|
result = (pSleepConditionVariableSRW(&cond->cond, &mutex->srw, timeout, 0) == TRUE);
|
||||||
|
|
||||||
// The mutex is owned by us again, regardless of status of the wait
|
// The mutex is owned by us again, regardless of status of the wait
|
||||||
SDL_assert(mutex->count == 0 && mutex->owner == 0);
|
SDL_assert(mutex->count == 0 && mutex->owner == 0);
|
||||||
|
@ -130,7 +130,7 @@ static bool SDL_WaitConditionTimeoutNS_cv(SDL_Condition *_cond, SDL_Mutex *_mute
|
||||||
|
|
||||||
SDL_assert(SDL_mutex_impl_active.Type == SDL_MUTEX_CS);
|
SDL_assert(SDL_mutex_impl_active.Type == SDL_MUTEX_CS);
|
||||||
|
|
||||||
result = pSleepConditionVariableCS(&cond->cond, &mutex->cs, timeout);
|
result = (pSleepConditionVariableCS(&cond->cond, &mutex->cs, timeout) == TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -157,7 +157,7 @@ static void SDL_LockMutex_cs(SDL_Mutex *mutex_) SDL_NO_THREAD_SAFETY_ANALYSIS /
|
||||||
static bool SDL_TryLockMutex_cs(SDL_Mutex *mutex_)
|
static bool SDL_TryLockMutex_cs(SDL_Mutex *mutex_)
|
||||||
{
|
{
|
||||||
SDL_mutex_cs *mutex = (SDL_mutex_cs *)mutex_;
|
SDL_mutex_cs *mutex = (SDL_mutex_cs *)mutex_;
|
||||||
return TryEnterCriticalSection(&mutex->cs);
|
return (TryEnterCriticalSection(&mutex->cs) == TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_UnlockMutex_cs(SDL_Mutex *mutex_) SDL_NO_THREAD_SAFETY_ANALYSIS // clang doesn't know about NULL mutexes
|
static void SDL_UnlockMutex_cs(SDL_Mutex *mutex_) SDL_NO_THREAD_SAFETY_ANALYSIS // clang doesn't know about NULL mutexes
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue