1c29fa5a6Sopenharmony_ci/*
2c29fa5a6Sopenharmony_ci * Copyright (c) 2024 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 LIBINPUT_INTERFACE_H
17c29fa5a6Sopenharmony_ci#define LIBINPUT_INTERFACE_H
18c29fa5a6Sopenharmony_ci
19c29fa5a6Sopenharmony_ci#include <memory>
20c29fa5a6Sopenharmony_ci#include <string>
21c29fa5a6Sopenharmony_ci
22c29fa5a6Sopenharmony_ci#include "libinput.h"
23c29fa5a6Sopenharmony_ci
24c29fa5a6Sopenharmony_cistruct udev_device {
25c29fa5a6Sopenharmony_ci    uint32_t tags;
26c29fa5a6Sopenharmony_ci};
27c29fa5a6Sopenharmony_ci
28c29fa5a6Sopenharmony_cistruct libinput_device {
29c29fa5a6Sopenharmony_ci    struct udev_device udevDev;
30c29fa5a6Sopenharmony_ci    unsigned int busType;
31c29fa5a6Sopenharmony_ci    unsigned int version;
32c29fa5a6Sopenharmony_ci    unsigned int product;
33c29fa5a6Sopenharmony_ci    unsigned int vendor;
34c29fa5a6Sopenharmony_ci    std::string name;
35c29fa5a6Sopenharmony_ci};
36c29fa5a6Sopenharmony_ci
37c29fa5a6Sopenharmony_cistruct libinput_event {
38c29fa5a6Sopenharmony_ci    uint64_t time;
39c29fa5a6Sopenharmony_ci    enum libinput_event_type type;
40c29fa5a6Sopenharmony_ci    libinput_device dev;
41c29fa5a6Sopenharmony_ci};
42c29fa5a6Sopenharmony_ci
43c29fa5a6Sopenharmony_cistruct libinput_event_pointer {
44c29fa5a6Sopenharmony_ci    struct libinput_event base;
45c29fa5a6Sopenharmony_ci    enum libinput_button_state buttonState;
46c29fa5a6Sopenharmony_ci};
47c29fa5a6Sopenharmony_ci
48c29fa5a6Sopenharmony_cistruct libinput_event_keyboard {
49c29fa5a6Sopenharmony_ci    struct libinput_event base;
50c29fa5a6Sopenharmony_ci    uint32_t key;
51c29fa5a6Sopenharmony_ci    enum libinput_key_state keyState;
52c29fa5a6Sopenharmony_ci};
53c29fa5a6Sopenharmony_ci
54c29fa5a6Sopenharmony_cistruct libinput_event_tablet_tool {
55c29fa5a6Sopenharmony_ci    struct libinput_event base;
56c29fa5a6Sopenharmony_ci    enum libinput_tablet_tool_tip_state tipState;
57c29fa5a6Sopenharmony_ci};
58c29fa5a6Sopenharmony_ci
59c29fa5a6Sopenharmony_cistruct libinput_tablet_tool {
60c29fa5a6Sopenharmony_ci    struct libinput_event_tablet_tool base;
61c29fa5a6Sopenharmony_ci    enum libinput_tablet_tool_type toolType;
62c29fa5a6Sopenharmony_ci};
63c29fa5a6Sopenharmony_ci
64c29fa5a6Sopenharmony_cistruct libinput_event_touch {
65c29fa5a6Sopenharmony_ci    struct libinput_event base;
66c29fa5a6Sopenharmony_ci    int32_t seatSlot;
67c29fa5a6Sopenharmony_ci    int32_t longAxis;
68c29fa5a6Sopenharmony_ci    int32_t shortAxis;
69c29fa5a6Sopenharmony_ci    int32_t toolType;
70c29fa5a6Sopenharmony_ci    double x;
71c29fa5a6Sopenharmony_ci    double y;
72c29fa5a6Sopenharmony_ci    double pressure;
73c29fa5a6Sopenharmony_ci    double toolX;
74c29fa5a6Sopenharmony_ci    double toolY;
75c29fa5a6Sopenharmony_ci    double toolWidth;
76c29fa5a6Sopenharmony_ci    double toolHeight;
77c29fa5a6Sopenharmony_ci};
78c29fa5a6Sopenharmony_ci
79c29fa5a6Sopenharmony_cistruct device_coords {
80c29fa5a6Sopenharmony_ci    int32_t x;
81c29fa5a6Sopenharmony_ci    int32_t y;
82c29fa5a6Sopenharmony_ci};
83c29fa5a6Sopenharmony_ci
84c29fa5a6Sopenharmony_ciconstexpr uint32_t N_GESTURE_DEVICE_COORDS { 5 };
85c29fa5a6Sopenharmony_ci
86c29fa5a6Sopenharmony_cistruct libinput_event_gesture {
87c29fa5a6Sopenharmony_ci    struct libinput_event base;
88c29fa5a6Sopenharmony_ci    double scale;
89c29fa5a6Sopenharmony_ci    double angle;
90c29fa5a6Sopenharmony_ci    struct device_coords coords[N_GESTURE_DEVICE_COORDS];
91c29fa5a6Sopenharmony_ci};
92c29fa5a6Sopenharmony_ci
93c29fa5a6Sopenharmony_ci
94c29fa5a6Sopenharmony_cinamespace OHOS {
95c29fa5a6Sopenharmony_cinamespace MMI {
96c29fa5a6Sopenharmony_ci
97c29fa5a6Sopenharmony_ciclass LibinputInterface {
98c29fa5a6Sopenharmony_cipublic:
99c29fa5a6Sopenharmony_ci    LibinputInterface();
100c29fa5a6Sopenharmony_ci    virtual ~LibinputInterface() = default;
101c29fa5a6Sopenharmony_ci
102c29fa5a6Sopenharmony_ci    virtual enum libinput_event_type GetEventType(struct libinput_event *event) = 0;
103c29fa5a6Sopenharmony_ci    virtual struct libinput_device* GetDevice(struct libinput_event *event) = 0;
104c29fa5a6Sopenharmony_ci    virtual uint64_t GetSensorTime(struct libinput_event *event) = 0;
105c29fa5a6Sopenharmony_ci    virtual struct libinput_event_touch* GetTouchEvent(struct libinput_event *event) = 0;
106c29fa5a6Sopenharmony_ci    virtual struct libinput_event_tablet_tool* GetTabletToolEvent(struct libinput_event *event) = 0;
107c29fa5a6Sopenharmony_ci    virtual struct libinput_event_gesture* GetGestureEvent(struct libinput_event *event) = 0;
108c29fa5a6Sopenharmony_ci    virtual struct libinput_tablet_tool* TabletToolGetTool(struct libinput_event_tablet_tool *event) = 0;
109c29fa5a6Sopenharmony_ci    virtual enum libinput_tablet_tool_tip_state TabletToolGetTipState(struct libinput_event_tablet_tool *event) = 0;
110c29fa5a6Sopenharmony_ci    virtual enum libinput_tablet_tool_type TabletToolGetType(struct libinput_tablet_tool *tool) = 0;
111c29fa5a6Sopenharmony_ci    virtual enum libinput_pointer_axis_source GetAxisSource(struct libinput_event_pointer *event) = 0;
112c29fa5a6Sopenharmony_ci    virtual struct libinput_event_pointer* LibinputGetPointerEvent(struct libinput_event *event) = 0;
113c29fa5a6Sopenharmony_ci    virtual int32_t TabletToolGetToolType(struct libinput_event_tablet_tool *event) = 0;
114c29fa5a6Sopenharmony_ci    virtual double TabletToolGetTiltX(struct libinput_event_tablet_tool *event) = 0;
115c29fa5a6Sopenharmony_ci    virtual double TabletToolGetTiltY(struct libinput_event_tablet_tool *event) = 0;
116c29fa5a6Sopenharmony_ci    virtual uint64_t TabletToolGetTimeUsec(struct libinput_event_tablet_tool *event) = 0;
117c29fa5a6Sopenharmony_ci    virtual double TabletToolGetPressure(struct libinput_event_tablet_tool *event) = 0;
118c29fa5a6Sopenharmony_ci    virtual uint64_t TouchEventGetTime(struct libinput_event_touch *event) = 0;
119c29fa5a6Sopenharmony_ci    virtual int32_t TouchEventGetSeatSlot(struct libinput_event_touch *event) = 0;
120c29fa5a6Sopenharmony_ci    virtual double TouchEventGetPressure(struct libinput_event_touch* event) = 0;
121c29fa5a6Sopenharmony_ci    virtual int32_t TouchEventGetMoveFlag(struct libinput_event_touch* event) = 0;
122c29fa5a6Sopenharmony_ci    virtual int32_t TouchEventGetContactLongAxis(struct libinput_event_touch *event) = 0;
123c29fa5a6Sopenharmony_ci    virtual int32_t TouchEventGetContactShortAxis(struct libinput_event_touch *event) = 0;
124c29fa5a6Sopenharmony_ci    virtual int32_t TouchEventGetToolType(struct libinput_event_touch *event) = 0;
125c29fa5a6Sopenharmony_ci    virtual int TouchEventGetBtnToolTypeDown(struct libinput_device *device, int32_t btnToolType) = 0;
126c29fa5a6Sopenharmony_ci    virtual uint32_t GestureEventGetTime(struct libinput_event_gesture *event) = 0;
127c29fa5a6Sopenharmony_ci    virtual int GestureEventGetFingerCount(struct libinput_event_gesture *event) = 0;
128c29fa5a6Sopenharmony_ci    virtual int GestureEventGetDevCoordsX(struct libinput_event_gesture *event, uint32_t idx) = 0;
129c29fa5a6Sopenharmony_ci    virtual int GestureEventGetDevCoordsY(struct libinput_event_gesture *event, uint32_t idx) = 0;
130c29fa5a6Sopenharmony_ci    virtual uint32_t PointerEventGetFingerCount(struct libinput_event_pointer *event) = 0;
131c29fa5a6Sopenharmony_ci    virtual double PointerGetDxUnaccelerated(struct libinput_event_pointer *event) = 0;
132c29fa5a6Sopenharmony_ci    virtual double PointerGetDyUnaccelerated(struct libinput_event_pointer *event) = 0;
133c29fa5a6Sopenharmony_ci    virtual uint32_t PointerGetButton(struct libinput_event_pointer *event) = 0;
134c29fa5a6Sopenharmony_ci    virtual int PointerHasAxis(struct libinput_event_pointer *event, enum libinput_pointer_axis axis) = 0;
135c29fa5a6Sopenharmony_ci    virtual double PointerGetAxisValue(struct libinput_event_pointer *event, enum libinput_pointer_axis axis) = 0;
136c29fa5a6Sopenharmony_ci    virtual struct libinput_event_touch* GetTouchpadEvent(struct libinput_event *event) = 0;
137c29fa5a6Sopenharmony_ci    virtual int32_t TouchpadGetTool(struct libinput_event_touch *event) = 0;
138c29fa5a6Sopenharmony_ci    virtual char* DeviceGetName(struct libinput_device *device) = 0;
139c29fa5a6Sopenharmony_ci    virtual struct libinput_event_keyboard* LibinputEventGetKeyboardEvent (struct libinput_event *event) = 0;
140c29fa5a6Sopenharmony_ci    virtual uint32_t LibinputEventKeyboardGetKey (struct libinput_event_keyboard *event) = 0;
141c29fa5a6Sopenharmony_ci    virtual enum libinput_key_state LibinputEventKeyboardGetKeyState (struct libinput_event_keyboard *event) = 0;
142c29fa5a6Sopenharmony_ci};
143c29fa5a6Sopenharmony_ci} // namespace MMI
144c29fa5a6Sopenharmony_ci} // namespace OHOS
145c29fa5a6Sopenharmony_ci#endif // LIBINPUT_INTERFACE_H