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 16 #ifndef STRUCT_MULTIMODAL_H 17 #define STRUCT_MULTIMODAL_H 18 19 #include <string> 20 #include "proto.h" 21 22 namespace OHOS { 23 namespace MMI { 24 inline constexpr int32_t MAX_DEVICENAME { 64 }; 25 inline constexpr int32_t MAX_UUIDSIZE { 64 }; 26 inline constexpr int32_t SYSTEMUID { 1000 }; 27 inline constexpr int32_t MAX_SOLTED_COORDS_NUMS { 10 }; 28 inline constexpr double SINGLE_KNUCKLE_ABS_PRESSURE_VALUE = 254.0 / 255; 29 inline constexpr double DOUBLE_KNUCKLE_ABS_PRESSURE_VALUE { 1.000000 }; 30 inline constexpr double LEFT_SILDE_UP_ABS_PRESSURE_VALUE = 249.0 / 255; 31 inline constexpr double LEFT_SILDE_DOWN_ABS_PRESSURE_VALUE = 250.0 / 255; 32 inline constexpr double RIGHT_SILDE_UP_ABS_PRESSURE_VALUE = 251.0 / 255; 33 inline constexpr double RIGHT_SILDE_DOWN_ABS_PRESSURE_VALUE = 252.0 / 255; 34 inline constexpr double SYNC_TOUCHPAD_SETTINGS = 253.0 / 255; 35 36 enum KNUCKLE_DOUBLE_CLICK_EVENT_TYPE { 37 KNUCKLE_1F_DOUBLE_CLICK = 254, 38 KNUCKLE_2F_DOUBLE_CLICK, 39 }; 40 41 enum SENIOR_DEVICE_TYPE { 42 INPUT_DEVICE_AISENSOR = 31, 43 INPUT_DEVICE_KNUCKLE = 41 44 }; 45 46 enum DEVICE_TYPE { 47 DEVICE_TYPE_UNKNOWN = -1, 48 DEVICE_TYPE_TOUCH_PANEL = 0, 49 DEVICE_TYPE_KEYBOARD = 1, 50 DEVICE_TYPE_MOUSE = 2, 51 DEVICE_TYPE_STYLUS = 3, 52 DEVICE_TYPE_BUILTIN_KEY = 4, 53 DEVICE_TYPE_ROTATION = 5, 54 DEVICE_TYPE_AI_SPEECH = 6, 55 DEVICE_TYPE_JOYSTICK = 7, 56 DEVICE_TYPE_TOUCHPAD = 8, 57 DEVICE_TYPE_KNUCKLE = 9, 58 DEVICE_TYPE_VIRTUAL_KEYBOARD = 10, 59 }; 60 61 enum BUTTON_STATE { 62 BUTTON_STATE_RELEASED = 0, 63 BUTTON_STATE_PRESSED = 1 64 }; 65 66 enum KEY_STATE { 67 KEY_STATE_RELEASED, 68 KEY_STATE_PRESSED 69 }; 70 71 enum POINTER_AXIS { 72 POINTER_AXIS_SCROLL_VERTICAL = 0, 73 POINTER_AXIS_SCROLL_HORIZONTAL = 1, 74 }; 75 76 enum POINTER_AXIS_SOURCE { 77 POINTER_AXIS_SOURCE_WHEEL = 1, 78 POINTER_AXIS_SOURCE_FINGER, 79 POINTER_AXIS_SOURCE_CONTINUOUS, 80 POINTER_AXIS_SOURCE_WHEEL_TILT, 81 }; 82 83 enum TABLE_TOOL_TYPE { 84 TABLET_TOOL_TYPE_PEN = 1, 85 TABLET_TOOL_TYPE_ERASER, 86 TABLET_TOOL_TYPE_BRUSH, 87 TABLET_TOOL_TYPE_PENCIL, 88 TABLET_TOOL_TYPE_AIRBRUSH, 89 TABLET_TOOL_TYPE_MOUSE, 90 TABLET_TOOL_TYPE_LENS, 91 TABLET_TOOL_TYPE_TOTEM, 92 }; 93 94 enum TABLE_TOOL_PROXIMITY_STATE { 95 TABLET_TOOL_PROXIMITY_STATE_OUT = 0, 96 TABLET_TOOL_PROXIMITY_STATE_IN = 1, 97 }; 98 99 enum TABLE_TOOL_TIP_STATE { 100 TABLET_TOOL_TIP_UP = 0, 101 TABLET_TOOL_TIP_DOWN = 1, 102 }; 103 104 enum POINT_EVENT_TYPE { 105 EVENT_TYPE_INVALID = 0, 106 PRIMARY_POINT_DOWN = 1, 107 PRIMARY_POINT_UP = 2, 108 POINT_MOVE = 3, 109 OTHER_POINT_DOWN = 4, 110 OTHER_POINT_UP = 5, 111 }; 112 113 enum TABLET_PAD_RING_AXIS_SOURCE { 114 TABLET_PAD_RING_SOURCE_UNKNOWN = 1, 115 TABLET_PAD_RING_SOURCE_FINGER, 116 }; 117 118 enum TABLET_PAD_STRIP_AXIS_SOURCE { 119 TABLET_PAD_STRIP_SOURCE_UNKNOWN = 1, 120 TABLET_PAD_STRIP_SOURCE_FINGER, 121 }; 122 123 enum MOUSE_ICON { 124 DEFAULT = 0, 125 EAST = 1, 126 WEST = 2, 127 SOUTH = 3, 128 NORTH = 4, 129 WEST_EAST = 5, 130 NORTH_SOUTH = 6, 131 NORTH_EAST = 7, 132 NORTH_WEST = 8, 133 SOUTH_EAST = 9, 134 SOUTH_WEST = 10, 135 NORTH_EAST_SOUTH_WEST = 11, 136 NORTH_WEST_SOUTH_EAST = 12, 137 CROSS = 13, 138 CURSOR_COPY = 14, 139 CURSOR_FORBID = 15, 140 COLOR_SUCKER = 16, 141 HAND_GRABBING = 17, 142 HAND_OPEN = 18, 143 HAND_POINTING = 19, 144 HELP = 20, 145 CURSOR_MOVE = 21, 146 RESIZE_LEFT_RIGHT = 22, 147 RESIZE_UP_DOWN = 23, 148 SCREENSHOT_CHOOSE = 24, 149 SCREENSHOT_CURSOR = 25, 150 TEXT_CURSOR = 26, 151 ZOOM_IN = 27, 152 ZOOM_OUT = 28, 153 MIDDLE_BTN_EAST = 29, 154 MIDDLE_BTN_WEST = 30, 155 MIDDLE_BTN_SOUTH = 31, 156 MIDDLE_BTN_NORTH = 32, 157 MIDDLE_BTN_NORTH_SOUTH = 33, 158 MIDDLE_BTN_NORTH_EAST = 34, 159 MIDDLE_BTN_NORTH_WEST = 35, 160 MIDDLE_BTN_SOUTH_EAST = 36, 161 MIDDLE_BTN_SOUTH_WEST = 37, 162 MIDDLE_BTN_NORTH_SOUTH_WEST_EAST = 38, 163 HORIZONTAL_TEXT_CURSOR = 39, 164 CURSOR_CROSS = 40, 165 CURSOR_CIRCLE = 41, 166 LOADING = 42, 167 RUNNING = 43, 168 MIDDLE_BTN_EAST_WEST = 44, 169 RUNNING_LEFT = 45, 170 RUNNING_RIGHT = 46, 171 AECH_DEVELOPER_DEFINED_ICON = 47, 172 SCREENRECORDER_CURSOR = 48, 173 DEVELOPER_DEFINED_ICON = -100, 174 TRANSPARENT_ICON = -101, 175 }; 176 177 enum RightClickType { 178 TOUCHPAD_RIGHT_BUTTON = 1, 179 TOUCHPAD_LEFT_BUTTON = 2, 180 TOUCHPAD_TWO_FINGER_TAP = 3, 181 TOUCHPAD_TWO_FINGER_TAP_OR_RIGHT_BUTTON = 4, 182 TOUCHPAD_TWO_FINGER_TAP_OR_LEFT_BUTTON = 5, 183 }; 184 185 enum ICON_TYPE { 186 ANGLE_E = 0, 187 ANGLE_S = 1, 188 ANGLE_W = 2, 189 ANGLE_N = 3, 190 ANGLE_SE = 4, 191 ANGLE_NE = 5, 192 ANGLE_SW = 6, 193 ANGLE_NW = 7, 194 ANGLE_CENTER = 8, 195 ANGLE_NW_RIGHT = 9, 196 }; 197 198 enum PrimaryButton { 199 LEFT_BUTTON = 0, 200 RIGHT_BUTTON = 1, 201 }; 202 203 enum SHIELD_MODE { 204 UNSET_MODE = -1, 205 FACTORY_MODE = 0, 206 OOBE_MODE = 1, 207 }; 208 struct IconStyle { 209 int32_t alignmentWay { 0 }; 210 std::string iconPath; 211 }; 212 213 struct CursorFocus { 214 int32_t x { 0 }; 215 int32_t y { 0 }; 216 }; 217 218 #pragma pack(1) 219 struct TagPackHead { 220 MmiMessageId idMsg; 221 int32_t sizeEvent[1]; 222 }; 223 #pragma pack() 224 225 struct SeniorDeviceInfo { 226 char physical[MAX_DEVICENAME]; 227 enum SENIOR_DEVICE_TYPE seniorDeviceType; 228 }; 229 230 struct EventJoyStickAxisAbsInfo { 231 int32_t code; 232 int32_t value; 233 int32_t minimum; 234 int32_t maximum; 235 int32_t fuzz; 236 int32_t flat; 237 int32_t resolution; 238 float standardValue; 239 bool isChanged; 240 }; 241 242 struct EventJoyStickAxis { 243 int32_t deviceId; 244 char physical[MAX_DEVICENAME]; 245 char deviceName[MAX_DEVICENAME]; 246 DEVICE_TYPE deviceType; 247 int32_t eventType; 248 char uuid[MAX_UUIDSIZE]; 249 int64_t time; 250 EventJoyStickAxisAbsInfo abs_throttle; 251 EventJoyStickAxisAbsInfo abs_hat0x; 252 EventJoyStickAxisAbsInfo abs_hat0y; 253 EventJoyStickAxisAbsInfo abs_x; 254 EventJoyStickAxisAbsInfo abs_y; 255 EventJoyStickAxisAbsInfo abs_z; 256 EventJoyStickAxisAbsInfo abs_rx; 257 EventJoyStickAxisAbsInfo abs_ry; 258 EventJoyStickAxisAbsInfo abs_rz; 259 EventJoyStickAxisAbsInfo abs_wheel; 260 }; 261 262 struct PhysicalCoordinate { 263 double x {}; 264 double y {}; 265 }; 266 267 struct LogicalCoordinate { 268 int32_t x {}; 269 int32_t y {}; 270 }; 271 272 struct NormalizedCoords { 273 double x {}; 274 double y {}; 275 }; 276 277 struct MMICoordinate2D { 278 double x { 0.0f }; 279 double y { 0.0f }; 280 }; 281 282 using GlobalCoords = MMICoordinate2D; 283 284 struct LogicalRectangle { 285 LogicalCoordinate point; 286 int32_t width; 287 int32_t height; 288 }; 289 290 struct TiltDegrees { 291 double x {}; 292 double y {}; 293 }; 294 295 struct PhysEllipsis { 296 double major {}; 297 double minor {}; 298 }; 299 300 struct Threshold { 301 int32_t upper {}; 302 int32_t lower {}; 303 }; 304 305 struct WinInfo { 306 int32_t windowPid {}; 307 int32_t windowId {}; 308 }; 309 310 struct RegisteredEvent { 311 int32_t deviceId {}; 312 char uuid[MAX_UUIDSIZE] {}; 313 int32_t eventType {}; 314 int64_t occurredTime {}; 315 DEVICE_TYPE deviceType; 316 char physical[MAX_DEVICENAME] {}; 317 }; 318 319 struct StandardTouchStruct { 320 int64_t time {}; 321 uint32_t msgType {}; 322 int32_t buttonType {}; 323 int32_t buttonCount {}; 324 int32_t buttonState {}; 325 int32_t reRventType {}; 326 int32_t curRventType {}; 327 int32_t tipState {}; 328 double x {}; 329 double y {}; 330 }; 331 332 struct EventKeyboard { 333 int32_t deviceId {}; 334 char physical[MAX_DEVICENAME] {}; 335 char deviceName[MAX_DEVICENAME] {}; 336 DEVICE_TYPE deviceType; 337 int32_t eventType {}; 338 char uuid[MAX_UUIDSIZE] {}; 339 int64_t time {}; 340 int32_t key {}; 341 uint32_t seat_key_count {}; 342 enum KEY_STATE state; 343 int32_t unicode {}; 344 bool isIntercepted { true }; 345 }; 346 347 struct EventPointer { 348 int32_t deviceId {}; 349 char physical[MAX_DEVICENAME] {}; 350 char deviceName[MAX_DEVICENAME] {}; 351 DEVICE_TYPE deviceType; 352 int32_t eventType {}; 353 char uuid[MAX_UUIDSIZE] {}; 354 int64_t time {}; 355 NormalizedCoords delta; 356 PhysicalCoordinate deltaRaw; 357 PhysicalCoordinate absolute; 358 PhysicalCoordinate discrete; 359 int32_t button {}; 360 int32_t seatButtonCount {}; 361 enum BUTTON_STATE state; 362 enum POINTER_AXIS_SOURCE source; 363 enum POINTER_AXIS axis; 364 }; 365 366 struct Pointer { 367 PhysicalCoordinate absolute; 368 }; 369 370 struct TabletAxes { 371 PhysicalCoordinate point; 372 NormalizedCoords delta; 373 double distance {}; 374 double pressure {}; 375 TiltDegrees tilt; 376 double rotation {}; 377 double slider {}; 378 double wheel {}; 379 int32_t wheel_discrete {}; 380 PhysEllipsis size; 381 }; 382 383 struct TabletTool { 384 uint32_t serial {}; 385 uint32_t tool_id {}; 386 enum TABLE_TOOL_TYPE type; 387 }; 388 389 struct EventTabletTool { 390 int32_t deviceId {}; 391 char physical[MAX_DEVICENAME] {}; 392 char deviceName[MAX_DEVICENAME] {}; 393 DEVICE_TYPE deviceType; 394 int32_t eventType {}; 395 char uuid[MAX_UUIDSIZE] {}; 396 uint32_t button {}; 397 enum BUTTON_STATE state; 398 uint32_t seat_button_count {}; 399 int64_t time {}; 400 TabletAxes axes; 401 TabletTool tool; 402 enum TABLE_TOOL_PROXIMITY_STATE proximity_state; 403 enum TABLE_TOOL_TIP_STATE tip_state; 404 }; 405 406 struct EventTouch { 407 int32_t deviceId {}; 408 char physical[MAX_DEVICENAME] {}; 409 char deviceName[MAX_DEVICENAME] {}; 410 char uuid[MAX_UUIDSIZE] {}; 411 int32_t eventType {}; 412 int64_t time {}; 413 int32_t slot {}; 414 int32_t seatSlot {}; 415 PhysicalCoordinate coordF {}; 416 LogicalCoordinate point {}; 417 GlobalCoords globalCoord {}; // 全局坐标 418 LogicalRectangle toolRect {}; 419 DEVICE_TYPE deviceType { DEVICE_TYPE::DEVICE_TYPE_UNKNOWN }; 420 double pressure {}; 421 double area {}; 422 }; 423 424 struct SlotedCoords { 425 bool isActive {}; 426 float x {}; 427 float y {}; 428 }; 429 430 struct SlotedCoordsInfo { 431 SlotedCoords coords[MAX_SOLTED_COORDS_NUMS]; 432 uint32_t activeCount {}; 433 }; 434 435 struct EventGesture { 436 int32_t deviceId {}; 437 char physical[MAX_DEVICENAME] {}; 438 char deviceName[MAX_DEVICENAME] {}; 439 DEVICE_TYPE deviceType; 440 int32_t eventType {}; 441 char uuid[MAX_UUIDSIZE] {}; 442 int64_t time {}; 443 int32_t fingerCount {}; 444 int32_t cancelled {}; 445 NormalizedCoords delta; 446 NormalizedCoords deltaUnaccel; 447 SlotedCoordsInfo soltTouches; 448 double scale {}; 449 double angle {}; 450 int32_t pointerEventType {}; 451 }; 452 453 struct RawInputEvent { 454 uint32_t stamp {}; 455 uint32_t ev_type {}; 456 uint32_t ev_code {}; 457 uint32_t ev_value {}; 458 }; 459 460 struct TestSurfaceData { 461 int32_t screenId {}; 462 int32_t onLayerId {}; 463 int32_t surfaceId {}; 464 int32_t opacity {}; 465 int32_t visibility {}; 466 int32_t srcX {}; 467 int32_t srcY {}; 468 int32_t srcW {}; 469 int32_t srcH {}; 470 }; 471 472 struct VirtualKey { 473 bool isPressed {}; 474 int32_t keyCode {}; 475 int64_t keyDownDuration {}; 476 bool isIntercepted { true }; 477 }; 478 479 struct DeviceManage { 480 uint32_t deviceId {}; 481 char physical[MAX_DEVICENAME] {}; 482 char deviceName[MAX_DEVICENAME] {}; 483 DEVICE_TYPE deviceType; 484 int32_t eventType {}; 485 char uuid[MAX_UUIDSIZE] {}; 486 }; 487 488 struct EventTabletPad { 489 uint32_t deviceId {}; 490 char physical[MAX_DEVICENAME] {}; 491 char deviceName[MAX_DEVICENAME] {}; 492 DEVICE_TYPE deviceType; 493 int32_t eventType {}; 494 char uuid[MAX_UUIDSIZE] {}; 495 int64_t time {}; 496 uint32_t mode {}; 497 struct { 498 uint32_t number {}; 499 enum BUTTON_STATE state; 500 } button; 501 struct { 502 uint32_t code {}; 503 enum KEY_STATE state; 504 } key; 505 struct { 506 enum TABLET_PAD_RING_AXIS_SOURCE source; 507 double position {}; 508 int32_t number {}; 509 } ring; 510 struct { 511 enum TABLET_PAD_STRIP_AXIS_SOURCE source; 512 double position {}; 513 int32_t number {}; 514 } strip; 515 }; 516 } // namespace MMI 517 } // namespace OHOS 518 #endif // STRUCT_MULTIMODAL_H 519