input: replace -1 as default axis limit with NO_AXIS_LIMIT define.
This allows easier refacturing of the coordinate limit handling. Grepping for -1 is boring.
This commit is contained in:
parent
00acb40f2b
commit
ffaccc2dc9
|
@ -1153,13 +1153,22 @@ InitProximityClassDeviceStruct(DeviceIntPtr dev)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the device's valuators. The memory must already be allocated,
|
||||
* this function merely inits the matching axis (specified through axnum) to
|
||||
* sane values.
|
||||
*
|
||||
* It is a condition that (minval < maxval).
|
||||
*
|
||||
* @see InitValuatorClassDeviceStruct
|
||||
*/
|
||||
_X_EXPORT void
|
||||
InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, int minval, int maxval,
|
||||
int resolution, int min_res, int max_res)
|
||||
{
|
||||
AxisInfoPtr ax;
|
||||
|
||||
if (!dev || !dev->valuator)
|
||||
|
||||
if (!dev || !dev->valuator || minval > maxval)
|
||||
return;
|
||||
|
||||
ax = dev->valuator->axes + axnum;
|
||||
|
|
|
@ -1187,7 +1187,8 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes,
|
|||
AllocateMotionHistory(dev);
|
||||
|
||||
for (i=0; i<numAxes; i++) {
|
||||
InitValuatorAxisStruct(dev, i, -1, -1, 0, 0, 0);
|
||||
InitValuatorAxisStruct(dev, i, NO_AXIS_LIMITS, NO_AXIS_LIMITS,
|
||||
0, 0, 0);
|
||||
valc->axisVal[i]=0;
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -1203,10 +1204,10 @@ InitAbsoluteClassDeviceStruct(DeviceIntPtr dev)
|
|||
return FALSE;
|
||||
|
||||
/* we don't do anything sensible with these, but should */
|
||||
abs->min_x = -1;
|
||||
abs->min_y = -1;
|
||||
abs->max_x = -1;
|
||||
abs->max_y = -1;
|
||||
abs->min_x = NO_AXIS_LIMITS;
|
||||
abs->min_y = NO_AXIS_LIMITS;
|
||||
abs->max_x = NO_AXIS_LIMITS;
|
||||
abs->max_y = NO_AXIS_LIMITS;
|
||||
abs->flip_x = 0;
|
||||
abs->flip_y = 0;
|
||||
abs->rotation = 0;
|
||||
|
@ -1214,8 +1215,8 @@ InitAbsoluteClassDeviceStruct(DeviceIntPtr dev)
|
|||
|
||||
abs->offset_x = 0;
|
||||
abs->offset_y = 0;
|
||||
abs->width = -1;
|
||||
abs->height = -1;
|
||||
abs->width = NO_AXIS_LIMITS;
|
||||
abs->height = NO_AXIS_LIMITS;
|
||||
abs->following = 0;
|
||||
abs->screen = 0;
|
||||
|
||||
|
|
|
@ -358,14 +358,15 @@ clipAxis(DeviceIntPtr pDev, int axisNum, int *val)
|
|||
{
|
||||
AxisInfoPtr axes = pDev->valuator->axes + axisNum;
|
||||
|
||||
/* Don't clip if min_value and max_value are the same, or if an invalid
|
||||
range is specified. */
|
||||
if(axes->min_value < axes->max_value) {
|
||||
if (*val < axes->min_value)
|
||||
*val = axes->min_value;
|
||||
if (*val > axes->max_value)
|
||||
*val = axes->max_value;
|
||||
}
|
||||
/* InitValuatoraAxisStruct ensures that (min < max) */
|
||||
|
||||
if (axes->min_value != NO_AXIS_LIMITS &&
|
||||
*val < axis->min_value)
|
||||
*val = axes->min_value;
|
||||
|
||||
if (axes->max_value != NO_AXIS_LIMITS &&
|
||||
*val > axes->max_value)
|
||||
*val = axes->max_value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -63,6 +63,8 @@ SOFTWARE.
|
|||
#define POINTER_ABSOLUTE (1 << 2)
|
||||
#define POINTER_ACCELERATE (1 << 3)
|
||||
|
||||
#define NO_AXIS_LIMITS -1
|
||||
|
||||
#define MAP_LENGTH 256
|
||||
#define DOWN_LENGTH 32 /* 256/8 => number of bytes to hold 256 bits */
|
||||
#define NullGrab ((GrabPtr)NULL)
|
||||
|
|
Loading…
Reference in New Issue
Block a user