dinput: Fix calculation of too small periods for periodic effect.

Based on ideas by Elias Vanderstuyft.

Signed-off-by: Bruno Jesus <00cpxxx@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Bruno Jesus 2016-08-24 22:55:56 -03:00 committed by Alexandre Julliard
parent f68e131e88
commit 7d88a12dc0
1 changed files with 20 additions and 10 deletions

View File

@ -588,19 +588,29 @@ static HRESULT WINAPI LinuxInputEffectImpl_SetParameters(
if (dwFlags & DIEP_TRIGGERREPEATINTERVAL)
This->effect.trigger.interval = peff->dwTriggerRepeatInterval / 1000;
if (dwFlags & DIEP_TYPESPECIFICPARAMS) {
if (!(peff->lpvTypeSpecificParams))
return DIERR_INCOMPLETEEFFECT;
if (type == DIEFT_PERIODIC) {
LPCDIPERIODIC tsp;
if (dwFlags & DIEP_TYPESPECIFICPARAMS)
{
if (!(peff->lpvTypeSpecificParams))
return DIERR_INCOMPLETEEFFECT;
if (type == DIEFT_PERIODIC)
{
DIPERIODIC *tsp;
if (peff->cbTypeSpecificParams != sizeof(DIPERIODIC))
return DIERR_INVALIDPARAM;
tsp = peff->lpvTypeSpecificParams;
This->effect.u.periodic.magnitude = (tsp->dwMagnitude / 10) * 32;
This->effect.u.periodic.offset = (tsp->lOffset / 10) * 32;
This->effect.u.periodic.phase = (tsp->dwPhase / 9) * 8; /* == (/ 36 * 32) */
This->effect.u.periodic.period = tsp->dwPeriod / 1000;
} else if (type == DIEFT_CONSTANTFORCE) {
This->effect.u.periodic.magnitude = (tsp->dwMagnitude / 10) * 32;
This->effect.u.periodic.offset = (tsp->lOffset / 10) * 32;
This->effect.u.periodic.phase = (tsp->dwPhase / 9) * 8; /* == (/ 36 * 32) */
/* dinput uses microseconds, linux uses miliseconds */
if (tsp->dwPeriod <= 1000)
This->effect.u.periodic.period = 1;
else
This->effect.u.periodic.period = tsp->dwPeriod / 1000;
}
else if (type == DIEFT_CONSTANTFORCE)
{
LPCDICONSTANTFORCE tsp;
if (peff->cbTypeSpecificParams != sizeof(DICONSTANTFORCE))
return DIERR_INVALIDPARAM;