1094332d3Sopenharmony_ci/*
2094332d3Sopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License.
5094332d3Sopenharmony_ci * You may obtain a copy of the License at
6094332d3Sopenharmony_ci *
7094332d3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8094332d3Sopenharmony_ci *
9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and
13094332d3Sopenharmony_ci * limitations under the License.
14094332d3Sopenharmony_ci */
15094332d3Sopenharmony_ci
16094332d3Sopenharmony_ci/**
17094332d3Sopenharmony_ci * @addtogroup Input
18094332d3Sopenharmony_ci * @{
19094332d3Sopenharmony_ci *
20094332d3Sopenharmony_ci * @brief Provides driver interfaces for the input service.
21094332d3Sopenharmony_ci *
22094332d3Sopenharmony_ci * These driver interfaces can be used to open and close input device files, get input events, query device information,
23094332d3Sopenharmony_ci * register callback functions, and control the feature status.
24094332d3Sopenharmony_ci *
25094332d3Sopenharmony_ci * @since 1.0
26094332d3Sopenharmony_ci * @version 1.0
27094332d3Sopenharmony_ci */
28094332d3Sopenharmony_ci
29094332d3Sopenharmony_ci/**
30094332d3Sopenharmony_ci * @file input_manager.h
31094332d3Sopenharmony_ci *
32094332d3Sopenharmony_ci * @brief Declares the driver interfaces for managing input devices.
33094332d3Sopenharmony_ci *
34094332d3Sopenharmony_ci * @since 1.0
35094332d3Sopenharmony_ci * @version 1.0
36094332d3Sopenharmony_ci */
37094332d3Sopenharmony_ci
38094332d3Sopenharmony_ci#ifndef INPUT_MANAGER_H
39094332d3Sopenharmony_ci#define INPUT_MANAGER_H
40094332d3Sopenharmony_ci
41094332d3Sopenharmony_ci#include "input_controller.h"
42094332d3Sopenharmony_ci#include "input_reporter.h"
43094332d3Sopenharmony_ci#include "input_type.h"
44094332d3Sopenharmony_ci
45094332d3Sopenharmony_ci#ifdef __cplusplus
46094332d3Sopenharmony_ciextern "C" {
47094332d3Sopenharmony_ci#endif
48094332d3Sopenharmony_ci
49094332d3Sopenharmony_ci/**
50094332d3Sopenharmony_ci * @brief Provides interfaces for managing input devices.
51094332d3Sopenharmony_ci *
52094332d3Sopenharmony_ci * The interfaces can be used to perform basic operations on the input devices, such as scanning online devices,
53094332d3Sopenharmony_ci * opening and closing the device files, querying information about a specified input device, and obtaining information
54094332d3Sopenharmony_ci * about all input devices in the device list.
55094332d3Sopenharmony_ci */
56094332d3Sopenharmony_citypedef struct {
57094332d3Sopenharmony_ci    /**
58094332d3Sopenharmony_ci     * @brief Scans all online input devices.
59094332d3Sopenharmony_ci     *
60094332d3Sopenharmony_ci     * @param staArr Indicates the pointer to the array storing information about the scanned input devices,
61094332d3Sopenharmony_ci     * including the device index and device type.
62094332d3Sopenharmony_ci     * @param arrLen Indicates the length of the array.
63094332d3Sopenharmony_ci     * @return Returns <b>INPUT SUCCESS</b> if the operation is successful; returns an error code defined in
64094332d3Sopenharmony_ci     * {@link RetStatus} otherwise.
65094332d3Sopenharmony_ci     * @since 1.0
66094332d3Sopenharmony_ci     * @version 1.0
67094332d3Sopenharmony_ci     */
68094332d3Sopenharmony_ci    int32_t (*ScanInputDevice)(InputDevDesc *staArr, uint32_t arrLen);
69094332d3Sopenharmony_ci
70094332d3Sopenharmony_ci    /**
71094332d3Sopenharmony_ci     * @brief Opens a specified input device file.
72094332d3Sopenharmony_ci     *
73094332d3Sopenharmony_ci     * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported.
74094332d3Sopenharmony_ci     * The value ranges from 0 to 31, and value <b>0</b> represents the first input device.
75094332d3Sopenharmony_ci     * @return Returns <b>INPUT SUCCESS</b> if the operation is successful; returns an error code defined in
76094332d3Sopenharmony_ci     * {@link RetStatus} otherwise.
77094332d3Sopenharmony_ci     * @since 1.0
78094332d3Sopenharmony_ci     * @version 1.0
79094332d3Sopenharmony_ci     */
80094332d3Sopenharmony_ci    int32_t (*OpenInputDevice)(uint32_t devIndex);
81094332d3Sopenharmony_ci
82094332d3Sopenharmony_ci    /**
83094332d3Sopenharmony_ci     * @brief Closes a specified input device file.
84094332d3Sopenharmony_ci     *
85094332d3Sopenharmony_ci     * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported.
86094332d3Sopenharmony_ci     * The value ranges from 0 to 31, and value <b>0</b> represents the first input device.
87094332d3Sopenharmony_ci     * @return Returns <b>INPUT SUCCESS</b> if the operation is successful; returns an error code defined in
88094332d3Sopenharmony_ci     * {@link RetStatus} otherwise.
89094332d3Sopenharmony_ci     * @since 1.0
90094332d3Sopenharmony_ci     * @version 1.0
91094332d3Sopenharmony_ci     */
92094332d3Sopenharmony_ci    int32_t (*CloseInputDevice)(uint32_t devIndex);
93094332d3Sopenharmony_ci
94094332d3Sopenharmony_ci    /**
95094332d3Sopenharmony_ci     * @brief Gets information about a specified input device.
96094332d3Sopenharmony_ci     *
97094332d3Sopenharmony_ci     * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported.
98094332d3Sopenharmony_ci     * The value ranges from 0 to 31, and value <b>0</b> represents the first input device.
99094332d3Sopenharmony_ci     * @param devInfo Indicates the double pointer to information about the specified device.
100094332d3Sopenharmony_ci     * For details, see {@link DeviceInfo}.
101094332d3Sopenharmony_ci     * @return Returns <b>INPUT SUCCESS</b> if the operation is successful; returns an error code defined in
102094332d3Sopenharmony_ci     * {@link RetStatus} otherwise.
103094332d3Sopenharmony_ci     * @since 1.0
104094332d3Sopenharmony_ci     * @version 1.0
105094332d3Sopenharmony_ci     */
106094332d3Sopenharmony_ci    int32_t (*GetInputDevice)(uint32_t devIndex, InputDeviceInfo **devInfo);
107094332d3Sopenharmony_ci
108094332d3Sopenharmony_ci    /**
109094332d3Sopenharmony_ci     * @brief Gets information about all input devices in the device list.
110094332d3Sopenharmony_ci     *
111094332d3Sopenharmony_ci     * @param devNum Indicates the pointer to the total number of input devices which have been registered.
112094332d3Sopenharmony_ci     * @param devList Indicates the double pointer to information about all devices in the device list.
113094332d3Sopenharmony_ci     * For details, see {@link DeviceInfo}.
114094332d3Sopenharmony_ci     * @param size Indicates the number of elements in the <b>devList</b> array.
115094332d3Sopenharmony_ci     * @return Returns <b>INPUT SUCCESS</b> if the operation is successful; returns an error code defined in
116094332d3Sopenharmony_ci     * {@link RetStatus} otherwise.
117094332d3Sopenharmony_ci     * @since 1.0
118094332d3Sopenharmony_ci     * @version 1.0
119094332d3Sopenharmony_ci     */
120094332d3Sopenharmony_ci    int32_t (*GetInputDeviceList)(uint32_t *devNum, InputDeviceInfo **devList, uint32_t size);
121094332d3Sopenharmony_ci} InputManager;
122094332d3Sopenharmony_ci
123094332d3Sopenharmony_ci/**
124094332d3Sopenharmony_ci * @brief Defines interfaces for providing driver capabilities of input devices.
125094332d3Sopenharmony_ci */
126094332d3Sopenharmony_citypedef struct {
127094332d3Sopenharmony_ci    InputManager *iInputManager;        /**< Device management interface for input devices */
128094332d3Sopenharmony_ci    InputController *iInputController;  /**< Service control interface for input devices */
129094332d3Sopenharmony_ci    InputReporter *iInputReporter;      /**< Data reporting interface for input devices */
130094332d3Sopenharmony_ci} IInputInterface;
131094332d3Sopenharmony_ci
132094332d3Sopenharmony_ci/**
133094332d3Sopenharmony_ci * @brief Gets all interfaces for performing operations on input devices.
134094332d3Sopenharmony_ci *
135094332d3Sopenharmony_ci * @param interface Indicates the double pointer to the interfaces for performing operations on input devices.
136094332d3Sopenharmony_ci * @return Returns <b>INPUT SUCCESS</b> if the operation is successful; returns an error code defined in
137094332d3Sopenharmony_ci * {@link RetStatus} otherwise.
138094332d3Sopenharmony_ci * @since 1.0
139094332d3Sopenharmony_ci * @version 1.0
140094332d3Sopenharmony_ci */
141094332d3Sopenharmony_ciint32_t GetInputInterface(IInputInterface **interface);
142094332d3Sopenharmony_ci
143094332d3Sopenharmony_ci/**
144094332d3Sopenharmony_ci * @brief Releases all interfaces for performing operations on input devices.
145094332d3Sopenharmony_ci *
146094332d3Sopenharmony_ci * @param inputInterface Indicates the pointer to the interfaces for performing operations on input devices.
147094332d3Sopenharmony_ci * @return Returns <b>INPUT SUCCESS</b> if the operation is successful; returns an error code defined in
148094332d3Sopenharmony_ci * {@link RetStatus} otherwise.
149094332d3Sopenharmony_ci * @since 1.0
150094332d3Sopenharmony_ci * @version 1.0
151094332d3Sopenharmony_ci */
152094332d3Sopenharmony_civoid ReleaseInputInterface(IInputInterface **inputInterface);
153094332d3Sopenharmony_ci
154094332d3Sopenharmony_ci#ifdef __cplusplus
155094332d3Sopenharmony_ci}
156094332d3Sopenharmony_ci#endif
157094332d3Sopenharmony_ci#endif
158094332d3Sopenharmony_ci/** @} */
159