Skip to contentSkip to conversation

hid-magicmouse: Magic Trackpad has 1 button, not 2

PATCH In review Daniel van Vugt 4 participants 4 messages Oct 14, 2011 – Oct 21, 2011 HID

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 hid-magicmouse: Magic Trackpad has 1 button, not 2

hid-magicmouse was advertising the Apple Magic Trackpad as having 2 buttons (left and right) when it actually only has 1 button.

Advertising multiple buttons makes Xorg disable all button 2 and 3 emulation (using multi-finger clicks). So Xorg users don't get working right/middle-click emulation out of the box.

This patch makes hid-magicmouse correctly only report one real button for Magic Trackpad, which in turn makes Xorg enable multi-finger click support to emulate right/middle buttons.

[http://launchpad.net/bugs/862094]

---
 drivers/hid/hid-magicmouse.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/hid/hid-magicmouse.c +0 -0
index f0fbd7b..2ab7175 100644
@@ -405,6 +405,13 @@ static void magicmouse_setup_input(struct input_dev

*input, struct hid_device *h
__set_bit(REL_HWHEEL, input->relbit);
}
} else { /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */
+ /* input->keybit is initialized with incorrect button info
+ * for Magic Trackpad. There really is only one physical
+ * button (BTN_LEFT == BTN_MOUSE). Make sure we don't
+ * advertise buttons that don't exist...
+ */
+ __clear_bit(BTN_RIGHT, input->keybit);
+ __clear_bit(BTN_MIDDLE, input->keybit);
__set_bit(BTN_MOUSE, input->keybit); __set_bit(BTN_TOOL_FINGER, input->keybit); __set_bit(BTN_TOOL_DOUBLETAP, input->keybit);

#1 lore raw
Quoted 37 lines · Daniel van Vugt

hid-magicmouse was advertising the Apple Magic Trackpad as having 2 buttons (left and right) when it actually only has 1 button.

Advertising multiple buttons makes Xorg disable all button 2 and 3 emulation (using multi-finger clicks). So Xorg users don't get working right/middle-click emulation out of the box.

This patch makes hid-magicmouse correctly only report one real button for Magic Trackpad, which in turn makes Xorg enable multi-finger click support to emulate right/middle buttons.

[http://launchpad.net/bugs/862094]

---
 drivers/hid/hid-magicmouse.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/hid/hid-magicmouse.c +7 -0
index f0fbd7b..2ab7175 100644
@@ -405,6 +405,13 @@ static void magicmouse_setup_input(struct input_dev
 *input, struct hid_device *h
 			__set_bit(REL_HWHEEL, input->relbit);
 		}
 	} else { /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */
+		/* input->keybit is initialized with incorrect button info
+		 * for Magic Trackpad. There really is only one physical
+		 * button (BTN_LEFT == BTN_MOUSE). Make sure we don't
+		 * advertise buttons that don't exist...
+		 */
+		__clear_bit(BTN_RIGHT, input->keybit);
+		__clear_bit(BTN_MIDDLE, input->keybit);
 		__set_bit(BTN_MOUSE, input->keybit);
 		__set_bit(BTN_TOOL_FINGER, input->keybit);
Quoted 1 line

__set_bit(BTN_TOOL_DOUBLETAP, input->keybit);

To'ing Jiri Kosina, the HID maintainer.

Thanks again Daniel!

#2 lore raw

Ping, Jiri?

Quoted 43 lines · Chase Douglas
Quoted 37 lines · Daniel van Vugt

hid-magicmouse was advertising the Apple Magic Trackpad as having 2 buttons (left and right) when it actually only has 1 button.

Advertising multiple buttons makes Xorg disable all button 2 and 3 emulation (using multi-finger clicks). So Xorg users don't get working right/middle-click emulation out of the box.

This patch makes hid-magicmouse correctly only report one real button for Magic Trackpad, which in turn makes Xorg enable multi-finger click support to emulate right/middle buttons.

[http://launchpad.net/bugs/862094]

---
 drivers/hid/hid-magicmouse.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/hid/hid-magicmouse.c +7 -0
index f0fbd7b..2ab7175 100644
@@ -405,6 +405,13 @@ static void magicmouse_setup_input(struct input_dev
 *input, struct hid_device *h
 			__set_bit(REL_HWHEEL, input->relbit);
 		}
 	} else { /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */
+		/* input->keybit is initialized with incorrect button info
+		 * for Magic Trackpad. There really is only one physical
+		 * button (BTN_LEFT == BTN_MOUSE). Make sure we don't
+		 * advertise buttons that don't exist...
+		 */
+		__clear_bit(BTN_RIGHT, input->keybit);
+		__clear_bit(BTN_MIDDLE, input->keybit);
 		__set_bit(BTN_MOUSE, input->keybit);
 		__set_bit(BTN_TOOL_FINGER, input->keybit);
Quoted 1 line

__set_bit(BTN_TOOL_DOUBLETAP, input->keybit);

To'ing Jiri Kosina, the HID maintainer.

Thanks again Daniel!

#3 lore raw
Quoted 1 line · Chase Douglas

Ping, Jiri?

Somehow I haven't seen the patch in my mailbox. Applied now, thanks.

(Daniel, please fix your mail client for future patch submissions, so that it doesn't wrap lines, I had to fix that up by hand).

Quoted 46 lines · Chase Douglas
Quoted 43 lines · Daniel van Vugt
Quoted 37 lines

hid-magicmouse was advertising the Apple Magic Trackpad as having 2 buttons (left and right) when it actually only has 1 button.

Advertising multiple buttons makes Xorg disable all button 2 and 3 emulation (using multi-finger clicks). So Xorg users don't get working right/middle-click emulation out of the box.

This patch makes hid-magicmouse correctly only report one real button for Magic Trackpad, which in turn makes Xorg enable multi-finger click support to emulate right/middle buttons.

[http://launchpad.net/bugs/862094]

---
 drivers/hid/hid-magicmouse.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/hid/hid-magicmouse.c +7 -0
index f0fbd7b..2ab7175 100644
@@ -405,6 +405,13 @@ static void magicmouse_setup_input(struct input_dev
 *input, struct hid_device *h
 			__set_bit(REL_HWHEEL, input->relbit);
 		}
 	} else { /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */
+		/* input->keybit is initialized with incorrect button info
+		 * for Magic Trackpad. There really is only one physical
+		 * button (BTN_LEFT == BTN_MOUSE). Make sure we don't
+		 * advertise buttons that don't exist...
+		 */
+		__clear_bit(BTN_RIGHT, input->keybit);
+		__clear_bit(BTN_MIDDLE, input->keybit);
 		__set_bit(BTN_MOUSE, input->keybit);
 		__set_bit(BTN_TOOL_FINGER, input->keybit);
Quoted 1 line

__set_bit(BTN_TOOL_DOUBLETAP, input->keybit);

To'ing Jiri Kosina, the HID maintainer.

Thanks again Daniel!

Signature · 2 lines
Jiri Kosina
SUSE Labs