Joysticks/joypads/etc information needed for Ubuntu 8.10 Intrepid Ibex and later

Matthew Garrett mjg59 at srcf.ucam.org
Tue Oct 21 15:33:59 UTC 2008


Something like this:

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 Ubuntu-devel-discuss mailing list