• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef HID_DDK_TYPES_H
17 #define HID_DDK_TYPES_H
18 /**
19  * @addtogroup HidDdk
20  * @{
21  *
22  * @brief Provides HID DDK interfaces, including creating a device, sending an event, and destroying a device.
23  *
24  * @kit DriverDevelopmentKit
25  * @syscap SystemCapability.Driver.HID.Extension
26  * @since 11
27  * @version 1.0
28  */
29 
30 /**
31  * @file hid_ddk_types.h
32  *
33  * @brief Provides definitions of enum variables and structs in the HID DDK.
34  *
35  * File to include: <hid/hid_ddk_types.h>
36  * @since 11
37  * @version 1.0
38  */
39 
40 #include <stdint.h>
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif /* __cplusplus */
45 
46 /**
47  * @brief Defines event information.
48  *
49  * @since 11
50  * @version 1.0
51  */
52 typedef struct Hid_EmitItem {
53     /** Event type */
54     uint16_t type;
55     /** Event code */
56     uint16_t code;
57     /** Event value */
58     uint32_t value;
59 } Hid_EmitItem;
60 
61 /**
62  * @brief Enumerates the input devices.
63  *
64  * @since 11
65  * @version 1.0
66  */
67 typedef enum {
68     /** Pointer device */
69     HID_PROP_POINTER = 0x00,
70     /** Direct input device */
71     HID_PROP_DIRECT = 0x01,
72     /** Touch device with bottom keys */
73     HID_PROP_BUTTON_PAD = 0x02,
74     /** Full multi-touch device */
75     HID_PROP_SEMI_MT = 0x03,
76     /** Touch device with top soft keys */
77     HID_PROP_TOP_BUTTON_PAD = 0x04,
78     /** Pointing stick */
79     HID_PROP_POINTING_STICK = 0x05,
80     /** Accelerometer */
81     HID_PROP_ACCELEROMETER = 0x06
82 } Hid_DeviceProp;
83 
84 /**
85  * @brief Defines the basic device information.
86  *
87  * @since 11
88  * @version 1.0
89  */
90 typedef struct Hid_Device {
91     /** Device name */
92     const char *deviceName;
93     /** Vendor ID */
94     uint16_t vendorId;
95     /** Product ID */
96     uint16_t productId;
97     /** Version */
98     uint16_t version;
99     /** Bus type */
100     uint16_t bustype;
101     /** Device properties */
102     Hid_DeviceProp *properties;
103     /** Number of device properties */
104     uint16_t propLength;
105 } Hid_Device;
106 
107 /**
108  * @brief Enumerates the event types.
109  *
110  * @since 11
111  * @version 1.0
112  */
113 typedef enum {
114     /** Synchronization event */
115     HID_EV_SYN = 0x00,
116     /** Key event */
117     HID_EV_KEY = 0x01,
118     /** Relative coordinate event */
119     HID_EV_REL = 0x02,
120     /** Absolute coordinate event */
121     HID_EV_ABS = 0x03,
122     /** Other special event */
123     HID_EV_MSC = 0x04
124 } Hid_EventType;
125 
126 /**
127  * @brief Enumerates the synchronization event codes.
128  *
129  * @since 11
130  * @version 1.0
131  */
132 typedef enum {
133     /** Indicates the end of an event. */
134     HID_SYN_REPORT = 0,
135     /** Indicates configuration synchronization. */
136     HID_SYN_CONFIG = 1,
137     /** Indicates the end of a multi-touch ABS data packet. */
138     HID_SYN_MT_REPORT = 2,
139     /** Indicates that the event is discarded. */
140     HID_SYN_DROPPED = 3
141 } Hid_SynEvent;
142 
143 /**
144  * @brief Enumerates the key value codes.
145  *
146  * @since 11
147  * @version 1.0
148  */
149 typedef enum {
150     /** Key A */
151     HID_KEY_A = 30,
152     /** Key B */
153     HID_KEY_B = 48,
154     /** Key C */
155     HID_KEY_C = 46,
156     /** Key D */
157     HID_KEY_D = 32,
158     /** Key E */
159     HID_KEY_E = 18,
160     /** Key F */
161     HID_KEY_F = 33,
162     /** Key G */
163     HID_KEY_G = 34,
164     /** Key H */
165     HID_KEY_H = 35,
166     /** Key I */
167     HID_KEY_I = 23,
168     /** Key J */
169     HID_KEY_J = 36,
170     /** Key K */
171     HID_KEY_K = 37,
172     /** Key L */
173     HID_KEY_L = 38,
174     /** Key M */
175     HID_KEY_M = 50,
176     /** Key N */
177     HID_KEY_N = 49,
178     /** Key O */
179     HID_KEY_O = 24,
180     /** Key P */
181     HID_KEY_P = 25,
182     /** Key Q */
183     HID_KEY_Q = 16,
184     /** Key R */
185     HID_KEY_R = 19,
186     /** Key S */
187     HID_KEY_S = 31,
188     /** Key T */
189     HID_KEY_T = 20,
190     /** Key U */
191     HID_KEY_U = 22,
192     /** Key V */
193     HID_KEY_V = 47,
194     /** Key W */
195     HID_KEY_W = 17,
196     /** Key X */
197     HID_KEY_X = 45,
198     /** Key Y */
199     HID_KEY_Y = 21,
200     /** Key Z */
201     HID_KEY_Z = 44,
202     /** Key Esc */
203     HID_KEY_ESC = 1,
204     /** Key 0 */
205     HID_KEY_0 = 11,
206     /** Key 1 */
207     HID_KEY_1 = 2,
208     /** Key 2 */
209     HID_KEY_2 = 3,
210     /** Key 3 */
211     HID_KEY_3 = 4,
212     /** Key 4 */
213     HID_KEY_4 = 5,
214     /** Key 5 */
215     HID_KEY_5 = 6,
216     /** Key 6 */
217     HID_KEY_6 = 7,
218     /** Key 7 */
219     HID_KEY_7 = 8,
220     /** Key 8 */
221     HID_KEY_8 = 9,
222     /** Key 9 */
223     HID_KEY_9 = 10,
224     /** Key grave (`) */
225     HID_KEY_GRAVE = 41,
226     /** Key minum (-) */
227     HID_KEY_MINUS = 12,
228     /** Key equals (=) */
229     HID_KEY_EQUALS = 13,
230     /** Key backspace */
231     HID_KEY_BACKSPACE = 14,
232     /** Key left bracket ([) */
233     HID_KEY_LEFT_BRACKET = 26,
234     /** Key right bracket (]) */
235     HID_KEY_RIGHT_BRACKET = 27,
236     /** Key Enter */
237     HID_KEY_ENTER = 28,
238     /** Key left Shift */
239     HID_KEY_LEFT_SHIFT = 42,
240     /** Key backslash (\) */
241     HID_KEY_BACKSLASH = 43,
242     /** Key semicolon (;) */
243     HID_KEY_SEMICOLON = 39,
244     /** Key apostrophe (') */
245     HID_KEY_APOSTROPHE = 40,
246     /** Key space */
247     HID_KEY_SPACE = 57,
248     /** Key slash (/) */
249     HID_KEY_SLASH = 53,
250     /** Key comma (,) */
251     HID_KEY_COMMA = 51,
252     /** Key period (.) */
253     HID_KEY_PERIOD = 52,
254     /** Key right Shift */
255     HID_KEY_RIGHT_SHIFT = 54,
256     /** Numeral 0 on the numeric keypad */
257     HID_KEY_NUMPAD_0 = 82,
258     /** Numeral 1 on the numeric keypad */
259     HID_KEY_NUMPAD_1 = 79,
260     /** Numeral 2 on the numeric keypad */
261     HID_KEY_NUMPAD_2 = 80,
262     /** Numeral 3 on the numeric keypad */
263     HID_KEY_NUMPAD_3 = 81,
264     /** Numeral 4 on the numeric keypad */
265     HID_KEY_NUMPAD_4 = 75,
266     /** Numeral 5 on the numeric keypad */
267     HID_KEY_NUMPAD_5 = 76,
268     /** Numeral 6 on the numeric keypad*/
269     HID_KEY_NUMPAD_6 = 77,
270     /** Numeral 7 on the numeric keypad */
271     HID_KEY_NUMPAD_7 = 71,
272     /** Numeral 8 on the numeric keypad */
273     HID_KEY_NUMPAD_8 = 72,
274     /** Numeral 9 on the numeric keypad */
275     HID_KEY_NUMPAD_9 = 73,
276     /** Arithmetic operator / (division) on the numeric keypad */
277     HID_KEY_NUMPAD_DIVIDE = 70,
278     /** Arithmetic operator * (multiplication) on the numeric keypad */
279     HID_KEY_NUMPAD_MULTIPLY = 55,
280     /** Arithmetic operator - (subtraction) on the numeric keypad */
281     HID_KEY_NUMPAD_SUBTRACT = 74,
282     /** Arithmetic operator + (addition) on the numeric keypad */
283     HID_KEY_NUMPAD_ADD = 78,
284     /** Decimal point (.) on the numeric keypad */
285     HID_KEY_NUMPAD_DOT = 83,
286     /** Key Print Screen */
287     HID_KEY_SYSRQ = 99,
288     /** Key Delete */
289     HID_KEY_DELETE = 111,
290     /** Key Mute */
291     HID_KEY_MUTE = 113,
292     /** Key for volume down */
293     HID_KEY_VOLUME_DOWN = 114,
294     /** Key for volume up */
295     HID_KEY_VOLUME_UP = 115,
296     /** Key for decreasing brightness */
297     HID_KEY_BRIGHTNESS_DOWN = 224,
298     /** Key for increasing brightness */
299     HID_KEY_BRIGHTNESS_UP = 225,
300     /** Button 0 */
301     HID_BTN_0 = 0x100,
302     /** Button 1 */
303     HID_BTN_1 = 0x101,
304     /** Button 2 */
305     HID_BTN_2 = 0x102,
306     /** Button 3 */
307     HID_BTN_3 = 0x103,
308     /** Button 4 */
309     HID_BTN_4 = 0x104,
310     /** Button 5 */
311     HID_BTN_5 = 0x105,
312     /** Button 6 */
313     HID_BTN_6 = 0x106,
314     /** Button 7 */
315     HID_BTN_7 = 0x107,
316     /** Button 8 */
317     HID_BTN_8 = 0x108,
318     /** Button 9 */
319     HID_BTN_9 = 0x109,
320     /** Left mouse button */
321     HID_BTN_LEFT = 0x110,
322     /** Right mouse button */
323     HID_BTN_RIGHT = 0x111,
324     /** Middle mouse button */
325     HID_BTN_MIDDLE = 0x112,
326     /** Side mouse button */
327     HID_BTN_SIDE = 0x113,
328     /** Extra mouse button */
329     HID_BTN_EXTRA = 0x114,
330     /** Mouse forward button */
331     HID_BTN_FORWARD = 0x115,
332     /** Mouse backward button */
333     HID_BTN_BACKWARD = 0x116,
334     /** Mouse task button */
335     HID_BTN_TASK = 0x117,
336     /** Pen */
337     HID_BTN_TOOL_PEN = 0x140,
338     /** Rubber */
339     HID_BTN_TOOL_RUBBER = 0x141,
340     /** Brush */
341     HID_BTN_TOOL_BRUSH = 0x142,
342     /** Pencil */
343     HID_BTN_TOOL_PENCIL = 0x143,
344     /** Air brush */
345     HID_BTN_TOOL_AIRBRUSH = 0x144,
346     /** Finger */
347     HID_BTN_TOOL_FINGER = 0x145,
348     /** Mouse */
349     HID_BTN_TOOL_MOUSE = 0x146,
350     /** Lens */
351     HID_BTN_TOOL_LENS = 0x147,
352     /** Five-finger touch */
353     HID_BTN_TOOL_QUINT_TAP = 0x148,
354     /** Stylus 3 */
355     HID_BTN_STYLUS3 = 0x149,
356     /** Touch */
357     HID_BTN_TOUCH = 0x14a,
358     /** Stylus */
359     HID_BTN_STYLUS = 0x14b,
360     /** Stylus 2 */
361     HID_BTN_STYLUS2 = 0x14c,
362     /** Two-finger touch */
363     HID_BTN_TOOL_DOUBLE_TAP = 0x14d,
364     /** Three-finger touch */
365     HID_BTN_TOOL_TRIPLE_TAP = 0x14e,
366     /** Four-finger touch */
367     HID_BTN_TOOL_QUAD_TAP = 0x14f,
368     /** Scroll wheel */
369     HID_BTN_WHEEL = 0x150
370 } Hid_KeyCode;
371 
372 /**
373  * @brief Enumerates the absolute coordinate codes.
374  *
375  * @since 11
376  * @version 1.0
377  */
378 typedef enum {
379     /** X axis */
380     HID_ABS_X = 0x00,
381     /** Y axis */
382     HID_ABS_Y = 0x01,
383     /** Z axis */
384     HID_ABS_Z = 0x02,
385     /** X axis of the right analog stick */
386     HID_ABS_RX = 0x03,
387     /** Y axis of the right analog stick */
388     HID_ABS_RY = 0x04,
389     /** Z axis of the right analog stick */
390     HID_ABS_RZ = 0x05,
391     /** Throttle */
392     HID_ABS_THROTTLE = 0x06,
393     /** Rudder */
394     HID_ABS_RUDDER = 0x07,
395     /** Scroll wheel */
396     HID_ABS_WHEEL = 0x08,
397     /** Gas */
398     HID_ABS_GAS = 0x09,
399     /** Brake */
400     HID_ABS_BRAKE = 0x0a,
401     /** HAT0X */
402     HID_ABS_HAT0X = 0x10,
403     /** HAT0Y */
404     HID_ABS_HAT0Y = 0x11,
405     /** HAT1X */
406     HID_ABS_HAT1X = 0x12,
407     /** HAT1Y */
408     HID_ABS_HAT1Y = 0x13,
409     /** HAT2X */
410     HID_ABS_HAT2X = 0x14,
411     /** HAT2Y */
412     HID_ABS_HAT2Y = 0x15,
413     /** HAT3X */
414     HID_ABS_HAT3X = 0x16,
415     /** HAT3Y */
416     HID_ABS_HAT3Y = 0x17,
417     /** Pressure */
418     HID_ABS_PRESSURE = 0x18,
419     /** Distance */
420     HID_ABS_DISTANCE = 0x19,
421     /** Inclination of X axis */
422     HID_ABS_TILT_X = 0x1a,
423     /** Inclination of Y axis */
424     HID_ABS_TILT_Y = 0x1b,
425     /** Width of the touch tool */
426     HID_ABS_TOOL_WIDTH = 0x1c,
427     /** Volume */
428     HID_ABS_VOLUME = 0x20,
429     /** Others */
430     HID_ABS_MISC = 0x28
431 } Hid_AbsAxes;
432 
433 /**
434  * @brief Enumerates the relative coordinate codes.
435  *
436  * @since 11
437  * @version 1.0
438  */
439 typedef enum {
440     /** X axis */
441     HID_REL_X = 0x00,
442     /** Y axis */
443     HID_REL_Y = 0x01,
444     /** Z axis */
445     HID_REL_Z = 0x02,
446     /** X axis of the right analog stick */
447     HID_REL_RX = 0x03,
448     /** Y axis of the right analog stick */
449     HID_REL_RY = 0x04,
450     /** Z axis of the right analog stick */
451     HID_REL_RZ = 0x05,
452     /** Horizontal scroll wheel */
453     HID_REL_HWHEEL = 0x06,
454     /** Scale */
455     HID_REL_DIAL = 0x07,
456     /** Scroll wheel */
457     HID_REL_WHEEL = 0x08,
458     /** Others */
459     HID_REL_MISC = 0x09,
460     /* Reserved */
461     HID_REL_RESERVED = 0x0a,
462     /** High-resolution scroll wheel */
463     HID_REL_WHEEL_HI_RES = 0x0b,
464     /** High-resolution horizontal scroll wheel */
465     HID_REL_HWHEEL_HI_RES = 0x0c
466 } Hid_RelAxes;
467 
468 /**
469  * @brief Enumerates the codes of other input events.
470  *
471  * @since 11
472  * @version 1.0
473  */
474 typedef enum {
475     /** Serial number */
476     HID_MSC_SERIAL = 0x00,
477     /** Pulse */
478     HID_MSC_PULSE_LED = 0x01,
479     /** Gesture */
480     HID_MSC_GESTURE = 0x02,
481     /** Start event */
482     HID_MSC_RAW = 0x03,
483     /** Scan */
484     HID_MSC_SCAN = 0x04,
485     /** Timestamp */
486     HID_MSC_TIMESTAMP = 0x05
487 } Hid_MscEvent;
488 
489 /**
490  * @brief Defines an array of the event type codes.
491  *
492  * @since 11
493  * @version 1.0
494  */
495 typedef struct Hid_EventTypeArray {
496     /** Event type code */
497     Hid_EventType *hidEventType;
498     /** Length of the array */
499     uint16_t length;
500 } Hid_EventTypeArray;
501 
502 /**
503  * @brief Defines an array of key value properties.
504  *
505  * @since 11
506  * @version 1.0
507  */
508 typedef struct Hid_KeyCodeArray {
509     /** Key value code */
510     Hid_KeyCode *hidKeyCode;
511     /** Length of the array */
512     uint16_t length;
513 } Hid_KeyCodeArray;
514 
515 /**
516  * @brief Defines an array of absolute coordinate properties.
517  *
518  * @since 11
519  * @version 1.0
520  */
521 typedef struct Hid_AbsAxesArray {
522     /** Absolute coordinate property code */
523     Hid_AbsAxes *hidAbsAxes;
524     /** Length of the array */
525     uint16_t length;
526 } Hid_AbsAxesArray;
527 
528 /**
529  * @brief Defines an array of relative coordinate properties.
530  *
531  * @since 11
532  * @version 1.0
533  */
534 typedef struct Hid_RelAxesArray {
535     /** Relative coordinate property code */
536     Hid_RelAxes *hidRelAxes;
537     /** Length of the array */
538     uint16_t length;
539 } Hid_RelAxesArray;
540 
541 /**
542  * @brief Defines an array of other special event properties.
543  *
544  * @since 11
545  * @version 1.0
546  */
547 typedef struct Hid_MscEventArray {
548     /** Code of the event property */
549     Hid_MscEvent *hidMscEvent;
550     /** Length of the array */
551     uint16_t length;
552 } Hid_MscEventArray;
553 
554 /**
555  * @brief Defines the event properties of a device to be observed.
556  *
557  * @since 11
558  * @version 1.0
559  */
560 typedef struct Hid_EventProperties {
561     /** Array of event type codes */
562     struct Hid_EventTypeArray hidEventTypes;
563     /** Array of key value codes */
564     struct Hid_KeyCodeArray hidKeys;
565     /** Array of absolute coordinate property codes */
566     struct Hid_AbsAxesArray hidAbs;
567     /** Array of relative coordinate property codes */
568     struct Hid_RelAxesArray hidRelBits;
569     /** Array of other event property codes */
570     struct Hid_MscEventArray hidMiscellaneous;
571 
572     /** Maximum values of the absolute coordinates */
573     int32_t hidAbsMax[64];
574     /** Minimum values of the absolute coordinates */
575     int32_t hidAbsMin[64];
576     /** Fuzzy values of the absolute coordinates */
577     int32_t hidAbsFuzz[64];
578     /** Fixed values of the absolute coordinates */
579     int32_t hidAbsFlat[64];
580 } Hid_EventProperties;
581 
582 /**
583  * @brief Defines the error codes used in the HID DDK.
584  *
585  * @since 11
586  * @version 1.0
587  */
588 typedef enum {
589     /** @error Operation successful */
590     HID_DDK_SUCCESS = 0,
591     /** @error Operation failed */
592     HID_DDK_FAILURE = -1,
593     /** @error Invalid parameter */
594     HID_DDK_INVALID_PARAMETER = -2,
595     /** @error Invalid operation */
596     HID_DDK_INVALID_OPERATION = -3,
597     /** @error Null pointer exception */
598     HID_DDK_NULL_PTR = -4,
599     /** @error Timeout */
600     HID_DDK_TIMEOUT = -5,
601     /** @error Permission denied */
602     HID_DDK_NO_PERM = -6
603 } Hid_DdkErrCode;
604 #ifdef __cplusplus
605 }
606 /** @} */
607 #endif /* __cplusplus */
608 #endif // HID_DDK_TYPES_H
609