Skip to content

Commit 499522c

Browse files
jigpuJiri Kosina
authored andcommitted
HID: wacom: Tie cached HID_DG_CONTACTCOUNT indices to report ID
The cached indicies 'cc_index' and 'cc_value_index' introduced in 1b5d514 are only valid for a single report ID. If a touchscreen has multiple reports with a HID_DG_CONTACTCOUNT usage, its possible that the values will not be correct for the report we're handling, resulting in an incorrect value for 'num_expected'. This has been observed with the Cintiq Companion 2. To address this, we store the ID of the report those indicies are valid for in a new 'cc_report' variable. Before using them to get the expected contact count, we first check if the ID of the report we're processing matches 'cc_report'. If it doesn't, we update the indicies to point to the HID_DG_CONTACTCOUNT usage of the current report (if it has one). Cc: [email protected] Signed-off-by: Jason Gerecke <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent e8e8843 commit 499522c

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

drivers/hid/wacom_wac.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,6 +1628,7 @@ static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
16281628
wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
16291629
break;
16301630
case HID_DG_CONTACTCOUNT:
1631+
wacom_wac->hid_data.cc_report = field->report->id;
16311632
wacom_wac->hid_data.cc_index = field->index;
16321633
wacom_wac->hid_data.cc_value_index = usage->usage_index;
16331634
break;
@@ -1715,6 +1716,31 @@ static void wacom_wac_finger_pre_report(struct hid_device *hdev,
17151716
struct wacom_wac *wacom_wac = &wacom->wacom_wac;
17161717
struct hid_data* hid_data = &wacom_wac->hid_data;
17171718

1719+
if (hid_data->cc_report != 0 &&
1720+
hid_data->cc_report != report->id) {
1721+
int i;
1722+
1723+
hid_data->cc_report = report->id;
1724+
hid_data->cc_index = -1;
1725+
hid_data->cc_value_index = -1;
1726+
1727+
for (i = 0; i < report->maxfield; i++) {
1728+
struct hid_field *field = report->field[i];
1729+
int j;
1730+
1731+
for (j = 0; j < field->maxusage; j++) {
1732+
if (field->usage[j].hid == HID_DG_CONTACTCOUNT) {
1733+
hid_data->cc_index = i;
1734+
hid_data->cc_value_index = j;
1735+
1736+
/* break */
1737+
i = report->maxfield;
1738+
j = field->maxusage;
1739+
}
1740+
}
1741+
}
1742+
}
1743+
17181744
if (hid_data->cc_index >= 0) {
17191745
struct hid_field *field = report->field[hid_data->cc_index];
17201746
int value = field->value[hid_data->cc_value_index];

drivers/hid/wacom_wac.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ struct hid_data {
198198
int width;
199199
int height;
200200
int id;
201+
int cc_report;
201202
int cc_index;
202203
int cc_value_index;
203204
int num_expected;

0 commit comments

Comments
 (0)