diff --git a/multimodalinput/kits/c/input/oh_input_manager.h b/multimodalinput/kits/c/input/oh_input_manager.h index 7d02e48a13a8aa3d7c3b540c7a2fb0eeacc00d2c..741b24091da48664eb934313119a7348a9c01a4f 100644 --- a/multimodalinput/kits/c/input/oh_input_manager.h +++ b/multimodalinput/kits/c/input/oh_input_manager.h @@ -61,6 +61,90 @@ enum Input_KeyStateAction { KEY_SWITCH_OFF = 3 }; +/** + * @brief Enumerates key event types. + * + * @since 12 + */ +typedef enum { + /** Cancellation of a key action. */ + KEY_ACTION_CANCEL = 0, + /** Pressing of a key. */ + KEY_ACTION_DOWN = 1, + /** Release of a key. */ + KEY_ACTION_UP = 2, +} Input_KeyEventAction; + +/** + * @brief Enumerated values of mouse event action. + * + * @since 12 + */ +typedef enum { + /** Cancel. */ + MOUSE_ACTION_CANCEL = 0, + /** Moving of the mouse pointer. */ + MOUSE_ACTION_MOVE = 1, + /** Pressing down of the mouse. */ + MOUSE_ACTION_BUTTON_DOWN = 2, + /** Lifting of the mouse button. */ + MOUSE_ACTION_BUTTON_UP = 3, + /** Beginning of the mouse axis event */ + MOUSE_ACTION_AXIS_BEGIN = 4, + /** Updating of the mouse axis event */ + MOUSE_ACTION_AXIS_UPDATE = 5, + /** End of the mouse axis event */ + MOUSE_ACTION_AXIS_END = 6, +} Input_MouseEventAction; + +/** + * @brief Mouse axis types. + * + * @since 12 + */ +enum InputEvent_MouseAxis { + /** Vertical scroll axis */ + MOUSE_AXIS_SCROLL_VERTICAL = 0, + /** Horizontal scroll axis */ + MOUSE_AXIS_SCROLL_HORIZONTAL = 1, +}; + +/** + * @brief Enumerated values of mouse event button. + * + * @since 12 + */ +typedef enum { + /** Invalid button */ + MOUSE_BUTTON_NONE = -1, + /** Left button on the mouse. */ + MOUSE_BUTTON_LEFT = 0, + /** Middle button on the mouse. */ + MOUSE_BUTTON_MIDDLE = 1, + /** Right button on the mouse. */ + MOUSE_BUTTON_RIGHT = 2, + /** Forward button on the mouse. */ + MOUSE_BUTTON_FORWARD = 3, + /** Back button on the mouse. */ + MOUSE_BUTTON_BACK = 4, +} Input_MouseEventButton; + +/** + * @brief Enumerated values of touch event action. + * + * @since 12 + */ +typedef enum { + /** Touch cancelled. */ + TOUCH_ACTION_CANCEL = 0, + /** Touch pressed. */ + TOUCH_ACTION_DOWN = 1, + /** Touch moved. */ + TOUCH_ACTION_MOVE = 2, + /** Touch lifted. */ + TOUCH_ACTION_UP = 3, +} Input_TouchEventAction; + /** * @brief Defines key information, which identifies a key pressing behavior. For example, the Ctrl key information contains the key value and key type. * @@ -68,6 +152,27 @@ enum Input_KeyStateAction { */ struct Input_KeyState; +/** + * @brief The key event to be injected. + * + * @since 12 + */ +struct Input_KeyEvent; + +/** + * @brief The mouse event to be injected. + * + * @since 12 + */ +struct Input_MouseEvent; + +/** + * @brief The touch event to be injected. + * + * @since 12 + */ +struct Input_TouchEvent; + /** * @brief Enumerates the error codes. * @@ -112,7 +217,7 @@ struct Input_KeyState* OH_Input_CreateKeyState(); * @syscap SystemCapability.MultimodalInput.Input.Core * @since 12 */ -void OH_Input_DestroyKeyState(struct Input_KeyState* keyState); +void OH_Input_DestroyKeyState(struct Input_KeyState** keyState); /** * @brief Sets the key value of a key status enumeration object. @@ -132,7 +237,7 @@ void OH_Input_SetKeyCode(struct Input_KeyState* keyState, int32_t keyCode); * @syscap SystemCapability.MultimodalInput.Input.Core * @since 12 */ -int32_t OH_Input_GetKeyCode(struct Input_KeyState* keyState); +int32_t OH_Input_GetKeyCode(const struct Input_KeyState* keyState); /** * @brief Sets whether the key specific to a key status enumeration object is pressed. @@ -152,7 +257,7 @@ void OH_Input_SetKeyPressed(struct Input_KeyState* keyState, int32_t keyAction); * @syscap SystemCapability.MultimodalInput.Input.Core * @since 12 */ -int32_t OH_Input_GetKeyPressed(struct Input_KeyState* keyState); +int32_t OH_Input_GetKeyPressed(const struct Input_KeyState* keyState); /** * @brief Sets the key switch of the key status enumeration object. @@ -172,7 +277,408 @@ void OH_Input_SetKeySwitch(struct Input_KeyState* keyState, int32_t keySwitch); * @syscap SystemCapability.MultimodalInput.Input.Core * @since 12 */ -int32_t OH_Input_GetKeySwitch(struct Input_KeyState* keyState); +int32_t OH_Input_GetKeySwitch(const struct Input_KeyState* keyState); + +/** + * @brief Inject system keys. + * + * @param keyEvent - the key event to be injected. + * @return 0 - Success. + * 201 - Missing permissions. + * 401 - Parameter error. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_InjectKeyEvent(const struct Input_KeyEvent* keyEvent); + +/** + * @brief Creates a key event object. + * + * @return Returns an {@link Input_KeyEvent} pointer object if the operation is successful. + * returns a null pointer otherwise. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +struct Input_KeyEvent* OH_Input_CreateKeyEvent(); + +/** + * @brief Destroys a key event object. + * + * @param keyEvent Key event object. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_DestroyKeyEvent(struct Input_KeyEvent** keyEvent); + +/** + * @brief Sets the key event type. + * + * @param keyEvent Key event object. + * @param action Key event type. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetKeyEventAction(struct Input_KeyEvent* keyEvent, int32_t action); + +/** + * @brief Obtains the key event type. + * + * @param keyEvent Key event object. + * @return Key event type. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_GetKeyEventAction(const struct Input_KeyEvent* keyEvent); + +/** + * @brief Sets the key value for a key event. + * + * @param keyEvent Key event object. + * @param keyCode keyCode Key code. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetKeyEventKeyCode(struct Input_KeyEvent* keyEvent, int32_t keyCode); + +/** + * @brief Obtains the key value of a key event. + * + * @param keyEvent Key event object. + * @return Key code. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_GetKeyEventKeyCode(const struct Input_KeyEvent* keyEvent); + +/** + * @brief Sets the time when a key event occurs. + * + * @param keyEvent Key event object. + * @param actionTime Time when the key event occurs. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetKeyEventActionTime(struct Input_KeyEvent* keyEvent, int64_t actionTime); + +/** + * @brief Obtains the time when a key event occurs. + * + * @param keyEvent Key event object. + * @return Returns the time when the key event occurs. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int64_t OH_Input_GetKeyEventActionTime(const struct Input_KeyEvent* keyEvent); + +/** + * @brief Inject mouse event. + * + * @param mouseEvent - the mouse event to be injected. + * @return 0 - Success. + * 201 - Missing permissions. + * 401 - Parameter error. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_InjectMouseEvent(const struct Input_MouseEvent* mouseEvent); + +/** + * @brief Creates a mouse event object. + * + * @return Returns an {@link Input_MouseEvent} pointer object if the operation is successful. + * returns a null pointer otherwise. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +struct Input_MouseEvent* OH_Input_CreateMouseEvent(); + +/** + * @brief Destroys a mouse event object. + * + * @param mouseEvent Mouse event object. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_DestroyMouseEvent(struct Input_MouseEvent** mouseEvent); + +/** + * @brief Sets the action for a mouse event. + * + * @param mouseEvent Mouse event object. + * @param action Mouse action. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetMouseEventAction(struct Input_MouseEvent* mouseEvent, int32_t action); + +/** + * @brief Obtains the action of a mouse event. + * + * @param mouseEvent Mouse event object. + * @return Mouse action. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_GetMouseEventAction(const struct Input_MouseEvent* mouseEvent); + +/** + * @brief Sets the X coordinate for a mouse event. + * + * @param mouseEvent Mouse event object. + * @param displayX X coordinate on the display. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetMouseEventDisplayX(struct Input_MouseEvent* mouseEvent, int32_t displayX); + +/** + * @brief Obtains the X coordinate of a mouse event. + * + * @param mouseEvent Mouse event object. + * @return X coordinate on the display. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_GetMouseEventDisplayX(const struct Input_MouseEvent* mouseEvent); + +/** + * @brief Sets the Y coordinate for a mouse event. + * + * @param mouseEvent Mouse event object. + * @param displayY Y coordinate on the display. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetMouseEventDisplayY(struct Input_MouseEvent* mouseEvent, int32_t displayY); + +/** + * @brief Obtains the Y coordinate of a mouse event. + * + * @param mouseEvent Mouse event object. + * @return Y coordinate on the display. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_GetMouseEventDisplayY(const struct Input_MouseEvent* mouseEvent); + +/** + * @brief Sets the button for a mouse event. + * + * @param mouseEvent Mouse event object. + * @param button Mouse button. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetMouseEventButton(struct Input_MouseEvent* mouseEvent, int32_t button); + +/** + * @brief Obtains the button of a mouse event. + * + * @param mouseEvent Mouse event object. + * @return Mouse button. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_GetMouseEventButton(const struct Input_MouseEvent* mouseEvent); + +/** + * @brief Sets the axis type for mouse event. + * + * @param mouseEvent Mouse event object. + * @param axisType Axis type, for example, X axis or Y axis. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetMouseEventAxisType(struct Input_MouseEvent* mouseEvent, int32_t axisType); + +/** + * @brief Obtains the axis type of a mouse event. + * + * @param mouseEvent Mouse event object. + * @return Axis type. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_GetMouseEventAxisType(const struct Input_MouseEvent* mouseEvent); + +/** + * @brief Sets the axis value for a mouse axis event. + * + * @param mouseEvent Mouse event object. + * @param axisType Axis value. A positive value means scrolling forward, and a negative number means scrolling backward. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetMouseEventAxisValue(struct Input_MouseEvent* mouseEvent, float axisValue); + +/** + * @brief Obtains the axis value of a mouse event. + * + * @param mouseEvent Mouse event object. + * @return Axis value. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +float OH_Input_GetMouseEventAxisValue(const struct Input_MouseEvent* mouseEvent); + +/** + * @brief Sets the time when a mouse event occurs. + * + * @param mouseEvent Mouse event object. + * @param actionTime Time when the mouse event occurs. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetMouseEventActionTime(struct Input_MouseEvent* mouseEvent, int64_t actionTime); + +/** + * @brief Obtains the time when a mouse event occurs. + * + * @param keyEvent Mouse event object. + * @return Returns the time when the mouse event occurs. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int64_t OH_Input_GetMouseEventActionTime(const struct Input_MouseEvent* mouseEvent); + +/** + * @brief Inject touch event. + * + * @param touchEvent - the touch event to be injected. + * @return 0 - Success. + * 201 - Missing permissions. + * 401 - Parameter error. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_InjectTouchEvent(const struct Input_TouchEvent* touchEvent); + +/** + * @brief Creates a touch event object. + * + * @return Returns an {@link Input_TouchEvent} pointer object if the operation is successful. + * returns a null pointer otherwise. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +struct Input_TouchEvent* OH_Input_CreateTouchEvent(); + +/** + * @brief Destroys a touch event object. + * + * @param touchEvent Touch event object. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_DestroyTouchEvent(struct Input_TouchEvent** touchEvent); + +/** + * @brief Sets the action for a touch event. + * + * @param touchEvent Touch event object. + * @param action Touch action. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetTouchEventAction(struct Input_TouchEvent* touchEvent, int32_t action); + +/** + * @brief Obtains the action of a touch event. + * + * @param touchEvent Touch event object. + * @return Touch action. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_GetTouchEventAction(const struct Input_TouchEvent* touchEvent); + +/** + * @brief Sets the finger ID for the touch event. + * + * @param touchEvent Touch event object. + * @param id Finger ID. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetTouchEventFingerId(struct Input_TouchEvent* touchEvent, int32_t id); + +/** + * @brief Obtains the finger ID of a touch event. + * + * @param touchEvent Touch event object. + * @return Finger ID. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_GetTouchEventFingerId(const struct Input_TouchEvent* touchEvent); + +/** + * @brief Sets the X coordinate for a touch event. + * + * @param touchEvent Touch event object. + * @param displayX X coordinate. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetTouchEventDisplayX(struct Input_TouchEvent* touchEvent, int32_t displayX); + +/** + * @brief Obtains the X coordinate of a touch event. + * + * @param touchEvent Touch event object. + * @return X coordinate. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_GetTouchEventDisplayX(const struct Input_TouchEvent* touchEvent); + +/** + * @brief Sets the Y coordinate for a touch event. + * + * @param touchEvent Touch event object. + * @param displayY Y coordinate. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetTouchEventDisplayY(struct Input_TouchEvent* touchEvent, int32_t displayY); + +/** + * @brief Obtains the Y coordinate of a touch event. + * + * @param touchEvent Touch event object. + * @return Y coordinate. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_GetTouchEventDisplayY(const struct Input_TouchEvent* touchEvent); + +/** + * @brief Sets the time when a touch event occurs. + * + * @param keyEvent Touch event object. + * @param actionTime Time when the touch event occurs. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetTouchEventActionTime(struct Input_TouchEvent* touchEvent, int64_t actionTime); + +/** + * @brief Obtains the time when a touch event occurs. + * + * @param keyEvent touch event object. + * @return Returns the time when the touch event occurs. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int64_t OH_Input_GetTouchEventActionTime(const struct Input_TouchEvent* touchEvent); + +/** + * @brief Cancels event injection and revokes authorization. + * + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_CancelInjection(); #ifdef __cplusplus } diff --git a/multimodalinput/kits/c/ohinput.ndk.json b/multimodalinput/kits/c/ohinput.ndk.json index 137265940516a56ad1120c613e8bb2cf0e1f494a..cc28eac475c5554d3edf45fa448698accea8275e 100644 --- a/multimodalinput/kits/c/ohinput.ndk.json +++ b/multimodalinput/kits/c/ohinput.ndk.json @@ -15,7 +15,7 @@ "first_introduced": "12", "name": "OH_Input_SetKeyCode" }, - { + { "first_introduced": "12", "name": "OH_Input_GetKeyCode" }, @@ -34,5 +34,165 @@ { "first_introduced": "12", "name": "OH_Input_GetKeySwitch" + }, + { + "first_introduced": "12", + "name": "OH_Input_InjectKeyEvent" + }, + { + "first_introduced": "12", + "name": "OH_Input_CreateKeyEvent" + }, + { + "first_introduced": "12", + "name": "OH_Input_DestroyKeyEvent" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetKeyEventAction" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetKeyEventAction" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetKeyEventKeyCode" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetKeyEventKeyCode" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetKeyEventActionTime" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetKeyEventActionTime" + }, + { + "first_introduced": "12", + "name": "OH_Input_InjectMouseEvent" + }, + { + "first_introduced": "12", + "name": "OH_Input_CreateMouseEvent" + }, + { + "first_introduced": "12", + "name": "OH_Input_DestroyMouseEvent" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetMouseEventAction" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetMouseEventAction" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetMouseEventDisplayX" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetMouseEventDisplayX" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetMouseEventDisplayY" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetMouseEventDisplayY" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetMouseEventButton" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetMouseEventButton" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetMouseEventAxisType" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetMouseEventAxisType" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetMouseEventAxisValue" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetMouseEventAxisValue" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetMouseEventActionTime" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetMouseEventActionTime" + }, + { + "first_introduced": "12", + "name": "OH_Input_InjectTouchEvent" + }, + { + "first_introduced": "12", + "name": "OH_Input_CreateTouchEvent" + }, + { + "first_introduced": "12", + "name": "OH_Input_DestroyTouchEvent" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetTouchEventAction" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetTouchEventAction" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetTouchEventFingerId" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetTouchEventFingerId" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetTouchEventDisplayX" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetTouchEventDisplayX" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetTouchEventDisplayY" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetTouchEventDisplayY" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetTouchEventActionTime" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetTouchEventActionTime" + }, + { + "first_introduced": "12", + "name": "OH_Input_CancelInjection" } ] \ No newline at end of file