Linux GPIO keys and events

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
=====================================================

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值