From 2f135f9e836f59b7cb2ff3ee29afdae9dc68c4d3 Mon Sep 17 00:00:00 2001 From: s00430227 Date: Thu, 4 Jan 2024 16:59:45 +0800 Subject: [PATCH 01/10] commit multimodalinput inject event api Signed-off-by: s00430227 --- multimodalinput/kits/c/BUILD.gn | 39 ++ .../kits/c/input_event/capi_input_event.h | 87 +++++ .../kits/c/input_event/capi_key_event.h | 369 ++++++++++++++++++ .../kits/c/input_event/capi_mouse_event.h | 145 +++++++ .../kits/c/input_event/capi_touch_event.h | 119 ++++++ multimodalinput/kits/c/ohinput.ndk.json | 5 + 6 files changed, 764 insertions(+) create mode 100644 multimodalinput/kits/c/BUILD.gn create mode 100644 multimodalinput/kits/c/input_event/capi_input_event.h create mode 100644 multimodalinput/kits/c/input_event/capi_key_event.h create mode 100644 multimodalinput/kits/c/input_event/capi_mouse_event.h create mode 100644 multimodalinput/kits/c/input_event/capi_touch_event.h create mode 100644 multimodalinput/kits/c/ohinput.ndk.json diff --git a/multimodalinput/kits/c/BUILD.gn b/multimodalinput/kits/c/BUILD.gn new file mode 100644 index 00000000000..5be6bfb1000 --- /dev/null +++ b/multimodalinput/kits/c/BUILD.gn @@ -0,0 +1,39 @@ +# Copyright (C) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") +import("//foundation/multimodalinput/input/multimodalinput_mini.gni") + +ohos_ndk_headers("ohinput_header") { + dest_dir = "$ndk_headers_out_dir/multimodalinput" + sources = [ + "input_event/capi_input_event.h", + "input_event/capi_key_event.h", + "input_event/capi_mouse_event.h", + "input_event/capi_touch_event.h", + ] +} + +ohos_ndk_library("libohinput_ndk") { + output_name = "ohinput" + output_extension = "so" + ndk_description_file = "./ohinput.ndk.json" + system_capability = "SystemCapability.MultimodalInput.Input.InputSimulator" + system_capability_headers = [ + "input_event/capi_input_event.h", + "input_event/capi_key_event.h", + "input_event/capi_mouse_event.h", + "input_event/capi_touch_event.h", + ] +} \ No newline at end of file diff --git a/multimodalinput/kits/c/input_event/capi_input_event.h b/multimodalinput/kits/c/input_event/capi_input_event.h new file mode 100644 index 00000000000..e1cca1f3e53 --- /dev/null +++ b/multimodalinput/kits/c/input_event/capi_input_event.h @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup input + * @{ + * + * @brief Provide the definition of the C interface for the input module. + * + * @syscap SystemCapability.MultimodalInput.Input.Pointer + * @since 11 + * @version 1.0 + */ + +/** + * @file native_input_pointer.h + * + * @brief Declare the pointer api related to mouse cursor settings. + * + * @library libohinput.so + * @syscap SystemCapability.MultimodalInput.Input.Pointer + * @since 11 + * @version 1.0 + */ + +#ifndef CAPI_INPUT_EVENT_H +#define CAPI_INPUT_EVENT_H + +#include +#include "capi_key_event.h" +#include "capi_mouse_event.h" +#include "capi_touch_event.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * Inject system keys. + * + * @param { CAPI_KeyEvent } keyEvent - the key event to be injected. + * @return Returns 0 if success; returns a non-0 value otherwise + * @syscap SystemCapability.MultimodalInput.Input.InputSimulator + * @systemapi hide for inner use + * @since 11 + */ +int32_t OH_InputEvent_InjectEvent(struct CAPI_KeyEvent* keyEvent); + +/** + * Inject mouse event. + * + * @param { CAPI_MouseEvent } mouseEvent - the mouse event to be injected. + * @return Returns 0 if success; returns a non-0 value otherwise + * @syscap SystemCapability.MultimodalInput.Input.InputSimulator + * @systemapi hide for inner use + * @since 11 + */ +int32_t OH_InputEvent_InjectMouseEvent(struct CAPI_MouseEvent* mouseEvent); + +/** + * Inject touch event. + * + * @param { CAPI_TouchEvent } touchEvent - the touch event to be injected. + * @return Returns 0 if success; returns a non-0 value otherwise + * @syscap SystemCapability.MultimodalInput.Input.InputSimulator + * @systemapi hide for inner use + * @since 11 + */ +int32_t OH_InputEvent_InjectTouchEvent(struct CAPI_TouchEvent* touchEvent); + +#ifdef __cplusplus +} +#endif +#endif // CAPI_INPUT_EVENT_H diff --git a/multimodalinput/kits/c/input_event/capi_key_event.h b/multimodalinput/kits/c/input_event/capi_key_event.h new file mode 100644 index 00000000000..95194e20a89 --- /dev/null +++ b/multimodalinput/kits/c/input_event/capi_key_event.h @@ -0,0 +1,369 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPI_KEY_EVENT_H +#define CAPI_KEY_EVENT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + KEYCODE_FN = 0, + KEYCODE_UNKNOWN = -1, + KEYCODE_HOME = 1, + KEYCODE_BACK = 2, + KEYCODE_MEDIA_PLAY_PAUSE = 10, + KEYCODE_MEDIA_STOP = 11, + KEYCODE_MEDIA_NEXT = 12, + KEYCODE_MEDIA_PREVIOUS = 13, + KEYCODE_MEDIA_REWIND = 14, + KEYCODE_MEDIA_FAST_FORWARD = 15, + KEYCODE_VOLUME_UP = 16, + KEYCODE_VOLUME_DOWN = 17, + KEYCODE_POWER = 18, + KEYCODE_CAMERA = 19, + KEYCODE_VOLUME_MUTE = 22, + KEYCODE_MUTE = 23, + KEYCODE_BRIGHTNESS_UP = 40, + KEYCODE_BRIGHTNESS_DOWN = 41, + KEYCODE_0 = 2000, + KEYCODE_1 = 2001, + KEYCODE_2 = 2002, + KEYCODE_3 = 2003, + KEYCODE_4 = 2004, + KEYCODE_5 = 2005, + KEYCODE_6 = 2006, + KEYCODE_7 = 2007, + KEYCODE_8 = 2008, + KEYCODE_9 = 2009, + KEYCODE_STAR = 2010, + KEYCODE_POUND = 2011, + KEYCODE_DPAD_UP = 2012, + KEYCODE_DPAD_DOWN = 2013, + KEYCODE_DPAD_LEFT = 2014, + KEYCODE_DPAD_RIGHT = 2015, + KEYCODE_DPAD_CENTER = 2016, + KEYCODE_A = 2017, + KEYCODE_B = 2018, + KEYCODE_C = 2019, + KEYCODE_D = 2020, + KEYCODE_E = 2021, + KEYCODE_F = 2022, + KEYCODE_G = 2023, + KEYCODE_H = 2024, + KEYCODE_I = 2025, + KEYCODE_J = 2026, + KEYCODE_K = 2027, + KEYCODE_L = 2028, + KEYCODE_M = 2029, + KEYCODE_N = 2030, + KEYCODE_O = 2031, + KEYCODE_P = 2032, + KEYCODE_Q = 2033, + KEYCODE_R = 2034, + KEYCODE_S = 2035, + KEYCODE_T = 2036, + KEYCODE_U = 2037, + KEYCODE_V = 2038, + KEYCODE_W = 2039, + KEYCODE_X = 2040, + KEYCODE_Y = 2041, + KEYCODE_Z = 2042, + KEYCODE_COMMA = 2043, + KEYCODE_PERIOD = 2044, + KEYCODE_ALT_LEFT = 2045, + KEYCODE_ALT_RIGHT = 2046, + KEYCODE_SHIFT_LEFT = 2047, + KEYCODE_SHIFT_RIGHT = 2048, + KEYCODE_TAB = 2049, + KEYCODE_SPACE = 2050, + KEYCODE_SYM = 2051, + KEYCODE_EXPLORER = 2052, + KEYCODE_ENVELOPE = 2053, + KEYCODE_ENTER = 2054, + KEYCODE_DEL = 2055, + KEYCODE_GRAVE = 2056, + KEYCODE_MINUS = 2057, + KEYCODE_EQUALS = 2058, + KEYCODE_LEFT_BRACKET = 2059, + KEYCODE_RIGHT_BRACKET = 2060, + KEYCODE_BACKSLASH = 2061, + KEYCODE_SEMICOLON = 2062, + KEYCODE_APOSTROPHE = 2063, + KEYCODE_SLASH = 2064, + KEYCODE_AT = 2065, + KEYCODE_PLUS = 2066, + KEYCODE_MENU = 2067, + KEYCODE_PAGE_UP = 2068, + KEYCODE_PAGE_DOWN = 2069, + KEYCODE_ESCAPE = 2070, + KEYCODE_FORWARD_DEL = 2071, + KEYCODE_CTRL_LEFT = 2072, + KEYCODE_CTRL_RIGHT = 2073, + KEYCODE_CAPS_LOCK = 2074, + KEYCODE_SCROLL_LOCK = 2075, + KEYCODE_META_LEFT = 2076, + KEYCODE_META_RIGHT = 2077, + KEYCODE_FUNCTION = 2078, + KEYCODE_SYSRQ = 2079, + KEYCODE_BREAK = 2080, + KEYCODE_MOVE_HOME = 2081, + KEYCODE_MOVE_END = 2082, + KEYCODE_INSERT = 2083, + KEYCODE_FORWARD = 2084, + KEYCODE_MEDIA_PLAY = 2085, + KEYCODE_MEDIA_PAUSE = 2086, + KEYCODE_MEDIA_CLOSE = 2087, + KEYCODE_MEDIA_EJECT = 2088, + KEYCODE_MEDIA_RECORD = 2089, + KEYCODE_F1 = 2090, + KEYCODE_F2 = 2091, + KEYCODE_F3 = 2092, + KEYCODE_F4 = 2093, + KEYCODE_F5 = 2094, + KEYCODE_F6 = 2095, + KEYCODE_F7 = 2096, + KEYCODE_F8 = 2097, + KEYCODE_F9 = 2098, + KEYCODE_F10 = 2099, + KEYCODE_F11 = 2100, + KEYCODE_F12 = 2101, + KEYCODE_NUM_LOCK = 2102, + KEYCODE_NUMPAD_0 = 2103, + KEYCODE_NUMPAD_1 = 2104, + KEYCODE_NUMPAD_2 = 2105, + KEYCODE_NUMPAD_3 = 2106, + KEYCODE_NUMPAD_4 = 2107, + KEYCODE_NUMPAD_5 = 2108, + KEYCODE_NUMPAD_6 = 2109, + KEYCODE_NUMPAD_7 = 2110, + KEYCODE_NUMPAD_8 = 2111, + KEYCODE_NUMPAD_9 = 2112, + KEYCODE_NUMPAD_DIVIDE = 2113, + KEYCODE_NUMPAD_MULTIPLY = 2114, + KEYCODE_NUMPAD_SUBTRACT = 2115, + KEYCODE_NUMPAD_ADD = 2116, + KEYCODE_NUMPAD_DOT = 2117, + KEYCODE_NUMPAD_COMMA = 2118, + KEYCODE_NUMPAD_ENTER = 2119, + KEYCODE_NUMPAD_EQUALS = 2120, + KEYCODE_NUMPAD_LEFT_PAREN = 2121, + KEYCODE_NUMPAD_RIGHT_PAREN = 2122, + KEYCODE_VIRTUAL_MULTITASK = 2210, + KEYCODE_SLEEP = 2600, + KEYCODE_ZENKAKU_HANKAKU = 2601, + KEYCODE_102ND = 2602, + KEYCODE_RO = 2603, + KEYCODE_KATAKANA = 2604, + KEYCODE_HIRAGANA = 2605, + KEYCODE_HENKAN = 2606, + KEYCODE_KATAKANA_HIRAGANA = 2607, + KEYCODE_MUHENKAN = 2608, + KEYCODE_LINEFEED = 2609, + KEYCODE_MACRO = 2610, + KEYCODE_NUMPAD_PLUSMINUS = 2611, + KEYCODE_SCALE = 2612, + KEYCODE_HANGUEL = 2613, + KEYCODE_HANJA = 2614, + KEYCODE_YEN = 2615, + KEYCODE_STOP = 2616, + KEYCODE_AGAIN = 2617, + KEYCODE_PROPS = 2618, + KEYCODE_UNDO = 2619, + KEYCODE_COPY = 2620, + KEYCODE_OPEN = 2621, + KEYCODE_PASTE = 2622, + KEYCODE_FIND = 2623, + KEYCODE_CUT = 2624, + KEYCODE_HELP = 2625, + KEYCODE_CALC = 2626, + KEYCODE_FILE = 2627, + KEYCODE_BOOKMARKS = 2628, + KEYCODE_NEXT = 2629, + KEYCODE_PLAYPAUSE = 2630, + KEYCODE_PREVIOUS = 2631, + KEYCODE_STOPCD = 2632, + KEYCODE_CONFIG = 2634, + KEYCODE_REFRESH = 2635, + KEYCODE_EXIT = 2636, + KEYCODE_EDIT = 2637, + KEYCODE_SCROLLUP = 2638, + KEYCODE_SCROLLDOWN = 2639, + KEYCODE_NEW = 2640, + KEYCODE_REDO = 2641, + KEYCODE_CLOSE = 2642, + KEYCODE_PLAY = 2643, + KEYCODE_BASSBOOST = 2644, + KEYCODE_PRINT = 2645, + KEYCODE_CHAT = 2646, + KEYCODE_FINANCE = 2647, + KEYCODE_CANCEL = 2648, + KEYCODE_KBDILLUM_TOGGLE = 2649, + KEYCODE_KBDILLUM_DOWN = 2650, + KEYCODE_KBDILLUM_UP = 2651, + KEYCODE_SEND = 2652, + KEYCODE_REPLY = 2653, + KEYCODE_FORWARDMAIL = 2654, + KEYCODE_SAVE = 2655, + KEYCODE_DOCUMENTS = 2656, + KEYCODE_VIDEO_NEXT = 2657, + KEYCODE_VIDEO_PREV = 2658, + KEYCODE_BRIGHTNESS_CYCLE = 2659, + KEYCODE_BRIGHTNESS_ZERO = 2660, + KEYCODE_DISPLAY_OFF = 2661, + KEYCODE_BTN_MISC = 2662, + KEYCODE_GOTO = 2663, + KEYCODE_INFO = 2664, + KEYCODE_PROGRAM = 2665, + KEYCODE_PVR = 2666, + KEYCODE_SUBTITLE = 2667, + KEYCODE_FULL_SCREEN = 2668, + KEYCODE_KEYBOARD = 2669, + KEYCODE_ASPECT_RATIO = 2670, + KEYCODE_PC = 2671, + KEYCODE_TV = 2672, + KEYCODE_TV2 = 2673, + KEYCODE_VCR = 2674, + KEYCODE_VCR2 = 2675, + KEYCODE_SAT = 2676, + KEYCODE_CD = 2677, + KEYCODE_TAPE = 2678, + KEYCODE_TUNER = 2679, + KEYCODE_PLAYER = 2680, + KEYCODE_DVD = 2681, + KEYCODE_AUDIO = 2682, + KEYCODE_VIDEO = 2683, + KEYCODE_MEMO = 2684, + KEYCODE_CALENDAR = 2685, + KEYCODE_RED = 2686, + KEYCODE_GREEN = 2687, + KEYCODE_YELLOW = 2688, + KEYCODE_BLUE = 2689, + KEYCODE_CHANNELUP = 2690, + KEYCODE_CHANNELDOWN = 2691, + KEYCODE_LAST = 2692, + KEYCODE_RESTART = 2693, + KEYCODE_SLOW = 2694, + KEYCODE_SHUFFLE = 2695, + KEYCODE_VIDEOPHONE = 2696, + KEYCODE_GAMES = 2697, + KEYCODE_ZOOMIN = 2698, + KEYCODE_ZOOMOUT = 2699, + KEYCODE_ZOOMRESET = 2700, + KEYCODE_WORDPROCESSOR = 2701, + KEYCODE_EDITOR = 2702, + KEYCODE_SPREADSHEET = 2703, + KEYCODE_GRAPHICSEDITOR = 2704, + KEYCODE_PRESENTATION = 2705, + KEYCODE_DATABASE = 2706, + KEYCODE_NEWS = 2707, + KEYCODE_VOICEMAIL = 2708, + KEYCODE_ADDRESSBOOK = 2709, + KEYCODE_MESSENGER = 2710, + KEYCODE_BRIGHTNESS_TOGGLE = 2711, + KEYCODE_SPELLCHECK = 2712, + KEYCODE_COFFEE = 2713, + KEYCODE_MEDIA_REPEAT = 2714, + KEYCODE_IMAGES = 2715, + KEYCODE_BUTTONCONFIG = 2716, + KEYCODE_TASKMANAGER = 2717, + KEYCODE_JOURNAL = 2718, + KEYCODE_CONTROLPANEL = 2719, + KEYCODE_APPSELECT = 2720, + KEYCODE_SCREENSAVER = 2721, + KEYCODE_ASSISTANT = 2722, + KEYCODE_KBD_LAYOUT_NEXT = 2723, + KEYCODE_BRIGHTNESS_MIN = 2724, + KEYCODE_BRIGHTNESS_MAX = 2725, + KEYCODE_KBDINPUTASSIST_PREV = 2726, + KEYCODE_KBDINPUTASSIST_NEXT = 2727, + KEYCODE_KBDINPUTASSIST_PREVGROUP = 2728, + KEYCODE_KBDINPUTASSIST_NEXTGROUP = 2729, + KEYCODE_KBDINPUTASSIST_ACCEPT = 2730, + KEYCODE_KBDINPUTASSIST_CANCEL = 2731, + KEYCODE_FRONT = 2800, + KEYCODE_SETUP = 2801, + KEYCODE_WAKEUP = 2802, + KEYCODE_SENDFILE = 2803, + KEYCODE_DELETEFILE = 2804, + KEYCODE_XFER = 2805, + KEYCODE_PROG1 = 2806, + KEYCODE_PROG2 = 2807, + KEYCODE_MSDOS = 2808, + KEYCODE_SCREENLOCK = 2809, + KEYCODE_DIRECTION_ROTATE_DISPLAY = 2810, + KEYCODE_CYCLEWINDOWS = 2811, + KEYCODE_COMPUTER = 2812, + KEYCODE_EJECTCLOSECD = 2813, + KEYCODE_ISO = 2814, + KEYCODE_MOVE = 2815, + KEYCODE_F13 = 2816, + KEYCODE_F14 = 2817, + KEYCODE_F15 = 2818, + KEYCODE_F16 = 2819, + KEYCODE_F17 = 2820, + KEYCODE_F18 = 2821, + KEYCODE_F19 = 2822, + KEYCODE_F20 = 2823, + KEYCODE_F21 = 2824, + KEYCODE_F22 = 2825, + KEYCODE_F23 = 2826, + KEYCODE_F24 = 2827, + KEYCODE_PROG3 = 2828, + KEYCODE_PROG4 = 2829, + KEYCODE_DASHBOARD = 2830, + KEYCODE_SUSPEND = 2831, + KEYCODE_HP = 2832, + KEYCODE_SOUND = 2833, + KEYCODE_QUESTION = 2834, + KEYCODE_CONNECT = 2836, + KEYCODE_SPORT = 2837, + KEYCODE_SHOP = 2838, + KEYCODE_ALTERASE = 2839, + KEYCODE_SWITCHVIDEOMODE = 2841, + KEYCODE_BATTERY = 2842, + KEYCODE_BLUETOOTH = 2843, + KEYCODE_WLAN = 2844, + KEYCODE_UWB = 2845, + KEYCODE_WWAN_WIMAX = 2846, + KEYCODE_RFKILL = 2847, + KEYCODE_CHANNEL = 3001, + KEYCODE_BTN_0 = 3100, + KEYCODE_BTN_1 = 3101, + KEYCODE_BTN_2 = 3102, + KEYCODE_BTN_3 = 3103, + KEYCODE_BTN_4 = 3104, + KEYCODE_BTN_5 = 3105, + KEYCODE_BTN_6 = 3106, + KEYCODE_BTN_7 = 3107, + KEYCODE_BTN_8 = 3108, + KEYCODE_BTN_9 = 3109 +} CAPI_KeyCode; + +struct CAPI_KeyEvent { + bool isPressed = false; + int32_t keyCode; + int32_t keyDownDuration = 0; + bool isIntercepted = false; +}; + +#ifdef __cplusplus +} +#endif + +#endif // CAPI_KEY_EVENT_H diff --git a/multimodalinput/kits/c/input_event/capi_mouse_event.h b/multimodalinput/kits/c/input_event/capi_mouse_event.h new file mode 100644 index 00000000000..040dc9be2b8 --- /dev/null +++ b/multimodalinput/kits/c/input_event/capi_mouse_event.h @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPI_MOUSE_EVENT_H +#define CAPI_MOUSE_EVENT_H + +#include +#include +#include "capi_key_event.h" + +#ifdef __cplusplus +extern "C" { +#endif + +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 axis event associated with the mouse. */ + MOUSE_ACTION_AXIS_BEGIN = 4, + /** Updating of the axis event associated with the mouse. */ + MOUSE_ACTION_AXIS_UPDATE = 5, + /** Ending of the axis event associated with the mouse. */ + MOUSE_ACTION_AXIS_END = 6, + /** Pressing down of the mouse touch pad. */ + MOUSE_ACTION_ACTION_DOWN = 7, + /** Lifting of the mouse touch pad. */ + MOUSE_ACTION_ACTION_UP = 8 +} MouseAction; + +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 +} MouseButton; + +typedef enum { + /** Vertical scroll axis. */ + MOUSE_AXIS_SCROLL_VERTICAL = 0, + /** Horizontal scroll axis. */ + MOUSE_AXIS_SCROLL_HORIZONTAL = 1, + /** Pinch axis. */ + MOUSE_AXIS_PINCH = 2 +} MouseAxis; + +typedef enum { + /** Unknown type. */ + MOUSE_TOOLTYPE_UNKNOWN = 0, + /** Mouse. */ + MOUSE_TOOLTYPE_MOUSE = 1, + /** Joystick. */ + MOUSE_TOOLTYPE_JOYSTICK = 2, + /** Touch pad. */ + MOUSE_TOOLTYPE_TOUCHPAD = 3 +} MouseToolType; + + +struct CAPI_AxisValue { + /** Axis type. */ + MouseAxis axis; + /** Axis value. */ + int32_t value; +}; + +struct CAPI_MouseEvent { + /** Mouse event action. */ + MouseAction action; + /** X coordinate of the mouse pointer on the screen. */ + int32_t screenX; + /** Y coordinate of the mouse pointer on the screen. */ + int32_t screenY; + /** X coordinate of the mouse pointer in the window. */ + int32_t windowX; + /** Y coordinate of the mouse pointer in the window. */ + int32_t windowY; + /** + * X axis offset relative to the previous reported mouse pointer position. When the mouse pointer is at + * the edge of the screen, the value may be less than the difference of the X coordinate reported twice. + */ + int32_t rawDeltaX; + /** Y axis offset relative to the previous reported mouse pointer position. */ + int32_t rawDeltaY; + /** Button that is currently pressed or released. */ + MouseButton button; + /** Button that is being pressed. */ + std::vector pressedButtons; + /** All axis data contained in the event. */ + std::vector axes; + /** List of pressed keys. */ + std::vector pressedKeys; + /** Whether ctrlKey is being pressed. */ + bool ctrlKey; + /** Whether altKey is being pressed. */ + bool altKey; + /** Whether shiftKey is being pressed. */ + bool shiftKey; + /** Whether logoKey is being pressed. */ + bool logoKey; + /** Whether fnKey is being pressed. */ + bool fnKey; + /** Whether capsLock is active. */ + bool capsLock; + /** Whether numLock is active. */ + bool numLock; + /** Whether scrollLock is active. */ + bool scrollLock; + /** Tool type */ + MouseToolType toolType; +}; + +#ifdef __cplusplus +} +#endif + +#endif // CAPI_MOUSE_EVENT_H diff --git a/multimodalinput/kits/c/input_event/capi_touch_event.h b/multimodalinput/kits/c/input_event/capi_touch_event.h new file mode 100644 index 00000000000..9044d25d06d --- /dev/null +++ b/multimodalinput/kits/c/input_event/capi_touch_event.h @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAPI_TOUCH_EVENT_H +#define CAPI_TOUCH_EVENT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +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, +} TouchAction; + +typedef enum { + /** Touchscreen. */ + TOUCH_SOURCE_TYPE_TOUCH_SCREEN = 0, + /** Stylus. */ + TOUCH_SOURCE_TYPE_PEN = 1, + /** Touchpad. */ + TOUCH_SOURCE_TYPE_TOUCH_PAD = 2 +} TouchSourceType; + +typedef enum { + /** Finger. */ + TOUCH_TOOLTYPE_FINGER = 0, + /** Stylus. */ + TOUCH_TOOLTYPE_PEN = 1, + /** Rubber. */ + TOUCH_TOOLTYPE_RUBBER = 2, + /** Brush. */ + TOUCH_TOOLTYPE_BRUSH = 3, + /** Pencil. */ + TOUCH_TOOLTYPE_PENCIL = 4, + /** Air brush. */ + TOUCH_TOOLTYPE_AIRBRUSH = 5, + /** Mouse. */ + TOUCH_TOOLTYPE_MOUSE = 6, + /** Lens. */ + TOUCH_TOOLTYPE_LENS = 7, +} TouchToolType; + +struct Touch { + /** Pointer identifier. */ + int32_t id; + /** Time stamp when touch is pressed. */ + int32_t pressedTime; + /** X coordinate of the touch position on the screen. */ + int32_t screenX; + /** Y coordinate of the touch position on the screen. */ + int32_t screenY; + /** X coordinate of the touch position in the window. */ + int32_t windowX; + /** Y coordinate of the touch position in the window. */ + int32_t windowY; + /** Pressure value. The value range is [0.0, 1.0]. The value 0.0 indicates that the pressure is not supported. */ + int32_t pressure; + /** Width of the contact area when touch is pressed. */ + int32_t width; + /** Height of the contact area when touch is pressed. */ + int32_t height; + /** Angle relative to the YZ plane. The value range is [-90, 90]. A positive value indicates a rightward tilt. */ + int32_t tiltX; + /** Angle relative to the XZ plane. The value range is [-90, 90]. A positive value indicates a downward tilt. */ + int32_t tiltY; + /** Center point X of the tool area. */ + int32_t toolX; + /** Center point Y of the tool area. */ + int32_t toolY; + /** Width of the tool area. */ + int32_t toolWidth; + /** Height of the tool area. */ + int32_t toolHeight; + /** X coordinate of the input device. */ + int32_t rawX; + /** Y coordinate of the input device. */ + int32_t rawY; + /** Tool type. */ + TouchToolType toolType; +}; + +struct CAPI_TouchEvent { + /** Touch action. */ + TouchAction action; + /** Current touch point. */ + Touch touch; + /** All touch points. */ + std::vector touches; + /** Device type of the touch source. */ + TouchSourceType sourceType; +}; + +#ifdef __cplusplus +} +#endif + +#endif // CAPI_TOUCH_EVENT_H diff --git a/multimodalinput/kits/c/ohinput.ndk.json b/multimodalinput/kits/c/ohinput.ndk.json new file mode 100644 index 00000000000..75ebe93b788 --- /dev/null +++ b/multimodalinput/kits/c/ohinput.ndk.json @@ -0,0 +1,5 @@ +[ + { "name": "OH_InputEvent_InjectEvent" }, + { "name": "OH_InputEvent_InjectMouseEvent" }, + { "name": "OH_InputEvent_InjectTouchEvent" } +] \ No newline at end of file -- Gitee From ae348bdaa72829df055bcce7c7b40d79825cfd31 Mon Sep 17 00:00:00 2001 From: s00430227 Date: Fri, 5 Jan 2024 15:52:45 +0800 Subject: [PATCH 02/10] commit multimodalinput inject event api Signed-off-by: s00430227 --- multimodalinput/kits/c/BUILD.gn | 12 ++-- .../kits/c/input_event/capi_input_event.h | 61 +++---------------- .../kits/c/input_event/capi_key_event.h | 6 +- .../kits/c/input_event/capi_mouse_event.h | 10 +-- .../kits/c/input_event/capi_touch_event.h | 4 +- 5 files changed, 26 insertions(+), 67 deletions(-) diff --git a/multimodalinput/kits/c/BUILD.gn b/multimodalinput/kits/c/BUILD.gn index 5be6bfb1000..ef280ae4410 100644 --- a/multimodalinput/kits/c/BUILD.gn +++ b/multimodalinput/kits/c/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2023 Huawei Device Co., Ltd. +# Copyright (C) 2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -31,9 +31,9 @@ ohos_ndk_library("libohinput_ndk") { ndk_description_file = "./ohinput.ndk.json" system_capability = "SystemCapability.MultimodalInput.Input.InputSimulator" system_capability_headers = [ - "input_event/capi_input_event.h", - "input_event/capi_key_event.h", - "input_event/capi_mouse_event.h", - "input_event/capi_touch_event.h", + "multimodalinput/capi_input_event.h", + "multimodalinput/capi_key_event.h", + "multimodalinput/capi_mouse_event.h", + "multimodalinput/capi_touch_event.h", ] -} \ No newline at end of file +} diff --git a/multimodalinput/kits/c/input_event/capi_input_event.h b/multimodalinput/kits/c/input_event/capi_input_event.h index e1cca1f3e53..0067070a959 100644 --- a/multimodalinput/kits/c/input_event/capi_input_event.h +++ b/multimodalinput/kits/c/input_event/capi_input_event.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,28 +13,6 @@ * limitations under the License. */ -/** - * @addtogroup input - * @{ - * - * @brief Provide the definition of the C interface for the input module. - * - * @syscap SystemCapability.MultimodalInput.Input.Pointer - * @since 11 - * @version 1.0 - */ - -/** - * @file native_input_pointer.h - * - * @brief Declare the pointer api related to mouse cursor settings. - * - * @library libohinput.so - * @syscap SystemCapability.MultimodalInput.Input.Pointer - * @since 11 - * @version 1.0 - */ - #ifndef CAPI_INPUT_EVENT_H #define CAPI_INPUT_EVENT_H @@ -47,39 +25,20 @@ extern "C" { #endif - -/** - * Inject system keys. +/* + * Sets the absolute coordinate of mouse. * - * @param { CAPI_KeyEvent } keyEvent - the key event to be injected. - * @return Returns 0 if success; returns a non-0 value otherwise - * @syscap SystemCapability.MultimodalInput.Input.InputSimulator - * @systemapi hide for inner use + * @param x Indicates the x coordinate of the mouse to be set + * @param y Indicates the y coordinate of the mouse to be set + * @return Returns 0 if success; returns a non-0 value otherwise. + * @syscap SystemCapability.MultimodalInput.Input.Pointer * @since 11 */ -int32_t OH_InputEvent_InjectEvent(struct CAPI_KeyEvent* keyEvent); +int32_t OH_InputEvent_InjectEvent(struct InputEvent_KeyEvent* keyEvent); -/** - * Inject mouse event. - * - * @param { CAPI_MouseEvent } mouseEvent - the mouse event to be injected. - * @return Returns 0 if success; returns a non-0 value otherwise - * @syscap SystemCapability.MultimodalInput.Input.InputSimulator - * @systemapi hide for inner use - * @since 11 - */ -int32_t OH_InputEvent_InjectMouseEvent(struct CAPI_MouseEvent* mouseEvent); +int32_t OH_InputEvent_InjectMouseEvent(struct InputEvent_MouseEvent* mouseEvent); -/** - * Inject touch event. - * - * @param { CAPI_TouchEvent } touchEvent - the touch event to be injected. - * @return Returns 0 if success; returns a non-0 value otherwise - * @syscap SystemCapability.MultimodalInput.Input.InputSimulator - * @systemapi hide for inner use - * @since 11 - */ -int32_t OH_InputEvent_InjectTouchEvent(struct CAPI_TouchEvent* touchEvent); +int32_t OH_InputEvent_InjectTouchEvent(struct InputEvent_TouchEvent* touchEvent); #ifdef __cplusplus } diff --git a/multimodalinput/kits/c/input_event/capi_key_event.h b/multimodalinput/kits/c/input_event/capi_key_event.h index 95194e20a89..fb8acc868df 100644 --- a/multimodalinput/kits/c/input_event/capi_key_event.h +++ b/multimodalinput/kits/c/input_event/capi_key_event.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -353,9 +353,9 @@ typedef enum { KEYCODE_BTN_7 = 3107, KEYCODE_BTN_8 = 3108, KEYCODE_BTN_9 = 3109 -} CAPI_KeyCode; +} InputEvent_KeyCode; -struct CAPI_KeyEvent { +struct InputEvent_KeyEvent { bool isPressed = false; int32_t keyCode; int32_t keyDownDuration = 0; diff --git a/multimodalinput/kits/c/input_event/capi_mouse_event.h b/multimodalinput/kits/c/input_event/capi_mouse_event.h index 040dc9be2b8..ea00bc93b08 100644 --- a/multimodalinput/kits/c/input_event/capi_mouse_event.h +++ b/multimodalinput/kits/c/input_event/capi_mouse_event.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -85,14 +85,14 @@ typedef enum { } MouseToolType; -struct CAPI_AxisValue { +struct InputEvent_AxisValue { /** Axis type. */ MouseAxis axis; /** Axis value. */ int32_t value; }; -struct CAPI_MouseEvent { +struct InputEvent_MouseEvent { /** Mouse event action. */ MouseAction action; /** X coordinate of the mouse pointer on the screen. */ @@ -115,9 +115,9 @@ struct CAPI_MouseEvent { /** Button that is being pressed. */ std::vector pressedButtons; /** All axis data contained in the event. */ - std::vector axes; + std::vector axes; /** List of pressed keys. */ - std::vector pressedKeys; + std::vector pressedKeys; /** Whether ctrlKey is being pressed. */ bool ctrlKey; /** Whether altKey is being pressed. */ diff --git a/multimodalinput/kits/c/input_event/capi_touch_event.h b/multimodalinput/kits/c/input_event/capi_touch_event.h index 9044d25d06d..0a7c3117eb1 100644 --- a/multimodalinput/kits/c/input_event/capi_touch_event.h +++ b/multimodalinput/kits/c/input_event/capi_touch_event.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -101,7 +101,7 @@ struct Touch { TouchToolType toolType; }; -struct CAPI_TouchEvent { +struct InputEvent_TouchEvent { /** Touch action. */ TouchAction action; /** Current touch point. */ -- Gitee From faefd130d8d8828e40b5f4de2fb1b0f0be488d7b Mon Sep 17 00:00:00 2001 From: s00430227 Date: Fri, 5 Jan 2024 16:01:19 +0800 Subject: [PATCH 03/10] commit multimodalinput inject event api Signed-off-by: s00430227 --- .../kits/c/input_event/capi_input_event.h | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/multimodalinput/kits/c/input_event/capi_input_event.h b/multimodalinput/kits/c/input_event/capi_input_event.h index 0067070a959..86927302a9f 100644 --- a/multimodalinput/kits/c/input_event/capi_input_event.h +++ b/multimodalinput/kits/c/input_event/capi_input_event.h @@ -25,19 +25,37 @@ extern "C" { #endif -/* - * Sets the absolute coordinate of mouse. +/** + * Inject system keys. * - * @param x Indicates the x coordinate of the mouse to be set - * @param y Indicates the y coordinate of the mouse to be set - * @return Returns 0 if success; returns a non-0 value otherwise. - * @syscap SystemCapability.MultimodalInput.Input.Pointer + * @param { CAPI_KeyEvent } keyEvent - the key event to be injected. + * @return Returns 0 if success; returns a non-0 value otherwise + * @syscap SystemCapability.MultimodalInput.Input.InputSimulator + * @systemapi hide for inner use * @since 11 */ int32_t OH_InputEvent_InjectEvent(struct InputEvent_KeyEvent* keyEvent); +/** + * Inject mouse event. + * + * @param { CAPI_MouseEvent } mouseEvent - the mouse event to be injected. + * @return Returns 0 if success; returns a non-0 value otherwise + * @syscap SystemCapability.MultimodalInput.Input.InputSimulator + * @systemapi hide for inner use + * @since 11 + */ int32_t OH_InputEvent_InjectMouseEvent(struct InputEvent_MouseEvent* mouseEvent); +/** + * Inject touch event. + * + * @param { CAPI_TouchEvent } touchEvent - the touch event to be injected. + * @return Returns 0 if success; returns a non-0 value otherwise + * @syscap SystemCapability.MultimodalInput.Input.InputSimulator + * @systemapi hide for inner use + * @since 11 + */ int32_t OH_InputEvent_InjectTouchEvent(struct InputEvent_TouchEvent* touchEvent); #ifdef __cplusplus -- Gitee From bbef10adf08c6d04fd129d22bde470bc7b1af358 Mon Sep 17 00:00:00 2001 From: s00430227 Date: Fri, 5 Jan 2024 16:48:37 +0800 Subject: [PATCH 04/10] commit multimodalinput inject event api Signed-off-by: s00430227 --- .../kits/c/input_event/capi_mouse_event.h | 18 +++++++++--------- .../kits/c/input_event/capi_touch_event.h | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/multimodalinput/kits/c/input_event/capi_mouse_event.h b/multimodalinput/kits/c/input_event/capi_mouse_event.h index ea00bc93b08..00822ea7f96 100644 --- a/multimodalinput/kits/c/input_event/capi_mouse_event.h +++ b/multimodalinput/kits/c/input_event/capi_mouse_event.h @@ -43,7 +43,7 @@ typedef enum { MOUSE_ACTION_ACTION_DOWN = 7, /** Lifting of the mouse touch pad. */ MOUSE_ACTION_ACTION_UP = 8 -} MouseAction; +} InputEvent_MouseAction; typedef enum { /** Left button on the mouse. */ @@ -62,7 +62,7 @@ typedef enum { MOUSE_BUTTON_BACK = 6, /** Task key on the mouse. */ MOUSE_BUTTON_TASK = 7 -} MouseButton; +} InputEvent_MouseButton; typedef enum { /** Vertical scroll axis. */ @@ -71,7 +71,7 @@ typedef enum { MOUSE_AXIS_SCROLL_HORIZONTAL = 1, /** Pinch axis. */ MOUSE_AXIS_PINCH = 2 -} MouseAxis; +} InputEvent_MouseAxis; typedef enum { /** Unknown type. */ @@ -82,19 +82,19 @@ typedef enum { MOUSE_TOOLTYPE_JOYSTICK = 2, /** Touch pad. */ MOUSE_TOOLTYPE_TOUCHPAD = 3 -} MouseToolType; +} InputEvent_MouseToolType; struct InputEvent_AxisValue { /** Axis type. */ - MouseAxis axis; + InputEvent_MouseAxis axis; /** Axis value. */ int32_t value; }; struct InputEvent_MouseEvent { /** Mouse event action. */ - MouseAction action; + InputEvent_MouseAction action; /** X coordinate of the mouse pointer on the screen. */ int32_t screenX; /** Y coordinate of the mouse pointer on the screen. */ @@ -111,9 +111,9 @@ struct InputEvent_MouseEvent { /** Y axis offset relative to the previous reported mouse pointer position. */ int32_t rawDeltaY; /** Button that is currently pressed or released. */ - MouseButton button; + InputEvent_MouseButton button; /** Button that is being pressed. */ - std::vector pressedButtons; + std::vector pressedButtons; /** All axis data contained in the event. */ std::vector axes; /** List of pressed keys. */ @@ -135,7 +135,7 @@ struct InputEvent_MouseEvent { /** Whether scrollLock is active. */ bool scrollLock; /** Tool type */ - MouseToolType toolType; + InputEvent_MouseToolType toolType; }; #ifdef __cplusplus diff --git a/multimodalinput/kits/c/input_event/capi_touch_event.h b/multimodalinput/kits/c/input_event/capi_touch_event.h index 0a7c3117eb1..df55fdf4f76 100644 --- a/multimodalinput/kits/c/input_event/capi_touch_event.h +++ b/multimodalinput/kits/c/input_event/capi_touch_event.h @@ -32,7 +32,7 @@ typedef enum { TOUCH_ACTION_MOVE = 2, /** Touch lifted. */ TOUCH_ACTION_UP = 3, -} TouchAction; +} InputEvent_TouchAction; typedef enum { /** Touchscreen. */ @@ -41,7 +41,7 @@ typedef enum { TOUCH_SOURCE_TYPE_PEN = 1, /** Touchpad. */ TOUCH_SOURCE_TYPE_TOUCH_PAD = 2 -} TouchSourceType; +} InputEvent_TouchSourceType; typedef enum { /** Finger. */ @@ -60,9 +60,9 @@ typedef enum { TOUCH_TOOLTYPE_MOUSE = 6, /** Lens. */ TOUCH_TOOLTYPE_LENS = 7, -} TouchToolType; +} InputEvent_TouchToolType; -struct Touch { +struct InputEvent_Touch { /** Pointer identifier. */ int32_t id; /** Time stamp when touch is pressed. */ @@ -98,18 +98,18 @@ struct Touch { /** Y coordinate of the input device. */ int32_t rawY; /** Tool type. */ - TouchToolType toolType; + InputEvent_TouchToolType toolType; }; struct InputEvent_TouchEvent { /** Touch action. */ - TouchAction action; + InputEvent_TouchAction action; /** Current touch point. */ - Touch touch; + InputEvent_Touch touch; /** All touch points. */ std::vector touches; /** Device type of the touch source. */ - TouchSourceType sourceType; + InputEvent_TouchSourceType sourceType; }; #ifdef __cplusplus -- Gitee From b8978aa0322dbba33f2d02e44864ee27fdbfe172 Mon Sep 17 00:00:00 2001 From: s00430227 Date: Sat, 6 Jan 2024 14:59:47 +0800 Subject: [PATCH 05/10] commit multimodalinput inject event api Signed-off-by: s00430227 --- .../kits/c/input_event/capi_input_event.h | 12 ++++----- .../kits/c/input_event/capi_key_event.h | 4 +-- .../kits/c/input_event/capi_mouse_event.h | 26 +++++++++---------- .../kits/c/input_event/capi_touch_event.h | 20 +++++++------- multimodalinput/kits/c/ohinput.ndk.json | 6 ++--- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/multimodalinput/kits/c/input_event/capi_input_event.h b/multimodalinput/kits/c/input_event/capi_input_event.h index 86927302a9f..9c21379ea61 100644 --- a/multimodalinput/kits/c/input_event/capi_input_event.h +++ b/multimodalinput/kits/c/input_event/capi_input_event.h @@ -28,35 +28,35 @@ extern "C" { /** * Inject system keys. * - * @param { CAPI_KeyEvent } keyEvent - the key event to be injected. + * @param { OH_KeyEvent } keyEvent - the key event to be injected. * @return Returns 0 if success; returns a non-0 value otherwise * @syscap SystemCapability.MultimodalInput.Input.InputSimulator * @systemapi hide for inner use * @since 11 */ -int32_t OH_InputEvent_InjectEvent(struct InputEvent_KeyEvent* keyEvent); +int32_t OH_InputEventClient_InjectEvent(struct OH_KeyEvent* keyEvent); /** * Inject mouse event. * - * @param { CAPI_MouseEvent } mouseEvent - the mouse event to be injected. + * @param { OH_MouseEvent } mouseEvent - the mouse event to be injected. * @return Returns 0 if success; returns a non-0 value otherwise * @syscap SystemCapability.MultimodalInput.Input.InputSimulator * @systemapi hide for inner use * @since 11 */ -int32_t OH_InputEvent_InjectMouseEvent(struct InputEvent_MouseEvent* mouseEvent); +int32_t OH_InputEventClient_InjectMouseEvent(struct OH_MouseEvent* mouseEvent); /** * Inject touch event. * - * @param { CAPI_TouchEvent } touchEvent - the touch event to be injected. + * @param { OH_TouchEvent } touchEvent - the touch event to be injected. * @return Returns 0 if success; returns a non-0 value otherwise * @syscap SystemCapability.MultimodalInput.Input.InputSimulator * @systemapi hide for inner use * @since 11 */ -int32_t OH_InputEvent_InjectTouchEvent(struct InputEvent_TouchEvent* touchEvent); +int32_t OH_InputEventClient_InjectTouchEvent(struct OH_TouchEvent* touchEvent); #ifdef __cplusplus } diff --git a/multimodalinput/kits/c/input_event/capi_key_event.h b/multimodalinput/kits/c/input_event/capi_key_event.h index fb8acc868df..c437fee69ba 100644 --- a/multimodalinput/kits/c/input_event/capi_key_event.h +++ b/multimodalinput/kits/c/input_event/capi_key_event.h @@ -353,9 +353,9 @@ typedef enum { KEYCODE_BTN_7 = 3107, KEYCODE_BTN_8 = 3108, KEYCODE_BTN_9 = 3109 -} InputEvent_KeyCode; +} OH_KeyCode; -struct InputEvent_KeyEvent { +struct OH_KeyEvent { bool isPressed = false; int32_t keyCode; int32_t keyDownDuration = 0; diff --git a/multimodalinput/kits/c/input_event/capi_mouse_event.h b/multimodalinput/kits/c/input_event/capi_mouse_event.h index 00822ea7f96..0f3c8041eff 100644 --- a/multimodalinput/kits/c/input_event/capi_mouse_event.h +++ b/multimodalinput/kits/c/input_event/capi_mouse_event.h @@ -43,7 +43,7 @@ typedef enum { MOUSE_ACTION_ACTION_DOWN = 7, /** Lifting of the mouse touch pad. */ MOUSE_ACTION_ACTION_UP = 8 -} InputEvent_MouseAction; +} MouseEvent_Action; typedef enum { /** Left button on the mouse. */ @@ -62,7 +62,7 @@ typedef enum { MOUSE_BUTTON_BACK = 6, /** Task key on the mouse. */ MOUSE_BUTTON_TASK = 7 -} InputEvent_MouseButton; +} MouseEvent_Button; typedef enum { /** Vertical scroll axis. */ @@ -71,7 +71,7 @@ typedef enum { MOUSE_AXIS_SCROLL_HORIZONTAL = 1, /** Pinch axis. */ MOUSE_AXIS_PINCH = 2 -} InputEvent_MouseAxis; +} MouseEvent_Axis; typedef enum { /** Unknown type. */ @@ -82,19 +82,19 @@ typedef enum { MOUSE_TOOLTYPE_JOYSTICK = 2, /** Touch pad. */ MOUSE_TOOLTYPE_TOUCHPAD = 3 -} InputEvent_MouseToolType; +} MouseEvent_ToolType; -struct InputEvent_AxisValue { +struct MouseEvent_AxisValue { /** Axis type. */ - InputEvent_MouseAxis axis; + MouseEvent_Axis axis; /** Axis value. */ int32_t value; }; -struct InputEvent_MouseEvent { +struct OH_MouseEvent { /** Mouse event action. */ - InputEvent_MouseAction action; + MouseEvent_Action action; /** X coordinate of the mouse pointer on the screen. */ int32_t screenX; /** Y coordinate of the mouse pointer on the screen. */ @@ -111,13 +111,13 @@ struct InputEvent_MouseEvent { /** Y axis offset relative to the previous reported mouse pointer position. */ int32_t rawDeltaY; /** Button that is currently pressed or released. */ - InputEvent_MouseButton button; + MouseEvent_Button button; /** Button that is being pressed. */ - std::vector pressedButtons; + std::vector pressedButtons; /** All axis data contained in the event. */ - std::vector axes; + std::vector axes; /** List of pressed keys. */ - std::vector pressedKeys; + std::vector pressedKeys; /** Whether ctrlKey is being pressed. */ bool ctrlKey; /** Whether altKey is being pressed. */ @@ -135,7 +135,7 @@ struct InputEvent_MouseEvent { /** Whether scrollLock is active. */ bool scrollLock; /** Tool type */ - InputEvent_MouseToolType toolType; + MouseEvent_ToolType toolType; }; #ifdef __cplusplus diff --git a/multimodalinput/kits/c/input_event/capi_touch_event.h b/multimodalinput/kits/c/input_event/capi_touch_event.h index df55fdf4f76..be51b891f29 100644 --- a/multimodalinput/kits/c/input_event/capi_touch_event.h +++ b/multimodalinput/kits/c/input_event/capi_touch_event.h @@ -32,7 +32,7 @@ typedef enum { TOUCH_ACTION_MOVE = 2, /** Touch lifted. */ TOUCH_ACTION_UP = 3, -} InputEvent_TouchAction; +} TouchEvent_Action; typedef enum { /** Touchscreen. */ @@ -41,7 +41,7 @@ typedef enum { TOUCH_SOURCE_TYPE_PEN = 1, /** Touchpad. */ TOUCH_SOURCE_TYPE_TOUCH_PAD = 2 -} InputEvent_TouchSourceType; +} TouchEvent_SourceType; typedef enum { /** Finger. */ @@ -60,9 +60,9 @@ typedef enum { TOUCH_TOOLTYPE_MOUSE = 6, /** Lens. */ TOUCH_TOOLTYPE_LENS = 7, -} InputEvent_TouchToolType; +} TouchEvent_ToolType; -struct InputEvent_Touch { +struct TouchEvent_Point { /** Pointer identifier. */ int32_t id; /** Time stamp when touch is pressed. */ @@ -98,18 +98,18 @@ struct InputEvent_Touch { /** Y coordinate of the input device. */ int32_t rawY; /** Tool type. */ - InputEvent_TouchToolType toolType; + TouchEvent_ToolType toolType; }; -struct InputEvent_TouchEvent { +struct OH_TouchEvent { /** Touch action. */ - InputEvent_TouchAction action; + TouchEvent_Action action; /** Current touch point. */ - InputEvent_Touch touch; + TouchEvent_Point touch; /** All touch points. */ - std::vector touches; + std::vector touches; /** Device type of the touch source. */ - InputEvent_TouchSourceType sourceType; + TouchEvent_SourceType sourceType; }; #ifdef __cplusplus diff --git a/multimodalinput/kits/c/ohinput.ndk.json b/multimodalinput/kits/c/ohinput.ndk.json index 75ebe93b788..7e057deaf9a 100644 --- a/multimodalinput/kits/c/ohinput.ndk.json +++ b/multimodalinput/kits/c/ohinput.ndk.json @@ -1,5 +1,5 @@ [ - { "name": "OH_InputEvent_InjectEvent" }, - { "name": "OH_InputEvent_InjectMouseEvent" }, - { "name": "OH_InputEvent_InjectTouchEvent" } + { "name": "OH_InputEventClient_InjectEvent" }, + { "name": "OH_InputEventClient_InjectMouseEvent" }, + { "name": "OH_InputEventClient_InjectTouchEvent" } ] \ No newline at end of file -- Gitee From 83620ce0751bcacf43a042b9a1298c4e7c9de6dc Mon Sep 17 00:00:00 2001 From: s00430227 Date: Sat, 6 Jan 2024 15:04:11 +0800 Subject: [PATCH 06/10] commit multimodalinput inject event api Signed-off-by: s00430227 --- multimodalinput/kits/c/input_event/capi_key_event.h | 2 +- multimodalinput/kits/c/input_event/capi_mouse_event.h | 4 ++-- multimodalinput/kits/c/input_event/capi_touch_event.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/multimodalinput/kits/c/input_event/capi_key_event.h b/multimodalinput/kits/c/input_event/capi_key_event.h index c437fee69ba..11853a4f0e5 100644 --- a/multimodalinput/kits/c/input_event/capi_key_event.h +++ b/multimodalinput/kits/c/input_event/capi_key_event.h @@ -355,7 +355,7 @@ typedef enum { KEYCODE_BTN_9 = 3109 } OH_KeyCode; -struct OH_KeyEvent { +typedef struct OH_KeyEvent { bool isPressed = false; int32_t keyCode; int32_t keyDownDuration = 0; diff --git a/multimodalinput/kits/c/input_event/capi_mouse_event.h b/multimodalinput/kits/c/input_event/capi_mouse_event.h index 0f3c8041eff..32e3f892816 100644 --- a/multimodalinput/kits/c/input_event/capi_mouse_event.h +++ b/multimodalinput/kits/c/input_event/capi_mouse_event.h @@ -85,14 +85,14 @@ typedef enum { } MouseEvent_ToolType; -struct MouseEvent_AxisValue { +typedef struct MouseEvent_AxisValue { /** Axis type. */ MouseEvent_Axis axis; /** Axis value. */ int32_t value; }; -struct OH_MouseEvent { +typedef struct OH_MouseEvent { /** Mouse event action. */ MouseEvent_Action action; /** X coordinate of the mouse pointer on the screen. */ diff --git a/multimodalinput/kits/c/input_event/capi_touch_event.h b/multimodalinput/kits/c/input_event/capi_touch_event.h index be51b891f29..2322695be4f 100644 --- a/multimodalinput/kits/c/input_event/capi_touch_event.h +++ b/multimodalinput/kits/c/input_event/capi_touch_event.h @@ -62,7 +62,7 @@ typedef enum { TOUCH_TOOLTYPE_LENS = 7, } TouchEvent_ToolType; -struct TouchEvent_Point { +typedef struct TouchEvent_Point { /** Pointer identifier. */ int32_t id; /** Time stamp when touch is pressed. */ @@ -101,7 +101,7 @@ struct TouchEvent_Point { TouchEvent_ToolType toolType; }; -struct OH_TouchEvent { +typedef struct OH_TouchEvent { /** Touch action. */ TouchEvent_Action action; /** Current touch point. */ -- Gitee From b2def2f164e84df15508ae927bcbf03fabe14444 Mon Sep 17 00:00:00 2001 From: s00430227 Date: Sat, 6 Jan 2024 16:30:53 +0800 Subject: [PATCH 07/10] commit multimodalinput inject event api Signed-off-by: s00430227 --- .../kits/c/input_event/capi_input_event.h | 57 +++++++++++++++---- .../kits/c/input_event/capi_key_event.h | 12 ++++ .../kits/c/input_event/capi_mouse_event.h | 37 +++++++++++- .../kits/c/input_event/capi_touch_event.h | 30 ++++++++++ multimodalinput/kits/c/ohinput.ndk.json | 15 ++++- 5 files changed, 135 insertions(+), 16 deletions(-) diff --git a/multimodalinput/kits/c/input_event/capi_input_event.h b/multimodalinput/kits/c/input_event/capi_input_event.h index 9c21379ea61..b5deacf4665 100644 --- a/multimodalinput/kits/c/input_event/capi_input_event.h +++ b/multimodalinput/kits/c/input_event/capi_input_event.h @@ -16,6 +16,27 @@ #ifndef CAPI_INPUT_EVENT_H #define CAPI_INPUT_EVENT_H +/** + * @addtogroup OHInput + * @{ + * + * @brief Provides the C interface in the multi-modal input domain. + * + * @since 11 + * @version 1.0 + */ + +/** + * @file capi_input_event.h + * + * @brief Provides C interfaces for multi-modal event injection. + * + * @syscap SystemCapability.MultimodalInput.Input.InputSimulator + * @library ohinput.so + * @since 11 + * @version 1.0 + */ + #include #include "capi_key_event.h" #include "capi_mouse_event.h" @@ -26,35 +47,47 @@ extern "C" { #endif /** - * Inject system keys. + * @brief Inject system keys. * - * @param { OH_KeyEvent } keyEvent - the key event to be injected. - * @return Returns 0 if success; returns a non-0 value otherwise + * @param keyEvent - the key event to be injected. + * @return 0 - Success. + * 201 - Missing permissions. + * 202 - SystemAPI permission error. + * 401 - Parameter error. + * @permission systemapi hide for inner use * @syscap SystemCapability.MultimodalInput.Input.InputSimulator - * @systemapi hide for inner use * @since 11 + * @version 1.0 */ int32_t OH_InputEventClient_InjectEvent(struct OH_KeyEvent* keyEvent); /** - * Inject mouse event. + * @brief Inject mouse event. * - * @param { OH_MouseEvent } mouseEvent - the mouse event to be injected. - * @return Returns 0 if success; returns a non-0 value otherwise + * @param mouseEvent - the mouse event to be injected. + * @return 0 - Success. + * 201 - Missing permissions. + * 202 - SystemAPI permission error. + * 401 - Parameter error. + * @permission systemapi hide for inner use * @syscap SystemCapability.MultimodalInput.Input.InputSimulator - * @systemapi hide for inner use * @since 11 + * @version 1.0 */ int32_t OH_InputEventClient_InjectMouseEvent(struct OH_MouseEvent* mouseEvent); /** - * Inject touch event. + * @brief Inject touch event. * - * @param { OH_TouchEvent } touchEvent - the touch event to be injected. - * @return Returns 0 if success; returns a non-0 value otherwise + * @param touchEvent - the touch event to be injected. + * @return 0 - Success. + * 201 - Missing permissions. + * 202 - SystemAPI permission error. + * 401 - Parameter error. + * @permission systemapi hide for inner use * @syscap SystemCapability.MultimodalInput.Input.InputSimulator - * @systemapi hide for inner use * @since 11 + * @version 1.0 */ int32_t OH_InputEventClient_InjectTouchEvent(struct OH_TouchEvent* touchEvent); diff --git a/multimodalinput/kits/c/input_event/capi_key_event.h b/multimodalinput/kits/c/input_event/capi_key_event.h index 11853a4f0e5..e3b227f9f84 100644 --- a/multimodalinput/kits/c/input_event/capi_key_event.h +++ b/multimodalinput/kits/c/input_event/capi_key_event.h @@ -22,6 +22,12 @@ extern "C" { #endif +/** + * @brief Enumerated values of OpenHarmony key code. + * + * @since 11 + * @version 1.0 + */ typedef enum { KEYCODE_FN = 0, KEYCODE_UNKNOWN = -1, @@ -355,6 +361,12 @@ typedef enum { KEYCODE_BTN_9 = 3109 } OH_KeyCode; +/** + * @brief The key event to be injected. + * + * @since 11 + * @version 1.0 + */ typedef struct OH_KeyEvent { bool isPressed = false; int32_t keyCode; diff --git a/multimodalinput/kits/c/input_event/capi_mouse_event.h b/multimodalinput/kits/c/input_event/capi_mouse_event.h index 32e3f892816..1f8fd426166 100644 --- a/multimodalinput/kits/c/input_event/capi_mouse_event.h +++ b/multimodalinput/kits/c/input_event/capi_mouse_event.h @@ -24,6 +24,12 @@ extern "C" { #endif +/** + * @brief Enumerated values of mouse event action. + * + * @since 11 + * @version 1.0 + */ typedef enum { /** Cancel. */ MOUSE_ACTION_CANCEL = 0, @@ -45,6 +51,12 @@ typedef enum { MOUSE_ACTION_ACTION_UP = 8 } MouseEvent_Action; +/** + * @brief Enumerated values of mouse event button. + * + * @since 11 + * @version 1.0 + */ typedef enum { /** Left button on the mouse. */ MOUSE_BUTTON_LEFT = 0, @@ -64,6 +76,12 @@ typedef enum { MOUSE_BUTTON_TASK = 7 } MouseEvent_Button; +/** + * @brief Enumerated values of mouse event axis. + * + * @since 11 + * @version 1.0 + */ typedef enum { /** Vertical scroll axis. */ MOUSE_AXIS_SCROLL_VERTICAL = 0, @@ -73,6 +91,12 @@ typedef enum { MOUSE_AXIS_PINCH = 2 } MouseEvent_Axis; +/** + * @brief Enumerated values of mouse event tool type. + * + * @since 11 + * @version 1.0 + */ typedef enum { /** Unknown type. */ MOUSE_TOOLTYPE_UNKNOWN = 0, @@ -84,7 +108,12 @@ typedef enum { MOUSE_TOOLTYPE_TOUCHPAD = 3 } MouseEvent_ToolType; - +/** + * @brief Structure of the axis information in the mouse event. + * + * @since 11 + * @version 1.0 + */ typedef struct MouseEvent_AxisValue { /** Axis type. */ MouseEvent_Axis axis; @@ -92,6 +121,12 @@ typedef struct MouseEvent_AxisValue { int32_t value; }; +/** + * @brief The mouse event to be injected. + * + * @since 11 + * @version 1.0 + */ typedef struct OH_MouseEvent { /** Mouse event action. */ MouseEvent_Action action; diff --git a/multimodalinput/kits/c/input_event/capi_touch_event.h b/multimodalinput/kits/c/input_event/capi_touch_event.h index 2322695be4f..e637bf55a9a 100644 --- a/multimodalinput/kits/c/input_event/capi_touch_event.h +++ b/multimodalinput/kits/c/input_event/capi_touch_event.h @@ -23,6 +23,12 @@ extern "C" { #endif +/** + * @brief Enumerated values of touch event action. + * + * @since 11 + * @version 1.0 + */ typedef enum { /** Touch cancelled. */ TOUCH_ACTION_CANCEL = 0, @@ -34,6 +40,12 @@ typedef enum { TOUCH_ACTION_UP = 3, } TouchEvent_Action; +/** + * @brief Enumerated values of touch event source type. + * + * @since 11 + * @version 1.0 + */ typedef enum { /** Touchscreen. */ TOUCH_SOURCE_TYPE_TOUCH_SCREEN = 0, @@ -43,6 +55,12 @@ typedef enum { TOUCH_SOURCE_TYPE_TOUCH_PAD = 2 } TouchEvent_SourceType; +/** + * @brief Enumerated values of touch event tool type. + * + * @since 11 + * @version 1.0 + */ typedef enum { /** Finger. */ TOUCH_TOOLTYPE_FINGER = 0, @@ -62,6 +80,12 @@ typedef enum { TOUCH_TOOLTYPE_LENS = 7, } TouchEvent_ToolType; +/** + * @brief Information structure of the touch point in a touch event. + * + * @since 11 + * @version 1.0 + */ typedef struct TouchEvent_Point { /** Pointer identifier. */ int32_t id; @@ -101,6 +125,12 @@ typedef struct TouchEvent_Point { TouchEvent_ToolType toolType; }; +/** + * @brief The touch event to be injected. + * + * @since 11 + * @version 1.0 + */ typedef struct OH_TouchEvent { /** Touch action. */ TouchEvent_Action action; diff --git a/multimodalinput/kits/c/ohinput.ndk.json b/multimodalinput/kits/c/ohinput.ndk.json index 7e057deaf9a..b07d85d00ef 100644 --- a/multimodalinput/kits/c/ohinput.ndk.json +++ b/multimodalinput/kits/c/ohinput.ndk.json @@ -1,5 +1,14 @@ [ - { "name": "OH_InputEventClient_InjectEvent" }, - { "name": "OH_InputEventClient_InjectMouseEvent" }, - { "name": "OH_InputEventClient_InjectTouchEvent" } + { + "first_introduced": "11", + "name": "OH_InputEventClient_InjectEvent" + }, + { + "first_introduced": "11", + "name": "OH_InputEventClient_InjectMouseEvent" + }, + { + "first_introduced": "11", + "name": "OH_InputEventClient_InjectTouchEvent" + } ] \ No newline at end of file -- Gitee From 945ff0f44e048d931b204f87831acdd95016fc06 Mon Sep 17 00:00:00 2001 From: s00430227 Date: Mon, 8 Jan 2024 15:16:21 +0800 Subject: [PATCH 08/10] commit multimodalinput inject event api Signed-off-by: s00430227 --- .../kits/c/input_event/capi_input_event.h | 15 ++---- .../kits/c/input_event/capi_key_event.h | 35 +++++++++---- .../kits/c/input_event/capi_mouse_event.h | 52 +++++++++++-------- .../kits/c/input_event/capi_touch_event.h | 44 ++++++++++------ 4 files changed, 84 insertions(+), 62 deletions(-) diff --git a/multimodalinput/kits/c/input_event/capi_input_event.h b/multimodalinput/kits/c/input_event/capi_input_event.h index b5deacf4665..b449a216c01 100644 --- a/multimodalinput/kits/c/input_event/capi_input_event.h +++ b/multimodalinput/kits/c/input_event/capi_input_event.h @@ -32,7 +32,7 @@ * @brief Provides C interfaces for multi-modal event injection. * * @syscap SystemCapability.MultimodalInput.Input.InputSimulator - * @library ohinput.so + * @library libohinput.so * @since 11 * @version 1.0 */ @@ -42,15 +42,11 @@ #include "capi_mouse_event.h" #include "capi_touch_event.h" -#ifdef __cplusplus -extern "C" { -#endif - /** * @brief Inject system keys. * * @param keyEvent - the key event to be injected. - * @return 0 - Success. + * @return 0 - Success. * 201 - Missing permissions. * 202 - SystemAPI permission error. * 401 - Parameter error. @@ -65,7 +61,7 @@ int32_t OH_InputEventClient_InjectEvent(struct OH_KeyEvent* keyEvent); * @brief Inject mouse event. * * @param mouseEvent - the mouse event to be injected. - * @return 0 - Success. + * @return 0 - Success. * 201 - Missing permissions. * 202 - SystemAPI permission error. * 401 - Parameter error. @@ -80,7 +76,7 @@ int32_t OH_InputEventClient_InjectMouseEvent(struct OH_MouseEvent* mouseEvent); * @brief Inject touch event. * * @param touchEvent - the touch event to be injected. - * @return 0 - Success. + * @return 0 - Success. * 201 - Missing permissions. * 202 - SystemAPI permission error. * 401 - Parameter error. @@ -91,7 +87,4 @@ int32_t OH_InputEventClient_InjectMouseEvent(struct OH_MouseEvent* mouseEvent); */ int32_t OH_InputEventClient_InjectTouchEvent(struct OH_TouchEvent* touchEvent); -#ifdef __cplusplus -} -#endif #endif // CAPI_INPUT_EVENT_H diff --git a/multimodalinput/kits/c/input_event/capi_key_event.h b/multimodalinput/kits/c/input_event/capi_key_event.h index e3b227f9f84..812acd70750 100644 --- a/multimodalinput/kits/c/input_event/capi_key_event.h +++ b/multimodalinput/kits/c/input_event/capi_key_event.h @@ -16,15 +16,32 @@ #ifndef CAPI_KEY_EVENT_H #define CAPI_KEY_EVENT_H -#include +/** + * @addtogroup OHInput + * @{ + * + * @brief Provides the C interface in the multi-modal input domain. + * + * @since 11 + * @version 1.0 + */ + +/** + * @file capi_key_event.h + * + * @brief Defines the key event structure and related enumeration values. + * + * @syscap SystemCapability.MultimodalInput.Input.InputSimulator + * @library libohinput.so + * @since 11 + * @version 1.0 + */ -#ifdef __cplusplus -extern "C" { -#endif +#include /** * @brief Enumerated values of OpenHarmony key code. - * + * * @since 11 * @version 1.0 */ @@ -363,7 +380,7 @@ typedef enum { /** * @brief The key event to be injected. - * + * * @since 11 * @version 1.0 */ @@ -372,10 +389,6 @@ typedef struct OH_KeyEvent { int32_t keyCode; int32_t keyDownDuration = 0; bool isIntercepted = false; -}; - -#ifdef __cplusplus -} -#endif +} OH_KeyEvent; #endif // CAPI_KEY_EVENT_H diff --git a/multimodalinput/kits/c/input_event/capi_mouse_event.h b/multimodalinput/kits/c/input_event/capi_mouse_event.h index 1f8fd426166..2d1815e199d 100644 --- a/multimodalinput/kits/c/input_event/capi_mouse_event.h +++ b/multimodalinput/kits/c/input_event/capi_mouse_event.h @@ -16,17 +16,33 @@ #ifndef CAPI_MOUSE_EVENT_H #define CAPI_MOUSE_EVENT_H +/** + * @addtogroup OHInput + * @{ + * + * @brief Provides the C interface in the multi-modal input domain. + * + * @since 11 + * @version 1.0 + */ + +/** + * @file capi_mouse_event.h + * + * @brief Defines the mouse event structure and related enumeration values. + * + * @syscap SystemCapability.MultimodalInput.Input.InputSimulator + * @library libohinput.so + * @since 11 + * @version 1.0 + */ + #include -#include #include "capi_key_event.h" -#ifdef __cplusplus -extern "C" { -#endif - /** * @brief Enumerated values of mouse event action. - * + * * @since 11 * @version 1.0 */ @@ -53,7 +69,7 @@ typedef enum { /** * @brief Enumerated values of mouse event button. - * + * * @since 11 * @version 1.0 */ @@ -78,7 +94,7 @@ typedef enum { /** * @brief Enumerated values of mouse event axis. - * + * * @since 11 * @version 1.0 */ @@ -93,7 +109,7 @@ typedef enum { /** * @brief Enumerated values of mouse event tool type. - * + * * @since 11 * @version 1.0 */ @@ -110,7 +126,7 @@ typedef enum { /** * @brief Structure of the axis information in the mouse event. - * + * * @since 11 * @version 1.0 */ @@ -119,11 +135,11 @@ typedef struct MouseEvent_AxisValue { MouseEvent_Axis axis; /** Axis value. */ int32_t value; -}; +} MouseEvent_AxisValue; /** * @brief The mouse event to be injected. - * + * * @since 11 * @version 1.0 */ @@ -147,12 +163,6 @@ typedef struct OH_MouseEvent { int32_t rawDeltaY; /** Button that is currently pressed or released. */ MouseEvent_Button button; - /** Button that is being pressed. */ - std::vector pressedButtons; - /** All axis data contained in the event. */ - std::vector axes; - /** List of pressed keys. */ - std::vector pressedKeys; /** Whether ctrlKey is being pressed. */ bool ctrlKey; /** Whether altKey is being pressed. */ @@ -171,10 +181,6 @@ typedef struct OH_MouseEvent { bool scrollLock; /** Tool type */ MouseEvent_ToolType toolType; -}; - -#ifdef __cplusplus -} -#endif +} OH_MouseEvent; #endif // CAPI_MOUSE_EVENT_H diff --git a/multimodalinput/kits/c/input_event/capi_touch_event.h b/multimodalinput/kits/c/input_event/capi_touch_event.h index e637bf55a9a..9414b0768f2 100644 --- a/multimodalinput/kits/c/input_event/capi_touch_event.h +++ b/multimodalinput/kits/c/input_event/capi_touch_event.h @@ -16,16 +16,32 @@ #ifndef CAPI_TOUCH_EVENT_H #define CAPI_TOUCH_EVENT_H -#include -#include +/** + * @addtogroup OHInput + * @{ + * + * @brief Provides the C interface in the multi-modal input domain. + * + * @since 11 + * @version 1.0 + */ + +/** + * @file capi_touch_event.h + * + * @brief Defines the touch event structure and related enumeration values. + * + * @syscap SystemCapability.MultimodalInput.Input.InputSimulator + * @library libohinput.so + * @since 11 + * @version 1.0 + */ -#ifdef __cplusplus -extern "C" { -#endif +#include /** * @brief Enumerated values of touch event action. - * + * * @since 11 * @version 1.0 */ @@ -42,7 +58,7 @@ typedef enum { /** * @brief Enumerated values of touch event source type. - * + * * @since 11 * @version 1.0 */ @@ -57,7 +73,7 @@ typedef enum { /** * @brief Enumerated values of touch event tool type. - * + * * @since 11 * @version 1.0 */ @@ -82,7 +98,7 @@ typedef enum { /** * @brief Information structure of the touch point in a touch event. - * + * * @since 11 * @version 1.0 */ @@ -123,7 +139,7 @@ typedef struct TouchEvent_Point { int32_t rawY; /** Tool type. */ TouchEvent_ToolType toolType; -}; +} TouchEvent_Point; /** * @brief The touch event to be injected. @@ -136,14 +152,8 @@ typedef struct OH_TouchEvent { TouchEvent_Action action; /** Current touch point. */ TouchEvent_Point touch; - /** All touch points. */ - std::vector touches; /** Device type of the touch source. */ TouchEvent_SourceType sourceType; -}; - -#ifdef __cplusplus -} -#endif +} OH_TouchEvent; #endif // CAPI_TOUCH_EVENT_H -- Gitee From ab4cf932310fbc4338c2866e21f63621e3521815 Mon Sep 17 00:00:00 2001 From: s00430227 Date: Mon, 8 Jan 2024 17:05:59 +0800 Subject: [PATCH 09/10] commit multimodalinput inject event api Signed-off-by: s00430227 --- multimodalinput/kits/c/input_event/capi_input_event.h | 7 +++++++ multimodalinput/kits/c/input_event/capi_key_event.h | 8 ++++++++ multimodalinput/kits/c/input_event/capi_mouse_event.h | 8 ++++++++ multimodalinput/kits/c/input_event/capi_touch_event.h | 8 ++++++++ 4 files changed, 31 insertions(+) diff --git a/multimodalinput/kits/c/input_event/capi_input_event.h b/multimodalinput/kits/c/input_event/capi_input_event.h index b449a216c01..3e10d78324d 100644 --- a/multimodalinput/kits/c/input_event/capi_input_event.h +++ b/multimodalinput/kits/c/input_event/capi_input_event.h @@ -42,6 +42,10 @@ #include "capi_mouse_event.h" #include "capi_touch_event.h" +#ifdef __cplusplus +extern "C" { +#endif + /** * @brief Inject system keys. * @@ -87,4 +91,7 @@ int32_t OH_InputEventClient_InjectMouseEvent(struct OH_MouseEvent* mouseEvent); */ int32_t OH_InputEventClient_InjectTouchEvent(struct OH_TouchEvent* touchEvent); +#ifdef __cplusplus +} +#endif #endif // CAPI_INPUT_EVENT_H diff --git a/multimodalinput/kits/c/input_event/capi_key_event.h b/multimodalinput/kits/c/input_event/capi_key_event.h index 812acd70750..38aa337070c 100644 --- a/multimodalinput/kits/c/input_event/capi_key_event.h +++ b/multimodalinput/kits/c/input_event/capi_key_event.h @@ -39,6 +39,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + /** * @brief Enumerated values of OpenHarmony key code. * @@ -391,4 +395,8 @@ typedef struct OH_KeyEvent { bool isIntercepted = false; } OH_KeyEvent; +#ifdef __cplusplus +} +#endif + #endif // CAPI_KEY_EVENT_H diff --git a/multimodalinput/kits/c/input_event/capi_mouse_event.h b/multimodalinput/kits/c/input_event/capi_mouse_event.h index 2d1815e199d..f6181b81e63 100644 --- a/multimodalinput/kits/c/input_event/capi_mouse_event.h +++ b/multimodalinput/kits/c/input_event/capi_mouse_event.h @@ -40,6 +40,10 @@ #include #include "capi_key_event.h" +#ifdef __cplusplus +extern "C" { +#endif + /** * @brief Enumerated values of mouse event action. * @@ -183,4 +187,8 @@ typedef struct OH_MouseEvent { MouseEvent_ToolType toolType; } OH_MouseEvent; +#ifdef __cplusplus +} +#endif + #endif // CAPI_MOUSE_EVENT_H diff --git a/multimodalinput/kits/c/input_event/capi_touch_event.h b/multimodalinput/kits/c/input_event/capi_touch_event.h index 9414b0768f2..5dc762ba711 100644 --- a/multimodalinput/kits/c/input_event/capi_touch_event.h +++ b/multimodalinput/kits/c/input_event/capi_touch_event.h @@ -39,6 +39,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + /** * @brief Enumerated values of touch event action. * @@ -156,4 +160,8 @@ typedef struct OH_TouchEvent { TouchEvent_SourceType sourceType; } OH_TouchEvent; +#ifdef __cplusplus +} +#endif + #endif // CAPI_TOUCH_EVENT_H -- Gitee From fab44c33f91825dd0bed0f319d73964500042375 Mon Sep 17 00:00:00 2001 From: s00430227 Date: Mon, 8 Jan 2024 19:54:21 +0800 Subject: [PATCH 10/10] commit multimodalinput inject event api Signed-off-by: s00430227 --- multimodalinput/kits/c/input_event/capi_touch_event.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multimodalinput/kits/c/input_event/capi_touch_event.h b/multimodalinput/kits/c/input_event/capi_touch_event.h index 5dc762ba711..eefdb10f70f 100644 --- a/multimodalinput/kits/c/input_event/capi_touch_event.h +++ b/multimodalinput/kits/c/input_event/capi_touch_event.h @@ -147,7 +147,7 @@ typedef struct TouchEvent_Point { /** * @brief The touch event to be injected. - * + * * @since 11 * @version 1.0 */ -- Gitee