Skip to contentSkip to conversation

USB HID buttons quirk for Chic Technology Corp. Browser Mice

RFC PATCH New Darren Salt 1 participant 1 message Nov 23, 2005 USB

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 USB HID buttons quirk for Chic Technology Corp. Browser Mice

USB HID buttons quirk for Chic Technology Corp. Browser Mice (ID 05FE:0011).

The example which I have (Advent-badged) has a wheel which can be pushed sideways (effectively two extra buttons) and a "hot-key" button. These extra buttons are reported as pairs of other buttons (presumably so that the mouse can appear as an ExplorerPS/2 device when connected via PS/2). This quirk maps this behaviour to input events for a USB-connected mouse.

  Action             Reported as               Mapped to
  ------             -----------               ---------
  Wheel left         BTN_MIDDLE + BTN_SIDE     BTN_BACK
  Wheel right        BTN_MIDDLE + BTN_EXTRA    BTN_FORWARD
  "Hot key" press    BTN_RIGHT + BTN_SIDE      BTN_TASK

For a mapping to be used and the appropriate key-down event to be generated, the relevant reported buttons must be transitioned to "pressed" simultaneously. With the mapping in use, release of any of them is enough for the corresponding key-up event.

A suitable X configuration fragment looks something like the following. The extra buttons appear as 8, 10 and 12 respectively.

Section "InputDevice"

        Identifier      "USB Mouse"
        Driver          "mouse"
        Option          "Protocol"              "evdev"
        Option          "Dev Name"              "Wireless Mouse Wireless Mouse"
        Option          "Dev Phys"              "usb-*/input0"
        Option          "Buttons"               "12"
        Option          "ZAxisMapping"          "4 5"

EndSection

(Compile-tested on 2.6.15-rc2; only one trivial change required from 2.6.13/2.6.14, where it has seen actual use.)

drivers/usb/input/hid-core.c renamed from drivers/usb/input.orig/hid-core.c +5 -0
diff -up linux-2.6.15-rc2/drivers/usb/input.orig/hid-core.c linux-2.6.15-rc2/drivers/usb/input/hid-core.c
@@ -847,6 +847,9 @@ static void hid_input_field(struct hid_d
 				hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt, regs);
 	}
 
+	if (hid->claimed & HID_CLAIMED_INPUT)
+		hidinput_hid_quirks(hid, field, regs);
+
 	memcpy(field->value, value, count * sizeof(__s32));
 exit:
 	kfree(value);
@@ -1393,6 +1396,7 @@ void hid_init_reports(struct hid_device 
 #define USB_DEVICE_ID_NEC_USB_GAME_PAD	0x0301
 
 #define USB_VENDOR_ID_CHIC		0x05fe
+#define USB_DEVICE_ID_CHIC_BROWSER_MOUSE 0x0011
 #define USB_DEVICE_ID_CHIC_GAMEPAD	0x0014
 
 #define USB_VENDOR_ID_GLAB		0x06c2
@@ -1566,6 +1570,7 @@ static struct hid_blacklist {
 	{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_POWERMOUSE, HID_QUIRK_2WHEEL_POWERMOUSE },
 	{ USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU, HID_QUIRK_2WHEEL_MOUSE_HACK_7 },
 	{ USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE, HID_QUIRK_2WHEEL_MOUSE_HACK_5 },
+	{ USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_BROWSER_MOUSE, HID_QUIRK_CHIC_2BUTTON_COMBOS_HACK },
 
 	{ USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_GAMEPAD, HID_QUIRK_BADPAD },
 	{ USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_PREDATOR, HID_QUIRK_BADPAD },
drivers/usb/input/hid-input.c renamed from drivers/usb/input.orig/hid-input.c +78 -0

105 lines not on this page · raw message

drivers/usb/input/hid.h renamed from drivers/usb/input.orig/hid.h +6 -0
diff -up linux-2.6.15-rc2/drivers/usb/input.orig/hid.h linux-2.6.15-rc2/drivers/usb/input/hid.h
@@ -246,6 +246,7 @@ struct hid_item {
 #define HID_QUIRK_2WHEEL_MOUSE_HACK_5		0x100
 #define HID_QUIRK_2WHEEL_MOUSE_HACK_ON		0x200
 #define HID_QUIRK_2WHEEL_POWERMOUSE		0x400
+#define HID_QUIRK_CHIC_2BUTTON_COMBOS_HACK	0x800
 
 /*
  * This is the global environment of the parser. This information is
@@ -431,6 +432,10 @@ struct hid_device {							/* device repo
 	void (*ff_exit)(struct hid_device*);                            /* Called by hid_exit_ff(hid) */
 	int (*ff_event)(struct hid_device *hid, struct input_dev *input,
 			unsigned int type, unsigned int code, int value);
+
+	/* For quirks where one physical button looks like (at least) two other physical buttons */
+	__u16 btn_state, btn_prev_state;				/* Button map data */
+	__u32 btn_quirks;						/* Which of the extra buttons are active */
 };
 
 #define HID_GLOBAL_STACK_SIZE 4
@@ -479,6 +484,7 @@ struct hid_descriptor {
 #define IS_INPUT_APPLICATION(a) (((a >= 0x00010000) && (a <= 0x00010008)) || (a == 0x00010080) || (a == 0x000c0001))
 extern void hidinput_hid_event(struct hid_device *, struct hid_field *, struct hid_usage *, __s32, struct pt_regs *regs);
 extern void hidinput_report_event(struct hid_device *hid, struct hid_report *report);
+extern void hidinput_hid_quirks(struct hid_device *, struct hid_field *, struct pt_regs *);
 extern int hidinput_connect(struct hid_device *);
 extern void hidinput_disconnect(struct hid_device *);
 #else
Signature · 6 lines
| Darren Salt | nr. Ashington, | d youmustbejoking,demon,co,uk
| Debian,     | Northumberland | s zap,tartarus,org
| RISC OS     | Toon Army      | @
|   Retrocomputing: a PC card in a Risc PC

For best results, squeeze from the bottom of the tube.