1c29fa5a6Sopenharmony_ci/*
2c29fa5a6Sopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3c29fa5a6Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4c29fa5a6Sopenharmony_ci * you may not use this file except in compliance with the License.
5c29fa5a6Sopenharmony_ci * You may obtain a copy of the License at
6c29fa5a6Sopenharmony_ci *
7c29fa5a6Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0
8c29fa5a6Sopenharmony_ci *
9c29fa5a6Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10c29fa5a6Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11c29fa5a6Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12c29fa5a6Sopenharmony_ci * See the License for the specific language governing permissions and
13c29fa5a6Sopenharmony_ci * limitations under the License.
14c29fa5a6Sopenharmony_ci */
15c29fa5a6Sopenharmony_ci
16c29fa5a6Sopenharmony_ci#ifndef PROCESSING_PEN_DEVICE_H
17c29fa5a6Sopenharmony_ci#define PROCESSING_PEN_DEVICE_H
18c29fa5a6Sopenharmony_ci
19c29fa5a6Sopenharmony_ci#include "device_base.h"
20c29fa5a6Sopenharmony_ci#include "msg_head.h"
21c29fa5a6Sopenharmony_ci
22c29fa5a6Sopenharmony_cinamespace OHOS {
23c29fa5a6Sopenharmony_cinamespace MMI {
24c29fa5a6Sopenharmony_ciclass ProcessingPenDevice : public DeviceBase {
25c29fa5a6Sopenharmony_ci    struct PenEvent {
26c29fa5a6Sopenharmony_ci        std::string eventType;
27c29fa5a6Sopenharmony_ci        int32_t xPos { 0 };
28c29fa5a6Sopenharmony_ci        int32_t yPos { 0 };
29c29fa5a6Sopenharmony_ci        int32_t tiltX { 0 };
30c29fa5a6Sopenharmony_ci        int32_t tiltY { 0 };
31c29fa5a6Sopenharmony_ci        int32_t pressure { 0 };
32c29fa5a6Sopenharmony_ci        int32_t distance { 0 };
33c29fa5a6Sopenharmony_ci        int32_t keyValue { 0 };
34c29fa5a6Sopenharmony_ci        int32_t keyStatus { 0 };
35c29fa5a6Sopenharmony_ci    };
36c29fa5a6Sopenharmony_cipublic:
37c29fa5a6Sopenharmony_ci    ProcessingPenDevice() = default;
38c29fa5a6Sopenharmony_ci    DISALLOW_COPY_AND_MOVE(ProcessingPenDevice);
39c29fa5a6Sopenharmony_ci    ~ProcessingPenDevice() = default;
40c29fa5a6Sopenharmony_ci    int32_t TransformJsonDataToInputData(const DeviceItem& inputEventArrays, InputEventArray& inputEventArray);
41c29fa5a6Sopenharmony_ciprivate:
42c29fa5a6Sopenharmony_ci    void TransformPenEventToInputEvent(const std::vector<PenEvent>& penEventArray, InputEventArray& inputEventArray);
43c29fa5a6Sopenharmony_ci    void SetPenApproachPadEvent(const PenEvent &penEvent, InputEventArray& inputEventArray);
44c29fa5a6Sopenharmony_ci    void SetPenSlidePadEvent(const PenEvent& penEvent, InputEventArray& inputEventArray);
45c29fa5a6Sopenharmony_ci    void SetPenLeavePadEvent(const PenEvent& penEvent, InputEventArray& inputEventArray);
46c29fa5a6Sopenharmony_ci    int32_t AnalysisPenPadEvent(const std::vector<DeviceEvent>& inputData, std::vector<PenEvent>& penEventArray);
47c29fa5a6Sopenharmony_ci    int32_t AnalysisPenApproachPadEvent(const DeviceEvent& event, std::vector<PenEvent>& penEventArray);
48c29fa5a6Sopenharmony_ci    int32_t AnalysisPenSlidePadEvent(const DeviceEvent& event, std::vector<PenEvent>& penEventArray);
49c29fa5a6Sopenharmony_ci    int32_t AnalysisPenLeavePadEvent(const DeviceEvent& event, std::vector<PenEvent>& penEventArray);
50c29fa5a6Sopenharmony_ci};
51c29fa5a6Sopenharmony_ci} // namespace MMI
52c29fa5a6Sopenharmony_ci} // namespace OHOS
53c29fa5a6Sopenharmony_ci#endif // PROCESSING_PEN_DEVICE_H