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