mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-07 02:16:26 +00:00
Clang-Tidy fixes (#6725)
This commit is contained in:
@@ -240,12 +240,13 @@ int SDL_JoystickIsHaptic(SDL_Joystick *joystick)
|
||||
|
||||
ret = SDL_SYS_JoystickIsHaptic(joystick);
|
||||
|
||||
if (ret > 0)
|
||||
if (ret > 0) {
|
||||
return SDL_TRUE;
|
||||
else if (ret == 0)
|
||||
} else if (ret == 0) {
|
||||
return SDL_FALSE;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -163,7 +163,6 @@ void SDL_SYS_HapticClose(SDL_Haptic *haptic)
|
||||
{
|
||||
((SDL_hapticlist_item *)haptic->hwdata)->haptic = NULL;
|
||||
haptic->hwdata = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
void SDL_SYS_HapticQuit(void)
|
||||
@@ -219,11 +218,9 @@ int SDL_SYS_HapticStopEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
|
||||
|
||||
void SDL_SYS_HapticDestroyEffect(SDL_Haptic *haptic, struct haptic_effect *effect)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic,
|
||||
struct haptic_effect *effect)
|
||||
int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *effect)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1201,8 +1201,9 @@ int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
|
||||
/* Check if it's infinite. */
|
||||
if (iterations == SDL_HAPTIC_INFINITY) {
|
||||
iter = FF_INFINITE;
|
||||
} else
|
||||
} else {
|
||||
iter = iterations;
|
||||
}
|
||||
|
||||
/* Run the effect. */
|
||||
ret = FFEffectStart(effect->hweffect->ref, iter, 0);
|
||||
|
@@ -152,8 +152,7 @@ int SDL_SYS_HapticInit(void)
|
||||
*/
|
||||
i = 0;
|
||||
for (j = 0; j < MAX_HAPTICS; ++j) {
|
||||
|
||||
SDL_snprintf(path, PATH_MAX, joydev_pattern, i++);
|
||||
(void)SDL_snprintf(path, PATH_MAX, joydev_pattern, i++);
|
||||
MaybeAddDevice(path);
|
||||
}
|
||||
|
||||
@@ -665,11 +664,11 @@ static int SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection *src)
|
||||
break;
|
||||
|
||||
case SDL_HAPTIC_CARTESIAN:
|
||||
if (!src->dir[1])
|
||||
if (!src->dir[1]) {
|
||||
*dest = (src->dir[0] >= 0 ? 0x4000 : 0xC000);
|
||||
else if (!src->dir[0])
|
||||
} else if (!src->dir[0]) {
|
||||
*dest = (src->dir[1] >= 0 ? 0x8000 : 0);
|
||||
else {
|
||||
} else {
|
||||
float f = SDL_atan2(src->dir[1], src->dir[0]); /* Ideally we'd use fixed point math instead of floats... */
|
||||
/*
|
||||
SDL_atan2 takes the parameters: Y-axis-value and X-axis-value (in that order)
|
||||
|
@@ -658,10 +658,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||
dest->lpvTypeSpecificParams = constant;
|
||||
|
||||
/* Generics */
|
||||
dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */
|
||||
dest->dwDuration = hap_constant->length * 1000UL; /* In microseconds. */
|
||||
dest->dwTriggerButton = DIGetTriggerButton(hap_constant->button);
|
||||
dest->dwTriggerRepeatInterval = hap_constant->interval;
|
||||
dest->dwStartDelay = hap_constant->delay * 1000; /* In microseconds. */
|
||||
dest->dwStartDelay = hap_constant->delay * 1000UL; /* In microseconds. */
|
||||
|
||||
/* Direction. */
|
||||
if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) {
|
||||
@@ -674,9 +674,9 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||
dest->lpEnvelope = NULL;
|
||||
} else {
|
||||
envelope->dwAttackLevel = CCONVERT(hap_constant->attack_level);
|
||||
envelope->dwAttackTime = hap_constant->attack_length * 1000;
|
||||
envelope->dwAttackTime = hap_constant->attack_length * 1000UL;
|
||||
envelope->dwFadeLevel = CCONVERT(hap_constant->fade_level);
|
||||
envelope->dwFadeTime = hap_constant->fade_length * 1000;
|
||||
envelope->dwFadeTime = hap_constant->fade_length * 1000UL;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -704,10 +704,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||
dest->lpvTypeSpecificParams = periodic;
|
||||
|
||||
/* Generics */
|
||||
dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */
|
||||
dest->dwDuration = hap_periodic->length * 1000UL; /* In microseconds. */
|
||||
dest->dwTriggerButton = DIGetTriggerButton(hap_periodic->button);
|
||||
dest->dwTriggerRepeatInterval = hap_periodic->interval;
|
||||
dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */
|
||||
dest->dwStartDelay = hap_periodic->delay * 1000UL; /* In microseconds. */
|
||||
|
||||
/* Direction. */
|
||||
if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) {
|
||||
@@ -720,9 +720,9 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||
dest->lpEnvelope = NULL;
|
||||
} else {
|
||||
envelope->dwAttackLevel = CCONVERT(hap_periodic->attack_level);
|
||||
envelope->dwAttackTime = hap_periodic->attack_length * 1000;
|
||||
envelope->dwAttackTime = hap_periodic->attack_length * 1000UL;
|
||||
envelope->dwFadeLevel = CCONVERT(hap_periodic->fade_level);
|
||||
envelope->dwFadeTime = hap_periodic->fade_length * 1000;
|
||||
envelope->dwFadeTime = hap_periodic->fade_length * 1000UL;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -755,10 +755,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||
dest->lpvTypeSpecificParams = condition;
|
||||
|
||||
/* Generics */
|
||||
dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */
|
||||
dest->dwDuration = hap_condition->length * 1000UL; /* In microseconds. */
|
||||
dest->dwTriggerButton = DIGetTriggerButton(hap_condition->button);
|
||||
dest->dwTriggerRepeatInterval = hap_condition->interval;
|
||||
dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */
|
||||
dest->dwStartDelay = hap_condition->delay * 1000UL; /* In microseconds. */
|
||||
|
||||
/* Direction. */
|
||||
if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) {
|
||||
@@ -786,10 +786,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||
dest->lpvTypeSpecificParams = ramp;
|
||||
|
||||
/* Generics */
|
||||
dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */
|
||||
dest->dwDuration = hap_ramp->length * 1000UL; /* In microseconds. */
|
||||
dest->dwTriggerButton = DIGetTriggerButton(hap_ramp->button);
|
||||
dest->dwTriggerRepeatInterval = hap_ramp->interval;
|
||||
dest->dwStartDelay = hap_ramp->delay * 1000; /* In microseconds. */
|
||||
dest->dwStartDelay = hap_ramp->delay * 1000UL; /* In microseconds. */
|
||||
|
||||
/* Direction. */
|
||||
if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) {
|
||||
@@ -802,9 +802,9 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||
dest->lpEnvelope = NULL;
|
||||
} else {
|
||||
envelope->dwAttackLevel = CCONVERT(hap_ramp->attack_level);
|
||||
envelope->dwAttackTime = hap_ramp->attack_length * 1000;
|
||||
envelope->dwAttackTime = hap_ramp->attack_length * 1000UL;
|
||||
envelope->dwFadeLevel = CCONVERT(hap_ramp->fade_level);
|
||||
envelope->dwFadeTime = hap_ramp->fade_length * 1000;
|
||||
envelope->dwFadeTime = hap_ramp->fade_length * 1000UL;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -819,7 +819,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||
|
||||
/* Specifics */
|
||||
custom->cChannels = hap_custom->channels;
|
||||
custom->dwSamplePeriod = hap_custom->period * 1000;
|
||||
custom->dwSamplePeriod = hap_custom->period * 1000UL;
|
||||
custom->cSamples = hap_custom->samples;
|
||||
custom->rglForceData =
|
||||
SDL_malloc(sizeof(LONG) * custom->cSamples * custom->cChannels);
|
||||
@@ -830,10 +830,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||
dest->lpvTypeSpecificParams = custom;
|
||||
|
||||
/* Generics */
|
||||
dest->dwDuration = hap_custom->length * 1000; /* In microseconds. */
|
||||
dest->dwDuration = hap_custom->length * 1000UL; /* In microseconds. */
|
||||
dest->dwTriggerButton = DIGetTriggerButton(hap_custom->button);
|
||||
dest->dwTriggerRepeatInterval = hap_custom->interval;
|
||||
dest->dwStartDelay = hap_custom->delay * 1000; /* In microseconds. */
|
||||
dest->dwStartDelay = hap_custom->delay * 1000UL; /* In microseconds. */
|
||||
|
||||
/* Direction. */
|
||||
if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) < 0) {
|
||||
@@ -846,9 +846,9 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
|
||||
dest->lpEnvelope = NULL;
|
||||
} else {
|
||||
envelope->dwAttackLevel = CCONVERT(hap_custom->attack_level);
|
||||
envelope->dwAttackTime = hap_custom->attack_length * 1000;
|
||||
envelope->dwAttackTime = hap_custom->attack_length * 1000UL;
|
||||
envelope->dwFadeLevel = CCONVERT(hap_custom->fade_level);
|
||||
envelope->dwFadeTime = hap_custom->fade_length * 1000;
|
||||
envelope->dwFadeTime = hap_custom->fade_length * 1000UL;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -887,6 +887,7 @@ static void SDL_SYS_HapticFreeDIEFFECT(DIEFFECT *effect, int type)
|
||||
/*
|
||||
* Gets the effect type from the generic SDL haptic effect wrapper.
|
||||
*/
|
||||
/* NOLINTNEXTLINE(readability-const-return-type): Can't fix Windows' headers */
|
||||
static REFGUID SDL_SYS_HapticEffectType(SDL_HapticEffect *effect)
|
||||
{
|
||||
switch (effect->type) {
|
||||
@@ -1082,7 +1083,7 @@ int SDL_DINPUT_HapticSetGain(SDL_Haptic *haptic, int gain)
|
||||
dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
||||
dipdw.diph.dwObj = 0;
|
||||
dipdw.diph.dwHow = DIPH_DEVICE;
|
||||
dipdw.dwData = gain * 100; /* 0 to 10,000 */
|
||||
dipdw.dwData = (DWORD)gain * 100; /* 0 to 10,000 */
|
||||
|
||||
/* Try to set the autocenter. */
|
||||
ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device,
|
||||
|
@@ -88,7 +88,7 @@ int SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid)
|
||||
/* !!! FIXME: I'm not bothering to query for a real name right now (can we even?) */
|
||||
{
|
||||
char buf[64];
|
||||
SDL_snprintf(buf, sizeof(buf), "XInput Controller #%u", (unsigned int)(userid + 1));
|
||||
(void)SDL_snprintf(buf, sizeof buf, "XInput Controller #%u", userid + 1);
|
||||
item->name = SDL_strdup(buf);
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us
|
||||
return SDL_SetError("Couldn't create XInput haptic mutex");
|
||||
}
|
||||
|
||||
SDL_snprintf(threadName, sizeof(threadName), "SDLXInputDev%d", (int)userid);
|
||||
(void)SDL_snprintf(threadName, sizeof threadName, "SDLXInputDev%u", userid);
|
||||
haptic->hwdata->thread = SDL_CreateThreadInternal(SDL_RunXInputHaptic, threadName, 64 * 1024, haptic->hwdata);
|
||||
|
||||
if (haptic->hwdata->thread == NULL) {
|
||||
|
Reference in New Issue
Block a user