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 小时前
【Android FrameWork】第二十四天:Activity生命周期是如何运行的
android
ytttr8732 小时前
基于C#的CAN总线数据解析BMS上位机
android·unity·c#
darryrzhong3 小时前
FluxImageLoader : 基于Coil3封装的 Android 图片加载库,旨在提供简单、高效且功能丰富的图片加载解决方案
android·github·android jetpack
pandarking3 小时前
[CTF]攻防世界:题目名称-warmup
android·web安全·网络安全
我命由我123454 小时前
Android 开发问题:在无法直接获取或者通过传递获取 Context 的地方如何获取 Context
android·java·java-ee·android studio·android jetpack·android-studio·android runtime
惟恋惜4 小时前
Jetpack Compose之“副作用”的讲解
android
モンキー・D・小菜鸡儿5 小时前
Android14 新特性与适配指南
android·kotlin·安卓新特性
技术摆渡人6 小时前
Android系统技术探索(1)启动流程
android
介一安全8 小时前
【Frida Android】实战篇12:企业常用对称加密场景 Hook 教程
android·网络安全·逆向·安全性测试·frida
モンキー・D・小菜鸡儿8 小时前
Android15 新特性与适配指南
android·kotlin·安卓新特性