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