Skip to contentSkip to conversation

2.6: joydev is too eager claiming input devices

PATCH New Dmitry Torokhov 1 participant 1 message Sep 3, 2003 Input drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.6: joydev is too eager claiming input devices

Currently joydev will claim any device reporting ABS_X events. This includes Synaptics touchpad in absolute mode, PC110 touchpad and both touchscreens. Nothing bad happens except for strange input/jsX device but it's still not right.

I think we need stricter rules for joydev matching, like in the patch below. Unfortunately I do not own any joysticks, but I did go through all code in input/joystick and I think I covered all possible cases.

Dmitry

drivers/input/joydev.c +31 -1
@@ -466,13 +466,43 @@
 
 static struct input_device_id joydev_ids[] = {
 	{
-		.flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT,
+		.flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT |
+			 INPUT_DEVICE_ID_MATCH_BUS,
+		.evbit = { BIT(EV_ABS) },
+		.absbit = { BIT(ABS_X) },
+		.id = { .bustype = BUS_GAMEPORT },
+	}, /* anything connected to a gameport is a fair game */
+	{
+		.flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT |
+			 INPUT_DEVICE_ID_MATCH_BUS,
+		.evbit = { BIT(EV_ABS) },
+		.absbit = { BIT(ABS_X) },
+		.id = { .bustype = BUS_AMIGA },
+	}, /* amiga joystick does not report any special buttons but luckily it is 
+	      the only device rporting absolute coordinates on Amiga bus */
+	{
+		.flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT | 
+			 INPUT_DEVICE_ID_MATCH_KEYBIT,
 		.evbit = { BIT(EV_ABS) },
 		.absbit = { BIT(ABS_X) },
+		.keybit = { BIT(BTN_TRIGGER) }, 
+	}, /* most joysticks have either BTN_TRIGGER or BTN_A or both */
+	{
+		.flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT | 
+			 INPUT_DEVICE_ID_MATCH_KEYBIT,
+		.evbit = { BIT(EV_ABS) },
+		.absbit = { BIT(ABS_X) },
+		.keybit = { BIT(BTN_A) },
 	},
 	{
 		.flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT,
 		.evbit = { BIT(EV_ABS) },
+		.absbit = { BIT(ABS_RX), BIT(ABS_RY) },
+	}, /* magellan and some others report only MISC buttons but we can identify 
+	      them by using special axis auch as RX/RY, ABS_WHEEL or ABS_THROTTLE */
+	{
+		.flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT,
+		.evbit = { BIT(EV_ABS) },
 		.absbit = { BIT(ABS_WHEEL) },
 	},
 	{