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"的节点。然后按遥控器按键,比如我按一下音量加按键。得到如下值:

bash 复制代码
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里面的。上面的按键我们需要在数组中添加如下代码:

diff 复制代码
--- 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 复制代码
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 @@
     <string name="vdm_camera_access_denied" product="tablet" msgid="6895968310395249076">"无法从<xliff:g id="DEVICE">%1$s</xliff:g>上访问平板电脑的摄像头"</string>
     <string name="vdm_secure_window" msgid="161700398158812314">"流式传输时无法访问此内容。您可以尝试在手机上访问。"</string>
     <string name="system_locale_title" msgid="711882686834677268">"系统默认设置"</string>
+	<string name="enter_mouse_mode">进入鼠标模式,再按一次退出鼠标模式!</string>
+	<string name="exit_mouse_mode">进入遥控模式!</string>
 </resources>
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 @@
     <string name="vdm_camera_access_denied" product="tablet" msgid="6895968310395249076">"無法從 <xliff:g id="DEVICE">%1$s</xliff:g> 存取平板電腦的相機"</string>
     <string name="vdm_secure_window" msgid="161700398158812314">"串流播放時無法使用,請改用手機。"</string>
     <string name="system_locale_title" msgid="711882686834677268">"系統預設"</string>
+	<string name="enter_mouse_mode">進入滑鼠模式,再按一次退出滑鼠模式!</string>
+	 <string name="exit_mouse_mode">進入遙控模式!</string>
 </resources>
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 @@
     <string name="vdm_camera_access_denied" product="tablet" msgid="6895968310395249076">"無法從 <xliff:g id="DEVICE">%1$s</xliff:g> 存取平板電腦的相機"</string>
     <string name="vdm_secure_window" msgid="161700398158812314">"串流播放時無法存取這項內容,請改用手機。"</string>
     <string name="system_locale_title" msgid="711882686834677268">"系統預設"</string>
+	<string name="enter_mouse_mode">進入滑鼠模式,再按一次退出滑鼠模式!</string>
+	 <string name="exit_mouse_mode">進入遙控模式!</string>
 </resources>
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.</string>
 
     <!-- Title for preference of the system default locale. [CHAR LIMIT=50]-->
     <string name="system_locale_title">System default</string>
+	<string name="enter_mouse_mode">Enter into mouse mode, click again to quit</string>
+	<string name="exit_mouse_mode">Restore to default button mode</string>
 </resources>
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 @@
   <!-- /// AW: add end. -->
 
   <java-symbol type="bool" name="config_global_action_screenshot_enabled" />
+  <java-symbol type="string" name="enter_mouse_mode" />
+  <java-symbol type="string" name="exit_mouse_mode" />
 </resources>
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;
相关推荐
长亭外的少年1 小时前
Kotlin 编译失败问题及解决方案:从守护进程到 Gradle 配置
android·开发语言·kotlin
建群新人小猿3 小时前
会员等级经验问题
android·开发语言·前端·javascript·php
1024小神4 小时前
tauri2.0版本开发苹果ios和安卓android应用,环境搭建和最后编译为apk
android·ios·tauri
兰琛5 小时前
20241121 android中树结构列表(使用recyclerView实现)
android·gitee
Y多了个想法5 小时前
RK3568 android11 适配敦泰触摸屏 FocalTech-ft5526
android·rk3568·触摸屏·tp·敦泰·focaltech·ft5526
NotesChapter6 小时前
Android吸顶效果,并有着ViewPager左右切换
android
_祝你今天愉快7 小时前
分析android :The binary version of its metadata is 1.8.0, expected version is 1.5.
android
暮志未晚Webgl8 小时前
109. UE5 GAS RPG 实现检查点的存档功能
android·java·ue5
麦田里的守望者江8 小时前
KMP 中的 expect 和 actual 声明
android·ios·kotlin
Dnelic-8 小时前
解决 Android 单元测试 No tests found for given includes:
android·junit·单元测试·问题记录·自学笔记