Chinaunix首页 | 论坛 | 博客
  • 博客访问: 271861
  • 博文数量: 95
  • 博客积分: 2047
  • 博客等级: 大尉
  • 技术积分: 1022
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-14 16:18
文章分类

全部博文(95)

文章存档

2013年(1)

2011年(94)

我的朋友

分类: 嵌入式

2011-08-14 19:53:58

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' <<<<<<<
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 the another 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 the 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'<<<<<<<
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.
阅读(572) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~