树莓派 -- 输入设备驱动 (key) 续1

测试
安装 input-utils

pi@raspberrypi:~ $ sudo apt-get install input-utils
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  input-utils
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 14.9 kB of archives.
After this operation, 60.4 kB of additional disk space will be used.
Get:1 http://mirrors.shu.edu.cn/raspbian/raspbian stretch/main armhf input-utils armhf 1.0-1.1 [14.9 kB]
Fetched 14.9 kB in 1min 20s (183 B/s)                  
Selecting previously unselected package input-utils.
(Reading database ... 124722 files and directories currently installed.)
Preparing to unpack .../input-utils_1.0-1.1_armhf.deb ...
Unpacking input-utils (1.0-1.1) ...
Setting up input-utils (1.0-1.1) ...
Processing triggers for man-db (2.7.6.1-2) ...
pi@raspberrypi:~ $ 

lsinput

/dev/input/event0
   bustype : BUS_HOST
   vendor  : 0x1
   product : 0x1
   version : 256
   name    : "gpio_keys"
   phys    : "gpio-keys/input0"
   bits ev : EV_SYN EV_KEY

input-events. 如果没有键按下,timeout

pi@raspberrypi:~ $ input-events 0
/dev/input/event0
   bustype : BUS_HOST
   vendor  : 0x1
   product : 0x1
   version : 256
   name    : "gpio_keys"
   phys    : "gpio-keys/input0"
   bits ev : EV_SYN EV_KEY

waiting for events
timeout, quitting

如果有键按下, 这里的key值是dts中定义的 linux,code = <100>;

pi@raspberrypi:~ $ input-events 0
/dev/input/event0
   bustype : BUS_HOST
   vendor  : 0x1
   product : 0x1
   version : 256
   name    : "gpio_keys"
   phys    : "gpio-keys/input0"
   bits ev : EV_SYN EV_KEY EV_REP

waiting for events
13:59:42.712941: EV_KEY KEY_RIGHTALT (0x64) pressed
13:59:42.712941: EV_SYN code=0 value=1

注: 上一篇中的dts中gpio-keys的部分需要加上

autorepeat;
posted @ 2018-07-04 22:47  feiwatson  阅读(146)  评论(0编辑  收藏  举报