ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上

2014年1月15日 星期三

Note: VirtualKey in android

ref: https://source.android.com/devices/tech/input/touch-devices.html

Virtual Key Map Files

Touch devices are often used to implement virtual keys.

There are several ways of doing this, depending on the capabilities of the touch controller. Some touch controllers can
 be directly configured to implement soft keys by setting firmware registers. Other times it is desirable to perform 
the mapping from touch coordinates to key codes in software.

When virtual keys are implemented in software, the kernel must export a virtual key map file called virtualkeys.
(devicename) as a board property. For example, if the touch screen device drivers reports its name as "touchyfeely" 
then the virtual key map file must have the path /sys/board_properties/virtualkeys.touchyfeely.

A virtual key map file describes the coordinates and Linux key codes of virtual keys on the touch screen.

In addition to the virtual key map file, there must be a corresponding key layout file and key character map file to 
map the Linux key codes to Android key codes and to specify the type of the keyboard device (usually SPECIAL_FUNCTION).
Syntax

A virtual key map file is a plain text file consisting of a sequence of virtual key layout descriptions either 
separated by newlines or by colons.

Comment lines begin with '#' and continue to the end of the line.

Each virtual key is described by 6 colon-delimited components:

    0x01: A version code. Must always be 0x01.
    Linux key code: The Linux key code of the virtual key.
    centerX: The X pixel coordinate of the center of the virtual key.
    centerY: The Y pixel coordinate of the center of the virtual key.
    width: The width of the virtual key in pixels.
    height: The height of the virtual key in pixels.

All coordinates and sizes are specified in terms of the display coordinate system.

Here is a virtual key map file all written on one line.

# All on one line
0x01:158:55:835:90:55:0x01:139:172:835:125:55:0x01:102:298:835:115:55:0x01:217:412:835:95:55

The same virtual key map file can also be written on multiple lines.

# One key per line
0x01:158:55:835:90:55
0x01:139:172:835:125:55
0x01:102:298:835:115:55
0x01:217:412:835:95:55

In the above example, the touch screen has a resolution of 480x800. Accordingly, all of the virtual keys have a centerY 
coordinate of 835, which is a little bit below the visible area of the touch screen.

The first key has a Linux scan code of 158 (KEY_BACK), centerX of 55, centerY of 835, width of 90 and height of 55.
Example

Virtual key map file: /sys/board_properties/virtualkeys.touchyfeely.

0x01:158:55:835:90:55
0x01:139:172:835:125:55
0x01:102:298:835:115:55
0x01:217:412:835:95:55

Key layout file: /system/usr/keylayout/touchyfeely.kl.

key 158 BACK
key 139 MENU
key 102 HOME
key 217 SEARCH

Key character map file: /system/usr/keychars/touchyfeely.kcm.

type SPECIAL_FUNCTION


ref:http://www.cnblogs.com/aceheart/archive/2012/10/27/2742309.html
這一篇有說明 kernel driver 怎麼實做這個 virtual key, board_properties ..

沒有留言:

標籤

網誌存檔