blob: 5aa3e51b562a27a750f130b72fe112d59c0547e2 [file] [log] [blame]
Michael Wright5113aff2015-02-13 17:31:41 -08001/*
2 * Copyright (C) 2015 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
17#ifndef ANDROID_INCLUDE_HARDWARE_INPUT_H
18#define ANDROID_INCLUDE_HARDWARE_INPUT_H
19
20#include <hardware/hardware.h>
21#include <stdint.h>
22
23__BEGIN_DECLS
24
25#define INPUT_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
26#define INPUT_HARDWARE_MODULE_ID "input"
27
28#define INPUT_INSTANCE_EVDEV "evdev"
29
30typedef enum input_bus {
31 INPUT_BUS_BT,
32 INPUT_BUS_USB,
33 INPUT_BUS_SERIAL,
34 INPUT_BUS_BUILTIN
35} input_bus_t;
36
37typedef struct input_host input_host_t;
38
39typedef struct input_device_handle input_device_handle_t;
40
41typedef struct input_device_identifier input_device_identifier_t;
42
43typedef struct input_device_definition input_device_definition_t;
44
45typedef struct input_report_definition input_report_definition_t;
46
47typedef struct input_report input_report_t;
48
49typedef struct input_collection input_collection_t;
50
51typedef enum {
Tim Kilbournaaf6b262015-02-27 15:01:50 -080052 // keycodes
53 INPUT_USAGE_KEYCODE_UNKNOWN,
54 INPUT_USAGE_KEYCODE_SOFT_LEFT,
55 INPUT_USAGE_KEYCODE_SOFT_RIGHT,
56 INPUT_USAGE_KEYCODE_HOME,
57 INPUT_USAGE_KEYCODE_BACK,
58 INPUT_USAGE_KEYCODE_CALL,
59 INPUT_USAGE_KEYCODE_ENDCALL,
60 INPUT_USAGE_KEYCODE_0,
61 INPUT_USAGE_KEYCODE_1,
62 INPUT_USAGE_KEYCODE_2,
63 INPUT_USAGE_KEYCODE_3,
64 INPUT_USAGE_KEYCODE_4,
65 INPUT_USAGE_KEYCODE_5,
66 INPUT_USAGE_KEYCODE_6,
67 INPUT_USAGE_KEYCODE_7,
68 INPUT_USAGE_KEYCODE_8,
69 INPUT_USAGE_KEYCODE_9,
70 INPUT_USAGE_KEYCODE_STAR,
71 INPUT_USAGE_KEYCODE_POUND,
72 INPUT_USAGE_KEYCODE_DPAD_UP,
73 INPUT_USAGE_KEYCODE_DPAD_DOWN,
74 INPUT_USAGE_KEYCODE_DPAD_LEFT,
75 INPUT_USAGE_KEYCODE_DPAD_RIGHT,
76 INPUT_USAGE_KEYCODE_DPAD_CENTER,
77 INPUT_USAGE_KEYCODE_VOLUME_UP,
78 INPUT_USAGE_KEYCODE_VOLUME_DOWN,
79 INPUT_USAGE_KEYCODE_POWER,
80 INPUT_USAGE_KEYCODE_CAMERA,
81 INPUT_USAGE_KEYCODE_CLEAR,
82 INPUT_USAGE_KEYCODE_A,
83 INPUT_USAGE_KEYCODE_B,
84 INPUT_USAGE_KEYCODE_C,
85 INPUT_USAGE_KEYCODE_D,
86 INPUT_USAGE_KEYCODE_E,
87 INPUT_USAGE_KEYCODE_F,
88 INPUT_USAGE_KEYCODE_G,
89 INPUT_USAGE_KEYCODE_H,
90 INPUT_USAGE_KEYCODE_I,
91 INPUT_USAGE_KEYCODE_J,
92 INPUT_USAGE_KEYCODE_K,
93 INPUT_USAGE_KEYCODE_L,
94 INPUT_USAGE_KEYCODE_M,
95 INPUT_USAGE_KEYCODE_N,
96 INPUT_USAGE_KEYCODE_O,
97 INPUT_USAGE_KEYCODE_P,
98 INPUT_USAGE_KEYCODE_Q,
99 INPUT_USAGE_KEYCODE_R,
100 INPUT_USAGE_KEYCODE_S,
101 INPUT_USAGE_KEYCODE_T,
102 INPUT_USAGE_KEYCODE_U,
103 INPUT_USAGE_KEYCODE_V,
104 INPUT_USAGE_KEYCODE_W,
105 INPUT_USAGE_KEYCODE_X,
106 INPUT_USAGE_KEYCODE_Y,
107 INPUT_USAGE_KEYCODE_Z,
108 INPUT_USAGE_KEYCODE_COMMA,
109 INPUT_USAGE_KEYCODE_PERIOD,
110 INPUT_USAGE_KEYCODE_ALT_LEFT,
111 INPUT_USAGE_KEYCODE_ALT_RIGHT,
112 INPUT_USAGE_KEYCODE_SHIFT_LEFT,
113 INPUT_USAGE_KEYCODE_SHIFT_RIGHT,
114 INPUT_USAGE_KEYCODE_TAB,
115 INPUT_USAGE_KEYCODE_SPACE,
116 INPUT_USAGE_KEYCODE_SYM,
117 INPUT_USAGE_KEYCODE_EXPLORER,
118 INPUT_USAGE_KEYCODE_ENVELOPE,
119 INPUT_USAGE_KEYCODE_ENTER,
120 INPUT_USAGE_KEYCODE_DEL,
121 INPUT_USAGE_KEYCODE_GRAVE,
122 INPUT_USAGE_KEYCODE_MINUS,
123 INPUT_USAGE_KEYCODE_EQUALS,
124 INPUT_USAGE_KEYCODE_LEFT_BRACKET,
125 INPUT_USAGE_KEYCODE_RIGHT_BRACKET,
126 INPUT_USAGE_KEYCODE_BACKSLASH,
127 INPUT_USAGE_KEYCODE_SEMICOLON,
128 INPUT_USAGE_KEYCODE_APOSTROPHE,
129 INPUT_USAGE_KEYCODE_SLASH,
130 INPUT_USAGE_KEYCODE_AT,
131 INPUT_USAGE_KEYCODE_NUM,
132 INPUT_USAGE_KEYCODE_HEADSETHOOK,
133 INPUT_USAGE_KEYCODE_FOCUS, // *Camera* focus
134 INPUT_USAGE_KEYCODE_PLUS,
135 INPUT_USAGE_KEYCODE_MENU,
136 INPUT_USAGE_KEYCODE_NOTIFICATION,
137 INPUT_USAGE_KEYCODE_SEARCH,
138 INPUT_USAGE_KEYCODE_MEDIA_PLAY_PAUSE,
139 INPUT_USAGE_KEYCODE_MEDIA_STOP,
140 INPUT_USAGE_KEYCODE_MEDIA_NEXT,
141 INPUT_USAGE_KEYCODE_MEDIA_PREVIOUS,
142 INPUT_USAGE_KEYCODE_MEDIA_REWIND,
143 INPUT_USAGE_KEYCODE_MEDIA_FAST_FORWARD,
144 INPUT_USAGE_KEYCODE_MUTE,
145 INPUT_USAGE_KEYCODE_PAGE_UP,
146 INPUT_USAGE_KEYCODE_PAGE_DOWN,
147 INPUT_USAGE_KEYCODE_PICTSYMBOLS,
148 INPUT_USAGE_KEYCODE_SWITCH_CHARSET,
149 INPUT_USAGE_KEYCODE_BUTTON_A,
150 INPUT_USAGE_KEYCODE_BUTTON_B,
151 INPUT_USAGE_KEYCODE_BUTTON_C,
152 INPUT_USAGE_KEYCODE_BUTTON_X,
153 INPUT_USAGE_KEYCODE_BUTTON_Y,
154 INPUT_USAGE_KEYCODE_BUTTON_Z,
155 INPUT_USAGE_KEYCODE_BUTTON_L1,
156 INPUT_USAGE_KEYCODE_BUTTON_R1,
157 INPUT_USAGE_KEYCODE_BUTTON_L2,
158 INPUT_USAGE_KEYCODE_BUTTON_R2,
159 INPUT_USAGE_KEYCODE_BUTTON_THUMBL,
160 INPUT_USAGE_KEYCODE_BUTTON_THUMBR,
161 INPUT_USAGE_KEYCODE_BUTTON_START,
162 INPUT_USAGE_KEYCODE_BUTTON_SELECT,
163 INPUT_USAGE_KEYCODE_BUTTON_MODE,
164 INPUT_USAGE_KEYCODE_ESCAPE,
165 INPUT_USAGE_KEYCODE_FORWARD_DEL,
166 INPUT_USAGE_KEYCODE_CTRL_LEFT,
167 INPUT_USAGE_KEYCODE_CTRL_RIGHT,
168 INPUT_USAGE_KEYCODE_CAPS_LOCK,
169 INPUT_USAGE_KEYCODE_SCROLL_LOCK,
170 INPUT_USAGE_KEYCODE_META_LEFT,
171 INPUT_USAGE_KEYCODE_META_RIGHT,
172 INPUT_USAGE_KEYCODE_FUNCTION,
173 INPUT_USAGE_KEYCODE_SYSRQ,
174 INPUT_USAGE_KEYCODE_BREAK,
175 INPUT_USAGE_KEYCODE_MOVE_HOME,
176 INPUT_USAGE_KEYCODE_MOVE_END,
177 INPUT_USAGE_KEYCODE_INSERT,
178 INPUT_USAGE_KEYCODE_FORWARD,
179 INPUT_USAGE_KEYCODE_MEDIA_PLAY,
180 INPUT_USAGE_KEYCODE_MEDIA_PAUSE,
181 INPUT_USAGE_KEYCODE_MEDIA_CLOSE,
182 INPUT_USAGE_KEYCODE_MEDIA_EJECT,
183 INPUT_USAGE_KEYCODE_MEDIA_RECORD,
184 INPUT_USAGE_KEYCODE_F1,
185 INPUT_USAGE_KEYCODE_F2,
186 INPUT_USAGE_KEYCODE_F3,
187 INPUT_USAGE_KEYCODE_F4,
188 INPUT_USAGE_KEYCODE_F5,
189 INPUT_USAGE_KEYCODE_F6,
190 INPUT_USAGE_KEYCODE_F7,
191 INPUT_USAGE_KEYCODE_F8,
192 INPUT_USAGE_KEYCODE_F9,
193 INPUT_USAGE_KEYCODE_F10,
194 INPUT_USAGE_KEYCODE_F11,
195 INPUT_USAGE_KEYCODE_F12,
196 INPUT_USAGE_KEYCODE_NUM_LOCK,
197 INPUT_USAGE_KEYCODE_NUMPAD_0,
198 INPUT_USAGE_KEYCODE_NUMPAD_1,
199 INPUT_USAGE_KEYCODE_NUMPAD_2,
200 INPUT_USAGE_KEYCODE_NUMPAD_3,
201 INPUT_USAGE_KEYCODE_NUMPAD_4,
202 INPUT_USAGE_KEYCODE_NUMPAD_5,
203 INPUT_USAGE_KEYCODE_NUMPAD_6,
204 INPUT_USAGE_KEYCODE_NUMPAD_7,
205 INPUT_USAGE_KEYCODE_NUMPAD_8,
206 INPUT_USAGE_KEYCODE_NUMPAD_9,
207 INPUT_USAGE_KEYCODE_NUMPAD_DIVIDE,
208 INPUT_USAGE_KEYCODE_NUMPAD_MULTIPLY,
209 INPUT_USAGE_KEYCODE_NUMPAD_SUBTRACT,
210 INPUT_USAGE_KEYCODE_NUMPAD_ADD,
211 INPUT_USAGE_KEYCODE_NUMPAD_DOT,
212 INPUT_USAGE_KEYCODE_NUMPAD_COMMA,
213 INPUT_USAGE_KEYCODE_NUMPAD_ENTER,
214 INPUT_USAGE_KEYCODE_NUMPAD_EQUALS,
215 INPUT_USAGE_KEYCODE_NUMPAD_LEFT_PAREN,
216 INPUT_USAGE_KEYCODE_NUMPAD_RIGHT_PAREN,
217 INPUT_USAGE_KEYCODE_VOLUME_MUTE,
218 INPUT_USAGE_KEYCODE_INFO,
219 INPUT_USAGE_KEYCODE_CHANNEL_UP,
220 INPUT_USAGE_KEYCODE_CHANNEL_DOWN,
221 INPUT_USAGE_KEYCODE_ZOOM_IN,
222 INPUT_USAGE_KEYCODE_ZOOM_OUT,
223 INPUT_USAGE_KEYCODE_TV,
224 INPUT_USAGE_KEYCODE_WINDOW,
225 INPUT_USAGE_KEYCODE_GUIDE,
226 INPUT_USAGE_KEYCODE_DVR,
227 INPUT_USAGE_KEYCODE_BOOKMARK,
228 INPUT_USAGE_KEYCODE_CAPTIONS,
229 INPUT_USAGE_KEYCODE_SETTINGS,
230 INPUT_USAGE_KEYCODE_TV_POWER,
231 INPUT_USAGE_KEYCODE_TV_INPUT,
232 INPUT_USAGE_KEYCODE_STB_POWER,
233 INPUT_USAGE_KEYCODE_STB_INPUT,
234 INPUT_USAGE_KEYCODE_AVR_POWER,
235 INPUT_USAGE_KEYCODE_AVR_INPUT,
236 INPUT_USAGE_KEYCODE_PROG_RED,
237 INPUT_USAGE_KEYCODE_PROG_GREEN,
238 INPUT_USAGE_KEYCODE_PROG_YELLOW,
239 INPUT_USAGE_KEYCODE_PROG_BLUE,
240 INPUT_USAGE_KEYCODE_APP_SWITCH,
241 INPUT_USAGE_KEYCODE_BUTTON_1,
242 INPUT_USAGE_KEYCODE_BUTTON_2,
243 INPUT_USAGE_KEYCODE_BUTTON_3,
244 INPUT_USAGE_KEYCODE_BUTTON_4,
245 INPUT_USAGE_KEYCODE_BUTTON_5,
246 INPUT_USAGE_KEYCODE_BUTTON_6,
247 INPUT_USAGE_KEYCODE_BUTTON_7,
248 INPUT_USAGE_KEYCODE_BUTTON_8,
249 INPUT_USAGE_KEYCODE_BUTTON_9,
250 INPUT_USAGE_KEYCODE_BUTTON_10,
251 INPUT_USAGE_KEYCODE_BUTTON_11,
252 INPUT_USAGE_KEYCODE_BUTTON_12,
253 INPUT_USAGE_KEYCODE_BUTTON_13,
254 INPUT_USAGE_KEYCODE_BUTTON_14,
255 INPUT_USAGE_KEYCODE_BUTTON_15,
256 INPUT_USAGE_KEYCODE_BUTTON_16,
257 INPUT_USAGE_KEYCODE_LANGUAGE_SWITCH,
258 INPUT_USAGE_KEYCODE_MANNER_MODE,
259 INPUT_USAGE_KEYCODE_3D_MODE,
260 INPUT_USAGE_KEYCODE_CONTACTS,
261 INPUT_USAGE_KEYCODE_CALENDAR,
262 INPUT_USAGE_KEYCODE_MUSIC,
263 INPUT_USAGE_KEYCODE_CALCULATOR,
264 INPUT_USAGE_KEYCODE_ZENKAKU_HANKAKU,
265 INPUT_USAGE_KEYCODE_EISU,
266 INPUT_USAGE_KEYCODE_MUHENKAN,
267 INPUT_USAGE_KEYCODE_HENKAN,
268 INPUT_USAGE_KEYCODE_KATAKANA_HIRAGANA,
269 INPUT_USAGE_KEYCODE_YEN,
270 INPUT_USAGE_KEYCODE_RO,
271 INPUT_USAGE_KEYCODE_KANA,
272 INPUT_USAGE_KEYCODE_ASSIST,
273 INPUT_USAGE_KEYCODE_BRIGHTNESS_DOWN,
274 INPUT_USAGE_KEYCODE_BRIGHTNESS_UP,
275 INPUT_USAGE_KEYCODE_MEDIA_AUDIO_TRACK,
276 INPUT_USAGE_KEYCODE_SLEEP,
277 INPUT_USAGE_KEYCODE_WAKEUP,
278 INPUT_USAGE_KEYCODE_PAIRING,
279 INPUT_USAGE_KEYCODE_MEDIA_TOP_MENU,
280 INPUT_USAGE_KEYCODE_11,
281 INPUT_USAGE_KEYCODE_12,
282 INPUT_USAGE_KEYCODE_LAST_CHANNEL,
283 INPUT_USAGE_KEYCODE_TV_DATA_SERVICE,
284 INPUT_USAGE_KEYCODE_VOICE_ASSIST,
285 INPUT_USAGE_KEYCODE_TV_RADIO_SERVICE,
286 INPUT_USAGE_KEYCODE_TV_TELETEXT,
287 INPUT_USAGE_KEYCODE_TV_NUMBER_ENTRY,
288 INPUT_USAGE_KEYCODE_TV_TERRESTRIAL_ANALOG,
289 INPUT_USAGE_KEYCODE_TV_TERRESTRIAL_DIGITAL,
290 INPUT_USAGE_KEYCODE_TV_SATELLITE,
291 INPUT_USAGE_KEYCODE_TV_SATELLITE_BS,
292 INPUT_USAGE_KEYCODE_TV_SATELLITE_CS,
293 INPUT_USAGE_KEYCODE_TV_SATELLITE_SERVICE,
294 INPUT_USAGE_KEYCODE_TV_NETWORK,
295 INPUT_USAGE_KEYCODE_TV_ANTENNA_CABLE,
296 INPUT_USAGE_KEYCODE_TV_INPUT_HDMI_1,
297 INPUT_USAGE_KEYCODE_TV_INPUT_HDMI_2,
298 INPUT_USAGE_KEYCODE_TV_INPUT_HDMI_3,
299 INPUT_USAGE_KEYCODE_TV_INPUT_HDMI_4,
300 INPUT_USAGE_KEYCODE_TV_INPUT_COMPOSITE_1,
301 INPUT_USAGE_KEYCODE_TV_INPUT_COMPOSITE_2,
302 INPUT_USAGE_KEYCODE_TV_INPUT_COMPONENT_1,
303 INPUT_USAGE_KEYCODE_TV_INPUT_COMPONENT_2,
304 INPUT_USAGE_KEYCODE_TV_INPUT_VGA_1,
305 INPUT_USAGE_KEYCODE_TV_AUDIO_DESCRIPTION,
306 INPUT_USAGE_KEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP,
307 INPUT_USAGE_KEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN,
308 INPUT_USAGE_KEYCODE_TV_ZOOM_MODE,
309 INPUT_USAGE_KEYCODE_TV_CONTENTS_MENU,
310 INPUT_USAGE_KEYCODE_TV_MEDIA_CONTEXT_MENU,
311 INPUT_USAGE_KEYCODE_TV_TIMER_PROGRAMMING,
312 INPUT_USAGE_KEYCODE_HELP,
313
314 // axes
315 INPUT_USAGE_AXIS_X,
316 INPUT_USAGE_AXIS_Y,
317 INPUT_USAGE_AXIS_PRESSURE,
318 INPUT_USAGE_AXIS_SIZE,
319 INPUT_USAGE_AXIS_TOUCH_MAJOR,
320 INPUT_USAGE_AXIS_TOUCH_MINOR,
321 INPUT_USAGE_AXIS_TOOL_MAJOR,
322 INPUT_USAGE_AXIS_TOOL_MINOR,
323 INPUT_USAGE_AXIS_ORIENTATION,
324 INPUT_USAGE_AXIS_VSCROLL,
325 INPUT_USAGE_AXIS_HSCROLL,
326 INPUT_USAGE_AXIS_Z,
327 INPUT_USAGE_AXIS_RX,
328 INPUT_USAGE_AXIS_RY,
329 INPUT_USAGE_AXIS_RZ,
330 INPUT_USAGE_AXIS_HAT_X,
331 INPUT_USAGE_AXIS_HAT_Y,
332 INPUT_USAGE_AXIS_LTRIGGER,
333 INPUT_USAGE_AXIS_RTRIGGER,
334 INPUT_USAGE_AXIS_THROTTLE,
335 INPUT_USAGE_AXIS_RUDDER,
336 INPUT_USAGE_AXIS_WHEEL,
337 INPUT_USAGE_AXIS_GAS,
338 INPUT_USAGE_AXIS_BRAKE,
339 INPUT_USAGE_AXIS_DISTANCE,
340 INPUT_USAGE_AXIS_TILT,
341 INPUT_USAGE_AXIS_GENERIC_1,
342 INPUT_USAGE_AXIS_GENERIC_2,
343 INPUT_USAGE_AXIS_GENERIC_3,
344 INPUT_USAGE_AXIS_GENERIC_4,
345 INPUT_USAGE_AXIS_GENERIC_5,
346 INPUT_USAGE_AXIS_GENERIC_6,
347 INPUT_USAGE_AXIS_GENERIC_7,
348 INPUT_USAGE_AXIS_GENERIC_8,
349 INPUT_USAGE_AXIS_GENERIC_9,
350 INPUT_USAGE_AXIS_GENERIC_10,
351 INPUT_USAGE_AXIS_GENERIC_11,
352 INPUT_USAGE_AXIS_GENERIC_12,
353 INPUT_USAGE_AXIS_GENERIC_13,
354 INPUT_USAGE_AXIS_GENERIC_14,
355 INPUT_USAGE_AXIS_GENERIC_15,
356 INPUT_USAGE_AXIS_GENERIC_16,
357
358 // leds
359 INPUT_USAGE_LED_NUM_LOCK,
360 INPUT_USAGE_LED_CAPS_LOCK,
361 INPUT_USAGE_LED_SCROLL_LOCK,
362 INPUT_USAGE_LED_COMPOSE,
363 INPUT_USAGE_LED_KANA,
364 INPUT_USAGE_LED_SLEEP,
365 INPUT_USAGE_LED_SUSPEND,
366 INPUT_USAGE_LED_MUTE,
367 INPUT_USAGE_LED_MISC,
368 INPUT_USAGE_LED_MAIL,
369 INPUT_USAGE_LED_CHARGING,
370 INPUT_USAGE_LED_CONTROLLER_1,
371 INPUT_USAGE_LED_CONTROLLER_2,
372 INPUT_USAGE_LED_CONTROLLER_3,
373 INPUT_USAGE_LED_CONTROLLER_4,
Michael Wright5113aff2015-02-13 17:31:41 -0800374} input_usage_t;
375
376typedef enum {
377 INPUT_COLLECTION_ID_TOUCH,
378 INPUT_COLLECTION_ID_KEYBOARD,
379 INPUT_COLLECTION_ID_MOUSE,
380 INPUT_COLLECTION_ID_TOUCHPAD,
381 // etc
382} input_collection_id_t;
383
384typedef struct input_message input_message_t;
385
386typedef struct input_host_callbacks {
387
388 /**
389 * Creates a device identifier with the given properties.
390 * The unique ID should be a string that precisely identifies a given piece of hardware. For
391 * example, an input device connected via Bluetooth could use its MAC address as its unique ID.
392 */
393 input_device_identifier_t* (*create_device_identifier)(input_host_t* host,
394 const char* name, int32_t product_id, int32_t vendor_id,
395 input_bus_t bus, const char* unique_id);
396
397 /**
398 * Allocates the device definition which will describe the input capabilities of a device. A
399 * device definition may be used to register as many devices as desired.
400 */
401 input_device_definition_t* (*create_device_definition)(input_host_t* host);
402
403 /**
404 * Allocate either an input report, which the HAL will use to tell the host of incoming input
405 * events, or an output report, which the host will use to tell the HAL of desired state
406 * changes (e.g. setting an LED).
407 */
408 input_report_definition_t* (*create_input_report_definition)(input_host_t* host);
409 input_report_definition_t* (*create_output_report_definition)(input_host_t* host);
410
411 /**
412 * Append the report to the given input device.
413 */
414 void (*input_device_definition_add_report)(input_host_t* host,
415 input_device_definition_t* d, input_report_definition_t* r);
416
417 /**
418 * Add a collection with the given arity and ID. A collection describes a set
419 * of logically grouped properties such as the X and Y coordinates of a single finger touch or
420 * the set of keys on a keyboard. The arity declares how many repeated instances of this
421 * collection will appear in whatever report it is attached to. The ID describes the type of
422 * grouping being represented by the collection. For example, a touchscreen capable of
423 * reporting up to 2 fingers simultaneously might have a collection with the X and Y
424 * coordinates, an arity of 2, and an ID of INPUT_COLLECTION_USAGE_TOUCHSCREEN. Any given ID
425 * may only be present once for a given report.
426 */
427 void (*input_report_definition_add_collection)(input_host_t* host,
428 input_report_definition_t* report, input_collection_id_t id, int32_t arity);
429
430 /**
431 * Declare an int usage with the given properties. The report and collection defines where the
432 * usage is being declared.
433 */
434 void (*input_report_definition_declare_usage_int)(input_host_t* host,
435 input_report_definition_t* report, input_collection_id_t id,
436 input_usage_t usage, int32_t min, int32_t max, float resolution);
437
438 /**
439 * Declare a set of boolean usages with the given properties. The report and collection
440 * defines where the usages are being declared.
441 */
442 void (*input_report_definition_declare_usages_bool)(input_host_t* host,
443 input_report_definition_t* report, input_collection_id_t id,
444 input_usage_t* usage, size_t usage_count);
445
446
447 /**
448 * Register a given input device definition. This notifies the host that an input device has
449 * been connected and gives a description of all its capabilities.
450 */
451 input_device_handle_t* (*register_device)(input_host_t* host,
452 input_device_identifier_t* id, input_device_definition_t* d);
453
454 /** Unregister the given device */
455 void (*unregister_device)(input_host_t* host, input_device_handle_t* handle);
456
457 /**
458 * Allocate a report that will contain all of the state as described by the given report.
459 */
460 input_report_t* (*input_allocate_report)(input_host_t* host, input_report_definition_t* r);
461
Tim Kilbournaaf6b262015-02-27 15:01:50 -0800462 /**
463 * Add an int usage value to a report.
464 */
465 void (*input_report_set_usage_int)(input_host_t* host, input_report_t* r,
466 input_collection_id_t id, input_usage_t usage, int32_t value, int32_t arity_index);
467
468 /**
469 * Add a boolean usage value to a report.
470 */
471 void (*input_report_set_usage_bool)(input_host_t* host, input_report_t* r,
472 input_collection_id_t id, input_usage_t usage, bool value, int32_t arity_index);
473
Michael Wright5113aff2015-02-13 17:31:41 -0800474 void (*report_event)(input_host_t* host, input_device_handle_t* d, input_report_t* report);
475} input_host_callbacks_t;
476
477typedef struct input_module input_module_t;
478
479struct input_module {
480 /**
481 * Common methods of the input module. This *must* be the first member
482 * of input_module as users of this structure will cast a hw_module_t
483 * to input_module pointer in contexts where it's known
484 * the hw_module_t references a input_module.
485 */
486 struct hw_module_t common;
487
488 /**
489 * Initialize the module with host callbacks. At this point the HAL should start up whatever
490 * infrastructure it needs to in order to process input events.
491 */
492 void (*init)(const input_module_t* module, input_host_t* host, input_host_callbacks_t cb);
493
494 /**
495 * Sends an output report with a new set of state the host would like the given device to
496 * assume.
497 */
Tim Kilbourn73475a42015-02-13 10:35:20 -0800498 void (*notify_report)(const input_module_t* module, input_report_t* report);
Michael Wright5113aff2015-02-13 17:31:41 -0800499};
500
501static inline int input_open(const struct hw_module_t** module, const char* type) {
502 return hw_get_module_by_class(INPUT_HARDWARE_MODULE_ID, type, module);
503}
504
505__END_DECLS
506
507#endif /* ANDROID_INCLUDE_HARDWARE_INPUT_H */