VOLUME_DOWN
key 114 VOLUME_DOWN
key 115 VOLUME_UP
key 116 POWER
key 256 BUTTON_1
key 257 BUTTON_2
struct keys_stru keys[] = {
{VOLUME_UP, (uint32_t (*)(void))target_volume_up},
{VOLUME_DOWN, target_volume_down},
{POWER_KEY, pm8x41_get_pwrkey_is_pressed},
};
protected boolean onKeyEvent(KeyEvent event) {
// Only consume volume key events.
final int keyCode = event.getKeyCode();
if (keyCode != KeyEvent.KEYCODE_VOLUME_UP
&& keyCode != KeyEvent.KEYCODE_VOLUME_DOWN) {
return false;
}
// Handle the event when the user releases the volume key. To prevent
// the keys from actually adjusting the device volume, we'll ignore
// the result of handleVolumeKey() and always return true to consume
// the events.
final int action = event.getAction();
if (action == KeyEvent.ACTION_UP) {
handleVolumeKey(keyCode == KeyEvent.KEYCODE_VOLUME_UP);
}
// Consume all volume key events.
return true;
}
key 114 VOLUME_DOWN
key 115 VOLUME_UP
========================
# cat /proc/bus/input/devices
I: Bus=0019 Vendor=0002 Product=0001 Version=0100
N: Name="vmouse"
P: Phys=vmouse/input0
S: Sysfs=/devices/virtual/input/input0
U: Uniq=
H: Handlers=mouse0 event0
B: PROP=0
B: EV=7
B: KEY=70400 0 0 0 0 0 0 0 0
B: REL=143
I: Bus=0019 Vendor=0001 Product=0001 Version=0100
N: Name="sunxi-ths"
P: Phys=sunxiths/input0
S: Sysfs=/devices/virtual/input/input3
U: Uniq=
H: Handlers=event3
B: PROP=0
B: EV=9
B: ABS=100 0
I: Bus=0003 Vendor=1220 Product=0008 Version=0100
N: Name="HID 1220:0008"
P: Phys=usb-sunxi-ohci-1/input0
S: Sysfs=/devices/platform/sunxi-ohci.3/usb7/7-1/7-1:1.0/input/input6
U: Uniq=
H: Handlers=sysrq kbd event1
B: PROP=0
B: EV=120013
B: KEY=10000 7 ff9f207a c14057ff febeffdf ffefffff ffffffff fffffffe
B: MSC=10
B: LED=1f
I: Bus=0003 Vendor=1220 Product=0008 Version=0100
N: Name="HID 1220:0008"
P: Phys=usb-sunxi-ohci-1/input1
S: Sysfs=/devices/platform/sunxi-ohci.3/usb7/7-1/7-1:1.1/input/input7
U: Uniq=
H: Handlers=kbd mouse1 event2
B: PROP=0
B: EV=1f
B: KEY=4837fff 72ff32d bf544446 0 0 1f0001 20f90 8b17c000 677bfa d941dfed 9ed680 4400 0 10000002
B: REL=143
B: ABS=1 0
B: MSC=10
==================================================
Showing device capabilities
Use the -p option with the adb command to see all of the keys and axes a device reports.
adb shell su -- getevent -p
================================================
https://source.android.com/docs/core/interaction/input/getevent
==============================================
Showing live events
The following example shows a two-finger multi-touch gesture for a touchscreen using the Linux multi-touch input protocol "B". The -l option displays textual labels and the -t option displays timestamps.
adb shell su -- getevent -lt /dev/input/event1
=====================================================