summaryrefslogtreecommitdiff
path: root/drivers/hid
diff options
context:
space:
mode:
authorJohn Chen <johnchen902@gmail.com>2021-03-30 19:33:17 +0800
committerJiri Kosina <jkosina@suse.cz>2021-04-07 13:15:05 +0200
commit3dcc5f7b45e037b0c6e84e4f757d16c55535db28 (patch)
tree13336f092b860ca70915ef95e3801091dd279679 /drivers/hid
parent2b0c086cd6f40648df73c30ea785e5c7777948da (diff)
HID: magicmouse: fix 3 button emulation of Mouse 2
It is observed that, with 3 button emulation, when middle button is clicked, either the left button or right button is clicked as well. It is caused by hidinput "correctly" acting on the event, oblivious to the 3 button emulation. As raw_event has taken care of everything, no further processing is needed. However, the only way to stop at raw_event is to return an error (negative) value. Therefore, the processing is stopped at event instead. [jkosina@suse.cz: fix comment style] Signed-off-by: John Chen <johnchen902@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/hid-magicmouse.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index 7aad6ca56780..6740bda725d1 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -440,6 +440,23 @@ static int magicmouse_raw_event(struct hid_device *hdev,
return 1;
}
+static int magicmouse_event(struct hid_device *hdev, struct hid_field *field,
+ struct hid_usage *usage, __s32 value)
+{
+ struct magicmouse_sc *msc = hid_get_drvdata(hdev);
+ if (msc->input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 &&
+ field->report->id == MOUSE2_REPORT_ID) {
+ /*
+ * magic_mouse_raw_event has done all the work. Skip hidinput.
+ *
+ * Specifically, hidinput may modify BTN_LEFT and BTN_RIGHT,
+ * breaking emulate_3button.
+ */
+ return 1;
+ }
+ return 0;
+}
+
static int magicmouse_setup_input(struct input_dev *input, struct hid_device *hdev)
{
int error;
@@ -754,6 +771,7 @@ static struct hid_driver magicmouse_driver = {
.id_table = magic_mice,
.probe = magicmouse_probe,
.raw_event = magicmouse_raw_event,
+ .event = magicmouse_event,
.input_mapping = magicmouse_input_mapping,
.input_configured = magicmouse_input_configured,
};