Commit fa11aa72 authored by Benjamin Tissoires's avatar Benjamin Tissoires Committed by Jiri Kosina

HID: multitouch: add handling for pen in dual-sensors device

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.

Since hid-multitouch sets the quirk HID_QUIRK_NO_INPUT_SYNC, we need
to manually send SYN events for pen report too.
Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 5b6498a1
...@@ -99,6 +99,7 @@ struct mt_device { ...@@ -99,6 +99,7 @@ struct mt_device {
int cc_value_index; /* contact count value index in the field */ int cc_value_index; /* contact count value index in the field */
unsigned last_slot_field; /* the last field of a slot */ unsigned last_slot_field; /* the last field of a slot */
unsigned mt_report_id; /* the report ID of the multitouch device */ 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; /* InputMode HID feature, -1 if non-existent */
__s8 inputmode_index; /* InputMode HID feature index in the report */ __s8 inputmode_index; /* InputMode HID feature index in the report */
__s8 maxcontact_report_id; /* Maximum Contact Number HID feature, __s8 maxcontact_report_id; /* Maximum Contact Number HID feature,
...@@ -367,6 +368,43 @@ static void mt_store_field(struct hid_usage *usage, struct mt_device *td, ...@@ -367,6 +368,43 @@ static void mt_store_field(struct hid_usage *usage, struct mt_device *td,
f->usages[f->length++] = usage->hid; 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)
{
struct hid_field *field = report->field[0];
input_sync(field->hidinput->input);
}
static void mt_pen_input_configured(struct hid_device *hdev,
struct hid_input *hi)
{
}
static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
struct hid_field *field, struct hid_usage *usage, struct hid_field *field, struct hid_usage *usage,
unsigned long **bit, int *max) unsigned long **bit, int *max)
...@@ -740,14 +778,12 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, ...@@ -740,14 +778,12 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
* We need to ignore fields that belong to other collections * We need to ignore fields that belong to other collections
* such as Mouse that might have the same GenericDesktop usages. */ * such as Mouse that might have the same GenericDesktop usages. */
if (field->application != HID_DG_TOUCHSCREEN && if (field->application != HID_DG_TOUCHSCREEN &&
field->application != HID_DG_PEN &&
field->application != HID_DG_TOUCHPAD) field->application != HID_DG_TOUCHPAD)
return -1; 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) 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); return mt_touch_input_mapping(hdev, hi, field, usage, bit, max);
} }
...@@ -756,6 +792,9 @@ static int mt_input_mapped(struct hid_device *hdev, struct hid_input *hi, ...@@ -756,6 +792,9 @@ static int mt_input_mapped(struct hid_device *hdev, struct hid_input *hi,
struct hid_field *field, struct hid_usage *usage, struct hid_field *field, struct hid_usage *usage,
unsigned long **bit, int *max) 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); return mt_touch_input_mapped(hdev, hi, field, usage, bit, max);
} }
...@@ -767,6 +806,9 @@ static int mt_event(struct hid_device *hid, struct hid_field *field, ...@@ -767,6 +806,9 @@ static int mt_event(struct hid_device *hid, struct hid_field *field,
if (field->report->id == td->mt_report_id) if (field->report->id == td->mt_report_id)
return mt_touch_event(hid, field, usage, value); 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 */ /* ignore other reports */
return 1; return 1;
} }
...@@ -780,6 +822,9 @@ static void mt_report(struct hid_device *hid, struct hid_report *report) ...@@ -780,6 +822,9 @@ static void mt_report(struct hid_device *hid, struct hid_report *report)
if (report->id == td->mt_report_id) if (report->id == td->mt_report_id)
mt_touch_report(hid, report); 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) static void mt_set_input_mode(struct hid_device *hdev)
...@@ -861,6 +906,9 @@ static void mt_input_configured(struct hid_device *hdev, struct hid_input *hi) ...@@ -861,6 +906,9 @@ static void mt_input_configured(struct hid_device *hdev, struct hid_input *hi)
if (hi->report->id == td->mt_report_id) if (hi->report->id == td->mt_report_id)
mt_touch_input_configured(hdev, hi); mt_touch_input_configured(hdev, hi);
if (hi->report->id == td->pen_report_id)
mt_pen_input_configured(hdev, hi);
} }
static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
...@@ -881,6 +929,14 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) ...@@ -881,6 +929,14 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
*/ */
hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC; 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); td = kzalloc(sizeof(struct mt_device), GFP_KERNEL);
if (!td) { if (!td) {
dev_err(&hdev->dev, "cannot allocate multitouch data\n"); dev_err(&hdev->dev, "cannot allocate multitouch data\n");
...@@ -890,6 +946,8 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) ...@@ -890,6 +946,8 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
td->inputmode = -1; td->inputmode = -1;
td->maxcontact_report_id = -1; td->maxcontact_report_id = -1;
td->cc_index = -1; td->cc_index = -1;
td->mt_report_id = -1;
td->pen_report_id = -1;
hid_set_drvdata(hdev, td); hid_set_drvdata(hdev, td);
td->fields = kzalloc(sizeof(struct mt_fields), GFP_KERNEL); td->fields = kzalloc(sizeof(struct mt_fields), GFP_KERNEL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment