1 /* 2 * Copyright (c) 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 EVENT_TOUCH_EVENT_H 17 #define EVENT_TOUCH_EVENT_H 18 19 #include <list> 20 #include <map> 21 #include "offset.h" 22 23 namespace OHOS::uitest { 24 using TimeStamp = std::chrono::high_resolution_clock::time_point; 25 26 struct TouchPoint final { 27 int32_t id = 0; 28 int32_t x = 0; 29 int32_t y = 0; 30 TimeStamp downTime; 31 }; 32 /** 33 * @brief TouchEvent contains the active change point and a list of all touch points. 34 */ 35 struct TouchEventInfo final { 36 // the active changed point info 37 // The ID is used to identify the point of contact between the finger and the screen. Different fingers have 38 // different ids. 39 int32_t id = 0; 40 int32_t x = 0; 41 int32_t y = 0; 42 int32_t wx = 0; 43 int32_t wy = 0; 44 // nanosecond time stamp. 45 TimeStamp time; 46 std::map<std::string, std::string> attributes; 47 std::string bundleName; 48 std::string abilityName; GetOffsetfinal49 Offset GetOffset() const 50 { 51 return Offset(x, y); 52 } Resetsfinal53 void Resets() 54 { 55 x = 0; 56 y = 0; 57 time = std::chrono::high_resolution_clock::now(); 58 } 59 }; 60 } // namespace OHOS::uitest 61 #endif // EVENT_TOUCH_EVENT_H 62