RK Android7.1 禁用 USB触摸
时间:2021-08-28
本文章向大家介绍RK Android7.1 禁用 USB触摸,主要包括RK Android7.1 禁用 USB触摸使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
一.拔插usb触摸导致浏览器页面重新刷新
二.禁用触摸
2.1.\frameworks\native\services\inputflinger\EventHub.h
/* * Input device classes. */ enum { /* The input device is a keyboard or has buttons. */ INPUT_DEVICE_CLASS_KEYBOARD = 0x00000001, /* The input device is an alpha-numeric keyboard (not just a dial pad). */ INPUT_DEVICE_CLASS_ALPHAKEY = 0x00000002, /* The input device is a touchscreen or a touchpad (either single-touch or multi-touch). */ INPUT_DEVICE_CLASS_TOUCH = 0x00000004, /* The input device is a cursor device such as a trackball or mouse. */ INPUT_DEVICE_CLASS_CURSOR = 0x00000008, /* The input device is a multi-touch touchscreen. */ INPUT_DEVICE_CLASS_TOUCH_MT = 0x00000010, /* The input device is a directional pad (implies keyboard, has DPAD keys). */ INPUT_DEVICE_CLASS_DPAD = 0x00000020, /* The input device is a gamepad (implies keyboard, has BUTTON keys). */ INPUT_DEVICE_CLASS_GAMEPAD = 0x00000040, /* The input device has switches. */ INPUT_DEVICE_CLASS_SWITCH = 0x00000080, /* The input device is a joystick (implies gamepad, has joystick absolute axes). */ INPUT_DEVICE_CLASS_JOYSTICK = 0x00000100, /* The input device has a vibrator (supports FF_RUMBLE). */ INPUT_DEVICE_CLASS_VIBRATOR = 0x00000200, /* The input device has a mouse. */ INPUT_DEVICE_CLASS_KEYMOUSE = 0x00000400, /* The input device has a microphone. */ INPUT_DEVICE_CLASS_MIC = 0x00000400, /* The input device is an external stylus (has data we want to fuse with touch data). */ INPUT_DEVICE_CLASS_EXTERNAL_STYLUS = 0x00000800, /* The input device has a rotary encoder */ INPUT_DEVICE_CLASS_ROTARY_ENCODER = 0x00001000, /* The input device is virtual (not a real device, not part of UI configuration). */ INPUT_DEVICE_CLASS_VIRTUAL = 0x40000000, /* The input device is external (not built-in). */ INPUT_DEVICE_CLASS_EXTERNAL = 0x80000000, };
2.2.frameworks\native\services\inputflinger\EventHub.cpp Mapper只处理一次 不能根据属性同步
触摸
--- a/frameworks/native/services/inputflinger/EventHub.cpp +++ b/frameworks/native/services/inputflinger/EventHub.cpp @@ -1199,7 +1199,10 @@ status_t EventHub::openDeviceLocked(const char *devicePath) { device->classes |= INPUT_DEVICE_CLASS_ROTARY_ENCODER; } } - + char usb_touch [PROPERTY_VALUE_MAX]; + int usb_touch_flag = 0; + property_get("persist.sys.UsbTouch", usb_touch, "0"); + usb_touch_flag = strtol(usb_touch,0,0); // See if this is a touch pad. // Is this a new modern multi-touch driver? if (test_bit(ABS_MT_POSITION_X, device->absBitmask) @@ -1208,13 +1211,21 @@ status_t EventHub::openDeviceLocked(const char *devicePath) { // with the ABS_MT range. Try to confirm that the device really is // a touch screen. if (test_bit(BTN_TOUCH, device->keyBitmask) || !haveGamepadButtons) { - device->classes |= INPUT_DEVICE_CLASS_TOUCH | INPUT_DEVICE_CLASS_TOUCH_MT; + device->classes |= INPUT_DEVICE_CLASS_TOUCH | INPUT_DEVICE_CLASS_TOUCH_MT; + if(usb_touch_flag){ + ALOGD("gatsby INPUT_DEVICE_CLASS_TOUCH INPUT_DEVICE_CLASS_TOUCH_MT"); + return -1; + } } // Is this an old style single-touch driver? } else if (test_bit(BTN_TOUCH, device->keyBitmask) && test_bit(ABS_X, device->absBitmask) && test_bit(ABS_Y, device->absBitmask)) { - device->classes |= INPUT_DEVICE_CLASS_TOUCH; + device->classes |= INPUT_DEVICE_CLASS_TOUCH; + if(usb_touch_flag){ + ALOGD("gatsby INPUT_DEVICE_CLASS_TOUCH"); + return -1; + } // Is this a BT stylus? } else if ((test_bit(ABS_PRESSURE, device->absBitmask) || test_bit(BTN_TOUCH, device->keyBitmask))
键盘
device->classes |= INPUT_DEVICE_CLASS_KEYBOARD | INPUT_DEVICE_CLASS_KEYMOUSE;
鼠标
device->classes |= INPUT_DEVICE_CLASS_CURSOR;
2.3.frameworks\native\services\inputflinger\InputReader.cpp 多点触摸屏处理函数 处理数据上报
--- a/frameworks/native/services/inputflinger/InputReader.cpp +++ b/frameworks/native/services/inputflinger/InputReader.cpp @@ -85,6 +85,9 @@ static const nsecs_t STYLUS_DATA_LATENCY = ms2ns(10); static const int KEYCODE_ENTER = 28; static const int KEYCODE_DPAD_CENTER = 232; +static char usb_touch [PROPERTY_VALUE_MAX]; +static int usb_touch_flag = 0; + // --- Static Functions --- template<typename T> @@ -1739,6 +1742,10 @@ void MultiTouchMotionAccumulator::clearSlots(int32_t initialSlot) { } void MultiTouchMotionAccumulator::process(const RawEvent* rawEvent) { + //ALOGD("gatsby MultiTouchMotionAccumulator"); + property_get("persist.sys.UsbTouch", usb_touch, "0"); + usb_touch_flag = strtol(usb_touch,0,0); +if(usb_touch_flag){ if (rawEvent->type == EV_ABS) { bool newSlot = false; if (mUsingSlotsProtocol) { @@ -1821,6 +1828,7 @@ void MultiTouchMotionAccumulator::process(const RawEvent* rawEvent) { // MultiTouch Sync: The driver has returned all data for *one* of the pointers. mCurrentSlot += 1; } +} }
原文地址:https://www.cnblogs.com/crushgirl/p/15200388.html
- 一个类似于进度和打卡进度的自定义view
- 《深入理解Java虚拟机》(四)虚拟机性能监控与故障处理工具
- 第七章:Shiro的Session管理——深入浅出学Shiro细粒度权限开发框架
- 《深入理解Java虚拟机》(六)堆内存使用分析,垃圾收集器 GC 日志解读
- Knockout.js是什么?
- 简单方法检测远端用户的反病毒软件
- 使用 JS 构建跨平台的原生应用(一):React Native for Android 初探
- 基于Metronic的Bootstrap开发框架经验总结(9)--实现Web页面内容的打印预览和保存操作
- 在Windows上安装Jekyll
- 如何解决ajax跨域问题
- 基础篇章:React Native之 Image 的讲解
- 防守式编程的艺术
- Git 简单命令,木有高深内容
- 基础篇章:React Native之 ScrollView 的讲解
- java教程
- Java快速入门
- Java 开发环境配置
- Java基本语法
- Java 对象和类
- Java 基本数据类型
- Java 变量类型
- Java 修饰符
- Java 运算符
- Java 循环结构
- Java 分支结构
- Java Number类
- Java Character类
- Java String类
- Java StringBuffer和StringBuilder类
- Java 数组
- Java 日期时间
- Java 正则表达式
- Java 方法
- Java 流(Stream)、文件(File)和IO
- Java 异常处理
- Java 继承
- Java 重写(Override)与重载(Overload)
- Java 多态
- Java 抽象类
- Java 封装
- Java 接口
- Java 包(package)
- Java 数据结构
- Java 集合框架
- Java 泛型
- Java 序列化
- Java 网络编程
- Java 发送邮件
- Java 多线程编程
- Java Applet基础
- Java 文档注释
- 用Python爬取LOL所有的英雄信息以及英雄皮肤的示例代码
- Python操作MySQL数据库的示例代码
- 解决pyinstaller 打包exe文件太大,用pipenv 缩小exe的问题
- PyCharm中配置PySide2的图文教程
- 浅析Python 简单工厂模式和工厂方法模式的优缺点
- thinkPHP利用ajax异步上传图片并显示、删除的示例
- 对python中list的五种查找方法说明
- Laravel框架查询构造器简单示例
- PHP调用微博接口实现微博登录的方法示例
- Python使用pyexecjs代码案例解析
- PHP抽象类与接口的区别实例详解
- laravel获取不到session的三种解决办法【推荐】
- php封装的pdo数据库操作工具类与用法示例
- 利用PyQt5+Matplotlib 绘制静态/动态图的实现代码
- PHP封装类似thinkphp连贯操作数据库Db类与简单应用示例