Android红外摇控与remote.conf
這幾天在研究Amlogic的紅外搖控,主要涉及到/system/etc/remote.conf和/system/usr/keylayout/Vendor_0001_Product_0001.kl這兩個文件,其實一般情況下只需要修改/system/etc/remote.conf這個文件就可以了,下面我們來介紹下remote.conf怎么修改.
換搖控之后,你按鍵會出現(xiàn)這樣的打印信息:
[? 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
如果按鍵沒這些,請在終端執(zhí)行remotecfg,如果還是沒有執(zhí)行下dmesg查看下內(nèi)核信息.
我們來看下remote.conf的內(nèi)容:
#********************************************************************************************************* #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 = 0xcekey_begin0x99 1050xc1 1060xca 1030xd2 1080xce 280x92 20x93 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需要進(jìn)行修改,我們按鍵之后的打印信息如下:
[? 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
這是我亂編的,當(dāng)然也有可能不是ff00也有可能是其它的,所以這里我們得到factory_code
factory_code就是0xff000001,前面得到的ff00在高位,低位的0001網(wǎng)上說可以隨便寫,不過這里還是寫成0001
我們依次讀到各個按鍵所打印出的數(shù)據(jù):
[? 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就是對應(yīng)的按鍵信息:
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 = 0xcekey_begin0x99 1050xc1 1060xca 1030xd2 1080xce 280x92 20x93 3 key_end left_key_scancode后面的是一個8位的數(shù)和key_begin下面的以0x開關(guān)的數(shù)都是從
[? 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
這些數(shù)據(jù)里面解析出來的,而key_begin后面的105 106 這些都是對應(yīng)的系統(tǒng)的鍵碼我們先來看下前面的那個0x的數(shù)據(jù)怎么得到,首先以0x2dd2ff00為例,這個在搖控器上是對應(yīng)的方向鍵down
0x2dd2ff00去掉產(chǎn)家代號ff00后剩下的就是2dd2了,remote.conf中的數(shù)值碼就是以0x開關(guān)的那個要么就是0x2d要么就是0xd2,不是高8位就是低8位,這個不同的產(chǎn)家有可能不一樣,像我這個就是低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位是按鍵數(shù)值碼.
下面說下remote.conf后面的105 103這些值,這些都是系統(tǒng)鍵碼,碼值定義一般是在內(nèi)核源碼include/linux/input.h中,然后在/system/usr/keylayout/Vendor_0001_Product_0001.kl中也會出現(xiàn)部分,當(dāng)你要用的按鍵功能這個.kl里沒有的時候你就可以去input.h里找.
我們看下/system/usr/keylayout/Vendor_0001_Product_0001.kl內(nèi)容:
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 CAMERAkey 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 BACKSLASHkey 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 DELkey 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 ENTERkey 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 ENVELOPEkey 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對應(yīng)的系統(tǒng)鍵碼
前面我們說到搖控器down對應(yīng)的編碼是0x2dd2ff00
按鍵數(shù)值碼是0xd2,功能是down,所以在key_begin里就應(yīng)該是:
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 = 0xcekey_begin0x99 1050xc1 1060xca 1030xd2 1080xce 280x92 20x93 3 key_end 網(wǎng)上有一對remote.conf里面這些的詳細(xì)說明,我這里就不作說明,我就說下這些數(shù)據(jù)怎么來的,不知道有沒有說清楚。
總結(jié)
以上是生活随笔為你收集整理的Android红外摇控与remote.conf的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 了解redis队列原理
- 下一篇: android sina oauth2.