• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2024 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 #ifndef INPUT_MANAGER_H
17 #define INPUT_MANAGER_H
18 
19 #include <list>
20 #include <map>
21 #include <memory>
22 #include <vector>
23 
24 #include "event_handler.h"
25 #include "nocopyable.h"
26 
27 #include "error_multimodal.h"
28 #include "extra_data.h"
29 #include "i_anr_observer.h"
30 #include "i_input_device_listener.h"
31 #include "i_input_event_consumer.h"
32 #include "i_input_event_filter.h"
33 #include "i_input_service_watcher.h"
34 #include "mmi_event_observer.h"
35 #include "i_window_checker.h"
36 #include "input_device.h"
37 #include "key_option.h"
38 #include "pointer_style.h"
39 #include "window_info.h"
40 
41 namespace OHOS {
42 namespace MMI {
43 class InputManager {
44 public:
45     /**
46      * @brief Obtains an <b>InputManager</b> instance.
47      * @return Returns the pointer to the <b>InputManager</b> instance.
48      * @since 9
49      */
50     static InputManager *GetInstance();
51     virtual ~InputManager() = default;
52 
53     int32_t GetDisplayBindInfo(DisplayBindInfos &infos);
54     int32_t SetDisplayBind(int32_t deviceId, int32_t displayId, std::string &msg);
55 
56     /**
57      * @brief Updates the screen and window information.
58      * @param displayGroupInfo Indicates the logical screen information.
59      * @since 9
60      */
61     void UpdateDisplayInfo(const DisplayGroupInfo &displayGroupInfo);
62 
63     /**
64      * @brief Updates the windows information.
65      * @param windowGroupInfo Indicates the window group information.
66      * @since 9
67      */
68     void UpdateWindowInfo(const WindowGroupInfo &windowGroupInfo);
69 
70     int32_t AddInputEventFilter(std::shared_ptr<IInputEventFilter> filter, int32_t priority, uint32_t deviceTags);
71     int32_t RemoveInputEventFilter(int32_t filterId);
72 
73     /**
74      * @brief Updates the process info to other server.
75      * @param observer Indicates the progess info.
76      * @return the observer setting successed or not.
77      * @since 10
78      */
79     int32_t AddInputEventObserver(std::shared_ptr<MMIEventObserver> observer);
80 
81     /**
82      * @brief Callback interface of the remove module.
83      * @param observer Indicates the progess info.
84      * @return EC_OK if unsubscribe successfully, else return other errcodes.
85      * @since 10
86      */
87     int32_t RemoveInputEventObserver(std::shared_ptr<MMIEventObserver> observer = nullptr);
88 
89     /**
90      * @brief Set the process info to mmi server.
91      * @param pid Indicates pid.
92      * @param uid Indicates uid.
93      * @param bundleName Indicates bundleName.
94      * @param napStatus Indicates napStatus.
95      * @since 10
96      */
97     void SetNapStatus(int32_t pid, int32_t uid, std::string bundleName, int32_t napStatus);
98 
99     /**
100      * @brief Get the process info datas to other server.
101      * @param callback Indicates the callback used to receive the reported data.
102      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
103      * @since 10
104      */
105     int32_t GetAllMmiSubscribedEvents(std::map<std::tuple<int32_t, int32_t, std::string>, int32_t> &datas);
106 
107     /**
108      * @brief Sets a consumer for the window input event of the current process.
109      * @param inputEventConsumer Indicates the consumer to set. The window input event of the current process
110      * will be called back to the consumer object for processing.
111      * @since 9
112      */
113     void SetWindowInputEventConsumer(std::shared_ptr<IInputEventConsumer> inputEventConsumer);
114 
115     /**
116      * @brief Sets a window input event consumer that runs on the specified thread.
117      * @param inputEventConsumer Indicates the consumer to set.
118      * @param eventHandler Indicates the thread running the consumer.
119      * @since 9
120      */
121     void SetWindowInputEventConsumer(std::shared_ptr<IInputEventConsumer> inputEventConsumer,
122         std::shared_ptr<AppExecFwk::EventHandler> eventHandler);
123 
124     /**
125      * @brief Subscribes to the key input event that meets a specific condition. When such an event occurs,
126      * the <b>callback</b> specified is invoked to process the event.
127      * @param keyOption Indicates the condition of the key input event.
128      * @param callback Indicates the callback.
129      * @return Returns the subscription ID, which uniquely identifies a subscription in the process.
130      * If the value is greater than or equal to <b>0</b>,
131      * the subscription is successful. Otherwise, the subscription fails.
132      * @since 9
133      */
134     int32_t SubscribeKeyEvent(std::shared_ptr<KeyOption> keyOption,
135         std::function<void(std::shared_ptr<KeyEvent>)> callback);
136 
137     /**
138      * @brief Unsubscribes from a key input event.
139      * @param subscriberId Indicates the subscription ID, which is the return value of <b>SubscribeKeyEvent</b>.
140      * @return void
141      * @since 9
142      */
143     void UnsubscribeKeyEvent(int32_t subscriberId);
144 
145     /**
146      * @brief Subscribes to the switch input event that meets a specific condition. When such an event occurs,
147      * the <b>callback</b> specified is invoked to process the event.
148      * @param callback Indicates the callback.
149      * @return Returns the subscription ID, which uniquely identifies a subscription in the process.
150      * If the value is greater than or equal to <b>0</b>,
151      * the subscription is successful. Otherwise, the subscription fails.
152      * @since 9
153      */
154     int32_t SubscribeSwitchEvent(std::function<void(std::shared_ptr<SwitchEvent>)> callback);
155 
156     /**
157      * @brief Unsubscribes from a switch input event.
158      * @param subscriberId Indicates the subscription ID, which is the return value of <b>SubscribeKeyEvent</b>.
159      * @return void
160      * @since 9
161      */
162     void UnsubscribeSwitchEvent(int32_t subscriberId);
163 
164     /**
165      * @brief Adds an input event monitor. After such a monitor is added,
166      * an input event is copied and distributed to the monitor while being distributed to the original target.
167      * @param monitor Indicates the input event monitor. After an input event is generated,
168      * the functions of the monitor object will be called.
169      * @return Returns the monitor ID, which uniquely identifies a monitor in the process.
170      * If the value is greater than or equal to <b>0</b>, the monitor is successfully added. Otherwise,
171      * the monitor fails to be added.
172      * @since 9
173      */
174     int32_t AddMonitor(std::function<void(std::shared_ptr<KeyEvent>)> monitor);
175 
176     /**
177      * @brief Adds an input event monitor. After such a monitor is added,
178      * an input event is copied and distributed to the monitor while being distributed to the original target.
179      * @param monitor Indicates the input event monitor. After an input event is generated,
180      * the functions of the monitor object will be called.
181      * @return Returns the monitor ID, which uniquely identifies a monitor in the process.
182      * If the value is greater than or equal to <b>0</b>, the monitor is successfully added. Otherwise,
183      * the monitor fails to be added.
184      * @since 9
185      */
186     int32_t AddMonitor(std::function<void(std::shared_ptr<PointerEvent>)> monitor);
187 
188     /**
189      * @brief Adds an input event monitor. After such a monitor is added,
190      * an input event is copied and distributed to the monitor while being distributed to the original target.
191      * @param monitor Indicates the input event monitor. After an input event is generated,
192      * the functions of the monitor object will be called.
193      * @return Returns the monitor ID, which uniquely identifies a monitor in the process.
194      * If the value is greater than or equal to <b>0</b>, the monitor is successfully added. Otherwise,
195      * the monitor fails to be added.
196      * @since 9
197      */
198     int32_t AddMonitor(std::shared_ptr<IInputEventConsumer> monitor);
199 
200     /**
201      * @brief Removes a monitor.
202      * @param monitorId Indicates the monitor ID, which is the return value of <b>AddMonitor</b>.
203      * @return void
204      * @since 9
205      */
206     void RemoveMonitor(int32_t monitorId);
207 
208     /**
209      * @brief Marks that a monitor has consumed a touchscreen input event. After being consumed,
210      * the touchscreen input event will not be distributed to the original target.
211      * @param monitorId Indicates the monitor ID.
212      * @param eventId Indicates the ID of the consumed touchscreen input event.
213      * @return void
214      * @since 9
215      */
216     void MarkConsumed(int32_t monitorId, int32_t eventId);
217 
218     /**
219      * @brief Moves the cursor to the specified position.
220      * @param offsetX Indicates the offset on the X axis.
221      * @param offsetY Indicates the offset on the Y axis.
222      * @return void
223      * @since 9
224      */
225     void MoveMouse(int32_t offsetX, int32_t offsetY);
226 
227     /**
228      * @brief Adds an input event interceptor. After such an interceptor is added,
229      * an input event will be distributed to the interceptor instead of the original target and monitor.
230      * @param interceptor Indicates the input event interceptor. After an input event is generated,
231      * the functions of the interceptor object will be called.
232      * @return Returns the interceptor ID, which uniquely identifies an interceptor in the process.
233      * If the value is greater than or equal to <b>0</b>,the interceptor is successfully added. Otherwise,
234      * the interceptor fails to be added.
235      * @since 9
236      */
237     int32_t AddInterceptor(std::shared_ptr<IInputEventConsumer> interceptor);
238     int32_t AddInterceptor(std::function<void(std::shared_ptr<KeyEvent>)> interceptor);
239     int32_t AddInterceptor(std::shared_ptr<IInputEventConsumer> interceptor, int32_t priority, uint32_t deviceTags);
240 
241     /**
242      * @brief Removes an interceptor.
243      * @param interceptorId Indicates the interceptor ID, which is the return value of <b>AddInterceptor</b>.
244      * @return void
245      * @since 9
246      */
247     void RemoveInterceptor(int32_t interceptorId);
248 
249     /**
250      * @brief Simulates a key input event. This event will be distributed and
251      * processed in the same way as the event reported by the input device.
252      * @param keyEvent Indicates the key input event to simulate.
253      * @return void
254      * @since 9
255      */
256     void SimulateInputEvent(std::shared_ptr<KeyEvent> keyEvent);
257 
258     /**
259      * @brief Simulates a touchpad input event, touchscreen input event, or mouse device input event.
260      * This event will be distributed and processed in the same way as the event reported by the input device.
261      * @param pointerEvent Indicates the touchpad input event, touchscreen input event,
262      * or mouse device input event to simulate.
263      * @return void
264      * @since 9
265      */
266     void SimulateInputEvent(std::shared_ptr<PointerEvent> pointerEvent);
267 
268     /**
269      * @brief Simulates a touchpad input event, touchscreen input event, or mouse device input event.
270      * This event will be distributed and processed in the same way as the event reported by the input device.
271      * @param pointerEvent Indicates the touchpad input event, touchscreen input event,
272      * or mouse device input event to simulate.
273      * @param zOrder Indicates the point event will inject to the window whose index value is less than the zOrder
274      * @return void
275      * @since 9
276      */
277     void SimulateInputEvent(std::shared_ptr<PointerEvent> pointerEvent, float zOrder);
278 
279     /**
280      * @brief Starts listening for an input device event.
281      * @param type Indicates the type of the input device event, which is <b>change</b>.
282      * @param listener Indicates the listener for the input device event.
283      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
284      * @since 9
285      */
286     int32_t RegisterDevListener(std::string type, std::shared_ptr<IInputDeviceListener> listener);
287 
288     /**
289      * @brief Stops listening for an input device event.
290      * @param type Indicates the type of the input device event, which is <b>change</b>.
291      * @param listener Indicates the listener for the input device event.
292      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
293      * @since 9
294      */
295     int32_t UnregisterDevListener(std::string type, std::shared_ptr<IInputDeviceListener> listener = nullptr);
296 
297     /**
298      * @brief Obtains the information about an input device.
299      * @param callback Indicates the callback used to receive the reported data.
300      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
301      * @since 9
302      */
303     int32_t GetDeviceIds(std::function<void(std::vector<int32_t>&)> callback);
304 
305     /**
306      * @brief Obtains the information about an input device.
307      * @param deviceId Indicates the ID of the input device whose information is to be obtained.
308      * @param callback Indicates the callback used to receive the reported data.
309      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
310      * @since 9
311      */
312     int32_t GetDevice(int32_t deviceId, std::function<void(std::shared_ptr<InputDevice>)> callback);
313 
314     /**
315      * @brief Checks whether the specified key codes of an input device are supported.
316      * @param deviceId Indicates the ID of the input device.
317      * @param keyCodes Indicates the key codes of the input device.
318      * @param callback Indicates the callback used to receive the reported data.
319      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
320      * @since 9
321      */
322     int32_t SupportKeys(int32_t deviceId, std::vector<int32_t> keyCodes,
323         std::function<void(std::vector<bool>&)> callback);
324 
325     /**
326      * @brief Sets the number of the mouse scrolling rows.
327      * @param rows Indicates the number of the mouse scrolling rows.
328      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
329      * @since 9
330      */
331     int32_t SetMouseScrollRows(int32_t rows);
332 
333     /**
334      * @brief Set pixelMap to override ohos mouse icon resouce.
335      * @param windowId Indicates the windowId of the window
336      * @param pixelMap Indicates the image resouce for this mouse icon. which realtype must be OHOS::Media::PixelMap*
337      * @param focusX Indicates focus x
338      * @param focusY Indicates focus y
339      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
340      * @since 9
341      */
342     int32_t SetCustomCursor(int32_t windowId, void* pixelMap, int32_t focusX = 0, int32_t focusY = 0);
343 
344     /**
345      * @brief Set pixelMap to override ohos mouse icon resouce.
346      * @param windowId Indicates the windowId of the window
347      * @param pixelMap Indicates the image resouce for this mouse icon. which realtype must be OHOS::Media::PixelMap*
348      * @return vint32_t
349      * @since 10
350      */
351     int32_t SetMouseIcon(int32_t windowId, void* pixelMap);
352 
353     /**
354      * @brief Set mouse icon hot spot.
355      * @param windowId Indicates the windowId of the window
356      * @param hotSpotX Indicates the hot spot x for this mouse icon.
357      * @param hotSpotY Indicates the hot spot y for this mouse icon.
358      * @return vint32_t
359      * @since 10
360      */
361     int32_t SetMouseHotSpot(int32_t windowId, int32_t hotSpotX, int32_t hotSpotY);
362 
363     /**
364      * @brief Gets the number of the mouse scrolling rows.
365      * @param rows Indicates the number of the mouse scrolling rows.
366      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
367      * @since 9
368      */
369     int32_t GetMouseScrollRows(int32_t &rows);
370 
371     /**
372      * @brief Sets pointer size.
373      * @param size Indicates pointer size.
374      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
375      * @since 9
376      */
377     int32_t SetPointerSize(int32_t size);
378 
379     /**
380      * @brief Gets pointer size.
381      * @param size Indicates pointer size.
382      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
383      * @since 9
384      */
385     int32_t GetPointerSize(int32_t &size);
386 
387     /**
388      * @brief Enable combine key
389      * @param enable Indicates whether the combine key is enabled. The value true indicates that the combine key
390      * is enabled, and the value false indicates the opposite.
391      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
392      * @since 11
393      */
394     int32_t EnableCombineKey(bool enable);
395 
396     /**
397      * @brief Sets mouse primary button.
398      * @param primaryButton Indicates the ID of the mouse primary button.The value 0 indicates that
399      * the primary button is left button.The value 1 indicates that the primary button is right button.
400      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
401      * @since 9
402      */
403     int32_t SetMousePrimaryButton(int32_t primaryButton);
404 
405     /**
406      * @brief Gets mouse primary button.
407      * @param primaryButton Indicates the ID of the mouse primary button.The value 0 indicates that
408      * the primary button is left button.The value 1 indicates that the primary button is right button.
409      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
410      * @since 9
411      */
412     int32_t GetMousePrimaryButton(int32_t &primaryButton);
413 
414     /**
415      * @brief Sets whether the mouse hover scroll is enabled in inactive window.
416      * @param state Indicates whether the mouse hover scroll is enabled in inactive window. The value true
417      * indicates that the mouse hover scroll is enabled, and the value false indicates the opposite.
418      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
419      * @since 9
420      */
421     int32_t SetHoverScrollState(bool state);
422 
423     /**
424      * @brief Gets a status whether the mouse hover scroll is enabled in inactive window.
425      * @param state Indicates whether the mouse hover scroll is enabled in inactive window. The value true
426      * indicates that the mouse hover scroll is enabled, and the value false indicates the opposite.
427      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
428      * @since 9
429      */
430     int32_t GetHoverScrollState(bool &state);
431 
432     /**
433      * @brief Sets whether the pointer icon is visible.
434      * @param visible Indicates whether the pointer icon is visible. The value <b>true</b> indicates that
435      * the pointer icon is visible, and the value <b>false</b> indicates the opposite.
436      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
437      * @since 9
438      */
439     int32_t SetPointerVisible(bool visible);
440 
441     /**
442      * @brief Checks whether the pointer icon is visible.
443      * @return Returns <b>true</b> if the pointer icon is visible; returns <b>false</b> otherwise.
444      * @since 9
445      */
446     bool IsPointerVisible();
447 
448     /**
449      * @brief Sets the mouse pointer style.
450      * @param windowId Indicates the ID of the window for which the mouse pointer style is set.
451      * @param pointerStyle Indicates the ID of the mouse pointer style.
452      * @return Returns <b>0</b> if the operation is successful; returns an error code otherwise.
453      * @since 9
454      */
455     int32_t SetPointerStyle(int32_t windowId, PointerStyle pointerStyle);
456 
457     /**
458      * @brief Obtains the mouse pointer style.
459      * @param windowId Indicates the ID of the window for which the mouse pointer style is obtained.
460      * @param pointerStyle Indicates the ID of the mouse pointer style.
461      * @return Returns <b>0</b> if the operation is successful; returns an error code otherwise.
462      * @since 9
463      */
464     int32_t GetPointerStyle(int32_t windowId, PointerStyle &pointerStyle);
465 
466     /**
467      * @brief Sets pointer color.
468      * @param color Indicates pointer color.
469      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
470      * @since 9
471      */
472     int32_t SetPointerColor(int32_t color);
473 
474     /**
475      * @brief Gets pointer color.
476      * @param color Indicates pointer color.
477      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
478      * @since 9
479      */
480     int32_t GetPointerColor(int32_t &color);
481 
482     /**
483      * @brief Sets the mouse pointer speed, which ranges from 1 to 11.
484      * @param speed Indicates the mouse pointer speed to set.
485      * @return Returns <b>RET_OK</b> if success; returns <b>RET_ERR</b> otherwise.
486      * @since 9
487      */
488     int32_t SetPointerSpeed(int32_t speed);
489 
490     /**
491      * @brief Obtains the mouse pointer speed.
492      * @param speed Indicates the mouse pointer speed to get.
493      * @return Returns the mouse pointer speed if the operation is successful; returns <b>RET_ERR</b> otherwise.
494      * @since 9
495      */
496     int32_t GetPointerSpeed(int32_t &speed);
497 
498     /**
499      * @brief Queries the keyboard type.
500      * @param deviceId Indicates the keyboard device ID.
501      * @param callback Callback used to return the keyboard type.
502      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
503      * @since 9
504      */
505     int32_t GetKeyboardType(int32_t deviceId, std::function<void(int32_t)> callback);
506 
507     /**
508      * @brief Sets the observer for events indicating that the application does not respond.
509      * @param observer Indicates the observer for events indicating that the application does not respond.
510      * @return void
511      * @since 9
512      */
513     void SetAnrObserver(std::shared_ptr<IAnrObserver> observer);
514 
515     /**
516      * @brief Obtains the enablement status of the specified function key on the keyboard.
517      * @param funcKey Indicates the function key. Currently, the following function keys are supported:
518      * NUM_LOCK_FUNCTION_KEY
519      * CAPS_LOCK_FUNCTION_KEY
520      * SCROLL_LOCK_FUNCTION_KEY
521      * @return Returns <b>true</b> if the function key is enabled;
522      * returns <b>false</b> otherwise.
523      */
524     bool GetFunctionKeyState(int32_t funcKey);
525 
526     /**
527      * @brief Sets the enablement status of the specified function key on the keyboard.
528      * @param funcKey Indicates the function key. Currently, the following function keys are supported:
529      * NUM_LOCK_FUNCTION_KEY
530      * CAPS_LOCK_FUNCTION_KEY
531      * SCROLL_LOCK_FUNCTION_KEY
532      * @param isEnable Indicates the enablement status to set.
533      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
534      */
535     int32_t SetFunctionKeyState(int32_t funcKey, bool enable);
536 
537     /**
538      * @brief Sets the absolute coordinate of mouse.
539      * @param x Specifies the x coordinate of the mouse to be set.
540      * @param y Specifies the y coordinate of the mouse to be set.
541      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
542      * @since 9
543      */
544     int32_t SetPointerLocation(int32_t x, int32_t y);
545 
546     /**
547      * @brief 进入捕获模式
548      * @param windowId 窗口id.
549      * @return 进入捕获模式成功或失败.
550      * @since 9
551      */
552     int32_t EnterCaptureMode(int32_t windowId);
553 
554     /**
555      * @brief 退出捕获模式
556      * @param windowId 窗口id.
557      * @return 退出捕获模式成功或失败.
558      * @since 9
559      */
560     int32_t LeaveCaptureMode(int32_t windowId);
561 
562     int32_t GetWindowPid(int32_t windowId);
563 
564     /**
565      * @brief pointer event添加辅助信息
566      * @param extraData 添加的信息.
567      * @return void
568      * @since 9
569      */
570     void AppendExtraData(const ExtraData& extraData);
571 
572     /**
573      * @brief 使能或者禁用输入设备
574      * @param enable 输入设备的使能状态
575      * @return 返回0表示接口调用成功,否则,表示接口调用失败。
576      * @since 9
577      */
578     int32_t EnableInputDevice(bool enable);
579 
580      /**
581      * @brief 自定义设置快捷键拉起ability延迟时间
582      * @param businessId 应用在ability_launch_config.json中注册的唯一标识符.
583      * @param delay 延迟时间 0-4000ms
584      * @return 设置快捷键拉起ability延迟时间成功或失败
585      * @since 10
586      */
587     int32_t SetKeyDownDuration(const std::string &businessId, int32_t delay);
588 
589     /**
590      * @brief Sets the keyboard repeat delay, which ranges from 300 to 1000.
591      * @param delay Indicates the keyboard repeat delay to set.
592      * @return Returns <b>RET_OK</b> if success; returns <b>RET_ERR</b> otherwise.
593      * @since 10
594      */
595     int32_t SetKeyboardRepeatDelay(int32_t delay);
596 
597     /**
598      * @brief Sets the keyboard repeat rate, which ranges from 36 to 100.
599      * @param rate Indicates the keyboard repeat rate to set.
600      * @return Returns <b>RET_OK</b> if success; returns <b>RET_ERR</b> otherwise.
601      * @since 10
602      */
603     int32_t SetKeyboardRepeatRate(int32_t rate);
604 
605     /**
606      * @brief Gets the keyboard repeat delay.
607      * @param callback Callback used to return the keyboard repeat delay.
608      * @return Returns <b>RET_OK</b> if success; returns <b>RET_ERR</b> otherwise.
609      * @since 10
610      */
611     int32_t GetKeyboardRepeatDelay(std::function<void(int32_t)> callback);
612 
613     /**
614      * @brief Gets the keyboard repeat rate.
615      * @param callback Callback used to return the keyboard repeat rate.
616      * @return Returns <b>RET_OK</b> if success; returns <b>RET_ERR</b> otherwise.
617      * @since 10
618      */
619     int32_t GetKeyboardRepeatRate(std::function<void(int32_t)> callback);
620 
621     /**
622      * @brief Set the switch of touchpad scroll.
623      * @param switchFlag Indicates the touchpad scroll switch state.
624      * @return if success; returns a non-0 value otherwise.
625      * @since 9
626      */
627     int32_t SetTouchpadScrollSwitch(bool switchFlag);
628 
629     /**
630      * @brief Get the switch of touchpad scroll.
631      * @param switchFlag Indicates the touchpad scroll switch state.
632      * @return if success; returns a non-0 value otherwise.
633      * @since 9
634      */
635     int32_t GetTouchpadScrollSwitch(bool &switchFlag);
636 
637     /**
638      * @brief Set the switch of touchpad scroll direction.
639      * @param state Indicates the touchpad scroll switch direction state.
640      * @return if success; returns a non-0 value otherwise.
641      * @since 9
642      */
643     int32_t SetTouchpadScrollDirection(bool state);
644 
645     /**
646      * @brief Get the switch of touchpad scroll direction.
647      * @param state Indicates the touchpad scroll switch direction state.
648      * @return if success; returns a non-0 value otherwise.
649      * @since 9
650      */
651     int32_t GetTouchpadScrollDirection(bool &state);
652 
653     /**
654      * @brief Set the switch of touchpad tap.
655      * @param switchFlag Indicates the touchpad tap switch state.
656      * @return if success; returns a non-0 value otherwise.
657      * @since 9
658      */
659     int32_t SetTouchpadTapSwitch(bool switchFlag);
660 
661     /**
662      * @brief Get the switch of touchpad tap.
663      * @param switchFlag Indicates the touchpad tap switch state.
664      * @return if success; returns a non-0 value otherwise.
665      * @since 9
666      */
667     int32_t GetTouchpadTapSwitch(bool &switchFlag);
668 
669     /**
670      * @brief Set the touchpad poniter speed.
671      * @param speed Indicates the touchpad pointer speed.
672      * @return if success; returns a non-0 value otherwise.
673      * @since 9
674      */
675     int32_t SetTouchpadPointerSpeed(int32_t speed);
676 
677     /**
678      * @brief Get the touchpad poniter speed.
679      * @param speed Indicates the touchpad pointer speed.
680      * @return if success; returns a non-0 value otherwise.
681      * @since 9
682      */
683     int32_t GetTouchpadPointerSpeed(int32_t &speed);
684 
685     /**
686      * @brief Set the switch of touchpad pinch.
687      * @param switchFlag Indicates the touchpad pinch switch state.
688      * @return if success; returns a non-0 value otherwise.
689      * @since 9
690      */
691     int32_t SetTouchpadPinchSwitch(bool switchFlag);
692 
693     /**
694      * @brief Get the switch of touchpad pinch.
695      * @param switchFlag Indicates the touchpad pinch switch state.
696      * @return if success; returns a non-0 value otherwise.
697      * @since 9
698      */
699     int32_t GetTouchpadPinchSwitch(bool &switchFlag);
700 
701     /**
702      * @brief Set the switch of touchpad swipe.
703      * @param switchFlag Indicates the touchpad swipe switch state.
704      * @return if success; returns a non-0 value otherwise.
705      * @since 9
706      */
707     int32_t SetTouchpadSwipeSwitch(bool switchFlag);
708 
709     /**
710      * @brief Get the switch of touchpad swipe.
711      * @param switchFlag Indicates the touchpad swipe switch state.
712      * @return if success; returns a non-0 value otherwise.
713      * @since 9
714      */
715     int32_t GetTouchpadSwipeSwitch(bool &switchFlag);
716 
717     /**
718      * @brief Set the touchpad right click type.
719      * @param type Indicates the touchpad right menu type.
720      * @return if success; returns a non-0 value otherwise.
721      * @since 9
722      */
723     int32_t SetTouchpadRightClickType(int32_t type);
724 
725     /**
726      * @brief Get the touchpad right click type.
727      * @param type Indicates the touchpad right menu type.
728      * @return if success; returns a non-0 value otherwise.
729      * @since 9
730      */
731     int32_t GetTouchpadRightClickType(int32_t &type);
732      /**
733      * @brief SetWindowPointerStyle.
734      * @param area Indicates area.
735      * @param pid Indicates pid.
736      * @param windowId Indicates windowId.
737      * @return void.
738      * @since 9
739      */
740     void SetWindowPointerStyle(WindowArea area, int32_t pid, int32_t windowId);
741 
742     /**
743      * @brief ClearWindowPointerStyle.
744      * @param pid Indicates pid.
745      * @param windowId Indicates windowId.
746      * @return void.
747      * @since 9
748      */
749     void ClearWindowPointerStyle(int32_t pid, int32_t windowId);
750 
751     /**
752      * @brief Sets a window input event consumer that runs on the specified thread.
753      * @param inputEventConsumer Indicates the consumer to set.
754      * @since 9
755      */
756     void SetWindowCheckerHandler(std::shared_ptr<IWindowChecker> windowChecker);
757 
758     /**
759      * @brief Sets whether shield key event interception, only support shield key event.
760      * @param shieldMode Indicates shield mode.
761      * @param isShield Indicates whether key event handler chain is shield. The value <b>true</b> indicates that
762      * the key event build chain is shield, all key events derictly dispatch to window,
763      * if the value <b>false</b> indicates not shield key event interception, handle by the chain.
764      * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
765      * @since 9
766      */
767     int32_t SetShieldStatus(int32_t shieldMode, bool isShield);
768 
769     /**
770     * Gets shield event interception status corresponding to shield mode
771     *
772     * @param shieldMode - Accroding the shield mode select shield status.
773     * @param isShield - shield status of shield mode param.
774     * @return Returns <b>0</b> if success; returns a non-0 value otherwise.
775     * @since 9
776     */
777     int32_t GetShieldStatus(int32_t shieldMode, bool &isShield);
778 
779 #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT
780     /**
781      * @brief Sets the enhance config of the security component.
782      * @param cfg Indicates the security component enhance config.
783      * @param cfgLen Indicates the security component enhance config len.
784      * @return void.
785      * @since 9
786      */
787     void SetEnhanceConfig(uint8_t *cfg, uint32_t cfgLen);
788 #endif // OHOS_BUILD_ENABLE_SECURITY_COMPONENT
789 
790 #ifdef OHOS_BUILD_ENABLE_ANCO
791     void SimulateInputEventExt(std::shared_ptr<KeyEvent> keyEvent);
792     void SimulateInputEventExt(std::shared_ptr<PointerEvent> pointerEvent);
793 #endif // OHOS_BUILD_ENABLE_ANCO
794 
795     void AddServiceWatcher(std::shared_ptr<IInputServiceWatcher> watcher);
796     void RemoveServiceWatcher(std::shared_ptr<IInputServiceWatcher> watcher);
797 
798 private:
799     InputManager() = default;
800     DISALLOW_COPY_AND_MOVE(InputManager);
801     static InputManager *instance_;
802 };
803 } // namespace MMI
804 } // namespace OHOS
805 #endif // INPUT_MANAGER_H
806