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