mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-20 22:16:49 +01:00
Haptic: Fix clamping bugs on Windows, by using the Darwin haptics code.
Thanks, Elias! Partially fixes Bugzilla #2686.
This commit is contained in:
parent
57db27909b
commit
e2bbc17d11
@ -602,7 +602,10 @@ SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir, int naxes)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CONVERT(x) (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF)
|
/* Clamps and converts. */
|
||||||
|
#define CCONVERT(x) (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF)
|
||||||
|
/* Just converts. */
|
||||||
|
#define CONVERT(x) (((x)*10000) / 0x7FFF)
|
||||||
/*
|
/*
|
||||||
* Creates the DIEFFECT from a SDL_HapticEffect.
|
* Creates the DIEFFECT from a SDL_HapticEffect.
|
||||||
*/
|
*/
|
||||||
@ -689,9 +692,9 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
|
|||||||
SDL_free(dest->lpEnvelope);
|
SDL_free(dest->lpEnvelope);
|
||||||
dest->lpEnvelope = NULL;
|
dest->lpEnvelope = NULL;
|
||||||
} else {
|
} else {
|
||||||
envelope->dwAttackLevel = CONVERT(hap_constant->attack_level);
|
envelope->dwAttackLevel = CCONVERT(hap_constant->attack_level);
|
||||||
envelope->dwAttackTime = hap_constant->attack_length * 1000;
|
envelope->dwAttackTime = hap_constant->attack_length * 1000;
|
||||||
envelope->dwFadeLevel = CONVERT(hap_constant->fade_level);
|
envelope->dwFadeLevel = CCONVERT(hap_constant->fade_level);
|
||||||
envelope->dwFadeTime = hap_constant->fade_length * 1000;
|
envelope->dwFadeTime = hap_constant->fade_length * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -736,9 +739,9 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
|
|||||||
SDL_free(dest->lpEnvelope);
|
SDL_free(dest->lpEnvelope);
|
||||||
dest->lpEnvelope = NULL;
|
dest->lpEnvelope = NULL;
|
||||||
} else {
|
} else {
|
||||||
envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level);
|
envelope->dwAttackLevel = CCONVERT(hap_periodic->attack_level);
|
||||||
envelope->dwAttackTime = hap_periodic->attack_length * 1000;
|
envelope->dwAttackTime = hap_periodic->attack_length * 1000;
|
||||||
envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level);
|
envelope->dwFadeLevel = CCONVERT(hap_periodic->fade_level);
|
||||||
envelope->dwFadeTime = hap_periodic->fade_length * 1000;
|
envelope->dwFadeTime = hap_periodic->fade_length * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -763,10 +766,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] / 2);
|
CCONVERT(hap_condition->right_sat[i] / 2);
|
||||||
condition[i].dwNegativeSaturation =
|
condition[i].dwNegativeSaturation =
|
||||||
CONVERT(hap_condition->left_sat[i] / 2);
|
CCONVERT(hap_condition->left_sat[i] / 2);
|
||||||
condition[i].lDeadBand = CONVERT(hap_condition->deadband[i] / 2);
|
condition[i].lDeadBand = CCONVERT(hap_condition->deadband[i] / 2);
|
||||||
}
|
}
|
||||||
dest->cbTypeSpecificParams = sizeof(DICONDITION) * dest->cAxes;
|
dest->cbTypeSpecificParams = sizeof(DICONDITION) * dest->cAxes;
|
||||||
dest->lpvTypeSpecificParams = condition;
|
dest->lpvTypeSpecificParams = condition;
|
||||||
@ -819,9 +822,9 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
|
|||||||
SDL_free(dest->lpEnvelope);
|
SDL_free(dest->lpEnvelope);
|
||||||
dest->lpEnvelope = NULL;
|
dest->lpEnvelope = NULL;
|
||||||
} else {
|
} else {
|
||||||
envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level);
|
envelope->dwAttackLevel = CCONVERT(hap_ramp->attack_level);
|
||||||
envelope->dwAttackTime = hap_ramp->attack_length * 1000;
|
envelope->dwAttackTime = hap_ramp->attack_length * 1000;
|
||||||
envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level);
|
envelope->dwFadeLevel = CCONVERT(hap_ramp->fade_level);
|
||||||
envelope->dwFadeTime = hap_ramp->fade_length * 1000;
|
envelope->dwFadeTime = hap_ramp->fade_length * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -842,7 +845,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
|
|||||||
custom->rglForceData =
|
custom->rglForceData =
|
||||||
SDL_malloc(sizeof(LONG) * custom->cSamples * custom->cChannels);
|
SDL_malloc(sizeof(LONG) * custom->cSamples * custom->cChannels);
|
||||||
for (i = 0; i < hap_custom->samples * hap_custom->channels; i++) { /* Copy data. */
|
for (i = 0; i < hap_custom->samples * hap_custom->channels; i++) { /* Copy data. */
|
||||||
custom->rglForceData[i] = CONVERT(hap_custom->data[i]);
|
custom->rglForceData[i] = CCONVERT(hap_custom->data[i]);
|
||||||
}
|
}
|
||||||
dest->cbTypeSpecificParams = sizeof(DICUSTOMFORCE);
|
dest->cbTypeSpecificParams = sizeof(DICUSTOMFORCE);
|
||||||
dest->lpvTypeSpecificParams = custom;
|
dest->lpvTypeSpecificParams = custom;
|
||||||
@ -864,9 +867,9 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
|
|||||||
SDL_free(dest->lpEnvelope);
|
SDL_free(dest->lpEnvelope);
|
||||||
dest->lpEnvelope = NULL;
|
dest->lpEnvelope = NULL;
|
||||||
} else {
|
} else {
|
||||||
envelope->dwAttackLevel = CONVERT(hap_custom->attack_level);
|
envelope->dwAttackLevel = CCONVERT(hap_custom->attack_level);
|
||||||
envelope->dwAttackTime = hap_custom->attack_length * 1000;
|
envelope->dwAttackTime = hap_custom->attack_length * 1000;
|
||||||
envelope->dwFadeLevel = CONVERT(hap_custom->fade_level);
|
envelope->dwFadeLevel = CCONVERT(hap_custom->fade_level);
|
||||||
envelope->dwFadeTime = hap_custom->fade_length * 1000;
|
envelope->dwFadeTime = hap_custom->fade_length * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user