• 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 HidDdk
18  * @{
19  *
20  * @brief Provides HID DDK interfaces, including creating a device, sending an event, and destroying a device.
21  *
22  * @syscap SystemCapability.Driver.HID.Extension
23  * @since 11
24  * @version 1.0
25  */
26 
27 /**
28  * @file hid_ddk_api.h
29  *
30  * @brief Declares the HID DDK interfaces for the host to access an input device.
31  *
32  * @kit DriverDevelopmentKit
33  * @library libhid.z.so
34  * @syscap SystemCapability.Driver.HID.Extension
35  * File to include: <hid/hid_ddk_api.h>
36  * @since 11
37  * @version 1.0
38  */
39 
40 #ifndef HID_DDK_API_H
41 #define HID_DDK_API_H
42 
43 #include <stdint.h>
44 #include "hid_ddk_types.h"
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif /* __cplusplus */
49 
50 /**
51   * @brief Creates a device.
52  *
53  * @permission ohos.permission.ACCESS_DDK_HID
54  * @param hidDevice Pointer to the basic information required for creating a device, including the device name,
55  * vendor ID, and product ID.
56  * @param hidEventProperties Pointer to the events of the device to be observed, including the event type and
57  * properties of the key event, absolute coordinate event, and relative coordinate event.
58  * @return device ID (a non-negative number), if the operation is successful;
59  *         {@link HID_DDK_NO_PERM} permission check failed.
60  *         {@link HID_DDK_INVALID_OPERATION} connect hid ddk service failed.
61  *         {@link HID_DDK_INVALID_PARAMETER} parameter check failed. Possible causes: 1.hidDevice is null;\n
62  *         2.hidEventProperties is null; 3.properties length exceeds 7; 4.hidEventTypes length exceeds 5;\n
63  *         5.hidKeys length exceeds 100; 6.hidAbs length exceeds 26; 7.hidRelBits length exceeds 13;\n
64  *         8.hidMiscellaneous length exceeds 6.
65  *         {@link HID_DDK_FAILURE} the number of device reaches the maximum 200.
66  * @since 11
67  * @version 1.0
68  */
69 int32_t OH_Hid_CreateDevice(Hid_Device *hidDevice, Hid_EventProperties *hidEventProperties);
70 
71 /**
72  * @brief Sends an event list to a device.
73  *
74  * @permission ohos.permission.ACCESS_DDK_HID
75  * @param deviceId ID of the device, to which the event list is sent.
76  * @param items List of events to sent. The event information includes the event type (<b>Hid_EventType</b>),
77  * event code (<b>Hid_SynEvent</b> for a synchronization event code, <b>Hid_KeyCode</b> for a key code,
78  * <b>Hid_AbsAxes</b> for an absolute coordinate code, <b>Hid_RelAxes</b> for a relative coordinate event,
79  * and <b>Hid_MscEvent</b> for other input event code), and value input by the device.
80  * @param length Length of the event list (number of events sent at a time).
81  * @return {@link HID_DDK_SUCCESS} operation successful.
82  *         {@link HID_DDK_NO_PERM} permission check failed.
83  *         {@link HID_DDK_INVALID_OPERATION} connect hid ddk service failed or the caller is not the creator of device.
84  *         {@link HID_DDK_INVALID_PARAMETER} parameter check failed. Possible causes: 1.deviceId is less than 0;\n
85  *         2.length exceeds 7; 3.items is null.
86  *         {@link HID_DDK_NULL_PTR} the inject of device is null.
87  *         {@link HID_DDK_FAILURE} the device does not exit.
88  * @since 11
89  * @version 1.0
90  */
91 int32_t OH_Hid_EmitEvent(int32_t deviceId, const Hid_EmitItem items[], uint16_t length);
92 
93 /**
94  * @brief Destroys a device.
95  *
96  * @permission ohos.permission.ACCESS_DDK_HID
97  * @param deviceId ID of the device to destroy.
98  * @return {@link HID_DDK_SUCCESS} operation successful.
99  *         {@link HID_DDK_NO_PERM} permission check failed.
100  *         {@link HID_DDK_INVALID_OPERATION} connect hid ddk service failed or the caller is not the creator of device.
101  *         {@link HID_DDK_FAILURE} the device does not exit.
102  * @since 11
103  * @version 1.0
104  */
105 int32_t OH_Hid_DestroyDevice(int32_t deviceId);
106 /** @} */
107 #ifdef __cplusplus
108 }
109 #endif /* __cplusplus */
110 
111 #endif // HID_DDK_API_H
112