mirror of https://github.com/encounter/SDL.git
Darwin haptic: Fixed a static analysis warning if axes==0.
This commit is contained in:
parent
f99d6e1df8
commit
37f4eb5379
|
@ -771,18 +771,18 @@ static int
|
||||||
SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src)
|
SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
FFCONSTANTFORCE *constant;
|
FFCONSTANTFORCE *constant = NULL;
|
||||||
FFPERIODIC *periodic;
|
FFPERIODIC *periodic = NULL;
|
||||||
FFCONDITION *condition; /* Actually an array of conditions - one per axis. */
|
FFCONDITION *condition = NULL; /* Actually an array of conditions - one per axis. */
|
||||||
FFRAMPFORCE *ramp;
|
FFRAMPFORCE *ramp = NULL;
|
||||||
FFCUSTOMFORCE *custom;
|
FFCUSTOMFORCE *custom = NULL;
|
||||||
FFENVELOPE *envelope;
|
FFENVELOPE *envelope = NULL;
|
||||||
SDL_HapticConstant *hap_constant;
|
SDL_HapticConstant *hap_constant = NULL;
|
||||||
SDL_HapticPeriodic *hap_periodic;
|
SDL_HapticPeriodic *hap_periodic = NULL;
|
||||||
SDL_HapticCondition *hap_condition;
|
SDL_HapticCondition *hap_condition = NULL;
|
||||||
SDL_HapticRamp *hap_ramp;
|
SDL_HapticRamp *hap_ramp = NULL;
|
||||||
SDL_HapticCustom *hap_custom;
|
SDL_HapticCustom *hap_custom = NULL;
|
||||||
DWORD *axes;
|
DWORD *axes = NULL;
|
||||||
|
|
||||||
/* Set global stuff. */
|
/* Set global stuff. */
|
||||||
SDL_memset(dest, 0, sizeof(FFEFFECT));
|
SDL_memset(dest, 0, sizeof(FFEFFECT));
|
||||||
|
@ -911,26 +911,29 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src)
|
||||||
case SDL_HAPTIC_DAMPER:
|
case SDL_HAPTIC_DAMPER:
|
||||||
case SDL_HAPTIC_INERTIA:
|
case SDL_HAPTIC_INERTIA:
|
||||||
case SDL_HAPTIC_FRICTION:
|
case SDL_HAPTIC_FRICTION:
|
||||||
hap_condition = &src->condition;
|
if (dest->cAxes > 0) {
|
||||||
condition = SDL_malloc(sizeof(FFCONDITION) * dest->cAxes);
|
hap_condition = &src->condition;
|
||||||
if (condition == NULL) {
|
condition = SDL_malloc(sizeof(FFCONDITION) * dest->cAxes);
|
||||||
return SDL_OutOfMemory();
|
if (condition == NULL) {
|
||||||
}
|
return SDL_OutOfMemory();
|
||||||
SDL_memset(condition, 0, sizeof(FFCONDITION));
|
}
|
||||||
|
SDL_memset(condition, 0, sizeof(FFCONDITION));
|
||||||
|
|
||||||
/* Specifics */
|
/* Specifics */
|
||||||
for (i = 0; i < dest->cAxes; i++) {
|
for (i = 0; i < dest->cAxes; i++) {
|
||||||
condition[i].lOffset = CONVERT(hap_condition->center[i]);
|
condition[i].lOffset = CONVERT(hap_condition->center[i]);
|
||||||
condition[i].lPositiveCoefficient =
|
condition[i].lPositiveCoefficient =
|
||||||
CONVERT(hap_condition->right_coeff[i]);
|
CONVERT(hap_condition->right_coeff[i]);
|
||||||
condition[i].lNegativeCoefficient =
|
condition[i].lNegativeCoefficient =
|
||||||
CONVERT(hap_condition->left_coeff[i]);
|
CONVERT(hap_condition->left_coeff[i]);
|
||||||
condition[i].dwPositiveSaturation =
|
condition[i].dwPositiveSaturation =
|
||||||
CCONVERT(hap_condition->right_sat[i] / 2);
|
CCONVERT(hap_condition->right_sat[i] / 2);
|
||||||
condition[i].dwNegativeSaturation =
|
condition[i].dwNegativeSaturation =
|
||||||
CCONVERT(hap_condition->left_sat[i] / 2);
|
CCONVERT(hap_condition->left_sat[i] / 2);
|
||||||
condition[i].lDeadBand = CCONVERT(hap_condition->deadband[i] / 2);
|
condition[i].lDeadBand = CCONVERT(hap_condition->deadband[i] / 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dest->cbTypeSpecificParams = sizeof(FFCONDITION) * dest->cAxes;
|
dest->cbTypeSpecificParams = sizeof(FFCONDITION) * dest->cAxes;
|
||||||
dest->lpvTypeSpecificParams = condition;
|
dest->lpvTypeSpecificParams = condition;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue