oh_input_manager.h
Overview
Provides functions such as event injection and status query.
System capability: SystemCapability.MultimodalInput.Input.Core
Library: libohinput.so
Since: 12
Related module: Input
Summary
Structs
| Name | Description |
|---|---|
| struct Input_InterceptorEventCallback | Defines the structure of the interceptor for callback events, including mouse events, touch events, and axis events. |
| struct Input_DeviceListener | Defines a listener for device hot swap events. |
Types
| Name | Description |
|---|---|
| typedef enum Input_KeyStateAction Input_KeyStateAction | Provides the enum values of the key status. |
| typedef enum Input_KeyEventAction Input_KeyEventAction | Provides the enum values of the key event type. |
| typedef enum Input_MouseEventAction Input_MouseEventAction | Provides the enum values of mouse actions. |
| typedef enum InputEvent_MouseAxis InputEvent_MouseAxis | Provides the enum values of mouse axis event types. |
| typedef enum Input_MouseEventButton Input_MouseEventButton | Provides the enum values of mouse buttons. |
| typedef enum Input_TouchEventAction Input_TouchEventAction | Provides the enum values of touch actions. |
| typedef enum InputEvent_SourceType InputEvent_SourceType | Provides the enum values of event source types. |
| typedef enum Input_KeyboardType Input_KeyboardType | Provides the enum values of keyboard types of the input device. |
| typedef struct Input_KeyState Input_KeyState | Defines key information, which identifies a key pressing behavior. For example, the Ctrl key information contains the key value and key type. |
| typedef struct Input_KeyEvent Input_KeyEvent | Defines the key event to be injected. |
| typedef struct Input_MouseEvent Input_MouseEvent | Defines the mouse event to be injected. |
| typedef struct Input_TouchEvent Input_TouchEvent | Defines the touch event to be injected. |
| typedef struct Input_AxisEvent Input_AxisEvent | Defines an axis event. |
| typedef enum Input_Result Input_Result | Provides the enum values of error codes. |
| typedef void(* Input_KeyEventCallback) (const Input_KeyEvent *keyEvent) | Defines a lifecycle callback for keyEvent. If the callback is triggered, keyEvent will be destroyed. |
| typedef void(* Input_MouseEventCallback) (const Input_MouseEvent *mouseEvent) | Defines a lifecycle callback for mouseEvent. If the callback is triggered, mouseEvent will be destroyed. |
| typedef void(* Input_TouchEventCallback) (const Input_TouchEvent *touchEvent) | Defines a lifecycle callback for touchEvent. If the callback is triggered, touchEvent will be destroyed. |
| typedef void(* Input_AxisEventCallback) (const Input_AxisEvent *axisEvent) | Defines a lifecycle callback for axisEvent. If the callback is triggered, axisEvent will be destroyed. |
| typedef void(* Input_HotkeyCallback) (Input_Hotkey *hotkey) | Defines the callback used to return shortcut key events. |
| typedef void(* Input_DeviceAddedCallback) (int32_t deviceId) | Defines a callback used to receive device insertion events. |
| typedef void(* Input_DeviceRemovedCallback) (int32_t deviceId) | Defines a callback used to receive device removal events. |
| typedef struct Input_InterceptorEventCallback Input_InterceptorEventCallback | Defines the structure of the interceptor for callback events, including mouse events, touch events, and axis events. |
| typedef struct Input_DeviceListener Input_DeviceListener | Defines a listener for device hot swap events. |
| typedef struct Input_InterceptorOptions Input_InterceptorOptions | Defines event interception options. |
| typedef struct Input_Hotkey Input_Hotkey | Defines the shortcut key structure. |
| typedef struct Input_DeviceInfo Input_DeviceInfo | Defines the input device information. |
Enums
Functions
| Name | Description |
|---|---|
| Input_Result OH_Input_GetKeyState (struct Input_KeyState *keyState) | Queries an enum object of the key status. |
| struct Input_KeyState * OH_Input_CreateKeyState () | Creates an enum object of the key status. |
| void OH_Input_DestroyKeyState (struct Input_KeyState **keyState) | Destroys an enum object of the key status. |
| void OH_Input_SetKeyCode (struct Input_KeyState *keyState, int32_t keyCode) | Sets the key value of a key status enum object. |
| int32_t OH_Input_GetKeyCode (const struct Input_KeyState *keyState) | Obtains the key value of a key status enum object. |
| void OH_Input_SetKeyPressed (struct Input_KeyState *keyState, int32_t keyAction) | Sets whether the key specific to a key status enum object is pressed. |
| int32_t OH_Input_GetKeyPressed (const struct Input_KeyState *keyState) | Checks whether the key specific to a key status enum object is pressed. |
| void OH_Input_SetKeySwitch (struct Input_KeyState *keyState, int32_t keySwitch) | Sets the key switch of the key status enum object. |
| int32_t OH_Input_GetKeySwitch (const struct Input_KeyState *keyState) | Obtains the key switch of the key status enum object. |
| int32_t OH_Input_InjectKeyEvent (const struct Input_KeyEvent *keyEvent) | Injects a key event. |
| struct Input_KeyEvent * OH_Input_CreateKeyEvent () | Creates a key event object. |
| void OH_Input_DestroyKeyEvent (struct Input_KeyEvent **keyEvent) | Destroys a key event object. |
| void OH_Input_SetKeyEventAction (struct Input_KeyEvent *keyEvent, int32_t action) | Sets the key event type. |
| int32_t OH_Input_GetKeyEventAction (const struct Input_KeyEvent *keyEvent) | Obtains the key event type. |
| void OH_Input_SetKeyEventKeyCode (struct Input_KeyEvent *keyEvent, int32_t keyCode) | Sets the key code value for a key event. |
| int32_t OH_Input_GetKeyEventKeyCode (const struct Input_KeyEvent *keyEvent) | Obtains the key code value of a key event. |
| void OH_Input_SetKeyEventActionTime (struct Input_KeyEvent *keyEvent, int64_t actionTime) | Sets the time when a key event occurs. |
| int64_t OH_Input_GetKeyEventActionTime (const struct Input_KeyEvent *keyEvent) | Obtains the time when a key event occurs. |
| int32_t OH_Input_InjectMouseEvent (const struct Input_MouseEvent *mouseEvent) | Injects a mouse event. |
| struct Input_MouseEvent * OH_Input_CreateMouseEvent () | Creates a mouse event object. |
| void OH_Input_DestroyMouseEvent (struct Input_MouseEvent **mouseEvent) | Destroys a mouse event object. |
| void OH_Input_SetMouseEventAction (struct Input_MouseEvent *mouseEvent, int32_t action) | Sets the action for a mouse event. |
| int32_t OH_Input_GetMouseEventAction (const struct Input_MouseEvent *mouseEvent) | Obtains the action of a mouse event. |
| void OH_Input_SetMouseEventDisplayX (struct Input_MouseEvent *mouseEvent, int32_t displayX) | Sets the X coordinate for a mouse event. |
| int32_t OH_Input_GetMouseEventDisplayX (const struct Input_MouseEvent *mouseEvent) | Obtains the X coordinate of a mouse event. |
| void OH_Input_SetMouseEventDisplayY (struct Input_MouseEvent *mouseEvent, int32_t displayY) | Sets the Y coordinate for a mouse event. |
| int32_t OH_Input_GetMouseEventDisplayY (const struct Input_MouseEvent *mouseEvent) | Obtains the Y coordinate of a mouse event. |
| void OH_Input_SetMouseEventButton (struct Input_MouseEvent *mouseEvent, int32_t button) | Sets the button for a mouse event. |
| int32_t OH_Input_GetMouseEventButton (const struct Input_MouseEvent *mouseEvent) | Obtains the button of a mouse event. |
| void OH_Input_SetMouseEventAxisType (struct Input_MouseEvent *mouseEvent, int32_t axisType) | Sets the axis type for a mouse event. |
| int32_t OH_Input_GetMouseEventAxisType (const struct Input_MouseEvent *mouseEvent) | Obtains the axis type of a mouse event. |
| void OH_Input_SetMouseEventAxisValue (struct Input_MouseEvent *mouseEvent, float axisValue) | Sets the axis value for a mouse axis event. |
| float OH_Input_GetMouseEventAxisValue (const struct Input_MouseEvent *mouseEvent) | Obtains the axis value of a mouse axis event. |
| void OH_Input_SetMouseEventActionTime (struct Input_MouseEvent *mouseEvent, int64_t actionTime) | Sets the time when a mouse event occurs. |
| int64_t OH_Input_GetMouseEventActionTime (const struct Input_MouseEvent *mouseEvent) | Obtains the time when a mouse event occurs. |
| int32_t OH_Input_InjectTouchEvent (const struct Input_TouchEvent *touchEvent) | Injects a touch event. |
| struct Input_TouchEvent * OH_Input_CreateTouchEvent () | Creates a touch event object. |
| void OH_Input_DestroyTouchEvent (struct Input_TouchEvent **touchEvent) | Destroys a touch event object. |
| void OH_Input_SetTouchEventAction (struct Input_TouchEvent *touchEvent, int32_t action) | Sets the action for a touch event. |
| int32_t OH_Input_GetTouchEventAction (const struct Input_TouchEvent *touchEvent) | Obtains the action of a touch event. |
| void OH_Input_SetTouchEventFingerId (struct Input_TouchEvent *touchEvent, int32_t id) | Sets the finger ID for a touch event. |
| int32_t OH_Input_GetTouchEventFingerId (const struct Input_TouchEvent *touchEvent) | Obtains the finger ID of a touch event. |
| void OH_Input_SetTouchEventDisplayX (struct Input_TouchEvent *touchEvent, int32_t displayX) | Sets the X coordinate for a touch event. |
| int32_t OH_Input_GetTouchEventDisplayX (const struct Input_TouchEvent *touchEvent) | Obtains the X coordinate of a touch event. |
| void OH_Input_SetTouchEventDisplayY (struct Input_TouchEvent *touchEvent, int32_t displayY) | Sets the Y coordinate for a touch event. |
| int32_t OH_Input_GetTouchEventDisplayY (const struct Input_TouchEvent *touchEvent) | Obtains the Y coordinate of a touch event. |
| void OH_Input_SetTouchEventActionTime (struct Input_TouchEvent *touchEvent, int64_t actionTime) | Sets the time when a touch event occurs. |
| int64_t OH_Input_GetTouchEventActionTime (const struct Input_TouchEvent *touchEvent) | Obtains the time when a touch event occurs. |
| void OH_Input_CancelInjection () | Stops event injection and revokes authorization. |
| Input_AxisEvent * OH_Input_CreateAxisEvent (void) | Creates an axis event object. |
| Input_Result OH_Input_DestroyAxisEvent (Input_AxisEvent **axisEvent) | Destroys an axis event object. |
| Input_Result OH_Input_SetAxisEventAction (Input_AxisEvent *axisEvent, InputEvent_AxisAction action) | Sets the action for an axis event. |
| Input_Result OH_Input_GetAxisEventAction (const Input_AxisEvent *axisEvent, InputEvent_AxisAction *action) | Obtains the action of an axis event. |
| Input_Result OH_Input_SetAxisEventDisplayX (Input_AxisEvent *axisEvent, float displayX) | Sets the X coordinate for an axis event. |
| Input_Result OH_Input_GetAxisEventDisplayX (const Input_AxisEvent *axisEvent, float *displayX) | Obtains the X coordinate of an axis event. |
| Input_Result OH_Input_SetAxisEventDisplayY (Input_AxisEvent *axisEvent, float displayY) | Sets the Y coordinate for an axis event. |
| Input_Result OH_Input_GetAxisEventDisplayY (const Input_AxisEvent *axisEvent, float *displayY) | Obtains the Y coordinate of an axis event. |
| Input_Result OH_Input_SetAxisEventAxisValue (Input_AxisEvent *axisEvent, InputEvent_AxisType axisType, double axisValue) | Sets the axis value of the axis type specified by the axis event. |
| Input_Result OH_Input_GetAxisEventAxisValue (const Input_AxisEvent *axisEvent, InputEvent_AxisType axisType, double *axisValue) | Obtains the axis value for the specified axis type of the axis event. |
| Input_Result OH_Input_SetAxisEventActionTime (Input_AxisEvent *axisEvent, int64_t actionTime) | Sets the time when an axis event occurs. |
| Input_Result OH_Input_GetAxisEventActionTime (const Input_AxisEvent *axisEvent, int64_t *actionTime) | Obtains the time when an axis event occurs. |
| Input_Result OH_Input_SetAxisEventType (Input_AxisEvent *axisEvent, InputEvent_AxisEventType axisEventType) | Sets the axis event type. |
| Input_Result OH_Input_GetAxisEventType (const Input_AxisEvent *axisEvent, InputEvent_AxisEventType *axisEventType) | Obtains the axis event type. |
| Input_Result OH_Input_SetAxisEventSourceType (Input_AxisEvent *axisEvent, InputEvent_SourceType sourceType) | Sets the axis event source type. |
| Input_Result OH_Input_GetAxisEventSourceType (const Input_AxisEvent *axisEvent, InputEvent_SourceType *sourceType) | Obtains the axis event source type. |
| Input_Result OH_Input_AddKeyEventMonitor (Input_KeyEventCallback callback) | Adds a listener for key events. |
| Input_Result OH_Input_AddMouseEventMonitor (Input_MouseEventCallback callback) | Adds a listener for mouse events, including mouse click and movement events, but not scroll wheel events. Scroll wheel events are axis events. |
| Input_Result OH_Input_AddTouchEventMonitor (Input_TouchEventCallback callback) | Adds a listener for touch events. |
| Input_Result OH_Input_AddAxisEventMonitorForAll (Input_AxisEventCallback callback) | Adds a listener for all types of axis events, which are defined in InputEvent_AxisEventType. |
| Input_Result OH_Input_AddAxisEventMonitor (InputEvent_AxisEventType axisEventType, Input_AxisEventCallback callback) | Adds a listener for the specified type of axis events, which are defined in InputEvent_AxisEventType. |
| Input_Result OH_Input_RemoveKeyEventMonitor (Input_KeyEventCallback callback) | Removes the listener for key events. |
| Input_Result OH_Input_RemoveMouseEventMonitor (Input_MouseEventCallback callback) | Removes the listener for mouse events. |
| Input_Result OH_Input_RemoveTouchEventMonitor (Input_TouchEventCallback callback) | Removes the listener for touch events. |
| Input_Result OH_Input_RemoveAxisEventMonitorForAll (Input_AxisEventCallback callback) | Removes the listener for all types of axis events. |
| Input_Result OH_Input_RemoveAxisEventMonitor (InputEvent_AxisEventType axisEventType, Input_AxisEventCallback callback) | Removes the listener for the specified type of axis events, which are defined in InputEvent_AxisEventType. |
| Input_Result OH_Input_AddKeyEventInterceptor (Input_KeyEventCallback callback, Input_InterceptorOptions *option) | Adds an interceptor for key events. If multiple interceptors are added, only the first one takes effect. |
| Input_Result OH_Input_AddInputEventInterceptor (Input_InterceptorEventCallback *callback Input_InterceptorOptions *option) | Adds an interceptor for input events, including mouse, touch, and axis events. If multiple interceptors are added, only the first one takes effect. |
| Input_Result OH_Input_RemoveKeyEventInterceptor () | Removes the interceptor for key events. |
| Input_Result OH_Input_RemoveInputEventInterceptor () | Removes the interceptor for input events, including mouse, touch, and axis events. |
| int32_t OH_Input_GetIntervalSinceLastInput (int64_t *timeInterval) | Obtains the interval since the last system input event. |
| Input_Hotkey * OH_Input_CreateHotkey () | Creates a shortcut key object. |
| void OH_Input_DestroyHotkey (Input_Hotkey **hotkey) | Destroys a shortcut key object. |
| void OH_Input_SetPreKeys (Input_Hotkey *hotkey, int32_t *preKeys, int32_t size) | Sets the modifier key. |
| Input_Result OH_Input_GetPreKeys (const Input_Hotkey *hotkey, int32_t **preKeys, int32_t *preKeyCount) | Obtains the modifier key. |
| void OH_Input_SetFinalKey (Input_Hotkey *hotkey, int32_t finalKey) | Sets the modified key. |
| Input_Result OH_Input_GetFinalKey (const Input_Hotkey *hotkey, int32_t *finalKeyCode) | Obtains the modified key. |
| Input_Hotkey ** OH_Input_CreateAllSystemHotkeys (int32_t count) | Creates an array of Input_Hotkey instances. |
| void OH_Input_DestroyAllSystemHotkeys (Input_Hotkey **hotkeys, int32_t count) | Destroys the array of Input_Hotkey instances and reclaims the memory. |
| Input_Result OH_Input_GetAllSystemHotkeys (Input_Hotkey **hotkey, int32_t *count) | Obtains all configured shortcut keys. |
| void OH_Input_SetRepeat (Input_Hotkey *hotkey, bool isRepeat) | Specifies whether to report repeated key events. |
| Input_Result OH_Input_GetRepeat (const Input_Hotkey *hotkey, bool *isRepeat) | Checks whether to report repeated key events. |
| Input_Result OH_Input_AddHotkeyMonitor (const Input_Hotkey *hotkey, Input_HotkeyCallback callback) | Subscribes to shortcut key events. |
| Input_Result OH_Input_RemoveHotkeyMonitor (const Input_Hotkey *hotkey, Input_HotkeyCallback callback) | Unsubscribes from shortcut key events. |
| Input_Result OH_Input_GetDeviceIds (int32_t *deviceIds, int32_t inSize, int32_t *outSize) | Obtains the IDs of all input devices. |
| Input_Result OH_Input_GetDevice (int32_t deviceId, Input_DeviceInfo **deviceInfo) | Obtains information about the input device. |
| Input_DeviceInfo * OH_Input_CreateDeviceInfo (void) | Creates a deviceInfo object. |
| void OH_Input_DestroyDeviceInfo (Input_DeviceInfo **deviceInfo) | Destroys a deviceInfo object. |
| Input_Result OH_Input_GetKeyboardType (int32_t deviceId, int32_t *keyboardType) | Obtains the keyboard type of the input device. |
| Input_Result OH_Input_GetDeviceId (Input_DeviceInfo *deviceInfo, int32_t *id) | Obtains the ID of an input device. |
| Input_Result OH_Input_GetDeviceName (Input_DeviceInfo *deviceInfo, char **name) | Obtains the name of an input device. |
| Input_Result OH_Input_GetCapabilities (Input_DeviceInfo *deviceInfo, int32_t *capabilities) | Obtains the capabilities of an input device, for example, a touchscreen, touchpad, or keyboard. |
| Input_Result OH_Input_GetDeviceVersion (Input_DeviceInfo *deviceInfo, int32_t *version) | Obtains the version information of an input device. |
| Input_Result OH_Input_GetDeviceProduct (Input_DeviceInfo *deviceInfo, int32_t *product) | Obtains the product information of an input device. |
| Input_Result OH_Input_GetDeviceVendor (Input_DeviceInfo *deviceInfo, int32_t *vendor) | Obtains the vendor information of an input device. |
| Input_Result OH_Input_GetDeviceAddress (Input_DeviceInfo *deviceInfo, char **address) | Obtains the physical address of an input device. |
| Input_Result OH_Input_RegisterDeviceListener (Input_DeviceListener *listener) | Registers a listener for device hot swap events. |
| Input_Result OH_Input_UnregisterDeviceListener (Input_DeviceListener *listener) | Unregisters the listener for device hot swap events. |
| Input_Result OH_Input_UnregisterDeviceListeners () | Unregisters the listener for all device hot swap events. |