112636162Sopenharmony_ci/* 212636162Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 312636162Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 412636162Sopenharmony_ci * you may not use this file except in compliance with the License. 512636162Sopenharmony_ci * You may obtain a copy of the License at 612636162Sopenharmony_ci * 712636162Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 812636162Sopenharmony_ci * 912636162Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1012636162Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1112636162Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1212636162Sopenharmony_ci * See the License for the specific language governing permissions and 1312636162Sopenharmony_ci * limitations under the License. 1412636162Sopenharmony_ci */ 1512636162Sopenharmony_ci#ifndef HID_DDK_API_H 1612636162Sopenharmony_ci#define HID_DDK_API_H 1712636162Sopenharmony_ci 1812636162Sopenharmony_ci/** 1912636162Sopenharmony_ci * @addtogroup HidDdk 2012636162Sopenharmony_ci * @{ 2112636162Sopenharmony_ci * 2212636162Sopenharmony_ci * @brief Provides HID DDK interfaces, including creating a device, sending an event, and destroying a device. 2312636162Sopenharmony_ci * 2412636162Sopenharmony_ci * @syscap SystemCapability.Driver.HID.Extension 2512636162Sopenharmony_ci * @since 11 2612636162Sopenharmony_ci * @version 1.0 2712636162Sopenharmony_ci */ 2812636162Sopenharmony_ci 2912636162Sopenharmony_ci/** 3012636162Sopenharmony_ci * @file hid_ddk_api.h 3112636162Sopenharmony_ci * 3212636162Sopenharmony_ci * @brief Declares the HID DDK interfaces for the host to access an input device. 3312636162Sopenharmony_ci * 3412636162Sopenharmony_ci * File to include: <hid/hid_ddk_api.h> 3512636162Sopenharmony_ci * @since 11 3612636162Sopenharmony_ci * @version 1.0 3712636162Sopenharmony_ci */ 3812636162Sopenharmony_ci 3912636162Sopenharmony_ci#include <stdint.h> 4012636162Sopenharmony_ci#include "hid_ddk_types.h" 4112636162Sopenharmony_ci 4212636162Sopenharmony_ci#ifdef __cplusplus 4312636162Sopenharmony_ciextern "C" { 4412636162Sopenharmony_ci#endif /* __cplusplus */ 4512636162Sopenharmony_ci 4612636162Sopenharmony_ci/** 4712636162Sopenharmony_ci * @brief Creates a device. 4812636162Sopenharmony_ci * 4912636162Sopenharmony_ci * @permission ohos.permission.ACCESS_DDK_HID 5012636162Sopenharmony_ci * @param hidDevice Pointer to the basic information required for creating a device, including the device name, 5112636162Sopenharmony_ci * vendor ID, and product ID. 5212636162Sopenharmony_ci * @param hidEventProperties Pointer to the events of the device to be observed, including the event type and 5312636162Sopenharmony_ci * properties of the key event, absolute coordinate event, and relative coordinate event. 5412636162Sopenharmony_ci * @return Returns the device ID (a non-negative number) if the operation is successful; 5512636162Sopenharmony_ci * returns a negative number otherwise. 5612636162Sopenharmony_ci * @since 11 5712636162Sopenharmony_ci * @version 1.0 5812636162Sopenharmony_ci */ 5912636162Sopenharmony_ciint32_t OH_Hid_CreateDevice(Hid_Device *hidDevice, Hid_EventProperties *hidEventProperties); 6012636162Sopenharmony_ci 6112636162Sopenharmony_ci/** 6212636162Sopenharmony_ci * @brief Sends an event list to a device. 6312636162Sopenharmony_ci * 6412636162Sopenharmony_ci * @permission ohos.permission.ACCESS_DDK_HID 6512636162Sopenharmony_ci * @param deviceId ID of the device, to which the event list is sent. 6612636162Sopenharmony_ci * @param items List of events to sent. The event information includes the event type (<b>Hid_EventType</b>), 6712636162Sopenharmony_ci * event code (<b>Hid_SynEvent</b> for a synchronization event code, <b>Hid_KeyCode</b> for a key code, 6812636162Sopenharmony_ci * <b>Hid_AbsAxes</b> for an absolute coordinate code, <b>Hid_RelAxes</b> for a relative coordinate event, 6912636162Sopenharmony_ci * and <b>Hid_MscEvent</b> for other input event code), and value input by the device. 7012636162Sopenharmony_ci * @param length Length of the event list (number of events sent at a time). 7112636162Sopenharmony_ci * @return Returns <b>0</b> if the operation is successful; returns a negative number otherwise. 7212636162Sopenharmony_ci * @since 11 7312636162Sopenharmony_ci * @version 1.0 7412636162Sopenharmony_ci */ 7512636162Sopenharmony_ciint32_t OH_Hid_EmitEvent(int32_t deviceId, const Hid_EmitItem items[], uint16_t length); 7612636162Sopenharmony_ci 7712636162Sopenharmony_ci/** 7812636162Sopenharmony_ci * @brief Destroys a device. 7912636162Sopenharmony_ci * 8012636162Sopenharmony_ci * @permission ohos.permission.ACCESS_DDK_HID 8112636162Sopenharmony_ci * @param deviceId ID of the device to destroy. 8212636162Sopenharmony_ci * @return Returns <b>0</b> if the operation is successful; returns a negative number otherwise. 8312636162Sopenharmony_ci * @since 11 8412636162Sopenharmony_ci * @version 1.0 8512636162Sopenharmony_ci */ 8612636162Sopenharmony_ciint32_t OH_Hid_DestroyDevice(int32_t deviceId); 8712636162Sopenharmony_ci 8812636162Sopenharmony_ci#ifdef __cplusplus 8912636162Sopenharmony_ci} 9012636162Sopenharmony_ci#endif /* __cplusplus */ 9112636162Sopenharmony_ci 9212636162Sopenharmony_ci#endif // HID_DDK_API_H 93