linux: If the kernel specifically tells us the device type, trust it
If a device is positively identified as an accelerometer, pointing stick or clickpad, then we don't need to second-guess it. In practice this does not change the result for any device in our test data, so add some artificial records that exercise this. Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
committed by
Sam Lantinga
parent
0d5aa70e62
commit
d584592822
@@ -58,6 +58,22 @@ SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_props[NBITS(INPUT_PROP_MA
|
||||
int devclass = 0;
|
||||
unsigned long keyboard_mask;
|
||||
|
||||
/* If the kernel specifically says it's an accelerometer, believe it */
|
||||
if (test_bit(INPUT_PROP_ACCELEROMETER, bitmask_props)) {
|
||||
return SDL_UDEV_DEVICE_ACCELEROMETER;
|
||||
}
|
||||
|
||||
/* We treat pointing sticks as indistinguishable from mice */
|
||||
if (test_bit(INPUT_PROP_POINTING_STICK, bitmask_props)) {
|
||||
return SDL_UDEV_DEVICE_MOUSE;
|
||||
}
|
||||
|
||||
/* We treat buttonpads as equivalent to touchpads */
|
||||
if (test_bit(INPUT_PROP_TOPBUTTONPAD, bitmask_props) ||
|
||||
test_bit(INPUT_PROP_BUTTONPAD, bitmask_props)) {
|
||||
return SDL_UDEV_DEVICE_TOUCHPAD;
|
||||
}
|
||||
|
||||
/* X, Y, Z axes but no buttons probably means an accelerometer */
|
||||
if (test_bit(EV_ABS, bitmask_ev) &&
|
||||
test_bit(ABS_X, bitmask_abs) &&
|
||||
@@ -67,7 +83,8 @@ SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_props[NBITS(INPUT_PROP_MA
|
||||
return SDL_UDEV_DEVICE_ACCELEROMETER;
|
||||
}
|
||||
|
||||
/* RX, RY, RZ axes but no buttons also probably means an accelerometer */
|
||||
/* RX, RY, RZ axes but no buttons probably means a gyro or
|
||||
* accelerometer (we don't distinguish) */
|
||||
if (test_bit(EV_ABS, bitmask_ev) &&
|
||||
test_bit(ABS_RX, bitmask_abs) &&
|
||||
test_bit(ABS_RY, bitmask_abs) &&
|
||||
|
||||
Reference in New Issue
Block a user