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 }; 51 52 enum EXPORT OHNativeXcomponentMouseEventAction { 53 OH_NATIVEXCOMPONENT_MOUSE_PRESS = 0, 54 OH_NATIVEXCOMPONENT_MOUSE_RELEASE, 55 OH_NATIVEXCOMPONENT_MOUSE_MOVE, 56 OH_NATIVEXCOMPONENT_MOUSE_NONE, 57 }; 58 59 enum EXPORT OHNativeXcomponentKeyEventType { 60 OH_NATIVEXCOMPONENT_KEY_DOWN = 0, 61 OH_NATIVEXCOMPONENT_KEY_UP, 62 }; 63 64 enum EXPORT OHNativeXcomponentMouseEventButton { 65 OH_NATIVEXCOMPONENT_LEFT_BUTTON = 0, 66 OH_NATIVEXCOMPONENT_MIDDLE_BUTTON, 67 OH_NATIVEXCOMPONENT_RIGHT_BUTTON, 68 }; 69 70 enum EXPORT OHNativeXcomponentInputMethodEventType { 71 OH_NATIVEXCOMPONENT_INPUT_CONTENT = 0, 72 OH_NATIVEXCOMPONENT_INPUT_FOCUS, 73 }; 74 75 enum EXPORT OHNativeXcomponentWheelEventDirection { 76 OH_NATIVEXCOMPONENT_WHEEL_VERTICAL = 0, 77 OH_NATIVEXCOMPONENT_WHEEL_HORIZONTAL 78 }; 79 80 enum EXPORT OHNativeXcomponentVirtualKeyEventType { 81 OH_NATIVEXCOMPONENT_VIRTUALKEY_BACK = 0, 82 OH_NATIVEXCOMPONENT_VIRTUALKEY_HOME, 83 OH_NATIVEXCOMPONENT_VIRTUALKEY_RECENT_APP, 84 OH_NATIVEXCOMPONENT_VIRTUALKEY_QUICK_SETTING 85 }; 86 87 const uint32_t EXPORT OH_MAX_TOUCH_POINTS_NUMBER = 10; 88 const uint32_t EXPORT OH_MAX_CONTENT_LEN = 472; 89 90 const uint32_t EXPORT EXPORT META_CAP_LOCKED = 0x100; 91 const uint32_t EXPORT META_ALT_LOCKED = 0x200; 92 const uint32_t EXPORT META_SYM_LOCKED = 0x400; 93 const uint32_t EXPORT META_SELECTING = 0x800; 94 const uint32_t EXPORT META_ALT_ON = 0x02; 95 const uint32_t EXPORT META_ALT_LEFT_ON = 0x10; 96 const uint32_t EXPORT META_ALT_RIGHT_ON = 0x20; 97 const uint32_t EXPORT META_SHIFT_ON = 0x1; 98 const uint32_t EXPORT META_SHIFT_LEFT_ON = 0x40; 99 const uint32_t EXPORT META_SHIFT_RIGHT_ON = 0x80; 100 const uint32_t EXPORT META_SYM_ON = 0x4; 101 const uint32_t EXPORT META_FUNCTION_ON = 0x8; 102 const uint32_t EXPORT META_CTRL_ON = 0x1000; 103 const uint32_t EXPORT META_CTRL_LEFT_ON = 0x2000; 104 const uint32_t EXPORT META_CTRL_RIGHT_ON = 0x4000; 105 const uint32_t EXPORT META_META_ON = 0x10000; 106 const uint32_t EXPORT META_META_LEFT_ON = 0x20000; 107 const uint32_t EXPORT META_META_RIGHT_ON = 0x40000; 108 const uint32_t EXPORT META_CAPS_LOCK_ON = 0x100000; 109 const uint32_t EXPORT META_NUM_LOCK_ON = 0x200000; 110 const uint32_t EXPORT META_SCROLL_LOCK_ON = 0x400000; 111 112 struct EXPORT OHNativeXcomponentTouchPoint { 113 int32_t id = 0; // Unique identifier of a finger. 114 float screenX = 0.0; // X coordinate of the touch point relative to the left edge of the screen. 115 float screenY = 0.0; // Y coordinate of the touch point relative to the upper edge of the screen. 116 float x = 0.0; // X coordinate of the touch point relative to the left edge of the element to touch. 117 float y = 0.0; // Y coordinate of the touch point relative to the upper edge of the element to touch. 118 OHNativeXcomponentTouchEventType type; 119 double size = 0.0; // Contact area between the finger pad and the screen. 120 float force = 0.0; // Pressure of the current touch event. 121 int64_t timeStamp = 0; // Timestamp of the current touch event. 122 bool isPressed = false; // Whether the current point is pressed. 123 }; 124 125 struct EXPORT OHNativeXcomponentTouchEvent { 126 int32_t id = 0; // Unique identifier of a finger. 127 float screenX = 0.0; // X coordinate of the touch point relative to the left edge of the screen. 128 float screenY = 0.0; // Y coordinate of the touch point relative to the upper edge of the screen. 129 float x = 0.0; // X coordinate of the touch point relative to the left edge of the element to touch. 130 float y = 0.0; // Y coordinate of the touch point relative to the upper edge of the element to touch. 131 OHNativeXcomponentTouchEventType type; 132 double size = 0.0; // Contact area between the finger pad and the screen. 133 float force = 0.0; // Pressure of the current touch event. 134 int64_t deviceId = 0; // ID of the device where the current touch event is generated. 135 int64_t timeStamp = 0; // Timestamp of the current touch event. 136 uint32_t numPoints = 0; // Number of current touch points. 137 OHNativeXcomponentTouchPoint touchPoints[OH_MAX_TOUCH_POINTS_NUMBER]; // Array of the current touch points. 138 }; 139 140 struct EXPORT OHNativeXcomponentMouseEvent { 141 float x = 0.0; // X coordinate of the mouse point relative to the left edge of the element to mouse. 142 float y = 0.0; // Y coordinate of the mouse point relative to the upper edge of the element to mouse. 143 float screenX = 0.0; // X coordinate of the mouse point relative to the left edge of the screen. 144 float screenY = 0.0; // Y coordinate of the mouse point relative to the upper edge of the screen. 145 int64_t timestamp = 0; // Timestamp of the current mouse event. 146 OHNativeXcomponentMouseEventAction action; 147 OHNativeXcomponentMouseEventButton button; 148 }; 149 150 struct EXPORT OHNativeXcomponentKeyEvent { 151 uint8_t reserved; 152 uint16_t keyCode1; // the first key code 153 uint16_t keyCode2; // the second key code 154 uint32_t metaState; // whether meta keys is pressed 155 OHNativeXcomponentKeyEventType type; 156 }; 157 158 struct EXPORT OHNativeXcomponentContentEvent { 159 uint16_t msgLen; 160 char inputText[OH_MAX_CONTENT_LEN]; 161 }; 162 163 struct EXPORT OHNativeXcomponentFocusEvent { 164 uint8_t focusStat; // is focus on 165 double cursorX1; // The X position of the upper-left corner of the cursor 166 double cursorY1; // The Y position of the upper-left corner of the cursor 167 double cursorX2; // The X position of the lowwer-right corner of the cursor 168 double cursorY2; // The Y position of the lowwer-right corner of the cursor 169 }; 170 171 struct EXPORT OHNativeXcomponentInputMethodEvent { 172 OHNativeXcomponentInputMethodEventType type; 173 union { 174 OHNativeXcomponentContentEvent contentEvent; 175 OHNativeXcomponentFocusEvent focusEvent; 176 }; 177 }; 178 179 struct EXPORT OHNativeXcomponentWheelEvent { 180 OHNativeXcomponentWheelEventDirection direction; 181 uint8_t indication = 1; // 0b0:Scrolling to the right/Scrolling down, 0b1:Scrolling to the left/Scrolling up 182 uint8_t scrollUnit = 2; // 0b00:the unit is a pixel, 0b01:the unit is a mouse notch, 0b10-0b11:Reserved 183 uint16_t wheelDis; // wheel distance 184 float x; // X-coordinate when wheel button down 185 float y; // Y-coordinate when wheel button down 186 }; 187 188 struct EXPORT OHNativeXcomponentVirtualKeyEvent { 189 OHNativeXcomponentVirtualKeyEventType type; 190 float x; 191 float y; 192 }; 193 194 struct EXPORT OHRemoteControlEvent { OHRemoteControlEventOHRemoteControlEvent195 OHRemoteControlEvent() {}; 196 XcomponentEventType eventType = XcomponentEventType::REMOTECONTROL_INVALID_EVENT; 197 union { 198 OHNativeXcomponentTouchEvent touchEvent; 199 OHNativeXcomponentMouseEvent mouseEvent; 200 OHNativeXcomponentKeyEvent keyEvent; 201 OHNativeXcomponentInputMethodEvent inputMethodEvent; 202 OHNativeXcomponentWheelEvent wheelEvent; 203 OHNativeXcomponentVirtualKeyEvent virtualKeyEvent; 204 }; 205 }; 206 } // namespace CastEngine 207 } // namespace OHOS 208 #endif 209