Code cleanup now that SDL_bool is equivalent to a C boolean expression

This commit is contained in:
Sam Lantinga
2023-11-03 09:27:29 -07:00
parent a76d8e39aa
commit f3261fedcc
53 changed files with 133 additions and 138 deletions

View File

@@ -505,8 +505,8 @@ static void UpdatePowerLevelWii(SDL_Joystick *joystick, Uint8 batteryLevelByte)
static void UpdatePowerLevelWiiU(SDL_Joystick *joystick, Uint8 extensionBatteryByte)
{
SDL_bool charging = extensionBatteryByte & 0x08 ? SDL_FALSE : SDL_TRUE;
SDL_bool pluggedIn = extensionBatteryByte & 0x04 ? SDL_FALSE : SDL_TRUE;
SDL_bool charging = !(extensionBatteryByte & 0x08);
SDL_bool pluggedIn = !(extensionBatteryByte & 0x04);
Uint8 batteryLevel = extensionBatteryByte >> 4;
/* Not sure if all Wii U Pro controllers act like this, but on mine
@@ -814,7 +814,7 @@ static SDL_bool HIDAPI_DriverWii_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy
static int HIDAPI_DriverWii_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
{
SDL_DriverWii_Context *ctx = (SDL_DriverWii_Context *)device->context;
SDL_bool active = (low_frequency_rumble || high_frequency_rumble) ? SDL_TRUE : SDL_FALSE;
SDL_bool active = (low_frequency_rumble || high_frequency_rumble);
if (active != ctx->m_bRumbleActive) {
Uint8 data[2];
@@ -1407,7 +1407,7 @@ static void GetExtensionData(WiiButtonData *dst, const Uint8 *src, int size)
static void HandleStatus(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick)
{
SDL_bool hadExtension = ctx->m_eExtensionControllerType != k_eWiiExtensionControllerType_None;
SDL_bool hasExtension = ctx->m_rgucReadBuffer[3] & 2 ? SDL_TRUE : SDL_FALSE;
SDL_bool hasExtension = (ctx->m_rgucReadBuffer[3] & 2) ? SDL_TRUE : SDL_FALSE;
WiiButtonData data;
SDL_zero(data);
GetBaseButtons(&data, ctx->m_rgucReadBuffer + 1);