• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 /**
17  * @addtogroup input
18  * @{
19  *
20  * @brief Provides the C interface in the multi-modal input domain.
21  *
22  * @since 12
23  */
24 
25 /**
26  * @file oh_input_manager.h
27  *
28  * @brief Provides capabilities such as event injection and key status query.
29  * @kit InputKit
30  * @syscap SystemCapability.MultimodalInput.Input.Core
31  * @library liboh_input.so
32  * @since 12
33  */
34 
35 #ifndef OH_INPUT_MANAGER_H
36 #define OH_INPUT_MANAGER_H
37 
38 #include <stdint.h>
39 
40 #include "oh_axis_type.h"
41 #include "oh_key_code.h"
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 /**
48  * @brief Enumerated values of key event action.
49  *
50  * @since 12
51  */
52 typedef enum Input_KeyStateAction {
53     /** Default */
54     KEY_DEFAULT = -1,
55     /** Pressing of a key */
56     KEY_PRESSED = 0,
57     /** Release of a key */
58     KEY_RELEASED = 1,
59     /** Key switch enabled */
60     KEY_SWITCH_ON = 2,
61     /** Key switch disabled */
62     KEY_SWITCH_OFF = 3
63 } Input_KeyStateAction;
64 
65 /**
66  * @brief Enumerates key event types.
67  *
68  * @since 12
69  */
70 typedef enum Input_KeyEventAction {
71     /** Cancellation of a key action. */
72     KEY_ACTION_CANCEL = 0,
73     /** Pressing of a key. */
74     KEY_ACTION_DOWN = 1,
75     /** Release of a key. */
76     KEY_ACTION_UP = 2,
77 } Input_KeyEventAction;
78 
79 /**
80  * @brief Enumerated values of mouse event action.
81  *
82  * @since 12
83  */
84 typedef enum Input_MouseEventAction {
85     /** Cancel. */
86     MOUSE_ACTION_CANCEL = 0,
87     /** Moving of the mouse pointer. */
88     MOUSE_ACTION_MOVE = 1,
89     /** Pressing down of the mouse. */
90     MOUSE_ACTION_BUTTON_DOWN = 2,
91     /** Lifting of the mouse button. */
92     MOUSE_ACTION_BUTTON_UP = 3,
93     /** Beginning of the mouse axis event */
94     MOUSE_ACTION_AXIS_BEGIN = 4,
95     /** Updating of the mouse axis event */
96     MOUSE_ACTION_AXIS_UPDATE = 5,
97     /** End of the mouse axis event */
98     MOUSE_ACTION_AXIS_END = 6,
99 } Input_MouseEventAction;
100 
101 /**
102  * @brief Mouse axis types.
103  *
104  * @since 12
105  */
106 typedef enum InputEvent_MouseAxis {
107     /** Vertical scroll axis */
108     MOUSE_AXIS_SCROLL_VERTICAL = 0,
109     /** Horizontal scroll axis */
110     MOUSE_AXIS_SCROLL_HORIZONTAL = 1,
111 } InputEvent_MouseAxis;
112 
113 /**
114  * @brief Enumerated values of mouse event button.
115  *
116  * @since 12
117  */
118 typedef enum Input_MouseEventButton {
119     /** Invalid button */
120     MOUSE_BUTTON_NONE = -1,
121     /** Left button on the mouse. */
122     MOUSE_BUTTON_LEFT = 0,
123     /** Middle button on the mouse. */
124     MOUSE_BUTTON_MIDDLE = 1,
125     /** Right button on the mouse. */
126     MOUSE_BUTTON_RIGHT = 2,
127     /** Forward button on the mouse. */
128     MOUSE_BUTTON_FORWARD = 3,
129     /** Back button on the mouse. */
130     MOUSE_BUTTON_BACK = 4,
131 } Input_MouseEventButton;
132 
133 /**
134  * @brief Enumerated values of touch event action.
135  *
136  * @since 12
137  */
138 typedef enum Input_TouchEventAction {
139     /** Touch cancelled. */
140     TOUCH_ACTION_CANCEL = 0,
141     /** Touch pressed. */
142     TOUCH_ACTION_DOWN = 1,
143     /** Touch moved. */
144     TOUCH_ACTION_MOVE = 2,
145     /** Touch lifted. */
146     TOUCH_ACTION_UP = 3,
147 } Input_TouchEventAction;
148 
149 /**
150  * @brief Enumerates keyboard types.
151  *
152  * @since 13
153  */
154 typedef enum Input_KeyboardType {
155     /** Keyboard without keys */
156     KEYBOARD_TYPE_NONE = 0,
157     /** Keyboard with unknown keys */
158     KEYBOARD_TYPE_UNKNOWN = 1,
159     /** Full keyboard */
160     KEYBOARD_TYPE_ALPHABETIC = 2,
161     /** Digital keyboard */
162     KEYBOARD_TYPE_DIGITAL = 3,
163     /** Stylus */
164     KEYBOARD_TYPE_STYLUS = 4,
165     /** Remote control */
166     KEYBOARD_TYPE_REMOTE_CONTROL = 5,
167 } Input_KeyboardType;
168 
169 /**
170  * @brief Enumerates event source types.
171  *
172  * @since 12
173  */
174 typedef enum InputEvent_SourceType {
175     /**
176      * Indicates that the input source generates events similar to mouse cursor movement,
177      * button press and release, and wheel scrolling.
178      *
179      * @since 12
180      */
181     SOURCE_TYPE_MOUSE = 1,
182     /**
183      * Indicates that the input source generates a touchscreen multi-touch event.
184      *
185      * @since 12
186      */
187     SOURCE_TYPE_TOUCHSCREEN = 2,
188     /**
189      * Indicates that the input source generates a touchpad multi-touch event.
190      *
191      * @since 12
192      */
193     SOURCE_TYPE_TOUCHPAD = 3
194 } InputEvent_SourceType;
195 
196 /**
197  * @brief Defines key information, which identifies a key pressing behavior. For example, the Ctrl key information contains the key value and key type.
198  *
199  * @since 12
200  */
201 typedef struct Input_KeyState Input_KeyState;
202 
203 /**
204  * @brief The key event to be injected.
205  *
206  * @since 12
207  */
208 typedef struct Input_KeyEvent Input_KeyEvent;
209 
210 /**
211  * @brief The mouse event to be injected.
212  *
213  * @since 12
214  */
215 typedef struct Input_MouseEvent Input_MouseEvent;
216 
217 /**
218  * @brief The touch event to be injected.
219  *
220  * @since 12
221  */
222 typedef struct Input_TouchEvent Input_TouchEvent;
223 
224 /**
225  * @brief Enumerates axis events.
226  *
227  * @since 12
228  */
229 typedef struct Input_AxisEvent Input_AxisEvent;
230 
231 /**
232  * @brief Defines the hot key structure.
233  *
234  * @since 14
235  */
236 typedef struct Input_Hotkey Input_Hotkey;
237 
238 /**
239  * @brief Enumerates error codes.
240  *
241  * @since 12
242  */
243 typedef enum Input_Result {
244     /** @error Success return code on success*/
245     INPUT_SUCCESS = 0,
246     /** @error Permission verification failed */
247     INPUT_PERMISSION_DENIED = 201,
248     /** @error Non-system application */
249     INPUT_NOT_SYSTEM_APPLICATION = 202,
250     /** @error Parameter check failed */
251     INPUT_PARAMETER_ERROR = 401,
252     /** @error Device not support */
253     INPUT_DEVICE_NOT_SUPPORTED = 801,
254     /** @error Service error */
255     INPUT_SERVICE_EXCEPTION = 3800001,
256     /** @error Interceptor repeatedly created for an application */
257     INPUT_REPEAT_INTERCEPTOR = 4200001,
258     /**
259      * @error Already occupied by the system
260      * @since 14
261      */
262     INPUT_OCCUPIED_BY_SYSTEM = 4200002,
263     /**
264      * @error Already occupied by the other
265      * @since 14
266      */
267     INPUT_OCCUPIED_BY_OTHER = 4200003,
268 } Input_Result;
269 
270 /**
271  * @brief Callback used to return shortcut key events.
272  * @since 14
273  */
274 typedef void (*Input_HotkeyCallback)(Input_Hotkey* hotkey);
275 
276 /**
277  * @brief Represents information about the input device.
278  *
279  * @since 13
280  */
281 typedef struct Input_DeviceInfo Input_DeviceInfo;
282 
283 /**
284  * @brief Defines a lifecycle callback for keyEvent. If the callback is triggered, keyEvent will be destroyed.
285  *
286  * @param keyEvent Key event object.
287  * @since 12
288  */
289 typedef void (*Input_KeyEventCallback)(const Input_KeyEvent* keyEvent);
290 
291 /**
292  * @brief Defines a lifecycle callback for mouseEvent. If the callback is triggered, mouseEvent will be destroyed.
293  *
294  * @param mouseEvent Mouse event object.
295  * @since 12
296  */
297 typedef void (*Input_MouseEventCallback)(const Input_MouseEvent* mouseEvent);
298 
299 /**
300  * @brief Defines a lifecycle callback for touchEvent. If the callback is triggered, touchEvent will be destroyed.
301  *
302  * @param touchEvent Touch event object.
303  * @since 12
304  */
305 typedef void (*Input_TouchEventCallback)(const Input_TouchEvent* touchEvent);
306 
307 /**
308  * @brief Defines a lifecycle callback for axisEvent. If the callback is triggered, axisEvent will be destroyed.
309  *
310  * @param axisEvent Axis event object.
311  * @since 12
312  */
313 typedef void (*Input_AxisEventCallback)(const Input_AxisEvent* axisEvent);
314 
315 /**
316  * @brief Defines the callback for device addition events.
317  * @param deviceId Device ID.
318  * @since 13
319  */
320 typedef void (*Input_DeviceAddedCallback)(int32_t deviceId);
321 
322 /**
323  * @brief Defines the callback for device removal events.
324  * @param deviceId Device ID.
325  * @since 13
326  */
327 typedef void (*Input_DeviceRemovedCallback)(int32_t deviceId);
328 
329 /**
330  * @brief Defines the structure for the interceptor of event callbacks,
331  * including mouseCallback, touchCallback, and axisCallback.
332  * @since 12
333  */
334 typedef struct Input_InterceptorEventCallback {
335     /** Defines a lifecycle callback for **mouseEvent**. */
336     Input_MouseEventCallback mouseCallback;
337     /** Defines a lifecycle callback for **touchEvent**. */
338     Input_TouchEventCallback touchCallback;
339     /** Defines a lifecycle callback for **axisEvent**. */
340     Input_AxisEventCallback axisCallback;
341 } Input_InterceptorEventCallback;
342 
343 /**
344  * @brief Defines a listener for device insertion and removal events.
345  * @since 13
346  */
347 typedef struct Input_DeviceListener {
348     /** Callback for device addition events */
349     Input_DeviceAddedCallback deviceAddedCallback;
350     /** Callback for device removal events */
351     Input_DeviceRemovedCallback deviceRemovedCallback;
352 } Input_DeviceListener;
353 
354 /**
355  * @brief Defines event interceptor options.
356  * @since 12
357  */
358 typedef struct Input_InterceptorOptions Input_InterceptorOptions;
359 
360 /**
361  * @brief Queries the key state.
362  *
363  * @param keyState Key state.
364  * @return OH_Input_GetKeyState function result code.
365  *         {@link INPUT_SUCCESS} get KeyState success.\n
366  *         {@link INPUT_PARAMETER_ERROR} keyCode is invalid.\n
367  * @syscap SystemCapability.MultimodalInput.Input.Core
368  * @since 12
369  */
370 Input_Result OH_Input_GetKeyState(struct Input_KeyState* keyState);
371 
372 /**
373  * @brief Creates a key status enumeration object.
374  *
375  * @return Returns an {@Input_KeyState} pointer object if the operation is successful.
376  * Otherwise, a null pointer is returned. The possible cause is memory allocation failure.
377  * @syscap SystemCapability.MultimodalInput.Input.Core
378  * @since 12
379  */
380 struct Input_KeyState* OH_Input_CreateKeyState();
381 
382 /**
383  * @brief Destroys a key status enumeration object.
384  *
385  * @param keyState Key status enumeration object.
386  * @syscap SystemCapability.MultimodalInput.Input.Core
387  * @since 12
388  */
389 void OH_Input_DestroyKeyState(struct Input_KeyState** keyState);
390 
391 /**
392  * @brief Sets the key value of a key status enumeration object.
393  *
394  * @param keyState Key status enumeration object.
395  * @param keyCode Key value of the key status enumeration object.
396  * @syscap SystemCapability.MultimodalInput.Input.Core
397  * @since 12
398  */
399 void OH_Input_SetKeyCode(struct Input_KeyState* keyState, int32_t keyCode);
400 
401 /**
402  * @brief Obtains the key value of a key status enumeration object.
403  *
404  * @param keyState Key status enumeration object.
405  * @return Key value of the key status enumeration object.
406  * @syscap SystemCapability.MultimodalInput.Input.Core
407  * @since 12
408  */
409 int32_t OH_Input_GetKeyCode(const struct Input_KeyState* keyState);
410 
411 /**
412  * @brief Sets whether the key specific to a key status enumeration object is pressed.
413  *
414  * @param keyState Key status enumeration object.
415  * @param keyAction Whether the key is pressed.
416  * @syscap SystemCapability.MultimodalInput.Input.Core
417  * @since 12
418  */
419 void OH_Input_SetKeyPressed(struct Input_KeyState* keyState, int32_t keyAction);
420 
421 /**
422  * @brief Checks whether the key specific to a key status enumeration object is pressed.
423  *
424  * @param keyState Key status enumeration object.
425  * @return Key pressing status of the key status enumeration object.
426  * @syscap SystemCapability.MultimodalInput.Input.Core
427  * @since 12
428  */
429 int32_t OH_Input_GetKeyPressed(const struct Input_KeyState* keyState);
430 
431 /**
432  * @brief Sets the key switch of the key status enumeration object.
433  *
434  * @param keyState Key status enumeration object.
435  * @param keySwitch Key switch of the key status enumeration object.
436  * @syscap SystemCapability.MultimodalInput.Input.Core
437  * @since 12
438  */
439 void OH_Input_SetKeySwitch(struct Input_KeyState* keyState, int32_t keySwitch);
440 
441 /**
442  * @brief Obtains the key switch of the key status enumeration object.
443  *
444  * @param keyState Key status enumeration object.
445  * @return Key switch of the key status enumeration object.
446  * @syscap SystemCapability.MultimodalInput.Input.Core
447  * @since 12
448  */
449 int32_t OH_Input_GetKeySwitch(const struct Input_KeyState* keyState);
450 
451 /**
452  * @brief Inject system keys.
453  *
454  * @param keyEvent - the key event to be injected.
455  * @return OH_Input_InjectKeyEvent function result code.
456  *         {@link INPUT_SUCCESS} inject keyEvent success.\n
457  *         {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n
458  *         {@link INPUT_PARAMETER_ERROR} keyCode is less 0, can not process.\n
459  * @syscap SystemCapability.MultimodalInput.Input.Core
460  * @since 12
461  */
462 int32_t OH_Input_InjectKeyEvent(const struct Input_KeyEvent* keyEvent);
463 
464 /**
465  * @brief Creates a key event object.
466  *
467  * @return Returns an {@link Input_KeyEvent} pointer object if the operation is successful.
468  * Otherwise, a null pointer is returned. The possible cause is memory allocation failure.
469  * @syscap SystemCapability.MultimodalInput.Input.Core
470  * @since 12
471  */
472 struct Input_KeyEvent* OH_Input_CreateKeyEvent();
473 
474 /**
475  * @brief Destroys a key event object.
476  *
477  * @param keyEvent Key event object.
478  * @syscap SystemCapability.MultimodalInput.Input.Core
479  * @since 12
480  */
481 void OH_Input_DestroyKeyEvent(struct Input_KeyEvent** keyEvent);
482 
483 /**
484  * @brief Sets the key event type.
485  *
486  * @param keyEvent Key event object.
487  * @param action Key event type.
488  * @syscap SystemCapability.MultimodalInput.Input.Core
489  * @since 12
490  */
491 void OH_Input_SetKeyEventAction(struct Input_KeyEvent* keyEvent, int32_t action);
492 
493 /**
494  * @brief Obtains the key event type.
495  *
496  * @param keyEvent Key event object.
497  * @return Key event type.
498  * @syscap SystemCapability.MultimodalInput.Input.Core
499  * @since 12
500  */
501 int32_t OH_Input_GetKeyEventAction(const struct Input_KeyEvent* keyEvent);
502 
503 /**
504  * @brief Sets the key value for a key event.
505  *
506  * @param keyEvent Key event object.
507  * @param keyCode keyCode Key code.
508  * @syscap SystemCapability.MultimodalInput.Input.Core
509  * @since 12
510  */
511 void OH_Input_SetKeyEventKeyCode(struct Input_KeyEvent* keyEvent, int32_t keyCode);
512 
513 /**
514  * @brief Obtains the key value of a key event.
515  *
516  * @param keyEvent Key event object.
517  * @return Key code.
518  * @syscap SystemCapability.MultimodalInput.Input.Core
519  * @since 12
520  */
521 int32_t OH_Input_GetKeyEventKeyCode(const struct Input_KeyEvent* keyEvent);
522 
523 /**
524  * @brief Sets the time when a key event occurs.
525  *
526  * @param keyEvent Key event object.
527  * @param actionTime Time when the key event occurs.
528  * @syscap SystemCapability.MultimodalInput.Input.Core
529  * @since 12
530  */
531 void OH_Input_SetKeyEventActionTime(struct Input_KeyEvent* keyEvent, int64_t actionTime);
532 
533 /**
534  * @brief Obtains the time when a key event occurs.
535  *
536  * @param keyEvent Key event object.
537  * @return Returns the time when the key event occurs.
538  * @syscap SystemCapability.MultimodalInput.Input.Core
539  * @since 12
540  */
541 int64_t OH_Input_GetKeyEventActionTime(const struct Input_KeyEvent* keyEvent);
542 
543 /**
544  * @brief Inject mouse event.
545  *
546  * @param mouseEvent - the mouse event to be injected.
547  * @return OH_Input_InjectMouseEvent function result code.
548  *         {@link INPUT_SUCCESS} inject mouseEvent success.\n
549  *         {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n
550  *         {@link INPUT_PARAMETER_ERROR} Parameter check failed.\n
551  * @syscap SystemCapability.MultimodalInput.Input.Core
552  * @since 12
553  */
554 int32_t OH_Input_InjectMouseEvent(const struct Input_MouseEvent* mouseEvent);
555 
556 /**
557  * @brief Creates a mouse event object.
558  *
559  * @return Returns an {@link Input_MouseEvent} pointer object if the operation is successful.
560  * Otherwise, a null pointer is returned. The possible cause is memory allocation failure.
561  * @syscap SystemCapability.MultimodalInput.Input.Core
562  * @since 12
563  */
564 struct Input_MouseEvent* OH_Input_CreateMouseEvent();
565 
566 /**
567  * @brief Destroys a mouse event object.
568  *
569  * @param mouseEvent Mouse event object.
570  * @syscap SystemCapability.MultimodalInput.Input.Core
571  * @since 12
572  */
573 void OH_Input_DestroyMouseEvent(struct Input_MouseEvent** mouseEvent);
574 
575 /**
576  * @brief Sets the action for a mouse event.
577  *
578  * @param mouseEvent Mouse event object.
579  * @param action Mouse action.
580  * @syscap SystemCapability.MultimodalInput.Input.Core
581  * @since 12
582  */
583 void OH_Input_SetMouseEventAction(struct Input_MouseEvent* mouseEvent, int32_t action);
584 
585 /**
586  * @brief Obtains the action of a mouse event.
587  *
588  * @param mouseEvent Mouse event object.
589  * @return Mouse action.
590  * @syscap SystemCapability.MultimodalInput.Input.Core
591  * @since 12
592  */
593 int32_t OH_Input_GetMouseEventAction(const struct Input_MouseEvent* mouseEvent);
594 
595 /**
596  * @brief Sets the X coordinate for a mouse event.
597  *
598  * @param mouseEvent Mouse event object.
599  * @param displayX  X coordinate on the display.
600  * @syscap SystemCapability.MultimodalInput.Input.Core
601  * @since 12
602  */
603 void OH_Input_SetMouseEventDisplayX(struct Input_MouseEvent* mouseEvent, int32_t displayX);
604 
605 /**
606  * @brief Obtains the X coordinate of a mouse event.
607  *
608  * @param mouseEvent Mouse event object.
609  * @return X coordinate on the display.
610  * @syscap SystemCapability.MultimodalInput.Input.Core
611  * @since 12
612  */
613 int32_t OH_Input_GetMouseEventDisplayX(const struct Input_MouseEvent* mouseEvent);
614 
615 /**
616  * @brief Sets the Y coordinate for a mouse event.
617  *
618  * @param mouseEvent Mouse event object.
619  * @param displayY Y coordinate on the display.
620  * @syscap SystemCapability.MultimodalInput.Input.Core
621  * @since 12
622  */
623 void OH_Input_SetMouseEventDisplayY(struct Input_MouseEvent* mouseEvent, int32_t displayY);
624 
625 /**
626  * @brief Obtains the Y coordinate of a mouse event.
627  *
628  * @param mouseEvent Mouse event object.
629  * @return Y coordinate on the display.
630  * @syscap SystemCapability.MultimodalInput.Input.Core
631  * @since 12
632  */
633 int32_t OH_Input_GetMouseEventDisplayY(const struct Input_MouseEvent* mouseEvent);
634 
635 /**
636  * @brief Sets the button for a mouse event.
637  *
638  * @param mouseEvent Mouse event object.
639  * @param button Mouse button.
640  * @syscap SystemCapability.MultimodalInput.Input.Core
641  * @since 12
642  */
643 void OH_Input_SetMouseEventButton(struct Input_MouseEvent* mouseEvent, int32_t button);
644 
645 /**
646  * @brief Obtains the button of a mouse event.
647  *
648  * @param mouseEvent Mouse event object.
649  * @return Mouse button.
650  * @syscap SystemCapability.MultimodalInput.Input.Core
651  * @since 12
652  */
653 int32_t OH_Input_GetMouseEventButton(const struct Input_MouseEvent* mouseEvent);
654 
655 /**
656  * @brief Sets the axis type for mouse event.
657  *
658  * @param mouseEvent Mouse event object.
659  * @param axisType Axis type, for example, X axis or Y axis.
660  * @syscap SystemCapability.MultimodalInput.Input.Core
661  * @since 12
662  */
663 void OH_Input_SetMouseEventAxisType(struct Input_MouseEvent* mouseEvent, int32_t axisType);
664 
665 /**
666  * @brief Obtains the axis type of a mouse event.
667  *
668  * @param mouseEvent Mouse event object.
669  * @return Axis type.
670  * @syscap SystemCapability.MultimodalInput.Input.Core
671  * @since 12
672  */
673 int32_t OH_Input_GetMouseEventAxisType(const struct Input_MouseEvent* mouseEvent);
674 
675 /**
676  * @brief Sets the axis value for a mouse axis event.
677  *
678  * @param mouseEvent Mouse event object.
679  * @param axisValue Axis value. A positive value means scrolling forward,
680  * and a negative number means scrolling backward.
681  * @syscap SystemCapability.MultimodalInput.Input.Core
682  * @since 12
683  */
684 void OH_Input_SetMouseEventAxisValue(struct Input_MouseEvent* mouseEvent, float axisValue);
685 
686 /**
687  * @brief Obtains the axis value of a mouse event.
688  *
689  * @param mouseEvent Mouse event object.
690  * @return Axis value.
691  * @syscap SystemCapability.MultimodalInput.Input.Core
692  * @since 12
693  */
694 float OH_Input_GetMouseEventAxisValue(const struct Input_MouseEvent* mouseEvent);
695 
696 /**
697  * @brief Sets the time when a mouse event occurs.
698  *
699  * @param mouseEvent Mouse event object.
700  * @param actionTime Time when the mouse event occurs.
701  * @syscap SystemCapability.MultimodalInput.Input.Core
702  * @since 12
703  */
704 void OH_Input_SetMouseEventActionTime(struct Input_MouseEvent* mouseEvent, int64_t actionTime);
705 
706 /**
707  * @brief Obtains the time when a mouse event occurs.
708  *
709  * @param mouseEvent Mouse event object.
710  * @return Returns the time when the mouse event occurs.
711  * @syscap SystemCapability.MultimodalInput.Input.Core
712  * @since 12
713  */
714 int64_t OH_Input_GetMouseEventActionTime(const struct Input_MouseEvent* mouseEvent);
715 
716 /**
717  * @brief Inject touch event.
718  *
719  * @param touchEvent - the touch event to be injected.
720  * @return OH_Input_InjectTouchEvent function result code.
721  *         {@link INPUT_SUCCESS} inject touchEvent success.\n
722  *         {@link INPUT_PARAMETER_ERROR} Parameter check failed.\n
723  * @syscap SystemCapability.MultimodalInput.Input.Core
724  * @since 12
725  */
726 int32_t OH_Input_InjectTouchEvent(const struct Input_TouchEvent* touchEvent);
727 
728 /**
729  * @brief Creates a touch event object.
730  *
731  * @return Returns an {@link Input_TouchEvent} pointer object if the operation is successful.
732  * Otherwise, a null pointer is returned. The possible cause is memory allocation failure.
733  * @syscap SystemCapability.MultimodalInput.Input.Core
734  * @since 12
735  */
736 struct Input_TouchEvent* OH_Input_CreateTouchEvent();
737 
738 /**
739  * @brief Destroys a touch event object.
740  *
741  * @param touchEvent Touch event object.
742  * @syscap SystemCapability.MultimodalInput.Input.Core
743  * @since 12
744  */
745 void OH_Input_DestroyTouchEvent(struct Input_TouchEvent** touchEvent);
746 
747 /**
748  * @brief Sets the action for a touch event.
749  *
750  * @param touchEvent Touch event object.
751  * @param action Touch action.
752  * @syscap SystemCapability.MultimodalInput.Input.Core
753  * @since 12
754  */
755 void OH_Input_SetTouchEventAction(struct Input_TouchEvent* touchEvent, int32_t action);
756 
757 /**
758  * @brief Obtains the action of a touch event.
759  *
760  * @param touchEvent Touch event object.
761  * @return Touch action.
762  * @syscap SystemCapability.MultimodalInput.Input.Core
763  * @since 12
764  */
765 int32_t OH_Input_GetTouchEventAction(const struct Input_TouchEvent* touchEvent);
766 
767 /**
768  * @brief Sets the finger ID for the touch event.
769  *
770  * @param touchEvent Touch event object.
771  * @param id Finger ID.
772  * @syscap SystemCapability.MultimodalInput.Input.Core
773  * @since 12
774  */
775 void OH_Input_SetTouchEventFingerId(struct Input_TouchEvent* touchEvent, int32_t id);
776 
777 /**
778  * @brief Obtains the finger ID of a touch event.
779  *
780  * @param touchEvent Touch event object.
781  * @return Finger ID.
782  * @syscap SystemCapability.MultimodalInput.Input.Core
783  * @since 12
784  */
785 int32_t OH_Input_GetTouchEventFingerId(const struct Input_TouchEvent* touchEvent);
786 
787 /**
788  * @brief Sets the X coordinate for a touch event.
789  *
790  * @param touchEvent Touch event object.
791  * @param displayX X coordinate.
792  * @syscap SystemCapability.MultimodalInput.Input.Core
793  * @since 12
794  */
795 void OH_Input_SetTouchEventDisplayX(struct Input_TouchEvent* touchEvent, int32_t displayX);
796 
797 /**
798  * @brief Obtains the X coordinate of a touch event.
799  *
800  * @param touchEvent Touch event object.
801  * @return X coordinate.
802  * @syscap SystemCapability.MultimodalInput.Input.Core
803  * @since 12
804  */
805 int32_t OH_Input_GetTouchEventDisplayX(const struct Input_TouchEvent* touchEvent);
806 
807 /**
808  * @brief Sets the Y coordinate for a touch event.
809  *
810  * @param touchEvent Touch event object.
811  * @param displayY Y coordinate.
812  * @syscap SystemCapability.MultimodalInput.Input.Core
813  * @since 12
814  */
815 void OH_Input_SetTouchEventDisplayY(struct Input_TouchEvent* touchEvent, int32_t displayY);
816 
817 /**
818  * @brief Obtains the Y coordinate of a touch event.
819  *
820  * @param touchEvent Touch event object.
821  * @return Y coordinate.
822  * @syscap SystemCapability.MultimodalInput.Input.Core
823  * @since 12
824  */
825 int32_t OH_Input_GetTouchEventDisplayY(const struct Input_TouchEvent* touchEvent);
826 
827 /**
828  * @brief Sets the time when a touch event occurs.
829  *
830  * @param touchEvent Touch event object.
831  * @param actionTime Time when the touch event occurs.
832  * @syscap SystemCapability.MultimodalInput.Input.Core
833  * @since 12
834  */
835 void OH_Input_SetTouchEventActionTime(struct Input_TouchEvent* touchEvent, int64_t actionTime);
836 
837 /**
838  * @brief Obtains the time when a touch event occurs.
839  *
840  * @param touchEvent touch event object.
841  * @return Returns the time when the touch event occurs.
842  * @syscap SystemCapability.MultimodalInput.Input.Core
843  * @since 12
844  */
845 int64_t OH_Input_GetTouchEventActionTime(const struct Input_TouchEvent* touchEvent);
846 
847 /**
848  * @brief Cancels event injection and revokes authorization.
849  *
850  * @syscap SystemCapability.MultimodalInput.Input.Core
851  * @since 12
852  */
853 void OH_Input_CancelInjection();
854 
855 /**
856  * @brief Creates an axis event object.
857  *
858  * @return If the operation is successful, a {@Link Input_AxisEvent} object is returned.
859  * If the operation fails, null is returned.
860  * @syscap SystemCapability.MultimodalInput.Input.Core
861  * @since 12
862  */
863 Input_AxisEvent* OH_Input_CreateAxisEvent(void);
864 
865 /**
866  * @brief Destroys an axis event object.
867  *
868  * @param axisEvent Pointer to the axis event object.
869  * @return OH_Input_DestroyAxisEvent function result code.
870  *         {@link INPUT_SUCCESS} Destroys axisEvent success.\n
871  *         {@link INPUT_PARAMETER_ERROR}The axisEvent is NULL or the *axisEvent is NULL.\n
872  * @syscap SystemCapability.MultimodalInput.Input.Core
873  * @since 12
874  */
875 Input_Result OH_Input_DestroyAxisEvent(Input_AxisEvent** axisEvent);
876 
877 /**
878  * @brief Sets the axis event action.
879  *
880  * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}.
881  * @param action Axis event action. The values are defined in {@link InputEvent_AxisAction}.
882  * @return OH_Input_SetAxisEventAction function result code.
883  *         {@link INPUT_SUCCESS} Sets the axis event action success.\n
884  *         {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n
885  * @syscap SystemCapability.MultimodalInput.Input.Core
886  * @since 12
887  */
888 Input_Result OH_Input_SetAxisEventAction(Input_AxisEvent* axisEvent, InputEvent_AxisAction action);
889 
890 /**
891  * @brief Obtains the axis event action.
892  *
893  * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}.
894  * @param action Axis event action. The values are defined in {@link InputEvent_AxisAction}.
895  * @return OH_Input_GetAxisEventAction function result code.
896  *         {@link INPUT_SUCCESS} Obtains the axis event action success.\n
897  *         {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the action is NULL.\n
898  * @syscap SystemCapability.MultimodalInput.Input.Core
899  * @since 12
900  */
901 Input_Result OH_Input_GetAxisEventAction(const Input_AxisEvent* axisEvent, InputEvent_AxisAction *action);
902 
903 /**
904  * @brief Sets the X coordinate of an axis event.
905  *
906  * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}.
907  * @param displayX X coordinate of the axis event.
908  * @return OH_Input_SetAxisEventDisplayX function result code.
909  *         {@link INPUT_SUCCESS} Sets the X coordinate of the axis event success.\n
910  *         {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n
911  * @syscap SystemCapability.MultimodalInput.Input.Core
912  * @since 12
913  */
914 Input_Result OH_Input_SetAxisEventDisplayX(Input_AxisEvent* axisEvent, float displayX);
915 
916 /**
917  * @brief Obtains the X coordinate of an axis event.
918  *
919  * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}.
920  * @param displayX X coordinate of the axis event.
921  * @return OH_Input_GetAxisEventDisplayX function result code.
922  *         {@link INPUT_SUCCESS} Obtains the X coordinate of the axis event success.\n
923  *         {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the displayX is NULL.\n
924  * @syscap SystemCapability.MultimodalInput.Input.Core
925  * @since 12
926  */
927 Input_Result OH_Input_GetAxisEventDisplayX(const Input_AxisEvent* axisEvent, float* displayX);
928 
929 /**
930  * @brief Sets the Y coordinate of an axis event.
931  *
932  * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}.
933  * @param displayY Y coordinate of the axis event.
934  * @return OH_Input_SetAxisEventDisplayY function result code.
935  *         {@link INPUT_SUCCESS} Sets the Y coordinate of the axis event success.\n
936  *         {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n
937  * @syscap SystemCapability.MultimodalInput.Input.Core
938  * @since 12
939  */
940 Input_Result OH_Input_SetAxisEventDisplayY(Input_AxisEvent* axisEvent, float displayY);
941 
942 /**
943  * @brief Obtains the Y coordinate of an axis event.
944  *
945  * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}.
946  * @param displayY Y coordinate of the axis event.
947  * @return OH_Input_GetAxisEventDisplayY function result code.
948  *         {@link INPUT_SUCCESS} Obtains the Y coordinate of the axis event success.\n
949  *         {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the displayY is NULL.\n
950  * @syscap SystemCapability.MultimodalInput.Input.Core
951  * @since 12
952  */
953 Input_Result OH_Input_GetAxisEventDisplayY(const Input_AxisEvent* axisEvent, float* displayY);
954 
955 /**
956  * @brief Sets the axis value of the axis type specified by the axis event.
957  *
958  * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}.
959  * @param axisType Axis type. The values are defined in {@link InputEvent_AxisType}.
960  * @param axisValue Axis value.
961  * @return OH_Input_SetAxisEventAxisValue function result code.
962  *         {@link INPUT_SUCCESS} Sets the axis value of the axis event success.\n
963  *         {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n
964  * @syscap SystemCapability.MultimodalInput.Input.Core
965  * @since 12
966  */
967 Input_Result OH_Input_SetAxisEventAxisValue(Input_AxisEvent* axisEvent,
968                                             InputEvent_AxisType axisType, double axisValue);
969 
970 /**
971  * @brief Obtains the axis value for the specified axis type of the axis event.
972  *
973  * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}.
974  * @param axisType Axis type. The values are defined in {@link InputEvent_AxisType}.
975  * @param axisValue Axis value.
976  * @return OH_Input_GetAxisEventAxisValue function result code.
977  *         {@link INPUT_SUCCESS} Obtains the axis value of the axis event success.\n
978  *         {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the axisValue is NULL,
979  *         or the axisType not found in the axisEvent.\n
980  * @syscap SystemCapability.MultimodalInput.Input.Core
981  * @since 12
982  */
983 Input_Result OH_Input_GetAxisEventAxisValue(const Input_AxisEvent* axisEvent,
984                                             InputEvent_AxisType axisType, double* axisValue);
985 
986 /**
987  * @brief Sets the time when an axis event occurs.
988  *
989  * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}.
990  * @param actionTime Time when an axis event occurs.
991  * @return OH_Input_SetAxisEventActionTime function result code.
992  *         {@link INPUT_SUCCESS} Sets the time when an axis event occurs success.\n
993  *         {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n
994  * @syscap SystemCapability.MultimodalInput.Input.Core
995  * @since 12
996  */
997 Input_Result OH_Input_SetAxisEventActionTime(Input_AxisEvent* axisEvent, int64_t actionTime);
998 
999 /**
1000  * @brief Obtains the time when an axis event occurs.
1001  *
1002  * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}.
1003  * @param actionTime Time when an axis event occurs.
1004  * @return OH_Input_GetAxisEventActionTime function result code.
1005  *         {@link INPUT_SUCCESS} Obtains the time when an axis event occurs success.\n
1006  *         {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the actionTime is NULL.\n
1007  * @syscap SystemCapability.MultimodalInput.Input.Core
1008  * @since 12
1009  */
1010 Input_Result OH_Input_GetAxisEventActionTime(const Input_AxisEvent* axisEvent, int64_t* actionTime);
1011 
1012 /**
1013  * @brief Sets the axis event type.
1014  *
1015  * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}.
1016  * @param axisEventType Axis event type. The values are defined in {@link InputEvent_AxisEventType}.
1017  * @return OH_Input_SetAxisEventType function result code.
1018  *         {@link INPUT_SUCCESS} Sets the axis event type success.\n
1019  *         {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n
1020  * @syscap SystemCapability.MultimodalInput.Input.Core
1021  * @since 12
1022  */
1023 Input_Result OH_Input_SetAxisEventType(Input_AxisEvent* axisEvent, InputEvent_AxisEventType axisEventType);
1024 
1025 /**
1026  * @brief Obtains the axis event type.
1027  *
1028  * @param axisEvent Axis event object.
1029  * @param axisEventType Axis event type. The values are defined in {@link InputEvent_AxisEventType}.
1030  * @return OH_Input_GetAxisEventType function result code.
1031  *         {@link INPUT_SUCCESS} Obtains the axis event type success.\n
1032  *         {@Link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the axisEventType is NULL.\n
1033  * @syscap SystemCapability.MultimodalInput.Input.Core
1034  * @since 12
1035  */
1036 Input_Result OH_Input_GetAxisEventType(const Input_AxisEvent* axisEvent, InputEvent_AxisEventType* axisEventType);
1037 
1038 /**
1039  * @brief Sets the axis event source type.
1040  *
1041  * @param axisEvent Axis event object.
1042  * @param sourceType Axis event source type. The values are defined in {@link InputEvent_SourceType}.
1043  * @return OH_Input_SetAxisEventSourceType function result code.
1044  *         {@link INPUT_SUCCESS} Sets the axis event source type success.\n
1045  *         {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n
1046  * @syscap SystemCapability.MultimodalInput.Input.Core
1047  * @since 12
1048  */
1049 Input_Result OH_Input_SetAxisEventSourceType(Input_AxisEvent* axisEvent, InputEvent_SourceType sourceType);
1050 
1051 /**
1052  * @brief Obtains the axis event source type.
1053  *
1054  * @param axisEvent Axis event object.
1055  * @param sourceType Axis event source type. The values are defined in {@link InputEvent_SourceType}.
1056  * @return OH_Input_GetAxisEventSourceType function result code.
1057  *         {@link INPUT_SUCCESS} Obtains the axis event source type success.\n
1058  *         {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the sourceType is NULL.\n
1059  * @syscap SystemCapability.MultimodalInput.Input.Core
1060  * @since 12
1061  */
1062 Input_Result OH_Input_GetAxisEventSourceType(const Input_AxisEvent* axisEvent, InputEvent_SourceType* sourceType);
1063 
1064 /**
1065  * @brief Adds a listener of key events.
1066  *
1067  * @permission ohos.permission.INPUT_MONITORING
1068  * @param callback - Callback used to receive key events.
1069  * @return OH_Input_AddKeyEventMonitor function result code.
1070  *         {@link INPUT_SUCCESS} Adds a listener of key events success.\n
1071  *         {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n
1072  *         {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n
1073  *         {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n
1074  * @syscap SystemCapability.MultimodalInput.Input.Core
1075  * @since 12
1076  */
1077 Input_Result OH_Input_AddKeyEventMonitor(Input_KeyEventCallback callback);
1078 
1079 /**
1080  * @brief Adds a listener for mouse events, including mouse click and movement events,
1081  * but not scroll wheel events. Scroll wheel events are axis events.
1082  *
1083  * @permission ohos.permission.INPUT_MONITORING
1084  * @param callback - Callback used to receive mouse events.
1085  * @return OH_Input_AddMouseEventMonitor function result code.
1086  *         {@link INPUT_SUCCESS} Adds a listener of mouse events success.\n
1087  *         {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n
1088  *         {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n
1089  *         {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n
1090  * @syscap SystemCapability.MultimodalInput.Input.Core
1091  * @since 12
1092  */
1093 Input_Result OH_Input_AddMouseEventMonitor(Input_MouseEventCallback callback);
1094 
1095 /**
1096  * @brief Add a listener for touch events.
1097  *
1098  * @permission ohos.permission.INPUT_MONITORING
1099  * @param callback - Callback used to receive touch events.
1100  * @return OH_Input_AddTouchEventMonitor function result code.
1101  *         {@link INPUT_SUCCESS} Adds a listener of touch events success.\n
1102  *         {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n
1103  *         {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n
1104  *         {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n
1105  * @syscap SystemCapability.MultimodalInput.Input.Core
1106  * @since 12
1107  */
1108 Input_Result OH_Input_AddTouchEventMonitor(Input_TouchEventCallback callback);
1109 
1110 /**
1111  * @brief Adds a listener for all types of axis events.
1112  * The axis event types are defined in {@Link InputEvent_AxisEventType}.
1113  *
1114  * @permission ohos.permission.INPUT_MONITORING
1115  * @param callback - Callback used to receive axis events.
1116  * @return OH_Input_AddAxisEventMonitorForAll function result code.
1117  *         {@link INPUT_SUCCESS} Adds a listener for all types of axis events success.\n
1118  *         {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n
1119  *         {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n
1120  *         {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n
1121  * @syscap SystemCapability.MultimodalInput.Input.Core
1122  * @since 12
1123  */
1124 Input_Result OH_Input_AddAxisEventMonitorForAll(Input_AxisEventCallback callback);
1125 
1126 /**
1127  * @brief Adds a listener for the specified type of axis events.
1128  *
1129  * @permission ohos.permission.INPUT_MONITORING
1130  * @param axisEventType - Axis event type. The values are defined in {@Link InputEvent_AxisEventType}.
1131  * @param callback - Callback used to receive the specified type of axis events.
1132  * @return OH_Input_AddAxisEventMonitor function result code.
1133  *         {@link INPUT_SUCCESS} Adds a listener for the specified types of axis events success.\n
1134  *         {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n
1135  *         {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n
1136  *         {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n
1137  * @syscap SystemCapability.MultimodalInput.Input.Core
1138  * @since 12
1139  */
1140 Input_Result OH_Input_AddAxisEventMonitor(InputEvent_AxisEventType axisEventType, Input_AxisEventCallback callback);
1141 
1142 /**
1143  * @brief Removes a key event listener.
1144  *
1145  * @permission ohos.permission.INPUT_MONITORING
1146  * @param callback - Callback for the key event listener.
1147  * @return OH_Input_RemoveKeyEventMonitor function result code.
1148  *         {@link INPUT_SUCCESS} Removes a key event listener success.\n
1149  *         {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n
1150  *         {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n
1151  *         {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n
1152  * @syscap SystemCapability.MultimodalInput.Input.Core
1153  * @since 12
1154  */
1155 Input_Result OH_Input_RemoveKeyEventMonitor(Input_KeyEventCallback callback);
1156 
1157 /**
1158  * @brief Removes a mouse event listener.
1159  *
1160  * @permission ohos.permission.INPUT_MONITORING
1161  * @param callback - Callback for the mouse event listener.
1162  * @return OH_Input_RemoveMouseEventMonitor function result code.
1163  *         {@link INPUT_SUCCESS} Removes a mouse event listener success.\n
1164  *         {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n
1165  *         {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n
1166  *         {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n
1167  * @syscap SystemCapability.MultimodalInput.Input.Core
1168  * @since 12
1169  */
1170 Input_Result OH_Input_RemoveMouseEventMonitor(Input_MouseEventCallback callback);
1171 
1172 /**
1173  * @brief Removes a touch event listener.
1174  *
1175  * @permission ohos.permission.INPUT_MONITORING
1176  * @param callback - Callback for the touch event listener.
1177  * @return OH_Input_RemoveTouchEventMonitor function result code.
1178  *         {@link INPUT_SUCCESS} Removes a touch event listener success.\n
1179  *         {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n
1180  *         {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n
1181  *         {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n
1182  * @syscap SystemCapability.MultimodalInput.Input.Core
1183  * @since 12
1184  */
1185 Input_Result OH_Input_RemoveTouchEventMonitor(Input_TouchEventCallback callback);
1186 
1187 /**
1188  * @brief Removes the listener for all types of axis events.
1189  *
1190  * @permission ohos.permission.INPUT_MONITORING
1191  * @param callback - Callback for the listener used to listen for all types of axis events.
1192  * @return OH_Input_RemoveAxisEventMonitorForAll function result code.
1193  *         {@link INPUT_SUCCESS} Removes the listener for all types of axis events success.\n
1194  *         {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n
1195  *         {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n
1196  *         {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n
1197  * @syscap SystemCapability.MultimodalInput.Input.Core
1198  * @since 12
1199  */
1200 Input_Result OH_Input_RemoveAxisEventMonitorForAll(Input_AxisEventCallback callback);
1201 
1202 /**
1203  * @brief Removes the listener for the specified type of axis events.
1204  *
1205  * @permission ohos.permission.INPUT_MONITORING
1206  * @param axisEventType - Axis event type. The axis event type is defined in {@Link InputEvent_AxisEventType}.
1207  * @param callback - Callback for the listener used to listen for the specified type of axis events.
1208  * @return OH_Input_RemoveAxisEventMonitor function result code.
1209  *         {@link INPUT_SUCCESS} Removes the listener for the specified type of axis events success.\n
1210  *         {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n
1211  *         {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n
1212  *         {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n
1213  * @syscap SystemCapability.MultimodalInput.Input.Core
1214  * @since 12
1215  */
1216 Input_Result OH_Input_RemoveAxisEventMonitor(InputEvent_AxisEventType axisEventType, Input_AxisEventCallback callback);
1217 
1218 /**
1219  * @brief Adds a key event interceptor. If multiple interceptors are added, only the first one takes effect.
1220  *
1221  * @permission ohos.permission.INTERCEPT_INPUT_EVENT
1222  * @param callback - Callback used to receive key events.
1223  * @param option - Options for event interception. If **null** is passed, the default value is used.
1224  * @return OH_Input_AddKeyEventInterceptor function result code.
1225  *         {@link INPUT_SUCCESS} Adds a key event interceptor success.\n
1226  *         {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n
1227  *         {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n
1228  *         {@link INPUT_REPEAT_INTERCEPTOR} Interceptor repeatedly created for an application.\n
1229  *         {@link INPUT_SERVICE_EXCEPTION} Failed to add the interceptor because the service is exception.\n
1230  * @syscap SystemCapability.MultimodalInput.Input.Core
1231  * @since 12
1232  */
1233 Input_Result OH_Input_AddKeyEventInterceptor(Input_KeyEventCallback callback, Input_InterceptorOptions *option);
1234 
1235 /**
1236  * @brief Adds an interceptor for input events, including mouse, touch, and axis events.
1237  * If multiple interceptors are added, only the first one takes effect.
1238  *
1239  * @permission ohos.permission.INTERCEPT_INPUT_EVENT
1240  * @param callback - Pointer to the structure of the callback for the input event interceptor.
1241  * For details, see {@Link Input_InterceptorEventCallback}.
1242  * @param option - Options for event interception. If **null** is passed, the default value is used.
1243  * @return OH_Input_AddInputEventInterceptor function result code.
1244  *         {@link INPUT_SUCCESS} Adds an interceptor for input events success.\n
1245  *         {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n
1246  *         {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n
1247  *         {@link INPUT_REPEAT_INTERCEPTOR} Interceptor repeatedly created for an application.\n
1248  *         {@link INPUT_SERVICE_EXCEPTION} Failed to add the interceptor because the service is exception.\n
1249  * @syscap SystemCapability.MultimodalInput.Input.Core
1250  * @since 12
1251  */
1252 Input_Result OH_Input_AddInputEventInterceptor(Input_InterceptorEventCallback *callback,
1253                                                Input_InterceptorOptions *option);
1254 
1255 /**
1256  * @brief Removes a key event interceptor.
1257  *
1258  * @permission ohos.permission.INTERCEPT_INPUT_EVENT
1259  * @return OH_Input_RemoveKeyEventInterceptor function result code.
1260  *         {@link INPUT_SUCCESS}Removes a key event interceptor success.\n
1261  *         {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n
1262  *         {@link INPUT_SERVICE_EXCEPTION} Failed to remove the interceptor because the service is exception.\n
1263  * @syscap SystemCapability.MultimodalInput.Input.Core
1264  * @since 12
1265  */
1266 Input_Result OH_Input_RemoveKeyEventInterceptor(void);
1267 
1268 /**
1269  * @brief Removes an interceptor for input events, including mouse, touch, and axis events.
1270  *
1271  * @permission ohos.permission.INTERCEPT_INPUT_EVENT
1272  * @return OH_Input_RemoveInputEventInterceptor function result code.
1273  *         {@link INPUT_SUCCESS} Removes an interceptor for input events success.\n
1274  *         {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n
1275  *         {@link INPUT_SERVICE_EXCEPTION} Failed to remove the interceptor because the service is exception.\n
1276  * @syscap SystemCapability.MultimodalInput.Input.Core
1277  * @since 12
1278  */
1279 Input_Result OH_Input_RemoveInputEventInterceptor(void);
1280 
1281 /**
1282  * @brief Obtains the interval since the last system input event.
1283  *
1284  * @param timeInterval Interval, in microseconds.
1285  * @return OH_Input_GetIntervalSinceLastInput status code, specifically.
1286  *         {@Link INPUT_SUCCESS} if the Operation is successful.\n
1287  *         {@Link INPUT_SERVICE_EXCEPTION} Failed to get the interval because the service is exception.\n
1288  *         {@Link INPUT_PARAMETER_ERROR} The timeInterval is NULL.\n
1289  * @syscap SystemCapability.MultimodalInput.Input.Core
1290  * @since 14
1291  */
1292 Input_Result OH_Input_GetIntervalSinceLastInput(int64_t *timeInterval);
1293 
1294 /**
1295  * @brief Creates a hot key object.
1296  *
1297  * @return Returns an {@Link Input_Hotkey} pointer object if the operation is successful. Otherwise, a null pointer is
1298  * returned. The possible cause is memory allocation failure.
1299  * @syscap SystemCapability.MultimodalInput.Input.Core
1300  * @since 14
1301  */
1302 Input_Hotkey *OH_Input_CreateHotkey(void);
1303 
1304 /**
1305  * @brief Destroys a hot key object.
1306  *
1307  * @param hotkey Hot key object.
1308  * @syscap SystemCapability.MultimodalInput.Input.Core
1309  * @since 14
1310  */
1311 void OH_Input_DestroyHotkey(Input_Hotkey **hotkey);
1312 
1313 /**
1314  * @brief Sets a modifier key.
1315  *
1316  * @param hotkey Hotkey key object.
1317  * @param preKeys List of modifier keys.
1318  * @param size Number of modifier keys. One or two modifier keys are supported.
1319  * @syscap SystemCapability.MultimodalInput.Input.Core
1320  * @since 14
1321  */
1322 void OH_Input_SetPreKeys(Input_Hotkey *hotkey, int32_t *preKeys, int32_t size);
1323 
1324 /**
1325  * @brief Obtains a modifier key.
1326  *
1327  * @param hotkey Hotkey key object.
1328  * @param preKeys List of modifier keys.
1329  * @param preKeyCount Number of modifier keys.
1330  * @return OH_Input_GetPreKeys status code, specifically,
1331  *         {@link INPUT_SUCCESS} if the operation is successful;\n
1332  *         {@link INPUT_PARAMETER_ERROR} The hotkey is NULL or the pressedKeys is NULL or the pressedKeyCount
1333  *         is NULL;\n
1334  *         {@Link INPUT_DEVICE_NOT_SUPPORTED} Capability not supported.\n
1335  * @syscap SystemCapability.MultimodalInput.Input.Core
1336  * @since 14
1337  */
1338 Input_Result OH_Input_GetPreKeys(const Input_Hotkey *hotkey, int32_t **preKeys, int32_t *preKeyCount);
1339 
1340 /**
1341  * @brief Sets a modified key.
1342  *
1343  * @param hotkey Hotkey key object.
1344  * @param finalKey Modified key. Only one modified key is supported.
1345  * @syscap SystemCapability.MultimodalInput.Input.Core
1346  * @since 14
1347  */
1348 void OH_Input_SetFinalKey(Input_Hotkey *hotkey, int32_t finalKey);
1349 
1350 /**
1351  * @brief Obtains a modified key.
1352  *
1353  * @param hotkey Hotkey key object.
1354  * @param finalKeyCode Returns the key value of the decorated key.
1355  * @return OH_Input_GetfinalKey status code, specifically,
1356  *         {@link INPUT_SUCCESS} if the operation is successful;\n
1357  *         {@link INPUT_PARAMETER_ERROR} The hotkey is NULL or the finalKeyCode is NULL;\n
1358  *         {@Link INPUT_DEVICE_NOT_SUPPORTED} Capability not supported.\n
1359  * @syscap SystemCapability.MultimodalInput.Input.Core
1360  * @since 14
1361  */
1362 Input_Result OH_Input_GetFinalKey(const Input_Hotkey *hotkey, int32_t *finalKeyCode);
1363 
1364 /**
1365  * @brief Creates an array of {@Link Input_Hotkey} instances.
1366  *
1367  * @param count Number of {@Link Input_Hotkey} instances to be created. The count must be the same as the number of
1368  * system shortcut keys.
1369  * @return Returns a pointer to an array of {@Link Input_Hotkey} instances if the operation is successful. If the
1370  * operation fails, a null pointer is returned. The possible cause is memory allocation failure or count is not equal
1371  * to the number of system hotkeys.
1372  * @syscap SystemCapability.MultimodalInput.Input.Core
1373  * @since 14
1374  */
1375 Input_Hotkey **OH_Input_CreateAllSystemHotkeys(int32_t count);
1376 
1377 /**
1378  * @brief Destroys an array of {@link Input_Hotkey} instances and reclaims memory.
1379  *
1380  * @param hotkeys Pointer to an array of {@Link Input_Hotkey } instances created by the
1381  * {@Link OH_Input_CreateAllSystemHotkeys} method.
1382  * @param count Count of the array to be destroyed, which must be the same as the number of system shortcut keys.
1383  * @syscap SystemCapability.MultimodalInput.Input.Core
1384  * @since 14
1385  */
1386 void OH_Input_DestroyAllSystemHotkeys(Input_Hotkey **hotkeys, int32_t count);
1387 
1388 /**
1389  * @brief Obtains all hot keys supported by the system.
1390  *
1391  * @param hotkey Array of {@Link Input_Hotkey} instances.
1392  * When calling this API for the first time, you can pass NULL to obtain the array length.
1393  * @param count Number of hot keys supported by the system.
1394  * @return OH_Input_GetAllSystemHotkeys status code, specifically,
1395  *         {@link INPUT_SUCCESS} if the operation is successful;\n
1396  *         {@link INPUT_PARAMETER_ERROR} The hotkey or count is NULL, or the value of count does not match the number
1397  *         of system shortcut keys supported by the system;
1398  *         {@Link INPUT_DEVICE_NOT_SUPPORTED} Capability not supported.\n
1399  * @syscap SystemCapability.MultimodalInput.Input.Core
1400  * @since 14
1401  */
1402 Input_Result OH_Input_GetAllSystemHotkeys(Input_Hotkey **hotkey, int32_t *count);
1403 
1404 /**
1405  * @brief Specifies whether to report repeated key events.
1406  *
1407  * @param hotkey Shortcut key object.
1408  * @param isRepeat Whether to report repeated key events.
1409  * The value <b>true</b> means to report repeated key events, and the value <b>false</b> means the opposite.
1410  * @syscap SystemCapability.MultimodalInput.Input.Core
1411  * @since 14
1412  */
1413 void OH_Input_SetRepeat(Input_Hotkey* hotkey, bool isRepeat);
1414 
1415 /**
1416  * @brief Checks whether to report repeated key events.
1417  *
1418  * @param hotkey Shortcut key object.
1419  * @param isRepeat Whether a key event is repeated.
1420  * @return OH_Input_GetIsRepeat status code, specifically,
1421  *         {@link INPUT_SUCCESS} if the operation is successful;\n
1422  *         {@link INPUT_PARAMETER_ERROR} otherwise;\n
1423  *         {@Link INPUT_DEVICE_NOT_SUPPORTED} Capability not supported.\n
1424  * @syscap SystemCapability.MultimodalInput.Input.Core
1425  * @since 14
1426  */
1427 Input_Result OH_Input_GetRepeat(const Input_Hotkey* hotkey, bool *isRepeat);
1428 
1429 /**
1430  * @brief Subscribes to shortcut key events.
1431  *
1432  * @param hotkey Shortcut key object.
1433  * @param callback Callback used to return shortcut key events.
1434  * @return OH_Input_AddHotkeyMonitor status code, specifically,
1435  *         {@link INPUT_SUCCESS} if the operation is successful;\n
1436  *         {@link INPUT_PARAMETER_ERROR} if hotkey or callback is NULL;\n
1437  *         {@Link INPUT_DEVICE_NOT_SUPPORTED} Capability not supported;\n
1438  *         {@Link INPUT_OCCUPIED_BY_SYSTEM} The hotkey has been used by the system. You can call the {@Link
1439  *         GetAllSystemHotkeys} interface to query all system shortcut keys.\n
1440  *         {@Link INPUT_OCCUPIED_BY_OTHER} The hotkey has been subscribed to by another.\n
1441  * @syscap SystemCapability.MultimodalInput.Input.Core
1442  * @since 14
1443  */
1444 Input_Result OH_Input_AddHotkeyMonitor(const Input_Hotkey* hotkey, Input_HotkeyCallback callback);
1445 
1446 /**
1447  * @brief Unsubscribes from shortcut key events.
1448  *
1449  * @param hotkey Shortcut key object.
1450  * @param callback Callback used to return shortcut key events.
1451  * @return OH_Input_RemoveHotkeyMonitor status code, specifically,
1452  *         {@link INPUT_SUCCESS} if the operation is successful;\n
1453  *         {@link INPUT_PARAMETER_ERROR} if hotkey or callback is NULL;\n
1454  *         {@Link INPUT_DEVICE_NOT_SUPPORTED} Capability not supported.\n
1455  * @syscap SystemCapability.MultimodalInput.Input.Core
1456  * @since 14
1457  */
1458 Input_Result OH_Input_RemoveHotkeyMonitor(const Input_Hotkey* hotkey, Input_HotkeyCallback callback);
1459 
1460 /**
1461  * @brief Obtains the IDs of all input devices.
1462  *
1463  * @param deviceIds Array of input device IDs.
1464  * @param inSize Size of the array of input device IDs.
1465  * @param outSize Length of the list of input device IDs. The value cannot be greater than the value of inSize.
1466  * @return OH_Input_GetDeviceIds result code, specifically,
1467  *         {@link INPUT_SUCCESS} if the operation is successful;
1468  *         {@link INPUT_PARAMETER_ERROR} if deviceIds or outSize is a null pointer or inSize is less than 0.
1469  * @syscap SystemCapability.MultimodalInput.Input.Core
1470  * @since 13
1471  */
1472 Input_Result OH_Input_GetDeviceIds(int32_t *deviceIds, int32_t inSize, int32_t *outSize);
1473 
1474 /**
1475  * @brief Obtains the information about an input device.
1476  *
1477  * @param deviceId Device ID.
1478  * @param deviceInfo Pointer to an {@Link Input_DeviceInfo} object.
1479  * @return OH_Input_GetDevice result code, specifically,
1480  *         {@link INPUT_SUCCESS} if the operation is successful;
1481  *         {@link INPUT_PARAMETER_ERROR} if the deviceInfo is a null pointer or the deviceId is invalid.
1482  * You can use the {@Link OH_Input_GetDeviceIds} interface to query the device IDs supported by the system.
1483  * @syscap SystemCapability.MultimodalInput.Input.Core
1484  * @since 13
1485  */
1486 Input_Result OH_Input_GetDevice(int32_t deviceId, Input_DeviceInfo **deviceInfo);
1487 
1488 /**
1489  * @brief Creates a deviceInfo object.
1490  *
1491  * @return Pointer to an {@Link Input_DeviceInfo} object if the operation is successful;
1492  * a null pointer otherwise (possibly because of a memory allocation failure).
1493  * @syscap SystemCapability.MultimodalInput.Input.Core
1494  * @since 13
1495  */
1496 Input_DeviceInfo* OH_Input_CreateDeviceInfo(void);
1497 
1498 /**
1499  * @brief Destroys a deviceInfo object.
1500  *
1501  * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}.
1502  * @syscap SystemCapability.MultimodalInput.Input.Core
1503  * @since 13
1504  */
1505 void OH_Input_DestroyDeviceInfo(Input_DeviceInfo **deviceInfo);
1506 
1507 /**
1508  * @brief Obtains the keyboard type of an input device.
1509  *
1510  * @param deviceId Device ID.
1511  * @param keyboardType Pointer to the keyboard type of the input device.
1512  * @return OH_Input_GetKeyboardType result code, specifically,
1513  *         {@link INPUT_SUCCESS} if the operation is successful;
1514  *         {@link INPUT_PARAMETER_ERROR} if the device ID is invalid or keyboardType is a null pointer.
1515  * @syscap SystemCapability.MultimodalInput.Input.Core
1516  * @since 13
1517  */
1518 Input_Result OH_Input_GetKeyboardType(int32_t deviceId, int32_t *keyboardType);
1519 
1520 /**
1521  * @brief Obtains the ID of an input device.
1522  *
1523  * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}.
1524  * @param id Pointer to the ID of the input device.
1525  * @return OH_Input_GetDeviceId result code, specifically,
1526  *         {@link INPUT_SUCCESS} if the operation is successful;
1527  *         {@link INPUT_PARAMETER_ERROR} if deviceInfo or id is a null pointer.
1528  * @syscap SystemCapability.MultimodalInput.Input.Core
1529  * @since 13
1530  */
1531 Input_Result OH_Input_GetDeviceId(Input_DeviceInfo *deviceInfo, int32_t *id);
1532 
1533 /**
1534  * @brief Obtains the name of an input device.
1535  *
1536  * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}.
1537  * @param name Pointer to the name of the input device.
1538  * @return OH_Input_GetDeviceName result code, specifically,
1539  *         {@link INPUT_SUCCESS} if the operation is successful;
1540  *         {@link INPUT_PARAMETER_ERROR} if deviceInfo or name is a null pointer.
1541  * @syscap SystemCapability.MultimodalInput.Input.Core
1542  * @since 13
1543  */
1544 Input_Result OH_Input_GetDeviceName(Input_DeviceInfo *deviceInfo, char **name);
1545 
1546 /**
1547  * @brief Obtains the capabilities of an input device, for example, a touchscreen, touchpad, or keyboard.
1548  *
1549  * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}.
1550  * @param capabilities Pointer to the capabilities of the input device.
1551  * @return OH_Input_GetCapabilities result code, specifically,
1552  *         {@link INPUT_SUCCESS} if the operation is successful;
1553  *         {@link INPUT_PARAMETER_ERROR} if deviceInfo or capabilities is a null pointer.
1554  * @syscap SystemCapability.MultimodalInput.Input.Core
1555  * @since 13
1556  */
1557 Input_Result OH_Input_GetCapabilities(Input_DeviceInfo *deviceInfo, int32_t *capabilities);
1558 
1559 /**
1560  * @brief Obtains the version information of an input device.
1561  *
1562  * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}.
1563  * @param version Pointer to the version information of the input device.
1564  * @return OH_Input_GetDeviceVersion result code, specifically,
1565  *         {@link INPUT_SUCCESS} if the operation is successful;
1566  *         {@link INPUT_PARAMETER_ERROR} if deviceInfo or version is a null pointer.
1567  * @syscap SystemCapability.MultimodalInput.Input.Core
1568  * @since 13
1569  */
1570 Input_Result OH_Input_GetDeviceVersion(Input_DeviceInfo *deviceInfo, int32_t *version);
1571 
1572 /**
1573  * @brief Obtains the product information of an input device.
1574  *
1575  * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}.
1576  * @param product Pointer to the product information of the input device.
1577  * @return OH_Input_GetDeviceProduct result code, specifically,
1578  *         {@link INPUT_SUCCESS} if the operation is successful;
1579  *         {@link INPUT_PARAMETER_ERROR} if deviceInfo or product is a null pointer.
1580  * @syscap SystemCapability.MultimodalInput.Input.Core
1581  * @since 13
1582  */
1583 Input_Result OH_Input_GetDeviceProduct(Input_DeviceInfo *deviceInfo, int32_t *product);
1584 
1585 /**
1586  * @brief Obtains the vendor information of an input device.
1587  *
1588  * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}.
1589  * @param vendor Pointer to the vendor information of the input device.
1590  * @return OH_Input_GetDeviceVendor result code, specifically,
1591  *         {@link INPUT_SUCCESS} if the operation is successful;
1592  *         {@link INPUT_PARAMETER_ERROR} if deviceInfo or vendor is a null pointer.
1593  * @syscap SystemCapability.MultimodalInput.Input.Core
1594  * @since 13
1595  */
1596 Input_Result OH_Input_GetDeviceVendor(Input_DeviceInfo *deviceInfo, int32_t *vendor);
1597 
1598 /**
1599  * @brief Obtains the physical address of an input device.
1600  *
1601  * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}.
1602  * @param address Pointer to the physical address of the input device.
1603  * @return OH_Input_GetDeviceAddress result code, specifically,
1604  *         {@link INPUT_SUCCESS} if the operation is successful;
1605  *         {@link INPUT_PARAMETER_ERROR} if deviceInfo or address is a null pointer.
1606  * @syscap SystemCapability.MultimodalInput.Input.Core
1607  * @since 13
1608  */
1609 Input_Result OH_Input_GetDeviceAddress(Input_DeviceInfo *deviceInfo, char **address);
1610 
1611 /**
1612  * @brief Registers a listener for device hot swap events.
1613  *
1614  * @param listener Pointer to an {@Link Input_DeviceListener} object.
1615  *
1616  * @return OH_Input_RegisterDeviceListener status code, specifically,
1617  *         {@link INPUT_SUCCESS} if the operation is successful;\n
1618  *         {@link INPUT_PARAMETER_ERROR} if listener is NULL;
1619  * @syscap SystemCapability.MultimodalInput.Input.Core
1620  * @since 13
1621  */
1622 Input_Result OH_Input_RegisterDeviceListener(Input_DeviceListener* listener);
1623 
1624 /**
1625  * @brief Unregisters the listener for device hot swap events.
1626  *
1627  * @param listener Pointer to the listener for device hot swap events. For details, see {@Link Input_DeviceListener}.
1628  *
1629  * @return OH_Input_UnregisterDeviceListener status code, specifically,
1630  *         {@link INPUT_SUCCESS} if the operation is successful;\n
1631  *         {@link INPUT_PARAMETER_ERROR} if listener is NULL or no listener is registered;
1632  *         {@link INPUT_SERVICE_EXCEPTION} if the service is abnormal.
1633  * @syscap SystemCapability.MultimodalInput.Input.Core
1634  * @since 13
1635  */
1636 Input_Result OH_Input_UnregisterDeviceListener(Input_DeviceListener* listener);
1637 
1638 /**
1639  * @brief Unregisters the listener for all device hot swap events.
1640  *
1641  * @return OH_Input_UnregisterDeviceListener status code, specifically,
1642  *         {@link INPUT_SUCCESS} if the operation is successful;\n
1643  *         {@link INPUT_SERVICE_EXCEPTION} if the service is abnormal.
1644  * @syscap SystemCapability.MultimodalInput.Input.Core
1645  * @since 13
1646  */
1647 Input_Result OH_Input_UnregisterDeviceListeners();
1648 #ifdef __cplusplus
1649 }
1650 #endif
1651 /** @} */
1652 
1653 #endif /* OH_INPUT_MANAGER_H */
1654