Android 设置20点触摸

Android 设置20点触摸

文章目录

一、前言

增加Android触摸点,一般是在商显的Android大屏上有一定的需求,在普通的Android设备基本不用。

首先,Android系统默认最多支持16点触摸。

如果要增加有效触摸点,需要更新对应的触摸框驱动ko文件;

还要再framework中进行代码适配。

关于触摸框点数增加的文章,网上也有不少,但是CSDN上基本都是要会员才能看,这里给大家介绍一下。

二、适配修改

1、修改触摸驱动文件

ko位置:

device/ko/touch/xxx.ko

ko 文件是驱动层结合触摸框硬件提供的,未进行过具体修改,不过多描述。

2、修改framework代码文件

framework中的需要适配的代码:

(1)开放触摸点数为20点,修改的文件包含:
release/frameworks/base/core/java/android/view/MotionEvent.java
release/frameworks/native/include/android/input.h
release/frameworks/native/include/input/Input.h
release/frameworks/native/include/input/InputEventLabels.h

修改的代码,不就是Android 系统中的按键相关代码吗。

(2)具体修改

其实改的代码也不多,也比较容易理解,具体修改入下:

有+号的行,就是代码增加的意思。

diff --git a/release/frameworks/base/core/java/android/view/MotionEvent.java b/release/frameworks/base/core/java/android/view/MotionEvent.java


+++ b/release/frameworks/base/core/java/android/view/MotionEvent.java
@@ -1229,6 +1229,10 @@ public final class MotionEvent extends InputEvent implements Parcelable {
      * @see InputDevice#getMotionRange
      */
     public static final int AXIS_GENERIC_16 = 47;
+    public static final int AXIS_GENERIC_17 = 48;
+    public static final int AXIS_GENERIC_18 = 49;
+    public static final int AXIS_GENERIC_19 = 50;
+    public static final int AXIS_GENERIC_20 = 51;
 
     // NOTE: If you add a new axis here you must also add it to:
     //  native/include/android/input.h
@@ -1283,6 +1287,10 @@ public final class MotionEvent extends InputEvent implements Parcelable {
         names.append(AXIS_GENERIC_14, "AXIS_GENERIC_14");
         names.append(AXIS_GENERIC_15, "AXIS_GENERIC_15");
         names.append(AXIS_GENERIC_16, "AXIS_GENERIC_16");
+        names.append(AXIS_GENERIC_17, "AXIS_GENERIC_17");
+        names.append(AXIS_GENERIC_18, "AXIS_GENERIC_18");
+        names.append(AXIS_GENERIC_19, "AXIS_GENERIC_19");
+        names.append(AXIS_GENERIC_20, "AXIS_GENERIC_20");
     }
 
     /**
diff --git a/release/frameworks/native/include/android/input.h b/release/frameworks/native/include/android/input.h


+++ b/release/frameworks/native/include/android/input.h
@@ -747,6 +747,10 @@ enum {
      * The interpretation of a generic axis is device-specific.
      */
     AMOTION_EVENT_AXIS_GENERIC_16 = 47,
+    AMOTION_EVENT_AXIS_GENERIC_17 = 48,
+    AMOTION_EVENT_AXIS_GENERIC_18 = 49,
+    AMOTION_EVENT_AXIS_GENERIC_19 = 50,
+    AMOTION_EVENT_AXIS_GENERIC_20 = 51,
 
     // NOTE: If you add a new axis here you must also add it to several other files.
     //       Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
diff --git a/release/frameworks/native/include/input/Input.h b/release/frameworks/native/include/input/Input.h


+++ b/release/frameworks/native/include/input/Input.h
@@ -122,7 +122,7 @@ enum {
  * (We want at least 10 but some touch controllers obstensibly configured for 10 pointers
  * will occasionally emit 11.  There is not much harm making this constant bigger.)
  */
-#define MAX_POINTERS 16
+#define MAX_POINTERS 20
 
 /*
  * Maximum number of samples supported per motion event.
diff --git a/release/frameworks/native/include/input/InputEventLabels.h b/release/frameworks/native/include/input/InputEventLabels.h
old mode 100644
new mode 100755

+++ b/release/frameworks/native/include/input/InputEventLabels.h
@@ -372,6 +372,10 @@ static const InputEventLabel AXES[] = {
     DEFINE_AXIS(GENERIC_14),
     DEFINE_AXIS(GENERIC_15),
     DEFINE_AXIS(GENERIC_16),
+    DEFINE_AXIS(GENERIC_17),
+    DEFINE_AXIS(GENERIC_18),
+    DEFINE_AXIS(GENERIC_19),
+    DEFINE_AXIS(GENERIC_20),
 
     // NOTE: If you add a new axis here you must also add it to several other files.
     //       Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
diff --git a/version.h b/version.h

(END)

随着cpu越来越高效,现在商显(白板应用)要求触摸点数也是越来多,有的设备要求32点或者更多。

无论修改多少点基本上修改上面对应的文件即可。

相关推荐
编程洪同学2 小时前
Spring Boot 中实现自定义注解记录接口日志功能
android·java·spring boot·后端
氤氲息4 小时前
Android 底部tab,使用recycleview实现
android
Clockwiseee4 小时前
PHP之伪协议
android·开发语言·php
小林爱4 小时前
【Compose multiplatform教程08】【组件】Text组件
android·java·前端·ui·前端框架·kotlin·android studio
小何开发6 小时前
Android Studio 安装教程
android·ide·android studio
开发者阿伟6 小时前
Android Jetpack LiveData源码解析
android·android jetpack
weixin_438150996 小时前
广州大彩串口屏安卓/linux触摸屏四路CVBS输入实现同时显示!
android·单片机
CheungChunChiu7 小时前
Android10 rk3399 以太网接入流程分析
android·framework·以太网·eth·net·netd
木头没有瓜7 小时前
ruoyi 请求参数类型不匹配,参数[giftId]要求类型为:‘java.lang.Long‘,但输入值为:‘orderGiftUnionList
android·java·okhttp
键盘侠0077 小时前
springboot 上传图片 转存成webp
android·spring boot·okhttp