diff --git a/multimodalinput/kits/c/input/oh_input_manager.h b/multimodalinput/kits/c/input/oh_input_manager.h index 7d02e48a13a8aa3d7c3b540c7a2fb0eeacc00d2c..99ed777202da1fe817c30acab7d59c3e3798774c 100644 --- a/multimodalinput/kits/c/input/oh_input_manager.h +++ b/multimodalinput/kits/c/input/oh_input_manager.h @@ -61,6 +61,66 @@ enum Input_KeyStateAction { KEY_SWITCH_OFF = 3 }; +/** + * @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, + /** Pressing down of the mouse touch pad. */ + MOUSE_ACTION_ACTION_DOWN = 4, + /** Lifting of the mouse touch pad. */ + MOUSE_ACTION_ACTION_UP = 5 +} Input_MouseEventAction; + +/** + * @brief Enumerated values of mouse event button. + * + * @since 12 + */ +typedef enum { + /** 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, + /** Side button on the mouse. */ + MOUSE_BUTTON_SIDE = 3, + /** Extended button on the mouse. */ + MOUSE_BUTTON_EXTRA = 4, + /** Forward button on the mouse. */ + MOUSE_BUTTON_FORWARD = 5, + /** Back button on the mouse. */ + MOUSE_BUTTON_BACK = 6, + /** Task key on the mouse. */ + MOUSE_BUTTON_TASK = 7 +} 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 +128,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. * @@ -107,16 +188,16 @@ struct Input_KeyState* OH_Input_CreateKeyState(); /** * @brief Destroys a key status enumeration object. - * + * * @param keyState Key status enumeration object. * @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. - * + * * @param keyState Key status enumeration object. * @param keyCode Key value of the key status enumeration object. * @syscap SystemCapability.MultimodalInput.Input.Core @@ -126,7 +207,7 @@ void OH_Input_SetKeyCode(struct Input_KeyState* keyState, int32_t keyCode); /** * @brief Obtains the key value of a key status enumeration object. - * + * * @param keyState Key status enumeration object. * @return Key value of the key status enumeration object. * @syscap SystemCapability.MultimodalInput.Input.Core @@ -136,7 +217,7 @@ int32_t OH_Input_GetKeyCode(struct Input_KeyState* keyState); /** * @brief Sets whether the key specific to a key status enumeration object is pressed. - * + * * @param keyState Key status enumeration object. * @param keyAction Whether the key is pressed. * @syscap SystemCapability.MultimodalInput.Input.Core @@ -146,7 +227,7 @@ void OH_Input_SetKeyPressed(struct Input_KeyState* keyState, int32_t keyAction); /** * @brief Checks whether the key specific to a key status enumeration object is pressed. - * + * * @param keyState Key status enumeration object. * @return Key pressing status of the key status enumeration object. * @syscap SystemCapability.MultimodalInput.Input.Core @@ -156,7 +237,7 @@ int32_t OH_Input_GetKeyPressed(struct Input_KeyState* keyState); /** * @brief Sets the key switch of the key status enumeration object. - * + * * @param keyState Key status enumeration object. * @param keySwitch Key switch of the key status enumeration object. * @syscap SystemCapability.MultimodalInput.Input.Core @@ -166,7 +247,7 @@ void OH_Input_SetKeySwitch(struct Input_KeyState* keyState, int32_t keySwitch); /** * @brief Obtains the key switch of the key status enumeration object. - * + * * @param keyState Key status enumeration object. * @return Key switch of the key status enumeration object. * @syscap SystemCapability.MultimodalInput.Input.Core @@ -174,6 +255,341 @@ void OH_Input_SetKeySwitch(struct Input_KeyState* keyState, int32_t keySwitch); */ int32_t OH_Input_GetKeySwitch(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. + * @permission systemapi hide for inner use + * @syscap SystemCapability.MultimodalInput.Input.InputSimulator + * @since 12 + */ +int32_t OH_Input_InjectKeyEvent(struct Input_KeyEvent* keyEvent); + +/** + * @brief 创建按键事件对象 + * + * @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 销毁按键事件对象 + * + * @param keyEvent 按键事件对象 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_DestroyKeyEvent(struct Input_KeyEvent** keyEvent); + +/** + * @brief 设置按键事件的是否按下 + * + * @param keyEvent 按键事件对象 + * @param isPressed 按键是否按下 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetKeyEventIsPressed(struct Input_KeyEvent* keyEvent, bool isPressed); + +/** + * @brief 获取按键事件的是否按下 + * + * @param keyEvent 按键事件对象 + * @return 按键是否按下 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +bool OH_Input_GetKeyEventIsPressed(struct Input_KeyEvent* keyEvent); + +/** + * @brief 设置按键事件的键值 + * + * @param keyEvent 按键事件对象 + * @param keyCode 按键的键值 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetKeyEventKeyCode(struct Input_KeyEvent* keyEvent, int32_t keyCode); + +/** + * @brief 获取按键事件的键值 + * + * @param keyEvent 按键事件对象 + * @return 按键的键值 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_GetKeyEventKeyCode(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. + * @permission systemapi hide for inner use + * @syscap SystemCapability.MultimodalInput.Input.InputSimulator + * @since 12 + */ +int32_t OH_Input_InjectMouseEvent(struct Input_MouseEvent* mouseEvent); + +/** + * @brief 创建鼠标事件对象 + * + * @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 销毁鼠标事件对象 + * + * @param mouseEvent 鼠标事件对象 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_DestroyMouseEvent(struct Input_MouseEvent** mouseEvent); + +/** + * @brief 设置鼠标事件的动作 + * + * @param mouseEvent 鼠标事件对象 + * @param action 鼠标的动作 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetMouseEventAction(struct Input_MouseEvent* mouseEvent, int32_t action); + +/** + * @brief 获取鼠标事件的动作 + * + * @param mouseEvent 鼠标事件对象 + * @return 鼠标的动作 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_GetMouseEventAction(struct Input_MouseEvent* mouseEvent); + +/** + * @brief 设置鼠标事件的屏幕横坐标 + * + * @param mouseEvent 鼠标事件对象 + * @param screenX 屏幕横坐标 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetMouseEventScreenX(struct Input_MouseEvent* mouseEvent, int32_t screenX); + +/** + * @brief 获取鼠标事件的屏幕横坐标 + * + * @param mouseEvent 鼠标事件对象 + * @return 屏幕横坐标 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_GetMouseEventScreenX(struct Input_MouseEvent* mouseEvent); + +/** + * @brief 设置鼠标事件的屏幕纵坐标 + * + * @param mouseEvent 鼠标事件对象 + * @param screenY 屏幕纵坐标 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetMouseEventScreenY(struct Input_MouseEvent* mouseEvent, int32_t screenY); + +/** + * @brief 获取鼠标事件的屏幕纵坐标 + * + * @param mouseEvent 鼠标事件对象 + * @return 屏幕纵坐标 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_GetMouseEventScreenY(struct Input_MouseEvent* mouseEvent); + +/** + * @brief 设置鼠标事件的按键 + * + * @param mouseEvent 鼠标事件对象 + * @param button 按键 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetMouseEventButton(struct Input_MouseEvent* mouseEvent, int32_t button); + +/** + * @brief 获取鼠标事件的屏幕按键 + * + * @param mouseEvent 鼠标事件对象 + * @return 按键 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_GetMouseEventButton(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. + * @permission systemapi hide for inner use + * @syscap SystemCapability.MultimodalInput.Input.InputSimulator + * @since 12 + */ +int32_t OH_Input_InjectTouchEvent(struct Input_TouchEvent* touchEvent); + +/** + * @brief 创建触屏事件对象 + * + * @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 销毁触屏事件对象 + * + * @param touchEvent 触屏事件对象 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_DestroyTouchEvent(struct Input_TouchEvent** touchEvent); + +/** + * @brief 设置触屏事件的动作 + * + * @param touchEvent 触屏事件对象 + * @param action 触屏的动作 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetTouchEventAction(struct Input_TouchEvent* touchEvent, int32_t action); + +/** + * @brief 获取触屏事件的动作 + * + * @param touchEvent 触屏事件对象 + * @return 触屏的动作 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_GetTouchEventAction(struct Input_TouchEvent* touchEvent); + +/** + * @brief 设置触屏事件的手指ID + * + * @param touchEvent 触屏事件对象 + * @param id 触屏的手指ID + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetTouchEventId(struct Input_TouchEvent* touchEvent, int32_t id); + +/** + * @brief 获取触屏事件的手指ID + * + * @param touchEvent 触屏事件对象 + * @return 触屏的手指ID + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_GetTouchEventId(struct Input_TouchEvent* touchEvent); + +/** + * @brief 设置触屏事件的屏幕横坐标 + * + * @param touchEvent 触屏事件对象 + * @param screenX 触屏的屏幕横坐标 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetTouchEventScreenX(struct Input_TouchEvent* touchEvent, int32_t screenX); + +/** + * @brief 获取触屏事件的屏幕横坐标 + * + * @param touchEvent 触屏事件对象 + * @return 触屏的屏幕横坐标 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_GetTouchEventScreenX(struct Input_TouchEvent* touchEvent); + +/** + * @brief 设置触屏事件的屏幕纵坐标 + * + * @param touchEvent 触屏事件对象 + * @param screenY 触屏的屏幕纵坐标 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetTouchEventScreenY(struct Input_TouchEvent* touchEvent, int32_t screenY); + +/** + * @brief 获取触屏事件的屏幕纵坐标 + * + * @param touchEvent 触屏事件对象 + * @return 触屏的屏幕纵坐标 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +int32_t OH_Input_GetTouchEventScreenY(struct Input_TouchEvent* touchEvent); + +/** + * @brief 设置触屏事件的手指压力 + * + * @param touchEvent 触屏事件对象 + * @param pressure 触屏的手指压力 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_SetTouchEventPressure(struct Input_TouchEvent* touchEvent, double pressure); + +/** + * @brief 获取触屏事件的手指压力 + * + * @param touchEvent 触屏事件对象 + * @return 触屏的手指压力 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +double OH_Input_GetTouchEventPressure(struct Input_TouchEvent* touchEvent); + +/** + * @brief 取消注入 + * + * @HTTP4O4 Returns {@Link Input_Result#INPUT_SUCCESS} if the operation is successful; + * returns an error code defined in {@Link Input_Result} otherwise. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_CancelInjection(); + +/** + * @brief 授权权限,只有授权hap可以调用 + * + * @param isAuthorize 是否同意授权 + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +void OH_Input_Authorize(bool isAuthorize); + #ifdef __cplusplus } #endif diff --git a/multimodalinput/kits/c/ohinput.ndk.json b/multimodalinput/kits/c/ohinput.ndk.json index 137265940516a56ad1120c613e8bb2cf0e1f494a..23b28c4f729a0cae257d8c9769515ebf958979d2 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,137 @@ { "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_SetKeyEventIsPressed" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetKeyEventIsPressed" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetKeyEventKeyCode" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetKeyEventKeyCode" + }, + { + "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_SetMouseEventScreenX" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetMouseEventScreenX" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetMouseEventScreenY" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetMouseEventScreenY" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetMouseEventButton" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetMouseEventButton" + }, + { + "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_SetTouchEventID" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetTouchEventID" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetTouchEventScreenX" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetTouchEventScreenX" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetTouchEventScreenY" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetTouchEventScreenY" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetTouchEventPressure" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetTouchEventPressure" + }, + { + "first_introduced": "12", + "name": "OH_Input_CancelInjection" + }, + { + "first_introduced": "12", + "name": "OH_Input_Authorize" } ] \ No newline at end of file