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 "event_handler.h" 20 21 #include "error_multimodal.h" 22 #include "extra_data.h" 23 #include "i_anco_consumer.h" 24 #include "i_anr_observer.h" 25 #include "i_input_device_listener.h" 26 #include "i_input_event_consumer.h" 27 #include "i_input_event_filter.h" 28 #include "i_input_service_watcher.h" 29 #include "i_window_checker.h" 30 #include "infrared_frequency_info.h" 31 #include "input_device.h" 32 #include "key_option.h" 33 #include "long_press_event.h" 34 #include "mmi_event_observer.h" 35 #include "pointer_style.h" 36 #include "touchpad_control_display_gain.h" 37 #include "shift_info.h" 38 39 namespace OHOS { 40 namespace MMI { 41 class InputManager { 42 public: 43 /** 44 * @brief Obtains an <b>InputManager</b> instance. 45 * @return Returns the pointer to the <b>InputManager</b> instance. 46 * @since 9 47 */ 48 static InputManager *GetInstance(); 49 virtual ~InputManager() = default; 50 51 int32_t GetDisplayBindInfo(DisplayBindInfos &infos); 52 int32_t SetDisplayBind(int32_t deviceId, int32_t displayId, std::string &msg); 53 54 /** 55 * @brief Updates the screen、display and window information array. 56 * @param userScreenInfo Indicates the user screen、display and window information. 57 * @since 20 58 */ 59 int32_t UpdateDisplayInfo(const UserScreenInfo &userScreenInfo); 60 61 /** 62 * @brief Updates the windows information. 63 * @param windowGroupInfo Indicates the window group information. 64 * @since 9 65 */ 66 int32_t UpdateWindowInfo(const WindowGroupInfo &windowGroupInfo); 67 68 int32_t AddInputEventFilter(std::shared_ptr<IInputEventFilter> filter, int32_t priority, uint32_t deviceTags); 69 int32_t RemoveInputEventFilter(int32_t filterId); 70 71 /** 72 * @brief Updates the process info to other server. 73 * @param observer Indicates the progess info. 74 * @return the observer setting successed or not. 75 * @since 10 76 */ 77 int32_t AddInputEventObserver(std::shared_ptr<MMIEventObserver> observer); 78 79 /** 80 * @brief Callback interface of the remove module. 81 * @param observer Indicates the progess info. 82 * @return EC_OK if unsubscribe successfully, else return other errcodes. 83 * @since 10 84 */ 85 int32_t RemoveInputEventObserver(std::shared_ptr<MMIEventObserver> observer = nullptr); 86 87 /** 88 * @brief Set the process info to mmi server. 89 * @param pid Indicates pid. 90 * @param uid Indicates uid. 91 * @param bundleName Indicates bundleName. 92 * @param napStatus Indicates napStatus. 93 * @since 10 94 */ 95 void SetNapStatus(int32_t pid, int32_t uid, const std::string &bundleName, int32_t napStatus); 96 97 /** 98 * @brief Get the process info datas to other server. 99 * @param callback Indicates the callback used to receive the reported data. 100 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 101 * @since 10 102 */ 103 int32_t GetAllMmiSubscribedEvents(std::map<std::tuple<int32_t, int32_t, std::string>, int32_t> &datas); 104 105 /** 106 * @brief Sets a consumer for the window input event of the current process. 107 * @param inputEventConsumer Indicates the consumer to set. The window input event of the current process 108 * will be called back to the consumer object for processing. 109 * @since 9 110 */ 111 int32_t SetWindowInputEventConsumer(std::shared_ptr<IInputEventConsumer> inputEventConsumer); 112 113 /** 114 * @brief Sets a window input event consumer that runs on the specified thread. 115 * @param inputEventConsumer Indicates the consumer to set. 116 * @param eventHandler Indicates the thread running the consumer. 117 * @since 9 118 */ 119 int32_t SetWindowInputEventConsumer(std::shared_ptr<IInputEventConsumer> inputEventConsumer, 120 std::shared_ptr<AppExecFwk::EventHandler> eventHandler); 121 122 /** 123 * @brief Subscribes to the key input event that meets a specific condition. When such an event occurs, 124 * the <b>callback</b> specified is invoked to process the event. 125 * @param keyOption Indicates the condition of the key input event. 126 * @param callback Indicates the callback. 127 * @return Returns the subscription ID, which uniquely identifies a subscription in the process. 128 * If the value is greater than or equal to <b>0</b>, 129 * the subscription is successful. Otherwise, the subscription fails. 130 * @since 9 131 */ 132 int32_t SubscribeKeyEvent(std::shared_ptr<KeyOption> keyOption, 133 std::function<void(std::shared_ptr<KeyEvent>)> callback); 134 135 /** 136 * @brief Unsubscribes from a key input event. 137 * @param subscriberId Indicates the subscription ID, which is the return value of <b>SubscribeKeyEvent</b>. 138 * @return void 139 * @since 9 140 */ 141 void UnsubscribeKeyEvent(int32_t subscriberId); 142 143 int32_t SubscribeHotkey(std::shared_ptr<KeyOption> keyOption, 144 std::function<void(std::shared_ptr<KeyEvent>)> callback); 145 void UnsubscribeHotkey(int32_t subscriberId); 146 147 int32_t SubscribeKeyMonitor(const KeyMonitorOption &keyOption, 148 std::function<void(std::shared_ptr<KeyEvent>)> callback); 149 int32_t UnsubscribeKeyMonitor(int32_t subscriberId); 150 151 /** 152 * @brief Subscribes to the switch input event that meets a specific condition. When such an event occurs, 153 * the <b>callback</b> specified is invoked to process the event. 154 * @param callback Indicates the callback. 155 * @param switchType Indicates the type of switch input event. 156 * @return Returns the subscription ID, which uniquely identifies a subscription in the process. 157 * If the value is greater than or equal to <b>0</b>, 158 * the subscription is successful. Otherwise, the subscription fails. 159 * @since 9 160 */ 161 int32_t SubscribeSwitchEvent(std::function<void(std::shared_ptr<SwitchEvent>)> callback, 162 SwitchEvent::SwitchType switchType = SwitchEvent::SwitchType::SWITCH_DEFAULT); 163 164 /** 165 * @brief Unsubscribes from a switch input event. 166 * @param subscriberId Indicates the subscription ID, which is the return value of <b>SubscribeKeyEvent</b>. 167 * @return void 168 * @since 9 169 */ 170 void UnsubscribeSwitchEvent(int32_t subscriberId); 171 172 /** 173 * @brief Query the current status of switches that meet specific conditions. 174 * @param switchType Indicates the type of switch to query. 175 * @param state Indicates the state of switch with given type. 176 * @return Returns <b>0<b/> if success; returns a non-0 value otherwise. 177 * @since 18 178 */ 179 int32_t QuerySwitchStatus(SwitchEvent::SwitchType switchType, SwitchEvent::SwitchState &state); 180 181 /** 182 * @brief Subscribes to the switch input event that meets a specific condition. When such an event occurs, 183 * the <b>callback</b> specified is invoked to process the event. 184 * @param callback Indicates the callback. 185 * @return Returns the subscription ID, which uniquely identifies a subscription in the process. 186 * If the value is greater than or equal to <b>0</b>, 187 * the subscription is successful. Otherwise, the subscription fails. 188 * @since 14 189 */ 190 int32_t SubscribeTabletProximity(std::function<void(std::shared_ptr<PointerEvent>)> callback); 191 192 /** 193 * @brief Unsubscribes from a switch input event. 194 * @param subscriberId Indicates the subscription ID, which is the return value of <b>SubscribeKeyEvent</b>. 195 * @return void 196 * @since 14 197 */ 198 void UnsubscribetabletProximity(int32_t subscriberId); 199 /** 200 * @brief Subscribes to the long-press event that meets a specific condition. 201 * @param LongPressRequest Long-press event. 202 * @param callback Callback invoked to process the event. 203 * @return Subscription ID, which uniquely identifies a subscription in the process. 204 * If the value is greater than or equal to <b>0</b>, 205 * the subscription is successful. Otherwise, the subscription fails. 206 * @since 16 207 */ 208 int32_t SubscribeLongPressEvent(const LongPressRequest &LongPressRequest, 209 std::function<void(LongPressEvent)> callback); 210 211 /** 212 * @brief Unsubscribes from a long-press event. 213 * @param subscriberId Subscription ID, which is the return value of <b>SubscribeKeyEvent</b>. 214 * @return void 215 * @since 16 216 */ 217 void UnsubscribeLongPressEvent(int32_t subscriberId); 218 219 /** 220 * @brief Adds an input event monitor. After such a monitor is added, 221 * an input event is copied and distributed to the monitor while being distributed to the original target. 222 * @param monitor Indicates the input event monitor. After an input event is generated, 223 * the functions of the monitor object will be called. 224 * @return Returns the monitor ID, which uniquely identifies a monitor in the process. 225 * If the value is greater than or equal to <b>0</b>, the monitor is successfully added. Otherwise, 226 * the monitor fails to be added. 227 * @since 9 228 */ 229 int32_t AddMonitor(std::function<void(std::shared_ptr<KeyEvent>)> monitor); 230 231 /** 232 * @brief Adds a pre input event monitor. After such a monitor is added, 233 * an input event is copied and distributed to the monitor while being distributed to the original target. 234 * @param monitor Indicates the input event monitor. After an input event is generated, 235 * the functions of the monitor object will be called. 236 * @param eventType Indicates the eventType for monitor. 237 * @param keys Event type, which is **key**. 238 * @return Returns the monitor ID, which uniquely identifies a monitor in the process. 239 * If the value is greater than or equal to <b>0</b>, the monitor is successfully added. Otherwise, 240 * the monitor fails to be added. 241 * @since 15 242 */ 243 int32_t AddPreMonitor(std::shared_ptr<IInputEventConsumer> monitor, 244 HandleEventType eventType, std::vector<int32_t> keys); 245 246 /** 247 * @brief Removes a pre monitor. 248 * @param monitorId Indicates the monitor ID, which is the return value of <b>AddPreMonitor</b>. 249 * @return void 250 * @since 15 251 */ 252 void RemovePreMonitor(int32_t monitorId); 253 254 /** 255 * @brief Adds an input event monitor. After such a monitor is added, 256 * an input event is copied and distributed to the monitor while being distributed to the original target. 257 * @param monitor Indicates the input event monitor. After an input event is generated, 258 * the functions of the monitor object will be called. 259 * @return Returns the monitor ID, which uniquely identifies a monitor in the process. 260 * If the value is greater than or equal to <b>0</b>, the monitor is successfully added. Otherwise, 261 * the monitor fails to be added. 262 * @since 9 263 */ 264 int32_t AddMonitor(std::function<void(std::shared_ptr<PointerEvent>)> monitor); 265 266 /** 267 * @brief Adds an input event monitor. After such a monitor is added, 268 * an input event is copied and distributed to the monitor while being distributed to the original target. 269 * @param monitor Indicates the input event monitor. After an input event is generated, 270 * the functions of the monitor object will be called. 271 * @param eventType Indicates the eventType for monitor. 272 * @return Returns the monitor ID, which uniquely identifies a monitor in the process. 273 * If the value is greater than or equal to <b>0</b>, the monitor is successfully added. Otherwise, 274 * the monitor fails to be added. 275 * @since 9 276 */ 277 int32_t AddMonitor(std::shared_ptr<IInputEventConsumer> monitor, HandleEventType eventType = HANDLE_EVENT_TYPE_KP); 278 /** 279 * @brief Adds an input event monitor. After such a monitor is added, 280 * an input event is copied and distributed to the monitor while being distributed to the original target. 281 * @param monitor Indicates the input event monitor. After an input event is generated, 282 * the functions of the monitor object will be called. 283 * @param actionsType Indicates the actionsType for monitor. 284 * @return Returns the monitor ID, which uniquely identifies a monitor in the process. 285 * If the value is greater than or equal to <b>0</b>, the monitor is successfully added. Otherwise, 286 * the monitor fails to be added. 287 * @since 9 288 */ 289 int32_t AddMonitor(std::shared_ptr<IInputEventConsumer> monitor, std::vector<int32_t> actionsType); 290 291 /** 292 * @brief Removes a monitor. 293 * @param monitorId Indicates the monitor ID, which is the return value of <b>AddMonitor</b>. 294 * @return void 295 * @since 9 296 */ 297 void RemoveMonitor(int32_t monitorId); 298 299 /** 300 * @brief Marks that a monitor has consumed a touchscreen input event. After being consumed, 301 * the touchscreen input event will not be distributed to the original target. 302 * @param monitorId Indicates the monitor ID. 303 * @param eventId Indicates the ID of the consumed touchscreen input event. 304 * @return void 305 * @since 9 306 */ 307 void MarkConsumed(int32_t monitorId, int32_t eventId); 308 309 /** 310 * @brief Moves the cursor to the specified position. 311 * @param offsetX Indicates the offset on the X axis. 312 * @param offsetY Indicates the offset on the Y axis. 313 * @return void 314 * @since 9 315 */ 316 void MoveMouse(int32_t offsetX, int32_t offsetY); 317 318 /** 319 * @brief Adds an input event interceptor. After such an interceptor is added, 320 * an input event will be distributed to the interceptor instead of the original target and monitor. 321 * @param interceptor Indicates the input event interceptor. After an input event is generated, 322 * the functions of the interceptor object will be called. 323 * @return Returns the interceptor ID, which uniquely identifies an interceptor in the process. 324 * If the value is greater than or equal to <b>0</b>,the interceptor is successfully added. Otherwise, 325 * the interceptor fails to be added. 326 * @since 9 327 */ 328 int32_t AddInterceptor(std::shared_ptr<IInputEventConsumer> interceptor); 329 int32_t AddInterceptor(std::function<void(std::shared_ptr<KeyEvent>)> interceptor); 330 int32_t AddInterceptor(std::shared_ptr<IInputEventConsumer> interceptor, int32_t priority, uint32_t deviceTags); 331 332 /** 333 * @brief Removes an interceptor. 334 * @param interceptorId Indicates the interceptor ID, which is the return value of <b>AddInterceptor</b>. 335 * @return void 336 * @since 9 337 */ 338 void RemoveInterceptor(int32_t interceptorId); 339 340 /** 341 * @brief Simulates a key input event. This event will be distributed and 342 * processed in the same way as the event reported by the input device. 343 * @param keyEvent Indicates the key input event to simulate. 344 * @return void 345 * @since 9 346 */ 347 void SimulateInputEvent(std::shared_ptr<KeyEvent> keyEvent); 348 349 /** 350 * @brief Simulates a touchpad input event, touchscreen input event, or mouse device input event. 351 * This event will be distributed and processed in the same way as the event reported by the input device. 352 * @param pointerEvent Indicates the touchpad input event, touchscreen input event, 353 * or mouse device input event to simulate. 354 * @param isAutoToVirtualScreen In one-handed mode, true indicates that the data is automatically injected to 355 * the virtual screen, and false indicates that the data is not automatically injected to the virtual screen. 356 * @param useCoordinate Which coordinates to use for injecting events. 357 * @return void 358 * @since 9 359 */ 360 void SimulateInputEvent(std::shared_ptr<PointerEvent> pointerEvent, bool isAutoToVirtualScreen = true, 361 int32_t useCoordinate = PointerEvent::DISPLAY_COORDINATE); 362 363 /** 364 * @brief Simulates a touchpad input event, touchscreen input event, or mouse device input event. 365 * This event will be distributed and processed in the same way as the event reported by the input device. 366 * @param pointerEvent Indicates the touchpad input event, touchscreen input event, 367 * or mouse device input event to simulate. 368 * @param zOrder Indicates the point event will inject to the window whose index value is less than the zOrder 369 * @param isAutoToVirtualScreen In one-handed mode, true indicates that the data is automatically injected to 370 * the virtual screen, and false indicates that the data is not automatically injected to the virtual screen. 371 * @param useCoordinate Which coordinates to use for injecting events. 372 * @return void 373 * @since 9 374 */ 375 void SimulateInputEvent(std::shared_ptr<PointerEvent> pointerEvent, float zOrder, 376 bool isAutoToVirtualScreen = true, int32_t useCoordinate = PointerEvent::DISPLAY_COORDINATE); 377 void SimulateTouchPadInputEvent(std::shared_ptr<PointerEvent> pointerEvent, const TouchpadCDG &touchpadCDG); 378 379 /** 380 * @brief Simulates a touchpad input event. 381 * because some event for touchpad is very different from other input, 382 * especially pointer.id must be same as actual data 0, 1, 2. 383 * @param pointerEvent Indicates the touchpad input event. 384 * @return void 385 * @since 12 386 */ 387 void SimulateTouchPadEvent(std::shared_ptr<PointerEvent> pointerEvent); 388 389 /** 390 * @brief Convert mouse events to touch events. 391 * @param pointerEvent PointerEvent object. 392 * @return bool 393 * @since 20 394 */ 395 bool TransformMouseEventToTouchEvent(std::shared_ptr<PointerEvent> pointerEvent); 396 397 /** 398 * @brief Convert touch events to mouse events. 399 * @param pointerEvent PointerEvent object. 400 * @return bool 401 * @since 20 402 */ 403 bool TransformTouchEventToMouseEvent(std::shared_ptr<PointerEvent> pointerEvent); 404 405 /** 406 * @brief Starts listening for an input device event. 407 * @param type Indicates the type of the input device event, which is <b>change</b>. 408 * @param listener Indicates the listener for the input device event. 409 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 410 * @since 9 411 */ 412 int32_t RegisterDevListener(std::string type, std::shared_ptr<IInputDeviceListener> listener); 413 414 /** 415 * @brief Stops listening for an input device event. 416 * @param type Indicates the type of the input device event, which is <b>change</b>. 417 * @param listener Indicates the listener for the input device event. 418 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 419 * @since 9 420 */ 421 int32_t UnregisterDevListener(std::string type, std::shared_ptr<IInputDeviceListener> listener = nullptr); 422 423 /** 424 * @brief Obtains the information about an input device. 425 * @param callback Indicates the callback used to receive the reported data. 426 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 427 * @since 9 428 */ 429 int32_t GetDeviceIds(std::function<void(std::vector<int32_t>&)> callback); 430 431 /** 432 * @brief Obtains the information about an input device. 433 * @param deviceId Indicates the ID of the input device whose information is to be obtained. 434 * @param callback Indicates the callback used to receive the reported data. 435 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 436 * @since 9 437 */ 438 int32_t GetDevice(int32_t deviceId, std::function<void(std::shared_ptr<InputDevice>)> callback); 439 440 /** 441 * @brief Checks whether the specified key codes of an input device are supported. 442 * @param deviceId Indicates the ID of the input device. 443 * @param keyCodes Indicates the key codes of the input device. 444 * @param callback Indicates the callback used to receive the reported data. 445 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 446 * @since 9 447 */ 448 int32_t SupportKeys(int32_t deviceId, std::vector<int32_t> keyCodes, 449 std::function<void(std::vector<bool>&)> callback); 450 451 /** 452 * @brief Sets the number of the mouse scrolling rows. 453 * @param rows Indicates the number of the mouse scrolling rows. 454 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 455 * @since 9 456 */ 457 int32_t SetMouseScrollRows(int32_t rows); 458 459 /** 460 * @brief Set pixelMap to override ohos mouse icon resouce. 461 * @param windowId Indicates the windowId of the window 462 * @param pixelMap Indicates the image resouce for this mouse icon. which realtype must be OHOS::Media::PixelMap* 463 * @param focusX Indicates focus x 464 * @param focusY Indicates focus y 465 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 466 * @since 9 467 */ 468 int32_t SetCustomCursor(int32_t windowId, void* pixelMap, int32_t focusX = 0, int32_t focusY = 0); 469 470 /** 471 * @brief Set pixelMap to override ohos mouse icon resouce. 472 * @param windowId Indicates the windowId of the window 473 * @param pixelMap Indicates the image resouce for this mouse icon. which realtype must be OHOS::Media::PixelMap* 474 * @return vint32_t 475 * @since 10 476 */ 477 int32_t SetMouseIcon(int32_t windowId, void* pixelMap); 478 479 /** 480 * @brief Set mouse icon hot spot. 481 * @param windowId Indicates the windowId of the window 482 * @param hotSpotX Indicates the hot spot x for this mouse icon. 483 * @param hotSpotY Indicates the hot spot y for this mouse icon. 484 * @return vint32_t 485 * @since 10 486 */ 487 int32_t SetMouseHotSpot(int32_t windowId, int32_t hotSpotX, int32_t hotSpotY); 488 489 /** 490 * @brief Gets the number of the mouse scrolling rows. 491 * @param rows Indicates the number of the mouse scrolling rows. 492 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 493 * @since 9 494 */ 495 int32_t GetMouseScrollRows(int32_t &rows); 496 497 /** 498 * @brief Sets pointer size. 499 * @param size Indicates pointer size. 500 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 501 * @since 9 502 */ 503 int32_t SetPointerSize(int32_t size); 504 505 /** 506 * @brief Gets pointer size. 507 * @param size Indicates pointer size. 508 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 509 * @since 9 510 */ 511 int32_t GetPointerSize(int32_t &size); 512 513 /** 514 * @brief Gets surface ID of the cursor. 515 * @param size Indicates surface ID of the cursor. 516 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 517 * @since 13 518 */ 519 int32_t GetCursorSurfaceId(uint64_t &surfaceId); 520 521 /** 522 * @brief Enable combine key 523 * @param enable Indicates whether the combine key is enabled. The value true indicates that the combine key 524 * is enabled, and the value false indicates the opposite. 525 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 526 * @since 11 527 */ 528 int32_t EnableCombineKey(bool enable); 529 530 /** 531 * @brief Sets mouse primary button. 532 * @param primaryButton Indicates the ID of the mouse primary button.The value 0 indicates that 533 * the primary button is left button.The value 1 indicates that the primary button is right button. 534 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 535 * @since 9 536 */ 537 int32_t SetMousePrimaryButton(int32_t primaryButton); 538 539 /** 540 * @brief Gets mouse primary button. 541 * @param primaryButton Indicates the ID of the mouse primary button.The value 0 indicates that 542 * the primary button is left button.The value 1 indicates that the primary button is right button. 543 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 544 * @since 9 545 */ 546 int32_t GetMousePrimaryButton(int32_t &primaryButton); 547 548 /** 549 * @brief Sets whether the mouse hover scroll is enabled in inactive window. 550 * @param state Indicates whether the mouse hover scroll is enabled in inactive window. The value true 551 * indicates that the mouse hover scroll is enabled, and the value false indicates the opposite. 552 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 553 * @since 9 554 */ 555 int32_t SetHoverScrollState(bool state); 556 557 /** 558 * @brief Gets a status whether the mouse hover scroll is enabled in inactive window. 559 * @param state Indicates whether the mouse hover scroll is enabled in inactive window. The value true 560 * indicates that the mouse hover scroll is enabled, and the value false indicates the opposite. 561 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 562 * @since 9 563 */ 564 int32_t GetHoverScrollState(bool &state); 565 566 /** 567 * @brief Sets whether the pointer icon is visible. 568 * @param visible Indicates whether the pointer icon is visible. The value <b>true</b> indicates that 569 * the pointer icon is visible, and the value <b>false</b> indicates the opposite. 570 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 571 * @since 9 572 */ 573 int32_t SetPointerVisible(bool visible, int32_t priority = 0); 574 575 /** 576 * @brief Checks whether the pointer icon is visible. 577 * @return Returns <b>true</b> if the pointer icon is visible; returns <b>false</b> otherwise. 578 * @since 9 579 */ 580 bool IsPointerVisible(); 581 582 /** 583 * @brief Sets the mouse pointer style. 584 * @param windowId Indicates the ID of the window for which the mouse pointer style is set. 585 * @param pointerStyle Indicates the ID of the mouse pointer style. 586 * @return Returns <b>0</b> if the operation is successful; returns an error code otherwise. 587 * @since 9 588 */ 589 int32_t SetPointerStyle(int32_t windowId, PointerStyle pointerStyle, bool isUiExtension = false); 590 591 /** 592 * @brief Obtains the mouse pointer style. 593 * @param windowId Indicates the ID of the window for which the mouse pointer style is obtained. 594 * @param pointerStyle Indicates the ID of the mouse pointer style. 595 * @return Returns <b>0</b> if the operation is successful; returns an error code otherwise. 596 * @since 9 597 */ 598 int32_t GetPointerStyle(int32_t windowId, PointerStyle &pointerStyle, bool isUiExtension = false); 599 600 /** 601 * @brief Sets pointer color. 602 * @param color Indicates pointer color. 603 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 604 * @since 9 605 */ 606 int32_t SetPointerColor(int32_t color); 607 608 /** 609 * @brief Gets pointer color. 610 * @param color Indicates pointer color. 611 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 612 * @since 9 613 */ 614 int32_t GetPointerColor(int32_t &color); 615 616 /** 617 * @brief Sets the mouse pointer speed, which ranges from 1 to 11. 618 * @param speed Indicates the mouse pointer speed to set. 619 * @return Returns <b>RET_OK</b> if success; returns <b>RET_ERR</b> otherwise. 620 * @since 9 621 */ 622 int32_t SetPointerSpeed(int32_t speed); 623 624 /** 625 * @brief Obtains the mouse pointer speed. 626 * @param speed Indicates the mouse pointer speed to get. 627 * @return Returns the mouse pointer speed if the operation is successful; returns <b>RET_ERR</b> otherwise. 628 * @since 9 629 */ 630 int32_t GetPointerSpeed(int32_t &speed); 631 632 /** 633 * @brief Queries the keyboard type. 634 * @param deviceId Indicates the keyboard device ID. 635 * @param callback Callback used to return the keyboard type. 636 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 637 * @since 9 638 */ 639 int32_t GetKeyboardType(int32_t deviceId, std::function<void(int32_t)> callback); 640 641 /** 642 * @brief Sets the observer for events indicating that the application does not respond. 643 * @param observer Indicates the observer for events indicating that the application does not respond. 644 * @return void 645 * @since 9 646 */ 647 void SetAnrObserver(std::shared_ptr<IAnrObserver> observer); 648 649 /** 650 * @brief Obtains the enablement status of the specified function key on the keyboard. 651 * @param funcKey Indicates the function key. Currently, the following function keys are supported: 652 * NUM_LOCK_FUNCTION_KEY 653 * CAPS_LOCK_FUNCTION_KEY 654 * SCROLL_LOCK_FUNCTION_KEY 655 * @return Returns <b>true</b> if the function key is enabled; 656 * returns <b>false</b> otherwise. 657 */ 658 int32_t GetFunctionKeyState(int32_t funcKey, bool &state); 659 660 /** 661 * @brief Sets the enablement status of the specified function key on the keyboard. 662 * @param funcKey Indicates the function key. Currently, the following function keys are supported: 663 * NUM_LOCK_FUNCTION_KEY 664 * CAPS_LOCK_FUNCTION_KEY 665 * SCROLL_LOCK_FUNCTION_KEY 666 * @param isEnable Indicates the enablement status to set. 667 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 668 */ 669 int32_t SetFunctionKeyState(int32_t funcKey, bool enable); 670 671 /** 672 * @brief Sets the absolute coordinate of mouse. 673 * @param x Specifies the x coordinate of the mouse to be set. 674 * @param y Specifies the y coordinate of the mouse to be set. 675 * @param displayId Specifies the id of the physical screen to be set. 676 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 677 * @since 9 678 */ 679 int32_t SetPointerLocation(int32_t x, int32_t y, int32_t displayId = -1); 680 681 /** 682 * @brief Query pointer location. 683 * @param displayId The displayId for the pointer location. 684 * @param displayX The displayX for the pointer location. 685 * @param displayY The displayY for the pointer location. 686 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 687 * @since 20 688 */ 689 int32_t GetPointerLocation(int32_t &displayId, double &displayX, double &displayY); 690 691 /** 692 * @brief 进入捕获模式 693 * @param windowId 窗口id. 694 * @return 进入捕获模式成功或失败. 695 * @since 9 696 */ 697 int32_t EnterCaptureMode(int32_t windowId); 698 699 /** 700 * @brief 退出捕获模式 701 * @param windowId 窗口id. 702 * @return 退出捕获模式成功或失败. 703 * @since 9 704 */ 705 int32_t LeaveCaptureMode(int32_t windowId); 706 707 int32_t GetWindowPid(int32_t windowId); 708 709 /** 710 * @brief pointer event添加辅助信息 711 * @param extraData 添加的信息. 712 * @return 设置拖拽数据成功或失败. 713 * @since 9 714 */ 715 int32_t AppendExtraData(const ExtraData& extraData); 716 717 /** 718 * @brief 使能或者禁用输入设备 719 * @param enable 输入设备的使能状态 720 * @return 返回0表示接口调用成功,否则,表示接口调用失败。 721 * @since 9 722 */ 723 int32_t EnableInputDevice(bool enable); 724 725 /** 726 * @brief 自定义设置快捷键拉起ability延迟时间 727 * @param businessId 应用在ability_launch_config.json中注册的唯一标识符. 728 * @param delay 延迟时间 0-4000ms 729 * @return 设置快捷键拉起ability延迟时间成功或失败 730 * @since 10 731 */ 732 int32_t SetKeyDownDuration(const std::string &businessId, int32_t delay); 733 734 /** 735 * @brief Sets the keyboard repeat delay, which ranges from 300 to 1000. 736 * @param delay Indicates the keyboard repeat delay to set. 737 * @return Returns <b>RET_OK</b> if success; returns <b>RET_ERR</b> otherwise. 738 * @since 10 739 */ 740 int32_t SetKeyboardRepeatDelay(int32_t delay); 741 742 /** 743 * @brief Sets the keyboard repeat rate, which ranges from 36 to 100. 744 * @param rate Indicates the keyboard repeat rate to set. 745 * @return Returns <b>RET_OK</b> if success; returns <b>RET_ERR</b> otherwise. 746 * @since 10 747 */ 748 int32_t SetKeyboardRepeatRate(int32_t rate); 749 750 /** 751 * @brief Gets the keyboard repeat delay. 752 * @param callback Callback used to return the keyboard repeat delay. 753 * @return Returns <b>RET_OK</b> if success; returns <b>RET_ERR</b> otherwise. 754 * @since 10 755 */ 756 int32_t GetKeyboardRepeatDelay(std::function<void(int32_t)> callback); 757 758 /** 759 * @brief Gets the keyboard repeat rate. 760 * @param callback Callback used to return the keyboard repeat rate. 761 * @return Returns <b>RET_OK</b> if success; returns <b>RET_ERR</b> otherwise. 762 * @since 10 763 */ 764 int32_t GetKeyboardRepeatRate(std::function<void(int32_t)> callback); 765 766 /** 767 * @brief Set the switch of touchpad scroll. 768 * @param switchFlag Indicates the touchpad scroll switch state. 769 * @return if success; returns a non-0 value otherwise. 770 * @since 9 771 */ 772 int32_t SetTouchpadScrollSwitch(bool switchFlag); 773 774 /** 775 * @brief Get the switch of touchpad scroll. 776 * @param switchFlag Indicates the touchpad scroll switch state. 777 * @return if success; returns a non-0 value otherwise. 778 * @since 9 779 */ 780 int32_t GetTouchpadScrollSwitch(bool &switchFlag); 781 782 /** 783 * @brief Set the switch of touchpad scroll direction. 784 * @param state Indicates the touchpad scroll switch direction state. 785 * @return if success; returns a non-0 value otherwise. 786 * @since 9 787 */ 788 int32_t SetTouchpadScrollDirection(bool state); 789 790 /** 791 * @brief Get the switch of touchpad scroll direction. 792 * @param state Indicates the touchpad scroll switch direction state. 793 * @return if success; returns a non-0 value otherwise. 794 * @since 9 795 */ 796 int32_t GetTouchpadScrollDirection(bool &state); 797 798 /** 799 * @brief Set the switch of touchpad tap. 800 * @param switchFlag Indicates the touchpad tap switch state. 801 * @return if success; returns a non-0 value otherwise. 802 * @since 9 803 */ 804 int32_t SetTouchpadTapSwitch(bool switchFlag); 805 806 /** 807 * @brief Get the switch of touchpad tap. 808 * @param switchFlag Indicates the touchpad tap switch state. 809 * @return if success; returns a non-0 value otherwise. 810 * @since 9 811 */ 812 int32_t GetTouchpadTapSwitch(bool &switchFlag); 813 814 /** 815 * @brief Set the touchpad poniter speed. 816 * @param speed Indicates the touchpad pointer speed. 817 * @return if success; returns a non-0 value otherwise. 818 * @since 9 819 */ 820 int32_t SetTouchpadPointerSpeed(int32_t speed); 821 822 /** 823 * @brief Get the touchpad poniter speed. 824 * @param speed Indicates the touchpad pointer speed. 825 * @return if success; returns a non-0 value otherwise. 826 * @since 9 827 */ 828 int32_t GetTouchpadPointerSpeed(int32_t &speed); 829 int32_t GetTouchpadCDG(TouchpadCDG &touchpadCDG); 830 831 /** 832 * @brief Set the switch of touchpad pinch. 833 * @param switchFlag Indicates the touchpad pinch switch state. 834 * @return if success; returns a non-0 value otherwise. 835 * @since 9 836 */ 837 int32_t SetTouchpadPinchSwitch(bool switchFlag); 838 839 /** 840 * @brief Get the switch of touchpad pinch. 841 * @param switchFlag Indicates the touchpad pinch switch state. 842 * @return if success; returns a non-0 value otherwise. 843 * @since 9 844 */ 845 int32_t GetTouchpadPinchSwitch(bool &switchFlag); 846 847 /** 848 * @brief Set the switch of touchpad swipe. 849 * @param switchFlag Indicates the touchpad swipe switch state. 850 * @return if success; returns a non-0 value otherwise. 851 * @since 9 852 */ 853 int32_t SetTouchpadSwipeSwitch(bool switchFlag); 854 855 /** 856 * @brief Get the switch of touchpad swipe. 857 * @param switchFlag Indicates the touchpad swipe switch state. 858 * @return if success; returns a non-0 value otherwise. 859 * @since 9 860 */ 861 int32_t GetTouchpadSwipeSwitch(bool &switchFlag); 862 863 /** 864 * @brief Set the touchpad right click type. 865 * @param type Indicates the touchpad right menu type. 866 * @return if success; returns a non-0 value otherwise. 867 * @since 9 868 */ 869 int32_t SetTouchpadRightClickType(int32_t type); 870 871 /** 872 * @brief Get the touchpad right click type. 873 * @param type Indicates the touchpad right menu type. 874 * @return if success; returns a non-0 value otherwise. 875 * @since 9 876 */ 877 int32_t GetTouchpadRightClickType(int32_t &type); 878 879 /** 880 * @brief Turn on or off hard cursor statistics. 881 * @param frameCount Counting the frame rate of continuous mouse movement. 882 * @param frameCount Statistics of mouse continuous movement synchronization frame rate. 883 * @return if success; returns a non-0 value otherwise. 884 * @since 12 885 */ 886 int32_t EnableHardwareCursorStats(bool enable); 887 /** 888 * @brief Get the mouse hard cursor information. 889 * @param frameCount Counting the frame rate of continuous mouse movement. 890 * @param frameCount Statistics of mouse continuous movement synchronization frame rate. 891 * @return if success; returns a non-0 value otherwise. 892 * @since 12 893 */ 894 int32_t GetHardwareCursorStats(uint32_t &frameCount, uint32_t &vsyncCount); 895 896 /** 897 * @brief Get the pointer snapshot. 898 * @param pixelMapPtr Indicates the image resource for this mouse icon. which realtype must be 899 * std::shared_ptr<OHOS::Media::PixelMap>*. 900 * @return if success; returns a non-0 value otherwise. 901 * @since 12 902 */ 903 int32_t GetPointerSnapshot(void *pixelMapPtr); 904 905 /** 906 * @brief Sets the number of the touchpad scrolling rows. 907 * @param rows Indicates the number of the touchpad scrolling rows. 908 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 909 * @since 12 910 */ 911 int32_t SetTouchpadScrollRows(int32_t rows); 912 913 /** 914 * @brief Gets the number of the touchpad scrolling rows. 915 * @param rows Indicates the number of the touchpad scrolling rows. 916 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 917 * @since 12 918 */ 919 int32_t GetTouchpadScrollRows(int32_t &rows); 920 921 /** 922 * @brief ClearWindowPointerStyle. 923 * @param pid Indicates pid. 924 * @param windowId Indicates windowId. 925 * @return void. 926 * @since 9 927 */ 928 void ClearWindowPointerStyle(int32_t pid, int32_t windowId); 929 930 /** 931 * @brief Sets whether shield key event interception, only support shield key event. 932 * @param shieldMode Indicates shield mode. 933 * @param isShield Indicates whether key event handler chain is shield. The value <b>true</b> indicates that 934 * the key event build chain is shield, all key events derictly dispatch to window, 935 * if the value <b>false</b> indicates not shield key event interception, handle by the chain. 936 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 937 * @since 9 938 */ 939 int32_t SetShieldStatus(int32_t shieldMode, bool isShield); 940 941 /** 942 * Gets shield event interception status corresponding to shield mode 943 * 944 * @param shieldMode - Accroding the shield mode select shield status. 945 * @param isShield - shield status of shield mode param. 946 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 947 * @since 9 948 */ 949 int32_t GetShieldStatus(int32_t shieldMode, bool &isShield); 950 951 int32_t MarkProcessed(int32_t eventId, int64_t actionTime, bool enable = true); 952 953 int32_t GetKeyState(std::vector<int32_t> &pressedKeys, std::map<int32_t, int32_t> &specialKeysState); 954 955 void Authorize(bool isAuthorize); 956 #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT 957 /** 958 * @brief Sets the enhance config of the security component. 959 * @param cfg Indicates the security component enhance config. 960 * @param cfgLen Indicates the security component enhance config len. 961 * @return void. 962 * @since 9 963 */ 964 void SetEnhanceConfig(uint8_t *cfg, uint32_t cfgLen); 965 #endif // OHOS_BUILD_ENABLE_SECURITY_COMPONENT 966 967 #ifdef OHOS_BUILD_ENABLE_ANCO 968 void SimulateInputEventExt(std::shared_ptr<KeyEvent> keyEvent); 969 void SimulateInputEventExt(std::shared_ptr<PointerEvent> pointerEvent); 970 #endif // OHOS_BUILD_ENABLE_ANCO 971 972 void AddServiceWatcher(std::shared_ptr<IInputServiceWatcher> watcher); 973 void RemoveServiceWatcher(std::shared_ptr<IInputServiceWatcher> watcher); 974 975 /** 976 * @brief Set the switch of touchpad rotate. 977 * @param rotateSwitch Indicates the touchpad rotate switch state. 978 * @return 0 if success; returns a non-0 value otherwise. 979 * @since 11 980 */ 981 int32_t SetTouchpadRotateSwitch(bool rotateSwitch); 982 983 /** 984 * @brief Get the switch of touchpad rotate. 985 * @param rotateSwitch Indicates the touchpad rotate switch state. 986 * @return 0 if success; returns a non-0 value otherwise. 987 * @since 11 988 */ 989 int32_t GetTouchpadRotateSwitch(bool &rotateSwitch); 990 991 /** 992 * @brief Set the switch of touchpad double tap and drag. 993 * @param switchFlag Indicates the touchpad double tap and drag switch state. 994 * true: user can use double tap and drag function. otherwise can't use 995 * @return if success; returns a non-0 value otherwise. 996 * @since 12 997 */ 998 int32_t SetTouchpadDoubleTapAndDragState(bool switchFlag); 999 1000 /** 1001 * @brief Get the switch of touchpad double tap and drag. 1002 * @param switchFlag Indicates the touchpad double tap and drag switch state. 1003 * true: user can use double tap and drag function. otherwise can't use 1004 * @return if success; returns a non-0 value otherwise. 1005 * @since 12 1006 */ 1007 int32_t GetTouchpadDoubleTapAndDragState(bool &switchFlag); 1008 1009 /** 1010 * @brief Set touch move event filters. 1011 * @param flag if set move event filters or not. 1012 * @return if success; returns a non-0 value otherwise. 1013 * @since 12 1014 */ 1015 int32_t SetMoveEventFilters(bool flag); 1016 1017 /** 1018 * @brief Get whether System has IrEmitter. 1019 * @param hasIrEmitter the para takes the value which Indicates the device has IrEmitter or not. 1020 * @return 0 if success; returns a non-0 value otherwise. 1021 * @since 12 1022 */ 1023 int32_t HasIrEmitter(bool &hasIrEmitter); 1024 1025 /** 1026 * @brief Get InfraredFrequency of the IrEmitter in device. 1027 * @param requencys take out the IrEmitter's Frequency. 1028 * @return 0 if success; returns a non-0 value otherwise. 1029 * @since 12 1030 */ 1031 int32_t GetInfraredFrequencies(std::vector<InfraredFrequency>& requencys); 1032 1033 /** 1034 * @brief user IrEmitter with parameter number and pattern. 1035 * @param number Frequency of IrEmitter works . 1036 * @param pattern Pattern of signal transmission in alternate on/off mode, in microseconds. 1037 * @return 0 if success; returns a non-0 value otherwise. 1038 * @since 12 1039 */ 1040 int32_t TransmitInfrared(int64_t number, std::vector<int64_t>& pattern); 1041 1042 #ifdef OHOS_BUILD_ENABLE_VKEYBOARD 1043 int32_t CreateVKeyboardDevice(sptr<IRemoteObject> &vkeyboardDevice); 1044 #endif // OHOS_BUILD_ENABLE_VKEYBOARD 1045 1046 int32_t SetCurrentUser(int32_t userId); 1047 1048 /** 1049 * @brief Set the switch of touchpad three finger tap. 1050 * @param switchFlag Indicates the touchpad three finger tap switch state. 1051 * true: user can use three finger function. otherwise can't use 1052 * @return if success; returns a non-0 value otherwise. 1053 * @since 12 1054 */ 1055 int32_t SetTouchpadThreeFingersTapSwitch(bool switchFlag); 1056 1057 /** 1058 * @brief Get the switch of touchpad three finger tap. 1059 * @param switchFlag Indicates the touchpad three finger tap switch state. 1060 * true: user can use three finger function. otherwise can't use 1061 * @return if success; returns a non-0 value otherwise. 1062 * @since 12 1063 */ 1064 int32_t GetTouchpadThreeFingersTapSwitch(bool &switchFlag); 1065 1066 int32_t GetWinSyncBatchSize(int32_t maxAreasCount, int32_t displayCount); 1067 1068 /** 1069 * @brief 添加虚拟输入设备 1070 * @param device 输入设备信息 1071 * @param deviceId 出参,所创建的虚拟输入设备对应的设备Id 1072 * @return 返回0表示接口调用成功,否则,表示接口调用失败。 1073 * @since 12 1074 */ 1075 int32_t AddVirtualInputDevice(std::shared_ptr<InputDevice> device, int32_t &deviceId); 1076 1077 /** 1078 * @brief 移除虚拟输入设备 1079 * @param deviceId 要移除的虚拟输入设备对应的设备Id 1080 * @return 返回0表示接口调用成功,否则,表示接口调用失败。 1081 * @since 12 1082 */ 1083 int32_t RemoveVirtualInputDevice(int32_t deviceId); 1084 1085 int32_t AncoAddConsumer(std::shared_ptr<IAncoConsumer> consumer); 1086 int32_t AncoRemoveConsumer(std::shared_ptr<IAncoConsumer> consumer); 1087 1088 int32_t SkipPointerLayer(bool isSkip); 1089 1090 int32_t RegisterWindowStateErrorCallback(std::function<void(int32_t, int32_t)> callback); 1091 /** 1092 * @brief Get Interval Since Last Input. 1093 * @param timeInterval the value which Indicates the time interval since last input. 1094 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 1095 * @since 13 1096 */ 1097 int32_t GetIntervalSinceLastInput(int64_t &timeInterval); 1098 1099 int32_t GetAllSystemHotkeys(std::vector<std::unique_ptr<KeyOption>> &keyOptions, int32_t &count); 1100 1101 /** 1102 * @brief Converted to a Capi-defined key action value. 1103 * @param keyAction The key action value of the return value of inner api. 1104 * @return Returns Capi-defined key action value if success; returns a negative number value otherwise. 1105 * @since 13 1106 */ 1107 int32_t ConvertToCapiKeyAction(int32_t keyAction); 1108 1109 /** 1110 * @brief 添加手势事件监视器。添加这样的监视器后,手势事件会被分发到到监视器。 1111 * @param consumer 表示手势事件监视器。手势事件产生后,将调用监视器对象的函数。 1112 * @param type 表示监视的手势类型。 1113 * @param fingers 表示监视的手势达成的手指数量。 1114 * @return 返回监视器ID,该ID唯一标识进程中的监视器。如果value的值大于等于0,表示添加成功。否则,添加监视器失败。 1115 * @since 13 1116 */ 1117 int32_t AddGestureMonitor(std::shared_ptr<IInputEventConsumer> consumer, 1118 TouchGestureType type, int32_t fingers = 0); 1119 1120 /** 1121 * @brief 删除一个手势监听器。 1122 * @param monitorId 表示手势事件监视器ID,即AddGestureMonitor的返回值。 1123 * @return 如果成功,则返回0;否则返回非0值。 1124 * @since 13 1125 */ 1126 int32_t RemoveGestureMonitor(int32_t monitorId); 1127 1128 /** 1129 * @brief Turn on/off the device input data update. 1130 * @param deviceID input device id. 1131 * @param enable Indicates the device input value. 1132 * @return if success; returns a non-0 value otherwise. 1133 * @since 14 1134 */ 1135 int32_t SetInputDeviceEnabled(int32_t deviceId, bool enable, std::function<void(int32_t)> callback); 1136 1137 /** 1138 * @brief shift AppPointerEvent from source window to target window 1139 * @param param - param for shift pointer event. 1140 * @param autoGenDown - send down event if true. 1141 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 1142 * @since 13 1143 */ 1144 int32_t ShiftAppPointerEvent(const ShiftWindowParam ¶m, bool autoGenDown = true); 1145 1146 /** 1147 * @brief Sets the custom cursor. You can set whether to adjust the cursor size based on the system settings. 1148 * @param windowId Indicates the windowId of the window 1149 * @param cursor Custom cursor, including the custom cursor resource and focus position. 1150 * @param options Custom cursor option 1151 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 1152 * @since 14 1153 */ 1154 int32_t SetCustomCursor(int32_t windowId, CustomCursor cursor, CursorOptions options); 1155 1156 /** 1157 * @brief Check whether the touch position is a knuckle event. 1158 * @param pointX X coordinate of the touch position 1159 * @param pointY Y coordinate of the touch position 1160 * @param isKnuckleType true is kunckle type 1161 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 1162 * @since 14 1163 */ 1164 int32_t CheckKnuckleEvent(float pointX, float pointY, bool &isKnuckleType); 1165 1166 void SetMultiWindowScreenId(uint64_t screenId, uint64_t displayNodeScreenId); 1167 1168 /** 1169 * @brief Enables or disables the knuckle switch. 1170 * @param knuckleSwitch Set to true to enable, false to disable. 1171 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 1172 * @since 18 1173 */ 1174 int32_t SetKnuckleSwitch(bool knuckleSwitch); 1175 1176 /** 1177 * @brief 拉起小艺识屏 1178 * @return 如果成功,则返回0;否则返回非0值。 1179 * @since 14 1180 */ 1181 int32_t LaunchAiScreenAbility(); 1182 1183 /** 1184 * @brief Get max Multi-Touch Points Num Supported. 1185 * @param pointNum the value which Indicates the max Multi-Touch point num supported. 1186 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 1187 * @since 18 1188 */ 1189 int32_t GetMaxMultiTouchPointNum(int32_t &pointNum); 1190 1191 /** 1192 * @brief Allows the service party to specify the input event of the specified touchscreen input device. 1193 * @param deviceName List of supported device names. 1194 * @param consumer Indicates the input event consumer. After an input event is generated, 1195 * the functions of the consumer object will be called. 1196 * @return Returns <b>0</b> if success; returns a non-0 value otherwise. 1197 * @since 20 1198 */ 1199 int32_t SetInputDeviceConsumer(const std::vector<std::string>& deviceName, 1200 std::shared_ptr<IInputEventConsumer> consumer); 1201 1202 /** 1203 * @brief Subscribes to the input active that meets a specific condition. When such an event occurs, 1204 * the <b>callback</b> specified is invoked to process the event. 1205 * A process can only support a maximum of one interface call. 1206 * @param inputEventConsumer Indicates the callback. 1207 * @param interval Indicate the interval time. 1208 * When the interval value is less than 0, the value is invalid. 1209 * When it is equal to 0, no filtering is performed. 1210 * The effective range of filtering values is greater than or equal to 500ms and less than or equal to 2000ms. 1211 * If the filtering value is greater than 0 and less than 500ms, the filtering interval is 500ms. 1212 * If the filtering value is greater than 2000ms, the filtering interval is 2000ms. 1213 * @return Returns the subscribe ID, which uniquely identifies a subscribe id in the process. 1214 * If the value is greater than or equal to <b>0</b> 1215 * the subscription is successful. Otherwise, the subscription fails. 1216 * @since 20 1217 */ 1218 int32_t SubscribeInputActive(std::shared_ptr<IInputEventConsumer> inputEventConsumer, int64_t interval); 1219 1220 /** 1221 * @brief Unsubscribes from input active. 1222 * @param subscribeId. Indicates the subscription ID, which is the return value of <b>SubscribeInputActive</b>. 1223 * @return void. 1224 * @since 20 1225 */ 1226 void UnsubscribeInputActive(int32_t subscribeId); 1227 1228 /** 1229 * @brief Enables or disables the mouse acceleration feature. 1230 * @note Only users with specific shell permissions are allowed to call this interface. 1231 * @param deviceId The identifier of the input device. 1232 * @param enable A boolean value; true to enable acceleration, false to disable it. 1233 * @return Returns 0 on success, or a non-zero error code on failure. 1234 * @since 20 1235 */ 1236 int32_t SetMouseAccelerateMotionSwitch(int32_t deviceId, bool enable); 1237 1238 /** 1239 * @brief Temporarily enables or disables screen capture and screen recording permissions. 1240 * @param permissionType The type of permission to switch (e.g., SCREENSHOT or SCREENRECORD). 1241 * @param enable Set to true to enable the permission, false to disable it. 1242 * @return Returns <b>0</b> if successful; returns a non-0 value otherwise. 1243 * @since 20 1244 */ 1245 int32_t SwitchScreenCapturePermission(uint32_t permissionType, bool enable); 1246 int32_t RequestInjection(int32_t &status, int32_t &reqId); 1247 int32_t QueryAuthorizedStatus(int32_t &status); 1248 void RequestInjectionCallback(int32_t reqId, int32_t status); 1249 void InsertRequestInjectionCallback(int32_t reqId, std::function<void(int32_t)> fun); 1250 1251 /** 1252 * @brief When the collaborative application is disconnected, clear the mouse hide flag. 1253 * @param eventId The collaborative application event id. 1254 * @return Returns <b>0</b> if successful; returns a non-0 value otherwise. 1255 * @since 20 1256 */ 1257 int32_t ClearMouseHideFlag(int32_t eventId); 1258 1259 /** 1260 * @brief Retrieves a specified number of pointer event records. 1261 * @param count The number of pointer event records to retrieve. 1262 * @param pointerList A reference to a vector that will store the retriebed pointer events. 1263 * @return Returns <b>0</b> if successful; returns a non-0 value otherwise. 1264 * @since 20 1265 */ 1266 int32_t QueryPointerRecord(int32_t count, std::vector<std::shared_ptr<PointerEvent>> &pointerList); 1267 private: 1268 InputManager() = default; 1269 DISALLOW_COPY_AND_MOVE(InputManager); 1270 static InputManager *instance_; 1271 std::mutex mutexMapCallBack_; 1272 std::map<int32_t, std::function<void(int32_t)>> mapCallBack_; 1273 }; 1274 } // namespace MMI 1275 } // namespace OHOS 1276 #endif // INPUT_MANAGER_H 1277