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点或者更多。
无论修改多少点基本上修改上面对应的文件即可。

相关推荐

  1. Android 设置20触摸

    2023-12-10 07:20:05       55 阅读
  2. android SpannableStringBuilder span 设置击事件

    2023-12-10 07:20:05       22 阅读
  3. [Ubuntu 20.04] QT屏幕与触摸旋转

    2023-12-10 07:20:05       39 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-10 07:20:05       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-10 07:20:05       106 阅读
  3. 在Django里面运行非项目文件

    2023-12-10 07:20:05       87 阅读
  4. Python语言-面向对象

    2023-12-10 07:20:05       96 阅读

热门阅读

  1. 前端知识笔记(二)———Django与Ajax

    2023-12-10 07:20:05       55 阅读
  2. qml刷新C++中的QImage图像

    2023-12-10 07:20:05       63 阅读
  3. 使用Spring Security、JWT和Swagger进行登录验证的流程

    2023-12-10 07:20:05       54 阅读
  4. Tomcat使用https方式连接

    2023-12-10 07:20:05       54 阅读
  5. 【MySQL】之联合索引与最左匹配原则

    2023-12-10 07:20:05       45 阅读
  6. 动态规划01-斐波那契类型一

    2023-12-10 07:20:05       54 阅读