From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Benjamin Tissoires <benjamin.tissoires@gmail.com>,
Henrik Rydberg <rydberg@euromail.se>,
Jiri Kosina <jkosina@suse.cz>, Stephane Chatty <chatty@enac.fr>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/7] HID: multitouch: add handling for pen in dual-sensors device
Date: Wed, 27 Feb 2013 17:55:24 +0100 [thread overview]
Message-ID: <1361984127-912-5-git-send-email-benjamin.tissoires@redhat.com> (raw)
In-Reply-To: <1361984127-912-1-git-send-email-benjamin.tissoires@redhat.com>
Dual sensors devices reports pen and touch on two different reports.
Using the quirk HID_QUIRK_MULTI_INPUT allows us to create a new input
device to forward pen events.
The quirk HID_QUIRK_NO_EMPTY_INPUT avoids the creation of input devices
for the not used mouse emulation present on Win7 certified devices.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
drivers/hid/hid-multitouch.c | 55 ++++++++++++++++++++++++++++++++++++++++----
1 file changed, 51 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 315500c..77ba751 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -100,6 +100,7 @@ struct mt_device {
unsigned last_field_index; /* last field index of the report */
unsigned last_slot_field; /* the last field of a slot */
unsigned mt_report_id; /* the report ID of the multitouch device */
+ unsigned pen_report_id; /* the report ID of the pen device */
__s8 inputmode; /* InputMode HID feature, -1 if non-existent */
__s8 inputmode_index; /* InputMode HID feature index in the report */
__s8 maxcontact_report_id; /* Maximum Contact Number HID feature,
@@ -365,6 +366,35 @@ static void mt_store_field(struct hid_usage *usage, struct mt_device *td,
f->usages[f->length++] = usage->hid;
}
+static int mt_pen_input_mapping(struct hid_device *hdev, struct hid_input *hi,
+ struct hid_field *field, struct hid_usage *usage,
+ unsigned long **bit, int *max)
+{
+ struct mt_device *td = hid_get_drvdata(hdev);
+
+ td->pen_report_id = field->report->id;
+
+ return 0;
+}
+
+static int mt_pen_input_mapped(struct hid_device *hdev, struct hid_input *hi,
+ struct hid_field *field, struct hid_usage *usage,
+ unsigned long **bit, int *max)
+{
+ return 0;
+}
+
+static int mt_pen_event(struct hid_device *hid, struct hid_field *field,
+ struct hid_usage *usage, __s32 value)
+{
+ /* let hid-input handle it */
+ return 0;
+}
+
+static void mt_pen_report(struct hid_device *hid, struct hid_report *report)
+{
+}
+
static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
struct hid_field *field, struct hid_usage *usage,
unsigned long **bit, int *max)
@@ -725,14 +755,12 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
* We need to ignore fields that belong to other collections
* such as Mouse that might have the same GenericDesktop usages. */
if (field->application != HID_DG_TOUCHSCREEN &&
+ field->application != HID_DG_PEN &&
field->application != HID_DG_TOUCHPAD)
return -1;
- /* eGalax devices provide a Digitizer.Stylus input which overrides
- * the correct Digitizers.Finger X/Y ranges.
- * Let's just ignore this input. */
if (field->physical == HID_DG_STYLUS)
- return -1;
+ return mt_pen_input_mapping(hdev, hi, field, usage, bit, max);
return mt_touch_input_mapping(hdev, hi, field, usage, bit, max);
}
@@ -741,6 +769,9 @@ static int mt_input_mapped(struct hid_device *hdev, struct hid_input *hi,
struct hid_field *field, struct hid_usage *usage,
unsigned long **bit, int *max)
{
+ if (field->physical == HID_DG_STYLUS)
+ return mt_pen_input_mapped(hdev, hi, field, usage, bit, max);
+
return mt_touch_input_mapped(hdev, hi, field, usage, bit, max);
}
@@ -752,6 +783,9 @@ static int mt_event(struct hid_device *hid, struct hid_field *field,
if (field->report->id == td->mt_report_id)
return mt_touch_event(hid, field, usage, value);
+ if (field->report->id == td->pen_report_id)
+ return mt_pen_event(hid, field, usage, value);
+
/* ignore other reports */
return 1;
}
@@ -765,6 +799,9 @@ static void mt_report(struct hid_device *hid, struct hid_report *report)
if (report->id == td->mt_report_id)
mt_touch_report(hid, report);
+
+ if (report->id == td->pen_report_id)
+ mt_pen_report(hid, report);
}
static void mt_set_input_mode(struct hid_device *hdev)
@@ -887,6 +924,14 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
*/
hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC;
+ /*
+ * This allows the driver to handle different input sensors
+ * that emits events through different reports on the same HID
+ * device.
+ */
+ hdev->quirks |= HID_QUIRK_MULTI_INPUT;
+ hdev->quirks |= HID_QUIRK_NO_EMPTY_INPUT;
+
td = kzalloc(sizeof(struct mt_device), GFP_KERNEL);
if (!td) {
dev_err(&hdev->dev, "cannot allocate multitouch data\n");
@@ -896,6 +941,8 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
td->inputmode = -1;
td->maxcontact_report_id = -1;
td->cc_index = -1;
+ td->mt_report_id = -1;
+ td->pen_report_id = -1;
hid_set_drvdata(hdev, td);
td->fields = kzalloc(sizeof(struct mt_fields), GFP_KERNEL);
--
1.8.1.2
next prev parent reply other threads:[~2013-02-27 16:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-27 16:55 [PATCH 0/7] HID: multitouch: support of hybrid finger/pen devices Benjamin Tissoires
2013-02-27 16:55 ` [PATCH 1/7] HID: input: don't register unmapped input devices Benjamin Tissoires
2013-03-19 21:25 ` Henrik Rydberg
2013-03-20 9:30 ` Benjamin Tissoires
2013-03-22 14:48 ` Benjamin Tissoires
2013-02-27 16:55 ` [PATCH 2/7] HID: multitouch: breaks out touch handling in specific functions Benjamin Tissoires
2013-02-27 16:55 ` [PATCH 3/7] HID: multitouch: do not map usage from non used reports Benjamin Tissoires
2013-02-27 16:55 ` Benjamin Tissoires [this message]
2013-03-19 21:32 ` [PATCH 4/7] HID: multitouch: add handling for pen in dual-sensors device Henrik Rydberg
2013-03-20 13:42 ` Benjamin Tissoires
2013-02-27 16:55 ` [PATCH 5/7] HID: multitouch: manually send sync event for pen input report Benjamin Tissoires
2013-02-27 16:55 ` [PATCH 6/7] HID: multitouch: append " Pen" to the name of the stylus input Benjamin Tissoires
2013-03-19 21:38 ` Henrik Rydberg
2013-03-20 14:42 ` Benjamin Tissoires
2013-02-27 16:55 ` [PATCH 7/7] HID: multitouch: force BTN_STYLUS for pen devices Benjamin Tissoires
2013-03-18 22:14 ` [PATCH 0/7] HID: multitouch: support of hybrid finger/pen devices Jiri Kosina
2013-03-19 21:40 ` Henrik Rydberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1361984127-912-5-git-send-email-benjamin.tissoires@redhat.com \
--to=benjamin.tissoires@redhat.com \
--cc=benjamin.tissoires@gmail.com \
--cc=chatty@enac.fr \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rydberg@euromail.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).