dix: Correct clipAxis so it can handle devices with value ranges properly

Signed-off-by: Peter Hutterer <peter@cs.unisa.edu.au>
This commit is contained in:
Magnus Vigerlöf 2008-05-23 00:36:11 +02:00 committed by Peter Hutterer
parent f6645ddbf7
commit a0241d5380

View File

@ -406,22 +406,15 @@ static void
clipAxis(DeviceIntPtr pDev, int axisNum, int *val)
{
AxisInfoPtr axis = pDev->valuator->axes + axisNum;
/* InitValuatoraAxisStruct ensures that (min < max). */
/* FIXME: drivers need to be updated, evdev e.g. inits axes as min = 0 and
* max = -1. Leave this extra check until the drivers have been updated.
*/
if (axis->max_value < axis->min_value)
/* If a value range is defined, clip. If not, do nothing */
if (axis->max_value <= axis->min_value)
return;
if (axis->min_value != NO_AXIS_LIMITS &&
*val < axis->min_value)
if (*val < axis->min_value)
*val = axis->min_value;
if (axis->max_value != NO_AXIS_LIMITS &&
*val > axis->max_value)
if (*val > axis->max_value)
*val = axis->max_value;
}