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 #include "input_manager.h"
17
18 #include "input_manager_impl.h"
19 #include "hitrace_meter.h"
20 #include "pre_monitor_manager.h"
21
22 #undef MMI_LOG_TAG
23 #define MMI_LOG_TAG "InputManager"
24
25 namespace OHOS {
26 namespace MMI {
27 InputManager *InputManager::instance_ = new (std::nothrow) InputManager();
28
29 const std::map<int32_t, int32_t> MOUSE_TO_TOUCH_PARAM_MAP = {
30 {PointerEvent::SOURCE_TYPE_MOUSE, PointerEvent::SOURCE_TYPE_TOUCHSCREEN},
31 {PointerEvent::POINTER_ACTION_BUTTON_DOWN, PointerEvent::POINTER_ACTION_DOWN},
32 {PointerEvent::POINTER_ACTION_BUTTON_UP, PointerEvent::POINTER_ACTION_UP},
33 {PointerEvent::TOOL_TYPE_MOUSE, PointerEvent::TOOL_TYPE_FINGER},
34 {PointerEvent::MOUSE_BUTTON_LEFT, PointerEvent::POINTER_INITIAL_VALUE}
35 };
36
37 const std::map<int32_t, int32_t> TOUCH_TO_MOUSE_PARAM_MAP = {
38 {PointerEvent::POINTER_ACTION_DOWN, PointerEvent::POINTER_ACTION_BUTTON_DOWN},
39 {PointerEvent::POINTER_ACTION_UP, PointerEvent::POINTER_ACTION_BUTTON_UP},
40 {PointerEvent::TOOL_TYPE_FINGER, PointerEvent::TOOL_TYPE_MOUSE}
41 };
42
GetInstance()43 InputManager *InputManager::GetInstance()
44 {
45 return instance_;
46 }
47
GetDisplayBindInfo(DisplayBindInfos & infos)48 int32_t InputManager::GetDisplayBindInfo(DisplayBindInfos &infos)
49 {
50 return InputMgrImpl.GetDisplayBindInfo(infos);
51 }
52
GetAllMmiSubscribedEvents(std::map<std::tuple<int32_t,int32_t,std::string>,int32_t> & datas)53 int32_t InputManager::GetAllMmiSubscribedEvents(std::map<std::tuple<int32_t, int32_t, std::string>, int32_t> &datas)
54 {
55 return InputMgrImpl.GetAllMmiSubscribedEvents(datas);
56 }
57
SetDisplayBind(int32_t deviceId,int32_t displayId,std::string & msg)58 int32_t InputManager::SetDisplayBind(int32_t deviceId, int32_t displayId, std::string &msg)
59 {
60 return InputMgrImpl.SetDisplayBind(deviceId, displayId, msg);
61 }
62
GetWindowPid(int32_t windowId)63 int32_t InputManager::GetWindowPid(int32_t windowId)
64 {
65 return InputMgrImpl.GetWindowPid(windowId);
66 }
67
UpdateDisplayInfo(const DisplayGroupInfo & displayGroupInfo)68 int32_t InputManager::UpdateDisplayInfo(const DisplayGroupInfo &displayGroupInfo)
69 {
70 return InputMgrImpl.UpdateDisplayInfo(displayGroupInfo);
71 }
72
UpdateWindowInfo(const WindowGroupInfo & windowGroupInfo)73 int32_t InputManager::UpdateWindowInfo(const WindowGroupInfo &windowGroupInfo)
74 {
75 return InputMgrImpl.UpdateWindowInfo(windowGroupInfo);
76 }
77
AddInputEventFilter(std::shared_ptr<IInputEventFilter> filter,int32_t priority,uint32_t deviceTags)78 int32_t InputManager::AddInputEventFilter(std::shared_ptr<IInputEventFilter> filter, int32_t priority,
79 uint32_t deviceTags)
80 {
81 return InputMgrImpl.AddInputEventFilter(filter, priority, deviceTags);
82 }
83
RemoveInputEventFilter(int32_t filterId)84 int32_t InputManager::RemoveInputEventFilter(int32_t filterId)
85 {
86 return InputMgrImpl.RemoveInputEventFilter(filterId);
87 }
88
AddInputEventObserver(std::shared_ptr<MMIEventObserver> observer)89 int32_t InputManager::AddInputEventObserver(std::shared_ptr<MMIEventObserver> observer)
90 {
91 return InputMgrImpl.AddInputEventObserver(observer);
92 }
93
RemoveInputEventObserver(std::shared_ptr<MMIEventObserver> observer)94 int32_t InputManager::RemoveInputEventObserver(std::shared_ptr<MMIEventObserver> observer)
95 {
96 return InputMgrImpl.RemoveInputEventObserver(observer);
97 }
98
SetWindowInputEventConsumer(std::shared_ptr<IInputEventConsumer> inputEventConsumer)99 int32_t InputManager::SetWindowInputEventConsumer(std::shared_ptr<IInputEventConsumer> inputEventConsumer)
100 {
101 return InputMgrImpl.SetWindowInputEventConsumer(inputEventConsumer, nullptr);
102 }
103
SetWindowInputEventConsumer(std::shared_ptr<IInputEventConsumer> inputEventConsumer,std::shared_ptr<AppExecFwk::EventHandler> eventHandler)104 int32_t InputManager::SetWindowInputEventConsumer(std::shared_ptr<IInputEventConsumer> inputEventConsumer,
105 std::shared_ptr<AppExecFwk::EventHandler> eventHandler)
106 {
107 CHKPR(eventHandler, RET_ERR);
108 return InputMgrImpl.SetWindowInputEventConsumer(inputEventConsumer, eventHandler);
109 }
110
SubscribeKeyEvent(std::shared_ptr<KeyOption> keyOption,std::function<void (std::shared_ptr<KeyEvent>)> callback)111 int32_t InputManager::SubscribeKeyEvent(std::shared_ptr<KeyOption> keyOption,
112 std::function<void(std::shared_ptr<KeyEvent>)> callback)
113 {
114 return InputMgrImpl.SubscribeKeyEvent(keyOption, callback);
115 }
116
UnsubscribeKeyEvent(int32_t subscriberId)117 void InputManager::UnsubscribeKeyEvent(int32_t subscriberId)
118 {
119 InputMgrImpl.UnsubscribeKeyEvent(subscriberId);
120 }
121
SubscribeHotkey(std::shared_ptr<KeyOption> keyOption,std::function<void (std::shared_ptr<KeyEvent>)> callback)122 int32_t InputManager::SubscribeHotkey(std::shared_ptr<KeyOption> keyOption,
123 std::function<void(std::shared_ptr<KeyEvent>)> callback)
124 {
125 return InputMgrImpl.SubscribeHotkey(keyOption, callback);
126 }
127
UnsubscribeHotkey(int32_t subscriberId)128 void InputManager::UnsubscribeHotkey(int32_t subscriberId)
129 {
130 InputMgrImpl.UnsubscribeHotkey(subscriberId);
131 }
132
SubscribeKeyMonitor(const KeyMonitorOption & keyOption,std::function<void (std::shared_ptr<KeyEvent>)> callback)133 int32_t InputManager::SubscribeKeyMonitor(const KeyMonitorOption &keyOption,
134 std::function<void(std::shared_ptr<KeyEvent>)> callback)
135 {
136 return InputMgrImpl.SubscribeKeyMonitor(keyOption, callback);
137 }
138
UnsubscribeKeyMonitor(int32_t subscriberId)139 void InputManager::UnsubscribeKeyMonitor(int32_t subscriberId)
140 {
141 InputMgrImpl.UnsubscribeKeyMonitor(subscriberId);
142 }
143
SubscribeSwitchEvent(std::function<void (std::shared_ptr<SwitchEvent>)> callback,SwitchEvent::SwitchType switchType)144 int32_t InputManager::SubscribeSwitchEvent(std::function<void(std::shared_ptr<SwitchEvent>)> callback,
145 SwitchEvent::SwitchType switchType)
146 {
147 return InputMgrImpl.SubscribeSwitchEvent(static_cast<int32_t>(switchType), callback);
148 }
149
UnsubscribeSwitchEvent(int32_t subscriberId)150 void InputManager::UnsubscribeSwitchEvent(int32_t subscriberId)
151 {
152 InputMgrImpl.UnsubscribeSwitchEvent(subscriberId);
153 }
154
SubscribeTabletProximity(std::function<void (std::shared_ptr<PointerEvent>)> callback)155 int32_t InputManager::SubscribeTabletProximity(std::function<void(std::shared_ptr<PointerEvent>)> callback)
156 {
157 return InputMgrImpl.SubscribeTabletProximity(callback);
158 }
159
UnsubscribetabletProximity(int32_t subscriberId)160 void InputManager::UnsubscribetabletProximity(int32_t subscriberId)
161 {
162 InputMgrImpl.UnsubscribetabletProximity(subscriberId);
163 }
164
SubscribeLongPressEvent(const LongPressRequest & longPressRequest,std::function<void (LongPressEvent)> callback)165 int32_t InputManager::SubscribeLongPressEvent(const LongPressRequest &longPressRequest,
166 std::function<void(LongPressEvent)> callback)
167 {
168 return InputMgrImpl.SubscribeLongPressEvent(longPressRequest, callback);
169 }
170
UnsubscribeLongPressEvent(int32_t subscriberId)171 void InputManager::UnsubscribeLongPressEvent(int32_t subscriberId)
172 {
173 InputMgrImpl.UnsubscribeLongPressEvent(subscriberId);
174 }
175
AddMonitor(std::function<void (std::shared_ptr<KeyEvent>)> monitor)176 int32_t InputManager::AddMonitor(std::function<void(std::shared_ptr<KeyEvent>)> monitor)
177 {
178 return InputMgrImpl.AddMonitor(monitor);
179 }
180
AddMonitor(std::function<void (std::shared_ptr<PointerEvent>)> monitor)181 int32_t InputManager::AddMonitor(std::function<void(std::shared_ptr<PointerEvent>)> monitor)
182 {
183 return InputMgrImpl.AddMonitor(monitor);
184 }
185
AddMonitor(std::shared_ptr<IInputEventConsumer> monitor,HandleEventType eventType)186 int32_t InputManager::AddMonitor(std::shared_ptr<IInputEventConsumer> monitor, HandleEventType eventType)
187 {
188 return InputMgrImpl.AddMonitor(monitor, eventType);
189 }
190
AddMonitor(std::shared_ptr<IInputEventConsumer> monitor,std::vector<int32_t> actionsType)191 int32_t InputManager::AddMonitor(std::shared_ptr<IInputEventConsumer> monitor, std::vector<int32_t> actionsType)
192 {
193 return InputMgrImpl.AddMonitor(monitor, actionsType);
194 }
195
AddPreMonitor(std::shared_ptr<IInputEventConsumer> monitor,HandleEventType eventType,std::vector<int32_t> keys)196 int32_t InputManager::AddPreMonitor(
197 std::shared_ptr<IInputEventConsumer> monitor, HandleEventType eventType, std::vector<int32_t> keys)
198 {
199 return PRE_MONITOR_MGR.AddHandler(monitor, eventType, keys);
200 }
201
RemovePreMonitor(int32_t monitorId)202 void InputManager::RemovePreMonitor(int32_t monitorId)
203 {
204 PRE_MONITOR_MGR.RemoveHandler(monitorId);
205 }
206
RemoveMonitor(int32_t monitorId)207 void InputManager::RemoveMonitor(int32_t monitorId)
208 {
209 InputMgrImpl.RemoveMonitor(monitorId);
210 }
211
AddGestureMonitor(std::shared_ptr<IInputEventConsumer> consumer,TouchGestureType type,int32_t fingers)212 int32_t InputManager::AddGestureMonitor(
213 std::shared_ptr<IInputEventConsumer> consumer, TouchGestureType type, int32_t fingers)
214 {
215 return InputMgrImpl.AddGestureMonitor(consumer, type, fingers);
216 }
217
RemoveGestureMonitor(int32_t monitorId)218 int32_t InputManager::RemoveGestureMonitor(int32_t monitorId)
219 {
220 return InputMgrImpl.RemoveGestureMonitor(monitorId);
221 }
222
MarkConsumed(int32_t monitorId,int32_t eventId)223 void InputManager::MarkConsumed(int32_t monitorId, int32_t eventId)
224 {
225 InputMgrImpl.MarkConsumed(monitorId, eventId);
226 }
227
MoveMouse(int32_t offsetX,int32_t offsetY)228 void InputManager::MoveMouse(int32_t offsetX, int32_t offsetY)
229 {
230 InputMgrImpl.MoveMouse(offsetX, offsetY);
231 }
232
AddInterceptor(std::shared_ptr<IInputEventConsumer> interceptor)233 int32_t InputManager::AddInterceptor(std::shared_ptr<IInputEventConsumer> interceptor)
234 {
235 return InputMgrImpl.AddInterceptor(interceptor);
236 }
237
AddInterceptor(std::function<void (std::shared_ptr<KeyEvent>)> interceptor)238 int32_t InputManager::AddInterceptor(std::function<void(std::shared_ptr<KeyEvent>)> interceptor)
239 {
240 return InputMgrImpl.AddInterceptor(interceptor);
241 }
242
AddInterceptor(std::shared_ptr<IInputEventConsumer> interceptor,int32_t priority,uint32_t deviceTags)243 int32_t InputManager::AddInterceptor(std::shared_ptr<IInputEventConsumer> interceptor, int32_t priority,
244 uint32_t deviceTags)
245 {
246 return InputMgrImpl.AddInterceptor(interceptor, priority, deviceTags);
247 }
248
RemoveInterceptor(int32_t interceptorId)249 void InputManager::RemoveInterceptor(int32_t interceptorId)
250 {
251 InputMgrImpl.RemoveInterceptor(interceptorId);
252 }
253
SimulateInputEvent(std::shared_ptr<KeyEvent> keyEvent)254 void InputManager::SimulateInputEvent(std::shared_ptr<KeyEvent> keyEvent)
255 {
256 LogTracer lt(keyEvent->GetId(), keyEvent->GetEventType(), keyEvent->GetKeyAction());
257 keyEvent->AddFlag(InputEvent::EVENT_FLAG_SIMULATE);
258 InputMgrImpl.SimulateInputEvent(keyEvent);
259 }
260
SimulateInputEvent(std::shared_ptr<PointerEvent> pointerEvent,bool isAutoToVirtualScreen)261 void InputManager::SimulateInputEvent(std::shared_ptr<PointerEvent> pointerEvent, bool isAutoToVirtualScreen)
262 {
263 LogTracer lt(pointerEvent->GetId(), pointerEvent->GetEventType(), pointerEvent->GetPointerAction());
264 pointerEvent->AddFlag(InputEvent::EVENT_FLAG_SIMULATE);
265 #ifdef OHOS_BUILD_ENABLE_ONE_HAND_MODE
266 pointerEvent->SetAutoToVirtualScreen(isAutoToVirtualScreen);
267 #endif // OHOS_BUILD_ENABLE_ONE_HAND_MODE
268 PointerEvent::PointerItem pointerItem;
269 if (pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem)) {
270 MMI_HILOGD("isAutoToVirtualScreen=%{public}s, DX=%{private}d, DY=%{private}d, "
271 "FDX=%{private}d, FDY=%{private}d",
272 isAutoToVirtualScreen ? "true" : "false", pointerItem.GetDisplayX(), pointerItem.GetDisplayY(),
273 pointerItem.GetFixedDisplayX(), pointerItem.GetFixedDisplayY());
274 } else {
275 MMI_HILOGD("isAutoToVirtualScreen=%{public}s", isAutoToVirtualScreen ? "true" : "false");
276 }
277 InputMgrImpl.SimulateInputEvent(pointerEvent);
278 }
279
SimulateInputEvent(std::shared_ptr<PointerEvent> pointerEvent,float zOrder,bool isAutoToVirtualScreen)280 void InputManager::SimulateInputEvent(std::shared_ptr<PointerEvent> pointerEvent, float zOrder,
281 bool isAutoToVirtualScreen)
282 {
283 CHKPV(pointerEvent);
284 LogTracer lt(pointerEvent->GetId(), pointerEvent->GetEventType(), pointerEvent->GetPointerAction());
285 pointerEvent->AddFlag(InputEvent::EVENT_FLAG_SIMULATE);
286 pointerEvent->SetZOrder(zOrder);
287 #ifdef OHOS_BUILD_ENABLE_ONE_HAND_MODE
288 pointerEvent->SetAutoToVirtualScreen(isAutoToVirtualScreen);
289 #endif // OHOS_BUILD_ENABLE_ONE_HAND_MODE
290 PointerEvent::PointerItem pointerItem;
291 if (pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem)) {
292 MMI_HILOGD("zOrder=%{public}f, isAutoToVirtualScreen=%{public}s, DX=%{private}d, DY=%{private}d, "
293 "FDX=%{private}d, FDY=%{private}d",
294 zOrder, isAutoToVirtualScreen ? "true" : "false", pointerItem.GetDisplayX(), pointerItem.GetDisplayY(),
295 pointerItem.GetFixedDisplayX(), pointerItem.GetFixedDisplayY());
296 } else {
297 MMI_HILOGD("zOrder=%{public}f, isAutoToVirtualScreen=%{public}s", zOrder,
298 isAutoToVirtualScreen ? "true" : "false");
299 }
300 InputMgrImpl.SimulateInputEvent(pointerEvent);
301 }
302
SimulateTouchPadInputEvent(std::shared_ptr<PointerEvent> pointerEvent,const TouchpadCDG & touchpadCDG)303 void InputManager::SimulateTouchPadInputEvent(std::shared_ptr<PointerEvent> pointerEvent,
304 const TouchpadCDG &touchpadCDG)
305 {
306 CHKPV(pointerEvent);
307 LogTracer lt(pointerEvent->GetId(), pointerEvent->GetEventType(), pointerEvent->GetPointerAction());
308 pointerEvent->AddFlag(InputEvent::EVENT_FLAG_SIMULATE);
309 pointerEvent->SetZOrder(touchpadCDG.zOrder);
310 InputMgrImpl.SimulateTouchPadInputEvent(pointerEvent, touchpadCDG);
311 }
312
SimulateTouchPadEvent(std::shared_ptr<PointerEvent> pointerEvent)313 void InputManager::SimulateTouchPadEvent(std::shared_ptr<PointerEvent> pointerEvent)
314 {
315 CHKPV(pointerEvent);
316 LogTracer lt(pointerEvent->GetId(), pointerEvent->GetEventType(), pointerEvent->GetPointerAction());
317 pointerEvent->AddFlag(InputEvent::EVENT_FLAG_SIMULATE);
318 InputMgrImpl.SimulateTouchPadEvent(pointerEvent);
319 }
320
TransformMouseEventToTouchEvent(std::shared_ptr<PointerEvent> pointerEvent)321 bool InputManager::TransformMouseEventToTouchEvent(std::shared_ptr<PointerEvent> pointerEvent)
322 {
323 if (pointerEvent->GetSourceType() != PointerEvent::SOURCE_TYPE_MOUSE) {
324 MMI_HILOGD("It's not MouseEvent, don't need to transform");
325 return true;
326 }
327
328 int32_t result = -1;
329 if (MOUSE_TO_TOUCH_PARAM_MAP.count(pointerEvent->GetSourceType()) > 0) {
330 result = MOUSE_TO_TOUCH_PARAM_MAP.at(pointerEvent->GetSourceType());
331 pointerEvent->SetSourceType(result);
332 }
333
334 if (MOUSE_TO_TOUCH_PARAM_MAP.count(pointerEvent->GetPointerAction()) > 0) {
335 result = MOUSE_TO_TOUCH_PARAM_MAP.at(pointerEvent->GetPointerAction());
336 pointerEvent->SetPointerAction(result);
337 pointerEvent->SetOriginPointerAction(result);
338 }
339
340 if (MOUSE_TO_TOUCH_PARAM_MAP.count(pointerEvent->GetButtonId()) > 0) {
341 result = MOUSE_TO_TOUCH_PARAM_MAP.at(pointerEvent->GetButtonId());
342 pointerEvent->SetButtonId(result);
343 }
344
345 int32_t pointerId = pointerEvent->GetPointerId();
346 PointerEvent::PointerItem pointerItem;
347 if (!pointerEvent->GetPointerItem(pointerId, pointerItem)) {
348 MMI_HILOGE("Can't find pointer item, pointer:%{public}d", pointerId);
349 return false;
350 }
351
352 if (MOUSE_TO_TOUCH_PARAM_MAP.count(pointerItem.GetToolType()) > 0) {
353 result = MOUSE_TO_TOUCH_PARAM_MAP.at(pointerItem.GetToolType());
354 pointerItem.SetToolType(result);
355 }
356
357 pointerEvent->UpdatePointerItem(pointerId, pointerItem);
358 return true;
359 }
360
TransformTouchEventToMouseEvent(std::shared_ptr<PointerEvent> pointerEvent)361 bool InputManager::TransformTouchEventToMouseEvent(std::shared_ptr<PointerEvent> pointerEvent)
362 {
363 if (pointerEvent->GetSourceType() != PointerEvent::SOURCE_TYPE_TOUCHSCREEN) {
364 MMI_HILOGD("It's not MouseEvent, don't need to transform");
365 return true;
366 }
367
368 int32_t result = -1;
369 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
370
371 if (TOUCH_TO_MOUSE_PARAM_MAP.count(pointerEvent->GetPointerAction()) > 0) {
372 result = TOUCH_TO_MOUSE_PARAM_MAP.at(pointerEvent->GetPointerAction());
373 pointerEvent->SetPointerAction(result);
374 pointerEvent->SetOriginPointerAction(result);
375 }
376
377 int32_t pointerId = pointerEvent->GetPointerId();
378 PointerEvent::PointerItem pointerItem;
379 if (!pointerEvent->GetPointerItem(pointerId, pointerItem)) {
380 MMI_HILOGE("Can't find pointer item, pointer:%{public}d", pointerId);
381 return false;
382 }
383
384 if (TOUCH_TO_MOUSE_PARAM_MAP.count(pointerItem.GetToolType()) > 0) {
385 result = TOUCH_TO_MOUSE_PARAM_MAP.at(pointerItem.GetToolType());
386 pointerItem.SetToolType(result);
387 }
388
389 if (pointerItem.GetTargetWindowId() > 0) {
390 pointerItem.SetTargetWindowId(PointerEvent::POINTER_INITIAL_VALUE);
391 }
392
393 pointerEvent->SetButtonId(PointerEvent::MOUSE_BUTTON_LEFT);
394
395 pointerEvent->UpdatePointerItem(pointerId, pointerItem);
396 return true;
397 }
398
RegisterDevListener(std::string type,std::shared_ptr<IInputDeviceListener> listener)399 int32_t InputManager::RegisterDevListener(std::string type, std::shared_ptr<IInputDeviceListener> listener)
400 {
401 return InputMgrImpl.RegisterDevListener(type, listener);
402 }
403
UnregisterDevListener(std::string type,std::shared_ptr<IInputDeviceListener> listener)404 int32_t InputManager::UnregisterDevListener(std::string type, std::shared_ptr<IInputDeviceListener> listener)
405 {
406 return InputMgrImpl.UnregisterDevListener(type, listener);
407 }
408
GetDeviceIds(std::function<void (std::vector<int32_t> &)> callback)409 int32_t InputManager::GetDeviceIds(std::function<void(std::vector<int32_t>&)> callback)
410 {
411 return InputMgrImpl.GetDeviceIds(callback);
412 }
413
GetDevice(int32_t deviceId,std::function<void (std::shared_ptr<InputDevice>)> callback)414 int32_t InputManager::GetDevice(int32_t deviceId,
415 std::function<void(std::shared_ptr<InputDevice>)> callback)
416 {
417 return InputMgrImpl.GetDevice(deviceId, callback);
418 }
419
SupportKeys(int32_t deviceId,std::vector<int32_t> keyCodes,std::function<void (std::vector<bool> &)> callback)420 int32_t InputManager::SupportKeys(int32_t deviceId, std::vector<int32_t> keyCodes,
421 std::function<void(std::vector<bool>&)> callback)
422 {
423 return InputMgrImpl.SupportKeys(deviceId, keyCodes, callback);
424 }
425
SetMouseScrollRows(int32_t Rows)426 int32_t InputManager::SetMouseScrollRows(int32_t Rows)
427 {
428 return InputMgrImpl.SetMouseScrollRows(Rows);
429 }
430
GetMouseScrollRows(int32_t & Rows)431 int32_t InputManager::GetMouseScrollRows(int32_t &Rows)
432 {
433 return InputMgrImpl.GetMouseScrollRows(Rows);
434 }
435
SetCustomCursor(int32_t windowId,void * pixelMap,int32_t focusX,int32_t focusY)436 int32_t InputManager::SetCustomCursor(int32_t windowId, void* pixelMap, int32_t focusX, int32_t focusY)
437 {
438 return InputMgrImpl.SetCustomCursor(windowId, focusX, focusY, pixelMap);
439 }
440
SetMouseIcon(int32_t windowId,void * pixelMap)441 int32_t InputManager::SetMouseIcon(int32_t windowId, void* pixelMap)
442 {
443 return InputMgrImpl.SetMouseIcon(windowId, pixelMap);
444 }
445
SetPointerSize(int32_t size)446 int32_t InputManager::SetPointerSize(int32_t size)
447 {
448 return InputMgrImpl.SetPointerSize(size);
449 }
450
GetPointerSize(int32_t & size)451 int32_t InputManager::GetPointerSize(int32_t &size)
452 {
453 return InputMgrImpl.GetPointerSize(size);
454 }
455
GetCursorSurfaceId(uint64_t & surfaceId)456 int32_t InputManager::GetCursorSurfaceId(uint64_t &surfaceId)
457 {
458 return InputMgrImpl.GetCursorSurfaceId(surfaceId);
459 }
460
SetMouseHotSpot(int32_t windowId,int32_t hotSpotX,int32_t hotSpotY)461 int32_t InputManager::SetMouseHotSpot(int32_t windowId, int32_t hotSpotX, int32_t hotSpotY)
462 {
463 return InputMgrImpl.SetMouseHotSpot(windowId, hotSpotX, hotSpotY);
464 }
465
SetMousePrimaryButton(int32_t primaryButton)466 int32_t InputManager::SetMousePrimaryButton(int32_t primaryButton)
467 {
468 return InputMgrImpl.SetMousePrimaryButton(primaryButton);
469 }
470
GetMousePrimaryButton(int32_t & primaryButton)471 int32_t InputManager::GetMousePrimaryButton(int32_t &primaryButton)
472 {
473 return InputMgrImpl.GetMousePrimaryButton(primaryButton);
474 }
475
SetHoverScrollState(bool state)476 int32_t InputManager::SetHoverScrollState(bool state)
477 {
478 return InputMgrImpl.SetHoverScrollState(state);
479 }
480
GetHoverScrollState(bool & state)481 int32_t InputManager::GetHoverScrollState(bool &state)
482 {
483 return InputMgrImpl.GetHoverScrollState(state);
484 }
485
SetPointerVisible(bool visible,int32_t priority)486 int32_t InputManager::SetPointerVisible(bool visible, int32_t priority)
487 {
488 return InputMgrImpl.SetPointerVisible(visible, priority);
489 }
490
IsPointerVisible()491 bool InputManager::IsPointerVisible()
492 {
493 return InputMgrImpl.IsPointerVisible();
494 }
495
SetPointerColor(int32_t color)496 int32_t InputManager::SetPointerColor(int32_t color)
497 {
498 return InputMgrImpl.SetPointerColor(color);
499 }
500
GetPointerColor(int32_t & color)501 int32_t InputManager::GetPointerColor(int32_t &color)
502 {
503 return InputMgrImpl.GetPointerColor(color);
504 }
505
EnableCombineKey(bool enable)506 int32_t InputManager::EnableCombineKey(bool enable)
507 {
508 return InputMgrImpl.EnableCombineKey(enable);
509 }
510
SetPointerSpeed(int32_t speed)511 int32_t InputManager::SetPointerSpeed(int32_t speed)
512 {
513 return InputMgrImpl.SetPointerSpeed(speed);
514 }
515
GetPointerSpeed(int32_t & speed)516 int32_t InputManager::GetPointerSpeed(int32_t &speed)
517 {
518 return InputMgrImpl.GetPointerSpeed(speed);
519 }
520
GetKeyboardType(int32_t deviceId,std::function<void (int32_t)> callback)521 int32_t InputManager::GetKeyboardType(int32_t deviceId, std::function<void(int32_t)> callback)
522 {
523 return InputMgrImpl.GetKeyboardType(deviceId, callback);
524 }
525
SetAnrObserver(std::shared_ptr<IAnrObserver> observer)526 void InputManager::SetAnrObserver(std::shared_ptr<IAnrObserver> observer)
527 {
528 InputMgrImpl.SetAnrObserver(observer);
529 }
530
SetPointerStyle(int32_t windowId,PointerStyle pointerStyle,bool isUiExtension)531 int32_t InputManager::SetPointerStyle(int32_t windowId, PointerStyle pointerStyle, bool isUiExtension)
532 {
533 return InputMgrImpl.SetPointerStyle(windowId, pointerStyle, isUiExtension);
534 }
535
GetPointerStyle(int32_t windowId,PointerStyle & pointerStyle,bool isUiExtension)536 int32_t InputManager::GetPointerStyle(int32_t windowId, PointerStyle &pointerStyle, bool isUiExtension)
537 {
538 return InputMgrImpl.GetPointerStyle(windowId, pointerStyle, isUiExtension);
539 }
540
GetFunctionKeyState(int32_t funcKey,bool & state)541 int32_t InputManager::GetFunctionKeyState(int32_t funcKey, bool &state)
542 {
543 return InputMgrImpl.GetFunctionKeyState(funcKey, state);
544 }
545
SetFunctionKeyState(int32_t funcKey,bool enable)546 int32_t InputManager::SetFunctionKeyState(int32_t funcKey, bool enable)
547 {
548 return InputMgrImpl.SetFunctionKeyState(funcKey, enable);
549 }
550
SetPointerLocation(int32_t x,int32_t y,int32_t displayId)551 int32_t InputManager::SetPointerLocation(int32_t x, int32_t y, int32_t displayId)
552 {
553 return InputMgrImpl.SetPointerLocation(x, y, displayId);
554 }
555
EnterCaptureMode(int32_t windowId)556 int32_t InputManager::EnterCaptureMode(int32_t windowId)
557 {
558 return InputMgrImpl.EnterCaptureMode(windowId);
559 }
560
LeaveCaptureMode(int32_t windowId)561 int32_t InputManager::LeaveCaptureMode(int32_t windowId)
562 {
563 return InputMgrImpl.LeaveCaptureMode(windowId);
564 }
565
AppendExtraData(const ExtraData & extraData)566 int32_t InputManager::AppendExtraData(const ExtraData& extraData)
567 {
568 return InputMgrImpl.AppendExtraData(extraData);
569 }
570
EnableInputDevice(bool enable)571 int32_t InputManager::EnableInputDevice(bool enable)
572 {
573 return InputMgrImpl.EnableInputDevice(enable);
574 }
575
AddVirtualInputDevice(std::shared_ptr<InputDevice> device,int32_t & deviceId)576 int32_t InputManager::AddVirtualInputDevice(std::shared_ptr<InputDevice> device, int32_t &deviceId)
577 {
578 return InputMgrImpl.AddVirtualInputDevice(device, deviceId);
579 }
580
RemoveVirtualInputDevice(int32_t deviceId)581 int32_t InputManager::RemoveVirtualInputDevice(int32_t deviceId)
582 {
583 return InputMgrImpl.RemoveVirtualInputDevice(deviceId);
584 }
585
SetKeyDownDuration(const std::string & businessId,int32_t delay)586 int32_t InputManager::SetKeyDownDuration(const std::string& businessId, int32_t delay)
587 {
588 return InputMgrImpl.SetKeyDownDuration(businessId, delay);
589 }
590
SetKeyboardRepeatDelay(int32_t delay)591 int32_t InputManager::SetKeyboardRepeatDelay(int32_t delay)
592 {
593 return InputMgrImpl.SetKeyboardRepeatDelay(delay);
594 }
595
SetKeyboardRepeatRate(int32_t rate)596 int32_t InputManager::SetKeyboardRepeatRate(int32_t rate)
597 {
598 return InputMgrImpl.SetKeyboardRepeatRate(rate);
599 }
600
GetKeyboardRepeatDelay(std::function<void (int32_t)> callback)601 int32_t InputManager::GetKeyboardRepeatDelay(std::function<void(int32_t)> callback)
602 {
603 return InputMgrImpl.GetKeyboardRepeatDelay(callback);
604 }
605
GetKeyboardRepeatRate(std::function<void (int32_t)> callback)606 int32_t InputManager::GetKeyboardRepeatRate(std::function<void(int32_t)> callback)
607 {
608 return InputMgrImpl.GetKeyboardRepeatRate(callback);
609 }
610
611 #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT
SetEnhanceConfig(uint8_t * cfg,uint32_t cfgLen)612 void InputManager::SetEnhanceConfig(uint8_t *cfg, uint32_t cfgLen)
613 {
614 InputMgrImpl.SetEnhanceConfig(cfg, cfgLen);
615 }
616 #endif // OHOS_BUILD_ENABLE_SECURITY_COMPONENT
617
SetTouchpadScrollSwitch(bool switchFlag)618 int32_t InputManager::SetTouchpadScrollSwitch(bool switchFlag)
619 {
620 return InputMgrImpl.SetTouchpadScrollSwitch(switchFlag);
621 }
622
GetTouchpadScrollSwitch(bool & switchFlag)623 int32_t InputManager::GetTouchpadScrollSwitch(bool &switchFlag)
624 {
625 return InputMgrImpl.GetTouchpadScrollSwitch(switchFlag);
626 }
SetTouchpadScrollDirection(bool state)627 int32_t InputManager::SetTouchpadScrollDirection(bool state)
628 {
629 return InputMgrImpl.SetTouchpadScrollDirection(state);
630 }
631
GetTouchpadScrollDirection(bool & state)632 int32_t InputManager::GetTouchpadScrollDirection(bool &state)
633 {
634 return InputMgrImpl.GetTouchpadScrollDirection(state);
635 }
SetTouchpadTapSwitch(bool switchFlag)636 int32_t InputManager::SetTouchpadTapSwitch(bool switchFlag)
637 {
638 return InputMgrImpl.SetTouchpadTapSwitch(switchFlag);
639 }
640
GetTouchpadTapSwitch(bool & switchFlag)641 int32_t InputManager::GetTouchpadTapSwitch(bool &switchFlag)
642 {
643 return InputMgrImpl.GetTouchpadTapSwitch(switchFlag);
644 }
645
SetTouchpadPointerSpeed(int32_t speed)646 int32_t InputManager::SetTouchpadPointerSpeed(int32_t speed)
647 {
648 return InputMgrImpl.SetTouchpadPointerSpeed(speed);
649 }
650
GetTouchpadPointerSpeed(int32_t & speed)651 int32_t InputManager::GetTouchpadPointerSpeed(int32_t &speed)
652 {
653 return InputMgrImpl.GetTouchpadPointerSpeed(speed);
654 }
655
GetTouchpadCDG(TouchpadCDG & touchpadCDG)656 int32_t InputManager::GetTouchpadCDG(TouchpadCDG &touchpadCDG)
657 {
658 return InputMgrImpl.GetTouchpadCDG(touchpadCDG);
659 }
660
SetTouchpadPinchSwitch(bool switchFlag)661 int32_t InputManager::SetTouchpadPinchSwitch(bool switchFlag)
662 {
663 return InputMgrImpl.SetTouchpadPinchSwitch(switchFlag);
664 }
665
GetTouchpadPinchSwitch(bool & switchFlag)666 int32_t InputManager::GetTouchpadPinchSwitch(bool &switchFlag)
667 {
668 return InputMgrImpl.GetTouchpadPinchSwitch(switchFlag);
669 }
670
SetTouchpadSwipeSwitch(bool switchFlag)671 int32_t InputManager::SetTouchpadSwipeSwitch(bool switchFlag)
672 {
673 return InputMgrImpl.SetTouchpadSwipeSwitch(switchFlag);
674 }
675
GetTouchpadSwipeSwitch(bool & switchFlag)676 int32_t InputManager::GetTouchpadSwipeSwitch(bool &switchFlag)
677 {
678 return InputMgrImpl.GetTouchpadSwipeSwitch(switchFlag);
679 }
680
SetTouchpadRightClickType(int32_t type)681 int32_t InputManager::SetTouchpadRightClickType(int32_t type)
682 {
683 return InputMgrImpl.SetTouchpadRightClickType(type);
684 }
685
GetTouchpadRightClickType(int32_t & type)686 int32_t InputManager::GetTouchpadRightClickType(int32_t &type)
687 {
688 return InputMgrImpl.GetTouchpadRightClickType(type);
689 }
690
SetTouchpadRotateSwitch(bool rotateSwitch)691 int32_t InputManager::SetTouchpadRotateSwitch(bool rotateSwitch)
692 {
693 return InputMgrImpl.SetTouchpadRotateSwitch(rotateSwitch);
694 }
695
GetTouchpadRotateSwitch(bool & rotateSwitch)696 int32_t InputManager::GetTouchpadRotateSwitch(bool &rotateSwitch)
697 {
698 return InputMgrImpl.GetTouchpadRotateSwitch(rotateSwitch);
699 }
700
SetTouchpadDoubleTapAndDragState(bool switchFlag)701 int32_t InputManager::SetTouchpadDoubleTapAndDragState(bool switchFlag)
702 {
703 return InputMgrImpl.SetTouchpadDoubleTapAndDragState(switchFlag);
704 }
705
GetTouchpadDoubleTapAndDragState(bool & switchFlag)706 int32_t InputManager::GetTouchpadDoubleTapAndDragState(bool &switchFlag)
707 {
708 return InputMgrImpl.GetTouchpadDoubleTapAndDragState(switchFlag);
709 }
710
EnableHardwareCursorStats(bool enable)711 int32_t InputManager::EnableHardwareCursorStats(bool enable)
712 {
713 return InputMgrImpl.EnableHardwareCursorStats(enable);
714 }
715
GetHardwareCursorStats(uint32_t & frameCount,uint32_t & vsyncCount)716 int32_t InputManager::GetHardwareCursorStats(uint32_t &frameCount, uint32_t &vsyncCount)
717 {
718 return InputMgrImpl.GetHardwareCursorStats(frameCount, vsyncCount);
719 }
720
GetPointerSnapshot(void * pixelMapPtr)721 int32_t InputManager::GetPointerSnapshot(void *pixelMapPtr)
722 {
723 return InputMgrImpl.GetPointerSnapshot(pixelMapPtr);
724 }
725
SetTouchpadScrollRows(int32_t rows)726 int32_t InputManager::SetTouchpadScrollRows(int32_t rows)
727 {
728 return InputMgrImpl.SetTouchpadScrollRows(rows);
729 }
730
GetTouchpadScrollRows(int32_t & rows)731 int32_t InputManager::GetTouchpadScrollRows(int32_t &rows)
732 {
733 return InputMgrImpl.GetTouchpadScrollRows(rows);
734 }
735
ClearWindowPointerStyle(int32_t pid,int32_t windowId)736 void InputManager::ClearWindowPointerStyle(int32_t pid, int32_t windowId)
737 {
738 InputMgrImpl.ClearWindowPointerStyle(pid, windowId);
739 }
740
SetNapStatus(int32_t pid,int32_t uid,std::string bundleName,int32_t napStatus)741 void InputManager::SetNapStatus(int32_t pid, int32_t uid, std::string bundleName, int32_t napStatus)
742 {
743 InputMgrImpl.SetNapStatus(pid, uid, bundleName, napStatus);
744 }
745
SetShieldStatus(int32_t shieldMode,bool isShield)746 int32_t InputManager::SetShieldStatus(int32_t shieldMode, bool isShield)
747 {
748 return InputMgrImpl.SetShieldStatus(shieldMode, isShield);
749 }
750
GetShieldStatus(int32_t shieldMode,bool & isShield)751 int32_t InputManager::GetShieldStatus(int32_t shieldMode, bool &isShield)
752 {
753 return InputMgrImpl.GetShieldStatus(shieldMode, isShield);
754 }
755
AddServiceWatcher(std::shared_ptr<IInputServiceWatcher> watcher)756 void InputManager::AddServiceWatcher(std::shared_ptr<IInputServiceWatcher> watcher)
757 {
758 InputMgrImpl.AddServiceWatcher(watcher);
759 }
760
RemoveServiceWatcher(std::shared_ptr<IInputServiceWatcher> watcher)761 void InputManager::RemoveServiceWatcher(std::shared_ptr<IInputServiceWatcher> watcher)
762 {
763 InputMgrImpl.RemoveServiceWatcher(watcher);
764 }
765
MarkProcessed(int32_t eventId,int64_t actionTime,bool enable)766 int32_t InputManager::MarkProcessed(int32_t eventId, int64_t actionTime, bool enable)
767 {
768 LogTracer lt(eventId, 0, 0);
769 if (enable) {
770 return InputMgrImpl.MarkProcessed(eventId, actionTime);
771 }
772 MMI_HILOGD("Skip MarkProcessed eventId:%{public}d", eventId);
773 return RET_OK;
774 }
775
GetKeyState(std::vector<int32_t> & pressedKeys,std::map<int32_t,int32_t> & specialKeysState)776 int32_t InputManager::GetKeyState(std::vector<int32_t> &pressedKeys, std::map<int32_t, int32_t> &specialKeysState)
777 {
778 return InputMgrImpl.GetKeyState(pressedKeys, specialKeysState);
779 }
780
Authorize(bool isAuthorize)781 void InputManager::Authorize(bool isAuthorize)
782 {
783 InputMgrImpl.Authorize(isAuthorize);
784 }
785
HasIrEmitter(bool & hasIrEmitter)786 int32_t InputManager::HasIrEmitter(bool &hasIrEmitter)
787 {
788 return InputMgrImpl.HasIrEmitter(hasIrEmitter);
789 }
790
GetInfraredFrequencies(std::vector<InfraredFrequency> & requencys)791 int32_t InputManager::GetInfraredFrequencies(std::vector<InfraredFrequency>& requencys)
792 {
793 return InputMgrImpl.GetInfraredFrequencies(requencys);
794 }
795
TransmitInfrared(int64_t number,std::vector<int64_t> & pattern)796 int32_t InputManager::TransmitInfrared(int64_t number, std::vector<int64_t>& pattern)
797 {
798 return InputMgrImpl.TransmitInfrared(number, pattern);
799 }
800
801 #ifdef OHOS_BUILD_ENABLE_VKEYBOARD
CreateVKeyboardDevice(sptr<IRemoteObject> & vkeyboardDevice)802 int32_t InputManager::CreateVKeyboardDevice(sptr<IRemoteObject> &vkeyboardDevice)
803 {
804 return InputMgrImpl.CreateVKeyboardDevice(vkeyboardDevice);
805 }
806 #endif // OHOS_BUILD_ENABLE_VKEYBOARD
807
SetCurrentUser(int32_t userId)808 int32_t InputManager::SetCurrentUser(int32_t userId)
809 {
810 return InputMgrImpl.SetCurrentUser(userId);
811 }
812
SetMoveEventFilters(bool flag)813 int32_t InputManager::SetMoveEventFilters(bool flag)
814 {
815 return InputMgrImpl.SetMoveEventFilters(flag);
816 }
817
SetTouchpadThreeFingersTapSwitch(bool switchFlag)818 int32_t InputManager::SetTouchpadThreeFingersTapSwitch(bool switchFlag)
819 {
820 return InputMgrImpl.SetTouchpadThreeFingersTapSwitch(switchFlag);
821 }
822
GetTouchpadThreeFingersTapSwitch(bool & switchFlag)823 int32_t InputManager::GetTouchpadThreeFingersTapSwitch(bool &switchFlag)
824 {
825 return InputMgrImpl.GetTouchpadThreeFingersTapSwitch(switchFlag);
826 }
827
GetWinSyncBatchSize(int32_t maxAreasCount,int32_t displayCount)828 int32_t InputManager::GetWinSyncBatchSize(int32_t maxAreasCount, int32_t displayCount)
829 {
830 return InputMgrImpl.GetWinSyncBatchSize(maxAreasCount, displayCount);
831 }
832
AncoAddConsumer(std::shared_ptr<IAncoConsumer> consumer)833 int32_t InputManager::AncoAddConsumer(std::shared_ptr<IAncoConsumer> consumer)
834 {
835 return InputMgrImpl.AncoAddChannel(consumer);
836 }
837
AncoRemoveConsumer(std::shared_ptr<IAncoConsumer> consumer)838 int32_t InputManager::AncoRemoveConsumer(std::shared_ptr<IAncoConsumer> consumer)
839 {
840 return InputMgrImpl.AncoRemoveChannel(consumer);
841 }
842
SkipPointerLayer(bool isSkip)843 int32_t InputManager::SkipPointerLayer(bool isSkip)
844 {
845 return InputMgrImpl.SkipPointerLayer(isSkip);
846 }
847
RegisterWindowStateErrorCallback(std::function<void (int32_t,int32_t)> callback)848 int32_t InputManager::RegisterWindowStateErrorCallback(std::function<void(int32_t, int32_t)> callback)
849 {
850 return InputMgrImpl.RegisterWindowStateErrorCallback(callback);
851 }
852
GetIntervalSinceLastInput(int64_t & timeInterval)853 int32_t InputManager::GetIntervalSinceLastInput(int64_t &timeInterval)
854 {
855 return InputMgrImpl.GetIntervalSinceLastInput(timeInterval);
856 }
857
GetAllSystemHotkeys(std::vector<std::unique_ptr<KeyOption>> & keyOptions,int32_t & count)858 int32_t InputManager::GetAllSystemHotkeys(std::vector<std::unique_ptr<KeyOption>> &keyOptions, int32_t &count)
859 {
860 return InputMgrImpl.GetAllSystemHotkeys(keyOptions, count);
861 }
862
ConvertToCapiKeyAction(int32_t keyAction)863 int32_t InputManager::ConvertToCapiKeyAction(int32_t keyAction)
864 {
865 return InputMgrImpl.ConvertToCapiKeyAction(keyAction);
866 }
867
SetInputDeviceEnabled(int32_t deviceId,bool enable,std::function<void (int32_t)> callback)868 int32_t InputManager::SetInputDeviceEnabled(int32_t deviceId, bool enable, std::function<void(int32_t)> callback)
869 {
870 return InputMgrImpl.SetInputDeviceEnabled(deviceId, enable, callback);
871 }
872
ShiftAppPointerEvent(const ShiftWindowParam & param,bool autoGenDown)873 int32_t InputManager::ShiftAppPointerEvent(const ShiftWindowParam ¶m, bool autoGenDown)
874 {
875 HITRACE_METER_NAME(HITRACE_TAG_MULTIMODALINPUT, "shift pointer event entry");
876 return InputMgrImpl.ShiftAppPointerEvent(param, autoGenDown);
877 }
878
SetCustomCursor(int32_t windowId,CustomCursor cursor,CursorOptions options)879 int32_t InputManager::SetCustomCursor(int32_t windowId, CustomCursor cursor, CursorOptions options)
880 {
881 return InputMgrImpl.SetCustomCursor(windowId, cursor, options);
882 }
883
CheckKnuckleEvent(float pointX,float pointY,bool & isKnuckleType)884 int32_t InputManager::CheckKnuckleEvent(float pointX, float pointY, bool &isKnuckleType)
885 {
886 return InputMgrImpl.CheckKnuckleEvent(pointX, pointY, isKnuckleType);
887 }
888
SetMultiWindowScreenId(uint64_t screenId,uint64_t displayNodeScreenId)889 void InputManager::SetMultiWindowScreenId(uint64_t screenId, uint64_t displayNodeScreenId)
890 {
891 InputMgrImpl.SetMultiWindowScreenId(screenId, displayNodeScreenId);
892 }
893 } // namespace MMI
894 } // namespace OHOS
895