openharmony 鸿蒙 capi-oh-input-manager-h

2025-06-12 浏览 (1)

oh_input_manager.h

Overview

Provides functions such as event injection and status query.

Library: libohinput.so

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Related module: input

Summary

Structs

Nametypedef KeywordDescription
Input_InterceptorEventCallbackInput_InterceptorEventCallbackDefines the structure of the interceptor for callback events, including mouse events, touch events, and axis events.
Input_DeviceListenerInput_DeviceListenerDefines a listener for device hot swap events.
Input_KeyStateInput_KeyStateDefines key information, which identifies a key pressing behavior. For example, the Ctrl key information contains the key value and key type.
Input_KeyEventInput_KeyEventDefines the key event to be injected.
Input_MouseEventInput_MouseEventDefines the mouse event to be injected.
Input_TouchEventInput_TouchEventDefines the touch event to be injected.
Input_AxisEventInput_AxisEventDefines an axis event.
Input_HotkeyInput_HotkeyDefines the shortcut key structure.
Input_DeviceInfoInput_DeviceInfoDefines the input device information.
Input_InterceptorOptionsInput_InterceptorOptionsDefines event interception options.

Enums

Nametypedef KeywordDescription
Input_KeyStateActionInput_KeyStateActionProvides the enum values of the key status.
Input_KeyEventActionInput_KeyEventActionProvides the enum values of the key event type.
Input_MouseEventActionInput_MouseEventActionProvides the enum values of mouse actions.
InputEvent_MouseAxisInputEvent_MouseAxisProvides the enum values of mouse axis event types.
Input_MouseEventButtonInput_MouseEventButtonProvides the enum values of mouse buttons.
Input_TouchEventActionInput_TouchEventActionProvides the enum values of touch actions.
InputEvent_SourceTypeInputEvent_SourceTypeProvides the enum values of event source types.
Input_KeyboardTypeInput_KeyboardTypeProvides the enum values of keyboard types of the input device.
Input_ResultInput_ResultProvides the enum values of error codes.

Functions

Nametypedef KeywordDescription
typedef void (*Input_HotkeyCallback)(Input_Hotkey* hotkey)Input_HotkeyCallbackDefines the callback used to return shortcut key events.
typedef void (*Input_KeyEventCallback)(const Input_KeyEvent* keyEvent)Input_KeyEventCallbackDefines a lifecycle callback for keyEvent. If the callback is triggered, keyEvent will be destroyed.
typedef void (*Input_MouseEventCallback)(const Input_MouseEvent* mouseEvent)Input_MouseEventCallbackDefines a lifecycle callback for mouseEvent. If the callback is triggered, mouseEvent will be destroyed.
typedef void (*Input_TouchEventCallback)(const Input_TouchEvent* touchEvent)Input_TouchEventCallbackDefines a lifecycle callback for touchEvent. If the callback is triggered, touchEvent will be destroyed.
typedef void (*Input_AxisEventCallback)(const Input_AxisEvent* axisEvent)Input_AxisEventCallbackDefines a lifecycle callback for axisEvent. If the callback is triggered, axisEvent will be destroyed.
typedef void (*Input_DeviceAddedCallback)(int32_t deviceId)Input_DeviceAddedCallbackDefines a callback used to receive device insertion events.
typedef void (*Input_DeviceRemovedCallback)(int32_t deviceId)Input_DeviceRemovedCallbackDefines a callback used to receive device removal events.
Input_Result OH_Input_GetKeyState(struct Input_KeyState* keyState)-Queries a key status enum object.
struct Input_KeyState* OH_Input_CreateKeyState()-Creates a key status enum object.
void OH_Input_DestroyKeyState(struct Input_KeyState** keyState)-Destroys a key status enum object.
void OH_Input_SetKeyCode(struct Input_KeyState* keyState, int32_t keyCode)-Sets 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.
void OH_Input_SetKeySwitch(struct Input_KeyState* keyState, int32_t keySwitch)-Sets the key switch of the key status enum object.
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.
void OH_Input_SetKeyEventKeyCode(struct Input_KeyEvent* keyEvent, int32_t keyCode)-Sets the key code value for a key event.
void OH_Input_SetKeyEventActionTime(struct Input_KeyEvent* keyEvent, int64_t actionTime)-Sets the time when a key event occurs.
void OH_Input_SetKeyEventWindowId(struct Input_KeyEvent* keyEvent, int32_t windowId)-Sets the window ID of a key event.
void OH_Input_SetKeyEventDisplayId(struct Input_KeyEvent* keyEvent, int32_t displayId)-Sets the screen ID of a key 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.
void OH_Input_SetMouseEventDisplayX(struct Input_MouseEvent* mouseEvent, int32_t displayX)-Sets the X coordinate for a mouse event.
void OH_Input_SetMouseEventDisplayY(struct Input_MouseEvent* mouseEvent, int32_t displayY)-Sets the Y coordinate for a mouse event.
void OH_Input_SetMouseEventButton(struct Input_MouseEvent* mouseEvent, int32_t button)-Sets the button for a mouse event.
void OH_Input_SetMouseEventAxisType(struct Input_MouseEvent* mouseEvent, int32_t axisType)-Sets the axis type for a mouse event.
void OH_Input_SetMouseEventAxisValue(struct Input_MouseEvent* mouseEvent, float axisValue)-Sets the axis value for a mouse axis event.
void OH_Input_SetMouseEventActionTime(struct Input_MouseEvent* mouseEvent, int64_t actionTime)-Sets the time when a mouse event occurs.
void OH_Input_SetMouseEventWindowId(struct Input_MouseEvent* mouseEvent, int32_t windowId)-Sets the window ID of a mouse event.
void OH_Input_SetMouseEventDisplayId(struct Input_MouseEvent* mouseEvent, int32_t displayId)-Sets the screen ID of a mouse 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.
void OH_Input_SetTouchEventFingerId(struct Input_TouchEvent* touchEvent, int32_t id)-Sets the finger ID for a touch event.
void OH_Input_SetTouchEventDisplayX(struct Input_TouchEvent* touchEvent, int32_t displayX)-Sets the X coordinate for a touch event.
void OH_Input_SetTouchEventDisplayY(struct Input_TouchEvent* touchEvent, int32_t displayY)-Sets the Y coordinate for a touch event.
void OH_Input_SetTouchEventActionTime(struct Input_TouchEvent* touchEvent, int64_t actionTime)-Sets the time when a touch event occurs.
void OH_Input_SetTouchEventWindowId(struct Input_TouchEvent* touchEvent, int32_t windowId)-Sets the window ID of a touchscreen event.
void OH_Input_SetTouchEventDisplayId(struct Input_TouchEvent* touchEvent, int32_t displayId)-Sets the screen ID of a touchscreen event.
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_SetAxisEventWindowId(Input_AxisEvent* axisEvent, int32_t windowId)-Sets the window ID of an axis event.
Input_Result OH_Input_GetAxisEventWindowId(const Input_AxisEvent* axisEvent, int32_t* windowId)-Obtains the window ID of an axis event.
Input_Result OH_Input_SetAxisEventDisplayId(Input_AxisEvent* axisEvent, int32_t displayId)-Sets the screen ID of an axis event.
Input_Result OH_Input_GetAxisEventDisplayId(const Input_AxisEvent* axisEvent, int32_t* displayId)-Obtains the screen ID of an axis event.
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. Key events are intercepted only when the application gains focus.
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. Key events are intercepted only when the application window is hit.
Input_Result OH_Input_RemoveKeyEventInterceptor(void)-Removes the interceptor for key events.
Input_Result OH_Input_RemoveInputEventInterceptor(void)-Removes the interceptor for input events, including mouse, touch, and axis events.
Input_Result OH_Input_GetIntervalSinceLastInput(int64_t *timeInterval)-Obtains the interval since the last system input event.
Input_Hotkey *OH_Input_CreateHotkey(void)-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. This API is not applicable to wearables and lite wearables.
Input_Result OH_Input_RemoveHotkeyMonitor(const Input_Hotkey* hotkey, Input_HotkeyCallback callback)-Unsubscribes from shortcut key events.
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.
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_GetFunctionKeyState(int32_t keyCode, int32_t *state)-Obtains the function key status.

Enum Description

Input_KeyStateAction

enum Input_KeyStateAction

Description

Provides the enum values of the key status.

Since: 12

EnumDescription
KEY_DEFAULT = -1Default status.
KEY_PRESSED = 0Pressing of a key.
KEY_RELEASED = 1Release of a key.
KEY_SWITCH_ON = 2Key switch enabled.
KEY_SWITCH_OFF = 3Key switch disabled.

Input_KeyEventAction

enum Input_KeyEventAction

Description

Provides the enum values of the key event type.

Since: 12

EnumDescription
KEY_ACTION_CANCEL = 0Button action canceled.
KEY_ACTION_DOWN = 1Pressing of a key.
KEY_ACTION_UP = 2Release of a key.

Input_MouseEventAction

enum Input_MouseEventAction

Description

Provides the enum values of mouse actions.

Since: 12

EnumDescription
MOUSE_ACTION_CANCEL = 0Mouse action canceled.
MOUSE_ACTION_MOVE = 1Moving of the mouse pointer.
MOUSE_ACTION_BUTTON_DOWN = 2Pressing of the mouse button.
MOUSE_ACTION_BUTTON_UP = 3Release of the mouse button.
MOUSE_ACTION_AXIS_BEGIN = 4Beginning of the mouse axis event.
MOUSE_ACTION_AXIS_UPDATE = 5Updating of the mouse axis event.
MOUSE_ACTION_AXIS_END = 6End of the mouse axis event.

InputEvent_MouseAxis

enum InputEvent_MouseAxis

Description

Provides the enum values of mouse axis event types.

Since: 12

EnumDescription
MOUSE_AXIS_SCROLL_VERTICAL = 0Vertical scroll axis.
MOUSE_AXIS_SCROLL_HORIZONTAL = 1Horizontal scroll axis.

Input_MouseEventButton

enum Input_MouseEventButton

Description

Provides the enum values of mouse buttons.

Since: 12

EnumDescription
MOUSE_BUTTON_NONE = -1Invalid key.
MOUSE_BUTTON_LEFT = 0Left mouse button.
MOUSE_BUTTON_MIDDLE = 1Middle mouse button.
MOUSE_BUTTON_RIGHT = 2Right mouse button.
MOUSE_BUTTON_FORWARD = 3Mouse forward button.
MOUSE_BUTTON_BACK = 4Mouse back button.

Input_TouchEventAction

enum Input_TouchEventAction

Description

Provides the enum values of touch actions.

Since: 12

EnumDescription
TOUCH_ACTION_CANCEL = 0Cancellation of touch.
TOUCH_ACTION_DOWN = 1Pressing of touch.
TOUCH_ACTION_MOVE = 2Moving of touch.
TOUCH_ACTION_UP = 3Lifting of touch.

InputEvent_SourceType

enum InputEvent_SourceType

Description

Enter the event source type.

Since: 12

EnumDescription
SOURCE_TYPE_MOUSE = 1Source that generates events similar to mouse cursor movement, button press and release, and wheel scrolling.
SOURCE_TYPE_TOUCHSCREEN = 2Source that generates a touchscreen multi-touch event.
SOURCE_TYPE_TOUCHPAD = 3Source that generates a touchpad multi-touch event.

Input_KeyboardType

enum Input_KeyboardType

Description

Provides the enum values of keyboard types of the input device.

Since: 13

EnumDescription
KEYBOARD_TYPE_NONE = 0Keyboard without keys.
KEYBOARD_TYPE_UNKNOWN = 1Keyboard with unknown keys.
KEYBOARD_TYPE_ALPHABETIC = 2Full keyboard.
KEYBOARD_TYPE_DIGITAL = 3Numeric keypad.
KEYBOARD_TYPE_STYLUS = 4Stylus.
KEYBOARD_TYPE_REMOTE_CONTROL = 5Remote control.

Input_Result

enum Input_Result

Description

Provides the enum values of error codes.

Since: 12

EnumDescription
INPUT_SUCCESS = 0Operation succeeded
INPUT_PERMISSION_DENIED = 201Permission verification failed.
INPUT_NOT_SYSTEM_APPLICATION = 202Not a system application.
INPUT_PARAMETER_ERROR = 401Parameter check failed.
INPUT_DEVICE_NOT_SUPPORTED = 801Input device not supported.
Since: 14
INPUT_SERVICE_EXCEPTION = 3800001Service Error
INPUT_REPEAT_INTERCEPTOR = 4200001Interceptor repeatedly created.
INPUT_OCCUPIED_BY_SYSTEM = 4200002Input device occupied by a system application.
Since: 14
INPUT_OCCUPIED_BY_OTHER = 4200003Input device occupied by another application.
Since: 14
INPUT_KEYBOARD_DEVICE_NOT_EXIST = 3900002No keyboard is connected.
Since: 15

Function Description

Input_HotkeyCallback()

typedef void (*Input_HotkeyCallback)(Input_Hotkey* hotkey)

Description

Defines the callback used to return shortcut key events.

Since: 14

Input_KeyEventCallback()

typedef void (*Input_KeyEventCallback)(const Input_KeyEvent* keyEvent)

Description

Defines a lifecycle callback for keyEvent. If the callback is triggered, keyEvent will be destroyed.

Since: 12

Parameters

ParameterDescription
const Input_KeyEvent* keyEventKey event object.

Input_MouseEventCallback()

typedef void (*Input_MouseEventCallback)(const Input_MouseEvent* mouseEvent)

Description

Defines a lifecycle callback for mouseEvent. If the callback is triggered, mouseEvent will be destroyed.

Since: 12

Parameters

ParameterDescription
const Input_MouseEvent* mouseEventMouse event object.

Input_TouchEventCallback()

typedef void (*Input_TouchEventCallback)(const Input_TouchEvent* touchEvent)

Description

Defines a lifecycle callback for touchEvent. If the callback is triggered, touchEvent will be destroyed.

Since: 12

Parameters

ParameterDescription
const Input_TouchEvent* touchEventTouch event object.

Input_AxisEventCallback()

typedef void (*Input_AxisEventCallback)(const Input_AxisEvent* axisEvent)

Description

Defines a lifecycle callback for axisEvent. If the callback is triggered, axisEvent will be destroyed.

Since: 12

Parameters

ParameterDescription
const Input_AxisEvent* axisEventAxis event object.

Input_DeviceAddedCallback()

typedef void (*Input_DeviceAddedCallback)(int32_t deviceId)

Description

Defines a callback used to receive device insertion events.

Since: 13

Parameters

ParameterDescription
int32_t deviceIdDevice ID.

Input_DeviceRemovedCallback()

typedef void (*Input_DeviceRemovedCallback)(int32_t deviceId)

Description

Defines a callback used to receive device removal events.

Since: 13

Parameters

ParameterDescription
int32_t deviceIdDevice ID.

OH_Input_GetKeyState()

Input_Result OH_Input_GetKeyState(struct Input_KeyState* keyState)

Description

Queries a key status enum object.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_KeyState* keyStateKey status enum object. For details, see Input_KeyStateAction.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful;
an error code defined in Input_Result otherwise.

OH_Input_CreateKeyState()

struct Input_KeyState* OH_Input_CreateKeyState()

Description

Creates a key status enum object.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Return value

TypeDescription
structInput_KeyState pointer object if the operation is successful; a null pointer otherwise.

OH_Input_DestroyKeyState()

void OH_Input_DestroyKeyState(struct Input_KeyState** keyState)

Description

Destroys a key status enum object.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_KeyState** keyStateKey status enum object. For details, see Input_KeyStateAction.

OH_Input_SetKeyCode()

void OH_Input_SetKeyCode(struct Input_KeyState* keyState, int32_t keyCode)

Description

Sets the key value of a key status enum object.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_KeyState* keyStateKey status enum object. For details, see Input_KeyStateAction.
int32_t keyCodeKey code.

OH_Input_SetKeyPressed()

void OH_Input_SetKeyPressed(struct Input_KeyState* keyState, int32_t keyAction)

Description

Sets whether the key specific to a key status enum object is pressed.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_KeyState* keyStateKey status enum object. For details, see Input_KeyStateAction.
int32_t keyActionWhether a key is pressed. For details, see Input_KeyEventAction.

OH_Input_SetKeySwitch()

void OH_Input_SetKeySwitch(struct Input_KeyState* keyState, int32_t keySwitch)

Description

Sets the key switch of the key status enum object.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_KeyState* keyStateKey status enum object. For details, see Input_KeyStateAction.
int32_t keySwitchKey switch.

OH_Input_CreateKeyEvent()

struct Input_KeyEvent* OH_Input_CreateKeyEvent()

Description

Creates a key event object.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Return value

TypeDescription
structInput_KeyEvent pointer object if the operation is successful; a null pointer otherwise.

OH_Input_DestroyKeyEvent()

void OH_Input_DestroyKeyEvent(struct Input_KeyEvent** keyEvent)

Description

Destroys a key event object.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_KeyEvent** keyEventKey event object.

OH_Input_SetKeyEventAction()

void OH_Input_SetKeyEventAction(struct Input_KeyEvent* keyEvent, int32_t action)

Description

Sets the key event type.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_KeyEvent* keyEventKey event object.
int32_t actionKey event type.

OH_Input_SetKeyEventKeyCode()

void OH_Input_SetKeyEventKeyCode(struct Input_KeyEvent* keyEvent, int32_t keyCode)

Description

Sets the key code value for a key event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_KeyEvent* keyEventKey event object.
int32_t keyCodeKey value.

OH_Input_SetKeyEventActionTime()

void OH_Input_SetKeyEventActionTime(struct Input_KeyEvent* keyEvent, int64_t actionTime)

Description

Sets the time when a key event occurs.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_KeyEvent* keyEventKey event object.
int64_t actionTimeTime when a key event occurs.

OH_Input_SetKeyEventWindowId()

void OH_Input_SetKeyEventWindowId(struct Input_KeyEvent* keyEvent, int32_t windowId)

Description

Sets the window ID of a key event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 15

Parameters

ParameterDescription
struct Input_KeyEvent* keyEventKey event object.
int32_t windowIdWindow ID of the key event.

OH_Input_SetKeyEventDisplayId()

void OH_Input_SetKeyEventDisplayId(struct Input_KeyEvent* keyEvent, int32_t displayId)

Description

Sets the screen ID of a key event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 15

Parameters

ParameterDescription
struct Input_KeyEvent* keyEventKey event object.
int32_t displayIdScreen ID of the key event.

OH_Input_CreateMouseEvent()

struct Input_MouseEvent* OH_Input_CreateMouseEvent()

Description

Creates a mouse event object.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Return value

TypeDescription
structInput_MouseEvent pointer object if the operation is successful; a null pointer otherwise.

OH_Input_DestroyMouseEvent()

void OH_Input_DestroyMouseEvent(struct Input_MouseEvent** mouseEvent)

Description

Destroys a mouse event object.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_MouseEvent** mouseEventMouse event object.

OH_Input_SetMouseEventAction()

void OH_Input_SetMouseEventAction(struct Input_MouseEvent* mouseEvent, int32_t action)

Description

Sets the action for a mouse event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_MouseEvent* mouseEventMouse event object.
int32_t actionMouse action.

OH_Input_SetMouseEventDisplayX()

void OH_Input_SetMouseEventDisplayX(struct Input_MouseEvent* mouseEvent, int32_t displayX)

Description

Sets the X coordinate for a mouse event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_MouseEvent* mouseEventMouse event object.
int32_t displayXX coordinate on the screen.

OH_Input_SetMouseEventDisplayY()

void OH_Input_SetMouseEventDisplayY(struct Input_MouseEvent* mouseEvent, int32_t displayY)

Description

Sets the Y coordinate for a mouse event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_MouseEvent* mouseEventMouse event object.
int32_t displayYY coordinate on the screen.

OH_Input_SetMouseEventButton()

void OH_Input_SetMouseEventButton(struct Input_MouseEvent* mouseEvent, int32_t button)

Description

Sets the button for a mouse event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_MouseEvent* mouseEventMouse event object.
int32_t buttonMouse button.

OH_Input_SetMouseEventAxisType()

void OH_Input_SetMouseEventAxisType(struct Input_MouseEvent* mouseEvent, int32_t axisType)

Description

Sets the axis type for a mouse event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_MouseEvent* mouseEventMouse event object.
int32_t axisTypeAxis type, for example, X axis or Y axis.

OH_Input_SetMouseEventAxisValue()

void OH_Input_SetMouseEventAxisValue(struct Input_MouseEvent* mouseEvent, float axisValue)

Description

Sets the axis value for a mouse axis event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_MouseEvent* mouseEventMouse event object.
float axisValueAxis value. A positive value means scrolling forward, and a negative number means scrolling backward.

OH_Input_SetMouseEventActionTime()

void OH_Input_SetMouseEventActionTime(struct Input_MouseEvent* mouseEvent, int64_t actionTime)

Description

Sets the time when a mouse event occurs.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_MouseEvent* mouseEventMouse event object.
int64_t actionTimeTime when a mouse event occurs.

OH_Input_SetMouseEventWindowId()

void OH_Input_SetMouseEventWindowId(struct Input_MouseEvent* mouseEvent, int32_t windowId)

Description

Sets the window ID of a mouse event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 15

Parameters

ParameterDescription
struct Input_MouseEvent* mouseEventMouse event object.
int32_t windowIdWindow ID of the mouse event.

OH_Input_SetMouseEventDisplayId()

void OH_Input_SetMouseEventDisplayId(struct Input_MouseEvent* mouseEvent, int32_t displayId)

Description

Sets the screen ID of a mouse event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 15

Parameters

ParameterDescription
struct Input_MouseEvent* mouseEventMouse event object.
int32_t displayIdScreen ID of the mouse event.

OH_Input_CreateTouchEvent()

struct Input_TouchEvent* OH_Input_CreateTouchEvent()

Description

Creates a touch event object.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Return value

TypeDescription
structInput_TouchEvent pointer object if the operation is successful; a null pointer otherwise.

OH_Input_DestroyTouchEvent()

void OH_Input_DestroyTouchEvent(struct Input_TouchEvent** touchEvent)

Description

Destroys a touch event object.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_TouchEvent** touchEventTouch event object.

OH_Input_SetTouchEventAction()

void OH_Input_SetTouchEventAction(struct Input_TouchEvent* touchEvent, int32_t action)

Description

Sets the action for a touch event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_TouchEvent* touchEventTouch event object.
int32_t actionAction of the touch event.

OH_Input_SetTouchEventFingerId()

void OH_Input_SetTouchEventFingerId(struct Input_TouchEvent* touchEvent, int32_t id)

Description

Sets the finger ID for a touch event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_TouchEvent* touchEventTouch event object.
int32_t idFinger ID of a touch event.

OH_Input_SetTouchEventDisplayX()

void OH_Input_SetTouchEventDisplayX(struct Input_TouchEvent* touchEvent, int32_t displayX)

Description

Sets the X coordinate for a touch event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_TouchEvent* touchEventTouch event object.
int32_t displayXX coordinate on the touchscreen.

OH_Input_SetTouchEventDisplayY()

void OH_Input_SetTouchEventDisplayY(struct Input_TouchEvent* touchEvent, int32_t displayY)

Description

Sets the Y coordinate for a touch event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
struct Input_TouchEvent* touchEventTouch event object.
int32_t displayYY coordinate on the touchscreen.

OH_Input_SetTouchEventActionTime()

void OH_Input_SetTouchEventActionTime(struct Input_TouchEvent* touchEvent, int64_t actionTime)

Description

Sets the time when a touch event occurs.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
keyEventTouch event object.
int64_t actionTimeTime when a touch event occurs.

OH_Input_SetTouchEventWindowId()

void OH_Input_SetTouchEventWindowId(struct Input_TouchEvent* touchEvent, int32_t windowId)

Description

Sets the window ID of a touchscreen event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 15

Parameters

ParameterDescription
struct Input_TouchEvent* touchEventTouch event object.
int32_t windowIdWindow ID of the touchscreen event.

OH_Input_SetTouchEventDisplayId()

void OH_Input_SetTouchEventDisplayId(struct Input_TouchEvent* touchEvent, int32_t displayId)

Description

Sets the screen ID of a touchscreen event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 15

Parameters

ParameterDescription
struct Input_TouchEvent* touchEventTouch event object.
int32_t displayIdScreen ID of the touchscreen event.

OH_Input_CancelInjection()

void OH_Input_CancelInjection()

Description

Stops event injection and revokes authorization.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

OH_Input_CreateAxisEvent()

Input_AxisEvent* OH_Input_CreateAxisEvent(void)

Description

Creates an axis event object.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Return value

TypeDescription
Input_AxisEvent*Input_AxisEvent object if the operation is successful; null otherwise.

OH_Input_DestroyAxisEvent()

Input_Result OH_Input_DestroyAxisEvent(Input_AxisEvent** axisEvent)

Description

Destroys an axis event object.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
Input_AxisEvent** axisEventPointer to the axis event object.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; [INPUT_PARAMETER_ERROR] (#input_result) if axisEvent is null.

OH_Input_SetAxisEventAction()

Input_Result OH_Input_SetAxisEventAction(Input_AxisEvent* axisEvent, InputEvent_AxisAction action)

Description

Sets the action for an axis event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
Input_AxisEvent* axisEventAxis event object.
InputEvent_AxisAction actionAxis event action. For details, see InputEvent_AxisAction.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; [INPUT_PARAMETER_ERROR] (#input_result) if axisEvent is null.

OH_Input_GetAxisEventAction()

Input_Result OH_Input_GetAxisEventAction(const Input_AxisEvent* axisEvent, InputEvent_AxisAction *action)

Description

Obtains the action of an axis event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
const Input_AxisEvent* axisEventAxis event object.
InputEvent_AxisAction *actionAxis event action. For details, see InputEvent_AxisAction.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; [INPUT_PARAMETER_ERROR] (#input_result) if axisEvent or action is null.

OH_Input_SetAxisEventDisplayX()

Input_Result OH_Input_SetAxisEventDisplayX(Input_AxisEvent* axisEvent, float displayX)

Description

Sets the X coordinate for an axis event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
Input_AxisEvent* axisEventAxis event object.
float displayXX coordinate of the axis event.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; [INPUT_PARAMETER_ERROR] (#input_result) if axisEvent is null.

OH_Input_GetAxisEventDisplayX()

Input_Result OH_Input_GetAxisEventDisplayX(const Input_AxisEvent* axisEvent, float* displayX)

Description

Obtains the X coordinate of an axis event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
const Input_AxisEvent* axisEventAxis event object.
float* displayXX coordinate of the axis event.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; [INPUT_PARAMETER_ERROR] (#input_result) if axisEvent or displayX is null.

OH_Input_SetAxisEventDisplayY()

Input_Result OH_Input_SetAxisEventDisplayY(Input_AxisEvent* axisEvent, float displayY)

Description

Sets the Y coordinate for an axis event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
Input_AxisEvent* axisEventAxis event object. For details, see Input_AxisEvent.
float displayYY coordinate of the axis event.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; [INPUT_PARAMETER_ERROR] (#input_result) if axisEvent is null.

OH_Input_GetAxisEventDisplayY()

Input_Result OH_Input_GetAxisEventDisplayY(const Input_AxisEvent* axisEvent, float* displayY)

Description

Obtains the Y coordinate of an axis event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
const Input_AxisEvent* axisEventAxis event object. For details, see Input_AxisEvent.
float* displayYY coordinate of the axis event.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; [INPUT_PARAMETER_ERROR] (#input_result) if axisEvent or displayY is null.

OH_Input_SetAxisEventAxisValue()

Input_Result OH_Input_SetAxisEventAxisValue(Input_AxisEvent* axisEvent,InputEvent_AxisType axisType, double axisValue)

Description

Sets the axis value of the axis type specified by the axis event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
Input_AxisEvent* axisEventAxis event object. For details, see Input_AxisEvent.
InputEvent_AxisType axisTypeAxis type. For details, see InputEvent_AxisType.
double axisValueAxis event axis value.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; [INPUT_PARAMETER_ERROR] (#input_result) if axisEvent is null.

OH_Input_GetAxisEventAxisValue()

Input_Result OH_Input_GetAxisEventAxisValue(const Input_AxisEvent* axisEvent,InputEvent_AxisType axisType, double* axisValue)

Description

Obtains the axis value for the specified axis type of the axis event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
const Input_AxisEvent* axisEventAxis event object. For details, see Input_AxisEvent.
InputEvent_AxisType axisTypeAxis type. For details, see InputEvent_AxisType.
double* axisValueAxis value of the axis event.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; [INPUT_PARAMETER_ERROR] (#input_result) if axisEvent or axisValue is null.

OH_Input_SetAxisEventActionTime()

Input_Result OH_Input_SetAxisEventActionTime(Input_AxisEvent* axisEvent, int64_t actionTime)

Description

Sets the time when an axis event occurs.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
Input_AxisEvent* axisEventAxis event object. For details, see Input_AxisEvent.
int64_t actionTimeTime when an event occurs.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; [INPUT_PARAMETER_ERROR] (#input_result) if axisEvent is null.

OH_Input_GetAxisEventActionTime()

Input_Result OH_Input_GetAxisEventActionTime(const Input_AxisEvent* axisEvent, int64_t* actionTime)

Description

Obtains the time when an axis event occurs.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
const Input_AxisEvent* axisEventAxis event object. For details, see Input_AxisEvent.
int64_t* actionTimeTime when an axis event occurs.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; [INPUT_PARAMETER_ERROR] (#input_result) if axisEvent or actionTime is null.

OH_Input_SetAxisEventType()

Input_Result OH_Input_SetAxisEventType(Input_AxisEvent* axisEvent, InputEvent_AxisEventType axisEventType)

Description

Sets the axis event type.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
Input_AxisEvent* axisEventAxis event object. For details, see Input_AxisEvent.
InputEvent_AxisEventType axisEventTypeAxis event type. For details, see InputEvent_AxisEventType.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; [INPUT_PARAMETER_ERROR] (#input_result) if axisEvent is null.

OH_Input_GetAxisEventType()

Input_Result OH_Input_GetAxisEventType(const Input_AxisEvent* axisEvent, InputEvent_AxisEventType* axisEventType)

Description

Obtains the axis event type.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
const Input_AxisEvent* axisEventAxis event object.
InputEvent_AxisEventType* axisEventTypeAxis event type. For details, see InputEvent_AxisEventType.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; [INPUT_PARAMETER_ERROR] (#input_result) if axisEvent or axisEventType is null.

OH_Input_SetAxisEventSourceType()

Input_Result OH_Input_SetAxisEventSourceType(Input_AxisEvent* axisEvent, InputEvent_SourceType sourceType)

Description

Sets the axis event source type.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
Input_AxisEvent* axisEventAxis event object.
InputEvent_SourceType sourceTypeAxis event source type. For details, see InputEvent_SourceType.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; [INPUT_PARAMETER_ERROR] (#input_result) if axisEvent is null.

OH_Input_GetAxisEventSourceType()

Input_Result OH_Input_GetAxisEventSourceType(const Input_AxisEvent* axisEvent, InputEvent_SourceType* sourceType)

Description

Obtains the axis event source type.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 12

Parameters

ParameterDescription
const Input_AxisEvent* axisEventAxis event object.
InputEvent_SourceType* sourceTypeAxis event source type. For details, see InputEvent_SourceType.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; [INPUT_PARAMETER_ERROR] (#input_result) if axisEvent or sourceType is null.

OH_Input_SetAxisEventWindowId()

Input_Result OH_Input_SetAxisEventWindowId(Input_AxisEvent* axisEvent, int32_t windowId)

Description

Sets the window ID of an axis event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 15

Parameters

ParameterDescription
Input_AxisEvent* axisEventAxis event object.
int32_t windowIdWindow ID of the axis event.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; [INPUT_PARAMETER_ERROR] (#input_result) if axisEvent is null.

OH_Input_GetAxisEventWindowId()

Input_Result OH_Input_GetAxisEventWindowId(const Input_AxisEvent* axisEvent, int32_t* windowId)

Description

Obtains the window ID of an axis event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 15

Parameters

ParameterDescription
const Input_AxisEvent* axisEventAxis event object.
int32_t* windowIdWindow ID of the axis event.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; [INPUT_PARAMETER_ERROR] (#input_result) if axisEvent or windowId is null.

OH_Input_SetAxisEventDisplayId()

Input_Result OH_Input_SetAxisEventDisplayId(Input_AxisEvent* axisEvent, int32_t displayId)

Description

Sets the screen ID of an axis event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 15

Parameters

ParameterDescription
Input_AxisEvent* axisEventAxis event object.
int32_t displayIdScreen ID of the axis event.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; [INPUT_PARAMETER_ERROR] (#input_result) if axisEvent is null.

OH_Input_GetAxisEventDisplayId()

Input_Result OH_Input_GetAxisEventDisplayId(const Input_AxisEvent* axisEvent, int32_t* displayId)

Description

Obtains the screen ID of an axis event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 15

Parameters

ParameterDescription
const Input_AxisEvent* axisEventAxis event object.
int32_t* displayIdScreen ID of the axis event.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; [INPUT_PARAMETER_ERROR] (#input_result) if axisEvent or displayId is null.

OH_Input_AddKeyEventMonitor()

Input_Result OH_Input_AddKeyEventMonitor(Input_KeyEventCallback callback)

Description

Adds a listener for key events.

System capability: SystemCapability.MultimodalInput.Input.Core

Required permissions: ohos.permission.INPUT_MONITORING

Since: 12

Parameters

ParameterDescription
Input_KeyEventCallback callbackCallback used to receive key events.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; INPUT_PERMISSION_DENIED if permission verification fails;
INPUT_PARAMETER_ERROR if the callback is empty; INPUT_SERVICE_EXCEPTION if the service is abnormal.

OH_Input_AddMouseEventMonitor()

Input_Result OH_Input_AddMouseEventMonitor(Input_MouseEventCallback callback)

Description

Adds a listener for mouse events, including mouse click and movement events, but not scroll wheel events. Scroll wheel events are axis events.

System capability: SystemCapability.MultimodalInput.Input.Core

Required permissions: ohos.permission.INPUT_MONITORING

Since: 12

Parameters

ParameterDescription
Input_MouseEventCallback callbackCallback used to receive mouse events.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; INPUT_PERMISSION_DENIED if permission verification fails;
INPUT_PARAMETER_ERROR if the callback is empty; INPUT_SERVICE_EXCEPTION if the service is abnormal.

OH_Input_AddTouchEventMonitor()

Input_Result OH_Input_AddTouchEventMonitor(Input_TouchEventCallback callback)

Description

Adds a listener for touch events.

System capability: SystemCapability.MultimodalInput.Input.Core

Required permissions: ohos.permission.INPUT_MONITORING

Since: 12

Parameters

ParameterDescription
Input_TouchEventCallback callbackCallback used to receive touch events.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; INPUT_PERMISSION_DENIED if permission verification fails;
INPUT_PARAMETER_ERROR if the callback is empty; INPUT_SERVICE_EXCEPTION if the service is abnormal.

OH_Input_AddAxisEventMonitorForAll()

Input_Result OH_Input_AddAxisEventMonitorForAll(Input_AxisEventCallback callback)

Description

Adds a listener for all types of axis events, which are defined in InputEvent_AxisEventType.

System capability: SystemCapability.MultimodalInput.Input.Core

Required permissions: ohos.permission.INPUT_MONITORING

Since: 12

Parameters

ParameterDescription
Input_AxisEventCallback callbackCallback used to receive axis events.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; INPUT_PERMISSION_DENIED if permission verification fails;
INPUT_PARAMETER_ERROR if the callback is empty; INPUT_SERVICE_EXCEPTION if the service is abnormal.

OH_Input_AddAxisEventMonitor()

Input_Result OH_Input_AddAxisEventMonitor(InputEvent_AxisEventType axisEventType, Input_AxisEventCallback callback)

Description

Adds a listener for the specified type of axis events, which are defined in InputEvent_AxisEventType.

System capability: SystemCapability.MultimodalInput.Input.Core

Required permissions: ohos.permission.INPUT_MONITORING

Since: 12

Parameters

ParameterDescription
InputEvent_AxisEventType axisEventTypeAxis event type, which is defined in InputEvent_AxisEventType.
Input_AxisEventCallback callbackCallback used to receive the specified type of axis events.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; INPUT_PERMISSION_DENIED if permission verification fails;
INPUT_PARAMETER_ERROR if the callback is empty; INPUT_SERVICE_EXCEPTION if the service is abnormal.

OH_Input_RemoveKeyEventMonitor()

Input_Result OH_Input_RemoveKeyEventMonitor(Input_KeyEventCallback callback)

Description

Removes the listener for key events.

System capability: SystemCapability.MultimodalInput.Input.Core

Required permissions: ohos.permission.INPUT_MONITORING

Since: 12

Parameters

ParameterDescription
Input_KeyEventCallback callbackCallback for key events.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; INPUT_PERMISSION_DENIED if permission verification fails;
[INPUT_PARAMETER_ERROR] (#input_result) if the callback is empty or no listener is added; INPUT_SERVICE_EXCEPTION if the service is abnormal.

OH_Input_RemoveMouseEventMonitor()

Input_Result OH_Input_RemoveMouseEventMonitor(Input_MouseEventCallback callback)

Description

Removes the listener for mouse events.

System capability: SystemCapability.MultimodalInput.Input.Core

Required permissions: ohos.permission.INPUT_MONITORING

Since: 12

Parameters

ParameterDescription
Input_MouseEventCallback callbackCallback for mouse events.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; INPUT_PERMISSION_DENIED if permission verification fails;
[INPUT_PARAMETER_ERROR] (#input_result) if the callback is empty or no listener is added; INPUT_SERVICE_EXCEPTION if the service is abnormal.

OH_Input_RemoveTouchEventMonitor()

Input_Result OH_Input_RemoveTouchEventMonitor(Input_TouchEventCallback callback)

Description

Removes the listener for touch events.

System capability: SystemCapability.MultimodalInput.Input.Core

Required permissions: ohos.permission.INPUT_MONITORING

Since: 12

Parameters

ParameterDescription
Input_TouchEventCallback callbackCallback for touch events.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; INPUT_PERMISSION_DENIED if permission verification fails;
[INPUT_PARAMETER_ERROR] (#input_result) if the callback is empty or no listener is added; INPUT_SERVICE_EXCEPTION if the service is abnormal.

OH_Input_RemoveAxisEventMonitorForAll()

Input_Result OH_Input_RemoveAxisEventMonitorForAll(Input_AxisEventCallback callback)

Description

Removes the listener for all types of axis events.

System capability: SystemCapability.MultimodalInput.Input.Core

Required permissions: ohos.permission.INPUT_MONITORING

Since: 12

Parameters

ParameterDescription
Input_AxisEventCallback callbackCallback for the all types of axis events.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; INPUT_PERMISSION_DENIED if permission verification fails;
[INPUT_PARAMETER_ERROR] (#input_result) if the callback is empty or no listener is added; INPUT_SERVICE_EXCEPTION if the service is abnormal.

OH_Input_RemoveAxisEventMonitor()

Input_Result OH_Input_RemoveAxisEventMonitor(InputEvent_AxisEventType axisEventType, Input_AxisEventCallback callback)

Description

Removes the listener for the specified type of axis events, which are defined in InputEvent_AxisEventType.

System capability: SystemCapability.MultimodalInput.Input.Core

Required permissions: ohos.permission.INPUT_MONITORING

Since: 12

Parameters

ParameterDescription
InputEvent_AxisEventType axisEventTypeAxis event type, which is defined in InputEvent_AxisEventType.
Input_AxisEventCallback callbackCallback for the specified type of axis events.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; INPUT_PERMISSION_DENIED if permission verification fails;
[INPUT_PARAMETER_ERROR] (#input_result) if the callback is empty or no listener is added; INPUT_SERVICE_EXCEPTION if the service is abnormal.

OH_Input_AddKeyEventInterceptor()

Input_Result OH_Input_AddKeyEventInterceptor(Input_KeyEventCallback callback, Input_InterceptorOptions *option)

Description

Adds an interceptor for key events. If multiple interceptors are added, only the first one takes effect. Key events are intercepted only when the application gains focus.

System capability: SystemCapability.MultimodalInput.Input.Core

Required permission: ohos.permission.INTERCEPT_INPUT_EVENT

Since: 12

Parameters

ParameterDescription
Input_KeyEventCallback callbackCallback used to receive key events.
Input_InterceptorOptions *optionOptions for event interception. If null is passed, the default value is used.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; INPUT_PERMISSION_DENIED if permission verification fails;
[INPUT_PARAMETER_ERROR] (#input_result) if the callback is empty or no listener is added; INPUT_REPEAT_INTERCEPTOR if an interceptor is repeatedly added;
INPUT_SERVICE_EXCEPTION if the service is abnormal.

OH_Input_AddInputEventInterceptor()

Input_Result OH_Input_AddInputEventInterceptor(Input_InterceptorEventCallback *callback,Input_InterceptorOptions *option)

Description

Adds an interceptor for input events, including mouse, touch, and axis events. If multiple interceptors are added, only the first one takes effect. Key events are intercepted only when the application window is hit.

System capability: SystemCapability.MultimodalInput.Input.Core

Required permission: ohos.permission.INTERCEPT_INPUT_EVENT

Since: 12

Parameters

ParameterDescription
Input_InterceptorEventCallback *callbackPointer to the structure of the interceptor event callback. For details, see Input_InterceptorEventCallback.
Input_InterceptorOptions *optionOptions for event interception. If null is passed, the default value is used.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; INPUT_PERMISSION_DENIED if permission verification fails;
[INPUT_PARAMETER_ERROR] (#input_result) if the callback is empty or no listener is added; INPUT_REPEAT_INTERCEPTOR if an interceptor is repeatedly added;
INPUT_SERVICE_EXCEPTION if the service is abnormal.

OH_Input_RemoveKeyEventInterceptor()

Input_Result OH_Input_RemoveKeyEventInterceptor(void)

Description

Removes the interceptor for key events.

System capability: SystemCapability.MultimodalInput.Input.Core

Required permission: ohos.permission.INTERCEPT_INPUT_EVENT

Since: 12

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; INPUT_PERMISSION_DENIED if permission verification fails;
[INPUT_SERVICE_EXCEPTION] (#input_result) if the service is abnormal.

OH_Input_RemoveInputEventInterceptor()

Input_Result OH_Input_RemoveInputEventInterceptor(void)

Description

Removes the interceptor for input events, including mouse, touch, and axis events.

System capability: SystemCapability.MultimodalInput.Input.Core

Required permission: ohos.permission.INTERCEPT_INPUT_EVENT

Since: 12

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful; INPUT_PERMISSION_DENIED if permission verification fails;
INPUT_SERVICE_EXCEPTION if the service is abnormal.

OH_Input_GetIntervalSinceLastInput()

Input_Result OH_Input_GetIntervalSinceLastInput(int64_t *timeInterval)

Description

Obtains the interval since the last system input event.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 14

Parameters

ParameterDescription
int64_t *timeIntervalInterval, in microseconds.

Return value

TypeDescription
Input_ResultStatus code of the OH_Input_GetIntervalSinceLastInput function,
INPUT_SUCCESS if the operation is successful; INPUT_SERVICE_EXCEPTION otherwise.

OH_Input_CreateHotkey()

Input_Hotkey *OH_Input_CreateHotkey(void)

Description

Creates a shortcut key object.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 14

Return value

TypeDescription
Input_HotkeyInput_Hotkey pointer if the operation is successful; a null pointer otherwise (possibly because of a memory allocation failure).

OH_Input_DestroyHotkey()

void OH_Input_DestroyHotkey(Input_Hotkey **hotkey)

Description

Destroys a shortcut key object.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 14

Parameters

ParameterDescription
Input_Hotkey **hotkeyShortcut key object.

OH_Input_SetPreKeys()

void OH_Input_SetPreKeys(Input_Hotkey *hotkey, int32_t *preKeys, int32_t size)

Description

Sets the modifier keys.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 14

Parameters

ParameterDescription
Input_Hotkey *hotkeyShortcut key object.
int32_t *preKeysList of modifier keys.
int32_t sizeNumber of modifier keys. One or two modifier keys are supported.

OH_Input_GetPreKeys()

Input_Result OH_Input_GetPreKeys(const Input_Hotkey *hotkey, int32_t **preKeys, int32_t *preKeyCount)

Description

Obtains the modifier key.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 14

Parameters

ParameterDescription
const Input_Hotkey *hotkeyShortcut key object.
int32_t **preKeysList of modifier keys.
int32_t *preKeyCountNumber of modifier keys.

Return value

TypeDescription
Input_ResultStatus code of the OH_Input_GetpressedKeys function, which is
INPUT_SUCCESS if the operation is successful; INPUT_PARAMETER_ERROR otherwise.

OH_Input_SetFinalKey()

void OH_Input_SetFinalKey(Input_Hotkey* hotkey, int32_t finalKey)

Description

Sets the modified key.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 14

Parameters

ParameterDescription
Input_Hotkey* hotkeyShortcut key object.
int32_t finalKeyModifier key value. Only one modifier key value is allowed.

OH_Input_GetFinalKey()

Input_Result OH_Input_GetFinalKey(const Input_Hotkey* hotkey, int32_t *finalKeyCode)

Description

Obtains the modified key.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 14

Parameters

ParameterDescription
const Input_Hotkey* hotkeyShortcut key object.
int32_t *finalKeyCodeModified key.

Return value

TypeDescription
Input_ResultStatus code of the OH_Input_GetfinalKey function, which is
INPUT_SUCCESS if the operation is successful;
INPUT_PARAMETER_ERROR otherwise.

OH_Input_CreateAllSystemHotkeys()

Input_Hotkey **OH_Input_CreateAllSystemHotkeys(int32_t count)

Description

Creates an array of Input_Hotkey instances.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 14

Parameters

ParameterDescription
int32_t countNumber of Input_Hotkey instances.

Return value

TypeDescription
Input_HotkeyOH_Input_CreateAllSystemHotkey status code,
which is INPUT_SUCCESS if the operation is successful.

OH_Input_DestroyAllSystemHotkeys()

void OH_Input_DestroyAllSystemHotkeys(Input_Hotkey **hotkeys, int32_t count)

Description

Destroys the array of Input_Hotkey instances and reclaims the memory.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 14

Parameters

ParameterDescription
Input_Hotkey **hotkeysDouble pointer to the array of Input_Hotkey instances.
int32_t countNumber of Input_Hotkey instances.

OH_Input_GetAllSystemHotkeys()

Input_Result OH_Input_GetAllSystemHotkeys(Input_Hotkey **hotkey, int32_t *count)

Description

Obtains all configured shortcut keys.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 14

Parameters

ParameterDescription
Input_Hotkey **hotkeyArray of Input_Hotkey instances. When calling this API for the first time, you can pass NULL to obtain the array length.
int32_t *countNumber of supported shortcut keys.

Return value

TypeDescription
Input_ResultStatus code of the OH_Input_GetAllSystemHotkeys function, which is
INPUT_SUCCESS if the operation is successful;
INPUT_PARAMETER_ERROR otherwise.

OH_Input_SetRepeat()

void OH_Input_SetRepeat(Input_Hotkey* hotkey, bool isRepeat)

Description

Specifies whether to report repeated key events.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 14

Parameters

ParameterDescription
Input_Hotkey* hotkeyShortcut key object.
bool isRepeatWhether to report repeated key events. The value true means to report repeated key events, and the value false means the opposite.

OH_Input_GetRepeat()

Input_Result OH_Input_GetRepeat(const Input_Hotkey* hotkey, bool *isRepeat)

Description

Checks whether to report repeated key events.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 14

Parameters

ParameterDescription
const Input_Hotkey* hotkeyShortcut key object.
bool *isRepeatWhether the reported key event is repeated.

Return value

TypeDescription
Input_ResultOH_Input_GetIsRepeat status code, specifically,
INPUT_SUCCESS if the operation is successful;
INPUT_PARAMETER_ERROR otherwise.

OH_Input_AddHotkeyMonitor()

Input_Result OH_Input_AddHotkeyMonitor(const Input_Hotkey* hotkey, Input_HotkeyCallback callback)

Description

Subscribes to shortcut key events. This API is not applicable to wearables and lite wearables.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 14

Parameters

ParameterDescription
const Input_Hotkey* hotkeyShortcut key object.
Input_HotkeyCallback callbackDefines the callback used to return shortcut key events.

Return value

TypeDescription
Input_ResultOH_Input_AddHotkeyMonitor status code, specifically,
INPUT_SUCCESS if the operation is successful;
INPUT_PARAMETER_ERROR if parameter verification fails;
INPUT_OCCUPIED_BY_SYSTEM if the shortcut key has been occupied by the system (you can use OH_Input_GetAllSystemHotkeys to query allsystem shortcut keys);
INPUT_OCCUPIED_BY_OTHER if the shortcut key has been occupied by another application;
INPUT_DEVICE_NOT_SUPPORTED if the function is not supported.

OH_Input_RemoveHotkeyMonitor()

Input_Result OH_Input_RemoveHotkeyMonitor(const Input_Hotkey* hotkey, Input_HotkeyCallback callback)

Description

Unsubscribes from shortcut key events.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 14

Parameters

ParameterDescription
const Input_Hotkey* hotkeyShortcut key object.
Input_HotkeyCallback callbackDefines the callback used to return shortcut key events.

Return value

TypeDescription
Input_ResultOH_Input_RemoveHotkeyMonitor status code, specifically,
INPUT_SUCCESS if the operation is successful; INPUT_PARAMETER_ERROR if parameter verification fails.

OH_Input_RegisterDeviceListener()

Input_Result OH_Input_RegisterDeviceListener(Input_DeviceListener* listener)

Description

Registers a listener for device hot swap events.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 13

Parameters

ParameterDescription
Input_DeviceListener* listenerPointer to the Input_DeviceListener object.

Return value

TypeDescription
Input_ResultOH_Input_RegisterDeviceListener status code, specifically:
INPUT_SUCCESS if the operation is successful;
INPUT_PARAMETER_ERROR if the listener is null.

OH_Input_UnregisterDeviceListener()

Input_Result OH_Input_UnregisterDeviceListener(Input_DeviceListener* listener)

Description

Unregisters the listener for device hot swap events.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 13

Parameters

ParameterDescription
Input_DeviceListener* listenerPointer to the Input_DeviceListener object.

Return value

TypeDescription
Input_ResultOH_Input_UnregisterDeviceListener status code, specifically:
INPUT_SUCCESS if the operation is successful;
INPUT_PARAMETER_ERROR if listener is NULL or the listener is not registered;
INPUT_SERVICE_EXCEPTION if the service is abnormal.

OH_Input_UnregisterDeviceListeners()

Input_Result OH_Input_UnregisterDeviceListeners()

Description

Unregisters the listener for all device hot swap events.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 13

Return value

TypeDescription
Input_ResultOH_Input_UnregisterDeviceListener status code, specifically:
INPUT_SUCCESS if the operation is successful;
INPUT_SERVICE_EXCEPTION if the service is abnormal.

OH_Input_GetDeviceIds()

Input_Result OH_Input_GetDeviceIds(int32_t *deviceIds, int32_t inSize, int32_t *outSize)

Description

Obtains the IDs of all input devices.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 13

Parameters

ParameterDescription
int32_t *deviceIdsList of input device IDs.
int32_t inSizeSize of the input device ID list.
int32_t *outSizeLength of the input device ID list. The value must be less than or equal to the value of inSize.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful;
INPUT_PARAMETER_ERROR if deviceIds or outSize is a null pointer or inSize is less than 0.

OH_Input_GetDevice()

Input_Result OH_Input_GetDevice(int32_t deviceId, Input_DeviceInfo **deviceInfo)

Description

Obtains information about the input device.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 13

Parameters

ParameterDescription
int32_t deviceIdDevice ID.
Input_DeviceInfo **deviceInfoPointer to the Input_DeviceInfo object.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful;
INPUT_PARAMETER_ERROR if deviceInfo is a null pointer or deviceId is invalid.
You can use OH_Input_GetDeviceIds to query the device IDs supported by the system.

OH_Input_CreateDeviceInfo()

Input_DeviceInfo* OH_Input_CreateDeviceInfo(void)

Description

Creates a deviceInfo object.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 13

Return value

TypeDescription
Input_DeviceInfo*Pointer to the Input_DeviceInfo object if the operation is successful; a null pointer otherwise (possibly because of a memory allocation failure).

OH_Input_DestroyDeviceInfo()

void OH_Input_DestroyDeviceInfo(Input_DeviceInfo **deviceInfo)

Description

Destroys a deviceInfo object.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 13

Parameters

ParameterDescription
Input_DeviceInfo **deviceInfodeviceInfo object.

OH_Input_GetKeyboardType()

Input_Result OH_Input_GetKeyboardType(int32_t deviceId, int32_t *keyboardType)

Description

Obtains the keyboard type of an input device.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 13

Parameters

ParameterDescription
int32_t deviceIdDevice ID.
int32_t *keyboardTypePointer to the keyboard type of the input device.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful;
INPUT_PARAMETER_ERROR if the device ID is invalid or keyboardType is a null pointer.

OH_Input_GetDeviceId()

Input_Result OH_Input_GetDeviceId(Input_DeviceInfo *deviceInfo, int32_t *id)

Description

Obtains the ID of an input device.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 13

Parameters

ParameterDescription
Input_DeviceInfo *deviceInfoInput device information. For details, see Input_DeviceInfo.
int32_t *idPointer to the input device ID.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful;
INPUT_PARAMETER_ERROR if deviceInfo or id is a null pointer.

OH_Input_GetDeviceName()

Input_Result OH_Input_GetDeviceName(Input_DeviceInfo *deviceInfo, char **name)

Description

Obtains the name of an input device.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 13

Parameters

ParameterDescription
Input_DeviceInfo *deviceInfoInput device information. For details, see Input_DeviceInfo.
char **namePointer to the input device name.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful;
INPUT_PARAMETER_ERROR if deviceInfo or name is a null pointer.

OH_Input_GetCapabilities()

Input_Result OH_Input_GetCapabilities(Input_DeviceInfo *deviceInfo, int32_t *capabilities)

Description

Obtains the capabilities of an input device, for example, a touchscreen, touchpad, or keyboard.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 13

Parameters

ParameterDescription
Input_DeviceInfo *deviceInfoInput device information. For details, see Input_DeviceInfo.
int32_t *capabilitiesPointer to the capability information of the input device.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful;
INPUT_PARAMETER_ERROR if deviceInfo or capabilities is a null pointer.

OH_Input_GetDeviceVersion()

Input_Result OH_Input_GetDeviceVersion(Input_DeviceInfo *deviceInfo, int32_t *version)

Description

Obtains the version information of an input device.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 13

Parameters

ParameterDescription
Input_DeviceInfo *deviceInfoInput device information. For details, see Input_DeviceInfo.
int32_t *versionPointer to the version information of the input device.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful;
INPUT_PARAMETER_ERROR if deviceInfo or version is a null pointer.

OH_Input_GetDeviceProduct()

Input_Result OH_Input_GetDeviceProduct(Input_DeviceInfo *deviceInfo, int32_t *product)

Description

Obtains the product information of an input device.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 13

Parameters

ParameterDescription
Input_DeviceInfo *deviceInfoInput device information. For details, see Input_DeviceInfo.
int32_t *productPointer to the product information of the input device.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful;
INPUT_PARAMETER_ERROR if deviceInfo or product is a null pointer.

OH_Input_GetDeviceVendor()

Input_Result OH_Input_GetDeviceVendor(Input_DeviceInfo *deviceInfo, int32_t *vendor)

Description

Obtains the vendor information of an input device.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 13

Parameters

ParameterDescription
Input_DeviceInfo *deviceInfoInput device information. For details, see Input_DeviceInfo.
int32_t *vendorPointer to the vendor information of the input device.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful;
INPUT_PARAMETER_ERROR if deviceInfo or vendor is a null pointer.

OH_Input_GetDeviceAddress()

Input_Result OH_Input_GetDeviceAddress(Input_DeviceInfo *deviceInfo, char **address)

Description

Obtains the physical address of an input device.

System capability: SystemCapability.MultimodalInput.Input.Core

Since: 13

Parameters

ParameterDescription
Input_DeviceInfo *deviceInfoInput device information. For details, see Input_DeviceInfo.
char **addressPointer to the physical address of the input device.

Return value

TypeDescription
Input_ResultINPUT_SUCCESS if the operation is successful;
INPUT_PARAMETER_ERROR if deviceInfo or address is a null pointer.

OH_Input_GetFunctionKeyState()

Input_Result OH_Input_GetFunctionKeyState(int32_t keyCode, int32_t *state)

Description

Obtains the function key status.

Since: 15

Parameters

ParameterDescription
int32_t keyCodeFunction key. Only the CapsLock key is supported.
int32_t *stateFunction key status. The value 0 indicates that the function key is disabled, and the value 1 indicates that the function key is enabled.

Return value

TypeDescription
Input_ResultOH_Input_GetFunctionKeyState status code, specifically:
INPUT_SUCCESS if the operation is successful;
INPUT_PARAMETER_ERROR if the parameter is incorrect;
{@link INPUT_DEVICE_NOT_EXIST } if the keyboard does not exist.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Input Kit

harmony 鸿蒙Input_DeviceListener

harmony 鸿蒙Input_InterceptorEventCallback

harmony 鸿蒙Input_AxisEvent

harmony 鸿蒙Input_DeviceInfo

harmony 鸿蒙Input_DeviceListener

harmony 鸿蒙Input_Hotkey

harmony 鸿蒙Input_InterceptorEventCallback

harmony 鸿蒙Input_InterceptorOptions

harmony 鸿蒙Input_KeyEvent

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/REr6TT