Commit 4712c65f authored by Bruno Jesus's avatar Bruno Jesus Committed by Alexandre Julliard

dinput: Simplify condition effect translation.

parent 086a2306
...@@ -649,43 +649,49 @@ static HRESULT WINAPI LinuxInputEffectImpl_SetParameters( ...@@ -649,43 +649,49 @@ static HRESULT WINAPI LinuxInputEffectImpl_SetParameters(
tsp = peff->lpvTypeSpecificParams; tsp = peff->lpvTypeSpecificParams;
This->effect.u.ramp.start_level = (tsp->lStart / 10) * 32; This->effect.u.ramp.start_level = (tsp->lStart / 10) * 32;
This->effect.u.ramp.end_level = (tsp->lEnd / 10) * 32; This->effect.u.ramp.end_level = (tsp->lEnd / 10) * 32;
} else if (type == DIEFT_CONDITION) { }
LPCDICONDITION tsp = peff->lpvTypeSpecificParams; else if (type == DIEFT_CONDITION)
if (peff->cbTypeSpecificParams == sizeof(DICONDITION)) { {
/* One condition block. This needs to be rotated to direction, DICONDITION *tsp = peff->lpvTypeSpecificParams;
* and expanded to separate x and y conditions. */ struct ff_condition_effect *cond = This->effect.u.condition;
int i; int i, j, sources;
double factor[2], angle; double factor[2];
/* rotate so 0 points right */
angle = ff_effect_direction_to_rad(This->effect.direction + 0xc000); if (peff->cbTypeSpecificParams == sizeof(DICONDITION))
factor[0] = sin(angle); {
factor[1] = -cos(angle); /* One condition block. This needs to be rotated to direction,
for (i = 0; i < 2; ++i) { * and expanded to separate x and y conditions. Ensures 0 points right */
This->effect.u.condition[i].center = (int)(factor[i] * (tsp->lOffset / 10) * 32); double angle = ff_effect_direction_to_rad(This->effect.direction + 0xc000);
This->effect.u.condition[i].right_coeff = (int)(factor[i] * (tsp->lPositiveCoefficient / 10) * 32); factor[0] = sin(angle);
This->effect.u.condition[i].left_coeff = (int)(factor[i] * (tsp->lNegativeCoefficient / 10) * 32); factor[1] = -cos(angle);
This->effect.u.condition[i].right_saturation = (int)(factor[i] * (tsp->dwPositiveSaturation / 10) * 32); sources = 1;
This->effect.u.condition[i].left_saturation = (int)(factor[i] * (tsp->dwNegativeSaturation / 10) * 32); }
This->effect.u.condition[i].deadband = (int)(factor[i] * (tsp->lDeadBand / 10) * 32); else if (peff->cbTypeSpecificParams == 2 * sizeof(DICONDITION))
} {
} else if (peff->cbTypeSpecificParams == 2 * sizeof(DICONDITION)) { /* Direct parameter copy without changes */
/* Two condition blocks. Direct parameter copy. */ factor[0] = factor[1] = 1;
int i; sources = 2;
for (i = 0; i < 2; ++i) { }
This->effect.u.condition[i].center = (tsp[i].lOffset / 10) * 32; else
This->effect.u.condition[i].right_coeff = (tsp[i].lPositiveCoefficient / 10) * 32;
This->effect.u.condition[i].left_coeff = (tsp[i].lNegativeCoefficient / 10) * 32;
This->effect.u.condition[i].right_saturation = (tsp[i].dwPositiveSaturation / 10) * 32;
This->effect.u.condition[i].left_saturation = (tsp[i].dwNegativeSaturation / 10) * 32;
This->effect.u.condition[i].deadband = (tsp[i].lDeadBand / 10) * 32;
}
} else {
return DIERR_INVALIDPARAM; return DIERR_INVALIDPARAM;
}
} else { for (i = j = 0; i < 2; ++i)
FIXME("Custom force types are not supported\n"); {
return DIERR_INVALIDPARAM; cond[i].center = (int)(factor[i] * (tsp[j].lOffset / 10) * 32);
} cond[i].right_coeff = (int)(factor[i] * (tsp[j].lPositiveCoefficient / 10) * 32);
cond[i].left_coeff = (int)(factor[i] * (tsp[j].lNegativeCoefficient / 10) * 32);
cond[i].right_saturation = (int)(factor[i] * (tsp[j].dwPositiveSaturation / 10) * 32);
cond[i].left_saturation = (int)(factor[i] * (tsp[j].dwNegativeSaturation / 10) * 32);
cond[i].deadband = (int)(factor[i] * (tsp[j].lDeadBand / 10) * 32);
if (sources == 2)
j++;
}
}
else
{
FIXME("Custom force types are not supported\n");
return DIERR_INVALIDPARAM;
}
} }
if (!(dwFlags & DIEP_NODOWNLOAD)) if (!(dwFlags & DIEP_NODOWNLOAD))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment