diff mbox

[05/11] HID: hid-multitouch: manually send sync event for pen input report

Message ID 1353684694-5723-6-git-send-email-benjamin.tissoires@gmail.com (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

Benjamin Tissoires Nov. 23, 2012, 3:31 p.m. UTC
Since hid-multitouch sets the quirk HID_QUIRK_NO_INPUT_SYNC, we need
to manually send the events and then make the SYN_EV.

This patch needs to export hidinput_hid_event

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
---
 drivers/hid/hid-input.c      |  1 +
 drivers/hid/hid-multitouch.c | 17 ++++++++++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index b0572d0..66ddbb6 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -1057,6 +1057,7 @@  void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
 	if ((field->flags & HID_MAIN_ITEM_RELATIVE) && (usage->type == EV_KEY))
 		input_event(input, usage->type, usage->code, 0);
 }
+EXPORT_SYMBOL_GPL(hidinput_hid_event);
 
 void hidinput_report_event(struct hid_device *hid, struct hid_report *report)
 {
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index c894306..0a4c062 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -84,6 +84,7 @@  struct mt_device {
 	struct mt_fields *fields;	/* temporary placeholder for storing the
 					   multitouch fields */
 	unsigned last_field_index;	/* last field index of the report */
+	unsigned last_pen_field_index;	/* last field index of the pen report */
 	unsigned last_slot_field;	/* the last field of a slot */
 	__s8 inputmode;		/* InputMode HID feature, -1 if non-existent */
 	__s8 inputmode_index;	/* InputMode HID feature index in the report */
@@ -371,8 +372,10 @@  static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
 		td->physical = field->physical;
 	}
 
-	if (field->physical == HID_DG_STYLUS)
+	if (field->physical == HID_DG_STYLUS) {
+		td->last_pen_field_index = field->index;
 		return 0;
+	}
 
 	if (usage->usage_index)
 		prev_usage = &field->usage[usage->usage_index - 1];
@@ -598,8 +601,16 @@  static int mt_event(struct hid_device *hid, struct hid_field *field,
 	struct mt_device *td = hid_get_drvdata(hid);
 	__s32 quirks = td->mtclass.quirks;
 
-	if (field->physical == HID_DG_STYLUS)
-		return 0;
+	if (field->physical == HID_DG_STYLUS) {
+		if (hid->claimed & HID_CLAIMED_INPUT)
+			hidinput_hid_event(hid, field, usage, value);
+		if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)
+			hid->hiddev_hid_event(hid, field, usage, value);
+		if (usage->usage_index + 1 == field->report_count &&
+		    field->index == td->last_pen_field_index)
+			input_sync(field->hidinput->input);
+		return 1;
+	}
 
 	if (hid->claimed & HID_CLAIMED_INPUT) {
 		switch (usage->hid) {