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#ifndef HID_DDK_API_H
16#define HID_DDK_API_H
17
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 * @syscap SystemCapability.Driver.HID.Extension
25 * @since 11
26 * @version 1.0
27 */
28
29/**
30 * @file hid_ddk_api.h
31 *
32 * @brief Declares the HID DDK interfaces for the host to access an input device.
33 *
34 * File to include: <hid/hid_ddk_api.h>
35 * @since 11
36 * @version 1.0
37 */
38
39#include <stdint.h>
40#include "hid_ddk_types.h"
41
42#ifdef __cplusplus
43extern "C" {
44#endif /* __cplusplus */
45
46/**
47  * @brief Creates a device.
48 *
49 * @permission ohos.permission.ACCESS_DDK_HID
50 * @param hidDevice Pointer to the basic information required for creating a device, including the device name,
51 * vendor ID, and product ID.
52 * @param hidEventProperties Pointer to the events of the device to be observed, including the event type and
53 * properties of the key event, absolute coordinate event, and relative coordinate event.
54 * @return Returns the device ID (a non-negative number) if the operation is successful;
55 * returns a negative number otherwise.
56 * @since 11
57 * @version 1.0
58 */
59int32_t OH_Hid_CreateDevice(Hid_Device *hidDevice, Hid_EventProperties *hidEventProperties);
60
61/**
62 * @brief Sends an event list to a device.
63 *
64 * @permission ohos.permission.ACCESS_DDK_HID
65 * @param deviceId ID of the device, to which the event list is sent.
66 * @param items List of events to sent. The event information includes the event type (<b>Hid_EventType</b>),
67 * event code (<b>Hid_SynEvent</b> for a synchronization event code, <b>Hid_KeyCode</b> for a key code,
68 * <b>Hid_AbsAxes</b> for an absolute coordinate code, <b>Hid_RelAxes</b> for a relative coordinate event,
69 * and <b>Hid_MscEvent</b> for other input event code), and value input by the device.
70 * @param length Length of the event list (number of events sent at a time).
71 * @return Returns <b>0</b> if the operation is successful; returns a negative number otherwise.
72 * @since 11
73 * @version 1.0
74 */
75int32_t OH_Hid_EmitEvent(int32_t deviceId, const Hid_EmitItem items[], uint16_t length);
76
77/**
78 * @brief Destroys a device.
79 *
80 * @permission ohos.permission.ACCESS_DDK_HID
81 * @param deviceId ID of the device to destroy.
82 * @return Returns <b>0</b> if the operation is successful; returns a negative number otherwise.
83 * @since 11
84 * @version 1.0
85 */
86int32_t OH_Hid_DestroyDevice(int32_t deviceId);
87
88#ifdef __cplusplus
89}
90#endif /* __cplusplus */
91
92#endif // HID_DDK_API_H
93