Rockie's Android Porting Guide(3)——Add correct keymap to your system

Rockie Cheng

We already have a keyboard dirver in Linux kernel.
Next, let us notice Android that we have a keyboard.


/* gpio buttons from linux*/
static struct gpio_keys_button gpio_buttons[] = {
{
.gpio = S3C64XX_GPN(0),
.code = 116,
.desc = "ENDCALL",
.active_low = 1,
.wakeup = 0,
},
{
.gpio = S3C64XX_GPN(1),
.code = 139,
.desc = "MENU",
.active_low = 1,
.wakeup = 0,
},
{
.gpio = S3C64XX_GPN(2),
.code = 99,
.desc = "ROTATE",
.active_low = 1,
.wakeup = 0,
},
{
.gpio = S3C64XX_GPN(3),
.code = 102,
.desc = "HOME",
.active_low = 1,
.wakeup = 0,
},
{
.gpio = S3C64XX_GPN(4),
.code = 42,
.desc = "BACK",
.active_low = 1,
.wakeup = 0,
},
{
.gpio = S3C64XX_GPN(5),
.code = 158,
.desc = "BACK",
.active_low = 1,
.wakeup = 0,
}
};


(1)Let me see logcat information.
I/EventHub( 58): New device: path=/dev/input/event1 name=S3C TouchScreen id=0x10000 (of 0x1) index=1 fd=45 classes=0x4
E/EventHub( 58): could not get driver version for /dev/input/mice, Not a typewriter
I/EventHub( 58): New keyboard: publicID=65537 device->id=0x10001 devname='gpio-keys' propName='hw.keyboards.65537.devname' keylayout='/system/usr/keylayout/qwerty.kl' <<<<<<<<Obviously this is not wht we want
I/EventHub( 58): New device: path=/dev/input/event0 name=gpio-keys id=0x10001 (of 0x2) index=2 fd=47 classes=0x1
E/EventHub( 58): could not get driver version for /dev/input/mouse0, Not a typewriter
I/KeyInputQueue( 58): Device added: id=0x0, name=gpio-keys, classes=1
I/KeyInputQueue( 58): Device added: id=0x10000, name=S3C TouchScreen, classes=4
I/KeyInputQueue( 58): X: min=0 max=480 flat=0 fuzz=0
I/KeyInputQueue( 58): Y: min=0 max=272 flat=0 fuzz=0
I/KeyInputQueue( 58): Pressure: min=0 max=1 flat=0 fuzz=0
I/KeyInputQueue( 58): Size: unknown values
I/KeyInputQueue( 58): No virtual keys found

(2)make a file build/target/board/idea6410/gpio-keys.kl
key 158 BACK WAKE_DROPPED
key 139 MENU WAKE_DROPPED
key 102 HOME WAKE
key 116 ENDCALL WAKE_DROPPED
key 99 ROTATOR
key 42 POWER WAKE

(3)make another file build/target/board/idea6410/gpio-keys.kcm
First,I just copy it from tutule2.kcm,but it does not work.
So I find this form net,just a little change.
It seems like 9 number keyboard more than qwerty.

[type=QWERTY]

# keycode display number base caps fn caps_fn

A 'A' '2' 'a' 'A' '#' 0x00
B 'B' '2' 'b' 'B' '<' 0x00
C 'C' '2' 'c' 'C' '9' 0x00E7
D 'D' '3' 'd' 'D' '5' 0x00
E 'E' '3' 'e' 'E' '2' 0x0301
F 'F' '3' 'f' 'F' '6' 0x00A5
G 'G' '4' 'g' 'G' '-' '_'
H 'H' '4' 'h' 'H' '[' '{'
I 'I' '4' 'i' 'I' '$' 0x0302
J 'J' '5' 'j' 'J' ']' '}'
K 'K' '5' 'k' 'K' '"' '~'
L 'L' '5' 'l' 'L' ''' '`'
M 'M' '6' 'm' 'M' '!' 0x00
N 'N' '6' 'n' 'N' '>' 0x0303
O 'O' '6' 'o' 'O' '(' 0x00
P 'P' '7' 'p' 'P' ')' 0x00
Q 'Q' '7' 'q' 'Q' '*' 0x0300
R 'R' '7' 'r' 'R' '3' 0x20AC
S 'S' '7' 's' 'S' '4' 0x00DF
T 'T' '8' 't' 'T' '+' 0x00A3
U 'U' '8' 'u' 'U' '&' 0x0308
V 'V' '8' 'v' 'V' '=' '^'
W 'W' '9' 'w' 'W' '1' 0x00
X 'X' '9' 'x' 'X' '8' 0xEF00
Y 'Y' '9' 'y' 'Y' '%' 0x00A1
Z 'Z' '9' 'z' 'Z' '7' 0x00

# on pc keyboards
COMMA ',' ',' ',' ';' ';' '|'
PERIOD '.' '.' '.' ':' ':' 0x2026
AT '@' '0' '@' '0' '0' 0x2022
SLASH '/' '/' '/' '?' '?' '/'

SPACE 0x20 0x20 0x20 0x20 0xEF01 0xEF01
ENTER 0xa 0xa 0xa 0xa 0xa 0xa

TAB 0x9 0x9 0x9 0x9 0x9 0x9
0 '0' '0' '0' ')' ')' ')'
1 '1' '1' '1' '!' '!' '!'
2 '2' '2' '2' '@' '@' '@'
3 '3' '3' '3' '#' '#' '#'
4 '4' '4' '4' '$' '$' '$'
5 '5' '5' '5' '%' '%' '%'
6 '6' '6' '6' '^' '^' '^'
7 '7' '7' '7' '&' '&' '&'
8 '8' '8' '8' '*' '*' '*'
9 '9' '9' '9' '(' '(' '('

GRAVE '`' '`' '`' '~' '`' '~'
MINUS '-' '-' '-' '_' '-' '_'
EQUALS '=' '=' '=' '+' '=' '+'
LEFT_BRACKET '[' '[' '[' '{' '[' '{'
RIGHT_BRACKET ']' ']' ']' '}' ']' '}'
BACKSLASH '/' '/' '/' '|' '/' '|'
SEMICOLON ';' ';' ';' ':' ';' ':'
APOSTROPHE ''' ''' ''' '"' ''' '"'
STAR '*' '*' '*' '*' '*' '*'
POUND '#' '#' '#' '#' '#' '#'
PLUS '+' '+' '+' '+' '+' '+'



(4)add these to AndroidBoard.mk

file := $(TARGET_OUT_KEYLAYOUT)/gpio-keys.kl
ALL_PREBUILT += $(file)
$(file) : $(LOCAL_PATH)/gpio-keys.kl | $(ACP)
$(transform-prebuilt-to-target)

include $(CLEAR_VARS)
LOCAL_SRC_FILES := gpio-keys.kcm
include $(BUILD_KEY_CHAR_MAP)

(5)add these to system.prop
android.keylayout.gpio-keys = /system/usr/keylayout/gpio-keys.kl
android.keychar.gpio-keys = /system/usr/keychars/gpio-keys.kcm

(6)build your system again
Now we can see the different:

I/EventHub( 63): New device: path=/dev/input/event1 name=S3C TouchScreen id=0x10000 (of 0x1) index=1 fd=50 classes=0x4
E/EventHub( 63): could not get driver version for /dev/input/mice, Not a typewriter
E/KeyLayoutMap( 63): /system/usr/keylayout/gpio-keys.kl:10: expected keycode, got 'ROTATOR'
I/EventHub( 63): New keyboard: publicID=0 device->id=0x10001 devname='gpio-keys' propName='hw.keyboards.0.devname' keylayout='/system/usr/keylayout/gpio-keys.kl'<<<<<<<<OK correct!
I/EventHub( 63): New device: path=/dev/input/event0 name=gpio-keys id=0x10001 (of 0x2) index=2 fd=52 classes=0x1
E/EventHub( 63): could not get driver version for /dev/input/mouse0, Not a typewriter
I/KeyInputQueue( 63): Device added: id=0x0, name=gpio-keys, classes=1
I/KeyInputQueue( 63): Device added: id=0x10000, name=S3C TouchScreen, classes=4
I/KeyInputQueue( 63): X: min=0 max=480 flat=0 fuzz=0
I/KeyInputQueue( 63): Y: min=0 max=272 flat=0 fuzz=0
I/KeyInputQueue( 63): Pressure: min=0 max=1 flat=0 fuzz=0
I/KeyInputQueue( 63): Size: unknown values
I/KeyInputQueue( 63): No virtual keys found


System do not know the word "ROTATOR" presently.
You can add a USB-KEYBOARD too.

Rockie Cheng 阿虚

Reference:

http://www.kandroid.org/android_pdk/keymaps_keyboard_input.html

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. 仿QQ android 实战(学习 android 先来个QQ
  2. Android测试之Monkey原理及源码分析(二)
  3. android linux 基础知识总结
  4. Android(安卓)Asynchronous Http Client
  5. Android(安卓)NDK 的学习之旅-----HelloW
  6. Android(安卓)网络权限配置
  7. material design 的android开源代码整理
  8. android开发专题系列-Android开发指南
  9. android打电话,发短信
  10. Android通信详解