1## 7.2\. Input Devices
2
3Device implementations:
4
5*    [C-0-1] MUST include an input mechanism, such as a
6[touchscreen](#7_2_4_touchScreen_input) or [non-touch navigation](#7_2_2_non-touch_navigation),
7to navigate between the UI elements.
8
9### 7.2.1\. Keyboard
10
11If device implementations include support for third-party
12Input Method Editor (IME) applications, they:
13
14*   [C-1-1] MUST declare the [`android.software.input_methods`](https://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_INPUT_METHODS)
15feature flag.
16*   [C-1-2] MUST implement fully [`Input Management Framework`](https://developer.android.com/reference/android/view/inputmethod/InputMethodManager.html)
17*   [C-1-3] MUST have a preinstalled software keyboard.
18
19Device implementations:
20*   [C-0-1] MUST NOT include a hardware keyboard that does not match one of the
21    formats specified in [android.content.res.Configuration.keyboard](
22    http://developer.android.com/reference/android/content/res/Configuration.html)
23    (QWERTY or 12-key).
24*   SHOULD include additional soft keyboard implementations.
25*   MAY include a hardware keyboard.
26
27### 7.2.2\. Non-touch Navigation
28
29Android includes support for d-pad, trackball, and wheel as mechanisms for
30non-touch navigation.
31
32Device implementations:
33
34*   [C-0-1] MUST report the correct value for
35    [android.content.res.Configuration.navigation](
36    https://developer.android.com/reference/android/content/res/Configuration.html#navigation).
37
38If device implementations lack non-touch navigations, they:
39
40*   [C-1-1] MUST provide a reasonable alternative user interface mechanism for the
41    selection and editing of text, compatible with Input Management Engines. The
42    upstream Android open source implementation includes a selection mechanism
43    suitable for use with devices that lack non-touch navigation inputs.
44
45
46### 7.2.3\. Navigation Keys
47
48The [Home](http://developer.android.com/reference/android/view/KeyEvent.html#`KEYCODE_HOME`),
49[Recents](http://developer.android.com/reference/android/view/KeyEvent.html#`KEYCODE_APP_SWITCH`),
50and [Back](http://developer.android.com/reference/android/view/KeyEvent.html#`KEYCODE_BACK`)
51functions typically provided via an interaction with a dedicated physical button
52or a distinct portion of the touch screen, are essential to the Android
53navigation paradigm and therefore, device implementations:
54
55*   [C-0-1] MUST provide a user affordance to launch installed applications
56    that have an activity with the `<intent-filter>` set with `ACTION=MAIN` and
57    `CATEGORY=LAUNCHER` or `CATEGORY=LEANBACK_LAUNCHER` for Television device
58    implementations.
59    The Home function SHOULD be the mechanism for this user affordance.
60*   SHOULD provide buttons for the Recents and Back function.
61
62If the Home, Recents, or Back functions are provided, they:
63
64*   [C-1-1] MUST be accessible with a single action (e.g. tap, double-click or
65gesture) when any of them are accessible.
66*   [C-1-2] MUST provide a clear indication of which single action would trigger
67each function. Having a visible icon imprinted on the button, showing a software
68icon on the navigation bar portion of the screen, or walking the user through a
69guided step-by-step demo flow during the out-of-box setup experience are
70examples of such an indication.
71
72Device implementations:
73
74*    [SR] are STRONGLY RECOMMENDED to not provide the input mechanism for the
75[Menu function](http://developer.android.com/reference/android/view/KeyEvent.html#`KEYCODE_BACK`)
76as it is deprecated in favor of action bar since Android 4.0.
77
78If device implementations provide the Menu function, they:
79
80*    [C-2-1] MUST display the action overflow button whenever the action
81overflow menu popup is not empty and the action bar is visible.
82*    [C-2-2] MUST NOT modify the position of the action overflow popup
83displayed by selecting the overflow button in the action bar, but MAY render
84the action overflow popup at a modified position on the screen when it is
85displayed by selecting the Menu function.
86
87If device implementations do not provide the Menu function, for backwards
88compatibility, they:
89*    [C-3-1] MUST make the Menu function available to applications when
90`targetSdkVersion` is less than 10, either by a physical button, a software key,
91or gestures. This Menu function should be accessible unless hidden together with
92other navigation functions.
93
94If device implementations provide the [Assist function](http://developer.android.com/reference/android/view/KeyEvent.html#`KEYCODE_ASSIST`),
95they:
96
97*    [C-4-1] MUST make the Assist function accessible with a single action
98(e.g. tap, double-click or gesture) when other navigation keys are accessible.
99*    [SR] STRONGLY RECOMMENDED to use long press on HOME function as this
100designated interaction.
101
102If device implementations use a distinct portion of the screen to display the
103navigation keys, they:
104
105*   [C-5-1] Navigation keys MUST use a distinct portion of the screen, not
106    available to applications, and MUST NOT obscure or otherwise interfere with
107    the portion of the screen available to applications.
108*   [C-5-2] MUST make available a portion of the display to applications that
109    meets the requirements defined in [section 7.1.1](#7_1_1_screen_configuration).
110*   [C-5-3] MUST honor the flags set by the app through the [`View.setSystemUiVisibility()`](https://developer.android.com/reference/android/view/View.html#setSystemUiVisibility%28int%29)
111    API method, so that this distinct portion of the screen
112    (a.k.a. the navigation bar) is properly hidden away as documented in
113    the SDK.
114
115If the navigation function is provided as an on-screen, gesture-based action:
116
117*   [C-6-1]
118    [`WindowInsets#getMandatorySystemGestureInsets()`](https://developer.android.com/reference/android/view/WindowInsets.html#getMandatorySystemGestureInsets())
119    MUST only be used to report the Home gesture recognition area.
120*   [C-6-2] Gestures that start within an exclusion rect as provided by the
121    foreground application via
122    [`View#setSystemGestureExclusionRects()`](https://developer.android.com/reference/android/view/View.html#setSystemGestureExclusionRects(java.util.List%3Candroid.graphics.Rect%3E)),
123    but outside of
124    [`WindowInsets#getMandatorySystemGestureInsets()`](https://developer.android.com/reference/android/view/WindowInsets.html#getMandatorySystemGestureInsets()),
125    MUST NOT be intercepted for the navigation function as long as the exclusion
126    rect is allowed within the max exclusion limit as specified in the
127    documentation for
128    [`View#setSystemGestureExclusionRects()`](https://developer.android.com/reference/android/view/View.html#setSystemGestureExclusionRects(java.util.List%3Candroid.graphics.Rect%3E)).
129*   [C-6-3] MUST send the foreground app a
130    [`MotionEvent.ACTION_CANCEL`](https://developer.android.com/reference/android/view/MotionEvent.html#ACTION_CANCEL)
131    event once touches start being intercepted for a system gesture,
132    if the foreground app was previously sent an
133    [`MotionEvent.ACTION_DOWN`](https://developer.android.com/reference/android/view/MotionEvent.html#ACTION_DOWN)
134    event.
135*   [C-6-4] MUST provide a user affordance to switch to an on-screen,
136    button-based navigation (for example, in Settings).
137*   SHOULD provide Home function as a swipe up from the bottom edge of the
138    current orientation of the screen.
139*   SHOULD provide Recents function as a swipe up and hold before release, from
140    the same area as the Home gesture.
141*   Gestures that start within
142    [`WindowInsets#getMandatorySystemGestureInsets()`](https://developer.android.com/reference/android/view/WindowInsets.html#getMandatorySystemGestureInsets())
143    SHOULD NOT be affected by exclusion rects provided by the foreground
144    application via
145    [`View#setSystemGestureExclusionRects()`](https://developer.android.com/reference/android/view/View.html#setSystemGestureExclusionRects(java.util.List%3Candroid.graphics.Rect%3E)).
146
147If a navigation function is provided from anywhere on the left and right edges
148of the current orientation of the screen:
149
150*   [C-7-1] The navigation function MUST be Back and provided as a swipe from
151    both left and right edges of the current orientation of the screen.
152*   [C-7-2] If custom swipeable system panels are provided on the left or
153    right edges, they MUST be placed within the top 1/3rd of the screen with
154    a clear, persistent visual indication that dragging in would invoke the
155    aforementioned panels, and hence not Back. A system panel MAY be
156    configured by a user such that it lands below the top 1/3rd of the screen
157    edge(s) but the system panel MUST NOT use longer than 1/3rd of the edge(s).
158*   [C-7-3] When the foreground app has either the
159    [`View.SYSTEM_UI_FLAG_IMMERSIVE`](https://developer.android.com/reference/android/view/View.html#SYSTEM_UI_FLAG_IMMERSIVE)
160    or
161    [`View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY`](https://developer.android.com/reference/android/view/View.html#SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
162    flags set, swiping from the edges MUST behave as implemented in AOSP,
163    which is documented in
164    [the SDK](https://developer.android.com/training/system-ui/immersive).
165*   [C-7-4] When the foreground app has either the
166    [`View.SYSTEM_UI_FLAG_IMMERSIVE`](https://developer.android.com/reference/android/view/View.html#SYSTEM_UI_FLAG_IMMERSIVE)
167    or
168    [`View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY`](https://developer.android.com/reference/android/view/View.html#SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
169    flags set, custom swipeable system panels MUST be hidden until the
170    user brings in the system bars (a.k.a. navigation and status bar) as
171    implemented in AOSP.
172
173### 7.2.4\. Touchscreen Input
174
175Android includes support for a variety of pointer input systems, such as
176touchscreens, touch pads, and fake touch input devices.
177[Touchscreen-based device implementations](https://source.android.com/devices/input/touch-devices)
178are associated with a display such that the user has the impression of directly
179manipulating items on screen. Since the user is directly touching the screen,
180the system does not require any additional affordances to indicate the objects
181being manipulated.
182
183Device implementations:
184
185*    SHOULD have a pointer input system of some kind
186     (either mouse-like or touch).
187*    SHOULD support fully independently tracked pointers.
188
189If device implementations include a touchscreen (single-touch or better), they:
190
191*    [C-1-1] MUST report `TOUCHSCREEN_FINGER` for the [`Configuration.touchscreen`](https://developer.android.com/reference/android/content/res/Configuration.html#touchscreen)
192     API field.
193*    [C-1-2] MUST report the `android.hardware.touchscreen` and
194     `android.hardware.faketouch` feature flags.
195
196If device implementations include a touchscreen that can track more than
197a single touch, they:
198
199*    [C-2-1] MUST report the appropriate feature flags  `android.hardware.touchscreen.multitouch`,
200`android.hardware.touchscreen.multitouch.distinct`, `android.hardware.touchscreen.multitouch.jazzhand`
201corresponding to the type of the specific touchscreen on the device.
202
203If device implementations do not include a touchscreen (and rely on a pointer
204device only) and meet the fake touch requirements in
205[section 7.2.5](#7_2_5_fake_touch_input), they:
206
207*    [C-3-1] MUST NOT report any feature flag starting with
208`android.hardware.touchscreen` and MUST report only `android.hardware.faketouch`.
209
210### 7.2.5\. Fake Touch Input
211
212Fake touch interface provides a user input system that approximates a subset of
213touchscreen capabilities. For example, a  mouse or remote control that drives
214an on-screen cursor approximates touch, but requires the user to first point or
215focus then click. Numerous input devices like the mouse, trackpad, gyro-based
216air mouse, gyro-pointer, joystick, and multi-touch trackpad can support fake
217touch interactions. Android includes the feature constant
218android.hardware.faketouch, which corresponds to a high-fidelity non-touch
219(pointer-based) input device such as a mouse or trackpad that can adequately
220emulate touch-based input (including basic gesture support), and indicates that
221the device supports an emulated subset of touchscreen functionality.
222
223If device implementations do not include a touchscreen but include another
224pointer input system which they want to make available, they:
225
226*    SHOULD declare support for the `android.hardware.faketouch` feature flag.
227
228If device implementations declare support for `android.hardware.faketouch`,
229they:
230
231*   [C-1-1] MUST report the [absolute X and Y screen positions](
232http://developer.android.com/reference/android/view/MotionEvent.html)
233of the pointer location and display a visual pointer on the screen.
234*   [C-1-2] MUST report touch event with the action code that specifies the
235state change that occurs on the pointer [going down or up on the
236screen](http://developer.android.com/reference/android/view/MotionEvent.html).
237*   [C-1-3] MUST support pointer down and up on an object on the screen, which
238allows users to emulate tap on an object on the screen.
239*   [C-1-4] MUST support pointer down, pointer up, pointer down then pointer up
240in the same place on an object on the screen within a time threshold, which
241allows users to [emulate double tap](
242http://developer.android.com/reference/android/view/MotionEvent.html)
243on an object on the screen.
244*   [C-1-5] MUST support pointer down on an arbitrary point on the screen,
245pointer move to any other arbitrary point on the screen, followed by a pointer
246up, which allows users to emulate a touch drag.
247*   [C-1-6] MUST support pointer down then allow users to quickly move the
248object to a different position on the screen and then pointer up on the screen,
249which allows users to fling an object on the screen.
250*   [C-1-7] MUST report `TOUCHSCREEN_NOTOUCH` for the [`Configuration.touchscreen`](https://developer.android.com/reference/android/content/res/Configuration.html#touchscreen)
251API field.
252
253If device implementations declare support for
254`android.hardware.faketouch.multitouch.distinct`, they:
255
256*    [C-2-1] MUST declare support for `android.hardware.faketouch`.
257*    [C-2-2] MUST support distinct tracking of two or more independent pointer
258inputs.
259
260If device implementations declare support for
261`android.hardware.faketouch.multitouch.jazzhand`, they:
262
263*    [C-3-1] MUST declare support for `android.hardware.faketouch`.
264*    [C-3-2] MUST support distinct tracking of 5 (tracking a hand of fingers)
265or more pointer inputs fully independently.
266
267### 7.2.6\. Game Controller Support
268
269#### 7.2.6.1\. Button Mappings
270
271If device implementations declare the `android.hardware.gamepad` feature flag,
272they:
273
274*    [C-1-1] MUST have embed a controller or ship with a separate controller
275in the box, that would provide means to input all the events listed in the
276below tables.
277*    [C-1-2] MUST be capable to map HID events to it's associated Android
278`view.InputEvent` constants as listed in the below tables. The upstream Android
279implementation includes implementation for game controllers that satisfies this
280requirement.
281
282<table>
283 <tr>
284    <th>Button</th>
285    <th>HID Usage<sup>2</sup></th>
286    <th>Android Button</th>
287 </tr>
288 <tr>
289    <td><a href="http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_BUTTON_A">A</a><sup>1</sup></td>
290    <td>0x09 0x0001</td>
291    <td>KEYCODE_BUTTON_A (96)</td>
292 </tr>
293 <tr>
294    <td><a href="http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_BUTTON_B">B</a><sup>1</sup></td>
295    <td>0x09 0x0002</td>
296    <td>KEYCODE_BUTTON_B (97)</td>
297 </tr>
298 <tr>
299    <td><a href="http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_BUTTON_X">X</a><sup>1</sup></td>
300    <td>0x09 0x0004</td>
301    <td>KEYCODE_BUTTON_X (99)</td>
302 </tr>
303 <tr>
304    <td><a href="http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_BUTTON_Y">Y</a><sup>1</sup></td>
305    <td>0x09 0x0005</td>
306    <td>KEYCODE_BUTTON_Y (100)</td>
307 </tr>
308 <tr>
309    <td><a href="http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_DPAD_UP">D-pad up</a><sup>1</sup><br />
310
311<a href="http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_DPAD_DOWN">D-pad down</a><sup>1</sup></td>
312    <td>0x01 0x0039<sup>3</sup></td>
313    <td><a href="http://developer.android.com/reference/android/view/MotionEvent.html#AXIS_HAT_Y">AXIS_HAT_Y</a><sup>4</sup></td>
314 </tr>
315 <tr>
316    <td><a href="http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_DPAD_LEFT">D-pad left</a>1<br />
317
318<a href="http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_DPAD_RIGHT">D-pad right</a><sup>1</sup></td>
319    <td>0x01 0x0039<sup>3</sup></td>
320    <td><a href="http://developer.android.com/reference/android/view/MotionEvent.html#AXIS_HAT_X">AXIS_HAT_X</a><sup>4</sup></td>
321 </tr>
322 <tr>
323    <td><a href="http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_BUTTON_L1">Left shoulder button</a><sup>1</sup></td>
324    <td>0x09 0x0007</td>
325    <td>KEYCODE_BUTTON_L1 (102)</td>
326 </tr>
327 <tr>
328    <td><a href="http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_BUTTON_R1">Right shoulder button</a><sup>1</sup></td>
329    <td>0x09 0x0008</td>
330    <td>KEYCODE_BUTTON_R1 (103)</td>
331 </tr>
332 <tr>
333    <td><a href="http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_BUTTON_THUMBL">Left stick click</a><sup>1</sup></td>
334    <td>0x09 0x000E</td>
335    <td>KEYCODE_BUTTON_THUMBL (106)</td>
336 </tr>
337 <tr>
338    <td><a href="http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_BUTTON_THUMBR">Right stick click</a><sup>1</sup></td>
339    <td>0x09 0x000F</td>
340    <td>KEYCODE_BUTTON_THUMBR (107)</td>
341 </tr>
342 <tr>
343    <td><a href="http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_HOME">Home</a><sup>1</sup></td>
344    <td>0x0c 0x0223</td>
345    <td>KEYCODE_HOME (3)</td>
346 </tr>
347 <tr>
348    <td><a href="http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_BACK">Back</a><sup>1</sup></td>
349    <td>0x0c 0x0224</td>
350    <td>KEYCODE_BACK (4)</td>
351 </tr>
352</table>
353
354
355<p class="table_footnote">1 <a href="http://developer.android.com/reference/android/view/KeyEvent.html">KeyEvent</a></p>
356
357<p class="table_footnote">2 The above HID usages must be declared within a Game
358pad CA (0x01 0x0005).</p>
359
360<p class="table_footnote">3 This usage must have a Logical Minimum of 0, a
361Logical Maximum of 7, a Physical Minimum of 0, a Physical Maximum of 315, Units
362in Degrees, and a Report Size of 4. The logical value is defined to be the
363clockwise rotation away from the vertical axis; for example, a logical value of
3640 represents no rotation and the up button being pressed, while a logical value
365of 1 represents a rotation of 45 degrees and both the up and left keys being
366pressed.</p>
367
368<p class="table_footnote">4 <a
369href="http://developer.android.com/reference/android/view/MotionEvent.html">MotionEvent</a></p>
370
371<table>
372 <tr>
373    <th>Analog Controls<sup>1</sup></th>
374    <th>HID Usage</th>
375    <th>Android Button</th>
376 </tr>
377 <tr>
378    <td><a href="http://developer.android.com/reference/android/view/MotionEvent.html#AXIS_LTRIGGER">Left Trigger</a></td>
379    <td>0x02 0x00C5</td>
380    <td>AXIS_LTRIGGER </td>
381 </tr>
382 <tr>
383    <td><a href="http://developer.android.com/reference/android/view/MotionEvent.html#AXIS_THROTTLE">Right Trigger</a></td>
384    <td>0x02 0x00C4</td>
385    <td>AXIS_RTRIGGER </td>
386 </tr>
387 <tr>
388    <td><a href="http://developer.android.com/reference/android/view/MotionEvent.html#AXIS_Y">Left Joystick</a></td>
389    <td>0x01 0x0030<br />
390
3910x01 0x0031</td>
392    <td>AXIS_X<br />
393
394AXIS_Y</td>
395 </tr>
396 <tr>
397    <td><a href="http://developer.android.com/reference/android/view/MotionEvent.html#AXIS_Z">Right Joystick</a></td>
398    <td>0x01 0x0032<br />
399
4000x01 0x0035</td>
401    <td>AXIS_Z<br />
402
403AXIS_RZ</td>
404 </tr>
405</table>
406
407
408<p class="table_footnote">1 <a
409href="http://developer.android.com/reference/android/view/MotionEvent.html">MotionEvent</a></p>
410
411### 7.2.7\. Remote Control
412
413See [Section 2.3.1](#2_3_1_hardware) for device-specific requirements.
414