Commit 51fac7f2 authored by Vitaliy Margolen's avatar Vitaliy Margolen Committed by Alexandre Julliard

dinput: Fix dead zone calculation.

Based on patch by Artur Szymiec.
parent 1b819cbe
......@@ -91,17 +91,20 @@ DWORD joystick_map_pov(POINTL *p)
LONG joystick_map_axis(ObjProps *props, int val)
{
LONG ret;
LONG center = (props->lMax - props->lMin) / 2;
/* map the value from the hmin-hmax range into the wmin-wmax range */
ret = MulDiv( val - props->lDevMin, props->lMax - props->lMin,
props->lDevMax - props->lDevMin ) + props->lMin;
props->lDevMax - props->lDevMin );
if ((ret >= -props->lDeadZone / 2 ) && (ret <= props->lDeadZone / 2))
ret = (props->lMax - props->lMin) / 2 + props->lMin;
if (abs( ret - center ) <= props->lDeadZone / 2 )
ret = center;
ret += props->lMin;
TRACE( "(%d %d) -> (%d <%d> %d): val=%d ret=%d\n",
props->lDevMin, props->lDevMax,
props->lMin, props->lDeadZone, props->lDevMax,
props->lMin, props->lDeadZone, props->lMax,
val, ret );
return ret;
......
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