[PATCH] Make joystick probing more robust
Matthew Garrett
mjg59 at srcf.ucam.org
Tue Oct 21 08:37:33 PDT 2008
Most joysticks will report ABS_X and ABS_Y. This currently results in
them falling into the vmware mouse hack and ending up tagged with
input.mouse. This patch catches those and also adds a couple of other
cases of devices that should be flagged as joysticks.
diff --git a/hald/linux/device.c b/hald/linux/device.c
index 11f79cd..eff4ee5 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -1060,16 +1060,27 @@ input_test_abs (HalDevice *d, const char *sysfs_path)
hal_device_add_capability (d, "input.touchpad");
goto out;
} else {
- /*
- * This path is taken by VMware's USB mouse, which has
- * absolute axes, but no touch/pressure button.
- */
- hal_device_add_capability (d, "input.mouse");
- goto out;
+ long bitmask_button[NBITS(KEY_MAX)];
+
+ s = hal_util_get_string_from_file (sysfs_path, "capabilities/key");
+ if (s == NULL) {
+ hal_device_add_capability (d, "input.joystick");
+ goto out;
+ }
+
+ if (test_bit(BTN_LEFT, bitmask_button)) {
+ /*
+ * This path is taken by VMware's USB mouse, which has
+ * absolute axes, but no touch/pressure button.
+ */
+ hal_device_add_capability (d, "input.mouse");
+ goto out;
+ }
+
+ hal_device_add_capability (d, "input.joystick");
}
}
- /* TODO: Hmm; this code looks sketchy... why do we do !test_bit on the Y axis ?? */
if (test_bit(ABS_X, bitmask) && !test_bit(ABS_Y, bitmask)) {
long bitmask_touch[NBITS(KEY_MAX)];
@@ -1084,6 +1095,9 @@ input_test_abs (HalDevice *d, const char *sysfs_path)
hal_device_add_capability (d, "input.tablet");
}
}
+
+ if (test_bit(ABS_WHEEL, bitmask) || test_bit(ABS_THROTTLE, bitmask))
+ hal_device_add_capability (d, "input.joystick");
out:
;
}
--
Matthew Garrett | mjg59 at srcf.ucam.org
More information about the hal
mailing list