1page.title=Getevent
2@jd:body
3
4<!--
5    Copyright 2013 The Android Open Source Project
6
7    Licensed under the Apache License, Version 2.0 (the "License");
8    you may not use this file except in compliance with the License.
9    You may obtain a copy of the License at
10
11        http://www.apache.org/licenses/LICENSE-2.0
12
13    Unless required by applicable law or agreed to in writing, software
14    distributed under the License is distributed on an "AS IS" BASIS,
15    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16    See the License for the specific language governing permissions and
17    limitations under the License.
18-->
19<p>The <code>getevent</code> tool runs on the device and provides information about input
20devices and a live dump of kernel input events.</p>
21<p>It is very useful tool for ensuring that device drivers are reporing the
22expected set of capabilities for each input device and are generating the
23desired stream of input events.</p>
24<h2 id="usage">Usage</h2>
25<h3 id="showing-device-capabilities">Showing Device Capabilities</h3>
26<p>It is often quite useful to see all of the keys and axes that a device reports.
27Use the <code>-p</code> option to do that.</p>
28<p>Here is a list of all of the Linux key codes and other events that a
29particular keyboard says it supports.</p>
30<pre><code>$ adb shell su -- getevent -p
31
32  name:     "Motorola Bluetooth Wireless Keyboard"
33  events:
34    KEY (0001): 0001  0002  0003  0004  0005  0006  0007  0008
35                0009  000a  000b  000c  000d  000e  000f  0010
36                0011  0012  0013  0014  0015  0016  0017  0018
37                0019  001a  001b  001c  001d  001e  001f  0020
38                0021  0022  0023  0024  0025  0026  0027  0028
39                0029  002a  002b  002c  002d  002e  002f  0030
40                0031  0032  0033  0034  0035  0036  0037  0038
41                0039  003a  003b  003c  003d  003e  003f  0040
42                0041  0042  0043  0044  0045  0046  0047  0048
43                0049  004a  004b  004c  004d  004e  004f  0050
44                0051  0052  0053  0055  0056  0057  0058  0059
45                005a  005b  005c  005d  005e  005f  0060  0061
46                0062  0063  0064  0066  0067  0068  0069  006a
47                006b  006c  006d  006e  006f  0071  0072  0073
48                0074  0075  0077  0079  007a  007b  007c  007d
49                007e  007f  0080  0081  0082  0083  0084  0085
50                0086  0087  0088  0089  008a  008c  008e  0090
51                0096  0098  009b  009c  009e  009f  00a1  00a3
52                00a4  00a5  00a6  00ab  00ac  00ad  00b0  00b1
53                00b2  00b3  00b4  00b7  00b8  00b9  00ba  00bb
54                00bc  00bd  00be  00bf  00c0  00c1  00c2  00d9
55                00f0  0110  0111  0112  01ba
56    REL (0002): 0000  0001  0008
57    ABS (0003): 0028  : value 223, min 0, max 255, fuzz 0, flat 0, resolution 0
58                0029  : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
59                002a  : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
60                002b  : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
61    MSC (0004): 0004
62    LED (0011): 0000  0001  0002  0003  0004
63  input props:
64    &lt;none&gt;
65</code></pre>
66<p>The <code>-i</code> option shows even more information than <code>-p</code>, including HID mapping tables
67and debugging information.</p>
68<p>The <code>-l</code> option uses textual labels for all event codes, which is handy.</p>
69<pre><code>$ adb shell su -- getevent -lp /dev/input/event1
70
71  name:     "Melfas MMSxxx Touchscreen"
72  events:
73    ABS (0003): ABS_MT_SLOT           : value 0, min 0, max 9, fuzz 0, flat 0, resolution 0
74                ABS_MT_TOUCH_MAJOR    : value 0, min 0, max 30, fuzz 0, flat 0, resolution 0
75                ABS_MT_POSITION_X     : value 0, min 0, max 720, fuzz 0, flat 0, resolution 0
76                ABS_MT_POSITION_Y     : value 0, min 0, max 1280, fuzz 0, flat 0, resolution 0
77                ABS_MT_TRACKING_ID    : value 0, min 0, max 65535, fuzz 0, flat 0, resolution 0
78                ABS_MT_PRESSURE       : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
79  input props:
80    INPUT_PROP_DIRECT
81</code></pre>
82<h3 id="showing-live-events">Showing Live Events</h3>
83<p>This is what a two finger multitouch gesture looks like for a touch screen
84that is using the Linux multitouch input protocol "B".  We use the <code>-l</code> option
85to show textual labels and <code>-t</code> to show timestamps.</p>
86<pre><code>$ adb shell su -- getevent -lt /dev/input/event1
87
88[   78826.389007] EV_ABS       ABS_MT_TRACKING_ID   0000001f
89[   78826.389038] EV_ABS       ABS_MT_PRESSURE      000000ab
90[   78826.389038] EV_ABS       ABS_MT_POSITION_X    000000ab
91[   78826.389068] EV_ABS       ABS_MT_POSITION_Y    0000025b
92[   78826.389068] EV_ABS       ABS_MT_SLOT          00000001
93[   78826.389068] EV_ABS       ABS_MT_TRACKING_ID   00000020
94[   78826.389068] EV_ABS       ABS_MT_PRESSURE      000000b9
95[   78826.389099] EV_ABS       ABS_MT_POSITION_X    0000019e
96[   78826.389099] EV_ABS       ABS_MT_POSITION_Y    00000361
97[   78826.389099] EV_SYN       SYN_REPORT           00000000
98[   78826.468688] EV_ABS       ABS_MT_SLOT          00000000
99[   78826.468688] EV_ABS       ABS_MT_TRACKING_ID   ffffffff
100[   78826.468719] EV_ABS       ABS_MT_SLOT          00000001
101[   78826.468719] EV_ABS       ABS_MT_TRACKING_ID   ffffffff
102[   78826.468719] EV_SYN       SYN_REPORT           00000000
103</code></pre>
104