T527 Android13遥控适配

T527 Android13遥控的适配和官方提供的文档有些不一样,按照官方的文档不能够正常适配到自己的遥控器。

首先确保驱动是否有打开CONFIG_AW_IR_RX和CONFIG_RC_DECODERS=y
以及CONFIG_IR_NEC_DECODER=m,这个可以在longan/out/t527对应的目录下的.config查看是否存在相关的项。一般默认是打开的,如果没有就到android13_arm64_defconfig配置里面添加。

然后查看驱动是否有加载到系统里面,可以adb下执行lsmod|grep ir查看是否有加载sunxi_ir_rx和ir_nec_decoder,如果没有加载,可以看一下android/device/softwinner下面的对应项目是否有将CONFIG_AW_SUPPORT_IR这个参数设置为false。这个值为false,驱动文件是不会编译到系统里面的。

驱动加载以后,getevent是可以查看到数据上报的,但是这个时候,按键是没有功能的,这个时候一般都会想到根据getvent上报的数值去改映射文件sunxi-ir.kl。但是这个时候改了也是没有用的,这是因为底层没有添加相应的按键值映射。如果底层添加了相应的按键值映射,sunxi-ir.kl可以不用修改,里面大部分的按键都已经映射好了android系统层按键值。

如何添加自己遥控器的按键值呢?首先打开android/longan/bsp/drivers/ir-rx/sunxi-ir-keymap.h,里面的数组static struct rc_map_table sunxi_nec_scan[]就是我们要添加按键映射的地方。先在adb下执行getevent -l /dev/input/event3,这里/dev/input/event3对应的是"sunxi-ir"的节点。然后按遥控器按键,比如我按一下音量加按键。得到如下值:

getevent -l /dev/input/event3
EV_MSC       MSC_SCAN             0000800a
EV_KEY       KEY_VOLUMEUP         DOWN
EV_SYN       SYN_REPORT           00000000
EV_MSC       MSC_SCAN             0000800a
EV_SYN       SYN_REPORT           00000000
EV_MSC       MSC_SCAN             0000800a
EV_SYN       SYN_REPORT           00000000
EV_KEY       KEY_VOLUMEUP         UP
EV_SYN       SYN_REPORT           00000000

找到上面的带MSC_SCAN的那一行,就是上报的数据,这行第三列第2个数字以后的数据(00800a)就是要填写到上面说的sunxi_nec_scan里面的。上面的按键我们需要在数组中添加如下代码:

--- a/longan/bsp/drivers/ir-rx/sunxi-ir-keymap.h
+++ b/longan/bsp/drivers/ir-rx/sunxi-ir-keymap.h
@@ -164,6 +164,40 @@ static struct rc_map_table sunxi_nec_scan[] = {
        { 0xbf63, BTN_MISC },           // unknow
        { 0xbf58, BTN_MISC },           // unknow
        { 0xbf61, KEY_HOME },

+       { 0x00800a, KEY_VOLUMEUP },

KEY_VOLUMEUP对应的是音量加按键,这个已经在sunxi-ir.kl里面映射好了。其他按键按照上面的方法依次填入即可。添加完所有按键以后,重新编译longan生成固件烧录,遥控器就会有作用了。

遥控器有个按键是鼠标模式,系统默认切换的时候是没有提示的,这个很不友好,如果要添加提示,添加下面修改即可:

diff --git a/frameworks/base/core/res/res/values-zh-rCN/strings.xml b/frameworks/base/core/res/res/values-zh-rCN/strings.xml
index 834e980487..e1bc769d84 100644
--- a/frameworks/base/core/res/res/values-zh-rCN/strings.xml
+++ b/frameworks/base/core/res/res/values-zh-rCN/strings.xml
@@ -2297,4 +2297,6 @@
     "无法从%1$s上访问平板电脑的摄像头"
     "流式传输时无法访问此内容。您可以尝试在手机上访问。"
     "系统默认设置"
+	进入鼠标模式,再按一次退出鼠标模式!
+	进入遥控模式!
 
diff --git a/frameworks/base/core/res/res/values-zh-rHK/strings.xml b/frameworks/base/core/res/res/values-zh-rHK/strings.xml
index cc4d15e339..86575ba0c3 100644
--- a/frameworks/base/core/res/res/values-zh-rHK/strings.xml
+++ b/frameworks/base/core/res/res/values-zh-rHK/strings.xml
@@ -2295,4 +2295,6 @@
     "無法從 %1$s 存取平板電腦的相機"
     "串流播放時無法使用,請改用手機。"
     "系統預設"
+	進入滑鼠模式,再按一次退出滑鼠模式!
+	 進入遙控模式!
 
diff --git a/frameworks/base/core/res/res/values-zh-rTW/strings.xml b/frameworks/base/core/res/res/values-zh-rTW/strings.xml
index 810ddc684b..443949e25b 100644
--- a/frameworks/base/core/res/res/values-zh-rTW/strings.xml
+++ b/frameworks/base/core/res/res/values-zh-rTW/strings.xml
@@ -2295,4 +2295,6 @@
     "無法從 %1$s 存取平板電腦的相機"
     "串流播放時無法存取這項內容,請改用手機。"
     "系統預設"
+	進入滑鼠模式,再按一次退出滑鼠模式!
+	 進入遙控模式!
 
diff --git a/frameworks/base/core/res/res/values/strings.xml b/frameworks/base/core/res/res/values/strings.xml
index fefa2c1454..c0d5893d06 100644
--- a/frameworks/base/core/res/res/values/strings.xml
+++ b/frameworks/base/core/res/res/values/strings.xml
@@ -6348,4 +6348,6 @@ ul.
 
     
     System default
+	Enter into mouse mode, click again to quit
+	Restore to default button mode
 
diff --git a/frameworks/base/core/res/res/values/symbols.xml b/frameworks/base/core/res/res/values/symbols.xml
index b58229ee19..dce38094a3 100644
--- a/frameworks/base/core/res/res/values/symbols.xml
+++ b/frameworks/base/core/res/res/values/symbols.xml
@@ -4915,4 +4915,6 @@
   
 
   
+  
+  
 
diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/MouseModeReceiver.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/MouseModeReceiver.java
new file mode 100755
index 0000000000..71d59a61cc
--- /dev/null
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/MouseModeReceiver.java
@@ -0,0 +1,25 @@
+package com.android.systemui;
+
+import java.util.*;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+import android.text.TextUtils;
+ import android.widget.Toast;
+ 
+public class MouseModeReceiver extends BroadcastReceiver
+{
+	static String TAG = "MouseModeReceiver";
+
+	@Override
+	public void onReceive(Context context, Intent intent) {
+		if (intent.getAction().equals("com.android.set_ir_mousemode")) {
+			Toast.makeText(context, com.android.internal.R.string.enter_mouse_mode, Toast.LENGTH_LONG).show();
+		}else if(intent.getAction().equals("com.android.set_ir_normalmode")){
+			Toast.makeText(context, com.android.internal.R.string.exit_mouse_mode, Toast.LENGTH_LONG).show();
+		}
+	}
+}
+
diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java
index 6fe176a3cf..f824cc607b 100644
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java
@@ -161,7 +161,11 @@ public class SystemUIApplication extends Application implements
         // application theme in the manifest does only work for activities. Keep this in sync with
         // the theme set there.
         setTheme(R.style.Theme_SystemUI);
-
+		
+		IntentFilter irfilter = new IntentFilter("com.android.set_ir_mousemode");
+		irfilter.addAction("com.android.set_ir_normalmode");
+		registerReceiver(new MouseModeReceiver(),irfilter);
+		
         if (Process.myUserHandle().equals(UserHandle.SYSTEM)) {
             IntentFilter bootCompletedFilter = new
                     IntentFilter(Intent.ACTION_LOCKED_BOOT_COMPLETED);
diff --git a/frameworks/base/services/core/java/com/android/server/policy/TvWindowManager.java b/frameworks/base/services/core/java/com/android/server/policy/TvWindowManager.java
index 25e714c5c0..b87d28fe27 100644
--- a/frameworks/base/services/core/java/com/android/server/policy/TvWindowManager.java
+++ b/frameworks/base/services/core/java/com/android/server/policy/TvWindowManager.java
@@ -239,9 +239,11 @@ public class TvWindowManager extends PhoneWindowManager {
                 if (mKeyEnterMouseMode) {
                     MouseMode.exitMouseMode();
                     mKeyEnterMouseMode = false;
+					mContext.sendBroadcast(new Intent("com.android.set_ir_normalmode"));
                 } else {
                     MouseMode.enterMouseMode();
                     mKeyEnterMouseMode = true;
+					mContext.sendBroadcast(new Intent("com.android.set_ir_mousemode"));
                 }
             }
             return -1;

你可能感兴趣的:(T527,Android13系统开发,android,T527,遥控器)