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