1 /*
2  * Copyright (c) 2024 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 FOUNDATION_ACE_ADAPTER_OHOS_ENTRANCE_ACE_EXTRA_INPUT_DATA_H
17 #define FOUNDATION_ACE_ADAPTER_OHOS_ENTRANCE_ACE_EXTRA_INPUT_DATA_H
18 
19 #include "input_event.h"
20 
21 #include "frameworks/core/components_ng/event/touch_event.h"
22 
23 namespace OHOS {
24 namespace Ace {
25 struct AceExtraInputData {
26     float interpolatedX = 0.f;
27     float interpolatedY = 0.f;
28     float interpolatedDisplayX = 0.f;
29     float interpolatedDisplayY = 0.f;
30     uint64_t msSinceEpoch = 0;
31 
32     AceExtraInputData() = default;
AceExtraInputDataAceExtraInputData33     AceExtraInputData(float x, float y, float displayX, float displayY, const TimeStamp& time)
34         : interpolatedX(x), interpolatedY(y), interpolatedDisplayX(displayX), interpolatedDisplayY(displayY)
35     {
36         auto stamp = std::chrono::duration_cast<std::chrono::milliseconds>(time.time_since_epoch()).count();
37         msSinceEpoch = static_cast<uint64_t>(stamp);
38     }
39     static void WriteToInput(const std::shared_ptr<MMI::InputEvent>& inputEvent, AceExtraInputData &data);
40     static void ReadToTouchEvent(const std::shared_ptr<MMI::InputEvent>& inputEvent, TouchEvent& touchEvent);
41     static void InsertInterpolatePoints(const TouchEventInfo& info);
42 };
43 
44 } // namespace Ace
45 } // namespace OHOS
46 #endif // FOUNDATION_ACE_ADAPTER_OHOS_ENTRANCE_ACE_EXTRA_INPUT_DATA_H
47