Input: Add double-precision valuator_mask API

Add API for valuator_mask that accepts and returns doubles, rather than
ints.  No double API is provided for set_range at the moment.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Daniel Stone
2011-02-23 17:28:18 +00:00
committed by Peter Hutterer
parent 79d4deb76d
commit 7e919ef5bf
3 changed files with 45 additions and 11 deletions

View File

@@ -497,10 +497,10 @@ valuator_mask_isset(const ValuatorMask *mask, int valuator)
}
/**
* Set the valuator to the given data.
* Set the valuator to the given floating-point data.
*/
void
valuator_mask_set(ValuatorMask *mask, int valuator, int data)
valuator_mask_set_double(ValuatorMask *mask, int valuator, double data)
{
mask->last_bit = max(valuator, mask->last_bit);
SetBit(mask->mask, valuator);
@@ -508,13 +508,33 @@ valuator_mask_set(ValuatorMask *mask, int valuator, int data)
}
/**
* Return the requested valuator value. If the mask bit is not set for the
* given valuator, the returned value is undefined.
* Set the valuator to the given integer data.
*/
void
valuator_mask_set(ValuatorMask *mask, int valuator, int data)
{
valuator_mask_set_double(mask, valuator, data);
}
/**
* Return the requested valuator value as a double. If the mask bit is not
* set for the given valuator, the returned value is undefined.
*/
double
valuator_mask_get_double(const ValuatorMask *mask, int valuator)
{
return mask->valuators[valuator];
}
/**
* Return the requested valuator value as an integer, rounding towards zero.
* If the mask bit is not set for the given valuator, the returned value is
* undefined.
*/
int
valuator_mask_get(const ValuatorMask *mask, int valuator)
{
return trunc(mask->valuators[valuator]);
return trunc(valuator_mask_get_double(mask, valuator));
}
/**