1 /* 2 * Copyright (C) 2023-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 * Description: Remote Control related data from OH XComponent structure definitions. 15 * Author: mayihao 16 * Create: 2022-09-14 17 */ 18 19 20 #ifndef OH_REMOTE_CONTROL_EVENT_H 21 #define OH_REMOTE_CONTROL_EVENT_H 22 23 #include <stdint.h> 24 #include "cast_engine_common.h" 25 26 namespace OHOS { 27 namespace CastEngine { 28 enum class EXPORT XcomponentEventType { 29 REMOTECONTROL_TOUCH, 30 REMOTECONTROL_MOUSE, 31 REMOTECONTROL_PEN, 32 REMOTECONTROL_WHEEL, 33 REMOTECONTROL_KEY, 34 REMOTECONTROL_INPUT_METHOD, 35 REMOTECONTROL_VIRTUAL_KEY, 36 REMOTECONTROL_INVALID_EVENT, 37 }; 38 39 enum EXPORT OHNativeXcomponentResult { 40 OH_NATIVEXCOMPONENT_RESULT_SUCCESS = 0, 41 OH_NATIVEXCOMPONENT_RESULT_FAILED = -1, 42 OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER = -2, 43 }; 44 45 enum EXPORT OHNativeXcomponentTouchEventType { 46 OH_NATIVEXCOMPONENT_TOUCH_DOWN = 0, 47 OH_NATIVEXCOMPONENT_TOUCH_UP, 48 OH_NATIVEXCOMPONENT_TOUCH_MOVE, 49 OH_NATIVEXCOMPONENT_TOUCH_CANCEL, 50 OH_NATIVEXCOMPONENT_TOUCH_PULL_IN_WINDOW, 51 }; 52 53 enum EXPORT OHNativeXcomponentMouseEventAction { 54 OH_NATIVEXCOMPONENT_MOUSE_PRESS = 0, 55 OH_NATIVEXCOMPONENT_MOUSE_RELEASE, 56 OH_NATIVEXCOMPONENT_MOUSE_MOVE, 57 OH_NATIVEXCOMPONENT_MOUSE_NONE, 58 OH_NATIVEXCOMPONENT_MOUSE_PULL_IN_WINDOW, 59 }; 60 61 enum EXPORT OHNativeXcomponentKeyEventType { 62 OH_NATIVEXCOMPONENT_KEY_DOWN = 0, 63 OH_NATIVEXCOMPONENT_KEY_UP, 64 }; 65 66 enum EXPORT OHNativeXcomponentMouseEventButton { 67 OH_NATIVEXCOMPONENT_LEFT_BUTTON = 0, 68 OH_NATIVEXCOMPONENT_MIDDLE_BUTTON, 69 OH_NATIVEXCOMPONENT_RIGHT_BUTTON, 70 }; 71 72 enum EXPORT OHNativeXcomponentInputMethodEventType { 73 OH_NATIVEXCOMPONENT_INPUT_CONTENT = 0, 74 OH_NATIVEXCOMPONENT_INPUT_FOCUS, 75 }; 76 77 enum EXPORT OHNativeXcomponentWheelEventDirection { 78 OH_NATIVEXCOMPONENT_WHEEL_VERTICAL = 0, 79 OH_NATIVEXCOMPONENT_WHEEL_HORIZONTAL 80 }; 81 82 enum EXPORT OHNativeXcomponentVirtualKeyEventType { 83 OH_NATIVEXCOMPONENT_VIRTUALKEY_BACK = 0, 84 OH_NATIVEXCOMPONENT_VIRTUALKEY_HOME, 85 OH_NATIVEXCOMPONENT_VIRTUALKEY_RECENT_APP, 86 OH_NATIVEXCOMPONENT_VIRTUALKEY_QUICK_SETTING 87 }; 88 89 const uint32_t EXPORT OH_MAX_TOUCH_POINTS_NUMBER = 10; 90 const uint32_t EXPORT OH_MAX_CONTENT_LEN = 472; 91 92 const uint32_t EXPORT EXPORT META_CAP_LOCKED = 0x100; 93 const uint32_t EXPORT META_ALT_LOCKED = 0x200; 94 const uint32_t EXPORT META_SYM_LOCKED = 0x400; 95 const uint32_t EXPORT META_SELECTING = 0x800; 96 const uint32_t EXPORT META_ALT_ON = 0x02; 97 const uint32_t EXPORT META_ALT_LEFT_ON = 0x10; 98 const uint32_t EXPORT META_ALT_RIGHT_ON = 0x20; 99 const uint32_t EXPORT META_SHIFT_ON = 0x1; 100 const uint32_t EXPORT META_SHIFT_LEFT_ON = 0x40; 101 const uint32_t EXPORT META_SHIFT_RIGHT_ON = 0x80; 102 const uint32_t EXPORT META_SYM_ON = 0x4; 103 const uint32_t EXPORT META_FUNCTION_ON = 0x8; 104 const uint32_t EXPORT META_CTRL_ON = 0x1000; 105 const uint32_t EXPORT META_CTRL_LEFT_ON = 0x2000; 106 const uint32_t EXPORT META_CTRL_RIGHT_ON = 0x4000; 107 const uint32_t EXPORT META_META_ON = 0x10000; 108 const uint32_t EXPORT META_META_LEFT_ON = 0x20000; 109 const uint32_t EXPORT META_META_RIGHT_ON = 0x40000; 110 const uint32_t EXPORT META_CAPS_LOCK_ON = 0x100000; 111 const uint32_t EXPORT META_NUM_LOCK_ON = 0x200000; 112 const uint32_t EXPORT META_SCROLL_LOCK_ON = 0x400000; 113 114 struct EXPORT OHNativeXcomponentTouchPoint { 115 int32_t id = 0; // Unique identifier of a finger. 116 float screenX = 0.0; // X coordinate of the touch point relative to the left edge of the screen. 117 float screenY = 0.0; // Y coordinate of the touch point relative to the upper edge of the screen. 118 float x = 0.0; // X coordinate of the touch point relative to the left edge of the element to touch. 119 float y = 0.0; // Y coordinate of the touch point relative to the upper edge of the element to touch. 120 OHNativeXcomponentTouchEventType type; 121 double size = 0.0; // Contact area between the finger pad and the screen. 122 float force = 0.0; // Pressure of the current touch event. 123 int64_t timeStamp = 0; // Timestamp of the current touch event. 124 bool isPressed = false; // Whether the current point is pressed. 125 }; 126 127 struct EXPORT OHNativeXcomponentTouchEvent { 128 int32_t id = 0; // Unique identifier of a finger. 129 float screenX = 0.0; // X coordinate of the touch point relative to the left edge of the screen. 130 float screenY = 0.0; // Y coordinate of the touch point relative to the upper edge of the screen. 131 float x = 0.0; // X coordinate of the touch point relative to the left edge of the element to touch. 132 float y = 0.0; // Y coordinate of the touch point relative to the upper edge of the element to touch. 133 OHNativeXcomponentTouchEventType type; 134 double size = 0.0; // Contact area between the finger pad and the screen. 135 float force = 0.0; // Pressure of the current touch event. 136 int64_t deviceId = 0; // ID of the device where the current touch event is generated. 137 int64_t timeStamp = 0; // Timestamp of the current touch event. 138 uint32_t numPoints = 0; // Number of current touch points. 139 OHNativeXcomponentTouchPoint touchPoints[OH_MAX_TOUCH_POINTS_NUMBER]; // Array of the current touch points. 140 }; 141 142 struct EXPORT OHNativeXcomponentMouseEvent { 143 float x = 0.0; // X coordinate of the mouse point relative to the left edge of the element to mouse. 144 float y = 0.0; // Y coordinate of the mouse point relative to the upper edge of the element to mouse. 145 float screenX = 0.0; // X coordinate of the mouse point relative to the left edge of the screen. 146 float screenY = 0.0; // Y coordinate of the mouse point relative to the upper edge of the screen. 147 int64_t timestamp = 0; // Timestamp of the current mouse event. 148 OHNativeXcomponentMouseEventAction action; 149 OHNativeXcomponentMouseEventButton button; 150 }; 151 152 struct EXPORT OHNativeXcomponentKeyEvent { 153 uint8_t reserved; 154 uint16_t keyCode1; // the first key code 155 uint16_t keyCode2; // the second key code 156 uint32_t metaState; // whether meta keys is pressed 157 OHNativeXcomponentKeyEventType type; 158 }; 159 160 struct EXPORT OHNativeXcomponentContentEvent { 161 uint16_t msgLen; 162 char inputText[OH_MAX_CONTENT_LEN]; 163 }; 164 165 struct EXPORT OHNativeXcomponentFocusEvent { 166 uint8_t focusStat; // is focus on 167 double cursorX1; // The X position of the upper-left corner of the cursor 168 double cursorY1; // The Y position of the upper-left corner of the cursor 169 double cursorX2; // The X position of the lowwer-right corner of the cursor 170 double cursorY2; // The Y position of the lowwer-right corner of the cursor 171 }; 172 173 struct EXPORT OHNativeXcomponentInputMethodEvent { 174 OHNativeXcomponentInputMethodEventType type; 175 union { 176 OHNativeXcomponentContentEvent contentEvent; 177 OHNativeXcomponentFocusEvent focusEvent; 178 }; 179 }; 180 181 struct EXPORT OHNativeXcomponentWheelEvent { 182 OHNativeXcomponentWheelEventDirection direction; 183 uint8_t indication = 1; // 0b0:Scrolling to the right/Scrolling down, 0b1:Scrolling to the left/Scrolling up 184 uint8_t scrollUnit = 2; // 0b00:the unit is a pixel, 0b01:the unit is a mouse notch, 0b10-0b11:Reserved 185 uint16_t wheelDis; // wheel distance 186 float x; // X-coordinate when wheel button down 187 float y; // Y-coordinate when wheel button down 188 }; 189 190 struct EXPORT OHNativeXcomponentVirtualKeyEvent { 191 OHNativeXcomponentVirtualKeyEventType type; 192 float x; 193 float y; 194 }; 195 196 struct EXPORT OHRemoteControlEvent { OHRemoteControlEventOHRemoteControlEvent197 OHRemoteControlEvent() {}; 198 XcomponentEventType eventType = XcomponentEventType::REMOTECONTROL_INVALID_EVENT; 199 union { 200 OHNativeXcomponentTouchEvent touchEvent; 201 OHNativeXcomponentMouseEvent mouseEvent; 202 OHNativeXcomponentKeyEvent keyEvent; 203 OHNativeXcomponentInputMethodEvent inputMethodEvent; 204 OHNativeXcomponentWheelEvent wheelEvent; 205 OHNativeXcomponentVirtualKeyEvent virtualKeyEvent; 206 }; 207 }; 208 } // namespace CastEngine 209 } // namespace OHOS 210 #endif 211