diff --git a/multimodalinput/kits/c/input/oh_input_manager.h b/multimodalinput/kits/c/input/oh_input_manager.h index 10da9574b5cd30f966a9a6bacb5d6e7668337a36..008b26dd5f600cf850b27e83bc73ddbaa0e8bb68 100644 --- a/multimodalinput/kits/c/input/oh_input_manager.h +++ b/multimodalinput/kits/c/input/oh_input_manager.h @@ -228,6 +228,13 @@ typedef struct Input_TouchEvent Input_TouchEvent; */ typedef struct Input_AxisEvent Input_AxisEvent; +/** + * @brief Defines the hot key structure. + * + * @since 14 + */ +typedef struct Input_Hotkey Input_Hotkey; + /** * @brief Enumerates error codes. * @@ -242,12 +249,30 @@ typedef enum Input_Result { INPUT_NOT_SYSTEM_APPLICATION = 202, /** @error Parameter check failed */ INPUT_PARAMETER_ERROR = 401, + /** @error Device not support */ + INPUT_DEVICE_NOT_SUPPORTED = 801, /** @error Service error */ INPUT_SERVICE_EXCEPTION = 3800001, /** @error Interceptor repeatedly created for an application */ - INPUT_REPEAT_INTERCEPTOR = 4200001 + INPUT_REPEAT_INTERCEPTOR = 4200001, + /** + * @error Already occupied by the system + * @since 14 + */ + INPUT_OCCUPIED_BY_SYSTEM = 4200002, + /** + * @error Already occupied by the other + * @since 14 + */ + INPUT_OCCUPIED_BY_OTHER = 4200003, } Input_Result; +/** + * @brief Callback used to return shortcut key events. + * @since 14 + */ +typedef void (*Input_HotkeyCallback)(Input_Hotkey* hotkey); + /** * @brief Represents information about the input device. * @@ -1253,6 +1278,185 @@ Input_Result OH_Input_RemoveKeyEventInterceptor(void); */ Input_Result OH_Input_RemoveInputEventInterceptor(void); +/** + * @brief Obtains the interval since the last system input event. + * + * @param timeInterval Interval, in microseconds. + * @return OH_Input_GetIntervalSinceLastInput status code, specifically. + * {@Link INPUT_SUCCESS} if the Operation is successful.\n + * {@Link INPUT_SERVICE_EXCEPTION} Failed to get the interval because the service is exception.\n + * {@Link INPUT_PARAMETER_ERROR} The timeInterval is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 14 + */ +Input_Result OH_Input_GetIntervalSinceLastInput(int64_t *timeInterval); + +/** + * @brief Creates a hot key object. + * + * @return Returns an {@Link Input_Hotkey} pointer object if the operation is successful. Otherwise, a null pointer is + * returned. The possible cause is memory allocation failure. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 14 + */ +Input_Hotkey *OH_Input_CreateHotkey(void); + +/** + * @brief Destroys a hot key object. + * + * @param hotkey Hot key object. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 14 + */ +void OH_Input_DestroyHotkey(Input_Hotkey **hotkey); + +/** + * @brief Sets a modifier key. + * + * @param hotkey Hotkey key object. + * @param preKeys List of modifier keys. + * @param size Number of modifier keys. One or two modifier keys are supported. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 14 + */ +void OH_Input_SetPreKeys(Input_Hotkey *hotkey, int32_t *preKeys, int32_t size); + +/** + * @brief Obtains a modifier key. + * + * @param hotkey Hotkey key object. + * @param preKeys List of modifier keys. + * @param preKeyCount Number of modifier keys. + * @return OH_Input_GetPreKeys status code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful;\n + * {@link INPUT_PARAMETER_ERROR} The hotkey is NULL or the pressedKeys is NULL or the pressedKeyCount + * is NULL;\n + * {@Link INPUT_DEVICE_NOT_SUPPORTED} Capability not supported.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 14 + */ +Input_Result OH_Input_GetPreKeys(const Input_Hotkey *hotkey, int32_t **preKeys, int32_t *preKeyCount); + +/** + * @brief Sets a modified key. + * + * @param hotkey Hotkey key object. + * @param finalKey Modified key. Only one modified key is supported. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 14 + */ +void OH_Input_SetFinalKey(Input_Hotkey *hotkey, int32_t finalKey); + +/** + * @brief Obtains a modified key. + * + * @param hotkey Hotkey key object. + * @param finalKeyCode Returns the key value of the decorated key. + * @return OH_Input_GetfinalKey status code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful;\n + * {@link INPUT_PARAMETER_ERROR} The hotkey is NULL or the finalKeyCode is NULL;\n + * {@Link INPUT_DEVICE_NOT_SUPPORTED} Capability not supported.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 14 + */ +Input_Result OH_Input_GetFinalKey(const Input_Hotkey *hotkey, int32_t *finalKeyCode); + +/** + * @brief Creates an array of {@Link Input_Hotkey} instances. + * + * @param count Number of {@Link Input_Hotkey} instances to be created. The count must be the same as the number of + * system shortcut keys. + * @return Returns a pointer to an array of {@Link Input_Hotkey} instances if the operation is successful. If the + * operation fails, a null pointer is returned. The possible cause is memory allocation failure or count is not equal + * to the number of system hotkeys. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 14 + */ +Input_Hotkey **OH_Input_CreateAllSystemHotkeys(int32_t count); + +/** + * @brief Destroys an array of {@link Input_Hotkey} instances and reclaims memory. + * + * @param hotkeys Pointer to an array of {@Link Input_Hotkey } instances created by the + * {@Link OH_Input_CreateAllSystemHotkeys} method. + * @param count Count of the array to be destroyed, which must be the same as the number of system shortcut keys. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 14 + */ +void OH_Input_DestroyAllSystemHotkeys(Input_Hotkey **hotkeys, int32_t count); + +/** + * @brief Obtains all hot keys supported by the system. + * + * @param hotkey Array of {@Link Input_Hotkey} instances. + * When calling this API for the first time, you can pass NULL to obtain the array length. + * @param count Number of hot keys supported by the system. + * @return OH_Input_GetAllSystemHotkeys status code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful;\n + * {@link INPUT_PARAMETER_ERROR} The hotkey or count is NULL, or the value of count does not match the number + * of system shortcut keys supported by the system; + * {@Link INPUT_DEVICE_NOT_SUPPORTED} Capability not supported.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 14 + */ +Input_Result OH_Input_GetAllSystemHotkeys(Input_Hotkey **hotkey, int32_t *count); + +/** + * @brief Specifies whether to report repeated key events. + * + * @param hotkey Shortcut key object. + * @param isRepeat Whether to report repeated key events. + * The value true means to report repeated key events, and the value false means the opposite. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 14 + */ +void OH_Input_SetRepeat(Input_Hotkey* hotkey, bool isRepeat); + +/** + * @brief Checks whether to report repeated key events. + * + * @param hotkey Shortcut key object. + * @param isRepeat Whether a key event is repeated. + * @return OH_Input_GetIsRepeat status code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful;\n + * {@link INPUT_PARAMETER_ERROR} otherwise;\n + * {@Link INPUT_DEVICE_NOT_SUPPORTED} Capability not supported.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 14 + */ +Input_Result OH_Input_GetRepeat(const Input_Hotkey* hotkey, bool *isRepeat); + +/** + * @brief Subscribes to shortcut key events. + * + * @param hotkey Shortcut key object. + * @param callback Callback used to return shortcut key events. + * @return OH_Input_AddHotkeyMonitor status code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful;\n + * {@link INPUT_PARAMETER_ERROR} if hotkey or callback is NULL;\n + * {@Link INPUT_DEVICE_NOT_SUPPORTED} Capability not supported;\n + * {@Link INPUT_OCCUPIED_BY_SYSTEM} The hotkey has been used by the system. You can call the {@Link + * GetAllSystemHotkeys} interface to query all system shortcut keys.\n + * {@Link INPUT_OCCUPIED_BY_OTHER} The hotkey has been subscribed to by another.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 14 + */ +Input_Result OH_Input_AddHotkeyMonitor(const Input_Hotkey* hotkey, Input_HotkeyCallback callback); + +/** + * @brief Unsubscribes from shortcut key events. + * + * @param hotkey Shortcut key object. + * @param callback Callback used to return shortcut key events. + * @return OH_Input_RemoveHotkeyMonitor status code, specifically, + * {@link INPUT_SUCCESS} if the operation is successful;\n + * {@link INPUT_PARAMETER_ERROR} if hotkey or callback is NULL;\n + * {@Link INPUT_DEVICE_NOT_SUPPORTED} Capability not supported.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 14 + */ +Input_Result OH_Input_RemoveHotkeyMonitor(const Input_Hotkey* hotkey, Input_HotkeyCallback callback); + /** * @brief Obtains the IDs of all input devices. * diff --git a/multimodalinput/kits/c/ohinput.ndk.json b/multimodalinput/kits/c/ohinput.ndk.json index c0c017a2f9bac8dcdc984b67f7c878627be22c1f..1b92c991420cd22affa967eb394d5487044bdc43 100644 --- a/multimodalinput/kits/c/ohinput.ndk.json +++ b/multimodalinput/kits/c/ohinput.ndk.json @@ -315,6 +315,62 @@ "first_introduced": "12", "name": "OH_Input_RemoveInputEventInterceptor" }, + { + "first_introduced": "14", + "name": "OH_Input_CreateAllSystemHotkeys" + }, + { + "first_introduced": "14", + "name": "OH_Input_DestroyAllSystemHotkeys" + }, + { + "first_introduced": "14", + "name": "OH_Input_GetAllSystemHotkeys" + }, + { + "first_introduced": "14", + "name": "OH_Input_CreateHotkey" + }, + { + "first_introduced": "14", + "name": "OH_Input_DestroyHotkey" + }, + { + "first_introduced": "14", + "name": "OH_Input_SetPreKeys" + }, + { + "first_introduced": "14", + "name": "OH_Input_GetPreKeys" + }, + { + "first_introduced": "14", + "name": "OH_Input_SetFinalKey" + }, + { + "first_introduced": "14", + "name": "OH_Input_GetFinalKey" + }, + { + "first_introduced": "14", + "name": "OH_Input_AddHotkeyMonitor" + }, + { + "first_introduced": "14", + "name": "OH_Input_RemoveHotkeyMonitor" + }, + { + "first_introduced": "14", + "name": "OH_Input_SetRepeat" + }, + { + "first_introduced": "14", + "name": "OH_Input_GetRepeat" + }, + { + "first_introduced": "14", + "name": "OH_Input_GetIntervalSinceLastInput" + }, { "first_introduced": "13", "name": "OH_Input_GetDeviceIds"