aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2017-11-22 06:57:10 -0500
committerJiri Kosina <jkosina@suse.cz>2017-11-22 10:01:06 -0500
commit127e71bd462b87301f5ff1d1fd686515b4a4af9c (patch)
treecc5fe72c76a542799f614d96688881bde6d491c1
parent55746d28d66860bccaae20a67b55b9d5db7c14af (diff)
HID: multitouch: Combine all left-button events in a frame
According to the Win8 Precision Touchpad spec, inside the HID_UP_BUTTON usage-page usage 1 is for a clickpad getting clicked, 2 for an external left button and 3 for an external right button. Since Linux uses BTN_LEFT for a clickpad being clicked we end up mapping both usage 1 and 2 to BTN_LEFT and if a single report contains both then we ended up always reporting the value of both in a single SYN, e.g. : BTN_LEFT 1, BTN_LEFT 0, SYN. This happens for example with Hantick HTT5288 i2c mt touchpads. This commit fixes this by not immediately reporting left button when we parse the report, but instead storing or-ing together the values and reporting the result from mt_sync_frame() when we've a complete frame. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/hid-multitouch.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 760c4a042e6a..76088f2cf598 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -122,6 +122,7 @@ struct mt_device {
122 int scantime_index; /* scantime field index in the report */ 122 int scantime_index; /* scantime field index in the report */
123 int scantime_val_index; /* scantime value index in the field */ 123 int scantime_val_index; /* scantime value index in the field */
124 int prev_scantime; /* scantime reported in the previous packet */ 124 int prev_scantime; /* scantime reported in the previous packet */
125 int left_button_state; /* left button state */
125 unsigned last_slot_field; /* the last field of a slot */ 126 unsigned last_slot_field; /* the last field of a slot */
126 unsigned mt_report_id; /* the report ID of the multitouch device */ 127 unsigned mt_report_id; /* the report ID of the multitouch device */
127 unsigned long initial_quirks; /* initial quirks state */ 128 unsigned long initial_quirks; /* initial quirks state */
@@ -743,10 +744,16 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input)
743 */ 744 */
744static void mt_sync_frame(struct mt_device *td, struct input_dev *input) 745static void mt_sync_frame(struct mt_device *td, struct input_dev *input)
745{ 746{
747 __s32 cls = td->mtclass.name;
748
749 if (cls == MT_CLS_WIN_8 || cls == MT_CLS_WIN_8_DUAL)
750 input_event(input, EV_KEY, BTN_LEFT, td->left_button_state);
751
746 input_mt_sync_frame(input); 752 input_mt_sync_frame(input);
747 input_event(input, EV_MSC, MSC_TIMESTAMP, td->timestamp); 753 input_event(input, EV_MSC, MSC_TIMESTAMP, td->timestamp);
748 input_sync(input); 754 input_sync(input);
749 td->num_received = 0; 755 td->num_received = 0;
756 td->left_button_state = 0;
750 if (test_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags)) 757 if (test_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags))
751 set_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); 758 set_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags);
752 else 759 else
@@ -857,6 +864,19 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field,
857 !first_packet) 864 !first_packet)
858 return; 865 return;
859 866
867 /*
868 * For Win8 PTP touchpads we map both the clickpad click
869 * and any "external" left buttons to BTN_LEFT if a
870 * device claims to have both we need to report 1 for
871 * BTN_LEFT if either is pressed, so we or all values
872 * together and report the result in mt_sync_frame().
873 */
874 if ((cls == MT_CLS_WIN_8 || cls == MT_CLS_WIN_8_DUAL) &&
875 usage->type == EV_KEY && usage->code == BTN_LEFT) {
876 td->left_button_state |= value;
877 return;
878 }
879
860 if (usage->type) 880 if (usage->type)
861 input_event(input, usage->type, usage->code, 881 input_event(input, usage->type, usage->code,
862 value); 882 value);