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 LIBINPUT_H
17#define LIBINPUT_H
18
19#include <stdint.h>
20
21#include "libudev.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27enum libinput_event_type {
28    LIBINPUT_EVENT_NONE = 0,
29
30    LIBINPUT_EVENT_KEYBOARD_KEY = 300,
31
32    LIBINPUT_EVENT_POINTER_TAP,
33    LIBINPUT_EVENT_POINTER_AXIS,
34    LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD,
35    LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD,
36    LIBINPUT_EVENT_POINTER_BUTTON,
37    LIBINPUT_EVENT_POINTER_MOTION,
38    LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE,
39
40    LIBINPUT_EVENT_TOUCH_DOWN = 500,
41    LIBINPUT_EVENT_TOUCH_UP,
42    LIBINPUT_EVENT_TOUCH_MOTION,
43    LIBINPUT_EVENT_TOUCH_CANCEL,
44    LIBINPUT_EVENT_TOUCH_FRAME,
45
46    LIBINPUT_EVENT_TOUCHPAD_DOWN = 550,
47    LIBINPUT_EVENT_TOUCHPAD_UP,
48    LIBINPUT_EVENT_TOUCHPAD_MOTION,
49
50    LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN = 800,
51    LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
52    LIBINPUT_EVENT_GESTURE_SWIPE_END,
53    LIBINPUT_EVENT_GESTURE_PINCH_BEGIN,
54    LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
55    LIBINPUT_EVENT_GESTURE_PINCH_END,
56
57    LIBINPUT_EVENT_TABLET_TOOL_AXIS,
58    LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY,
59    LIBINPUT_EVENT_TABLET_TOOL_TIP,
60};
61
62enum libinput_key_state {
63    LIBINPUT_KEY_STATE_RELEASED = 0,
64    LIBINPUT_KEY_STATE_PRESSED = 1
65};
66
67enum libinput_tablet_tool_tip_state {
68    LIBINPUT_TABLET_TOOL_TIP_UP = 0,
69    LIBINPUT_TABLET_TOOL_TIP_DOWN = 1,
70};
71
72enum libinput_button_state {
73    LIBINPUT_BUTTON_STATE_RELEASED = 0,
74    LIBINPUT_BUTTON_STATE_PRESSED = 1
75};
76
77enum libinput_pointer_axis_source {
78    LIBINPUT_POINTER_AXIS_SOURCE_WHEEL = 1,
79    LIBINPUT_POINTER_AXIS_SOURCE_FINGER,
80    LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS,
81    LIBINPUT_POINTER_AXIS_SOURCE_WHEEL_TILT,
82};
83
84enum libinput_device_capability {
85    LIBINPUT_DEVICE_CAP_KEYBOARD = 0,
86    LIBINPUT_DEVICE_CAP_POINTER = 1,
87    LIBINPUT_DEVICE_CAP_TOUCH = 2,
88    LIBINPUT_DEVICE_CAP_TABLET_TOOL = 3,
89    LIBINPUT_DEVICE_CAP_TABLET_PAD = 4,
90    LIBINPUT_DEVICE_CAP_GESTURE = 5,
91    LIBINPUT_DEVICE_CAP_SWITCH = 6,
92    LIBINPUT_DEVICE_CAP_JOYSTICK = 7,
93};
94
95enum evdev_device_udev_tags {
96    EVDEV_UDEV_TAG_INPUT = 1 << 0,
97    EVDEV_UDEV_TAG_KEYBOARD = 1 << 1,
98    EVDEV_UDEV_TAG_MOUSE = 1 << 2,
99    EVDEV_UDEV_TAG_TOUCHPAD = 1 << 3,
100    EVDEV_UDEV_TAG_TOUCHSCREEN = 1 << 4,
101    EVDEV_UDEV_TAG_TABLET = 1 << 5,
102    EVDEV_UDEV_TAG_JOYSTICK = 1 << 6,
103    EVDEV_UDEV_TAG_ACCELEROMETER = 1 << 7,
104    EVDEV_UDEV_TAG_TABLET_PAD = 1 << 8,
105    EVDEV_UDEV_TAG_POINTINGSTICK = 1 << 9,
106    EVDEV_UDEV_TAG_TRACKBALL = 1 << 10,
107    EVDEV_UDEV_TAG_SWITCH = 1 << 11,
108};
109
110enum libinput_tablet_tool_type {
111    LIBINPUT_TABLET_TOOL_TYPE_PEN = 1,
112    LIBINPUT_TABLET_TOOL_TYPE_ERASER,
113    LIBINPUT_TABLET_TOOL_TYPE_BRUSH,
114    LIBINPUT_TABLET_TOOL_TYPE_PENCIL,
115    LIBINPUT_TABLET_TOOL_TYPE_AIRBRUSH,
116    LIBINPUT_TABLET_TOOL_TYPE_MOUSE,
117    LIBINPUT_TABLET_TOOL_TYPE_LENS,
118    LIBINPUT_TABLET_TOOL_TYPE_TOTEM,
119};
120
121enum libinput_pointer_axis {
122	LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL = 0,
123	LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL = 1,
124};
125
126struct udev_device;
127struct libinput_device;
128struct libinput_event;
129struct libinput_event_keyboard;
130struct libinput_event_pointer;
131struct libinput_event_touch;
132struct libinput_event_tablet_tool;
133struct libinput_event_gesture;
134struct libinput_tablet_tool;
135
136enum libinput_event_type libinput_event_get_type(struct libinput_event *event);
137
138int32_t libinput_event_tablet_tool_get_tool_type(struct libinput_event_tablet_tool *event);
139
140struct libinput_tablet_tool* libinput_event_tablet_tool_get_tool(struct libinput_event_tablet_tool *event);
141
142enum libinput_tablet_tool_type libinput_tablet_tool_get_type(struct libinput_tablet_tool *tool);
143
144enum libinput_tablet_tool_tip_state libinput_event_tablet_tool_get_tip_state(struct libinput_event_tablet_tool *event);
145
146enum libinput_pointer_axis_source libinput_event_pointer_get_axis_source(struct libinput_event_pointer *event);
147
148double libinput_event_tablet_tool_get_tilt_x(struct libinput_event_tablet_tool *event);
149
150double libinput_event_tablet_tool_get_tilt_y(struct libinput_event_tablet_tool *event);
151
152uint64_t libinput_event_tablet_tool_get_time_usec(struct libinput_event_tablet_tool *event);
153
154double libinput_event_tablet_tool_get_pressure(struct libinput_event_tablet_tool *event);
155
156struct libinput_device* libinput_event_get_device(struct libinput_event *event);
157
158uint64_t libinput_event_get_sensortime(struct libinput_event *event);
159
160struct libinput_event_keyboard* libinput_event_get_keyboard_event(struct libinput_event *event);
161
162struct libinput_event_pointer* libinput_event_get_pointer_event(struct libinput_event *event);
163
164struct libinput_event_touch* libinput_event_get_touch_event(struct libinput_event *event);
165
166struct libinput_event_touch* libinput_event_get_touchpad_event(struct libinput_event *event);
167
168struct libinput_event_gesture* libinput_event_get_gesture_event(struct libinput_event *event);
169
170struct libinput_event_tablet_tool* libinput_event_get_tablet_tool_event(struct libinput_event *event);
171
172uint64_t libinput_event_keyboard_get_time_usec(struct libinput_event_keyboard *event);
173
174uint32_t libinput_event_keyboard_get_key(struct libinput_event_keyboard *event);
175
176int libinput_device_keyboard_has_key(struct libinput_device *device, uint32_t code);
177
178enum libinput_key_state libinput_event_keyboard_get_key_state(struct libinput_event_keyboard *event);
179
180enum libinput_button_state libinput_event_pointer_get_button_state(struct libinput_event_pointer *event);
181
182uint64_t libinput_event_touch_get_time_usec(struct libinput_event_touch *event);
183
184int32_t libinput_event_touch_get_seat_slot(struct libinput_event_touch *event);
185
186double libinput_event_touch_get_pressure(struct libinput_event_touch* event);
187
188int32_t libinput_event_touch_get_move_flag(struct libinput_event_touch* event);
189
190int32_t libinput_event_get_touch_contact_long_axis(struct libinput_event_touch *event);
191
192int32_t libinput_event_get_touch_contact_short_axis(struct libinput_event_touch *event);
193
194int32_t libinput_event_touch_get_tool_type(struct libinput_event_touch *event);
195
196int libinput_device_touch_btn_tool_type_down(struct libinput_device *device, int32_t btnToolType);
197
198double libinput_event_touch_get_x_transformed(struct libinput_event_touch *event, uint32_t width);
199
200double libinput_event_touch_get_y_transformed(struct libinput_event_touch *event, uint32_t height);
201
202double libinput_event_touch_get_tool_x_transformed(struct libinput_event_touch *event, uint32_t width);
203
204double libinput_event_touch_get_tool_y_transformed(struct libinput_event_touch *event, uint32_t height);
205
206double libinput_event_touch_get_tool_width_transformed(struct libinput_event_touch *event, uint32_t width);
207
208double libinput_event_touch_get_tool_height_transformed(struct libinput_event_touch *event, uint32_t height);
209
210double libinput_event_tablet_tool_get_x_transformed(struct libinput_event_tablet_tool *event, uint32_t width);
211
212double libinput_event_tablet_tool_get_y_transformed(struct libinput_event_tablet_tool *event, uint32_t height);
213
214uint64_t libinput_event_touchpad_get_time_usec(struct libinput_event_touch *event);
215
216int32_t libinput_event_touchpad_get_seat_slot(struct libinput_event_touch *event);
217
218double libinput_event_touchpad_get_x(struct libinput_event_touch *event);
219
220double libinput_event_touchpad_get_y(struct libinput_event_touch *event);
221
222double libinput_event_touchpad_get_pressure(struct libinput_event_touch *event);
223
224int32_t libinput_event_touchpad_get_touch_contact_long_axis(struct libinput_event_touch *event);
225
226int32_t libinput_event_touchpad_get_touch_contact_short_axis(struct libinput_event_touch *event);
227
228int32_t libinput_event_touchpad_get_tool_type(struct libinput_event_touch *event);
229
230int32_t libinput_device_touchpad_btn_tool_type_down(struct libinput_device *device, int32_t btnToolType);
231
232double libinput_event_touchpad_get_tool_x(struct libinput_event_touch *event);
233
234double libinput_event_touchpad_get_tool_y(struct libinput_event_touch *event);
235
236double libinput_event_touchpad_get_tool_width(struct libinput_event_touch *event);
237
238double libinput_event_touchpad_get_tool_height(struct libinput_event_touch *event);
239
240uint32_t libinput_event_gesture_get_time(struct libinput_event_gesture *event);
241
242int libinput_event_gesture_get_finger_count(struct libinput_event_gesture *event);
243
244double libinput_event_gesture_get_scale(struct libinput_event_gesture *event);
245
246double libinput_event_gesture_get_angle_delta(struct libinput_event_gesture *event);
247
248int libinput_event_gesture_get_device_coords_x(struct libinput_event_gesture *event, uint32_t idx);
249
250int libinput_event_gesture_get_device_coords_y(struct libinput_event_gesture *event, uint32_t idx);
251
252int libinput_has_event_led_type(struct libinput_device *device);
253
254const char* libinput_device_get_name(struct libinput_device *device);
255
256unsigned int libinput_device_get_id_bustype(struct libinput_device *device);
257
258unsigned int libinput_device_get_id_version(struct libinput_device *device);
259
260unsigned int libinput_device_get_id_product(struct libinput_device *device);
261
262unsigned int libinput_device_get_id_vendor(struct libinput_device *device);
263
264const char* libinput_device_get_phys(struct libinput_device* device);
265
266const char* libinput_device_get_uniq(struct libinput_device* device);
267
268const char* libinput_device_get_sysname(struct libinput_device *device);
269
270struct udev_device* libinput_device_get_udev_device(struct libinput_device *device);
271
272enum evdev_device_udev_tags libinput_device_get_tags(struct libinput_device* device);
273
274int libinput_device_has_capability(struct libinput_device *device, enum libinput_device_capability capability);
275
276int32_t libinput_device_has_key(struct libinput_device* device, int32_t keyCode);
277
278int32_t libinput_device_get_axis_min(struct libinput_device* device, int32_t code);
279
280int32_t libinput_device_get_axis_max(struct libinput_device* device, int32_t code);
281
282int32_t libinput_device_get_axis_fuzz(struct libinput_device* device, int32_t code);
283
284int32_t libinput_device_get_axis_flat(struct libinput_device* device, int32_t code);
285
286int32_t libinput_device_get_axis_resolution(struct libinput_device* device, int32_t code);
287
288int libinput_get_funckey_state(struct libinput_device *device, unsigned int code);
289
290uint32_t libinput_event_pointer_get_finger_count(struct libinput_event_pointer *event);
291
292double libinput_event_pointer_get_dx_unaccelerated(struct libinput_event_pointer *event);
293
294double libinput_event_pointer_get_dy_unaccelerated(struct libinput_event_pointer *event);
295
296uint32_t libinput_event_pointer_get_button(struct libinput_event_pointer *event);
297
298int libinput_event_pointer_has_axis(struct libinput_event_pointer *event, enum libinput_pointer_axis axis);
299
300double libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event, enum libinput_pointer_axis axis);
301
302#ifdef __cplusplus
303}
304#endif
305#endif /* LIBINPUT_H */