diff --git a/input/bundle.json b/input/bundle.json new file mode 100644 index 0000000000000000000000000000000000000000..69c6489384eaad5827c793b72aac6cad7a549065 --- /dev/null +++ b/input/bundle.json @@ -0,0 +1,42 @@ +{ + "name": "input_device_driver_interface", + "description": "input device driver interface", + "version": "3.2", + "license": "Apache License 2.0", + "component": { + "name": "input_device_driver_interface", + "subsystem": "hdf", + "syscap": [""], + "adapter_system_type": ["standard"], + "rom": "675KB", + "ram": "1024KB", + "deps": { + "components": [ + "ipc", + "device_driver_framework", + "hiviewdfx_hilog_native", + "utils_base" + ], + "third_part": [ + "bounds_checking_function" + ] + }, + "build": { + "sub_component": [ + "//drivers/interface/input/v1_0:libinput_proxy_1.0" + ], + "test": [ + ], + "inner_kits": [ + { + "name": "//drivers/interface/input/v1_0:libinput_proxy_1.0", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/input" + } + } + ] + } + } + } \ No newline at end of file diff --git a/input/v1_0/BUILD.gn b/input/v1_0/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..17e90a629ff3eba325dd2cf07d008a34e792e86a --- /dev/null +++ b/input/v1_0/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//drivers/adapter/uhdf2/hdi.gni") +if (defined(ohos_lite)) { + group("libinput_proxy_1.0") { + deps = [] + public_configs = [] + } +} else { + hdi("input") { + module_name = "input_service" + + sources = [ + "IInputCallback.idl", + "IInputInterfaces.idl", + "InputTypes.idl", + ] + + language = "cpp" + subsystem_name = "hdf" + part_name = "input_device_driver" + } +} diff --git a/input/v1_0/IInputCallback.idl b/input/v1_0/IInputCallback.idl new file mode 100644 index 0000000000000000000000000000000000000000..1f6cdcb1d8205c1393da4e68aaf993ab55e5c655 --- /dev/null +++ b/input/v1_0/IInputCallback.idl @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /** + * @addtogroup HdiInput + * @{ + * + * @brief Provides driver interfaces for the input service. + * + * These driver interfaces can be used to open and close input device files, get input events, query device information, + * register callback functions, and control the feature status. + * + * @version 1.0 + */ + +package ohos.hdi.input.v1_0; + +import ohos.hdi.input.v1_0.InputTypes; + +[callback] interface IInputCallback { + /** + * @brief Reports input event data by the registered callback. + * + * @param pkgs describes the input event data package. + * @param count Indicates the number of input event data packets. + * @param devIndex Indicates the index of an input device. + * @since 2.2 + * @version 1.0 + */ + EventPkgCallback([in] struct HdfEventPackage[] pkgs, [in] unsigned int count, [in] unsigned int devIndex); + + /** + * @brief Reports hot plug event data by the registered callback. + * + * @param event Indicates the pointer to the hot plug event data reported by the input driver. + * @since 2.2 + * @version 1.0 + */ + HotPlugCallback([in] struct HdfHotPlugEvent event); +} \ No newline at end of file diff --git a/input/v1_0/IInputInterfaces.idl b/input/v1_0/IInputInterfaces.idl new file mode 100644 index 0000000000000000000000000000000000000000..465d69f5ed69c49ebe71a5f1f6c62a690d937363 --- /dev/null +++ b/input/v1_0/IInputInterfaces.idl @@ -0,0 +1,288 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup HdiInput + * @{ + * + * @brief Provides driver interfaces for the input service. + * + * These driver interfaces can be used to open and close input device files, get input events, query device information, + * register callback functions, and control the feature status. + * + * @version 1.0 + */ + +package ohos.hdi.input.v1_0; + +import ohos.hdi.input.v1_0.IInputCallback; +import ohos.hdi.input.v1_0.InputTypes; + +interface IInputInterfaces { + /** + * @brief Scans all online input devices. + * + * @param staArr Indicates the pointer to the array storing information about the scanned input devices, + * including the device index and device type. + * @return Returns 0 if the operation is successful; returns an error code defined in + * {@link RetStatus} otherwise. + * @since 2.2 + * @version 1.0 + */ + ScanInputDevice([out] struct HdfDevDesc[] staArr); + + /** + * @brief Opens a specified input device file. + * + * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. + * The value ranges from 0 to 31, and value 0 represents the first input device. + * @return Returns 0 if the operation is successful; returns an error code defined in + * {@link RetStatus} otherwise. + * @since 2.2 + * @version 1.0 + */ + OpenInputDevice([in] unsigned int devIndex); + + /** + * @brief Closes a specified input device file. + * + * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. + * The value ranges from 0 to 31, and value 0 represents the first input device. + * @return Returns 0 if the operation is successful; returns an error code defined in + * {@link RetStatus} otherwise. + * @since 2.2 + * @version 1.0 + */ + CloseInputDevice([in] unsigned int devIndex); + + /** + * @brief Gets information about a specified input device. + * + * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. + * The value ranges from 0 to 31, and value 0 represents the first input device. + * @param devInfo Indicates the double pointer to information about the specified device. + * For details, see {@link DeviceInfo}. + * @return Returns 0 if the operation is successful; returns an error code defined in + * {@link RetStatus} otherwise. + * @since 2.2 + * @version 1.0 + */ + GetInputDevice([in] unsigned int devIndex, [out] struct HdfDeviceInfo devInfo); + + /** + * @brief Gets information about all input devices in the device list. + * + * @param devNum Indicates the pointer to the total number of input devices which have been registered. + * @param devList Indicates the double pointer to information about all devices in the device list. + * For details, see {@link DeviceInfo}. + * @param size Indicates the number of elements in the devList array. + * @return Returns 0 if the operation is successful; returns an error code defined in + * {@link RetStatus} otherwise. + * @since 2.2 + * @version 1.0 + */ + GetInputDeviceList([in] unsigned int devNum, [out] struct HdfDeviceInfo[] devList, [in]unsigned int size); + + /** + * @brief Sets the power status. + * + * This function is called only when the power status of the OS is changed. \n + * The input service or the power management module can call this function to set the power status + * for the input device when the OS is in the Resume or Suspend status, so that the driver integrated circuit (IC) + * of the device can normally enter the specified status. + * + * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. + * The value ranges from 0 to 31, and value 0 represents the first input device. + * @param status Indicates the power status to set. The input service will notify the input device of entering the + * Resume or Suspend state specified by {@link PowerStatus}. + * @return Returns 0 if the operation is successful; returns an error code defined in + * {@link RetStatus} otherwise. + * @since 2.2 + * @version 1.0 + */ + SetPowerStatus([in] unsigned int devIndex, [in] unsigned int status); + + /** + * @brief Gets the power status. + * + * The input service or the power management module can get the power status for the input device when the OS + * is in the Resume or Suspend status, so that the driver IC of the device can normally enter the specified status. + * You can call this function to obtain the power status. + * + * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. + * The value ranges from 0 to 31, and value 0 represents the first input device. + * @param status Indicates the pointer to the power status of the device. For details, see {@link PowerStatus}. + * @return Returns 0 if the operation is successful; returns an error code defined in + * {@link RetStatus} otherwise. + * @since 2.2 + * @version 1.0 + */ + GetPowerStatus([in] unsigned int devIndex, [out] unsigned int status); + + /** + * @brief Gets the type of the input device based on the specified device index. + * + * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. + * The value ranges from 0 to 31, and value 0 represents the first input device. + * @param deviceType Indicates the pointer to the device type. For details, see {@link InputDevType}. + * @return Returns 0 if the operation is successful; returns an error code defined + * in {@link RetStatus} otherwise. + * @since 2.2 + * @version 1.0 + */ + GetDeviceType([in] unsigned int devIndex, [out] unsigned int deviceType); + + /** + * @brief Gets the chip information of the specified device. + * + * A product is usually equipped with modules and driver ICs provided by multiple vendors. An input service + * can call this function to get the specific information if needed. + * + * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. + * The value ranges from 0 to 31, and value 0 represents the first input device. + * @param chipInfo Indicates the pointer to the chip information. + * @return Returns 0 if the operation is successful; returns an error code defined + * in {@link RetStatus} otherwise. + * @since 2.2 + * @version 1.0 + */ + GetChipInfo([in] unsigned int devIndex, [out] String chipInfo); + + /** + * @brief Gets the module vendor name of the specified device. + * + * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. + * The value ranges from 0 to 31, and value 0 represents the first input device. + * @param vendorName Indicates the pointer to the module vendor name. + * @return Returns 0 if the operation is successful; returns an error code defined + * in {@link RetStatus} otherwise. + * @since 2.2 + * @version 1.0 + */ + GetVendorName([in] unsigned int devIndex, [out] String vendorName); + + /** + * @brief Gets the driver chip name of the specified device. + * + * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. + * The value ranges from 0 to 31, and value 0 represents the first input device. + * @param chipName Indicates the pointer to the driver chip name. + * @return Returns 0 if the operation is successful; returns an error code defined + * in {@link RetStatus} otherwise. + * @since 2.2 + * @version 1.0 + */ + GetChipName([in] unsigned int devIndex, [out] String chipName); + + /** + * @brief Sets the gesture mode. + * + * The input service can use this function to enable or disable the gesture mode by setting EnableBit + * of the gesture mode. + * + * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. + * The value ranges from 0 to 31, and value 0 represents the first input device. + * @param gestureMode Indicates the gesture mode to set. + * @return Returns 0 if the operation is successful; returns an error code defined + * in {@link RetStatus} otherwise. + * @since 2.2 + * @version 1.0 + */ + SetGestureMode([in] unsigned int devIndex, [in] unsigned int gestureMode); + + /** + * @brief Conducts a capacitance self-test. + * + * The capacitance self-test items are defined by the component vendor, such as the tests on the raw data, + * short circuit, open circuit, interference, and row/column difference. + * + * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. + * The value ranges from 0 to 31, and value 0 represents the first input device. + * @param testType Indicates the capacitance test type. For details, see {@link CapacitanceTest}. + * @param result Indicates the pointer to the capacitance test result. The value is SUCC for a successful + * operation and is an error code for a failed operation. + * @param length Indicates the length of the test result. The minimum value of length is 20. + * @return Returns 0 if the operation is successful; returns an error code defined + * in {@link RetStatus} otherwise. + * @since 2.2 + * @version 1.0 + */ + RunCapacitanceTest([in] unsigned int devIndex, [in] unsigned int testType, [out] String result, [in] unsigned int length); + + /** + * @brief Executes the extra command. + * + * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. + * The value ranges from 0 to 31, and value 0 represents the first input device. + * @param cmd Indicates the pointer to the extra command data packet, including the command codes and parameters. + * For details, see {@link InputExtraCmd}. + * @return Returns 0 if the operation is successful; returns an error code defined + * in {@link RetStatus} otherwise. + * @since 2.2 + * @version 1.0 + */ + RunExtraCommand([in] unsigned int devIndex, [in] struct HdfInputExtraCmd cmd); + + /** + * @brief Register a callback for reporting subscribed data of specified input devices. + * + * After this callback is successfully registered, the driver can report the input event data to the input service + * through this callback. + * + * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. + * The value ranges from 0 to 31, and value 0 represents the first input device. + * @param callback Indicates the pointer to the callback to register. + * @return Returns 0 if the operation is successful; returns an error code defined in + * {@link RetStatus} otherwise. + * @since 2.2 + * @version 1.0 + */ + RegisterReportCallback([in] unsigned int devIndex, [in] IInputCallback eventPkgCallback); + + /** + * @brief Unregister the callback for reporting subscribed data of specified input devices. + * + * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. + * The value ranges from 0 to 31, and value 0 represents the first input device. + * @return Returns 0 if the operation is successful; returns an error code defined in + * {@link RetStatus} otherwise. + * @since 2.2 + * @version 1.0 + */ + UnregisterReportCallback([in] unsigned int devIndex); + + /** + * @brief Register a hot plug callback to the HDIs for input devices. + * + * All input devices can use this callback to report hot plug events. + * + * @param callback Indicates the pointer to the callback to register. + * @return Returns 0 if the operation is successful; returns an error code defined in + * {@link RetStatus} otherwise. + * @since 2.2 + * @version 1.0 + */ + RegisterHotPlugCallback([in] IInputCallback hotPlugCallback); + + /** + * @brief Unregister the hot plug callback of input devices. + * + * @return Returns 0 if the operation is successful; returns an error code defined in + * {@link RetStatus} otherwise. + * @since 2.2 + * @version 1.0 + */ + UnregisterHotPlugCallback(); +} \ No newline at end of file diff --git a/input/v1_0/InputTypes.idl b/input/v1_0/InputTypes.idl new file mode 100644 index 0000000000000000000000000000000000000000..845cf411fe01b588471f7b692bd92a29b941bdda --- /dev/null +++ b/input/v1_0/InputTypes.idl @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ohos.hdi.input.v1_0; + +struct HdfDevDesc { + unsigned int devIndex; + unsigned int devType; +}; + +struct HdfInputDevIdentify { + unsigned short busType; + unsigned short vendor; + unsigned short product; + unsigned short version; +}; + +struct HdfDimensionInfo { + int axis; + int min; + int max; + int fuzz; + int flat; + int range; +}; + +struct HdfDevAttr { + String devName; + struct HdfInputDevIdentify id; + struct HdfDimensionInfo[] axisInfo; +}; + +struct HdfDevAbility { + unsigned long[] devProp; + unsigned long[] eventType; + unsigned long[] absCode; + unsigned long[] relCode; + unsigned long[] keyCode; + unsigned long[] ledCode; + unsigned long[] miscCode; + unsigned long[] soundCode; + unsigned long[] forceCode; + unsigned long[] switchCode; + unsigned long[] keyType; + unsigned long[] ledType; + unsigned long[] soundType; + unsigned long[] switchType; +}; + +/** + * @brief Describes basic device information of the input device. + */ +struct HdfDeviceInfo { + unsigned int devIndex; /**< Device index */ + unsigned int devType; /**< Device type */ + String chipInfo; /**< Driver chip information */ + String vendorName; /**< Module vendor name */ + String chipName; /**< Driver chip name */ + struct HdfDevAttr attrSet; + struct HdfDevAbility abilitySet; +}; + +/** + * @brief Describes the extra commands. + */ +struct HdfInputExtraCmd { + String cmdCode; /**< Command code */ + String cmdValue; /**< Data transmitted in the command */ +}; + +struct HdfHotPlugEvent { + unsigned int devIndex; + unsigned int devType; + unsigned int status; +}; + +/** + * @brief Describes the input event data package. + */ +struct HdfEventPackage { + unsigned int type; /**< Type of the input event */ + unsigned int code; /**< Specific code item of the input event */ + int value; /**< Value of the input event code item */ + unsigned long timestamp; /**< Timestamp of the input event */ +};