dinput: Clamp joystick position values to min-max range.

This commit is contained in:
Vitaliy Margolen 2008-05-13 07:33:31 -06:00 committed by Alexandre Julliard
parent a5d288f08c
commit f2bdd8d96c
1 changed files with 4 additions and 0 deletions

View File

@ -110,6 +110,10 @@ LONG joystick_map_axis(ObjProps *props, int val)
ret = MulDiv( val, props->lMax - props->lMin, dev_range ) +
(props->lMin + props->lMax) / 2;
/* Clamp in case or rounding errors */
if (ret > props->lMax) ret = props->lMax;
else if (ret < props->lMin) ret = props->lMin;
TRACE( "(%d <%d> %d) -> (%d <%d> %d): val=%d ret=%d\n",
props->lDevMin, dead_zone, props->lDevMax,
props->lMin, props->lDeadZone, props->lMax,