mirror of https://github.com/encounter/SDL.git
Haptic: Fix the saturation and deadband parameters' available range.
There was a misconception that Linux's saturation and deadband parameters - on which the corresponding SDL parameters were based - use only half of the possible range. Thanks, Elias! Partially fixes Bugzilla #2686.
This commit is contained in:
parent
a2622ce6e0
commit
57db27909b
|
@ -604,11 +604,11 @@ typedef struct SDL_HapticCondition
|
||||||
Uint16 interval; /**< How soon it can be triggered again after button. */
|
Uint16 interval; /**< How soon it can be triggered again after button. */
|
||||||
|
|
||||||
/* Condition */
|
/* Condition */
|
||||||
Uint16 right_sat[3]; /**< Level when joystick is to the positive side. */
|
Uint16 right_sat[3]; /**< Level when joystick is to the positive side; max 0xFFFF. */
|
||||||
Uint16 left_sat[3]; /**< Level when joystick is to the negative side. */
|
Uint16 left_sat[3]; /**< Level when joystick is to the negative side; max 0xFFFF. */
|
||||||
Sint16 right_coeff[3]; /**< How fast to increase the force towards the positive side. */
|
Sint16 right_coeff[3]; /**< How fast to increase the force towards the positive side. */
|
||||||
Sint16 left_coeff[3]; /**< How fast to increase the force towards the negative side. */
|
Sint16 left_coeff[3]; /**< How fast to increase the force towards the negative side. */
|
||||||
Uint16 deadband[3]; /**< Size of the dead zone. */
|
Uint16 deadband[3]; /**< Size of the dead zone; max 0xFFFF: whole axis-range when 0-centered. */
|
||||||
Sint16 center[3]; /**< Position of the dead zone. */
|
Sint16 center[3]; /**< Position of the dead zone. */
|
||||||
} SDL_HapticCondition;
|
} SDL_HapticCondition;
|
||||||
|
|
||||||
|
|
|
@ -924,10 +924,10 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src)
|
||||||
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]);
|
CCONVERT(hap_condition->right_sat[i] / 2);
|
||||||
condition[i].dwNegativeSaturation =
|
condition[i].dwNegativeSaturation =
|
||||||
CCONVERT(hap_condition->left_sat[i]);
|
CCONVERT(hap_condition->left_sat[i] / 2);
|
||||||
condition[i].lDeadBand = CCONVERT(hap_condition->deadband[i]);
|
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;
|
||||||
|
|
|
@ -847,20 +847,18 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src)
|
||||||
|
|
||||||
/* Condition */
|
/* Condition */
|
||||||
/* X axis */
|
/* X axis */
|
||||||
dest->u.condition[0].right_saturation =
|
dest->u.condition[0].right_saturation = condition->right_sat[0];
|
||||||
CLAMP(condition->right_sat[0]);
|
dest->u.condition[0].left_saturation = condition->left_sat[0];
|
||||||
dest->u.condition[0].left_saturation = CLAMP(condition->left_sat[0]);
|
|
||||||
dest->u.condition[0].right_coeff = condition->right_coeff[0];
|
dest->u.condition[0].right_coeff = condition->right_coeff[0];
|
||||||
dest->u.condition[0].left_coeff = condition->left_coeff[0];
|
dest->u.condition[0].left_coeff = condition->left_coeff[0];
|
||||||
dest->u.condition[0].deadband = CLAMP(condition->deadband[0]);
|
dest->u.condition[0].deadband = condition->deadband[0];
|
||||||
dest->u.condition[0].center = condition->center[0];
|
dest->u.condition[0].center = condition->center[0];
|
||||||
/* Y axis */
|
/* Y axis */
|
||||||
dest->u.condition[1].right_saturation =
|
dest->u.condition[1].right_saturation = condition->right_sat[1];
|
||||||
CLAMP(condition->right_sat[1]);
|
dest->u.condition[1].left_saturation = condition->left_sat[1];
|
||||||
dest->u.condition[1].left_saturation = CLAMP(condition->left_sat[1]);
|
|
||||||
dest->u.condition[1].right_coeff = condition->right_coeff[1];
|
dest->u.condition[1].right_coeff = condition->right_coeff[1];
|
||||||
dest->u.condition[1].left_coeff = condition->left_coeff[1];
|
dest->u.condition[1].left_coeff = condition->left_coeff[1];
|
||||||
dest->u.condition[1].deadband = CLAMP(condition->deadband[1]);
|
dest->u.condition[1].deadband = condition->deadband[1];
|
||||||
dest->u.condition[1].center = condition->center[1];
|
dest->u.condition[1].center = condition->center[1];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -763,10 +763,10 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
|
||||||
condition[i].lNegativeCoefficient =
|
condition[i].lNegativeCoefficient =
|
||||||
CONVERT(hap_condition->left_coeff[i]);
|
CONVERT(hap_condition->left_coeff[i]);
|
||||||
condition[i].dwPositiveSaturation =
|
condition[i].dwPositiveSaturation =
|
||||||
CONVERT(hap_condition->right_sat[i]);
|
CONVERT(hap_condition->right_sat[i] / 2);
|
||||||
condition[i].dwNegativeSaturation =
|
condition[i].dwNegativeSaturation =
|
||||||
CONVERT(hap_condition->left_sat[i]);
|
CONVERT(hap_condition->left_sat[i] / 2);
|
||||||
condition[i].lDeadBand = CONVERT(hap_condition->deadband[i]);
|
condition[i].lDeadBand = CONVERT(hap_condition->deadband[i] / 2);
|
||||||
}
|
}
|
||||||
dest->cbTypeSpecificParams = sizeof(DICONDITION) * dest->cAxes;
|
dest->cbTypeSpecificParams = sizeof(DICONDITION) * dest->cAxes;
|
||||||
dest->lpvTypeSpecificParams = condition;
|
dest->lpvTypeSpecificParams = condition;
|
||||||
|
|
|
@ -172,8 +172,8 @@ main(int argc, char **argv)
|
||||||
efx[nefx].type = SDL_HAPTIC_SPRING;
|
efx[nefx].type = SDL_HAPTIC_SPRING;
|
||||||
efx[nefx].condition.length = 5000;
|
efx[nefx].condition.length = 5000;
|
||||||
for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
|
for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
|
||||||
efx[nefx].condition.right_sat[i] = 0x7FFF;
|
efx[nefx].condition.right_sat[i] = 0xFFFF;
|
||||||
efx[nefx].condition.left_sat[i] = 0x7FFF;
|
efx[nefx].condition.left_sat[i] = 0xFFFF;
|
||||||
efx[nefx].condition.right_coeff[i] = 0x2000;
|
efx[nefx].condition.right_coeff[i] = 0x2000;
|
||||||
efx[nefx].condition.left_coeff[i] = 0x2000;
|
efx[nefx].condition.left_coeff[i] = 0x2000;
|
||||||
efx[nefx].condition.center[i] = 0x1000; /* Displace the center for it to move. */
|
efx[nefx].condition.center[i] = 0x1000; /* Displace the center for it to move. */
|
||||||
|
@ -191,10 +191,11 @@ main(int argc, char **argv)
|
||||||
efx[nefx].type = SDL_HAPTIC_INERTIA;
|
efx[nefx].type = SDL_HAPTIC_INERTIA;
|
||||||
efx[nefx].condition.length = 5000;
|
efx[nefx].condition.length = 5000;
|
||||||
for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
|
for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
|
||||||
efx[nefx].condition.right_sat[i] = 0x7FFF;
|
efx[nefx].condition.right_sat[i] = 0xFFFF;
|
||||||
efx[nefx].condition.left_sat[i] = 0x7FFF;
|
efx[nefx].condition.left_sat[i] = 0xFFFF;
|
||||||
efx[nefx].condition.right_coeff[i] = 0x2000;
|
efx[nefx].condition.right_coeff[i] = 0x2000;
|
||||||
efx[nefx].condition.left_coeff[i] = 0x2000;
|
efx[nefx].condition.left_coeff[i] = 0x2000;
|
||||||
|
efx[nefx].condition.deadband[i] = 0x1000; /* 1/16th of axis-range around the center is 'dead'. */
|
||||||
}
|
}
|
||||||
id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
|
id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
|
||||||
if (id[nefx] < 0) {
|
if (id[nefx] < 0) {
|
||||||
|
|
Loading…
Reference in New Issue