Home | History | Annotate | Download | only in input
      1 page.title=Getevent
      2 @jd:body
      3 
      4 <!--
      5     Copyright 2015 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 <div id="qv-wrapper">
     20   <div id="qv">
     21     <h2>In this document</h2>
     22     <ol id="auto-toc">
     23     </ol>
     24   </div>
     25 </div>
     26 
     27 <p>The <code>getevent</code> tool runs on the device and provides information
     28 about input devices and a live dump of kernel input events.</p>
     29 <p>This tool is useful for ensuring device drivers are reporting the
     30 expected set of capabilities for each input device and are generating the
     31 desired stream of input events.</p>
     32 
     33 <h2 id="showing-device-capabilities">Showing device capabilities</h2>
     34 <p>Use the <code>-p</code> option to see all of the keys and axes a device
     35 reports. The following example lists the Linux key codes and other events a
     36 particular keyboard says it supports.</p>
     37 
     38 <pre><code>$ adb shell su -- getevent -p
     39 
     40   name:     "Motorola Bluetooth Wireless Keyboard"
     41   events:
     42     KEY (0001): 0001  0002  0003  0004  0005  0006  0007  0008
     43                 0009  000a  000b  000c  000d  000e  000f  0010
     44                 0011  0012  0013  0014  0015  0016  0017  0018
     45                 0019  001a  001b  001c  001d  001e  001f  0020
     46                 0021  0022  0023  0024  0025  0026  0027  0028
     47                 0029  002a  002b  002c  002d  002e  002f  0030
     48                 0031  0032  0033  0034  0035  0036  0037  0038
     49                 0039  003a  003b  003c  003d  003e  003f  0040
     50                 0041  0042  0043  0044  0045  0046  0047  0048
     51                 0049  004a  004b  004c  004d  004e  004f  0050
     52                 0051  0052  0053  0055  0056  0057  0058  0059
     53                 005a  005b  005c  005d  005e  005f  0060  0061
     54                 0062  0063  0064  0066  0067  0068  0069  006a
     55                 006b  006c  006d  006e  006f  0071  0072  0073
     56                 0074  0075  0077  0079  007a  007b  007c  007d
     57                 007e  007f  0080  0081  0082  0083  0084  0085
     58                 0086  0087  0088  0089  008a  008c  008e  0090
     59                 0096  0098  009b  009c  009e  009f  00a1  00a3
     60                 00a4  00a5  00a6  00ab  00ac  00ad  00b0  00b1
     61                 00b2  00b3  00b4  00b7  00b8  00b9  00ba  00bb
     62                 00bc  00bd  00be  00bf  00c0  00c1  00c2  00d9
     63                 00f0  0110  0111  0112  01ba
     64     REL (0002): 0000  0001  0008
     65     ABS (0003): 0028  : value 223, min 0, max 255, fuzz 0, flat 0, resolution 0
     66                 0029  : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
     67                 002a  : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
     68                 002b  : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
     69     MSC (0004): 0004
     70     LED (0011): 0000  0001  0002  0003  0004
     71   input props:
     72     &lt;none&gt;
     73 </code></pre>
     74 
     75 <p>Use the <code>-i</code> option to get more information, including HID mapping
     76 tables and debugging information.</p>
     77 
     78 <p>Use the <code>-l</code> option to display textual labels for all event codes.
     79 Example:</p>
     80 <pre><code>$ adb shell su -- getevent -lp /dev/input/event1
     81 
     82   name:     "Melfas MMSxxx Touchscreen"
     83   events:
     84     ABS (0003): ABS_MT_SLOT           : value 0, min 0, max 9, fuzz 0, flat 0, resolution 0
     85                 ABS_MT_TOUCH_MAJOR    : value 0, min 0, max 30, fuzz 0, flat 0, resolution 0
     86                 ABS_MT_POSITION_X     : value 0, min 0, max 720, fuzz 0, flat 0, resolution 0
     87                 ABS_MT_POSITION_Y     : value 0, min 0, max 1280, fuzz 0, flat 0, resolution 0
     88                 ABS_MT_TRACKING_ID    : value 0, min 0, max 65535, fuzz 0, flat 0, resolution 0
     89                 ABS_MT_PRESSURE       : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
     90   input props:
     91     INPUT_PROP_DIRECT
     92 </code></pre>
     93 <h2 id="showing-live-events">Showing live events</h2>
     94 <p>The following example shows a two-finger multi-touch gesture for a
     95 touchscreen using the Linux multi-touch input protocol "B". The <code>-l</code>
     96 option displays textual labels and the <code>-t</code> option displays
     97 timestamps.</p>
     98 
     99 <pre><code>$ adb shell su -- getevent -lt /dev/input/event1
    100 
    101 [   78826.389007] EV_ABS       ABS_MT_TRACKING_ID   0000001f
    102 [   78826.389038] EV_ABS       ABS_MT_PRESSURE      000000ab
    103 [   78826.389038] EV_ABS       ABS_MT_POSITION_X    000000ab
    104 [   78826.389068] EV_ABS       ABS_MT_POSITION_Y    0000025b
    105 [   78826.389068] EV_ABS       ABS_MT_SLOT          00000001
    106 [   78826.389068] EV_ABS       ABS_MT_TRACKING_ID   00000020
    107 [   78826.389068] EV_ABS       ABS_MT_PRESSURE      000000b9
    108 [   78826.389099] EV_ABS       ABS_MT_POSITION_X    0000019e
    109 [   78826.389099] EV_ABS       ABS_MT_POSITION_Y    00000361
    110 [   78826.389099] EV_SYN       SYN_REPORT           00000000
    111 [   78826.468688] EV_ABS       ABS_MT_SLOT          00000000
    112 [   78826.468688] EV_ABS       ABS_MT_TRACKING_ID   ffffffff
    113 [   78826.468719] EV_ABS       ABS_MT_SLOT          00000001
    114 [   78826.468719] EV_ABS       ABS_MT_TRACKING_ID   ffffffff
    115 [   78826.468719] EV_SYN       SYN_REPORT           00000000
    116 </code></pre>
    117 <p class="note"><strong>Note:</strong> <code>getevent</code> timestamps use
    118 the format $SECONDS.$MICROSECONDS in the CLOCK_MONOTONIC timebase. For details,
    119 refer to getevent.c.</p>