这几天在研究Amlogic的红外摇控,主要涉及到/system/etc/remote.conf和/system/usr/keylayout/Vendor_0001_Product_0001.kl这两个文件,其实一般情况下只需要修改/system/etc/remote.conf这个文件就可以了,下面我们来介绍下remote.conf怎么修改.
换摇控之后,你按键会出现这样的打印信息:
[ 727.416139@0] Wrong custom code is 0x2dd2ff00
[ 727.868522@0] Wrong custom code is 0x6699ff00
[ 728.217197@0] Wrong custom code is 0x3ec1ff00
[ 728.626735@0] Wrong custom code is 0x2dd2ff00
[ 728.929900@0] Wrong custom code is 0x6699ff00
[ 729.239544@0] Wrong custom code is 0x3ec1ff00
如果按键没这些,请在终端执行remotecfg,如果还是没有执行下dmesg查看下内核信息.
我们来看下remote.conf的内容:
#*********************************************************************************************************
#this file is configuration for each factory remote device
# work_mode 0 :software mode 1 :hardware mode
# repeat_enable 0 :disable repeat 1 :enable repeat
#
# factory_code each device has it's unique factory code.
# pattern:custom_code(16bit)+index_code(16bit)
# examble: 0xff000001 = 0xff00(custom cod) 0001 (index)
#
# release_delay unit:ms.release will report from kernel to user layer after this period of time
# from press or repeat triggered.
#
# debug_enable 0 :debug disable 1 :debug disable
#
# SW MODE:
# bit_count how many bits in each frame
# tw_leader_act time window for leader active
# tw_bit0 time window for bit0 time.
# tw_bit1 time window for bit1 time
# tw_repeat_leader time window for repeat leader
# REG
# reg_base_gen set value for PREG_IR_DEC_BASE_GEN
# reg_control set value for PREG_IR_DEC_CONTROL
# reg_leader_act set value for PREG_IR_DEC_LEADER_ACTIVE
# reg_leader_idle set value for PREG_IR_DEC_LEADER_IDLE
# reg_repeat_leader set value for PREG_IR_DEC_REPEAT_IDLE
# reg_bit0_time set value for PREG_IR_DEC_BIT0_TIME
#*************************************************************************************************************
#amlogic NEC remote
factory_code = 0xff000001
work_mode = 1
repeat_enable = 1
release_delay = 150
debug_enable = 1
reg_control = 0xfbe40
#left 0x6699ff00
left_key_scancode = 0x99
right_key_scancode = 0xc1
up_key_scancode = 0xca
down_key_scancode = 0xd2
ok_key_scancode = 0xce
key_begin
0x99 105
0xc1 106
0xca 103
0xd2 108
0xce 28
0x92 2
0x93 3
key_end
这个是我修改之后的,首先看下这部分:
#amlogic NEC remote
factory_code = 0xff000001
work_mode = 1
repeat_enable = 1
release_delay = 150
debug_enable = 1
reg_control = 0xfbe40
这里只有factory_code需要进行修改,我们按键之后的打印信息如下:
[ 727.416139@0] Wrong custom code is 0x2dd2ff00
[ 727.868522@0] Wrong custom code is 0x6699ff00
[ 728.217197@0] Wrong custom code is 0x3ec1ff00
[ 728.626735@0] Wrong custom code is 0x2dd2ff00
[ 728.929900@0] Wrong custom code is 0x6699ff00
[ 729.239544@0] Wrong custom code is 0x3ec1ff00
可以看到后16位是不变的都是ff00,有的可能是在高16位例如:
[ 728.929900@0] Wrong custom code is 0xff002dd2
[ 729.239544@0] Wrong custom code is 0xff003ec1
这是我乱编的,当然也有可能不是ff00也有可能是其它的,所以这里我们得到factory_code
factory_code就是0xff000001,前面得到的ff00在高位,低位的0001网上说可以随便写,不过这里还是写成0001
我们依次读到各个按键所打印出的数据:
[ 727.416139@0] Wrong custom code is 0x2dd2ff00
[ 727.868522@0] Wrong custom code is 0x6699ff00
[ 728.217197@0] Wrong custom code is 0x3ec1ff00
[ 728.626735@0] Wrong custom code is 0x2dd2ff00
[ 728.929900@0] Wrong custom code is 0x6699ff00
[ 729.239544@0] Wrong custom code is 0x3ec1ff00
这些code就是对应的按键信息:
up: 0x35caff00
down:0x2dd2ff00
left:0x6699ff00
right:0x3ec1ff00
这里我就只说这几个了,其它的按键方法都是一样.
我们看到remote.conf剩下的部分:
left_key_scancode = 0x99
right_key_scancode = 0xc1
up_key_scancode = 0xca
down_key_scancode = 0xd2
ok_key_scancode = 0xce
key_begin
0x99 105
0xc1 106
0xca 103
0xd2 108
0xce 28
0x92 2
0x93 3
key_end
left_key_scancode后面的是一个8位的数和key_begin下面的以0x开关的数都是从
[ 727.416139@0] Wrong custom code is 0x2dd2ff00
[ 727.868522@0] Wrong custom code is 0x6699ff00
[ 728.217197@0] Wrong custom code is 0x3ec1ff00
[ 728.626735@0] Wrong custom code is 0x2dd2ff00
[ 728.929900@0] Wrong custom code is 0x6699ff00
[ 729.239544@0] Wrong custom code is 0x3ec1ff00
这些数据里面解析出来的,而key_begin后面的105 106 这些都是对应的系统的键码我们先来看下前面的那个0x的数据怎么得到,首先以0x2dd2ff00为例,这个在摇控器上是对应的方向键down
0x2dd2ff00去掉产家代号ff00后剩下的就是2dd2了,remote.conf中的数值码就是以0x开关的那个要么就是0x2d要么就是0xd2,不是高8位就是低8位,这个不同的产家有可能不一样,像我这个就是低8位0xd2,这个我是试了之后才知道的。
不过也可以不用试就可以得出,首先得记录摇控器各个按键的编码,然后修改remote.conf的factory_code后,重启盒子,然后你在按键的时候就会出来这样的信息:
[ 145.727698@0] scancode is 0x008a, invalid key is 0x0000.
[ 145.868198@0] scancode is 0x008a, invalid key is 0x0000.
[ 166.160143@0] scancode is 0x008b, invalid key is 0x0000.
[ 166.308242@0] scancode is 0x008b, invalid key is 0x0000.
这个0x008a,8a是低8位,所以可以确定低8位是按键数值码.
下面说下remote.conf后面的105 103这些值,这些都是系统键码,码值定义一般是在内核源码include/linux/input.h中,然后在/system/usr/keylayout/Vendor_0001_Product_0001.kl中也会出现部分,当你要用的按键功能这个.kl里没有的时候你就可以去input.h里找.
我们看下/system/usr/keylayout/Vendor_0001_Product_0001.kl内容:
key 399 GRAVE
key 1 BACK
key 2 1
key 3 2
key 4 3
key 5 4
key 6 5
key 7 6
key 8 7
key 9 8
key 10 9
key 11 0
key 15 BACK
key 158 BACK
key 58 SOFT_RIGHT
key 107 ENDCALL
key 62 ENDCALL
key 139 MENU
key 125 MENU
key 60 NOTIFICATION
key 127 SEARCH
key 217 SEARCH
key 228 POUND
key 227 STAR
key 231 CALL
key 61 CALL
key 97 DPAD_CENTER
key 232 DPAD_CENTER
key 108 DPAD_DOWN
key 103 DPAD_UP
key 102 HOME
key 105 DPAD_LEFT
key 106 DPAD_RIGHT
key 115 VOLUME_UP
key 114 VOLUME_DOWN
key 104 VOLUME_UP
key 109 VOLUME_DOWN
key 212 CAMERA
key 16 Q
key 17 W
key 18 E
key 19 R
key 20 T
key 21 Y
key 22 U
key 23 I
key 24 O
key 25 P
key 26 LEFT_BRACKET
key 27 RIGHT_BRACKET
key 43 BACKSLASH
key 30 A
key 31 S
key 32 D
key 33 F
key 34 G
key 35 H
key 36 J
key 37 K
key 38 L
key 39 SEMICOLON
key 40 APOSTROPHE
key 14 DEL
key 44 Z
key 45 X
key 46 C
key 47 V
key 48 B
key 49 N
key 50 M
key 51 COMMA
key 52 PERIOD
key 53 SLASH
key 28 ENTER
key 56 ALT_LEFT
key 100 ALT_RIGHT
key 42 SHIFT_LEFT
key 54 SHIFT_RIGHT
#key 15 TAB
key 57 SPACE
key 70 EXPLORER
key 155 ENVELOPE
key 12 MINUS
key 13 EQUALS
key 215 AT
key 119 MEDIA_PLAY_PAUSE
key 122 MEDIA_PREVIOUS
key 123 MEDIA_NEXT
key 120 MEDIA_FAST_FORWARD
key 121 MEDIA_REWIND
key 116 POWER WAKE
key 113 VOLUME_MUTE
key 128 MEDIA_STOP
key 130 ZOOM_IN
key 131 ZOOM_OUT
key 133 TAB
key 140 F10
里面有一个:
key 108 DPAD_DOWN
这个108就是down对应的系统键码
前面我们说到摇控器down对应的编码是0x2dd2ff00
按键数值码是0xd2,功能是down,所以在key_begin里就应该是:
0xd2 108
我的摇控器部分编码:
up:0x35caff00
down:0x2dd2ff00
left:0x6699ff00
right:0x3ec1ff00
1:0x6d92ff00
2:0x6c93ff00
所以最后的remote.conf为:
#*********************************************************************************************************
#this file is configuration for each factory remote device
# work_mode 0 :software mode 1 :hardware mode
# repeat_enable 0 :disable repeat 1 :enable repeat
#
# factory_code each device has it's unique factory code.
# pattern:custom_code(16bit)+index_code(16bit)
# examble: 0xff000001 = 0xff00(custom cod) 0001 (index)
#
# release_delay unit:ms.release will report from kernel to user layer after this period of time
# from press or repeat triggered.
#
# debug_enable 0 :debug disable 1 :debug disable
#
# SW MODE:
# bit_count how many bits in each frame
# tw_leader_act time window for leader active
# tw_bit0 time window for bit0 time.
# tw_bit1 time window for bit1 time
# tw_repeat_leader time window for repeat leader
# REG
# reg_base_gen set value for PREG_IR_DEC_BASE_GEN
# reg_control set value for PREG_IR_DEC_CONTROL
# reg_leader_act set value for PREG_IR_DEC_LEADER_ACTIVE
# reg_leader_idle set value for PREG_IR_DEC_LEADER_IDLE
# reg_repeat_leader set value for PREG_IR_DEC_REPEAT_IDLE
# reg_bit0_time set value for PREG_IR_DEC_BIT0_TIME
#*************************************************************************************************************
#amlogic NEC remote
factory_code = 0xff000001
work_mode = 1
repeat_enable = 1
release_delay = 150
debug_enable = 1
reg_control = 0xfbe40
#left 0x6699ff00
left_key_scancode = 0x99
right_key_scancode = 0xc1
up_key_scancode = 0xca
down_key_scancode = 0xd2
ok_key_scancode = 0xce
key_begin
0x99 105
0xc1 106
0xca 103
0xd2 108
0xce 28
0x92 2
0x93 3
key_end
网上有一对remote.conf里面这些的详细说明,我这里就不作说明,我就说下这些数据怎么来的,不知道有没有说清楚。