blob: e8746d000e4a25933cdca8b1fd199ee9ee2f306b [file] [log] [blame]
Siarhei Vishniakou70622952020-07-30 11:17:23 -05001/**
2 * Copyright (c) 2020, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.os;
18
19
20/** @hide */
21interface IInputConstants
22{
Peter Collingbourneb04b9b82021-02-08 12:09:47 -080023 // This should be multiplied by the value of the system property ro.hw_timeout_multiplier before
24 // use. A pre-multiplied constant is available in Java in
25 // android.os.InputConstants.DEFAULT_DISPATCHING_TIMEOUT_MILLIS.
26 const int UNMULTIPLIED_DEFAULT_DISPATCHING_TIMEOUT_MILLIS = 5000; // 5 seconds
Siarhei Vishniakou2508b872020-12-03 16:33:53 -100027
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -100028 // Indicate invalid battery capacity
29 const int INVALID_BATTERY_CAPACITY = -1;
30
31 /**
32 * Every input event has an id. This constant value is used when a valid input event id is not
33 * available.
34 */
35 const int INVALID_INPUT_EVENT_ID = 0;
Siarhei Vishniakou5d552c42021-05-21 05:02:22 +000036
37 /**
Sandro Meierd3d40602022-10-19 16:18:26 +000038 * Every input device has an id. This constant value is used when a valid input device id is not
39 * available.
40 * The virtual keyboard uses -1 as the input device id. Therefore, we use -2 as the value for
41 * an invalid input device.
42 */
43 const int INVALID_INPUT_DEVICE_ID = -2;
44
45 /**
Siarhei Vishniakouf00a4ec2021-06-16 03:55:32 +000046 * The input event was injected from accessibility. Used in policyFlags for input event
47 * injection.
Siarhei Vishniakou5d552c42021-05-21 05:02:22 +000048 */
49 const int POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY = 0x20000;
Siarhei Vishniakouf00a4ec2021-06-16 03:55:32 +000050
51 /**
Siarhei Vishniakouc40f6e02024-04-25 15:49:29 -070052 * This flag indicates that the window that received this motion event is partly
53 * or wholly obscured by another visible window above it and the event directly passed through
54 * the obscured area.
55 *
56 * A security sensitive application can check this flag to identify situations in which
57 * a malicious application may have covered up part of its content for the purpose
58 * of misleading the user or hijacking touches. An appropriate response might be
59 * to drop the suspect touches or to take additional precautions to confirm the user's
60 * actual intent.
61 */
62 const int MOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1;
63
64 /**
65 * This flag indicates that the window that received this motion event is partly
66 * or wholly obscured by another visible window above it and the event did not directly pass
67 * through the obscured area.
68 *
69 * A security sensitive application can check this flag to identify situations in which
70 * a malicious application may have covered up part of its content for the purpose
71 * of misleading the user or hijacking touches. An appropriate response might be
72 * to drop the suspect touches or to take additional precautions to confirm the user's
73 * actual intent.
74 *
75 * Unlike FLAG_WINDOW_IS_OBSCURED, this is only true if the window that received this event is
76 * obstructed in areas other than the touched location.
77 */
78 const int MOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED = 0x2;
79
80 /**
81 * This private flag is only set on {@link #ACTION_HOVER_MOVE} events and indicates that
82 * this event will be immediately followed by a {@link #ACTION_HOVER_EXIT}. It is used to
83 * prevent generating redundant {@link #ACTION_HOVER_ENTER} events.
84 * @hide
85 */
86 const int MOTION_EVENT_FLAG_HOVER_EXIT_PENDING = 0x4;
87
88 /**
89 * This flag indicates that the event has been generated by a gesture generator. It
90 * provides a hint to the GestureDetector to not apply any touch slop.
91 *
92 * @hide
93 */
94 const int MOTION_EVENT_FLAG_IS_GENERATED_GESTURE = 0x8;
95
96 /**
97 * This flag is only set for events with {@link #ACTION_POINTER_UP} and {@link #ACTION_CANCEL}.
98 * It indicates that the pointer going up was an unintentional user touch. When FLAG_CANCELED
99 * is set, the typical actions that occur in response for a pointer going up (such as click
100 * handlers, end of drawing) should be aborted. This flag is typically set when the user was
101 * accidentally touching the screen, such as by gripping the device, or placing the palm on the
102 * screen.
103 *
104 * @see #ACTION_POINTER_UP
105 * @see #ACTION_CANCEL
106 */
107 const int INPUT_EVENT_FLAG_CANCELED = 0x20;
108
109 /**
110 * This flag indicates that the event will not cause a focus change if it is directed to an
111 * unfocused window, even if it an {@link #ACTION_DOWN}. This is typically used with pointer
112 * gestures to allow the user to direct gestures to an unfocused window without bringing the
113 * window into focus.
114 * @hide
115 */
116 const int MOTION_EVENT_FLAG_NO_FOCUS_CHANGE = 0x40;
117
118 /**
Siarhei Vishniakouf00a4ec2021-06-16 03:55:32 +0000119 * The input event was generated or modified by accessibility service.
120 * Shared by both KeyEvent and MotionEvent flags, so this value should not overlap with either
121 * set of flags, including in input/Input.h and in android/input.h.
122 */
123 const int INPUT_EVENT_FLAG_IS_ACCESSIBILITY_EVENT = 0x800;
Prabir Pradhande788502021-12-22 00:26:07 -0800124
Siarhei Vishniakouc40f6e02024-04-25 15:49:29 -0700125 /**
126 * Private flag that indicates when the system has detected that this motion event
127 * may be inconsistent with respect to the sequence of previously delivered motion events,
128 * such as when a pointer move event is sent but the pointer is not down.
129 *
130 * @hide
131 * @see #isTainted
132 * @see #setTainted
133 */
134 const int INPUT_EVENT_FLAG_TAINTED = 0x80000000;
135
136 /**
137 * Private flag indicating that this event was synthesized by the system and should be delivered
138 * to the accessibility focused view first. When being dispatched such an event is not handled
139 * by predecessors of the accessibility focused view and after the event reaches that view the
140 * flag is cleared and normal event dispatch is performed. This ensures that the platform can
141 * click on any view that has accessibility focus which is semantically equivalent to asking the
142 * view to perform a click accessibility action but more generic as views not implementing click
143 * action correctly can still be activated.
144 *
145 * @hide
146 * @see #isTargetAccessibilityFocus()
147 * @see #setTargetAccessibilityFocus(boolean)
148 */
149 const int MOTION_EVENT_FLAG_TARGET_ACCESSIBILITY_FOCUS = 0x40000000;
150
Christine Franks46d8a1e2022-01-05 16:11:48 -0800151 /* The default pointer acceleration value. */
152 const int DEFAULT_POINTER_ACCELERATION = 3;
Siarhei Vishniakouf7436a12023-08-14 15:17:11 -0700153
154 /**
155 * Use the default Velocity Tracker Strategy. Different axes may use different default
156 * strategies.
157 */
158 const int VELOCITY_TRACKER_STRATEGY_DEFAULT = -1;
159
160 /**
161 * Velocity Tracker Strategy: Impulse.
162 * Physical model of pushing an object. Quality: VERY GOOD.
163 * Works with duplicate coordinates, unclean finger liftoff.
164 */
165 const int VELOCITY_TRACKER_STRATEGY_IMPULSE = 0;
166
167 /**
168 * Velocity Tracker Strategy: LSQ1.
169 * 1st order least squares. Quality: POOR.
170 * Frequently underfits the touch data especially when the finger accelerates
171 * or changes direction. Often underestimates velocity. The direction
172 * is overly influenced by historical touch points.
173 */
174 const int VELOCITY_TRACKER_STRATEGY_LSQ1 = 1;
175
176 /**
177 * Velocity Tracker Strategy: LSQ2.
178 * 2nd order least squares. Quality: VERY GOOD.
179 * Pretty much ideal, but can be confused by certain kinds of touch data,
180 * particularly if the panel has a tendency to generate delayed,
181 * duplicate or jittery touch coordinates when the finger is released.
182 */
183 const int VELOCITY_TRACKER_STRATEGY_LSQ2 = 2;
184
185 /**
186 * Velocity Tracker Strategy: LSQ3.
187 * 3rd order least squares. Quality: UNUSABLE.
188 * Frequently overfits the touch data yielding wildly divergent estimates
189 * of the velocity when the finger is released.
190 */
191 const int VELOCITY_TRACKER_STRATEGY_LSQ3 = 3;
192
193 /**
194 * Velocity Tracker Strategy: WLSQ2_DELTA.
195 * 2nd order weighted least squares, delta weighting. Quality: EXPERIMENTAL
196 */
197 const int VELOCITY_TRACKER_STRATEGY_WLSQ2_DELTA = 4;
198
199 /**
200 * Velocity Tracker Strategy: WLSQ2_CENTRAL.
201 * 2nd order weighted least squares, central weighting. Quality: EXPERIMENTALe
202 */
203 const int VELOCITY_TRACKER_STRATEGY_WLSQ2_CENTRAL = 5;
204
205 /**
206 * Velocity Tracker Strategy: WLSQ2_RECENT.
207 * 2nd order weighted least squares, recent weighting. Quality: EXPERIMENTAL
208 */
209 const int VELOCITY_TRACKER_STRATEGY_WLSQ2_RECENT = 6;
210
211 /**
212 * Velocity Tracker Strategy: INT1.
213 * 1st order integrating filter. Quality: GOOD.
214 * Not as good as 'lsq2' because it cannot estimate acceleration but it is
215 * more tolerant of errors. Like 'lsq1', this strategy tends to underestimate
216 * the velocity of a fling but this strategy tends to respond to changes in
217 * direction more quickly and accurately.
218 */
219 const int VELOCITY_TRACKER_STRATEGY_INT1 = 7;
220
221 /**
222 * Velocity Tracker Strategy: INT2.
223 * 2nd order integrating filter. Quality: EXPERIMENTAL.
224 * For comparison purposes only. Unlike 'int1' this strategy can compensate
225 * for acceleration but it typically overestimates the effect.
226 */
227 const int VELOCITY_TRACKER_STRATEGY_INT2 = 8;
228
229 /**
230 * Velocity Tracker Strategy: Legacy.
231 * Legacy velocity tracker algorithm. Quality: POOR.
232 * For comparison purposes only. This algorithm is strongly influenced by
233 * old data points, consistently underestimates velocity and takes a very long
234 * time to adjust to changes in direction.
235 */
236 const int VELOCITY_TRACKER_STRATEGY_LEGACY = 9;
Vaibhav Devmurarie58ffb92024-05-22 17:38:25 +0000237
238
239 /*
240 * Input device class: Keyboard
241 * The input device is a keyboard or has buttons.
242 *
243 * @hide
244 */
245 const int DEVICE_CLASS_KEYBOARD = 0x00000001;
246
247 /*
248 * Input device class: Alphakey
249 * The input device is an alpha-numeric keyboard (not just a dial pad).
250 *
251 * @hide
252 */
253 const int DEVICE_CLASS_ALPHAKEY = 0x00000002;
254
255 /*
256 * Input device class: Touch
257 * The input device is a touchscreen or a touchpad (either single-touch or multi-touch).
258 *
259 * @hide
260 */
261 const int DEVICE_CLASS_TOUCH = 0x00000004;
262
263 /*
264 * Input device class: Cursor
265 * The input device is a cursor device such as a trackball or mouse.
266 *
267 * @hide
268 */
269 const int DEVICE_CLASS_CURSOR = 0x00000008;
270
271 /*
272 * Input device class: Multi-touch
273 * The input device is a multi-touch touchscreen or touchpad.
274 *
275 * @hide
276 */
277 const int DEVICE_CLASS_TOUCH_MT = 0x00000010;
278
279 /*
280 * Input device class: Dpad
281 * The input device is a directional pad (implies keyboard, has DPAD keys).
282 *
283 * @hide
284 */
285 const int DEVICE_CLASS_DPAD = 0x00000020;
286
287 /*
288 * Input device class: Gamepad
289 * The input device is a gamepad (implies keyboard, has BUTTON keys).
290 *
291 * @hide
292 */
293 const int DEVICE_CLASS_GAMEPAD = 0x00000040;
294
295 /*
296 * Input device class: Switch
297 * The input device has switches.
298 *
299 * @hide
300 */
301 const int DEVICE_CLASS_SWITCH = 0x00000080;
302
303 /*
304 * Input device class: Joystick
305 * The input device is a joystick (implies gamepad, has joystick absolute axes).
306 *
307 * @hide
308 */
309 const int DEVICE_CLASS_JOYSTICK = 0x00000100;
310
311 /*
312 * Input device class: Vibrator
313 * The input device has a vibrator (supports FF_RUMBLE).
314 *
315 * @hide
316 */
317 const int DEVICE_CLASS_VIBRATOR = 0x00000200;
318
319 /*
320 * Input device class: Mic
321 * The input device has a microphone.
322 *
323 * @hide
324 */
325 const int DEVICE_CLASS_MIC = 0x00000400;
326
327 /*
328 * Input device class: External Stylus
329 * The input device is an external stylus (has data we want to fuse with touch data).
330 *
331 * @hide
332 */
333 const int DEVICE_CLASS_EXTERNAL_STYLUS = 0x00000800;
334
335 /*
336 * Input device class: Rotary Encoder
337 * The input device has a rotary encoder.
338 *
339 * @hide
340 */
341 const int DEVICE_CLASS_ROTARY_ENCODER = 0x00001000;
342
343 /*
344 * Input device class: Sensor
345 * The input device has a sensor like accelerometer, gyro, etc.
346 *
347 * @hide
348 */
349 const int DEVICE_CLASS_SENSOR = 0x00002000;
350
351 /*
352 * Input device class: Battery
353 * The input device has a battery.
354 *
355 * @hide
356 */
357 const int DEVICE_CLASS_BATTERY = 0x00004000;
358
359 /*
360 * Input device class: Light
361 * The input device has sysfs controllable lights.
362 *
363 * @hide
364 */
365 const int DEVICE_CLASS_LIGHT = 0x00008000;
366
367 /*
368 * Input device class: Touchpad
369 * The input device is a touchpad, requiring an on-screen cursor.
370 *
371 * @hide
372 */
373 const int DEVICE_CLASS_TOUCHPAD = 0x00010000;
374
375 /*
376 * Input device class: Virtual
377 * The input device is virtual (not a real device, not part of UI configuration).
378 *
379 * @hide
380 */
381 const int DEVICE_CLASS_VIRTUAL = 0x20000000;
382
383 /*
384 * Input device class: External
385 * The input device is external (not built-in).
386 *
387 * @hide
388 */
389 const int DEVICE_CLASS_EXTERNAL = 0x40000000;
Siarhei Vishniakou70622952020-07-30 11:17:23 -0500390}