Home | History | Annotate | Download | only in input
      1 <html devsite>
      2   <head>
      3     <title>Input Device Configuration Files</title>
      4     <meta name="project_path" value="/_project.yaml" />
      5     <meta name="book_path" value="/_book.yaml" />
      6   </head>
      7   <body>
      8   <!--
      9       Copyright 2017 The Android Open Source Project
     10 
     11       Licensed under the Apache License, Version 2.0 (the "License");
     12       you may not use this file except in compliance with the License.
     13       You may obtain a copy of the License at
     14 
     15           http://www.apache.org/licenses/LICENSE-2.0
     16 
     17       Unless required by applicable law or agreed to in writing, software
     18       distributed under the License is distributed on an "AS IS" BASIS,
     19       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     20       See the License for the specific language governing permissions and
     21       limitations under the License.
     22   -->
     23 
     24 
     25 
     26 <p>Input device configuration files (<code>.idc</code> files) contain device-specific
     27 configuration properties that affect the behavior of input devices.</p>
     28 <p>Input device configuration files are typically not necessary for standard
     29 peripherals such as HID keyboards and mice since the default system behavior
     30 usually ensures that they will work out of the box.  On the other hand,
     31 built-in embedded devices, particularly touch screens, almost always
     32 require input device configuration files to specify their behavior.</p>
     33 <h2 id="rationale">Rationale</h2>
     34 <p>Android automatically detects and configures most input device capabilities
     35 based on the event types and properties that are reported by the associated
     36 Linux kernel input device driver.</p>
     37 <p>For example, if an input device supports the <code>EV_REL</code> event type and codes
     38 <code>REL_X</code> and <code>REL_Y</code> as well as the <code>EV_KEY</code> event type and <code>BTN_MOUSE</code>,
     39 then Android will classify the input device as a mouse.  The default behavior
     40 for a mouse is to present an on-screen cursor which tracks the mouse's movements
     41 and simulates touches when the mouse is clicked.  Although the mouse can
     42 be configured differently, the default behavior is usually sufficient for
     43 standard mouse peripherals.</p>
     44 <p>Certain classes of input devices are more ambiguous.  For example, multi-touch
     45 touch screens and touch pads both support the <code>EV_ABS</code> event type and codes
     46 <code>ABS_MT_POSITION_X</code> and <code>ABS_MT_POSITION_Y</code> at a minimum.  However, the intended
     47 uses of these devices are quite different and cannot always be determined
     48 automatically.  Also, additional information is required to make sense of the
     49 pressure and size information reported by touch devices.  Hence touch devices,
     50 especially built-in touch screens, usually need IDC files.</p>
     51 <h2 id="location">Location</h2>
     52 <p>Input device configuration files are located by USB vendor, product (and
     53 optionally version) id or by input device name.</p>
     54 <p>The following paths are consulted in order.</p>
     55 <ul>
     56 <li><code>/system/usr/idc/Vendor_XXXX_Product_XXXX_Version_XXXX.idc</code></li>
     57 <li><code>/system/usr/idc/Vendor_XXXX_Product_XXXX.idc</code></li>
     58 <li><code>/system/usr/idc/DEVICE_NAME.idc</code></li>
     59 <li><code>/data/system/devices/idc/Vendor_XXXX_Product_XXXX_Version_XXXX.idc</code></li>
     60 <li><code>/data/system/devices/idc/Vendor_XXXX_Product_XXXX.idc</code></li>
     61 <li><code>/data/system/devices/idc/DEVICE_NAME.idc</code></li>
     62 </ul>
     63 <p>When constructing a file path that contains the device name, all characters
     64 in the device name other than '0'-'9', 'a'-'z', 'A'-'Z', '-' or '_' are replaced by '_'.</p>
     65 <h2 id="syntax">Syntax</h2>
     66 <p>An input device configuration file is a plain text file consisting of property
     67 assignments and comments.</p>
     68 <h3 id="properties">Properties</h3>
     69 <p>Property assignments each consist of a property name, an <code>=</code>, a property value,
     70 and a new line.  Like this:</p>
     71 <pre class="devsite-click-to-copy">
     72 property = value
     73 </pre>
     74 <p>Property names are non-empty literal text identifiers.  They must not contain
     75 whitespace.  Each components of the input system defines a set of properties
     76 that are used to configure its function.</p>
     77 <p>Property values are non-empty string literals, integers or floating point numbers.
     78 They must not contain whitespace or the reserved characters <code>\</code> or <code>"</code>.</p>
     79 <p>Property names and values are case-sensitive.</p>
     80 <h3 id="comments">Comments</h3>
     81 <p>Comment lines begin with '#' and continue to the end of the line.  Like this:</p>
     82 <pre class="devsite-click-to-copy">
     83 # A comment!
     84 </pre>
     85 <p>Blank lines are ignored.</p>
     86 <h3 id="example">Example</h3>
     87 <pre class="devsite-click-to-copy">
     88 # This is an example of an input device configuration file.
     89 # It might be used to describe the characteristics of a built-in touch screen.
     90 
     91 # This is an internal device, not an external peripheral attached to the USB
     92 # or Bluetooth bus.
     93 device.internal = 1
     94 
     95 # The device should behave as a touch screen, which uses the same orientation
     96 # as the built-in display.
     97 touch.deviceType = touchScreen
     98 touch.orientationAware = 1
     99 
    100 # Additional calibration properties...
    101 # etc...
    102 </pre>
    103 <h2 id="common-properties">Common Properties</h2>
    104 <p>The following property is common to all input device classes.</p>
    105 <p>Refer to the documentation of each input device class for information about the
    106 special properties used by each class.</p>
    107 <h4 id="deviceinternal"><code>device.internal</code></h4>
    108 <p><em>Definition:</em> <code>device.internal</code> = <code>0</code> | <code>1</code></p>
    109 <p>Specifies whether the input device is an internal built-in component as opposed to an
    110 externally attached (most likely removable) peripheral.</p>
    111 <ul>
    112 <li>
    113 <p>If the value is <code>0</code>, the device is external.</p>
    114 </li>
    115 <li>
    116 <p>If the value is <code>1</code>, the device is internal.</p>
    117 </li>
    118 <li>
    119 <p>If the value is not specified, the default value is <code>0</code> for all devices on the
    120     USB (BUS_USB) or Bluetooth (BUS_BLUETOOTH) bus, <code>1</code> otherwise.</p>
    121 </li>
    122 </ul>
    123 <p>This property determines default policy decisions regarding wake events.</p>
    124 <p>Internal input devices generally do not wake the display from sleep unless explicitly
    125 configured to do so in the key layout file or in a hardcoded policy rule.  This
    126 distinction prevents key presses and touches from spuriously waking up your phone
    127 when it is in your pocket.  Usually there are only a small handful of wake keys defined.</p>
    128 <p>Conversely, external input devices usually wake the device more aggressively because
    129 they are assumed to be turned off or not plugged in during transport.  For example,
    130 pressing any key on an external keyboard is a good indicator that the user wants the
    131 device to wake up and respond.</p>
    132 <p>It is important to ensure that the value of the <code>device.internal</code> property is set
    133 correctly for all internal input devices.</p>
    134 <h2 id="validation">Validation</h2>
    135 <p>Make sure to validate your input device configuration files using the
    136 <a href="validate-keymaps.html">Validate Keymaps</a> tool.</p>
    137 
    138 
    139   </body>
    140 </html>
    141