1 /* 2 * Copyright (c) 2021-2022 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 */ 15 #ifndef STRUCT_MULTIMODAL_H 16 #define STRUCT_MULTIMODAL_H 17 18 #include "proto.h" 19 20 namespace OHOS { 21 namespace MMI { 22 namespace { 23 constexpr int32_t MAX_DEVICENAME = 64; 24 constexpr int32_t MAX_UUIDSIZE = 64; 25 constexpr int32_t SYSTEMUID = 1000; 26 constexpr int32_t MAX_SOLTED_COORDS_NUMS = 10; 27 } 28 enum SENIOR_DEVICE_TYPE { 29 INPUT_DEVICE_AISENSOR = 31, 30 INPUT_DEVICE_KNUCKLE = 41 31 }; 32 33 enum DEVICE_TYPE { 34 DEVICE_TYPE_UNKNOWN = -1, 35 DEVICE_TYPE_TOUCH_PANEL = 0, 36 DEVICE_TYPE_KEYBOARD = 1, 37 DEVICE_TYPE_MOUSE = 2, 38 DEVICE_TYPE_STYLUS = 3, 39 DEVICE_TYPE_BUILTIN_KEY = 4, 40 DEVICE_TYPE_ROTATION = 5, 41 DEVICE_TYPE_AI_SPEECH = 6, 42 DEVICE_TYPE_JOYSTICK = 7, 43 DEVICE_TYPE_TOUCHPAD = 8, 44 DEVICE_TYPE_KNUCKLE = 9, 45 DEVICE_TYPE_VIRTUAL_KEYBOARD = 10, 46 }; 47 48 enum BUTTON_STATE { 49 BUTTON_STATE_RELEASED = 0, 50 BUTTON_STATE_PRESSED = 1 51 }; 52 53 enum KEY_STATE { 54 KEY_STATE_RELEASED, 55 KEY_STATE_PRESSED 56 }; 57 58 enum POINTER_AXIS { 59 POINTER_AXIS_SCROLL_VERTICAL = 0, 60 POINTER_AXIS_SCROLL_HORIZONTAL = 1, 61 }; 62 63 enum POINTER_AXIS_SOURCE { 64 POINTER_AXIS_SOURCE_WHEEL = 1, 65 POINTER_AXIS_SOURCE_FINGER, 66 POINTER_AXIS_SOURCE_CONTINUOUS, 67 POINTER_AXIS_SOURCE_WHEEL_TILT, 68 }; 69 70 enum TABLE_TOOL_TYPE { 71 TABLET_TOOL_TYPE_PEN = 1, 72 TABLET_TOOL_TYPE_ERASER, 73 TABLET_TOOL_TYPE_BRUSH, 74 TABLET_TOOL_TYPE_PENCIL, 75 TABLET_TOOL_TYPE_AIRBRUSH, 76 TABLET_TOOL_TYPE_MOUSE, 77 TABLET_TOOL_TYPE_LENS, 78 TABLET_TOOL_TYPE_TOTEM, 79 }; 80 81 enum TABLE_TOOL_PROXIMITY_STATE { 82 TABLET_TOOL_PROXIMITY_STATE_OUT = 0, 83 TABLET_TOOL_PROXIMITY_STATE_IN = 1, 84 }; 85 86 enum TABLE_TOOL_TIP_STATE { 87 TABLET_TOOL_TIP_UP = 0, 88 TABLET_TOOL_TIP_DOWN = 1, 89 }; 90 91 enum POINT_EVENT_TYPE { 92 EVENT_TYPE_INVALID = 0, 93 PRIMARY_POINT_DOWN = 1, 94 PRIMARY_POINT_UP = 2, 95 POINT_MOVE = 3, 96 OTHER_POINT_DOWN = 4, 97 OTHER_POINT_UP = 5, 98 }; 99 100 enum TABLET_PAD_RING_AXIS_SOURCE { 101 TABLET_PAD_RING_SOURCE_UNKNOWN = 1, 102 TABLET_PAD_RING_SOURCE_FINGER, 103 }; 104 105 enum TABLET_PAD_STRIP_AXIS_SOURCE { 106 TABLET_PAD_STRIP_SOURCE_UNKNOWN = 1, 107 TABLET_PAD_STRIP_SOURCE_FINGER, 108 }; 109 110 #pragma pack(1) 111 struct TagPackHead { 112 MmiMessageId idMsg; 113 int32_t sizeEvent[1]; 114 }; 115 #pragma pack() 116 117 struct SeniorDeviceInfo { 118 char physical[MAX_DEVICENAME]; 119 enum SENIOR_DEVICE_TYPE seniorDeviceType; 120 }; 121 122 struct EventJoyStickAxisAbsInfo { 123 int32_t code; 124 int32_t value; 125 int32_t minimum; 126 int32_t maximum; 127 int32_t fuzz; 128 int32_t flat; 129 int32_t resolution; 130 float standardValue; 131 bool isChanged; 132 }; 133 134 struct EventJoyStickAxis { 135 int32_t deviceId; 136 char physical[MAX_DEVICENAME]; 137 char deviceName[MAX_DEVICENAME]; 138 DEVICE_TYPE deviceType; 139 int32_t eventType; 140 char uuid[MAX_UUIDSIZE]; 141 int64_t time; 142 EventJoyStickAxisAbsInfo abs_throttle; 143 EventJoyStickAxisAbsInfo abs_hat0x; 144 EventJoyStickAxisAbsInfo abs_hat0y; 145 EventJoyStickAxisAbsInfo abs_x; 146 EventJoyStickAxisAbsInfo abs_y; 147 EventJoyStickAxisAbsInfo abs_z; 148 EventJoyStickAxisAbsInfo abs_rx; 149 EventJoyStickAxisAbsInfo abs_ry; 150 EventJoyStickAxisAbsInfo abs_rz; 151 EventJoyStickAxisAbsInfo abs_wheel; 152 }; 153 154 struct NormalizedCoords { 155 double x; 156 double y; 157 }; 158 159 struct DeviceFloatCoords { 160 double x; 161 double y; 162 }; 163 164 struct DeviceCoords { 165 double x; 166 double y; 167 }; 168 169 struct TiltDegrees { 170 double x; 171 double y; 172 }; 173 174 struct DiscreteCoords { 175 double x; 176 double y; 177 }; 178 179 struct PhysEllipsis { 180 double major; 181 double minor; 182 }; 183 184 struct Threshold { 185 int32_t upper; 186 int32_t lower; 187 }; 188 189 struct RegisteredEvent { 190 int32_t deviceId; 191 char uuid[MAX_UUIDSIZE]; 192 int32_t eventType; 193 int64_t occurredTime; 194 DEVICE_TYPE deviceType; 195 char physical[MAX_DEVICENAME]; 196 }; 197 198 struct StandardTouchStruct { 199 int64_t time; 200 uint32_t msgType; 201 int32_t buttonType; 202 int32_t buttonCount; 203 int32_t buttonState; 204 int32_t reRventType; 205 int32_t curRventType; 206 int32_t tipState; 207 double x; 208 double y; 209 }; 210 211 struct EventKeyboard { 212 int32_t deviceId; 213 char physical[MAX_DEVICENAME]; 214 char deviceName[MAX_DEVICENAME]; 215 DEVICE_TYPE deviceType; 216 int32_t eventType; 217 char uuid[MAX_UUIDSIZE]; 218 int64_t time; 219 int32_t key; 220 uint32_t seat_key_count; 221 enum KEY_STATE state; 222 int32_t unicode; 223 bool isIntercepted {true}; 224 }; 225 226 struct EventPointer { 227 int32_t deviceId; 228 char physical[MAX_DEVICENAME]; 229 char deviceName[MAX_DEVICENAME]; 230 DEVICE_TYPE deviceType; 231 int32_t eventType; 232 char uuid[MAX_UUIDSIZE]; 233 int64_t time; 234 NormalizedCoords delta; 235 DeviceFloatCoords delta_raw; 236 DeviceCoords absolute; 237 DiscreteCoords discrete; 238 int32_t button; 239 int32_t seat_button_count; 240 enum BUTTON_STATE state; 241 enum POINTER_AXIS_SOURCE source; 242 enum POINTER_AXIS axis; 243 }; 244 245 struct Pointer { 246 DeviceCoords absolute; 247 }; 248 249 struct TabletAxes { 250 DeviceCoords point; 251 NormalizedCoords delta; 252 double distance; 253 double pressure; 254 TiltDegrees tilt; 255 double rotation; 256 double slider; 257 double wheel; 258 int32_t wheel_discrete; 259 PhysEllipsis size; 260 }; 261 262 struct TabletTool { 263 uint32_t serial; 264 uint32_t tool_id; 265 enum TABLE_TOOL_TYPE type; 266 }; 267 268 struct EventTabletTool { 269 int32_t deviceId; 270 char physical[MAX_DEVICENAME]; 271 char deviceName[MAX_DEVICENAME]; 272 DEVICE_TYPE deviceType; 273 int32_t eventType; 274 char uuid[MAX_UUIDSIZE]; 275 uint32_t button; 276 enum BUTTON_STATE state; 277 uint32_t seat_button_count; 278 int64_t time; 279 TabletAxes axes; 280 TabletTool tool; 281 enum TABLE_TOOL_PROXIMITY_STATE proximity_state; 282 enum TABLE_TOOL_TIP_STATE tip_state; 283 }; 284 285 struct EventTouch { 286 int32_t deviceId; 287 char physical[MAX_DEVICENAME]; 288 char deviceName[MAX_DEVICENAME]; 289 char uuid[MAX_UUIDSIZE]; 290 int32_t eventType; 291 int64_t time; 292 int32_t slot; 293 int32_t seatSlot; 294 DeviceCoords point; 295 DEVICE_TYPE deviceType; 296 double pressure; 297 double area; 298 }; 299 300 struct SlotedCoords { 301 bool isActive; 302 float x; 303 float y; 304 }; 305 306 struct SlotedCoordsInfo { 307 SlotedCoords coords[MAX_SOLTED_COORDS_NUMS]; 308 uint32_t activeCount; 309 }; 310 311 struct EventGesture { 312 int32_t deviceId; 313 char physical[MAX_DEVICENAME]; 314 char deviceName[MAX_DEVICENAME]; 315 DEVICE_TYPE deviceType; 316 int32_t eventType; 317 char uuid[MAX_UUIDSIZE]; 318 int64_t time; 319 int32_t fingerCount; 320 int32_t cancelled; 321 NormalizedCoords delta; 322 NormalizedCoords deltaUnaccel; 323 SlotedCoordsInfo soltTouches; 324 double scale; 325 double angle; 326 int32_t pointerEventType; 327 }; 328 329 struct RawInputEvent { 330 uint32_t stamp; 331 uint32_t ev_type; 332 uint32_t ev_code; 333 uint32_t ev_value; 334 }; 335 336 struct TestSurfaceData { 337 int32_t screenId; 338 int32_t onLayerId; 339 int32_t surfaceId; 340 int32_t opacity; 341 int32_t visibility; 342 int32_t srcX; 343 int32_t srcY; 344 int32_t srcW; 345 int32_t srcH; 346 }; 347 348 struct VirtualKey { 349 bool isPressed; 350 int32_t keyCode; 351 int32_t keyDownDuration; 352 bool isIntercepted {true}; 353 }; 354 355 struct DeviceManage { 356 uint32_t deviceId; 357 char physical[MAX_DEVICENAME]; 358 char deviceName[MAX_DEVICENAME]; 359 DEVICE_TYPE deviceType; 360 int32_t eventType; 361 char uuid[MAX_UUIDSIZE]; 362 }; 363 364 struct EventTabletPad { 365 uint32_t deviceId; 366 char physical[MAX_DEVICENAME]; 367 char deviceName[MAX_DEVICENAME]; 368 DEVICE_TYPE deviceType; 369 int32_t eventType; 370 char uuid[MAX_UUIDSIZE]; 371 int64_t time; 372 uint32_t mode; 373 struct { 374 uint32_t number; 375 enum BUTTON_STATE state; 376 } button; 377 struct { 378 uint32_t code; 379 enum KEY_STATE state; 380 } key; 381 struct { 382 enum TABLET_PAD_RING_AXIS_SOURCE source; 383 double position; 384 int32_t number; 385 } ring; 386 struct { 387 enum TABLET_PAD_STRIP_AXIS_SOURCE source; 388 double position; 389 int32_t number; 390 } strip; 391 }; 392 } // namespace MMI 393 } // namespace OHOS 394 395 #endif // STRUCT_MULTIMODAL_H