USB 触摸在竖屏时校准

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位置触摸才正确

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值