linux-3.10\drivers\hid\hid-multitouch.c
--- hid-multitouch.c_bak 2019-07-05 17:33:23.000000000 +0800
+++ hid-multitouch.c 2020-04-17 09:42:26.076644126 +0800
@@ -68,6 +68,12 @@
#define MT_QUIRK_HOVERING (1 << 11)
#define MT_QUIRK_CONTACT_CNT_ACCURATE (1 << 12)
+static int exchange_x_y_flag = 1;
+static int revert_x_flag = 0;
+static int revert_y_flag = 1;
+
+static int X_max = 0;
+static int Y_max = 0;
struct mt_slot {
__s32 x, y, cx, cy, p, w, h;
__s32 contactid; /* the device ContactID assigned to this slot */
@@ -460,7 +466,8 @@
case HID_UP_GENDESK:
switch (usage->hid) {
- case HID_GD_X:
+ case HID_GD_Y:
+ X_max = field->logical_maximum;
if (prev_usage && (prev_usage->hid == usage->hid)) {
hid_map_usage(hi, usage, bit, max,
EV_ABS, ABS_MT_TOOL_X);
@@ -475,7 +482,9 @@
mt_store_field(usage, td, hi);
return 1;
- case HID_GD_Y:
+ case HID_GD_X:
+ Y_max = field->logical_maximum;
+
if (prev_usage && (prev_usage->hid == usage->hid)) {
hid_map_usage(hi, usage, bit, max,
EV_ABS, ABS_MT_TOOL_Y);
@@ -641,6 +650,15 @@
int major = max(s->w, s->h) >> 1;
int minor = min(s->w, s->h) >> 1;
+ if(1 == exchange_x_y_flag)
+ swap(s->x, s->y);
+
+ if(1 == revert_x_flag)
+ s->x = X_max - (s->x);
+
+ if(1 == revert_y_flag)
+ s->y = Y_max - (s->y);
+
input_event(input, EV_ABS, ABS_MT_POSITION_X, s->x);
input_event(input, EV_ABS, ABS_MT_POSITION_Y, s->y);
input_event(input, EV_ABS, ABS_MT_TOOL_X, s->cx);
之前只交换s->x 和 s->y的数值但是触摸还是没对
之后 HID_GD_X和HID_GD_Y位置触摸才正确