[Miscellaneous Android Development] sabercatpuck:
found this and did a rough translation from it's native Chinese:

1.5 custom button
(1) Hardware: KEY detection using the ADC conversion principle to achieve, because of the limitations of this principle, it is not
Able to distinguish between the combination of keys (function keys, not including the power button); in accordance with the current public version of the schematic, the voltage changes 0.2V
Can distinguish between a file, so it can achieve up to 10 keys;
(2) the corresponding relations of the driver and hardware:
AllWinnerTech-V2.1-9/19/2011
6
Key driver file location: kernel/linux2.6.36/drivers/input/keyboard/sun4i-keyboard.c;
The principle:
Digital detection voltage value to distinguish the first few keys:
/ / 0.2V the mode
static unsigned char keypad_mapindex [64] =
{
0,0,0,0,0,0,0,0, / / ​​key 1, 8, 0-7
1,1,1,1,1,1,1, / / ​​key 2, 7, 8-14
2,2,2,2,2,2,2, / / ​​key 3, 7, 15-21
3,3,3,3,3,3, / / ​​key 4, 6, 22-27
4,4,4,4,4,4, / / ​​key 5, 6, 28-33
5,5,5,5,5,5, / / ​​key 6, 6, 34-39
6,6,6,6,6,6,6,6,6,6, / / ​​key 7, 10, 40 -49
7,7,7,7,7,7,7,7,7,7,7,7,7,7 / / key 8, 17, 50 -63
;}
2 keys corresponding to the key:
static unsigned int sun4i_scankeycodes [KEY_MAX_CNT] =
{
[0] = 163, / / ​​KEY_NEXTSONG
[1] = 165, / / ​​KEY_PREVIOUSSONG
[2] = KEY_VOLUMEUP
[3] = KEY_VOLUMEDOWN
[4] = KEY_ENTER
[5] = KEY_RESERVED
[6] = KEY_RESERVED
[7] = KEY_RESERVED
[8] = KEY_RESERVED
[9] = KEY_RESERVED
[10] = KEY_RESERVED
[11] = KEY_RESERVED
[12] = KEY_RESERVED
;}
Reported when key events mapped by more than twice the final key:
scancode = keypad_mapindex [key_val & 0x3f];
input_report_key (sun3ikbd_dev, sun3i_scankeycodes [scancode], 1);
input_sync (sun3ikbd_dev);
(3) Android key function mapping:
Map file android2.3 \ device \ softwinner \ crane_xx \
sun4i-keyboard.kl, for example as follows:
the key 102 the HOME WAKE.
the key 115 BACK to WAKE.
key 114 MENU WAKE_DROPPED
the key behind the figures reported in the drive key, followed by the corresponding function only when the custom button needs to be front
AllWinnerTech-V2.1-9/19/2011
7
Map value and the back of the function corresponding to can; (WAKE_DROPPED: wake up the screen, but this button does not
Will be issued to the current application, WAKE: Wake-up screen, but the keys need to be sent to the application, followed by
Without representatives did not wake-up function)
Note: If you just want to quickly match buttons, the first question the practice of the training test subject to achieve rapid configuration (into the
Into the adb shell, getevent command to obtain the key mapping values, re-fill sun4i-keyboard.kl file);

1.14. The use of the Recovery function
(1) Recovery Functional Description:
Recovery is a special upgrade mode in the Android update for android itself; into recovery mode
The style, the android system boot, press and hold a specific button, it automatically enters the android's recovery
Mode.
(2) key to view
The button is made of the principle of the AD converter. When the user presses a button, this button will get the corresponding
The value of the AD converter. At the same time, the keys of all the buttons are not the same, and the key has a certain interval between, there is no
Adjacent. For example, the key may be 5, 10, 15, 20, but can not be 5,11,12,13.
In order to facilitate the user to view the different keys of the key, this method is required to connect the serial port to use and therefore suitable for the development order
AllWinnerTech-V2.1-9/19/2011
30
The Duan use. Concrete steps are:
1) the small machine to a PC via a serial cable to connect, set the screen focus on serial debugging software;
2) before the user boot, hold down the number keys on the PC keyboard "3";
3) boot, wait one second after releasing the computer keyboard;
After this step, the user will see the following printed information appears on the screen:
This means that the system has entered the key key test mode, this mode will always wait for the user presses the button, and
Keys keys to print out the serial port on the screen. In this way, users can easily view different keys keys. For example, the
When a key is pressed, the user can see the following printed information.
AD used in very fast, so with one button press on the screen there will be more than one value. The user can see
Out the key key is 8. 63 of the last appears is due to release the button when using the need to remove the dry
Scrambling data. Therefore, as long as the users to view key key concern in front of the print out the value, the back appears to be ignored
Do not count.
(3) button to select
Under normal circumstances, the number of keys a program board, or a different arrangement, which have led to a solution provider in the choice of
Key as the boot stage of recovery is different. Therefore, the system provides a method used to select to enter
recovery mode keys:
In the efex \ sys_config1.fex configuration script, provide a configuration for the select button of the key, as follows:
It said that the choice for the key recovery function key range fall key_min to key_max to
, 17-24. View due to the choice of all keys are available through the previously described method, therefore, assume that
Households to choose the keys a user select configuration:
1) in accordance with the method described above, to read out the key of all keys;
2) to read out of a key a1, remove the two adjacent to a key value, denoted by b1 and c1, b1 is greater than c1;
3) calculate (a1 + b1) / 2 (a1 + c1) / 2, respectively, fill in the key_max, and key_min Department;
4) If a1 is exactly the minimum of all the keys, take key_min 0; If a1 is exactly all key
Large value, then take key_max to 63;
After the above steps, you can select a specific key into recovery mode. Took an average of the original
Considered due to long use, the resistor may be a slight change to lead to key changes, and take the range of values ​​compatible
This resistance changes brought about key changes.
(4) uses
The android compiled after the use of the make otapackage command can
key value = 8
key value = 8
key value = 8
the key of value = 63
welcome to the key the value test,
press any key, and the value would be printed
press power key to the exit
[Recovery_key]
key_max = 24
key_min = 17
AllWinnerTech-V2.1-9/19/2011
31
android2.3.4 \ out \ target \ product \ crane-xxx directory to generate a crane_xxx-ota-eng.username.zip text
, Renamed this file to the SD card copy the update.zip;
A specific key at system startup, hold down the set into recovery mode, enter this mode, the system will be in SD
Card catalog to find the update.zip file, find the file goes into the automatic upgrade, if not find the file, the system
Will prompt an error;