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点或者更多。

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

相关推荐
fie88892 小时前
MySQL:Prepared Statement 预处理语句
android·数据库·mysql
wu_android2 小时前
android 网络视图 手机相册
android·智能手机
VirusVIP2 小时前
解决:Android studio 编译后报错\app\src\main\cpp\CMakeLists.txt‘ to exist
android·ide·android studio
androidwork4 小时前
嵌套滚动交互处理总结
android·java·kotlin
fatiaozhang95275 小时前
中兴B860AV1.1强力降级固件包
android·adb·电视盒子·av1·机顶盒rom·魔百盒刷机
橙子199110167 小时前
Kotlin 中的 Object
android·开发语言·kotlin
AD钙奶-lalala11 小时前
android:foregroundServiceType详解
android
大胃粥14 小时前
Android V app 冷启动(13) 焦点窗口更新
android
fatiaozhang952718 小时前
中兴B860AV1.1_晨星MSO9280芯片_4G和8G闪存_TTL-BIN包刷机固件包
android·linux·adb·电视盒子·av1·魔百盒刷机
fatiaozhang952719 小时前
中兴B860AV1.1_MSO9280_降级后开ADB-免刷机破解教程(非刷机)
android·adb·电视盒子·av1·魔百盒刷机·移动魔百盒·魔百盒固件