1# HID DDK
2
3
4## Overview
5
6Provides HID driver development kit (DDK) functions, including those for creating a device, sending events to a device, and destroying a device.
7
8**System capability**: SystemCapability.Driver.HID.Extension
9
10**Since**
11
1211
13
14## Summary
15
16
17### Files
18
19| Name| Description|
20| -------- | -------- |
21| [hid_ddk_api.h](hid__ddk__api_8h.md) | Declares the HID DDK functions for accessing an input device from the host.<br>File to include: &lt;hid/hid_ddk_api.h&gt;<br>Library: libhid.z.so|
22| [hid_ddk_types.h](hid__ddk__types_8h.md) | Defines the enum variables and structs used in the HID DDK.<br>File to include: &lt;hid/hid_ddk_types.h&gt;<br>Library: libhid.z.so |
23
24
25### Structs
26
27| Name| Description|
28| -------- | -------- |
29| [Hid_EmitItem](_hid___emit_item.md) | Defines event information. |
30| [Hid_Device](_hid___device.md) | Defines basic device information. |
31| [Hid_EventTypeArray](_hid___event_type_array.md) | Defines an array of event types. |
32| [Hid_KeyCodeArray](_hid___key_code_array.md) | Defines an array of key codes. |
33| [Hid_AbsAxesArray](_hid___abs_axes_array.md) | Defines an array of absolute coordinates. |
34| [Hid_RelAxesArray](_hid___rel_axes_array.md) | Defines an array of relative coordinates. |
35| [Hid_MscEventArray](_hid___msc_event_array.md) | Defines an array of miscellaneous events. |
36| [Hid_EventProperties](_hid___event_properties.md) | Defines the event properties of a device. |
37
38
39### Types
40
41| Name| Description|
42| -------- | -------- |
43| [Hid_EmitItem](#hid_emititem) | Defines a struct for event information. |
44| [Hid_Device](#hid_device) | Defines a struct for basic device information. |
45| [Hid_EventTypeArray](#hid_eventtypearray) | Defines a struct for an array of event types. |
46| [Hid_KeyCodeArray](#hid_keycodearray) | Defines a struct for an array of key codes. |
47| [Hid_AbsAxesArray](#hid_absaxesarray) | Defines a struct for an array of absolute coordinates. |
48| [Hid_RelAxesArray](#hid_relaxesarray) | Defines a struct for an array of relative coordinates. |
49| [Hid_MscEventArray](#hid_msceventarray) | Defines a struct for an array of miscellaneous events. |
50| [Hid_EventProperties](#hid_eventproperties) | Defines a struct for the event properties of a device. |
51
52
53### Enums
54
55| Name| Description|
56| -------- | -------- |
57| [Hid_DeviceProp](#hid_deviceprop) {<br>HID_PROP_POINTER = 0x00, HID_PROP_DIRECT = 0x01, HID_PROP_BUTTON_PAD = 0x02, HID_PROP_SEMI_MT = 0x03,<br>HID_PROP_TOP_BUTTON_PAD = 0x04, HID_PROP_POINTING_STICK = 0x05, HID_PROP_ACCELEROMETER = 0x06<br>} | Enumerates the properties of input devices. |
58| [Hid_EventType](#hid_eventtype) {<br>HID_EV_SYN = 0x00, HID_EV_KEY = 0x01, HID_EV_REL = 0x02, HID_EV_ABS = 0x03,<br>HID_EV_MSC = 0x04<br>} | Enumerates the event types. |
59| [Hid_SynEvent](#hid_synevent) { HID_SYN_REPORT = 0, HID_SYN_CONFIG = 1, HID_SYN_MT_REPORT = 2, HID_SYN_DROPPED = 3 } | Enumerates sync events. |
60| [Hid_KeyCode](#hid_keycode) {<br>HID_KEY_A = 30, HID_KEY_B = 48, HID_KEY_C = 46, HID_KEY_D = 32,<br>HID_KEY_E = 18, HID_KEY_F = 33, HID_KEY_G = 34, HID_KEY_H = 35,<br>HID_KEY_I = 23, HID_KEY_J = 36, HID_KEY_K = 37, HID_KEY_L = 38,<br>HID_KEY_M = 50, HID_KEY_N = 49, HID_KEY_O = 24, HID_KEY_P = 25,<br>HID_KEY_Q = 16, HID_KEY_R = 19, HID_KEY_S = 31, HID_KEY_T = 20,<br>HID_KEY_U = 22, HID_KEY_V = 47, HID_KEY_W = 17, HID_KEY_X = 45,<br>HID_KEY_Y = 21, HID_KEY_Z = 44, HID_KEY_ESC = 1, HID_KEY_0 = 11,<br>HID_KEY_1 = 2, HID_KEY_2 = 3, HID_KEY_3 = 4, HID_KEY_4 = 5,<br>HID_KEY_5 = 6, HID_KEY_6 = 7, HID_KEY_7 = 8, HID_KEY_8 = 9,<br>HID_KEY_9 = 10, HID_KEY_GRAVE = 41, HID_KEY_MINUS = 12, HID_KEY_EQUALS = 13,<br>HID_KEY_BACKSPACE = 14, HID_KEY_LEFT_BRACKET = 26, HID_KEY_RIGHT_BRACKET = 27, HID_KEY_ENTER = 28,<br>HID_KEY_LEFT_SHIFT = 42, HID_KEY_BACKSLASH = 43, HID_KEY_SEMICOLON = 39, HID_KEY_APOSTROPHE = 40,<br>HID_KEY_SPACE = 57, HID_KEY_SLASH = 53, HID_KEY_COMMA = 51, HID_KEY_PERIOD = 52,<br>HID_KEY_RIGHT_SHIFT = 54, HID_KEY_NUMPAD_0 = 82, HID_KEY_NUMPAD_1 = 79, HID_KEY_NUMPAD_2 = 80,<br>HID_KEY_NUMPAD_3 = 81, HID_KEY_NUMPAD_4 = 75, HID_KEY_NUMPAD_5 = 76, HID_KEY_NUMPAD_6 = 77,<br>HID_KEY_NUMPAD_7 = 71, HID_KEY_NUMPAD_8 = 72, HID_KEY_NUMPAD_9 = 73, HID_KEY_NUMPAD_DIVIDE = 70,<br>HID_KEY_NUMPAD_MULTIPLY = 55, HID_KEY_NUMPAD_SUBTRACT = 74, HID_KEY_NUMPAD_ADD = 78, HID_KEY_NUMPAD_DOT = 83,<br>HID_KEY_SYSRQ = 99, HID_KEY_MUTE = 113, HID_KEY_VOLUME_DOWN = 114, HID_KEY_VOLUME_UP = 115,<br>HID_KEY_BRIGHTNESS_DOWN = 224, HID_KEY_BRIGHTNESS_UP = 225, HID_BTN_0 = 0x100, HID_BTN_1 = 0x101,<br>HID_BTN_2 = 0x102, HID_BTN_3 = 0x103, HID_BTN_4 = 0x104, HID_BTN_5 = 0x105,<br>HID_BTN_6 = 0x106, HID_BTN_7 = 0x107, HID_BTN_8 = 0x108, HID_BTN_9 = 0x109,<br>HID_BTN_LEFT = 0x110, HID_BTN_RIGHT = 0x111, HID_BTN_MIDDLE = 0x112, HID_BTN_SIDE = 0x113,<br>HID_BTN_EXTRA = 0x114, HID_BTN_FORWARD = 0x115, HID_BTN_BACKWARD = 0x116, HID_BTN_TASK = 0x117,<br>HID_BTN_TOOL_PEN = 0x140, HID_BTN_TOOL_RUBBER = 0x141, HID_BTN_TOOL_BRUSH = 0x142, HID_BTN_TOOL_PENCIL = 0x143,<br>HID_BTN_TOOL_AIRBRUSH = 0x144, HID_BTN_TOOL_FINGER = 0x145, HID_BTN_TOOL_MOUSE = 0x146, HID_BTN_TOOL_LENS = 0x147,<br>HID_BTN_TOOL_QUINT_TAP = 0x148, HID_BTN_STYLUS3 = 0x149, HID_BTN_TOUCH = 0x14a, HID_BTN_STYLUS = 0x14b,<br>HID_BTN_STYLUS2 = 0x14c, HID_BTN_TOOL_DOUBLE_TAP = 0x14d, HID_BTN_TOOL_TRIPLE_TAP = 0x14e, HID_BTN_TOOL_QUAD_TAP = 0x14f,<br>HID_BTN_WHEEL = 0x150<br>} | Enumerates the key codes. |
61| [Hid_AbsAxes](#hid_absaxes) {<br>HID_ABS_X = 0x00, HID_ABS_Y = 0x01, HID_ABS_Z = 0x02, HID_ABS_RX = 0x03,<br>HID_ABS_RY = 0x04, HID_ABS_RZ = 0x05, HID_ABS_THROTTLE = 0x06, HID_ABS_RUDDER = 0x07,<br>HID_ABS_WHEEL = 0x08, HID_ABS_GAS = 0x09, HID_ABS_BRAKE = 0x0a, HID_ABS_HAT0X = 0x10,<br>HID_ABS_HAT0Y = 0x11, HID_ABS_HAT1X = 0x12, HID_ABS_HAT1Y = 0x13, HID_ABS_HAT2X = 0x14,<br>HID_ABS_HAT2Y = 0x15, HID_ABS_HAT3X = 0x16, HID_ABS_HAT3Y = 0x17, HID_ABS_PRESSURE = 0x18,<br>HID_ABS_DISTANCE = 0x19, HID_ABS_TILT_X = 0x1a, HID_ABS_TILT_Y = 0x1b, HID_ABS_TOOL_WIDTH = 0x1c,<br>HID_ABS_VOLUME = 0x20, HID_ABS_MISC = 0x28<br>} | Enumerates the absolute coordinates. |
62| [Hid_RelAxes](#hid_relaxes) {<br>HID_REL_X = 0x00, HID_REL_Y = 0x01, HID_REL_Z = 0x02, HID_REL_RX = 0x03,<br>HID_REL_RY = 0x04, HID_REL_RZ = 0x05, HID_REL_HWHEEL = 0x06, HID_REL_DIAL = 0x07,<br>HID_REL_WHEEL = 0x08, HID_REL_MISC = 0x09, HID_REL_RESERVED = 0x0a, HID_REL_WHEEL_HI_RES = 0x0b,<br>HID_REL_HWHEEL_HI_RES = 0x0c<br>} | Enumerates the relative coordinates. |
63| [Hid_MscEvent](#hid_mscevent) {<br>HID_MSC_SERIAL = 0x00, HID_MSC_PULSE_LED = 0x01, HID_MSC_GESTURE = 0x02, HID_MSC_RAW = 0x03,<br>HID_MSC_SCAN = 0x04, HID_MSC_TIMESTAMP = 0x05<br>} | Enumerates miscellaneous input events. |
64| [Hid_DdkErrCode](#hid_ddkerrcode) {<br>HID_DDK_SUCCESS = 0, HID_DDK_NO_PERM = 201, HID_DDK_INVALID_PARAMETER = 401,HID_DDK_FAILURE = 27300001,<br>HID_DDK_NULL_PTR = 27300002, HID_DDK_INVALID_OPERATION = 27300003, HID_DDK_TIMEOUT = 27300004<br>} | Enumerates the HID DDK error codes. |
65
66
67### Functions
68
69| Name| Description|
70| -------- | -------- |
71| [OH_Hid_CreateDevice](#oh_hid_createdevice) ([Hid_Device](_hid___device.md) \*hidDevice, [Hid_EventProperties](_hid___event_properties.md) \*hidEventProperties) | Creates a device. |
72| [OH_Hid_EmitEvent](#oh_hid_emitevent) (int32_t deviceId, const [Hid_EmitItem](_hid___emit_item.md) items[], uint16_t length) | Sends an event list to a device. |
73| [OH_Hid_DestroyDevice](#oh_hid_destroydevice) (int32_t deviceId) | Destroys a device. |
74
75
76### Variables
77
78| Name| Description|
79| -------- | -------- |
80| [Hid_EmitItem::type](#type) | Event type. |
81| [Hid_EmitItem::code](#code) | Event code. |
82| [Hid_EmitItem::value](#value) | Event value. |
83| [Hid_Device::deviceName](#devicename) | Device name. |
84| [Hid_Device::vendorId](#vendorid) | Vendor ID. |
85| [Hid_Device::productId](#productid) | Product ID. |
86| [Hid_Device::version](#version) | Version number. |
87| [Hid_Device::bustype](#bustype) | Bus type. |
88| [Hid_Device::properties](#properties) | Device properties. |
89| [Hid_Device::propLength](#proplength) | Number of device properties. |
90| [Hid_EventTypeArray::hidEventType](#hideventtype) | Event type. |
91| [Hid_EventTypeArray::length](#length-15) | Array length. |
92| [Hid_KeyCodeArray::hidKeyCode](#hidkeycode) | key code. |
93| [Hid_KeyCodeArray::length](#length-25) | Array length. |
94| [Hid_AbsAxesArray::hidAbsAxes](#hidabsaxes) | Array of absolute coordinates. |
95| [Hid_AbsAxesArray::length](#length-35) | Array length. |
96| [Hid_RelAxesArray::hidRelAxes](#hidrelaxes) | Array of relative coordinates. |
97| [Hid_RelAxesArray::length](#length-45) | Array length. |
98| [Hid_MscEventArray::hidMscEvent](#hidmscevent) | Miscellaneous event. |
99| [Hid_MscEventArray::length](#length-55) | Array length. |
100| [Hid_EventProperties::hidEventTypes](#hideventtypes) | Array of event types. |
101| [Hid_EventProperties::hidKeys](#hidkeys) | Array of key codes. |
102| [Hid_EventProperties::hidAbs](#hidabs) | Array of absolute coordinate properties. |
103| [Hid_EventProperties::hidRelBits](#hidrelbits) | Array of relative coordinate properties. |
104| [Hid_EventProperties::hidMiscellaneous](#hidmiscellaneous) | Array of miscellaneous events. |
105| [Hid_EventProperties::hidAbsMax](#hidabsmax) [64] | Maximum values of the absolute coordinates. |
106| [Hid_EventProperties::hidAbsMin](#hidabsmin) [64] | Minimum values of the absolute coordinates. |
107| [Hid_EventProperties::hidAbsFuzz](#hidabsfuzz) [64] | Fuzzy values of the absolute coordinates. |
108| [Hid_EventProperties::hidAbsFlat](#hidabsflat) [64] | Fixed values of the absolute coordinates. |
109
110
111## Type Description
112
113
114### Hid_AbsAxesArray
115
116```
117typedef struct Hid_AbsAxesArrayHid_AbsAxesArray
118```
119**Description**
120Defines a struct for an array of absolute coordinates.
121
122**Since**: 11
123
124
125### Hid_Device
126
127```
128typedef struct Hid_DeviceHid_Device
129```
130**Description**
131Defines a struct for basic device information.
132
133**Since**: 11
134
135
136### Hid_EmitItem
137
138```
139typedef struct Hid_EmitItemHid_EmitItem
140```
141**Description**
142Defines a struct for event information.
143
144**Since**: 11
145
146
147### Hid_EventProperties
148
149```
150typedef struct Hid_EventPropertiesHid_EventProperties
151```
152**Description**
153Defines a struct for the event properties of a device.
154
155**Since**: 11
156
157
158### Hid_EventTypeArray
159
160```
161typedef struct Hid_EventTypeArrayHid_EventTypeArray
162```
163**Description**
164Defines a struct for an array of event types.
165
166**Since**: 11
167
168
169### Hid_KeyCodeArray
170
171```
172typedef struct Hid_KeyCodeArrayHid_KeyCodeArray
173```
174**Description**
175Defines a struct for an array of key codes.
176
177**Since**: 11
178
179
180### Hid_MscEventArray
181
182```
183typedef struct Hid_MscEventArrayHid_MscEventArray
184```
185**Description**
186Defines a struct for an array of miscellaneous events.
187
188**Since**: 11
189
190
191### Hid_RelAxesArray
192
193```
194typedef struct Hid_RelAxesArrayHid_RelAxesArray
195```
196**Description**
197Defines a struct for an array of relative coordinates.
198
199**Since**: 11
200
201
202## Enum Description
203
204
205### Hid_AbsAxes
206
207```
208enum Hid_AbsAxes
209```
210**Description**
211Enumerates the absolute coordinates.
212
213**Since**: 11
214
215| Value| Description|
216| -------- | -------- |
217| HID_ABS_X  | X axis.|
218| HID_ABS_Y  | Y axis.|
219| HID_ABS_Z  | Z axis.|
220| HID_ABS_RX  | X axis of the right analog stick.|
221| HID_ABS_RY  | Y axis of the right analog stick.|
222| HID_ABS_RZ  | Z axis of the right analog stick.|
223| HID_ABS_THROTTLE  | Throttle.|
224| HID_ABS_RUDDER  | Rudder.|
225| HID_ABS_WHEEL  | Scroll wheel.|
226| HID_ABS_GAS  | Gas.|
227| HID_ABS_BRAKE  | Brake.|
228| HID_ABS_HAT0X  | HAT0X |
229| HID_ABS_HAT0Y  | HAT0Y |
230| HID_ABS_HAT1X  | HAT1X |
231| HID_ABS_HAT1Y  | HAT1Y |
232| HID_ABS_HAT2X  | HAT2X |
233| HID_ABS_HAT2Y  | HAT2Y |
234| HID_ABS_HAT3X  | HAT3X |
235| HID_ABS_HAT3Y  | HAT3Y |
236| HID_ABS_PRESSURE  | Pressure.|
237| HID_ABS_DISTANCE  | Distance.|
238| HID_ABS_TILT_X  | Tilt of X axis.|
239| HID_ABS_TILT_Y  | Tilt of Y axis.|
240| HID_ABS_TOOL_WIDTH  | Width of the touch tool.|
241| HID_ABS_VOLUME  | Volume.|
242| HID_ABS_MISC  | Others.|
243
244
245### Hid_DdkErrCode
246
247```
248enum Hid_DdkErrCode
249```
250**Description**
251Enumerates the HID DDK error codes.
252
253**Since**: 11
254
255| Enum| Value| Description|
256| -------- | -------- |-------- |
257| HID_DDK_SUCCESS | 0 | Operation successful.|
258| HID_DDK_NO_PERM | 201 | Permission denied.|
259| HID_DDK_INVALID_PARAMETER | 401 | Invalid parameter.|
260| HID_DDK_FAILURE | 27300001 | Operation failed.|
261| HID_DDK_NULL_PTR | 27300002 | Null pointer.|
262| HID_DDK_INVALID_OPERATION | 27300003 | Invalid operation.|
263| HID_DDK_TIMEOUT | 27300004 | Timeout.|
264
265### Hid_DeviceProp
266
267```
268enum Hid_DeviceProp
269```
270**Description**
271Enumerates the properties of input devices.
272
273**Since**: 11
274
275| Value| Description|
276| -------- | -------- |
277| HID_PROP_POINTER  | Pointer device.|
278| HID_PROP_DIRECT  | Direct input device.|
279| HID_PROP_BUTTON_PAD  | Touch device with bottom keys.|
280| HID_PROP_SEMI_MT  | Full multi-touch device.|
281| HID_PROP_TOP_BUTTON_PAD  | Touch device with top soft keys.|
282| HID_PROP_POINTING_STICK  | Pointing stick.|
283| HID_PROP_ACCELEROMETER  | Accelerometer.|
284
285
286### Hid_EventType
287
288```
289enum Hid_EventType
290```
291**Description**
292Enumerates the event types.
293
294**Since**: 11
295
296| Value| Description|
297| -------- | -------- |
298| HID_EV_SYN  | Sync event.|
299| HID_EV_KEY  | Key event.|
300| HID_EV_REL  | Relative coordinate event.|
301| HID_EV_ABS  | Absolute coordinate event.|
302| HID_EV_MSC  |  Miscellaneous event.|
303
304
305### Hid_KeyCode
306
307```
308enum Hid_KeyCode
309```
310**Description**
311Enumerates the key codes.
312
313**Since**: 11
314
315| Value| Description|
316| -------- | -------- |
317| HID_KEY_A  | Key A.|
318| HID_KEY_B  | Key B.|
319| HID_KEY_C  | Key C.|
320| HID_KEY_D  | Key D.|
321| HID_KEY_E  | Key E.|
322| HID_KEY_F  | Key F.|
323| HID_KEY_G  | Key G.|
324| HID_KEY_H  | Key H.|
325| HID_KEY_I  | Key I.|
326| HID_KEY_J  | Key J.|
327| HID_KEY_K  | Key K.|
328| HID_KEY_L  | Key L.|
329| HID_KEY_M  | Key M.|
330| HID_KEY_N  | Key N.|
331| HID_KEY_O  | Key O.|
332| HID_KEY_P  | Key P.|
333| HID_KEY_Q  | Key Q.|
334| HID_KEY_R  | Key R.|
335| HID_KEY_S  | Key S.|
336| HID_KEY_T  | Key T.|
337| HID_KEY_U  | Key U.|
338| HID_KEY_V  | Key V.|
339| HID_KEY_W  | Key W.|
340| HID_KEY_X  | Key X.|
341| HID_KEY_Y  | Key Y.|
342| HID_KEY_Z  | Key Z.|
343| HID_KEY_ESC  | Key Esc.|
344| HID_KEY_0  | Key 0.|
345| HID_KEY_1  | Key 1.|
346| HID_KEY_2  | Key 2.|
347| HID_KEY_3  | Key 3.|
348| HID_KEY_4  | Key 4.|
349| HID_KEY_5  | Key 5.|
350| HID_KEY_6  | Key 6.|
351| HID_KEY_7  | Key 7.|
352| HID_KEY_8  | Key 8.|
353| HID_KEY_9  | Key 9.|
354| HID_KEY_GRAVE  | Key grave (`).|
355| HID_KEY_MINUS  | Key minus (-).|
356| HID_KEY_EQUALS  | Key equals (=).|
357| HID_KEY_BACKSPACE  | key Backspace.|
358| HID_KEY_LEFT_BRACKET  | Key left bracket ([).|
359| HID_KEY_RIGHT_BRACKET  | Key right bracket (]).|
360| HID_KEY_ENTER  | Key Enter.|
361| HID_KEY_LEFT_SHIFT  | Left Shift.|
362| HID_KEY_BACKSLASH  | Key backslash (\).|
363| HID_KEY_SEMICOLON  | Key semicolon (;).|
364| HID_KEY_APOSTROPHE  | Key apostrophe (').|
365| HID_KEY_SPACE  | Key Space.|
366| HID_KEY_SLASH  | Key slash (/).|
367| HID_KEY_COMMA  | Key comma (,).|
368| HID_KEY_PERIOD  | Key period (.).|
369| HID_KEY_RIGHT_SHIFT  | Right Shift.|
370| HID_KEY_NUMPAD_0  | Numeral 0 on the numeric keypad.|
371| HID_KEY_NUMPAD_1  | Numeral 1 on the numeric keypad.|
372| HID_KEY_NUMPAD_2  | Numeral 2 on the numeric keypad.|
373| HID_KEY_NUMPAD_3  | Numeral 3 on the numeric keypad.|
374| HID_KEY_NUMPAD_4  | Numeral 4 on the numeric keypad.|
375| HID_KEY_NUMPAD_5  | Numeral 5 on the numeric keypad.|
376| HID_KEY_NUMPAD_6  | Numeral 6 on the numeric keypad.|
377| HID_KEY_NUMPAD_7  | Numeral 7 on the numeric keypad.|
378| HID_KEY_NUMPAD_8  | Numeral 8 on the numeric keypad.|
379| HID_KEY_NUMPAD_9  | Numeral 9 on the numeric keypad.|
380| HID_KEY_NUMPAD_DIVIDE  | Arithmetic operator / (division) on the numeric keypad.|
381| HID_KEY_NUMPAD_MULTIPLY  | Arithmetic operator * (multiplication) on the numeric keypad.|
382| HID_KEY_NUMPAD_SUBTRACT  | Arithmetic operator - (subtraction) on the numeric keypad.|
383| HID_KEY_NUMPAD_ADD  | Arithmetic operator + (addition) on the numeric keypad.|
384| HID_KEY_NUMPAD_DOT  | Decimal point (.) on the numeric keypad. |
385| HID_KEY_SYSRQ  | SYSRQ key.|
386| HID_KEY_MUTE  | Mute key.|
387| HID_KEY_VOLUME_DOWN  | Volume Down key.|
388| HID_KEY_VOLUME_UP  | Volume Up key.|
389| HID_KEY_BRIGHTNESS_DOWN  | Brightness Down key.|
390| HID_KEY_BRIGHTNESS_UP  | Brightness Up key.|
391| HID_BTN_0  | Button 0.|
392| HID_BTN_1  | Button 1|
393| HID_BTN_2  | Button 2.|
394| HID_BTN_3  | Button 3.|
395| HID_BTN_4  | Button 4.|
396| HID_BTN_5  | Button 5.|
397| HID_BTN_6  | Button 6.|
398| HID_BTN_7  | Button 7.|
399| HID_BTN_8  | Button 8.|
400| HID_BTN_9  | Button 9.|
401| HID_BTN_LEFT  | Left mouse button.|
402| HID_BTN_RIGHT  | Right mouse button.|
403| HID_BTN_MIDDLE  | Middle mouse button.|
404| HID_BTN_SIDE  | Side mouse button.|
405| HID_BTN_EXTRA  | Extra mouse button.|
406| HID_BTN_FORWARD  | Mouse forward button.|
407| HID_BTN_BACKWARD  | Mouse backward button.|
408| HID_BTN_TASK  | Mouse task button.|
409| HID_BTN_TOOL_PEN  | Pen.|
410| HID_BTN_TOOL_RUBBER  | Eraser.|
411| HID_BTN_TOOL_BRUSH  | Brush.|
412| HID_BTN_TOOL_PENCIL  | Pencil.|
413| HID_BTN_TOOL_AIRBRUSH  | Air brush.|
414| HID_BTN_TOOL_FINGER  | Finger.|
415| HID_BTN_TOOL_MOUSE  | Mouse.|
416| HID_BTN_TOOL_LENS  | Lens.|
417| HID_BTN_TOOL_QUINT_TAP  | Five-finger touch.|
418| HID_BTN_STYLUS3  | Stylus 3.|
419| HID_BTN_TOUCH  | Touch.|
420| HID_BTN_STYLUS  | Stylus.|
421| HID_BTN_STYLUS2  | Stylus 2.|
422| HID_BTN_TOOL_DOUBLE_TAP  | Two-finger touch.|
423| HID_BTN_TOOL_TRIPLE_TAP  | Three-finger touch.|
424| HID_BTN_TOOL_QUAD_TAP  | Four-finger touch.|
425| HID_BTN_WHEEL  | Scroll wheel.|
426
427
428### Hid_MscEvent
429
430```
431enum Hid_MscEvent
432```
433**Description**
434Enumerates miscellaneous input events.
435
436**Since**: 11
437
438| Value| Description|
439| -------- | -------- |
440| HID_MSC_SERIAL  | Serial number.|
441| HID_MSC_PULSE_LED  | Pulse.|
442| HID_MSC_GESTURE  | Gesture.|
443| HID_MSC_RAW  | Start event.|
444| HID_MSC_SCAN  | Scan.|
445| HID_MSC_TIMESTAMP  | Timestamp.|
446
447
448### Hid_RelAxes
449
450```
451enum Hid_RelAxes
452```
453**Description**
454Enumerates the relative coordinates.
455
456**Since**: 11
457
458| Value| Description|
459| -------- | -------- |
460| HID_REL_X  | X axis.|
461| HID_REL_Y  | Y axis.|
462| HID_REL_Z  | Z axis.|
463| HID_REL_RX  | X axis of the right analog stick.|
464| HID_REL_RY  | Y axis of the right analog stick.|
465| HID_REL_RZ  | Z axis of the right analog stick.|
466| HID_REL_HWHEEL  | Horizontal scroll wheel.|
467| HID_REL_DIAL  | Scale.|
468| HID_REL_WHEEL  | Scroll wheel.|
469| HID_REL_MISC  | Others.|
470| HID_REL_RESERVED  | Reserved.|
471| HID_REL_WHEEL_HI_RES  | High-resolution scroll wheel.|
472| HID_REL_HWHEEL_HI_RES  | High-resolution horizontal scroll wheel.|
473
474
475### Hid_SynEvent
476
477```
478enum Hid_SynEvent
479```
480**Description**
481Enumerates sync events.
482
483**Since**: 11
484
485| Value| Description|
486| -------- | -------- |
487| HID_SYN_REPORT  | Indicates the end of an event.|
488| HID_SYN_CONFIG  | Indicates configuration synchronization.|
489| HID_SYN_MT_REPORT  | Indicates the end of a multi-touch ABS data packet.|
490| HID_SYN_DROPPED  | Indicates that the event is discarded.|
491
492
493## Function Description
494
495
496### OH_Hid_CreateDevice()
497
498```
499int32_t OH_Hid_CreateDevice (Hid_Device * hidDevice, Hid_EventProperties * hidEventProperties )
500```
501**Description**
502Creates a device.
503
504**Since**: 11
505
506**Parameters**
507
508| Name| Description|
509| -------- | -------- |
510| hidDevice | Pointer to the basic information about the device to create, including the device name, vendor ID, and product ID. |
511| hidEventProperties | Pointer to the event properties related to the device to create, including the event type, key event properties, absolute coordinate event properties, and relative coordinate event properties. |
512
513**Required Permissions**
514
515ohos.permission.ACCESS_DDK_HID
516
517**Returns**
518
519- deviceID (a non-negative digit): The API call is successful.
520- [HID_DDK_NO_PERM](#hid_ddkerrcode): Permission verification fails.
521- [HID_DDK_INVALID_OPERATION](#hid_ddkerrcode): The hid_ddk service connection fails.
522- [HID_DDK_INVALID_PARAMETER](#hid_ddkerrcode): Parameter verification fails. The possible causes are as follows: 1. The input **hidDevice** is a null pointer. 2. The input **hidEventProperties** is a null pointer. 3. The length of **properties** exceeds 7 characters. 4. The length of **hidEventTypes** exceeds 5 characters. The length of **hidKeys** exceeds 100 characters. 6. The length of **hidAbs** exceeds 26 characters. 7. The length of **hidRelBits** exceeds 13 characters. 8. The length of **hidMiscellaneous** exceeds 6 characters.
523- [HID_DDK_FAILURE](#hid_ddkerrcode): The number of devices reaches the maximum value **200**.
524
525### OH_Hid_DestroyDevice()
526
527```
528int32_t OH_Hid_DestroyDevice (int32_t deviceId)
529```
530**Description**
531Destroys a device.
532
533**Since**: 11
534
535**Parameters**
536
537| Name| Description|
538| -------- | -------- |
539| deviceId | ID of the device to destroy. |
540
541**Required Permissions**
542
543ohos.permission.ACCESS_DDK_HID
544
545**Returns**
546
547- [HID_DDK_SUCCESS](#hid_ddkerrcode): The API call is successful.
548- [HID_DDK_NO_PERM](#hid_ddkerrcode): Permission verification failed.
549- [HID_DDK_INVALID_OPERATION](#hid_ddkerrcode): The hid_ddk service connection fails or the caller is not the device creator.
550
551### OH_Hid_EmitEvent()
552
553```
554int32_t OH_Hid_EmitEvent (int32_t deviceId, const Hid_EmitItem items[], uint16_t length )
555```
556**Description**
557Sends an event list to a device.
558
559**Since**: 11
560
561**Parameters**
562
563| Name| Description|
564| -------- | -------- |
565| deviceId | ID of the target device. |
566| items | List of the events to send. The event information includes the event type (**Hid_EventType**), code (**Hid_SynEvent**, **Hid_KeyCode**, **HidBtnCode**, **Hid_AbsAxes**, **Hid_RelAxes**, or **Hid_MscEvent**), and value (depending on the actual device input). |
567| length | Length of the event list (number of events to be sent at a time). |
568
569**Required Permissions**
570
571ohos.permission.ACCESS_DDK_HID
572
573**Returns**
574
575- [HID_DDK_SUCCESS](#hid_ddkerrcode): The API call is successful.
576- [HID_DDK_NO_PERM](#hid_ddkerrcode): Permission verification failed.
577- [HID_DDK_INVALID_OPERATION](#hid_ddkerrcode): The hid_ddk service connection fails or the caller is not the device creator.
578- [HID_DDK_INVALID_PARAMETER](#hid_ddkerrcode): Parameter verification fails. The possible causes are as follows: 1. The device ID is smaller than 0. 2. The length of the input parameter exceeds 7 characters. 3. The input **items** is a null pointer.
579- [HID_DDK_NULL_PTR](#hid_ddkerrcode): The corresponding device does not exist.
580
581
582## Variable Description
583
584
585### bustype
586
587```
588uint16_t Hid_Device::bustype
589```
590**Description**
591Bus type.
592
593
594### code
595
596```
597uint16_t Hid_EmitItem::code
598```
599**Description**
600Event code.
601
602
603### deviceName
604
605```
606const char* Hid_Device::deviceName
607```
608**Description**
609Device name.
610
611
612### hidAbs
613
614```
615struct Hid_AbsAxesArray Hid_EventProperties::hidAbs
616```
617**Description**
618Array of absolute coordinates.
619
620
621### hidAbsAxes
622
623```
624Hid_AbsAxes* Hid_AbsAxesArray::hidAbsAxes
625```
626**Description**
627Absolute coordinates.
628
629
630### hidAbsFlat
631
632```
633int32_t Hid_EventProperties::hidAbsFlat[64]
634```
635**Description**
636Fixed values of the absolute coordinates.
637
638
639### hidAbsFuzz
640
641```
642int32_t Hid_EventProperties::hidAbsFuzz[64]
643```
644**Description**
645Fuzzy values of the absolute coordinates.
646
647
648### hidAbsMax
649
650```
651int32_t Hid_EventProperties::hidAbsMax[64]
652```
653**Description**
654Maximum values of the absolute coordinates.
655
656
657### hidAbsMin
658
659```
660int32_t Hid_EventProperties::hidAbsMin[64]
661```
662**Description**
663Minimum values of the absolute coordinates.
664
665
666### hidEventType
667
668```
669Hid_EventType* Hid_EventTypeArray::hidEventType
670```
671**Description**
672Event type.
673
674
675### hidEventTypes
676
677```
678struct Hid_EventTypeArray Hid_EventProperties::hidEventTypes
679```
680**Description**
681Array of event types.
682
683
684### hidKeyCode
685
686```
687Hid_KeyCode* Hid_KeyCodeArray::hidKeyCode
688```
689**Description**
690Key code.
691
692
693### hidKeys
694
695```
696struct Hid_KeyCodeArray Hid_EventProperties::hidKeys
697```
698**Description**
699Array of key codes.
700
701
702### hidMiscellaneous
703
704```
705struct Hid_MscEventArray Hid_EventProperties::hidMiscellaneous
706```
707**Description**
708Array of miscellaneous events.
709
710
711### hidMscEvent
712
713```
714Hid_MscEvent* Hid_MscEventArray::hidMscEvent
715```
716**Description**
717Miscellaneous event.
718
719
720### hidRelAxes
721
722```
723Hid_RelAxes* Hid_RelAxesArray::hidRelAxes
724```
725**Description**
726Relative coordinates.
727
728
729### hidRelBits
730
731```
732struct Hid_RelAxesArray Hid_EventProperties::hidRelBits
733```
734**Description**
735Array of relative coordinates.
736
737
738### length [1/5]
739
740```
741uint16_t Hid_EventTypeArray::length
742```
743**Description**
744Length of the event type array.
745
746
747### length [2/5]
748
749```
750uint16_t Hid_KeyCodeArray::length
751```
752**Description**
753Length of the key code array.
754
755
756### length [3/5]
757
758```
759uint16_t Hid_AbsAxesArray::length
760```
761**Description**
762Length of the absolute coordinate array.
763
764
765### length [4/5]
766
767```
768uint16_t Hid_RelAxesArray::length
769```
770**Description**
771Length of the relative coordinate array.
772
773
774### length [5/5]
775
776```
777uint16_t Hid_MscEventArray::length
778```
779**Description**
780Length of the miscellaneous event array.
781
782
783### productId
784
785```
786uint16_t Hid_Device::productId
787```
788**Description**
789Product ID.
790
791
792### properties
793
794```
795Hid_DeviceProp* Hid_Device::properties
796```
797**Description**
798Device properties.
799
800
801### propLength
802
803```
804uint16_t Hid_Device::propLength
805```
806**Description**
807Number of device properties.
808
809
810### type
811
812```
813uint16_t Hid_EmitItem::type
814```
815**Description**
816Event type.
817
818
819### value
820
821```
822uint32_t Hid_EmitItem::value
823```
824**Description**
825Event value.
826
827
828### vendorId
829
830```
831uint16_t Hid_Device::vendorId
832```
833**Description**
834Vendor ID.
835
836
837### version
838
839```
840uint16_t Hid_Device::version
841```
842**Description**
843Version number.
844