Input: Convert clipAxis, moveAbsolute and moveRelative to double
Change all these three to use doubles internally, though the outputs of moveAbsolute and moveRelative are still truncated to int. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
parent
4e52cc0ef4
commit
3463078f96
|
@ -617,7 +617,7 @@ GetMaximumEventsNum(void) {
|
||||||
* InitValuatorAxisClassStruct.
|
* InitValuatorAxisClassStruct.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
clipAxis(DeviceIntPtr pDev, int axisNum, int *val)
|
clipAxis(DeviceIntPtr pDev, int axisNum, double *val)
|
||||||
{
|
{
|
||||||
AxisInfoPtr axis;
|
AxisInfoPtr axis;
|
||||||
|
|
||||||
|
@ -647,9 +647,9 @@ clipValuators(DeviceIntPtr pDev, ValuatorMask *mask)
|
||||||
for (i = 0; i < valuator_mask_size(mask); i++)
|
for (i = 0; i < valuator_mask_size(mask); i++)
|
||||||
if (valuator_mask_isset(mask, i))
|
if (valuator_mask_isset(mask, i))
|
||||||
{
|
{
|
||||||
int val = valuator_mask_get(mask, i);
|
double val = valuator_mask_get_double(mask, i);
|
||||||
clipAxis(pDev, i, &val);
|
clipAxis(pDev, i, &val);
|
||||||
valuator_mask_set(mask, i, val);
|
valuator_mask_set_double(mask, i, val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -699,17 +699,18 @@ static void
|
||||||
moveAbsolute(DeviceIntPtr dev, int *x_out, int *y_out, ValuatorMask *mask)
|
moveAbsolute(DeviceIntPtr dev, int *x_out, int *y_out, ValuatorMask *mask)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int x, y;
|
|
||||||
|
|
||||||
for (i = 0; i < valuator_mask_size(mask); i++)
|
for (i = 0; i < valuator_mask_size(mask); i++)
|
||||||
{
|
{
|
||||||
if (valuator_mask_isset(mask, i))
|
double val;
|
||||||
{
|
|
||||||
int val = valuator_mask_get(mask, i);
|
if (!valuator_mask_isset(mask, i))
|
||||||
|
continue;
|
||||||
|
val = valuator_mask_get_double(mask, i);
|
||||||
clipAxis(dev, i, &val);
|
clipAxis(dev, i, &val);
|
||||||
dev->last.valuators[i] = val;
|
dev->last.valuators[i] = trunc(val);
|
||||||
valuator_mask_set(mask, i, val);
|
dev->last.remainder[i] = val - trunc(val);
|
||||||
}
|
valuator_mask_set_double(mask, i, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
*x_out = dev->last.valuators[0];
|
*x_out = dev->last.valuators[0];
|
||||||
|
@ -733,18 +734,19 @@ moveRelative(DeviceIntPtr dev, int *x_out, int *y_out, ValuatorMask *mask)
|
||||||
/* calc other axes, clip, drop back into valuators */
|
/* calc other axes, clip, drop back into valuators */
|
||||||
for (i = 0; i < valuator_mask_size(mask); i++)
|
for (i = 0; i < valuator_mask_size(mask); i++)
|
||||||
{
|
{
|
||||||
if (valuator_mask_isset(mask, i))
|
double val = dev->last.valuators[i] + dev->last.remainder[i];
|
||||||
{
|
|
||||||
int val = dev->last.valuators[i];
|
if (!valuator_mask_isset(mask, i))
|
||||||
val += valuator_mask_get(mask, i);
|
continue;
|
||||||
|
val += valuator_mask_get_double(mask, i);
|
||||||
/* x & y need to go over the limits to cross screens if the SD
|
/* x & y need to go over the limits to cross screens if the SD
|
||||||
* isn't currently attached; otherwise, clip to screen bounds. */
|
* isn't currently attached; otherwise, clip to screen bounds. */
|
||||||
if (valuator_get_mode(dev, i) == Absolute &&
|
if (valuator_get_mode(dev, i) == Absolute &&
|
||||||
((i != 0 && i != 1) || clip_xy))
|
((i != 0 && i != 1) || clip_xy))
|
||||||
clipAxis(dev, i, &val);
|
clipAxis(dev, i, &val);
|
||||||
dev->last.valuators[i] = val;
|
dev->last.valuators[i] = trunc(val);
|
||||||
valuator_mask_set(mask, i, val);
|
dev->last.remainder[i] = val - trunc(val);
|
||||||
}
|
valuator_mask_set_double(mask, i, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
*x_out = dev->last.valuators[0];
|
*x_out = dev->last.valuators[0];
|
||||||
|
|
Loading…
Reference in New Issue