Use C99 bool internally in SDL

This commit is contained in:
Sam Lantinga
2024-08-22 09:21:26 -07:00
parent 6501e90018
commit 8f546bb3c9
450 changed files with 6046 additions and 6033 deletions

View File

@@ -44,7 +44,7 @@ int SDL_InitHaptics(void)
return status;
}
static SDL_bool SDL_GetHapticIndex(SDL_HapticID instance_id, int *driver_index)
static bool SDL_GetHapticIndex(SDL_HapticID instance_id, int *driver_index)
{
int num_haptics, device_index;
@@ -54,13 +54,13 @@ static SDL_bool SDL_GetHapticIndex(SDL_HapticID instance_id, int *driver_index)
SDL_HapticID haptic_id = SDL_SYS_HapticInstanceID(device_index);
if (haptic_id == instance_id) {
*driver_index = device_index;
return SDL_TRUE;
return true;
}
}
}
SDL_SetError("Haptic device %" SDL_PRIu32 " not found", instance_id);
return SDL_FALSE;
return false;
}
SDL_HapticID *SDL_GetHaptics(int *count)
@@ -134,7 +134,7 @@ SDL_Haptic *SDL_OpenHaptic(SDL_HapticID instance_id)
}
// Initialize the haptic device
SDL_SetObjectValid(haptic, SDL_OBJECT_TYPE_HAPTIC, SDL_TRUE);
SDL_SetObjectValid(haptic, SDL_OBJECT_TYPE_HAPTIC, true);
haptic->instance_id = instance_id;
haptic->rumble_id = -1;
if (SDL_SYS_HapticOpen(haptic) < 0) {
@@ -195,9 +195,9 @@ const char *SDL_GetHapticName(SDL_Haptic *haptic)
SDL_bool SDL_IsMouseHaptic(void)
{
if (SDL_SYS_HapticMouse() < 0) {
return SDL_FALSE;
return false;
}
return SDL_TRUE;
return true;
}
SDL_Haptic *SDL_OpenHapticFromMouse(void)
@@ -216,7 +216,7 @@ SDL_Haptic *SDL_OpenHapticFromMouse(void)
SDL_bool SDL_IsJoystickHaptic(SDL_Joystick *joystick)
{
SDL_bool result = SDL_FALSE;
bool result = false;
SDL_LockJoysticks();
{
@@ -315,7 +315,7 @@ void SDL_CloseHaptic(SDL_Haptic *haptic)
}
}
SDL_SYS_HapticClose(haptic);
SDL_SetObjectValid(haptic, SDL_OBJECT_TYPE_HAPTIC, SDL_FALSE);
SDL_SetObjectValid(haptic, SDL_OBJECT_TYPE_HAPTIC, false);
// Remove from the list
hapticlist = SDL_haptics;
@@ -379,16 +379,16 @@ int SDL_GetNumHapticAxes(SDL_Haptic *haptic)
SDL_bool SDL_HapticEffectSupported(SDL_Haptic *haptic, const SDL_HapticEffect *effect)
{
CHECK_HAPTIC_MAGIC(haptic, SDL_FALSE);
CHECK_HAPTIC_MAGIC(haptic, false);
if (!effect) {
return SDL_FALSE;
return false;
}
if ((haptic->supported & effect->type) != 0) {
return SDL_TRUE;
return true;
}
return SDL_FALSE;
return false;
}
int SDL_CreateHapticEffect(SDL_Haptic *haptic, const SDL_HapticEffect *effect)
@@ -402,7 +402,7 @@ int SDL_CreateHapticEffect(SDL_Haptic *haptic, const SDL_HapticEffect *effect)
}
// Check to see if effect is supported
if (SDL_HapticEffectSupported(haptic, effect) == SDL_FALSE) {
if (SDL_HapticEffectSupported(haptic, effect) == false) {
return SDL_SetError("Haptic: Effect not supported by haptic device.");
}
@@ -614,7 +614,7 @@ int SDL_StopHapticEffects(SDL_Haptic *haptic)
SDL_bool SDL_HapticRumbleSupported(SDL_Haptic *haptic)
{
CHECK_HAPTIC_MAGIC(haptic, SDL_FALSE);
CHECK_HAPTIC_MAGIC(haptic, false);
// Most things can use SINE, but XInput only has LEFTRIGHT.
return (haptic->supported & (SDL_HAPTIC_SINE | SDL_HAPTIC_LEFTRIGHT)) != 0;

View File

@@ -93,7 +93,7 @@ int SDL_SYS_HapticMouse(void);
/*
* Checks to see if the joystick has haptic capabilities.
*/
extern SDL_bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick);
extern bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick);
/*
* Opens the haptic device for usage using the same device as
@@ -106,9 +106,9 @@ extern int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic,
/*
* Checks to see if haptic device and joystick device are the same.
*
* Returns SDL_TRUE if they are the same, SDL_FALSE if they aren't.
* Returns true if they are the same, false if they aren't.
*/
extern SDL_bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic,
extern bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic,
SDL_Joystick *joystick);
/*

View File

@@ -138,9 +138,9 @@ int SDL_SYS_HapticMouse(void)
return -1;
}
SDL_bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
{
return SDL_FALSE;
return false;
}
int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
@@ -148,9 +148,9 @@ int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
return SDL_Unsupported();
}
SDL_bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
{
return SDL_FALSE;
return false;
}
void SDL_SYS_HapticClose(SDL_Haptic *haptic)

View File

@@ -587,34 +587,34 @@ int SDL_SYS_HapticMouse(void)
/*
* Checks to see if a joystick has haptic features.
*/
SDL_bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
{
#ifdef SDL_JOYSTICK_IOKIT
if (joystick->driver != &SDL_DARWIN_JoystickDriver) {
return SDL_FALSE;
return false;
}
if (joystick->hwdata->ffservice != 0) {
return SDL_TRUE;
return true;
}
#endif
return SDL_FALSE;
return false;
}
/*
* Checks to see if the haptic device and joystick are in reality the same.
*/
SDL_bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
{
#ifdef SDL_JOYSTICK_IOKIT
if (joystick->driver != &SDL_DARWIN_JoystickDriver) {
return SDL_FALSE;
return false;
}
if (IOObjectIsEqualTo((io_object_t)((size_t)haptic->hwdata->device),
joystick->hwdata->ffservice)) {
return SDL_TRUE;
return true;
}
#endif
return SDL_FALSE;
return false;
}
/*
@@ -1277,9 +1277,9 @@ int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic,
}
if (status == 0) {
return SDL_FALSE;
return false;
}
return SDL_TRUE; // Assume it's playing or emulated.
return true; // Assume it's playing or emulated.
}
/*

View File

@@ -61,9 +61,9 @@ int SDL_SYS_HapticMouse(void)
return -1;
}
SDL_bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
{
return SDL_FALSE;
return false;
}
int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
@@ -71,9 +71,9 @@ int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
return SDL_SYS_LogicError();
}
SDL_bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
{
return SDL_FALSE;
return false;
}
void SDL_SYS_HapticClose(SDL_Haptic *haptic)

View File

@@ -503,39 +503,39 @@ int SDL_SYS_HapticMouse(void)
/*
* Checks to see if a joystick has haptic features.
*/
SDL_bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
{
#ifdef SDL_JOYSTICK_LINUX
SDL_AssertJoysticksLocked();
if (joystick->driver != &SDL_LINUX_JoystickDriver) {
return SDL_FALSE;
return false;
}
if (EV_IsHaptic(joystick->hwdata->fd)) {
return SDL_TRUE;
return true;
}
#endif
return SDL_FALSE;
return false;
}
/*
* Checks to see if the haptic device and joystick are in reality the same.
*/
SDL_bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
{
#ifdef SDL_JOYSTICK_LINUX
SDL_AssertJoysticksLocked();
if (joystick->driver != &SDL_LINUX_JoystickDriver) {
return SDL_FALSE;
return false;
}
/* We are assuming Linux is using evdev which should trump the old
* joystick methods. */
if (SDL_strcmp(joystick->hwdata->fname, haptic->hwdata->fname) == 0) {
return SDL_TRUE;
return true;
}
#endif
return SDL_FALSE;
return false;
}
/*

View File

@@ -40,7 +40,7 @@ static const HWND SDL_HelperWindow = NULL;
/*
* Internal stuff.
*/
static SDL_bool coinitialized = SDL_FALSE;
static bool coinitialized = false;
static LPDIRECTINPUT8 dinput = NULL;
/*
@@ -71,7 +71,7 @@ int SDL_DINPUT_HapticInit(void)
return SDL_SetError("Haptic: SubSystem already open.");
}
if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_DIRECTINPUT, SDL_TRUE)) {
if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_DIRECTINPUT, true)) {
// In some environments, IDirectInput8_Initialize / _EnumDevices can take a minute even with no controllers.
return 0;
}
@@ -81,7 +81,7 @@ int SDL_DINPUT_HapticInit(void)
return DI_SetError("Coinitialize", ret);
}
coinitialized = SDL_TRUE;
coinitialized = true;
ret = CoCreateInstance(&CLSID_DirectInput8, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectInput8, (LPVOID *)&dinput);
@@ -280,7 +280,7 @@ static BOOL CALLBACK DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv)
* - Reset actuators.
* - Get supported features.
*/
static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVICE8 device8, SDL_bool is_joystick)
static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVICE8 device8, bool is_joystick)
{
HRESULT ret;
DIPROPDWORD dipdw;
@@ -428,7 +428,7 @@ int SDL_DINPUT_HapticOpen(SDL_Haptic *haptic, SDL_hapticlist_item *item)
return -1;
}
if (SDL_DINPUT_HapticOpenFromDevice(haptic, device, SDL_FALSE) < 0) {
if (SDL_DINPUT_HapticOpenFromDevice(haptic, device, false) < 0) {
IDirectInputDevice8_Release(device);
return -1;
}
@@ -475,7 +475,7 @@ int SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick
if (WIN_IsEqualGUID(&item->instance.guidInstance, &joy_instance.guidInstance)) {
haptic->instance_id = item->instance_id;
haptic->name = SDL_strdup(item->name);
return SDL_DINPUT_HapticOpenFromDevice(haptic, joystick->hwdata->InputDevice, SDL_TRUE);
return SDL_DINPUT_HapticOpenFromDevice(haptic, joystick->hwdata->InputDevice, true);
}
}
@@ -501,7 +501,7 @@ void SDL_DINPUT_HapticQuit(void)
if (coinitialized) {
WIN_CoUninitialize();
coinitialized = SDL_FALSE;
coinitialized = false;
}
}
@@ -1056,9 +1056,9 @@ int SDL_DINPUT_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *e
}
if (status == 0) {
return SDL_FALSE;
return false;
}
return SDL_TRUE;
return true;
}
int SDL_DINPUT_HapticSetGain(SDL_Haptic *haptic, int gain)

View File

@@ -180,24 +180,24 @@ int SDL_SYS_HapticMouse(void)
/*
* Checks to see if a joystick has haptic features.
*/
SDL_bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
{
if (joystick->driver != &SDL_WINDOWS_JoystickDriver) {
return SDL_FALSE;
return false;
}
if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) {
return SDL_TRUE;
return true;
}
return SDL_FALSE;
return false;
}
/*
* Checks to see if the haptic device and joystick are in reality the same.
*/
SDL_bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
{
if (joystick->driver != &SDL_WINDOWS_JoystickDriver) {
return SDL_FALSE;
return false;
}
return SDL_DINPUT_JoystickSameHaptic(haptic, joystick);
}

View File

@@ -41,7 +41,7 @@ struct haptic_hwdata
LPDIRECTINPUTDEVICE8 device;
#endif
DWORD axes[3]; // Axes to use.
SDL_bool is_joystick; // Device is loaded as joystick.
bool is_joystick; // Device is loaded as joystick.
SDL_Thread *thread;
SDL_Mutex *mutex;
Uint64 stopTicks;