android BT 遥控器配置

所有遥控器的配置文件都是基于 google 的 Generic.kl (frameworks\base\data\keyboards)做的
修改,BT 也不例外。BT 的配置按照如下步骤(所有下面的配置都已 HOME 键为例,其他
的类似):
1,获取 vendor id 和 product id
系统起来敲入:dumpsys input

dumpsys  input                                    
INPUT MANAGER (dumpsys input)

Event Hub State:
  BuiltInKeyboardId: -2
  Devices:
    -1: Virtual
      Classes: 0x40000023
      Path: <virtual>
      Descriptor: a718a782d34bc767f4689c232d64d527998ea7fd
      Location: 
      ControllerNumber: 0
      UniqueId: <virtual>
      Identifier: bus=0x0000, vendor=0x0000, product=0x0000, version=0x0000
      KeyLayoutFile: /system/usr/keylayout/Generic.kl
      KeyCharacterMapFile: /system/usr/keychars/Virtual.kcm
      ConfigurationFile: 
      HaveKeyboardLayoutOverlay: false
    1: mtk-kpd
      Classes: 0x00000001
      Path: /dev/input/event2
      Descriptor: f0d2e427e7a05eb6d316f5e14800c5ac7b6aee79
      Location: 
      ControllerNumber: 0
      UniqueId: 
      Identifier: bus=0x0019, vendor=0x2454, product=0x6500, version=0x0010
      KeyLayoutFile: /system/usr/keylayout/mtk-kpd.kl
      KeyCharacterMapFile: /system/usr/keychars/Generic.kcm
      ConfigurationFile: 
      HaveKeyboardLayoutOverlay: false
    2: ACCDET
      Classes: 0x00000001
      Path: /dev/input/event3
      Descriptor: 1c78f7e0d16d4dbc8d3ab93943523f379203f90b
      Location: 
      ControllerNumber: 0
      UniqueId: 
      Identifier: bus=0x0019, vendor=0x0000, product=0x0000, version=0x0000
      KeyLayoutFile: /system/usr/keylayout/ACCDET.kl
      KeyCharacterMapFile: /system/usr/keychars/Generic.kcm
      ConfigurationFile: 
      HaveKeyboardLayoutOverlay: false
    3: NEC_Remote_Controller_Mouse
      Classes: 0x00000008
      Path: /dev/input/event1
      Descriptor: 9208b38663027d7d72cdff95baf104571adb6880
      Location: 
      ControllerNumber: 0
      UniqueId: 
      Identifier: bus=0x0019, vendor=0x000c, product=0x000c, version=0x000c
      KeyLayoutFile: 
      KeyCharacterMapFile: 
      ConfigurationFile: 
      HaveKeyboardLayoutOverlay: false
    4: NEC_Remote_Controller
      Classes: 0x00000001
      Path: /dev/input/event0
      Descriptor: d1344eb5e730be322c5338ae3961c67f6c68dc52
      Location: 
      ControllerNumber: 0
      UniqueId: 
      Identifier: bus=0x0019, vendor=0x000b, product=0x000b, version=0x000b
      KeyLayoutFile: /system/usr/keylayout/Generic.kl
      KeyCharacterMapFile: /system/usr/keychars/Generic.kcm
      ConfigurationFile: 
      HaveKeyboardLayoutOverlay: false

2,将 Generic.kl 重新命名为:Vendor_0a5c_Product_4502.kl;系统起来后根据 vendor id 和
product id 来识别对应的配置文件;
3,将 Vendor_0a5c_Product_4502.kl 拷贝到系统的/system/usr/keylayout/下,重启(reboot)
4,系统起来后 dumpsys input 查看系统是否是用你的配置文件即对应 keylayoutfile;
5,在#4 的基础上,串口输入 getevent,按遥控器的按键来获取键值,我们获取到的 scancode
是 0x66(注意:这里获取到的是 hex)
Vendor_0a5c_Product_4502.kl 部分 配置文件如下

key 100   ALT_RIGHT
# key 101 "KEY_LINEFEED"
key 102   HOME
key 103   DPAD_UP
key 104   PAGE_UP
key 105   DPAD_LEFT
key 106   DPAD_RIGHT
key 107   MOVE_END
key 108   DPAD_DOWN
key 109   PAGE_DOWN
key 110   INSERT key 111 FORWARD_DEL # key 112 "KEY_MACRO" key 113 VOLUME_MUTE key 114 VOLUME_DOWN key 115 VOLUME_UP key 116 POWER WAKE key 117 NUMPAD_EQUALS # key 118 "KEY_KPPLUSMINUS" key 119 BREAK # key 120 (undefined) key 121 NUMPAD_COMMA key 122 KANA key 123 EISU key 124 YEN key 125 META_LEFT key 126 META_RIGHT key 127 MENU WAKE_DROPPED key 128 MEDIA_STOP # key 129 "KEY_AGAIN" # key 130 "KEY_PROPS" # key 131 "KEY_UNDO" # key 132 "KEY_FRONT" # key 133 "KEY_COPY" # key 134 "KEY_OPEN" # key 135 "KEY_PASTE" # key 136 "KEY_FIND" # key 137 "KEY_CUT" # key 138 "KEY_HELP" key 139 MENU WAKE_DROPPED key 140 CALCULATOR # key 141 "KEY_SETUP" key 142 POWER WAKE key 143 POWER WAKE # key 144 "KEY_FILE" # key 145 "KEY_SENDFILE" # key 146 "KEY_DELETEFILE" # key 147 "KEY_XFER" # key 148 "KEY_PROG1" # key 149 "KEY_PROG2" key 150 EXPLORER # key 151 "KEY_MSDOS" key 152 POWER WAKE # key 153 "KEY_DIRECTION" # key 154 "KEY_CYCLEWINDOWS" key 155 ENVELOPE key 156 BOOKMARK

将 0x73 转换成十进制即:115 即 key 115 VOLUME_UP

8,查看你的配置是否正确,出口输入 getevent -l

  name:     "NEC_Remote_Controller"
/dev/input/event0: EV_KEY       KEY_VOLUMEUP         DOWN                
/dev/input/event0: EV_SYN       SYN_REPORT           00000000            
/dev/input/event0: EV_KEY       KEY_VOLUMEUP         UP                  
/dev/input/event0: EV_SYN       SYN_REPORT           00000000  

你可能感兴趣的:(配置,frameworks,遥控器)