转载请注明出处:https://www.cnblogs.com/lialong1st/p/10071557.html

CPU:RK3288

系统:Android 5.1

1、在 dts 中增加红外遥控器键值(点播按键),注意文件中加载的 input.h 头文件路径。

#include <dt-bindings/input/input.h>

diff --git a/kernel/arch/arm/boot/dts/rk3288-tb_8846.dts b/kernel/arch/arm/boot/dts/rk3288-tb_8846.dts
index ba9b8f7..0f1a5a4
--- a/kernel/arch/arm/boot/dts/rk3288-tb_8846.dts
+++ b/kernel/arch/arm/boot/dts/rk3288-tb_8846.dts
@@ -, +, @@ clock-frequency = <>;
<0xeb KEY_DOT>, // .
<0xe3 KEY_DELETE>, // Del
+ <0xec KEY_VOD>, // Vod
<0xa6 KEY_PAUSE>, // Pause
<0xaa KEY_PLAY>; // Play

2、在内核头文件 input.h 中增加按键定义,不能重复,input.h 路径要与第一步 dts 文件中头文件加载的一致。

diff --git a/kernel/include/dt-bindings/input/input.h b/kernel/include/dt-bindings/input/input.h
index 2b1990d..b49dc4d
--- a/kernel/include/dt-bindings/input/input.h
+++ b/kernel/include/dt-bindings/input/input.h
@@ -, +, @@
#define BTN_TRIGGER_HAPPY39 0x2e6
#define BTN_TRIGGER_HAPPY40 0x2e7 +#define KEY_VOD 0x2f0
+
/* We avoid low common keys in module aliases so they don't get huge. */
#define KEY_MIN_INTERESTING KEY_MUTE
#define KEY_MAX 0x2ff

3、增加键值与上层对应的关系。

diff --git a/device/rockchip/common/ff680000_pwm.kl b/device/rockchip/common/ff680000_pwm.kl
index fb4cae7..eed2df8
--- a/device/rockchip/common/ff680000_pwm.kl
+++ b/device/rockchip/common/ff680000_pwm.kl
@@ -, +, @@ key DEL
key MEDIA_PAUSE
key MEDIA_PLAY +key VOD
+
#key TV_MEDIA_MULT_BACKWARD
#key TV_MEDIA_MULT_FORWARD
#key TV_MEDIA_PLAY_PAUSE

4、在 KeyEvent.java 中定义按键上层的键值,定义按键值后面有提示,新按键需要更新哪些地方。

    public static final int KEYCODE_VOD = 275;
private static final int LAST_KEYCODE = KEYCODE_VOD; // NOTE: If you add a new keycode here you must also add it to:
// isSystem()
// isWakeKey()
// frameworks/native/include/android/keycodes.h
// frameworks/native/include/input/InputEventLabels.h
// frameworks/base/core/res/res/values/attrs.xml
// emulator?
// LAST_KEYCODE

在当前文件中定义键值,修改最后面的键值、isSystem 和 isWakeKey 两个方法。

diff --git a/frameworks/base/core/java/android/view/KeyEvent.java b/frameworks/base/core/java/android/view/KeyEvent.java
index bcf9a46..45f6ffb 100755
--- a/frameworks/base/core/java/android/view/KeyEvent.java
+++ b/frameworks/base/core/java/android/view/KeyEvent.java
@@ -773,7 +773,9 @@ public class KeyEvent extends InputEvent implements Parcelable {
public static final int KEYCODE_TV_MEDIA_PAUSE = 274;
//$_rbox_$_modify_$ end - private static final int LAST_KEYCODE = KEYCODE_TV_MEDIA_PAUSE;
+ public static final int KEYCODE_VOD = 275;
+
+ private static final int LAST_KEYCODE = KEYCODE_VOD; // NOTE: If you add a new keycode here you must also add it to:
// isSystem()
@@ -1818,6 +1820,7 @@ public class KeyEvent extends InputEvent implements Parcelable {
case KeyEvent.KEYCODE_BRIGHTNESS_DOWN:
case KeyEvent.KEYCODE_BRIGHTNESS_UP:
case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK:
+ case KeyEvent.KEYCODE_VOD:
return true;
} @@ -1833,6 +1836,7 @@ public class KeyEvent extends InputEvent implements Parcelable {
case KeyEvent.KEYCODE_WAKEUP:
case KeyEvent.KEYCODE_PAIRING:
case KeyEvent.KEYCODE_NOTIFICATION:
+ case KeyEvent.KEYCODE_VOD:
return true;
}

5、在 keycodes.h 文件中定义键值

diff --git a/frameworks/native/include/android/keycodes.h b/frameworks/native/include/android/keycodes.h
index ff998df..212fef6 100755
--- a/frameworks/native/include/android/keycodes.h
+++ b/frameworks/native/include/android/keycodes.h
@@ -307,6 +307,7 @@ enum {
AKEYCODE_TV_KEYMOUSE_UP = 262,
AKEYCODE_TV_KEYMOUSE_DOWN = 263,
AKEYCODE_TV_KEYMOUSE_MODE_SWITCH = 264,
+ AKEYCODE_VOD = 275,
AKEYCODE_HELP = 259 // NOTE: If you add a new keycode here you must also add it to several other files.

6、在 InputEventLabels.h 中添加按键标签

diff --git a/frameworks/native/include/input/InputEventLabels.h b/frameworks/native/include/input/InputEventLabels.h
index d7a06dd..4359e3f
--- a/frameworks/native/include/input/InputEventLabels.h
+++ b/frameworks/native/include/input/InputEventLabels.h
@@ -, +, @@ static const InputEventLabel KEYCODES[] = {
DEFINE_KEYCODE(TV_KEYMOUSE_DOWN),
DEFINE_KEYCODE(TV_KEYMOUSE_MODE_SWITCH),
DEFINE_KEYCODE(HELP),
+ DEFINE_KEYCODE(VOD), { NULL, }
};

7、在 attrs.xml 中增加按键

diff --git a/frameworks/base/core/res/res/values/attrs.xml b/frameworks/base/core/res/res/values/attrs.xml
index 75157be..e591fce 100755
--- a/frameworks/base/core/res/res/values/attrs.xml
+++ b/frameworks/base/core/res/res/values/attrs.xml
@@ -1791,6 +1791,7 @@
<enum name="KEYCODE_TV_MEDIA_MULT_BACKWARD" value="272" />
<enum name="KEYCODE_TV_MEDIA_PLAY" value="273" />
<enum name="KEYCODE_TV_MEDIA_PAUSE" value="274" />
+ <enum name="KEYCODE_VOD" value="275" />
<!--$_rbox_$_modify_$_end-->
</attr>

8、此时按键已经添加完毕,但是编译会报错如下,需要更新 api 文件,先执行指令 make update-api,再编译。

******************************
You have tried to change the API from what has been previously approved. To make these errors go away, you have two choices:
) You can add "@hide" javadoc comments to the methods, etc. listed in the
errors above. ) You can update current.txt by executing the following command:
make update-api To submit the revised current.txt to the main Android repository,
you will need approval.
******************************

9、编译成功后,上层就可以接收到此键值,也可以通过 getevent 查看,但是看到的只是键值(02f0),没有解析到实际含义。

$ adb shell
root@rk3288:/ # getevent -rtl /dev/input/event0
getevent -rtl /dev/input/event0
[ 43.142191] EV_KEY 02f0 DOWN
[ 43.142191] EV_SYN SYN_REPORT
[ 43.220034] EV_KEY 02f0 UP
[ 43.220034] EV_SYN SYN_REPORT rate

10、在 getevent.h 中添加此按键标签

diff --git a/system/core/toolbox/getevent.h b/system/core/toolbox/getevent.h
index 0482d04..785d4f4
--- a/system/core/toolbox/getevent.h
+++ b/system/core/toolbox/getevent.h
@@ -, +, @@ static struct label key_labels[] = {
LABEL(BTN_TRIGGER_HAPPY38),
LABEL(BTN_TRIGGER_HAPPY39),
LABEL(BTN_TRIGGER_HAPPY40),
+ LABEL(KEY_VOD),
LABEL_END,
};

11、上一步添加标签后编译会报错,提示找不到 KEY_VOD,则需要在头文件中定义。

diff --git a/bionic/libc/kernel/uapi/linux/input.h b/bionic/libc/kernel/uapi/linux/input.h
index b9d5b2a..d7c99c3
--- a/bionic/libc/kernel/uapi/linux/input.h
+++ b/bionic/libc/kernel/uapi/linux/input.h
@@ -, +, @@ struct input_keymap_entry {
#define BTN_TRIGGER_HAPPY39 0x2e6
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define BTN_TRIGGER_HAPPY40 0x2e7
+#define KEY_VOD 0x2f0
#define KEY_MIN_INTERESTING KEY_MUTE
#define KEY_MAX 0x2ff
#define KEY_CNT (KEY_MAX+1)

此时,自定义按键添加大功告成,上层app可以接收到按键值,getevent 中也能解析此按键。

$ adb shell
root@rk3288:/ # getevent -rtl /dev/input/event0
getevent -rtl /dev/input/event0
[ 138.898690] EV_KEY KEY_VOD DOWN
[ 138.898690] EV_SYN SYN_REPORT
[ 138.980104] EV_KEY KEY_VOD UP
[ 138.980104] EV_SYN SYN_REPORT rate

RK3288 红外遥控器增加系统中已有的键值

RK3288 红外遥控器增加自定义按键的更多相关文章

  1. RK3288 红外遥控器增加系统中已有的键值

    转载请注明出处:https://www.cnblogs.com/lialong1st/p/10066673.html CPU:RK3288 系统:Android 5.1 1.查看遥控器的用户码和键值, ...

  2. stm32与红外遥控器(NEC协议)

    1.器件简介 本次测试采用R903V1红外接收头与NEC协议的红外遥控器,接收头原理图如下: 器件的供电电压VCC在2.7V~5.5V之间,输出电压VOUT正常在0.2v ~(VCC-0.3±0.2) ...

  3. arduino 红外遥控器控制LED灯

    /* 日期:2016.9.1 功能:红外遥控器控制LED灯 开,关,闪烁,呼吸 元件: 跳线公公头 * 5 led 220欧电阻 红外接收管,红外遥控 接线: 红外灯面向自己从左到右分别接 IO3 , ...

  4. DIY手机万能红外遥控器

    DIY手机万能红外遥控器 1.手机安装软件:遥控精灵 2.红外二极管两个(旧的遥控器里面可以拆) 3.耳机的插头一个 步骤:首选讲两个二极管的正负相接(即a二极管的正极连接b二极管的负极,a二极管的负 ...

  5. 手把手教你DIY尼康ML-L3红外遥控器

    项目介绍 ML-L3是用于尼康部分型号相机的无线红外遥控器,可以通过红外方式来控制快门的释放,支持B门拍摄.官方售价100RMB左右,山寨版售价10RMB左右.虽然也能实现基本的遥控功能,但是功能还是 ...

  6. iOS数字键盘自定义按键

    UIKeyboardTypeNumberPad 数字键盘自定义按键 最近做一个搜索用户的功能,这里使用了UISearchBar.由于搜索的方式只有手机号码,所以这里的键盘要限制为数字输入,可以这么做: ...

  7. Android给自定义按键添加广播和通过广播给当前焦点输入框赋值

    一.给自定义按键添加广播 修改PhoneWindowManager.java中的interceptKeyBeforeDispatching方法 /frameworks/base/policy/src/ ...

  8. [转]通过继承ConfigurationSection,在web.config中增加自定义配置

    本文转自:http://www.blue1000.com/bkhtml/2008-02/55810.htm 前几天写了一篇使用IConfigurationSectionHandler在web.conf ...

  9. MTK 自定义按键添加广播

    一.给自定义按键添加广播 修改PhoneWindowManager.java中的interceptKeyBeforeDispatching方法 /frameworks/base/policy/src/ ...

随机推荐

  1. bzoj1602 / P2912 [USACO08OCT]牧场散步Pasture Walking(倍增lca)

    P2912 [USACO08OCT]牧场散步Pasture Walking 求树上两点间路径--->lca 使用倍增处理lca(树剖多长鸭) #include<iostream> # ...

  2. Git提交撤销

    场景:本地修改代码后,执行commit提交,但此时想撤销该提交. 执行命令: git reflog   查看所有commit历史 git reset --hard commitid     将当前远程 ...

  3. Linux服务器使用tar加密压缩文件

    使用tar命令进行加密压缩时需要和OpenSSL进行结合 加密压缩命令如下: tar -zcf - filename |openssl des3 -salt -k passwd | dd of=fil ...

  4. 《Effective Java 2nd》第8章 通用程序设计

    目录 第45条 将局部变量的作用域最小化 第46条 for-each循环优先于传统的for循环 第47条 了解和使用类库 第48条 如果需要精确的答案,避免使用float和double 第49条 基本 ...

  5. 初始化 Flask 虚拟环境 命令

    参考:<Flask Web开发> 系统:Mac OSX CMD // 激活环境 virtualenv venv source venv/bin/activate // 安装flask pi ...

  6. 【异常记录(六)】vs文件乱码:文件加载,使用Unicode(UTF-8)编码加载文件xxx时,有些字节已用Unicode替换字符替换。保存该文件将不会保留原始文件内容。

    VS2013偶遇这种情况,页面汉字编码出现乱码.  .... 按照网上查到的:   工具>选项>文本编辑器> 勾选了  然并卵,还是乱码... 其实炒鸡简单 用记事本打开另存为,选择 ...

  7. LightOJ 1038 Race to 1 Again(概率dp+期望)

    https://vjudge.net/problem/LightOJ-1038 题意:给出一个数n,每次选择n的一个约数m,n=n/m,直到n=1,求次数的期望. 思路:d[i]表示将i这个数变成1的 ...

  8. php while循环

    <html> <body> <?php $i=; ) { echo "The number is " . $i . "<br>& ...

  9. package 'orocos-bfl' not found

    -- ==> add_subdirectory(bp_fusion) -- checking for module 'orocos-bfl' -- package 'orocos-bfl' no ...

  10. css可应用的渐进增强新特性

    1. 让有滚动行为的元素平滑滚动  scroll-behavior: smooth; <div class="smooth"> </dvi> .smooth ...